aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlana <none@none>2010-06-21 22:08:10 -0700
committerlana <none@none>2010-06-21 22:08:10 -0700
commit6048cc17b3db3a7a2fa986cf3d0f054cbd7e996f (patch)
tree40a0618c9173281cbf753620cca05e723795a460
parent8f9dfbf06f99413917a4a9073a1d20cef6791766 (diff)
parent005b672c17171b2e3d5763bc82eb4d91b752e724 (diff)
Merge
-rw-r--r--make/common/Defs-linux.gmk1
-rw-r--r--make/common/Defs-solaris.gmk3
-rw-r--r--make/common/Release.gmk9
-rw-r--r--make/common/shared/Defs-control.gmk3
-rw-r--r--make/docs/CORE_PKGS.gmk1
-rw-r--r--make/java/hpi/hpi_common.gmk2
-rw-r--r--make/java/java/Makefile2
-rw-r--r--make/java/java_hprof_demo/Makefile2
-rw-r--r--make/java/net/Makefile2
-rw-r--r--make/jpda/transport/socket/Makefile4
-rw-r--r--make/mkdemo/jvmti/hprof/Makefile4
-rw-r--r--make/netbeans/README4
-rw-r--r--make/netbeans/world/README4
-rw-r--r--make/netbeans/world/build.xml4
-rw-r--r--make/sun/nio/cs/Makefile2
-rw-r--r--make/sun/tools/Makefile3
-rw-r--r--src/share/classes/com/sun/java/util/jar/pack/Constants.java7
-rw-r--r--src/share/classes/com/sun/java/util/jar/pack/Package.java17
-rw-r--r--src/share/classes/com/sun/java/util/jar/pack/PropMap.java6
-rw-r--r--src/share/classes/com/sun/servicetag/Registry.java34
-rw-r--r--src/share/classes/com/sun/servicetag/resources/jdk_header.pngbin19005 -> 8705 bytes
-rw-r--r--src/share/classes/com/sun/servicetag/resources/register.html24
-rw-r--r--src/share/classes/com/sun/servicetag/resources/register_ja.html12
-rw-r--r--src/share/classes/com/sun/servicetag/resources/register_zh_CN.html12
-rw-r--r--src/share/classes/java/lang/AssertionError.java19
-rw-r--r--src/share/classes/java/lang/Math.java21
-rw-r--r--src/share/classes/java/lang/ProcessBuilder.java4
-rw-r--r--src/share/classes/java/lang/StrictMath.java21
-rw-r--r--src/share/classes/java/security/Security.java2
-rw-r--r--src/share/classes/java/util/Collections.java8
-rw-r--r--src/share/classes/java/util/concurrent/ThreadLocalRandom.java12
-rw-r--r--src/share/classes/java/util/jar/Pack200.java25
-rw-r--r--src/share/classes/sun/io/ByteToCharISO2022.java6
-rw-r--r--src/share/classes/sun/io/ByteToCharISO2022JP.java2
-rw-r--r--src/share/classes/sun/io/ByteToCharJISAutoDetect.java16
-rw-r--r--src/share/classes/sun/io/CharToBytePCK.java2
-rw-r--r--src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java17
-rw-r--r--src/share/classes/sun/nio/ch/ServerSocketAdaptor.java6
-rw-r--r--src/share/classes/sun/nio/ch/SocketAdaptor.java6
-rw-r--r--src/share/classes/sun/nio/cs/ext/DoubleByte.java4
-rw-r--r--src/share/classes/sun/nio/cs/ext/EUC_JP.java16
-rw-r--r--src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java30
-rw-r--r--src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java33
-rw-r--r--src/share/classes/sun/nio/cs/ext/EUC_TW.java2
-rw-r--r--src/share/classes/sun/nio/cs/ext/GB18030.java2
-rw-r--r--src/share/classes/sun/nio/cs/ext/HKSCS.java4
-rw-r--r--src/share/classes/sun/nio/cs/ext/ISO2022.java6
-rw-r--r--src/share/classes/sun/nio/cs/ext/JISAutoDetect.java4
-rw-r--r--src/share/classes/sun/nio/cs/ext/PCK.java12
-rw-r--r--src/share/classes/sun/nio/cs/ext/SJIS.java8
-rw-r--r--src/share/classes/sun/security/krb5/EncryptionKey.java17
-rw-r--r--src/share/classes/sun/security/krb5/KrbAsReq.java24
-rw-r--r--src/share/classes/sun/security/krb5/internal/KRBError.java26
-rw-r--r--src/share/classes/sun/security/validator/PKIXValidator.java45
-rw-r--r--src/share/classes/sun/tools/jstat/Arguments.java18
-rw-r--r--src/share/classes/sun/tools/jstat/OptionFinder.java17
-rw-r--r--src/share/classes/sun/tools/jstat/OptionLister.java11
-rw-r--r--src/share/classes/sun/tools/jstat/resources/jstat_options8
-rw-r--r--src/share/classes/sun/tools/jstat/resources/jstat_unsupported_options228
-rw-r--r--src/share/demo/jvmti/hprof/sample.makefile.txt2
-rw-r--r--src/solaris/classes/java/lang/UNIXProcess.java.linux335
-rw-r--r--src/solaris/classes/java/lang/UNIXProcess.java.solaris6
-rw-r--r--src/solaris/classes/sun/nio/cs/ext/COMPOUND_TEXT_Encoder.java13
-rw-r--r--src/solaris/classes/sun/nio/cs/ext/CompoundTextSupport.java36
-rw-r--r--src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java20
-rw-r--r--src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java16
-rw-r--r--src/windows/classes/java/lang/ProcessImpl.java6
-rw-r--r--src/windows/native/sun/nio/ch/DatagramChannelImpl.c6
-rw-r--r--src/windows/native/sun/nio/ch/Net.c24
-rw-r--r--src/windows/native/sun/nio/ch/SocketDispatcher.c30
-rw-r--r--src/windows/native/sun/nio/ch/nio_util.h8
-rw-r--r--test/Makefile8
-rw-r--r--test/ProblemList.txt413
-rw-r--r--test/com/sun/jdi/PopAndInvokeTest.java1
-rw-r--r--test/com/sun/servicetag/FindServiceTags.java12
-rw-r--r--test/com/sun/servicetag/JavaServiceTagTest1.java14
-rw-r--r--test/com/sun/servicetag/SystemRegistryTest.java10
-rw-r--r--test/com/sun/servicetag/Util.java27
-rw-r--r--test/com/sun/tools/attach/BasicTests.sh15
-rw-r--r--test/com/sun/tracing/BasicFunctionality.java1
-rw-r--r--test/java/beans/Beans/Test4080522.java1
-rw-r--r--test/java/beans/EventHandler/Test6277246.java1
-rw-r--r--test/java/beans/EventHandler/Test6277266.java1
-rw-r--r--test/java/beans/Introspector/Test6277246.java1
-rw-r--r--test/java/io/BufferedReader/BigMark.java2
-rw-r--r--test/java/io/BufferedReader/ReadLineSync.java18
-rw-r--r--test/java/io/DataInputStream/OpsAfterClose.java18
-rw-r--r--test/java/io/DataInputStream/ReadFully.java1
-rw-r--r--test/java/io/File/DeleteOnExit.java4
-rw-r--r--test/java/io/File/DeleteOnExitNPE.java3
-rw-r--r--test/java/io/File/IsHidden.java17
-rw-r--r--test/java/io/FileInputStream/LeadingSlash.java4
-rw-r--r--test/java/io/InputStream/OpsAfterClose.java30
-rw-r--r--test/java/io/InputStream/ReadParams.java1
-rw-r--r--test/java/io/InputStreamReader/GrowAfterEOF.java47
-rw-r--r--test/java/io/ObjectInputStream/ResolveProxyClass.java2
-rw-r--r--test/java/io/RandomAccessFile/EOF.java14
-rw-r--r--test/java/io/RandomAccessFile/ParameterCheck.java5
-rw-r--r--test/java/io/RandomAccessFile/ReadLine.java38
-rw-r--r--test/java/io/RandomAccessFile/Seek.java2
-rw-r--r--test/java/io/RandomAccessFile/WriteBytesChars.java5
-rw-r--r--test/java/io/RandomAccessFile/WriteUTF.java3
-rw-r--r--test/java/io/RandomAccessFile/skipBytes/SkipBytes.java20
-rw-r--r--test/java/io/Reader/Skip.java14
-rw-r--r--test/java/io/Reader/SkipNegative.java2
-rw-r--r--test/java/io/Serializable/ClassCastExceptionDetail/Read.java6
-rw-r--r--test/java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java2
-rw-r--r--test/java/io/Serializable/backRefCNFException/Read.java14
-rw-r--r--test/java/io/Serializable/checkModifiers/CheckModifiers.java58
-rw-r--r--test/java/io/Serializable/classDescFlagConflict/Read.java13
-rw-r--r--test/java/io/Serializable/classDescHooks/ClassDescHooks.java21
-rw-r--r--test/java/io/Serializable/duplicateSerialFields/Test.java12
-rw-r--r--test/java/io/Serializable/enum/badResolve/Read.java6
-rw-r--r--test/java/io/Serializable/enum/constantSubclasses/Read.java16
-rw-r--r--test/java/io/Serializable/enum/missingConstant/Read.java28
-rw-r--r--test/java/io/Serializable/fieldTypeString/Read.java27
-rw-r--r--test/java/io/Serializable/illegalHandle/Test.java26
-rw-r--r--test/java/io/Serializable/longString/LongString.java20
-rw-r--r--test/java/io/Serializable/oldTests/AnnotateClass.java61
-rw-r--r--test/java/io/Serializable/oldTests/ArrayFields.java11
-rw-r--r--test/java/io/Serializable/oldTests/ArraysOfArrays.java8
-rw-r--r--test/java/io/Serializable/oldTests/BinaryTree.java42
-rw-r--r--test/java/io/Serializable/oldTests/CircularList.java11
-rw-r--r--test/java/io/Serializable/oldTests/SimpleArrays.java8
-rw-r--r--test/java/io/Serializable/oldTests/WritePrimitive.java8
-rw-r--r--test/java/io/Serializable/packageAccess/Test.java3
-rw-r--r--test/java/io/Serializable/parents/EvolvedClass.java8
-rw-r--r--test/java/io/Serializable/parents/OriginalClass.java10
-rw-r--r--test/java/io/Serializable/proxy/Basic.java2
-rw-r--r--test/java/io/Serializable/proxy/skipMissing/Read.java30
-rw-r--r--test/java/io/Serializable/proxy/skipMissing/Write.java2
-rw-r--r--test/java/io/Serializable/readObjectNoData/Read.java20
-rw-r--r--test/java/io/Serializable/skipWriteObject/Read.java10
-rw-r--r--test/java/io/Serializable/skippedObjCNFException/Read.java10
-rw-r--r--test/java/io/Serializable/stopCustomDeserialization/Read.java22
-rw-r--r--test/java/io/Serializable/unresolvedClassDesc/Read.java24
-rw-r--r--test/java/io/Serializable/unshared/Read.java28
-rw-r--r--test/java/io/Serializable/wrongReturnTypes/Read.java22
-rw-r--r--test/java/io/StreamTokenizer/Comment.java63
-rw-r--r--test/java/io/readBytes/ReadBytesBounds.java40
-rw-r--r--test/java/lang/ClassLoader/UninitializedParent.java1
-rw-r--r--test/java/lang/ClassLoader/defineClass/DefineClassByteBuffer.java41
-rw-r--r--test/java/lang/ClassLoader/findSystemClass/Loader.java6
-rw-r--r--test/java/lang/ProcessBuilder/Basic.java112
-rw-r--r--test/java/lang/System/ExitFinalizersAndJIT.java1
-rw-r--r--test/java/lang/System/IgnoreNullSecurityManager.java1
-rw-r--r--test/java/lang/Thread/GenerifyStackTraces.java2
-rw-r--r--test/java/lang/Thread/StackTraces.java2
-rw-r--r--test/java/lang/annotation/ParameterAnnotations.java1
-rw-r--r--test/java/lang/management/ClassLoadingMXBean/LoadCounts.java18
-rw-r--r--test/java/lang/management/ManagementFactory/MXBeanProxyTest.java1
-rw-r--r--test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java52
-rw-r--r--test/java/lang/management/MemoryMXBean/LowMemoryTest.java2
-rw-r--r--test/java/lang/management/MemoryMXBean/MemoryManagement.java2
-rw-r--r--test/java/lang/management/MemoryMXBean/Pending.java17
-rw-r--r--test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java2
-rw-r--r--test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java22
-rw-r--r--test/java/lang/management/RuntimeMXBean/UpTime.java7
-rw-r--r--test/java/lang/management/ThreadMXBean/AllThreadIds.java24
-rw-r--r--test/java/lang/management/ThreadMXBean/DisableTest.java14
-rw-r--r--test/java/lang/management/ThreadMXBean/EnableTest.java15
-rw-r--r--test/java/lang/management/ThreadMXBean/FindDeadlocks.java2
-rw-r--r--test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java2
-rw-r--r--test/java/lang/management/ThreadMXBean/Locks.java2
-rw-r--r--test/java/lang/reflect/Proxy/Boxing.java4
-rw-r--r--test/java/lang/reflect/Proxy/ClassRestrictions.java22
-rw-r--r--test/java/lang/reflect/Proxy/returnTypes/Test.java10
-rw-r--r--test/java/net/ResponseCache/file1.cachebin5723 -> 5806 bytes
-rw-r--r--test/java/nio/channels/AsyncCloseAndInterrupt.java25
-rw-r--r--test/java/nio/channels/AsynchronousSocketChannel/Basic.java118
-rw-r--r--test/java/nio/channels/DatagramChannel/AdaptDatagramSocket.java6
-rw-r--r--test/java/nio/channels/DatagramChannel/Connect.java39
-rw-r--r--test/java/nio/channels/DatagramChannel/EmptyBuffer.java32
-rw-r--r--test/java/nio/channels/DatagramChannel/NoSender.java2
-rw-r--r--test/java/nio/channels/DatagramChannel/SRTest.java50
-rw-r--r--test/java/nio/channels/DatagramChannel/SelectWhenRefused.java94
-rw-r--r--test/java/nio/channels/DatagramChannel/Sender.java51
-rw-r--r--test/java/nio/channels/Selector/ByteServer.java7
-rw-r--r--test/java/nio/channels/Selector/CloseThenRegister.java18
-rw-r--r--test/java/nio/channels/Selector/OpRead.java74
-rw-r--r--test/java/nio/channels/Selector/ReadAfterConnect.java2
-rw-r--r--test/java/nio/channels/Selector/SelectAfterRead.java8
-rw-r--r--test/java/nio/channels/Selector/SelectWrite.java2
-rw-r--r--test/java/nio/channels/SocketChannel/BigReadWrite.java1
-rw-r--r--test/java/nio/channels/SocketChannel/OpenLeak.java2
-rw-r--r--test/java/nio/channels/SocketChannel/VectorIO.java33
-rw-r--r--test/java/nio/channels/SocketChannel/Write.java31
-rw-r--r--test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java2
-rw-r--r--test/java/util/Locale/Bug4184873_hebin113 -> 129 bytes
-rw-r--r--test/java/util/Locale/Bug4184873_idbin113 -> 129 bytes
-rw-r--r--test/java/util/Locale/Bug4184873_yibin113 -> 129 bytes
-rw-r--r--test/java/util/ResourceBundle/Bug4168625Test.java12
-rw-r--r--test/java/util/ResourceBundle/Bug6359330.java1
-rw-r--r--test/java/util/ResourceBundle/Test4300693.java1
-rw-r--r--test/java/util/ResourceBundle/TestBug4179766.java3
-rw-r--r--test/java/util/logging/ParentLoggersTest.java41
-rw-r--r--test/java/util/zip/InfoZip.java28
-rw-r--r--test/java/util/zip/ZipFile/Comment.java21
-rw-r--r--test/java/util/zip/ZipFile/CorruptedZipFiles.java28
-rw-r--r--test/java/util/zip/ZipFile/ManyEntries.java90
-rw-r--r--test/sun/jvmstat/testlibrary/utils.sh34
-rw-r--r--test/sun/security/krb5/auto/Context.java31
-rw-r--r--test/sun/security/krb5/auto/KDC.java38
-rw-r--r--test/sun/security/krb5/auto/W83.java131
-rw-r--r--test/sun/security/validator/CertReplace.java29
-rw-r--r--test/sun/security/validator/certreplace.sh10
-rw-r--r--test/sun/security/validator/samedn.sh82
-rw-r--r--test/sun/tools/jps/jps-Vvml_2.sh6
-rw-r--r--test/sun/tools/jps/jps-m_2.sh6
-rw-r--r--test/sun/tools/jstat/classloadOutput1.awk31
-rw-r--r--test/sun/tools/jstat/jstatClassloadOutput1.sh36
-rw-r--r--test/sun/tools/jstat/jstatOptions1.sh8
-rw-r--r--test/sun/tools/jstat/options2.out13
-rw-r--r--test/sun/tools/jstatd/jstatdDefaults.sh7
-rw-r--r--test/sun/tools/jstatd/jstatdExternalRegistry.sh13
-rw-r--r--test/sun/tools/jstatd/jstatdPort.sh13
-rw-r--r--test/sun/tools/jstatd/jstatdServerName.sh22
-rw-r--r--test/tools/jar/UpdateManifest.java1
-rw-r--r--test/tools/jar/index/MetaInf.java12
-rw-r--r--test/tools/pack200/Pack200Test.java10
-rw-r--r--test/tools/pack200/PackageVersionTest.java169
-rw-r--r--test/tools/pack200/SegmentLimit.java134
222 files changed, 3122 insertions, 1714 deletions
diff --git a/make/common/Defs-linux.gmk b/make/common/Defs-linux.gmk
index 970cea9fc..df8cba2ec 100644
--- a/make/common/Defs-linux.gmk
+++ b/make/common/Defs-linux.gmk
@@ -320,6 +320,7 @@ override LIBCXX = -lstdc++
endif
override LIBPOSIX4 =
override LIBSOCKET =
+override LIBNSL =
override LIBTHREAD =
override MOOT_PRIORITIES = true
override NO_INTERRUPTIBLE_IO = true
diff --git a/make/common/Defs-solaris.gmk b/make/common/Defs-solaris.gmk
index 32f8bf7f1..97b6a69e4 100644
--- a/make/common/Defs-solaris.gmk
+++ b/make/common/Defs-solaris.gmk
@@ -645,6 +645,9 @@ LIBM = /usr/lib$(ISA_DIR)/libm.so.2
# Socket library
LIBSOCKET = -lsocket
+# Network Services library
+LIBNSL = -lnsl
+
# GLOBAL_KPIC: If set means all libraries are PIC, position independent code
# EXCEPT for select compiles
# If a .o file is compiled non-PIC then it should be forced
diff --git a/make/common/Release.gmk b/make/common/Release.gmk
index 4c16022ce..cf16ea8dd 100644
--- a/make/common/Release.gmk
+++ b/make/common/Release.gmk
@@ -54,6 +54,13 @@ EXCLUDE_PROPWARN_PKGS = com.sun.java.swing.plaf.windows \
# This is a stopgap until 6839872 is fixed.
EXCLUDE_PROPWARN_PKGS += sun.dyn
+#
+# Include the exported private packages in ct.sym.
+# This is an interim solution until the ct.sym is replaced
+# with a new module system (being discussed for JDK 7).
+#
+EXPORTED_PRIVATE_PKGS = com.sun.servicetag
+
# 64-bit solaris has a few special cases. We define the variable
# SOLARIS64 for use in this Makefile to easily test those cases
ifeq ($(PLATFORM), solaris)
@@ -982,7 +989,7 @@ initial-image-jdk:: initial-image-jdk-setup \
-processor com.sun.tools.javac.sym.CreateSymbols \
-Acom.sun.tools.javac.sym.Jar=$(RT_JAR) \
-Acom.sun.tools.javac.sym.Dest=$(OUTPUTDIR)/symbols/META-INF/sym/rt.jar \
- $(CORE_PKGS) $(NON_CORE_PKGS) $(EXCLUDE_PROPWARN_PKGS)
+ $(CORE_PKGS) $(NON_CORE_PKGS) $(EXCLUDE_PROPWARN_PKGS) $(EXPORTED_PRIVATE_PKGS)
$(BOOT_JAR_CMD) c0f $(LIBDIR)/ct.sym \
-C $(OUTPUTDIR)/symbols META-INF $(BOOT_JAR_JFLAGS)
@$(java-vm-cleanup)
diff --git a/make/common/shared/Defs-control.gmk b/make/common/shared/Defs-control.gmk
index b5f06e752..4e545ca99 100644
--- a/make/common/shared/Defs-control.gmk
+++ b/make/common/shared/Defs-control.gmk
@@ -35,9 +35,6 @@ ifndef JDK_MAKE_SHARED_DIR
JDK_MAKE_SHARED_DIR = $(JDK_TOPDIR)/make/common/shared
endif
-ifndef CONTROL_TOPDIR
- CONTROL_TOPDIR=$(TOPDIR)
-endif
ifndef HOTSPOT_TOPDIR
HOTSPOT_TOPDIR=$(TOPDIR)/hotspot
endif
diff --git a/make/docs/CORE_PKGS.gmk b/make/docs/CORE_PKGS.gmk
index b1cb7e62d..31aaeb1b5 100644
--- a/make/docs/CORE_PKGS.gmk
+++ b/make/docs/CORE_PKGS.gmk
@@ -234,6 +234,7 @@ CORE_PKGS = \
javax.xml.ws.http \
javax.xml.ws.soap \
javax.xml.ws.spi \
+ javax.xml.ws.spi.http \
javax.xml.ws.wsaddressing \
javax.xml.transform \
javax.xml.transform.sax \
diff --git a/make/java/hpi/hpi_common.gmk b/make/java/hpi/hpi_common.gmk
index 5f7703830..025d2de10 100644
--- a/make/java/hpi/hpi_common.gmk
+++ b/make/java/hpi/hpi_common.gmk
@@ -86,5 +86,5 @@ endif
# Things that must be linked in.
#
ifneq ($(PLATFORM), windows)
-OTHER_LDLIBS += $(LIBSOCKET) -lnsl $(LIBM) -ldl
+OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) $(LIBM) -ldl
endif
diff --git a/make/java/java/Makefile b/make/java/java/Makefile
index 60542f2ad..827a0ec17 100644
--- a/make/java/java/Makefile
+++ b/make/java/java/Makefile
@@ -204,7 +204,7 @@ ifeq ($(PLATFORM),windows)
OTHER_LDLIBS += $(JVMLIB) -libpath:$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) fdlibm.lib \
-libpath:$(OBJDIR)/../../../verify/$(OBJDIRNAME) verify.lib
else
-OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) -lnsl -ldl \
+OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) -ldl \
-L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH)
endif
diff --git a/make/java/java_hprof_demo/Makefile b/make/java/java_hprof_demo/Makefile
index f051de0c5..b6d0539ad 100644
--- a/make/java/java_hprof_demo/Makefile
+++ b/make/java/java_hprof_demo/Makefile
@@ -84,7 +84,7 @@ OTHER_INCLUDES = -I$(SRCDIR) \
ifeq ($(PLATFORM), windows)
OTHER_LDLIBS += wsock32.lib winmm.lib
else
- OTHER_LDLIBS += $(LIBSOCKET) -lnsl -ldl
+ OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) -ldl
endif
#
diff --git a/make/java/net/Makefile b/make/java/net/Makefile
index ca898e53a..0021087cb 100644
--- a/make/java/net/Makefile
+++ b/make/java/net/Makefile
@@ -96,7 +96,7 @@ include $(BUILDDIR)/common/Library.gmk
ifeq ($(PLATFORM), windows)
OTHER_LDLIBS = ws2_32.lib $(JVMLIB)
else
- OTHER_LDLIBS = $(LIBSOCKET) -lnsl -ldl $(JVMLIB)
+ OTHER_LDLIBS = $(LIBSOCKET) $(LIBNSL) -ldl $(JVMLIB)
endif
ifeq ($(PLATFORM), linux)
OTHER_LDLIBS += -lpthread
diff --git a/make/jpda/transport/socket/Makefile b/make/jpda/transport/socket/Makefile
index a048e24b4..ee7980c7b 100644
--- a/make/jpda/transport/socket/Makefile
+++ b/make/jpda/transport/socket/Makefile
@@ -38,11 +38,11 @@ FILES_m = mapfile-vers
include $(BUILDDIR)/common/Defs.gmk
ifeq ($(PLATFORM), linux)
- OTHER_LDLIBS += -lnsl $(LIBSOCKET) -lpthread
+ OTHER_LDLIBS += $(LIBNSL) $(LIBSOCKET) -lpthread
endif
ifeq ($(PLATFORM), solaris)
- OTHER_LDLIBS += -lnsl $(LIBSOCKET)
+ OTHER_LDLIBS += $(LIBNSL) $(LIBSOCKET)
endif
ifeq ($(PLATFORM), windows)
diff --git a/make/mkdemo/jvmti/hprof/Makefile b/make/mkdemo/jvmti/hprof/Makefile
index 9a3cd19ee..b0c703f67 100644
--- a/make/mkdemo/jvmti/hprof/Makefile
+++ b/make/mkdemo/jvmti/hprof/Makefile
@@ -39,10 +39,10 @@ ifeq ($(PLATFORM), windows)
EXTRA_LIBS += wsock32.lib winmm.lib
endif
ifeq ($(PLATFORM), solaris)
- OTHER_LDLIBS += $(LIBSOCKET) -lnsl -ldl
+ OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) -ldl
endif
ifeq ($(PLATFORM), linux)
- OTHER_LDLIBS += $(LIBSOCKET) -lnsl -ldl -lpthread
+ OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) -ldl -lpthread
endif
#
diff --git a/make/netbeans/README b/make/netbeans/README
index 8f68dce0e..b23433401 100644
--- a/make/netbeans/README
+++ b/make/netbeans/README
@@ -204,8 +204,8 @@ Provided NetBeans projects
note that pretty much regardless of your hardware, this *will* take
a long time, and use *lots* of disk space (more than 3GB). The
results of the build are in
- *install-dir*/control/build/*platform*-*arch* and
- *install-dir*/control/build/*platform*-*arch*-fastdebug.
+ *install-dir*/build/*platform*-*arch* and
+ *install-dir*/build/*platform*-*arch*-fastdebug.
Consult the project's README file for details.
diff --git a/make/netbeans/world/README b/make/netbeans/world/README
index 72c21a933..54c2ccc1f 100644
--- a/make/netbeans/world/README
+++ b/make/netbeans/world/README
@@ -10,6 +10,6 @@ project code, you might prefer to build it from the command line using ant.
Please note: the results of building this project are *not* put in the place
used by other projects. In this case, the results are place in
- <install-dir>/control/build/<platform>-<arch>
+ <install-dir>/build/<platform>-<arch>
and
- <install-dir>/control/build/<platform>-<arch>-fastdebug
+ <install-dir>/build/<platform>-<arch>-fastdebug
diff --git a/make/netbeans/world/build.xml b/make/netbeans/world/build.xml
index 99dbfbf69..b502c2835 100644
--- a/make/netbeans/world/build.xml
+++ b/make/netbeans/world/build.xml
@@ -34,11 +34,11 @@
<import file="../common/shared.xml"/>
<target name="-build-make" depends="-make.init" if="use.make">
- <make-run target="dev" dir="${root}/../control/make" opts="SKIP_COMPARE_IMAGES=true"/>
+ <make-run target="dev" dir="${root}/.." opts="SKIP_COMPARE_IMAGES=true"/>
</target>
<target name="-clean-make" depends="-make.init" if="use.make">
- <make-run target="clean" dir="${root}/../control/make"/>
+ <make-run target="clean" dir="${root}/.."/>
</target>
</project>
diff --git a/make/sun/nio/cs/Makefile b/make/sun/nio/cs/Makefile
index ff2f8ca16..26437efca 100644
--- a/make/sun/nio/cs/Makefile
+++ b/make/sun/nio/cs/Makefile
@@ -37,7 +37,7 @@ PRODUCT = sun
# This re-directs all the class files to a separate location
CLASSDESTDIR = $(TEMPDIR)/classes
-OTHER_JAVACFLAGS += -Xlint:serial -Werror
+OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror
include $(BUILDDIR)/common/Defs.gmk
#
diff --git a/make/sun/tools/Makefile b/make/sun/tools/Makefile
index a041eb0c7..ebfcff513 100644
--- a/make/sun/tools/Makefile
+++ b/make/sun/tools/Makefile
@@ -49,7 +49,8 @@ AUTO_FILES_JAVA_DIRS = \
# Extra jstat files
FILES_copy += \
- $(CLASSDESTDIR)/sun/tools/jstat/resources/jstat_options
+ $(CLASSDESTDIR)/sun/tools/jstat/resources/jstat_options \
+ $(CLASSDESTDIR)/sun/tools/jstat/resources/jstat_unsupported_options
# Extra jhat files
JHAT_RESOURCEDIR = $(CLASSDESTDIR)/com/sun/tools/hat/resources
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Constants.java b/src/share/classes/com/sun/java/util/jar/pack/Constants.java
index a9deb0cd8..19ce04cf5 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Constants.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Constants.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,10 +47,13 @@ interface Constants {
public final static short JAVA5_MAX_CLASS_MAJOR_VERSION = 49;
public final static short JAVA5_MAX_CLASS_MINOR_VERSION = 0;
- // NOTE: ASSUMED for now
+
public final static short JAVA6_MAX_CLASS_MAJOR_VERSION = 50;
public final static short JAVA6_MAX_CLASS_MINOR_VERSION = 0;
+ public final static short JAVA7_MAX_CLASS_MAJOR_VERSION = 51;
+ public final static short JAVA7_MAX_CLASS_MINOR_VERSION = 0;
+
public final static int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
public final static int JAVA5_PACKAGE_MAJOR_VERSION = 150;
public final static int JAVA5_PACKAGE_MINOR_VERSION = 7;
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Package.java b/src/share/classes/com/sun/java/util/jar/pack/Package.java
index ad7fdbaa5..1ea04690e 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Package.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Package.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,8 +57,8 @@ class Package implements Constants {
// These fields can be adjusted by driver properties.
short min_class_majver = JAVA_MIN_CLASS_MAJOR_VERSION;
short min_class_minver = JAVA_MIN_CLASS_MINOR_VERSION;
- short max_class_majver = JAVA6_MAX_CLASS_MAJOR_VERSION;
- short max_class_minver = JAVA6_MAX_CLASS_MINOR_VERSION;
+ short max_class_majver = JAVA7_MAX_CLASS_MAJOR_VERSION;
+ short max_class_minver = JAVA7_MAX_CLASS_MINOR_VERSION;
short observed_max_class_majver = min_class_majver;
short observed_max_class_minver = min_class_minver;
@@ -122,13 +122,16 @@ class Package implements Constants {
void choosePackageVersion() {
assert(package_majver <= 0); // do not call this twice
int classver = getHighestClassVersion();
- if (classver != 0 &&
- (classver >>> 16) < JAVA6_MAX_CLASS_MAJOR_VERSION) {
- // There are only old classfiles in this segment.
+ if (classver == 0 || (classver >>> 16) < JAVA6_MAX_CLASS_MAJOR_VERSION) {
+ // There are only old classfiles in this segment or resources
package_majver = JAVA5_PACKAGE_MAJOR_VERSION;
package_minver = JAVA5_PACKAGE_MINOR_VERSION;
+ } else if ((classver >>> 16) == JAVA6_MAX_CLASS_MAJOR_VERSION) {
+ package_majver = JAVA6_PACKAGE_MAJOR_VERSION;
+ package_minver = JAVA6_PACKAGE_MINOR_VERSION;
} else {
- // Normal case. Use the newest archive format.
+ // Normal case. Use the newest archive format, when available
+ // TODO: replace the following with JAVA7* when the need arises
package_majver = JAVA6_PACKAGE_MAJOR_VERSION;
package_minver = JAVA6_PACKAGE_MINOR_VERSION;
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java
index c5eb8d75d..6b92236f8 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003,2010 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -90,8 +90,8 @@ class PropMap extends TreeMap {
props.put(Utils.PACK_DEFAULT_TIMEZONE,
String.valueOf(Boolean.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)));
- // Limit segment size to less than a megabyte.
- props.put(Pack200.Packer.SEGMENT_LIMIT, ""+(1*1000*1000));
+ // The segment size is unlimited
+ props.put(Pack200.Packer.SEGMENT_LIMIT, "");
// Preserve file ordering by default.
props.put(Pack200.Packer.KEEP_FILE_ORDER, Pack200.Packer.TRUE);
diff --git a/src/share/classes/com/sun/servicetag/Registry.java b/src/share/classes/com/sun/servicetag/Registry.java
index 68386ce67..14ad2fd62 100644
--- a/src/share/classes/com/sun/servicetag/Registry.java
+++ b/src/share/classes/com/sun/servicetag/Registry.java
@@ -67,7 +67,6 @@ public class Registry {
// The stclient output has to be an exported interface
private static final String INSTANCE_URN_DESC = "Product instance URN=";
private static boolean initialized = false;
- private static boolean supportsHelperClass = true; // default
private static File stclient = null;
private static String stclientPath = null;
private static Registry registry = new Registry();
@@ -81,17 +80,6 @@ public class Registry {
private synchronized static String getSTclient() {
if (!initialized) {
- // the system property always overrides the default setting
- if (System.getProperty(SVCTAG_STHELPER_SUPPORTED) != null) {
- supportsHelperClass = Boolean.getBoolean(SVCTAG_STHELPER_SUPPORTED);
- }
-
- // This is only used for testing
- stclientPath = System.getProperty(SVCTAG_STCLIENT_CMD);
- if (stclientPath != null) {
- return stclientPath;
- }
-
// Initialization to determine the platform's stclient pathname
String os = System.getProperty("os.name");
if (os.equals("SunOS")) {
@@ -108,10 +96,26 @@ public class Registry {
initialized = true;
}
+ boolean supportsHelperClass = true; // default
+ if (System.getProperty(SVCTAG_STHELPER_SUPPORTED) != null) {
+ // the system property always overrides the default setting
+ supportsHelperClass = Boolean.getBoolean(SVCTAG_STHELPER_SUPPORTED);
+ }
+
+ if (!supportsHelperClass) {
+ // disable system registry
+ return null;
+ }
+
+ // This is only used for testing
+ String path = System.getProperty(SVCTAG_STCLIENT_CMD);
+ if (path != null) {
+ return path;
+ }
+
// com.sun.servicetag package has to be compiled with JDK 5 as well
// JDK 5 doesn't support the File.canExecute() method.
// Risk not checking isExecute() for the stclient command is very low.
-
if (stclientPath == null && stclient != null && stclient.exists()) {
stclientPath = stclient.getAbsolutePath();
}
@@ -142,8 +146,8 @@ public class Registry {
* @return {@code true} if the {@code Registry} class is supported;
* otherwise, return {@code false}.
*/
- public static boolean isSupported() {
- return (getSTclient() != null && supportsHelperClass);
+ public static synchronized boolean isSupported() {
+ return getSTclient() != null;
}
private static List<String> getCommandList() {
diff --git a/src/share/classes/com/sun/servicetag/resources/jdk_header.png b/src/share/classes/com/sun/servicetag/resources/jdk_header.png
index 011cfd4cd..ccfe6dad8 100644
--- a/src/share/classes/com/sun/servicetag/resources/jdk_header.png
+++ b/src/share/classes/com/sun/servicetag/resources/jdk_header.png
Binary files differ
diff --git a/src/share/classes/com/sun/servicetag/resources/register.html b/src/share/classes/com/sun/servicetag/resources/register.html
index 7684268eb..cc1dee262 100644
--- a/src/share/classes/com/sun/servicetag/resources/register.html
+++ b/src/share/classes/com/sun/servicetag/resources/register.html
@@ -53,13 +53,13 @@ a:visited,a:visited code{color:#917E9C}
</tr>
<tr>
<td>&nbsp;</td>
- <td><p class="style1">Thank you for installing the
+ <td><p class="style1">Thank you for installing the
<strong> Java Development Kit @@JDK_VERSION@@ </strong>
- from Sun Microsystems. </p>
+ from Oracle Corporation. </p>
<p class="style1">Registering your product will give you the following benefits:</p>
<ul class="style1">
<li> Notification of new versions, patches, and updates</li>
- <li> Special offers on Sun developer products, services and training </li>
+ <li> Special offers on Oracle developer products, services and training </li>
<li> Access to early releases and documentation </li>
</ul>
<p class="style1">Product registration is FREE, quick and easy!</p>
@@ -68,11 +68,11 @@ a:visited,a:visited code{color:#917E9C}
<table width="708" border="0" cellspacing="0" cellpadding="3">
<tr valign="top">
<td width="126" height="35">
- <form name="form1" method="post" action="@@REGISTRATION_URL@@">
+ <form name="form1" method="post" action="@@REGISTRATION_URL@@" enctype="text/xml">
<input type="hidden" name="servicetag_payload" value="@@REGISTRATION_PAYLOAD@@">
<input type="submit" name="Submit"border="0" class="buttonblue" onmouseover="this.style.color='#fbe249';" onmouseout="this.style.color='#FFF';" value="Register My JDK">
</form></td>
- <td width="570"><span class="style3">You need to be connected to the Internet to register this Sun product. </span></td>
+ <td width="570"><span class="style3">You need to be connected to the Internet to register this Oracle product. </span></td>
</tr>
</table>
</blockquote>
@@ -81,16 +81,16 @@ a:visited,a:visited code{color:#917E9C}
<tr>
<td>&nbsp;</td>
<td bgcolor="#f1f7df">
- <p class="style3">Sun Microsystems, Inc. respects your privacy.
- We will use your personal information for communications
- and management of your Sun Online Account, the services
- and applications you access using your Sun Online Account,
+ <p class="style3">Oracle Corporation respects your privacy.
+ We will use your personal information for communications
+ and management of your Sun Online Account, the services
+ and applications you access using your Sun Online Account,
and the products and systems you register with your Sun Online Account.</p>
- <p class="style3">For more information on the data that will be collected as
+ <p class="style3">For more information on the data that will be collected as
part of the registration process and how it will be managed <br>
- see <a href="http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html</a>. <br>
+ see <a href="http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html</a>. <br>
<br>
- For more information on Sun's Privacy Policy see <a href="http://www.sun.com/privacy/">http://www.sun.com/privacy/</a> or contact <a class="moz-txt-link-rfc2396E" href="mailto:privacy@sun.com">privacy@sun.com.</a></p></td>
+ For more information on Oracle's Privacy Policy see <a href="http://www.oracle.com/html/privacy.html">http://www.oracle.com/html/privacy.html</a> or contact <a class="moz-txt-link-rfc2396E" href="mailto:privacy_ww@oracle.com">privacy_ww@oracle.com.</a></p></td>
</tr>
<tr>
<td>&nbsp;</td>
diff --git a/src/share/classes/com/sun/servicetag/resources/register_ja.html b/src/share/classes/com/sun/servicetag/resources/register_ja.html
index dae437712..3da70723e 100644
--- a/src/share/classes/com/sun/servicetag/resources/register_ja.html
+++ b/src/share/classes/com/sun/servicetag/resources/register_ja.html
@@ -50,11 +50,11 @@ a:visited,a:visited code{color:#917E9C}
<tr>
<td>&nbsp;</td>
- <td><p class="style1">Sun Microsystems の<strong> Java Development Kit @@JDK_VERSION@@ </strong>をインストールしていただき、ありがとうございます。 </p>
+ <td><p class="style1">Oracle Corporation の<strong> Java Development Kit @@JDK_VERSION@@ </strong>をインストールしていただき、ありがとうございます。 </p>
<p class="style1">製品登録をすると、次のような特典を受けることができます。</p>
<ul class="style1">
<li> 最新のバージョン、パッチ、および更新についての通知</li>
- <li> Sun の開発者向け製品、サービス、およびトレーニングの特別販売 </li>
+ <li> Oracle の開発者向け製品、サービス、およびトレーニングの特別販売 </li>
<li> アーリーリリースおよびドキュメントへのアクセス </li>
</ul>
<p class="style1">製品登録は無料であり、迅速で簡単です。</p>
@@ -62,11 +62,11 @@ a:visited,a:visited code{color:#917E9C}
<p class="style1">必要になるのは、Sun 開発者向けネットワークアカウントまたはその他の Sun オンラインアカウントだけです。 まだアカウントがない場合は、アカウントの作成が求められます。 </p>
<table width="708" border="0" cellspacing="0" cellpadding="3">
<tr valign="top">
- <td width="126" height="35"><form name="form1" method="post" action="@@REGISTRATION_URL@@">
+ <td width="126" height="35"><form name="form1" method="post" action="@@REGISTRATION_URL@@" enctype="text/xml">
<input type="hidden" name="servicetag_payload" value="@@REGISTRATION_PAYLOAD@@">
<input type="submit" name="Submit"border="0" class="buttonblue" onmouseover="this.style.color='#fbe249';" onmouseout="this.style.color='#FFF';" value="JDK 製品登録">
</form></td>
- <td width="570"><span class="style3">この Sun 製品を登録するには、インターネットに接続している必要があります。 </span></td>
+ <td width="570"><span class="style3">この Oracle 製品を登録するには、インターネットに接続している必要があります。 </span></td>
</tr>
</table>
</blockquote>
@@ -75,8 +75,8 @@ a:visited,a:visited code{color:#917E9C}
<tr>
<td>&nbsp;</td>
<td bgcolor="#f1f7df">
- <p class="style3">Sun Microsystems, Inc. は、お客様のプライバシーを尊重します。 お客様の個人情報は、お客様の Sun オンラインアカウント、お客様が Sun オンラインアカウントを使用してアクセスするサービスとアプリケーション、およびお客様が Sun オンラインアカウントで登録する製品とシステムの通信と管理に使用します。</p>
- <p class="style3">登録の際に収集されるデータや、それらがどのように管理されるかについての詳細は、<br><a href="http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html</a> を参照してください。 <br> <br> Sun のプライバシーポリシーについての詳細は、<a href="http://jp.sun.com/privacy/">http://jp.sun.com/privacy/</a> を参照するか、<a class="moz-txt-link-rfc2396E" href="http://jp.sun.com/cgi-bin/contact/comment.cgi?url=http://jp.sun.com/privacy/">お問い合わせフォーム</a>からお問い合わせください。</p></td>
+ <p class="style3">Oracle Corporation は、お客様のプライバシーを尊重します。 お客様の個人情報は、お客様の Sun オンラインアカウント、お客様が Sun オンラインアカウントを使用してアクセスするサービスとアプリケーション、およびお客様が Sun オンラインアカウントで登録する製品とシステムの通信と管理に使用します。</p>
+ <p class="style3">登録の際に収集されるデータや、それらがどのように管理されるかについての詳細は、<br><a href="http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html</a> を参照してください。 <br> <br> Oracle のプライバシーポリシーについての詳細は、<a href="http://www.oracle.com/html/privacy.html">http://www.oracle.com/html/privacy.html</a> を参照するか、<a class="moz-txt-link-rfc2396E" href="mailto:privacy_ww@oracle.com">お問い合わせフォーム</a>からお問い合わせください。</p></td>
</tr>
<tr>
<td>&nbsp;</td>
diff --git a/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html b/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html
index dfc24dc94..f5bad110b 100644
--- a/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html
+++ b/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html
@@ -51,11 +51,11 @@ a:visited,a:visited code{color:#917E9C}
<tr>
<td>&nbsp;</td>
-<td><p class="style1">感谢您安装 Sun Microsystems 的 <strong>Java Development Kit @@JDK_VERSION@@</strong>。 </p>
+<td><p class="style1">感谢您安装 Oracle Corporation 的 <strong>Java Development Kit @@JDK_VERSION@@</strong>。 </p>
<p class="style1">注册产品后您将获得如下增值服务:</p>
<ul class="style1">
<li> 获得新版本、修补程序和更新的通知服务</li>
-<li> 获得有关 Sun 开发者产品、服务和培训的优惠 </li>
+<li> 获得有关 Oracle 开发者产品、服务和培训的优惠 </li>
<li> 获得对早期版本和文档的访问权限 </li>
</ul>
<p class="style1">产品注册是免费的,即快速又轻松!</p>
@@ -63,11 +63,11 @@ a:visited,a:visited code{color:#917E9C}
<p class="style1">您需要具有 Sun 开发者网络或其他 Sun 联机帐户。如果您没有,系统将提示您创建一个。 </p>
<table width="708" border="0" cellspacing="0" cellpadding="3">
<tr valign="top">
- <td width="126" height="35"><form name="form1" method="post" action="@@REGISTRATION_URL@@">
+ <td width="126" height="35"><form name="form1" method="post" action="@@REGISTRATION_URL@@" enctype="text/xml">
<input type="hidden" name="servicetag_payload" value="@@REGISTRATION_PAYLOAD@@">
<input type="submit" name="Submit"border="0" class="buttonblue" onmouseover="this.style.color='#fbe249';" onmouseout="this.style.color='#FFF';" value="注册我的 JDK">
</form></td>
-<td width="570"><span class="style3">您需要连接到 Internet 来注册此 Sun 产品。 </span></td>
+<td width="570"><span class="style3">您需要连接到 Internet 来注册此 Oracle 产品。 </span></td>
</tr>
</table>
</blockquote>
@@ -76,8 +76,8 @@ a:visited,a:visited code{color:#917E9C}
<tr>
<td>&nbsp;</td>
<td bgcolor="#f1f7df">
- <p class="style3">Sun Microsystems, Inc. 尊重您的隐私。我们会将您的个人信息用于通信和 Sun 联机帐户的管理、Sun 联机帐户访问的服务和应用程序以及用于使用 Sun 联机帐户注册的产品和系统。</p>
-<p class="style3">有关注册过程中收集的数据以及这些数据的管理方式的更多信息,<br>请访问 <a href="http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html</a>。<br> <br>有关 Sun 隐私政策的更多信息,请访问 <a href="http://www.sun.com/privacy/">http://www.sun.com/privacy/</a> 或与 <a class="moz-txt-link-rfc2396E" href="mailto:privacy@sun.com">privacy@sun.com</a> 联系。</p></td>
+ <p class="style3">Oracle 尊重您的隐私。我们会将您的个人信息用于通信和 Sun 联机帐户的管理、Sun 联机帐户访问的服务和应用程序以及用于使用 Sun 联机帐户注册的产品和系统。</p>
+<p class="style3">有关注册过程中收集的数据以及这些数据的管理方式的更多信息,<br>请访问 <a href="http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html">http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html</a>。<br> <br>有关 Oracle 隐私政策的更多信息,请访问 <a href="http://www.oracle.com/html/privacy.html">http://www.oracle.com/html/privacy.html</a> 或与 <a class="moz-txt-link-rfc2396E" href="mailto:privacy_ww@oracle.com">privacy_ww@oracle.com</a> 联系。</p></td>
</tr>
<tr>
<td>&nbsp;</td>
diff --git a/src/share/classes/java/lang/AssertionError.java b/src/share/classes/java/lang/AssertionError.java
index 75e8cd8f0..8fb577a6e 100644
--- a/src/share/classes/java/lang/AssertionError.java
+++ b/src/share/classes/java/lang/AssertionError.java
@@ -66,7 +66,7 @@ public class AssertionError extends Error {
* defined in <i>The Java Language Specification, Second
* Edition</i>, Section 15.18.1.1.
*<p>
- * If the specified object is an instance of <tt>Throwable</tt>, it
+ * If the specified object is an instance of {@code Throwable}, it
* becomes the <i>cause</i> of the newly constructed assertion error.
*
* @param detailMessage value to be used in constructing detail message
@@ -149,4 +149,21 @@ public class AssertionError extends Error {
public AssertionError(double detailMessage) {
this("" + detailMessage);
}
+
+ /**
+ * Constructs a new {@code AssertionError} with the specified
+ * detail message and cause.
+ *
+ * <p>Note that the detail message associated with
+ * {@code cause} is <i>not</i> automatically incorporated in
+ * this error's detail message.
+ *
+ * @param message the detail message, may be {@code null}
+ * @param cause the cause, may be {@code null}
+ *
+ * @since 1.7
+ */
+ public AssertionError(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/src/share/classes/java/lang/Math.java b/src/share/classes/java/lang/Math.java
index 7ce31265d..455a21f9a 100644
--- a/src/share/classes/java/lang/Math.java
+++ b/src/share/classes/java/lang/Math.java
@@ -681,9 +681,9 @@ public final class Math {
private static Random randomNumberGenerator;
- private static synchronized void initRNG() {
- if (randomNumberGenerator == null)
- randomNumberGenerator = new Random();
+ private static synchronized Random initRNG() {
+ Random rnd = randomNumberGenerator;
+ return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
}
/**
@@ -694,9 +694,11 @@ public final class Math {
*
* <p>When this method is first called, it creates a single new
* pseudorandom-number generator, exactly as if by the expression
- * <blockquote>{@code new java.util.Random}</blockquote> This
- * new pseudorandom-number generator is used thereafter for all
- * calls to this method and is used nowhere else.
+ *
+ * <blockquote>{@code new java.util.Random()}</blockquote>
+ *
+ * This new pseudorandom-number generator is used thereafter for
+ * all calls to this method and is used nowhere else.
*
* <p>This method is properly synchronized to allow correct use by
* more than one thread. However, if many threads need to generate
@@ -705,11 +707,12 @@ public final class Math {
*
* @return a pseudorandom {@code double} greater than or equal
* to {@code 0.0} and less than {@code 1.0}.
- * @see java.util.Random#nextDouble()
+ * @see Random#nextDouble()
*/
public static double random() {
- if (randomNumberGenerator == null) initRNG();
- return randomNumberGenerator.nextDouble();
+ Random rnd = randomNumberGenerator;
+ if (rnd == null) rnd = initRNG();
+ return rnd.nextDouble();
}
/**
diff --git a/src/share/classes/java/lang/ProcessBuilder.java b/src/share/classes/java/lang/ProcessBuilder.java
index 82fad4a2b..97ce45cdf 100644
--- a/src/share/classes/java/lang/ProcessBuilder.java
+++ b/src/share/classes/java/lang/ProcessBuilder.java
@@ -418,6 +418,8 @@ public final class ProcessBuilder
* Implements a <a href="#redirect-output">null input stream</a>.
*/
static class NullInputStream extends InputStream {
+ static final NullInputStream INSTANCE = new NullInputStream();
+ private NullInputStream() {}
public int read() { return -1; }
public int available() { return 0; }
}
@@ -426,6 +428,8 @@ public final class ProcessBuilder
* Implements a <a href="#redirect-input">null output stream</a>.
*/
static class NullOutputStream extends OutputStream {
+ static final NullOutputStream INSTANCE = new NullOutputStream();
+ private NullOutputStream() {}
public void write(int b) throws IOException {
throw new IOException("Stream closed");
}
diff --git a/src/share/classes/java/lang/StrictMath.java b/src/share/classes/java/lang/StrictMath.java
index f2f275b5c..916b82ff9 100644
--- a/src/share/classes/java/lang/StrictMath.java
+++ b/src/share/classes/java/lang/StrictMath.java
@@ -667,9 +667,9 @@ public final class StrictMath {
private static Random randomNumberGenerator;
- private static synchronized void initRNG() {
- if (randomNumberGenerator == null)
- randomNumberGenerator = new Random();
+ private static synchronized Random initRNG() {
+ Random rnd = randomNumberGenerator;
+ return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
}
/**
@@ -680,9 +680,11 @@ public final class StrictMath {
*
* <p>When this method is first called, it creates a single new
* pseudorandom-number generator, exactly as if by the expression
- * <blockquote>{@code new java.util.Random}</blockquote> This
- * new pseudorandom-number generator is used thereafter for all
- * calls to this method and is used nowhere else.
+ *
+ * <blockquote>{@code new java.util.Random()}</blockquote>
+ *
+ * This new pseudorandom-number generator is used thereafter for
+ * all calls to this method and is used nowhere else.
*
* <p>This method is properly synchronized to allow correct use by
* more than one thread. However, if many threads need to generate
@@ -691,11 +693,12 @@ public final class StrictMath {
*
* @return a pseudorandom {@code double} greater than or equal
* to {@code 0.0} and less than {@code 1.0}.
- * @see java.util.Random#nextDouble()
+ * @see Random#nextDouble()
*/
public static double random() {
- if (randomNumberGenerator == null) initRNG();
- return randomNumberGenerator.nextDouble();
+ Random rnd = randomNumberGenerator;
+ if (rnd == null) rnd = initRNG();
+ return rnd.nextDouble();
}
/**
diff --git a/src/share/classes/java/security/Security.java b/src/share/classes/java/security/Security.java
index 4aea17e38..81e029b8e 100644
--- a/src/share/classes/java/security/Security.java
+++ b/src/share/classes/java/security/Security.java
@@ -678,7 +678,7 @@ public final class Security {
spiMap.put(type, clazz);
return clazz;
} catch (ClassNotFoundException e) {
- throw (Error)new AssertionError("Spi class not found").initCause(e);
+ throw new AssertionError("Spi class not found", e);
}
}
diff --git a/src/share/classes/java/util/Collections.java b/src/share/classes/java/util/Collections.java
index 8b20182f7..e4329dc0e 100644
--- a/src/share/classes/java/util/Collections.java
+++ b/src/share/classes/java/util/Collections.java
@@ -463,10 +463,10 @@ public class Collections {
* its list-iterator does not support the <tt>set</tt> operation.
*/
public static void shuffle(List<?> list) {
- if (r == null) {
- r = new Random();
- }
- shuffle(list, r);
+ Random rnd = r;
+ if (rnd == null)
+ r = rnd = new Random();
+ shuffle(list, rnd);
}
private static Random r;
diff --git a/src/share/classes/java/util/concurrent/ThreadLocalRandom.java b/src/share/classes/java/util/concurrent/ThreadLocalRandom.java
index ba83c80a7..c8a67dd65 100644
--- a/src/share/classes/java/util/concurrent/ThreadLocalRandom.java
+++ b/src/share/classes/java/util/concurrent/ThreadLocalRandom.java
@@ -73,10 +73,10 @@ public class ThreadLocalRandom extends Random {
private long rnd;
/**
- * Initialization flag to permit the first and only allowed call
- * to setSeed (inside Random constructor) to succeed. We can't
- * allow others since it would cause setting seed in one part of a
- * program to unintentionally impact other usages by the thread.
+ * Initialization flag to permit calls to setSeed to succeed only
+ * while executing the Random constructor. We can't allow others
+ * since it would cause setting seed in one part of a program to
+ * unintentionally impact other usages by the thread.
*/
boolean initialized;
@@ -98,11 +98,10 @@ public class ThreadLocalRandom extends Random {
/**
* Constructor called only by localRandom.initialValue.
- * We rely on the fact that the superclass no-arg constructor
- * invokes setSeed exactly once to initialize.
*/
ThreadLocalRandom() {
super();
+ initialized = true;
}
/**
@@ -123,7 +122,6 @@ public class ThreadLocalRandom extends Random {
public void setSeed(long seed) {
if (initialized)
throw new UnsupportedOperationException();
- initialized = true;
rnd = (seed ^ multiplier) & mask;
}
diff --git a/src/share/classes/java/util/jar/Pack200.java b/src/share/classes/java/util/jar/Pack200.java
index 83a5d2049..41dec9180 100644
--- a/src/share/classes/java/util/jar/Pack200.java
+++ b/src/share/classes/java/util/jar/Pack200.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003,2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -212,10 +212,18 @@ public abstract class Pack200 {
* to produce a specific bytewise image for any given transmission
* ordering of archive elements.)
* <p>
- * In order to maintain backward compatibility, if the input JAR-files are
- * solely comprised of 1.5 (or lesser) classfiles, a 1.5 compatible
- * pack file is produced. Otherwise a 1.6 compatible pack200 file is
- * produced.
+ * In order to maintain backward compatibility, the pack file's version is
+ * set to accommodate the class files present in the input JAR file. In
+ * other words, the pack file version will be the latest, if the class files
+ * are the latest and conversely the pack file version will be the oldest
+ * if the class file versions are also the oldest. For intermediate class
+ * file versions the corresponding pack file version will be used.
+ * For example:
+ * If the input JAR-files are solely comprised of 1.5 (or lesser)
+ * class files, a 1.5 compatible pack file is produced. This will also be
+ * the case for archives that have no class files.
+ * If the input JAR-files contains a 1.6 class file, then the pack file
+ * version will be set to 1.6.
* <p>
* @since 1.5
*/
@@ -236,9 +244,10 @@ public abstract class Pack200 {
* input file to be transmitted in the segment, along with the size
* of its name and other transmitted properties.
* <p>
- * The default is 1000000 (a million bytes). This allows input JAR files
- * of moderate size to be transmitted in one segment. It also puts
- * a limit on memory requirements for packers and unpackers.
+ * The default is -1, which means the packer will always create a single
+ * segment output file. In cases where extremely large output files are
+ * generated, users are strongly encouraged to use segmenting or break
+ * up the input file into smaller JARs.
* <p>
* A 10Mb JAR packed without this limit will
* typically pack about 10% smaller, but the packer may require
diff --git a/src/share/classes/sun/io/ByteToCharISO2022.java b/src/share/classes/sun/io/ByteToCharISO2022.java
index 4b2e21b56..5fef812fd 100644
--- a/src/share/classes/sun/io/ByteToCharISO2022.java
+++ b/src/share/classes/sun/io/ByteToCharISO2022.java
@@ -124,15 +124,15 @@ public abstract class ByteToCharISO2022 extends ByteToCharConverter
switch(shiftFlag) {
case SOFlag:
tmpIndex = curSODes;
- tmpConverter = (ByteToCharConverter [])SOConverter;
+ tmpConverter = SOConverter;
break;
case SS2Flag:
tmpIndex = curSS2Des;
- tmpConverter = (ByteToCharConverter [])SS2Converter;
+ tmpConverter = SS2Converter;
break;
case SS3Flag:
tmpIndex = curSS3Des;
- tmpConverter = (ByteToCharConverter [])SS3Converter;
+ tmpConverter = SS3Converter;
break;
}
diff --git a/src/share/classes/sun/io/ByteToCharISO2022JP.java b/src/share/classes/sun/io/ByteToCharISO2022JP.java
index 8000870fb..03027c247 100644
--- a/src/share/classes/sun/io/ByteToCharISO2022JP.java
+++ b/src/share/classes/sun/io/ByteToCharISO2022JP.java
@@ -141,7 +141,7 @@ public class ByteToCharISO2022JP extends ByteToCharJIS0208 {
} else {
savedSize = 2;
savedBytes[0] = (byte)byte1;
- savedBytes[1] = (byte)input[readOff + inputSize];
+ savedBytes[1] = input[readOff + inputSize];
inputSize++;
}
break;
diff --git a/src/share/classes/sun/io/ByteToCharJISAutoDetect.java b/src/share/classes/sun/io/ByteToCharJISAutoDetect.java
index 97a0e8828..8f00ef6c2 100644
--- a/src/share/classes/sun/io/ByteToCharJISAutoDetect.java
+++ b/src/share/classes/sun/io/ByteToCharJISAutoDetect.java
@@ -34,14 +34,12 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter {
private final static int SJIS1B_MASK = 0x04;
private final static int EUCJP_KANA1_MASK = 0x08;
private final static int EUCJP_KANA2_MASK = 0x10;
- private static byte[] maskTable1;
- private static byte[] maskTable2;
+ private final static byte[] maskTable1 = JISAutoDetect.getByteMask1();
+ private final static byte[] maskTable2 = JISAutoDetect.getByteMask2();
private final static int SS2 = 0x8e;
private final static int SS3 = 0x8f;
- private final static JISAutoDetect nioCoder = new JISAutoDetect();
-
// SJISName is set to either "SJIS" or "MS932"
private String SJISName;
private String EUCJPName;
@@ -57,8 +55,6 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter {
defaultConv = new ByteToCharISO8859_1();
defaultConv.subChars = subChars;
defaultConv.subMode = subMode;
- maskTable1 = nioCoder.getByteMask1();
- maskTable2 = nioCoder.getByteMask2();
}
public int flush(char [] output, int outStart, int outEnd)
@@ -133,7 +129,7 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter {
break;
}
if ((mask == SJIS2B_MASK) || (mask == SJIS1B_MASK)
- || (nioCoder.canBeSJIS1B(firstmask) && secondmask == 0)) {
+ || (JISAutoDetect.canBeSJIS1B(firstmask) && secondmask == 0)) {
convName = SJISName;
break;
}
@@ -145,15 +141,15 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter {
// character boundary. If we tried both
// possibilities here, it might be able to be
// determined correctly.
- if ((byte1 == SS3) && nioCoder.canBeEUCJP(secondmask)) {
+ if ((byte1 == SS3) && JISAutoDetect.canBeEUCJP(secondmask)) {
if (cnt+1 < inEnd) {
int nextbyte = input[cnt+1] & 0xff;
- if (! nioCoder.canBeEUCJP(maskTable2[nextbyte]))
+ if (! JISAutoDetect.canBeEUCJP(maskTable2[nextbyte]))
convName = SJISName;
} else
convName = SJISName;
}
- if (nioCoder.canBeEUCKana(firstmask, secondmask))
+ if (JISAutoDetect.canBeEUCKana(firstmask, secondmask))
euckana++;
} else {
if ((firstmask & SJIS1B_MASK) != 0) {
diff --git a/src/share/classes/sun/io/CharToBytePCK.java b/src/share/classes/sun/io/CharToBytePCK.java
index 0c877df0e..9a8d1a76c 100644
--- a/src/share/classes/sun/io/CharToBytePCK.java
+++ b/src/share/classes/sun/io/CharToBytePCK.java
@@ -66,7 +66,7 @@ public class CharToBytePCK extends CharToByteSJIS {
switch (ch) {
case '\u2015':
- return (int)0x815C;
+ return 0x815C;
case '\u2014':
return 0;
default:
diff --git a/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java b/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java
index da54a3d64..a59488814 100644
--- a/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java
+++ b/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java
@@ -171,10 +171,9 @@ public class DatagramSocketAdaptor
// Must hold dc.blockingLock()
//
- private void receive(ByteBuffer bb) throws IOException {
+ private SocketAddress receive(ByteBuffer bb) throws IOException {
if (timeout == 0) {
- dc.receive(bb);
- return;
+ return dc.receive(bb);
}
// Implement timeout with a selector
@@ -183,8 +182,9 @@ public class DatagramSocketAdaptor
dc.configureBlocking(false);
try {
int n;
- if (dc.receive(bb) != null)
- return;
+ SocketAddress sender;
+ if ((sender = dc.receive(bb)) != null)
+ return sender;
sel = Util.getTemporarySelector(dc);
sk = dc.register(sel, SelectionKey.OP_READ);
long to = timeout;
@@ -194,8 +194,8 @@ public class DatagramSocketAdaptor
long st = System.currentTimeMillis();
int ns = sel.select(to);
if (ns > 0 && sk.isReadable()) {
- if (dc.receive(bb) != null)
- return;
+ if ((sender = dc.receive(bb)) != null)
+ return sender;
}
sel.selectedKeys().remove(sk);
to -= System.currentTimeMillis() - st;
@@ -222,7 +222,8 @@ public class DatagramSocketAdaptor
ByteBuffer bb = ByteBuffer.wrap(p.getData(),
p.getOffset(),
p.getLength());
- receive(bb);
+ SocketAddress sender = receive(bb);
+ p.setSocketAddress(sender);
p.setLength(bb.position() - p.getOffset());
}
} catch (IOException x) {
diff --git a/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java b/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java
index c1b3f3bf3..eff83e2bf 100644
--- a/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java
+++ b/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java
@@ -144,11 +144,7 @@ public class ServerSocketAdaptor // package-private
}
public void close() throws IOException {
- try {
- ssc.close();
- } catch (Exception x) {
- Net.translateException(x);
- }
+ ssc.close();
}
public ServerSocketChannel getChannel() {
diff --git a/src/share/classes/sun/nio/ch/SocketAdaptor.java b/src/share/classes/sun/nio/ch/SocketAdaptor.java
index 36c8d9f20..583835727 100644
--- a/src/share/classes/sun/nio/ch/SocketAdaptor.java
+++ b/src/share/classes/sun/nio/ch/SocketAdaptor.java
@@ -404,11 +404,7 @@ public class SocketAdaptor
}
public void close() throws IOException {
- try {
- sc.close();
- } catch (Exception x) {
- Net.translateToSocketException(x);
- }
+ sc.close();
}
public void shutdownInput() throws IOException {
diff --git a/src/share/classes/sun/nio/cs/ext/DoubleByte.java b/src/share/classes/sun/nio/cs/ext/DoubleByte.java
index f76c9cc7d..265e03c71 100644
--- a/src/share/classes/sun/nio/cs/ext/DoubleByte.java
+++ b/src/share/classes/sun/nio/cs/ext/DoubleByte.java
@@ -103,7 +103,7 @@ public class DoubleByte {
public final static char[] B2C_UNMAPPABLE;
static {
B2C_UNMAPPABLE = new char[0x100];
- Arrays.fill(B2C_UNMAPPABLE, (char)UNMAPPABLE_DECODING);
+ Arrays.fill(B2C_UNMAPPABLE, UNMAPPABLE_DECODING);
}
public static class Decoder extends CharsetDecoder
@@ -374,7 +374,7 @@ public class DoubleByte {
static final char[] b2cSB;
static {
b2cSB = new char[0x100];
- Arrays.fill(b2cSB, (char)UNMAPPABLE_DECODING);
+ Arrays.fill(b2cSB, UNMAPPABLE_DECODING);
}
Decoder_EBCDIC_DBCSONLY(Charset cs, char[][] b2c, int b2Min, int b2Max) {
super(cs, 0.5f, 1.0f, b2c, b2cSB, b2Min, b2Max);
diff --git a/src/share/classes/sun/nio/cs/ext/EUC_JP.java b/src/share/classes/sun/nio/cs/ext/EUC_JP.java
index 03de24834..6443de399 100644
--- a/src/share/classes/sun/nio/cs/ext/EUC_JP.java
+++ b/src/share/classes/sun/nio/cs/ext/EUC_JP.java
@@ -79,8 +79,10 @@ public class EUC_JP
JIS_X_0201.Decoder decoderJ0201;
JIS_X_0212_Decoder decoderJ0212;
- short[] j0208Index1;
- String[] j0208Index2;
+ private static final short[] j0208Index1 =
+ JIS_X_0208_Decoder.getIndex1();
+ private static final String[] j0208Index2 =
+ JIS_X_0208_Decoder.getIndex2();
protected Decoder(Charset cs) {
super(cs);
@@ -88,8 +90,6 @@ public class EUC_JP
decoderJ0212 = new JIS_X_0212_Decoder(cs);
start = 0xa1;
end = 0xfe;
- j0208Index1 = super.getIndex1();
- j0208Index2 = super.getIndex2();
}
protected char decode0212(int byte1, int byte2) {
return decoderJ0212.decodeDouble(byte1, byte2);
@@ -238,8 +238,10 @@ public class EUC_JP
JIS_X_0201.Encoder encoderJ0201;
JIS_X_0212_Encoder encoderJ0212;
- short[] j0208Index1;
- String[] j0208Index2;
+ private static final short[] j0208Index1 =
+ JIS_X_0208_Encoder.getIndex1();
+ private static final String[] j0208Index2 =
+ JIS_X_0208_Encoder.getIndex2();
private final Surrogate.Parser sgp = new Surrogate.Parser();
@@ -247,8 +249,6 @@ public class EUC_JP
super(cs, 3.0f, 3.0f);
encoderJ0201 = new JIS_X_0201.Encoder(cs);
encoderJ0212 = new JIS_X_0212_Encoder(cs);
- j0208Index1 = super.getIndex1();
- j0208Index2 = super.getIndex2();
}
public boolean canEncode(char c) {
diff --git a/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java b/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java
index fbbd30b13..480a4a740 100644
--- a/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java
+++ b/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java
@@ -65,20 +65,18 @@ public class EUC_JP_LINUX
private static class Decoder extends CharsetDecoder {
JIS_X_0201.Decoder decoderJ0201;
- JIS_X_0208_Decoder decodeMappingJ0208;
protected final char REPLACE_CHAR='\uFFFD';
- short[] jis0208Index1;
- String[] jis0208Index2;
+ private static final int start = 0xa1;
+ private static final int end = 0xfe;
+ private static final short[] jis0208Index1 =
+ JIS_X_0208_Decoder.getIndex1();
+ private static final String[] jis0208Index2 =
+ JIS_X_0208_Decoder.getIndex2();
private Decoder(Charset cs) {
super(cs, 1.0f, 1.0f);
decoderJ0201 = new JIS_X_0201.Decoder(cs);
- decodeMappingJ0208 = new JIS_X_0208_Decoder(cs);
- decodeMappingJ0208.start = 0xa1;
- decodeMappingJ0208.end = 0xfe;
- jis0208Index1 = decodeMappingJ0208.getIndex1();
- jis0208Index2 = decodeMappingJ0208.getIndex2();
}
protected char convSingleByte(int b) {
@@ -93,11 +91,11 @@ public class EUC_JP_LINUX
}
if (((byte1 < 0) || (byte1 > jis0208Index1.length))
- || ((byte2 < decodeMappingJ0208.start) || (byte2 > decodeMappingJ0208.end)))
+ || ((byte2 < start) || (byte2 > end)))
return REPLACE_CHAR;
- int n = (jis0208Index1[byte1 - 0x80] & 0xf) * (decodeMappingJ0208.end - decodeMappingJ0208.start + 1)
- + (byte2 - decodeMappingJ0208.start);
+ int n = (jis0208Index1[byte1 - 0x80] & 0xf) * (end - start + 1)
+ + (byte2 - start);
return jis0208Index2[jis0208Index1[byte1 - 0x80] >> 4].charAt(n);
}
@@ -213,18 +211,16 @@ public class EUC_JP_LINUX
private static class Encoder extends CharsetEncoder {
JIS_X_0201.Encoder encoderJ0201;
- JIS_X_0208_Encoder encoderJ0208;
private final Surrogate.Parser sgp = new Surrogate.Parser();
- short[] jis0208Index1;
- String[] jis0208Index2;
+ private static final short[] jis0208Index1 =
+ JIS_X_0208_Encoder.getIndex1();
+ private static final String[] jis0208Index2 =
+ JIS_X_0208_Encoder.getIndex2();
private Encoder(Charset cs) {
super(cs, 2.0f, 2.0f);
encoderJ0201 = new JIS_X_0201.Encoder(cs);
- encoderJ0208 = new JIS_X_0208_Encoder(cs);
- jis0208Index1 = encoderJ0208.getIndex1();
- jis0208Index2 = encoderJ0208.getIndex2();
}
public boolean canEncode(char c) {
diff --git a/src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java b/src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java
index 4043dc1ad..b36b76d3c 100644
--- a/src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java
+++ b/src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java
@@ -75,8 +75,12 @@ public class EUC_JP_Open
JIS_X_0212_Solaris_Decoder decodeMappingJ0212;
JIS_X_0208_Solaris_Decoder decodeMappingJ0208;
- short[] j0208Index1;
- String[] j0208Index2;
+ private static final short[] j0208Index1 =
+ JIS_X_0208_Solaris_Decoder.getIndex1();
+ private static final String[] j0208Index2 =
+ JIS_X_0208_Solaris_Decoder.getIndex2();
+ private static final int start = 0xa1;
+ private static final int end = 0xfe;
protected final char REPLACE_CHAR='\uFFFD';
@@ -84,11 +88,6 @@ public class EUC_JP_Open
super(cs);
decoderJ0201 = new JIS_X_0201.Decoder(cs);
decodeMappingJ0212 = new JIS_X_0212_Solaris_Decoder(cs);
- decodeMappingJ0208 = new JIS_X_0208_Solaris_Decoder(cs);
- decodeMappingJ0208.start = 0xa1;
- decodeMappingJ0208.end = 0xfe;
- j0208Index1 = decodeMappingJ0208.getIndex1();
- j0208Index2 = decodeMappingJ0208.getIndex2();
}
@@ -103,9 +102,9 @@ public class EUC_JP_Open
}
if (((byte1 < 0)
- || (byte1 > decodeMappingJ0208.getIndex1().length))
- || ((byte2 < decodeMappingJ0208.start)
- || (byte2 > decodeMappingJ0208.end)))
+ || (byte1 > j0208Index1.length))
+ || ((byte2 < start)
+ || (byte2 > end)))
return REPLACE_CHAR;
char result = super.decodeDouble(byte1, byte2);
@@ -113,8 +112,8 @@ public class EUC_JP_Open
return result;
} else {
int n = (j0208Index1[byte1 - 0x80] & 0xf) *
- (decodeMappingJ0208.end - decodeMappingJ0208.start + 1)
- + (byte2 - decodeMappingJ0208.start);
+ (end - start + 1)
+ + (byte2 - start);
return j0208Index2[j0208Index1[byte1 - 0x80] >> 4].charAt(n);
}
}
@@ -125,10 +124,11 @@ public class EUC_JP_Open
JIS_X_0201.Encoder encoderJ0201;
JIS_X_0212_Solaris_Encoder encoderJ0212;
- JIS_X_0208_Solaris_Encoder encoderJ0208;
- short[] j0208Index1;
- String[] j0208Index2;
+ private static final short[] j0208Index1 =
+ JIS_X_0208_Solaris_Encoder.getIndex1();
+ private static final String[] j0208Index2 =
+ JIS_X_0208_Solaris_Encoder.getIndex2();
private final Surrogate.Parser sgp = new Surrogate.Parser();
@@ -136,9 +136,6 @@ public class EUC_JP_Open
super(cs);
encoderJ0201 = new JIS_X_0201.Encoder(cs);
encoderJ0212 = new JIS_X_0212_Solaris_Encoder(cs);
- encoderJ0208 = new JIS_X_0208_Solaris_Encoder(cs);
- j0208Index1 = encoderJ0208.getIndex1();
- j0208Index2 = encoderJ0208.getIndex2();
}
protected int encodeSingle(char inputChar, byte[] outputByte) {
diff --git a/src/share/classes/sun/nio/cs/ext/EUC_TW.java b/src/share/classes/sun/nio/cs/ext/EUC_TW.java
index 368b47190..a4ae8df6e 100644
--- a/src/share/classes/sun/nio/cs/ext/EUC_TW.java
+++ b/src/share/classes/sun/nio/cs/ext/EUC_TW.java
@@ -423,7 +423,7 @@ public class EUC_TW extends Charset implements HistoricallyNamedCharset
if (dst.remaining() < outSize)
return CoderResult.OVERFLOW;
for (int i = 0; i < outSize; i++)
- dst.put((byte)bb[i]);
+ dst.put(bb[i]);
mark += inSize;
}
return CoderResult.UNDERFLOW;
diff --git a/src/share/classes/sun/nio/cs/ext/GB18030.java b/src/share/classes/sun/nio/cs/ext/GB18030.java
index 20df56007..acbe23a36 100644
--- a/src/share/classes/sun/nio/cs/ext/GB18030.java
+++ b/src/share/classes/sun/nio/cs/ext/GB18030.java
@@ -12339,7 +12339,7 @@ public class GB18030
int start = 0x40, end = 0xFE;
if (((byte1 < 0) || (byte1 > index1.length))
|| ((byte2 < start) || (byte2 > end)))
- return (char)'\uFFFD';
+ return '\uFFFD';
int n = (index1[byte1] & 0xf) * (end - start + 1) + (byte2 - start);
return index2[index1[byte1] >> 4].charAt(n);
diff --git a/src/share/classes/sun/nio/cs/ext/HKSCS.java b/src/share/classes/sun/nio/cs/ext/HKSCS.java
index d2e118e01..69002ee2b 100644
--- a/src/share/classes/sun/nio/cs/ext/HKSCS.java
+++ b/src/share/classes/sun/nio/cs/ext/HKSCS.java
@@ -43,7 +43,7 @@ public class HKSCS {
private char[][] b2cBmp;
private char[][] b2cSupp;
- private static DoubleByte.Decoder big5Dec;
+ private DoubleByte.Decoder big5Dec;
protected Decoder(Charset cs,
DoubleByte.Decoder big5Dec,
@@ -355,7 +355,7 @@ public class HKSCS {
c2b[hi] = new char[0x100];
Arrays.fill(c2b[hi], (char)UNMAPPABLE_ENCODING);
}
- c2b[hi][c & 0xff] = (char)bb;
+ c2b[hi][c & 0xff] = bb;
}
c++;
}
diff --git a/src/share/classes/sun/nio/cs/ext/ISO2022.java b/src/share/classes/sun/nio/cs/ext/ISO2022.java
index faf803699..ad4e5978b 100644
--- a/src/share/classes/sun/nio/cs/ext/ISO2022.java
+++ b/src/share/classes/sun/nio/cs/ext/ISO2022.java
@@ -104,15 +104,15 @@ abstract class ISO2022
switch(shiftFlag) {
case SOFlag:
tmpIndex = curSODes;
- tmpDecoder = (CharsetDecoder [])SODecoder;
+ tmpDecoder = SODecoder;
break;
case SS2Flag:
tmpIndex = curSS2Des;
- tmpDecoder = (CharsetDecoder [])SS2Decoder;
+ tmpDecoder = SS2Decoder;
break;
case SS3Flag:
tmpIndex = curSS3Des;
- tmpDecoder = (CharsetDecoder [])SS3Decoder;
+ tmpDecoder = SS3Decoder;
break;
}
diff --git a/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java b/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java
index 78007a02a..e190bd587 100644
--- a/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java
+++ b/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java
@@ -82,11 +82,11 @@ public class JISAutoDetect
* with the sun.io JISAutoDetect implementation
*/
- public byte[] getByteMask1() {
+ public static byte[] getByteMask1() {
return Decoder.maskTable1;
}
- public byte[] getByteMask2() {
+ public static byte[] getByteMask2() {
return Decoder.maskTable2;
}
diff --git a/src/share/classes/sun/nio/cs/ext/PCK.java b/src/share/classes/sun/nio/cs/ext/PCK.java
index a11a9dda5..2c2387e00 100644
--- a/src/share/classes/sun/nio/cs/ext/PCK.java
+++ b/src/share/classes/sun/nio/cs/ext/PCK.java
@@ -101,17 +101,15 @@ public class PCK
private static class Encoder extends SJIS.Encoder {
private JIS_X_0201.Encoder jis0201;
- private JIS_X_0208_Solaris_Encoder jis0208;
- short[] j0208Index1;
- String[] j0208Index2;
+ private static final short[] j0208Index1 =
+ JIS_X_0208_Solaris_Encoder.getIndex1();
+ private static final String[] j0208Index2 =
+ JIS_X_0208_Solaris_Encoder.getIndex2();
private Encoder(Charset cs) {
super(cs);
jis0201 = new JIS_X_0201.Encoder(cs);
- jis0208 = new JIS_X_0208_Solaris_Encoder(cs);
- j0208Index1 = jis0208.getIndex1();
- j0208Index2 = jis0208.getIndex2();
}
protected int encodeDouble(char ch) {
@@ -121,7 +119,7 @@ public class PCK
switch (ch) {
case '\u2015':
- return (int)0x815C;
+ return 0x815C;
case '\u2014':
return 0;
default:
diff --git a/src/share/classes/sun/nio/cs/ext/SJIS.java b/src/share/classes/sun/nio/cs/ext/SJIS.java
index 65a03aea1..1f8a8ea0c 100644
--- a/src/share/classes/sun/nio/cs/ext/SJIS.java
+++ b/src/share/classes/sun/nio/cs/ext/SJIS.java
@@ -114,14 +114,14 @@ public class SJIS
private JIS_X_0201.Encoder jis0201;
- short[] j0208Index1;
- String[] j0208Index2;
+ private static final short[] j0208Index1 =
+ JIS_X_0208_Encoder.getIndex1();
+ private static final String[] j0208Index2 =
+ JIS_X_0208_Encoder.getIndex2();
protected Encoder(Charset cs) {
super(cs);
jis0201 = new JIS_X_0201.Encoder(cs);
- j0208Index1 = super.getIndex1();
- j0208Index2 = super.getIndex2();
}
protected int encodeSingle(char inputChar) {
diff --git a/src/share/classes/sun/security/krb5/EncryptionKey.java b/src/share/classes/sun/security/krb5/EncryptionKey.java
index ac54b14d5..ff920af8e 100644
--- a/src/share/classes/sun/security/krb5/EncryptionKey.java
+++ b/src/share/classes/sun/security/krb5/EncryptionKey.java
@@ -188,24 +188,13 @@ public class EncryptionKey
etypes = EType.getBuiltInDefaults();
}
- // set the preferred etype for preauth
- if ((pa_exists) && (pa_etype != EncryptedData.ETYPE_NULL)) {
- if (DEBUG) {
- System.out.println("Pre-Authentication: " +
- "Set preferred etype = " + pa_etype);
- }
- if (EType.isSupported(pa_etype)) {
- // reset etypes to preferred value
- etypes = new int[1];
- etypes[0] = pa_etype;
- }
- }
-
EncryptionKey[] encKeys = new EncryptionKey[etypes.length];
for (int i = 0; i < etypes.length; i++) {
if (EType.isSupported(etypes[i])) {
+ byte[] s2kparams = (pa_exists && etypes[i] == pa_etype)
+ ? pa_s2kparams : null;
encKeys[i] = new EncryptionKey(
- stringToKey(password, salt, pa_s2kparams, etypes[i]),
+ stringToKey(password, salt, s2kparams, etypes[i]),
etypes[i], null);
} else {
if (DEBUG) {
diff --git a/src/share/classes/sun/security/krb5/KrbAsReq.java b/src/share/classes/sun/security/krb5/KrbAsReq.java
index 4073ddf26..77f379833 100644
--- a/src/share/classes/sun/security/krb5/KrbAsReq.java
+++ b/src/share/classes/sun/security/krb5/KrbAsReq.java
@@ -342,20 +342,20 @@ public class KrbAsReq extends KrbKdcReq {
}
princName = cname;
-
- EncryptionKey key = null;
- int[] tktETypes = EType.getDefaults("default_tkt_enctypes");
- if (pa_exists && pa_etype != EncryptedData.ETYPE_NULL) {
- if (DEBUG) {
- System.out.println("Pre-Authenticaton: find key for etype = " + pa_etype);
- }
- key = EncryptionKey.findKey(pa_etype, keys);
- } else {
- key = EncryptionKey.findKey(tktETypes[0], keys);
- }
-
+ int[] tktETypes = EType.getDefaults("default_tkt_enctypes", keys);
PAData[] paData = null;
if (PA_ENC_TIMESTAMP_REQUIRED) {
+ EncryptionKey key = null;
+ if (pa_etype != EncryptedData.ETYPE_NULL) {
+ if (DEBUG) {
+ System.out.println("Pre-Authenticaton: find key for etype = " + pa_etype);
+ }
+ key = EncryptionKey.findKey(pa_etype, keys);
+ } else {
+ if (tktETypes.length > 0) {
+ key = EncryptionKey.findKey(tktETypes[0], keys);
+ }
+ }
if (DEBUG) {
System.out.println("AS-REQ: Add PA_ENC_TIMESTAMP now");
}
diff --git a/src/share/classes/sun/security/krb5/internal/KRBError.java b/src/share/classes/sun/security/krb5/internal/KRBError.java
index dca82a439..4bf1de79e 100644
--- a/src/share/classes/sun/security/krb5/internal/KRBError.java
+++ b/src/share/classes/sun/security/krb5/internal/KRBError.java
@@ -286,6 +286,19 @@ public class KRBError implements java.io.Serializable {
salt = info.getSalt();
if (DEBUG) {
System.out.println("\t PA-ETYPE-INFO etype = " + etype);
+ System.out.println("\t PA-ETYPE-INFO salt = " + salt);
+ }
+ while (der.data.available() > 0) {
+ value = der.data.getDerValue();
+ info = new ETypeInfo(value);
+ if (DEBUG) {
+ etype = info.getEType();
+ System.out.println("\t salt for " + etype
+ + " is " + info.getSalt());
+ }
+ if (salt == null || salt.isEmpty()) {
+ salt = info.getSalt();
+ }
}
}
break;
@@ -299,6 +312,19 @@ public class KRBError implements java.io.Serializable {
s2kparams = info2.getParams();
if (DEBUG) {
System.out.println("\t PA-ETYPE-INFO2 etype = " + etype);
+ System.out.println("\t PA-ETYPE-INFO salt = " + salt);
+ }
+ while (der.data.available() > 0) {
+ value = der.data.getDerValue();
+ info2 = new ETypeInfo2(value);
+ if (DEBUG) {
+ etype = info2.getEType();
+ System.out.println("\t salt for " + etype
+ + " is " + info2.getSalt());
+ }
+ if (salt == null || salt.isEmpty()) {
+ salt = info2.getSalt();
+ }
}
}
break;
diff --git a/src/share/classes/sun/security/validator/PKIXValidator.java b/src/share/classes/sun/security/validator/PKIXValidator.java
index 8068a9db8..59daa9eef 100644
--- a/src/share/classes/sun/security/validator/PKIXValidator.java
+++ b/src/share/classes/sun/security/validator/PKIXValidator.java
@@ -53,7 +53,7 @@ public final class PKIXValidator extends Validator {
private int certPathLength = -1;
// needed only for the validator
- private Map<X500Principal, X509Certificate> trustedSubjects;
+ private Map<X500Principal, List<PublicKey>> trustedSubjects;
private CertificateFactory factory;
private boolean plugin = false;
@@ -95,9 +95,17 @@ public final class PKIXValidator extends Validator {
if (TRY_VALIDATOR == false) {
return;
}
- trustedSubjects = new HashMap<X500Principal, X509Certificate>();
+ trustedSubjects = new HashMap<X500Principal, List<PublicKey>>();
for (X509Certificate cert : trustedCerts) {
- trustedSubjects.put(cert.getSubjectX500Principal(), cert);
+ X500Principal dn = cert.getSubjectX500Principal();
+ List<PublicKey> keys;
+ if (trustedSubjects.containsKey(dn)) {
+ keys = trustedSubjects.get(dn);
+ } else {
+ keys = new ArrayList<PublicKey>();
+ trustedSubjects.put(dn, keys);
+ }
+ keys.add(cert.getPublicKey());
}
try {
factory = CertificateFactory.getInstance("X.509");
@@ -161,13 +169,21 @@ public final class PKIXValidator extends Validator {
// chain is not ordered correctly, call builder instead
return doBuild(chain, otherCerts);
}
- if (trustedSubjects.containsKey(dn)
- && trustedSubjects.get(dn).getPublicKey()
- .equals(cert.getPublicKey())) {
+
+ // Check if chain[i] is already trusted. It may be inside
+ // trustedCerts, or has the same dn and public key as a cert
+ // inside trustedCerts. The latter happens when a CA has
+ // updated its cert with a stronger signature algorithm in JRE
+ // but the weak one is still in circulation.
+
+ if (trustedCerts.contains(cert) || // trusted cert
+ (trustedSubjects.containsKey(dn) && // replacing ...
+ trustedSubjects.get(dn).contains( // ... weak cert
+ cert.getPublicKey()))) {
if (i == 0) {
return new X509Certificate[] {chain[0]};
}
- // Remove and call validator
+ // Remove and call validator on partial chain [0 .. i-1]
X509Certificate[] newChain = new X509Certificate[i];
System.arraycopy(chain, 0, newChain, 0, i);
return doValidate(newChain);
@@ -217,14 +233,17 @@ public final class PKIXValidator extends Validator {
return doBuild(chain, otherCerts);
}
- private boolean isSignatureValid(X509Certificate iss, X509Certificate sub) {
+ private boolean isSignatureValid(List<PublicKey> keys, X509Certificate sub) {
if (plugin) {
- try {
- sub.verify(iss.getPublicKey());
- } catch (Exception ex) {
- return false;
+ for (PublicKey key: keys) {
+ try {
+ sub.verify(key);
+ return true;
+ } catch (Exception ex) {
+ continue;
+ }
}
- return true;
+ return false;
}
return true; // only check if PLUGIN is set
}
diff --git a/src/share/classes/sun/tools/jstat/Arguments.java b/src/share/classes/sun/tools/jstat/Arguments.java
index a6453203a..151917559 100644
--- a/src/share/classes/sun/tools/jstat/Arguments.java
+++ b/src/share/classes/sun/tools/jstat/Arguments.java
@@ -47,6 +47,7 @@ public class Arguments {
private static final String JVMSTAT_USERDIR = ".jvmstat";
private static final String OPTIONS_FILENAME = "jstat_options";
+ private static final String UNSUPPORTED_OPTIONS_FILENAME = "jstat_unsupported_options";
private static final String ALL_NAMES = "\\w*";
private Comparator<Monitor> comparator;
@@ -411,8 +412,8 @@ public class Arguments {
return optionFormat;
}
- public URL[] optionsSources() {
- URL[] sources = new URL[2];
+ public List<URL> optionsSources() {
+ List<URL> sources = new ArrayList<URL>();
int i = 0;
String filename = OPTIONS_FILENAME;
@@ -421,7 +422,7 @@ public class Arguments {
String userHome = System.getProperty("user.home");
String userDir = userHome + "/" + JVMSTAT_USERDIR;
File home = new File(userDir + "/" + filename);
- sources[i++] = home.toURL();
+ sources.add(home.toURI().toURL());
} catch (Exception e) {
if (debug) {
System.err.println(e.getMessage());
@@ -430,8 +431,15 @@ public class Arguments {
throw new IllegalArgumentException("Internal Error: Bad URL: "
+ e.getMessage());
}
- sources[i] = this.getClass().getResource("resources/" + filename);
- assert sources[i] != null;
+ URL u = this.getClass().getResource("resources/" + filename);
+ assert u != null;
+ sources.add(u);
+
+ if (showUnsupported) {
+ u = this.getClass().getResource("resources/" + UNSUPPORTED_OPTIONS_FILENAME);
+ assert u != null;
+ sources.add(u);
+ }
return sources;
}
}
diff --git a/src/share/classes/sun/tools/jstat/OptionFinder.java b/src/share/classes/sun/tools/jstat/OptionFinder.java
index 628bd6c99..6efa5737a 100644
--- a/src/share/classes/sun/tools/jstat/OptionFinder.java
+++ b/src/share/classes/sun/tools/jstat/OptionFinder.java
@@ -39,9 +39,9 @@ public class OptionFinder {
private static final boolean debug = false;
- URL[] optionsSources;
+ List<URL> optionsSources;
- public OptionFinder(URL[] optionsSources) {
+ public OptionFinder(List<URL> optionsSources) {
this.optionsSources = optionsSources;
}
@@ -59,24 +59,25 @@ public class OptionFinder {
return of;
}
- protected OptionFormat getOptionFormat(String option, URL[] sources) {
+ protected OptionFormat getOptionFormat(String option, List<URL> sources) {
OptionFormat of = null;
- for (int i = 0; (i < sources.length) && (of == null); i++) {
+ for (URL u : sources) {
try {
- URL u = sources[i];
Reader r = new BufferedReader(
new InputStreamReader(u.openStream()));
of = new Parser(r).parse(option);
+ if (of != null)
+ break;
} catch (IOException e) {
if (debug) {
- System.err.println("Error processing " + sources[i]
+ System.err.println("Error processing " + u
+ " : " + e.getMessage());
e.printStackTrace();
}
} catch (ParserException e) {
// Exception in parsing the options file.
- System.err.println(sources[i] + ": " + e.getMessage());
- System.err.println("Parsing of " + sources[i] + " aborted");
+ System.err.println(u + ": " + e.getMessage());
+ System.err.println("Parsing of " + u + " aborted");
}
}
return of;
diff --git a/src/share/classes/sun/tools/jstat/OptionLister.java b/src/share/classes/sun/tools/jstat/OptionLister.java
index d274a4082..5ed55647d 100644
--- a/src/share/classes/sun/tools/jstat/OptionLister.java
+++ b/src/share/classes/sun/tools/jstat/OptionLister.java
@@ -37,9 +37,9 @@ import java.io.*;
*/
public class OptionLister {
private static final boolean debug = false;
- private URL[] sources;
+ private List<URL> sources;
- public OptionLister(URL[] sources) {
+ public OptionLister(List<URL> sources) {
this.sources = sources;
}
@@ -54,9 +54,8 @@ public class OptionLister {
Set<OptionFormat> options = new TreeSet<OptionFormat>(c);
- for (int i = 0; i < sources.length; i++) {
+ for (URL u : sources) {
try {
- URL u = sources[i];
Reader r = new BufferedReader(
new InputStreamReader(u.openStream()));
Set<OptionFormat> s = new Parser(r).parseOptions();
@@ -68,8 +67,8 @@ public class OptionLister {
}
} catch (ParserException e) {
// Exception in parsing the options file.
- System.err.println(sources[i] + ": " + e.getMessage());
- System.err.println("Parsing of " + sources[i] + " aborted");
+ System.err.println(u + ": " + e.getMessage());
+ System.err.println("Parsing of " + u + " aborted");
}
}
diff --git a/src/share/classes/sun/tools/jstat/resources/jstat_options b/src/share/classes/sun/tools/jstat/resources/jstat_options
index a32027d4d..f339965e5 100644
--- a/src/share/classes/sun/tools/jstat/resources/jstat_options
+++ b/src/share/classes/sun/tools/jstat/resources/jstat_options
@@ -37,7 +37,7 @@ option timestamp {
option class {
column {
header "^Loaded^" /* Number of classes loaded */
- data java.cls.loadedClasses
+ data (java.cls.loadedClasses + java.cls.sharedLoadedClasses)
align right
scale raw
width 5
@@ -45,7 +45,7 @@ option class {
}
column {
header "^Bytes^" /* Accumulated Size of classes loaded */
- data sun.cls.loadedBytes
+ data (sun.cls.loadedBytes + sun.cls.sharedLoadedBytes)
align right
scale K
width 7
@@ -53,7 +53,7 @@ option class {
}
column {
header "^Unloaded^" /* Number of classes unloaded */
- data java.cls.unloadedClasses
+ data (java.cls.unloadedClasses + java.cls.sharedUnloadedClasses)
align right
width 5
scale raw
@@ -61,7 +61,7 @@ option class {
}
column {
header "^Bytes^" /* Accumulated size of classes unloaded */
- data sun.cls.unloadedBytes
+ data (sun.cls.unloadedBytes + sun.cls.sharedUnloadedBytes)
align right
scale K
width 7
diff --git a/src/share/classes/sun/tools/jstat/resources/jstat_unsupported_options b/src/share/classes/sun/tools/jstat/resources/jstat_unsupported_options
new file mode 100644
index 000000000..37008e332
--- /dev/null
+++ b/src/share/classes/sun/tools/jstat/resources/jstat_unsupported_options
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+option classload {
+ column {
+ header "^Loaded^" /* Number of classes loaded */
+ data (java.cls.loadedClasses + java.cls.sharedLoadedClasses)
+ align right
+ scale raw
+ width 5
+ format "0"
+ }
+ column {
+ header "Time^" /* Accumulated time for class loading */
+ data sun.cls.time/sun.os.hrt.frequency
+ scale sec
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "^Inited^" /* Number of initialized classes */
+ data sun.cls.initializedClasses
+ align right
+ scale raw
+ width 5
+ format "0"
+ }
+ column {
+ header "Time^" /* Accumulated time for class initialization */
+ data sun.cls.classInitTime.self/sun.os.hrt.frequency
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "Shared^" /* Number of system classes loaded from shared archive */
+ data java.cls.sharedLoadedClasses
+ align right
+ scale raw
+ width 5
+ format "0"
+ }
+ column {
+ header "Kbytes^" /* Accumulated Size of classes loaded */
+ data sun.cls.sharedLoadedBytes
+ align right
+ scale K
+ width 7
+ format "0.0"
+ }
+ column {
+ header "LoadTime^" /* Accumulated time for loading classes from shared archive */
+ data sun.cls.sharedClassLoadTime/sun.os.hrt.frequency
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "^SysClass^" /* Number of system classes loaded */
+ data java.cls.loadedClasses
+ align right
+ scale raw
+ width 5
+ format "0"
+ }
+ column {
+ header "Kbytes^" /* Bytes read from system class files */
+ data sun.cls.sysClassBytes
+ align right
+ scale K
+ width 7
+ format "0.0"
+ }
+ column {
+ header "LoadTime^" /* Accumulated time for loading non-shared system classes */
+ data sun.cls.sysClassLoadTime/sun.os.hrt.frequency
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "Lookup^" /* Time spent in looking up/reading of system classes */
+ data sun.cls.lookupSysClassTime/sun.os.hrt.frequency
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "Parse^" /* Time spent in parsing system classes */
+ data sun.cls.parseClassTime.self/sun.os.hrt.frequency
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "^Linked^" /* Number of linked classes */
+ data sun.cls.linkedClasses
+ align right
+ scale raw
+ width 5
+ format "0"
+ }
+ column {
+ header "Time^" /* Accumulated time for class linking */
+ data sun.cls.classInitTime.self/sun.os.hrt.frequency
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "^Verified^" /* Number of verified classes */
+ data sun.cls.verifiedClasses
+ align right
+ scale raw
+ width 5
+ format "0"
+ }
+ column {
+ header "Time^" /* Accumulated time for class verification */
+ data sun.cls.classVerifyTime.self/sun.os.hrt.frequency
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "AppClass^" /* Number of loaded application classes */
+ data sun.cls.appClassLoadCount
+ align right
+ scale raw
+ width 5
+ format "0"
+ }
+ column {
+ header "Kbytes^" /* Bytes read from app class files */
+ data sun.cls.appClassBytes
+ align right
+ scale K
+ width 7
+ format "0.0"
+ }
+ column {
+ header "AppCL^" /* Accumulated time for loading app classes */
+ data sun.cls.appClassLoadTime/sun.os.hrt.frequency
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "^DefineClass^" /* Number of defineClass calls */
+ data sun.cls.defineAppClasses
+ align right
+ scale raw
+ width 5
+ format "0"
+ }
+ column {
+ header "Time^" /* Accumulated time for defineClass */
+ data sun.cls.defineAppClassTime.self/sun.os.hrt.frequency
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "^FindClass^" /* Number of findClass calls */
+ data sun.classloader.findClasses
+ align right
+ scale raw
+ width 5
+ format "0"
+ }
+ column {
+ header "Time^" /* Accumulated time for findClass */
+ data sun.classloader.findClassTime/1000000000
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "Delegation^" /* Parent class loader delegation time */
+ data sun.classloader.parentDelegationTime/1000000000
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+ column {
+ header "URLCL Read^" /* Accumulated time for URLClassLoader reading bytes */
+ data sun.urlClassLoader.readClassBytesTime/1000000000
+ scale raw
+ align right
+ width 10
+ format "0.000"
+ }
+}
+
diff --git a/src/share/demo/jvmti/hprof/sample.makefile.txt b/src/share/demo/jvmti/hprof/sample.makefile.txt
index 4b7499e40..3766a2877 100644
--- a/src/share/demo/jvmti/hprof/sample.makefile.txt
+++ b/src/share/demo/jvmti/hprof/sample.makefile.txt
@@ -132,7 +132,7 @@ ifeq ($(OSNAME), linux)
LIBRARY=lib$(LIBNAME).so
LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
# Libraries we are dependent on
- LIBRARIES= -lnsl -ldl -lc
+ LIBRARIES= -ldl -lc
# Building a shared library
LINK_SHARED=$(LINK.c) -shared -o $@
endif
diff --git a/src/solaris/classes/java/lang/UNIXProcess.java.linux b/src/solaris/classes/java/lang/UNIXProcess.java.linux
index 00eef09d4..af68ce18e 100644
--- a/src/solaris/classes/java/lang/UNIXProcess.java.linux
+++ b/src/solaris/classes/java/lang/UNIXProcess.java.linux
@@ -25,25 +25,42 @@
package java.lang;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadFactory;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
-/* java.lang.Process subclass in the UNIX environment.
+/**
+ * java.lang.Process subclass in the UNIX environment.
*
* @author Mario Wolczko and Ross Knippel.
* @author Konstantin Kladko (ported to Linux)
+ * @author Martin Buchholz
*/
-
final class UNIXProcess extends Process {
private static final sun.misc.JavaIOFileDescriptorAccess fdAccess
= sun.misc.SharedSecrets.getJavaIOFileDescriptorAccess();
- private int pid;
+ private final int pid;
private int exitcode;
private boolean hasExited;
- private OutputStream stdin_stream;
- private InputStream stdout_stream;
- private InputStream stderr_stream;
+ private /* final */ OutputStream stdin;
+ private /* final */ InputStream stdout;
+ private /* final */ InputStream stderr;
/* this is for the reaping thread */
private native int waitForProcessExit(int pid);
@@ -51,155 +68,136 @@ final class UNIXProcess extends Process {
/**
* Create a process using fork(2) and exec(2).
*
- * @param std_fds array of file descriptors. Indexes 0, 1, and
- * 2 correspond to standard input, standard output and
- * standard error, respectively. On input, a value of -1
- * means to create a pipe to connect child and parent
- * processes. On output, a value which is not -1 is the
- * parent pipe fd corresponding to the pipe which has
- * been created. An element of this array is -1 on input
- * if and only if it is <em>not</em> -1 on output.
+ * @param fds an array of three file descriptors.
+ * Indexes 0, 1, and 2 correspond to standard input,
+ * standard output and standard error, respectively. On
+ * input, a value of -1 means to create a pipe to connect
+ * child and parent processes. On output, a value which
+ * is not -1 is the parent pipe fd corresponding to the
+ * pipe which has been created. An element of this array
+ * is -1 on input if and only if it is <em>not</em> -1 on
+ * output.
* @return the pid of the subprocess
*/
private native int forkAndExec(byte[] prog,
byte[] argBlock, int argc,
byte[] envBlock, int envc,
byte[] dir,
- int[] std_fds,
+ int[] fds,
boolean redirectErrorStream)
throws IOException;
- /* In the process constructor we wait on this gate until the process */
- /* has been created. Then we return from the constructor. */
- /* fork() is called by the same thread which later waits for the process */
- /* to terminate */
-
- private static class Gate {
-
- private boolean exited = false;
- private IOException savedException;
-
- synchronized void exit() { /* Opens the gate */
- exited = true;
- this.notify();
- }
-
- synchronized void waitForExit() { /* wait until the gate is open */
- boolean interrupted = false;
- while (!exited) {
- try {
- this.wait();
- } catch (InterruptedException e) {
- interrupted = true;
- }
- }
- if (interrupted) {
- Thread.currentThread().interrupt();
- }
- }
+ /**
+ * The thread factory used to create "process reaper" daemon threads.
+ */
+ private static class ProcessReaperThreadFactory implements ThreadFactory {
+ private final static ThreadGroup group = getRootThreadGroup();
- void setException (IOException e) {
- savedException = e;
+ private static ThreadGroup getRootThreadGroup() {
+ return AccessController.doPrivileged
+ (new PrivilegedAction<ThreadGroup> () {
+ public ThreadGroup run() {
+ ThreadGroup root = Thread.currentThread().getThreadGroup();
+ while (root.getParent() != null)
+ root = root.getParent();
+ return root;
+ }});
}
- IOException getException() {
- return savedException;
+ public Thread newThread(Runnable grimReaper) {
+ // Our thread stack requirement is quite modest.
+ Thread t = new Thread(group, grimReaper, "process reaper", 32768);
+ t.setDaemon(true);
+ // A small attempt (probably futile) to avoid priority inversion
+ t.setPriority(Thread.MAX_PRIORITY);
+ return t;
}
}
+ /**
+ * The thread pool of "process reaper" daemon threads.
+ */
+ private static final Executor processReaperExecutor
+ = Executors.newCachedThreadPool(new ProcessReaperThreadFactory());
+
UNIXProcess(final byte[] prog,
final byte[] argBlock, final int argc,
final byte[] envBlock, final int envc,
final byte[] dir,
- final int[] std_fds,
+ final int[] fds,
final boolean redirectErrorStream)
- throws IOException {
-
- final Gate gate = new Gate();
- /*
- * For each subprocess forked a corresponding reaper thread
- * is started. That thread is the only thread which waits
- * for the subprocess to terminate and it doesn't hold any
- * locks while doing so. This design allows waitFor() and
- * exitStatus() to be safely executed in parallel (and they
- * need no native code).
- */
-
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction<Void>() {
- public Void run() {
- Thread t = new Thread("process reaper") {
- public void run() {
- try {
- pid = forkAndExec(prog,
- argBlock, argc,
- envBlock, envc,
- dir,
- std_fds,
- redirectErrorStream);
- } catch (IOException e) {
- gate.setException(e); /*remember to rethrow later*/
- gate.exit();
- return;
- }
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction<Void>() {
- public Void run() {
- if (std_fds[0] == -1)
- stdin_stream = new ProcessBuilder.NullOutputStream();
- else {
- FileDescriptor stdin_fd = new FileDescriptor();
- fdAccess.set(stdin_fd, std_fds[0]);
- stdin_stream = new BufferedOutputStream(
- new FileOutputStream(stdin_fd));
- }
-
- if (std_fds[1] == -1)
- stdout_stream = new ProcessBuilder.NullInputStream();
- else {
- FileDescriptor stdout_fd = new FileDescriptor();
- fdAccess.set(stdout_fd, std_fds[1]);
- stdout_stream = new BufferedInputStream(
- new FileInputStream(stdout_fd));
- }
-
- if (std_fds[2] == -1)
- stderr_stream = new ProcessBuilder.NullInputStream();
- else {
- FileDescriptor stderr_fd = new FileDescriptor();
- fdAccess.set(stderr_fd, std_fds[2]);
- stderr_stream = new FileInputStream(stderr_fd);
- }
-
- return null; }});
- gate.exit(); /* exit from constructor */
- int res = waitForProcessExit(pid);
- synchronized (UNIXProcess.this) {
- hasExited = true;
- exitcode = res;
- UNIXProcess.this.notifyAll();
- }
- }
- };
- t.setDaemon(true);
- t.start();
- return null; }});
- gate.waitForExit();
- IOException e = gate.getException();
- if (e != null)
- throw new IOException(e.toString());
+ throws IOException {
+
+ pid = forkAndExec(prog,
+ argBlock, argc,
+ envBlock, envc,
+ dir,
+ fds,
+ redirectErrorStream);
+
+ try {
+ AccessController.doPrivileged
+ (new PrivilegedExceptionAction<Void>() {
+ public Void run() throws IOException {
+ initStreams(fds);
+ return null;
+ }});
+ } catch (PrivilegedActionException ex) {
+ throw (IOException) ex.getException();
+ }
+ }
+
+ static FileDescriptor newFileDescriptor(int fd) {
+ FileDescriptor fileDescriptor = new FileDescriptor();
+ fdAccess.set(fileDescriptor, fd);
+ return fileDescriptor;
+ }
+
+ void initStreams(int[] fds) throws IOException {
+ stdin = (fds[0] == -1) ?
+ ProcessBuilder.NullOutputStream.INSTANCE :
+ new ProcessPipeOutputStream(fds[0]);
+
+ stdout = (fds[1] == -1) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new ProcessPipeInputStream(fds[1]);
+
+ stderr = (fds[2] == -1) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new ProcessPipeInputStream(fds[2]);
+
+ processReaperExecutor.execute(new Runnable() {
+ public void run() {
+ int exitcode = waitForProcessExit(pid);
+ UNIXProcess.this.processExited(exitcode);
+ }});
+ }
+
+ synchronized void processExited(int exitcode) {
+ if (stdout instanceof ProcessPipeInputStream)
+ ((ProcessPipeInputStream) stdout).processExited();
+
+ if (stderr instanceof ProcessPipeInputStream)
+ ((ProcessPipeInputStream) stderr).processExited();
+
+ if (stdin instanceof ProcessPipeOutputStream)
+ ((ProcessPipeOutputStream) stdin).processExited();
+
+ this.exitcode = exitcode;
+ hasExited = true;
+ notifyAll();
}
public OutputStream getOutputStream() {
- return stdin_stream;
+ return stdin;
}
public InputStream getInputStream() {
- return stdout_stream;
+ return stdout;
}
public InputStream getErrorStream() {
- return stderr_stream;
+ return stderr;
}
public synchronized int waitFor() throws InterruptedException {
@@ -228,13 +226,9 @@ final class UNIXProcess extends Process {
if (!hasExited)
destroyProcess(pid);
}
- try {
- stdin_stream.close();
- stdout_stream.close();
- stderr_stream.close();
- } catch (IOException e) {
- // ignore
- }
+ try { stdin.close(); } catch (IOException ignored) {}
+ try { stdout.close(); } catch (IOException ignored) {}
+ try { stderr.close(); } catch (IOException ignored) {}
}
/* This routine initializes JNI field offsets for the class */
@@ -243,4 +237,77 @@ final class UNIXProcess extends Process {
static {
initIDs();
}
+
+ /**
+ * A buffered input stream for a subprocess pipe file descriptor
+ * that allows the underlying file descriptor to be reclaimed when
+ * the process exits, via the processExited hook.
+ *
+ * This is tricky because we do not want the user-level InputStream to be
+ * closed until the user invokes close(), and we need to continue to be
+ * able to read any buffered data lingering in the OS pipe buffer.
+ */
+ static class ProcessPipeInputStream extends BufferedInputStream {
+ ProcessPipeInputStream(int fd) {
+ super(new FileInputStream(newFileDescriptor(fd)));
+ }
+
+ private static byte[] drainInputStream(InputStream in)
+ throws IOException {
+ if (in == null) return null;
+ int n = 0;
+ int j;
+ byte[] a = null;
+ while ((j = in.available()) > 0) {
+ a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
+ n += in.read(a, n, j);
+ }
+ return (a == null || n == a.length) ? a : Arrays.copyOf(a, n);
+ }
+
+ /** Called by the process reaper thread when the process exits. */
+ synchronized void processExited() {
+ // Most BufferedInputStream methods are synchronized, but close()
+ // is not, and so we have to handle concurrent racing close().
+ try {
+ InputStream in = this.in;
+ if (in != null) {
+ byte[] stragglers = drainInputStream(in);
+ in.close();
+ this.in = (stragglers == null) ?
+ ProcessBuilder.NullInputStream.INSTANCE :
+ new ByteArrayInputStream(stragglers);
+ if (buf == null) // asynchronous close()?
+ this.in = null;
+ }
+ } catch (IOException ignored) {
+ // probably an asynchronous close().
+ }
+ }
+ }
+
+ /**
+ * A buffered output stream for a subprocess pipe file descriptor
+ * that allows the underlying file descriptor to be reclaimed when
+ * the process exits, via the processExited hook.
+ */
+ static class ProcessPipeOutputStream extends BufferedOutputStream {
+ ProcessPipeOutputStream(int fd) {
+ super(new FileOutputStream(newFileDescriptor(fd)));
+ }
+
+ /** Called by the process reaper thread when the process exits. */
+ synchronized void processExited() {
+ OutputStream out = this.out;
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException ignored) {
+ // We know of no reason to get an IOException, but if
+ // we do, there's nothing else to do but carry on.
+ }
+ this.out = ProcessBuilder.NullOutputStream.INSTANCE;
+ }
+ }
+ }
}
diff --git a/src/solaris/classes/java/lang/UNIXProcess.java.solaris b/src/solaris/classes/java/lang/UNIXProcess.java.solaris
index 7f87d797a..8d01b7e72 100644
--- a/src/solaris/classes/java/lang/UNIXProcess.java.solaris
+++ b/src/solaris/classes/java/lang/UNIXProcess.java.solaris
@@ -86,7 +86,7 @@ final class UNIXProcess extends Process {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() { public Void run() {
if (std_fds[0] == -1)
- stdin_stream = new ProcessBuilder.NullOutputStream();
+ stdin_stream = ProcessBuilder.NullOutputStream.INSTANCE;
else {
FileDescriptor stdin_fd = new FileDescriptor();
fdAccess.set(stdin_fd, std_fds[0]);
@@ -95,7 +95,7 @@ final class UNIXProcess extends Process {
}
if (std_fds[1] == -1)
- stdout_stream = new ProcessBuilder.NullInputStream();
+ stdout_stream = ProcessBuilder.NullInputStream.INSTANCE;
else {
FileDescriptor stdout_fd = new FileDescriptor();
fdAccess.set(stdout_fd, std_fds[1]);
@@ -104,7 +104,7 @@ final class UNIXProcess extends Process {
}
if (std_fds[2] == -1)
- stderr_stream = new ProcessBuilder.NullInputStream();
+ stderr_stream = ProcessBuilder.NullInputStream.INSTANCE;
else {
FileDescriptor stderr_fd = new FileDescriptor();
fdAccess.set(stderr_fd, std_fds[2]);
diff --git a/src/solaris/classes/sun/nio/cs/ext/COMPOUND_TEXT_Encoder.java b/src/solaris/classes/sun/nio/cs/ext/COMPOUND_TEXT_Encoder.java
index e7cc9c1b1..d73a21b98 100644
--- a/src/solaris/classes/sun/nio/cs/ext/COMPOUND_TEXT_Encoder.java
+++ b/src/solaris/classes/sun/nio/cs/ext/COMPOUND_TEXT_Encoder.java
@@ -43,8 +43,8 @@ public class COMPOUND_TEXT_Encoder extends CharsetEncoder {
* cannot be used for actual encoding because they are shared across all
* COMPOUND_TEXT encoders and may be stateful.
*/
- private static final Map encodingToEncoderMap =
- Collections.synchronizedMap(new HashMap(21, 1.0f));
+ private static final Map<String,CharsetEncoder> encodingToEncoderMap =
+ Collections.synchronizedMap(new HashMap<String,CharsetEncoder>(21, 1.0f));
private static final CharsetEncoder latin1Encoder;
private static final CharsetEncoder defaultEncoder;
private static final boolean defaultEncodingSupported;
@@ -221,7 +221,7 @@ public class COMPOUND_TEXT_Encoder extends CharsetEncoder {
out.put((byte)0x1B);
out.put((byte)0x25);
out.put((byte)0x2F);
- out.put((byte)nonStandardBytes[3]);
+ out.put(nonStandardBytes[3]);
int toWrite = Math.min(numBytes - nonStandardBytesOff,
(1 << 14) - 1 - nonStandardEncodingLen);
@@ -313,12 +313,9 @@ public class COMPOUND_TEXT_Encoder extends CharsetEncoder {
}
// 4. Brute force search of all supported encodings.
- for (Iterator iter = CompoundTextSupport.getEncodings().iterator();
- iter.hasNext();)
+ for (String encoding : CompoundTextSupport.getEncodings())
{
- String encoding = (String)iter.next();
- CharsetEncoder enc =
- (CharsetEncoder)encodingToEncoderMap.get(encoding);
+ CharsetEncoder enc = encodingToEncoderMap.get(encoding);
if (enc == null) {
enc = CompoundTextSupport.getEncoder(encoding);
if (enc == null) {
diff --git a/src/solaris/classes/sun/nio/cs/ext/CompoundTextSupport.java b/src/solaris/classes/sun/nio/cs/ext/CompoundTextSupport.java
index 07c87af26..4f2a04711 100644
--- a/src/solaris/classes/sun/nio/cs/ext/CompoundTextSupport.java
+++ b/src/solaris/classes/sun/nio/cs/ext/CompoundTextSupport.java
@@ -130,13 +130,13 @@ final class CompoundTextSupport {
/**
* Maps a GL or GR escape sequence to an encoding.
*/
- private static final Map sequenceToEncodingMap;
+ private static final Map<ControlSequence, String> sequenceToEncodingMap;
/**
* Indicates whether a particular encoding wants the high bit turned on
* or off.
*/
- private static final Map highBitsMap;
+ private static final Map<ControlSequence, Boolean> highBitsMap;
/**
* Maps an encoding to an escape sequence. Rather than manage two
@@ -144,18 +144,21 @@ final class CompoundTextSupport {
* modify both GL and GR if necessary. This makes the output slightly less
* efficient, but our code much simpler.
*/
- private static final Map encodingToSequenceMap;
+ private static final Map<String, ControlSequence> encodingToSequenceMap;
/**
* The keys of 'encodingToSequenceMap', sorted in preferential order.
*/
- private static final List encodings;
+ private static final List<String> encodings;
static {
- HashMap tSequenceToEncodingMap = new HashMap(33, 1.0f);
- HashMap tHighBitsMap = new HashMap(31, 1.0f);
- HashMap tEncodingToSequenceMap = new HashMap(21, 1.0f);
- ArrayList tEncodings = new ArrayList(21);
+ HashMap<ControlSequence, String> tSequenceToEncodingMap =
+ new HashMap<>(33, 1.0f);
+ HashMap<ControlSequence, Boolean> tHighBitsMap =
+ new HashMap<>(31, 1.0f);
+ HashMap<String, ControlSequence> tEncodingToSequenceMap =
+ new HashMap<>(21, 1.0f);
+ ArrayList<String> tEncodings = new ArrayList<>(21);
if (!(isEncodingSupported("US-ASCII") &&
isEncodingSupported("ISO-8859-1")))
@@ -457,13 +460,12 @@ final class CompoundTextSupport {
return getNonStandardDecoder(escSequence, null);
}
static boolean getHighBit(byte[] escSequence) {
- Boolean bool = (Boolean)highBitsMap.get
- (new ControlSequence(escSequence));
+ Boolean bool = highBitsMap.get(new ControlSequence(escSequence));
return (bool == Boolean.TRUE);
}
static CharsetDecoder getNonStandardDecoder(byte[] escSequence,
byte[] encoding) {
- return getDecoder((String)sequenceToEncodingMap.get
+ return getDecoder(sequenceToEncodingMap.get
(new ControlSequence(escSequence, encoding)));
}
static CharsetDecoder getDecoder(String enc) {
@@ -474,7 +476,7 @@ final class CompoundTextSupport {
try {
cs = Charset.forName(enc);
} catch (IllegalArgumentException e) {
- Class cls;
+ Class<?> cls;
try {
cls = Class.forName("sun.awt.motif." + enc);
} catch (ClassNotFoundException ee) {
@@ -497,22 +499,20 @@ final class CompoundTextSupport {
// For Encoder
static byte[] getEscapeSequence(String encoding) {
- ControlSequence seq = (ControlSequence)
- encodingToSequenceMap.get(encoding);
+ ControlSequence seq = encodingToSequenceMap.get(encoding);
if (seq != null) {
return seq.escSequence;
}
return null;
}
static byte[] getEncoding(String encoding) {
- ControlSequence seq = (ControlSequence)
- encodingToSequenceMap.get(encoding);
+ ControlSequence seq = encodingToSequenceMap.get(encoding);
if (seq != null) {
return seq.encoding;
}
return null;
}
- static List getEncodings() {
+ static List<String> getEncodings() {
return encodings;
}
static CharsetEncoder getEncoder(String enc) {
@@ -523,7 +523,7 @@ final class CompoundTextSupport {
try {
cs = Charset.forName(enc);
} catch (IllegalArgumentException e) {
- Class cls;
+ Class<?> cls;
try {
cls = Class.forName("sun.awt.motif." + enc);
} catch (ClassNotFoundException ee) {
diff --git a/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java b/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java
index cf194a2f1..bdec8fc54 100644
--- a/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java
+++ b/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java
@@ -37,6 +37,8 @@ import java.util.Properties;
* Linux implementation of HotSpotVirtualMachine
*/
public class LinuxVirtualMachine extends HotSpotVirtualMachine {
+ // temp directory for socket file
+ private static final String tmpdir = System.getProperty("java.io.tmpdir");
// Indicates if this machine uses the old LinuxThreads
static boolean isLinuxThreads;
@@ -260,7 +262,7 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine {
// Return the socket file for the given process.
// Checks working directory of process for .java_pid<pid>. If not
- // found it looks in /tmp.
+ // found it looks in temp directory.
private String findSocketFile(int pid) {
// First check for a .java_pid<pid> file in the working directory
// of the target process
@@ -268,20 +270,17 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine {
String path = "/proc/" + pid + "/cwd/" + fn;
File f = new File(path);
if (!f.exists()) {
- // Not found, so try /tmp
- path = "/tmp/" + fn;
- f = new File(path);
- if (!f.exists()) {
- return null; // not found
- }
+ // Not found, so try temp directory
+ f = new File(tmpdir, fn);
+ path = f.exists() ? f.getPath() : null;
}
return path;
}
// On Solaris/Linux a simple handshake is used to start the attach mechanism
// if not already started. The client creates a .attach_pid<pid> file in the
- // target VM's working directory (or /tmp), and the SIGQUIT handler checks
- // for the file.
+ // target VM's working directory (or temp directory), and the SIGQUIT handler
+ // checks for the file.
private File createAttachFile(int pid) throws IOException {
String fn = ".attach_pid" + pid;
String path = "/proc/" + pid + "/cwd/" + fn;
@@ -289,8 +288,7 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine {
try {
f.createNewFile();
} catch (IOException x) {
- path = "/tmp/" + fn;
- f = new File(path);
+ f = new File(tmpdir, fn);
f.createNewFile();
}
return f;
diff --git a/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java b/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java
index ed923639b..0d6b234fa 100644
--- a/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java
+++ b/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java
@@ -38,6 +38,11 @@ import java.util.Properties;
* Solaris implementation of HotSpotVirtualMachine.
*/
public class SolarisVirtualMachine extends HotSpotVirtualMachine {
+ // Use /tmp instead of /var/tmp on Solaris as /tmp is the default used by
+ // HotSpot when the property is not set on the command line.
+ private static final String tmpdir1 = System.getProperty("java.io.tmpdir");
+ private static final String tmpdir =
+ (tmpdir1.equals("/var/tmp") || tmpdir1.equals("/var/tmp/")) ? "/tmp" : tmpdir1;
// door descriptor;
private int fd = -1;
@@ -187,7 +192,7 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine {
}
// The door is attached to .java_pid<pid> in the target VM's working
- // directory or /tmp.
+ // directory or temporary directory.
private int openDoor(int pid) throws IOException {
// First check for a .java_pid<pid> file in the working directory
// of the target process
@@ -196,7 +201,7 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine {
try {
fd = open(path);
} catch (FileNotFoundException fnf) {
- path = "/tmp/" + fn;
+ path = tmpdir + "/" + fn;
fd = open(path);
}
@@ -213,8 +218,8 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine {
// On Solaris/Linux a simple handshake is used to start the attach mechanism
// if not already started. The client creates a .attach_pid<pid> file in the
- // target VM's working directory (or /tmp), and the SIGQUIT handler checks
- // for the file.
+ // target VM's working directory (or temporary directory), and the SIGQUIT
+ // handler checks for the file.
private File createAttachFile(int pid) throws IOException {
String fn = ".attach_pid" + pid;
String path = "/proc/" + pid + "/cwd/" + fn;
@@ -222,8 +227,7 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine {
try {
f.createNewFile();
} catch (IOException x) {
- path = "/tmp/" + fn;
- f = new File(path);
+ f = new File(tmpdir, fn);
f.createNewFile();
}
return f;
diff --git a/src/windows/classes/java/lang/ProcessImpl.java b/src/windows/classes/java/lang/ProcessImpl.java
index 19e0b3ee7..c0a0daa09 100644
--- a/src/windows/classes/java/lang/ProcessImpl.java
+++ b/src/windows/classes/java/lang/ProcessImpl.java
@@ -159,7 +159,7 @@ final class ProcessImpl extends Process {
new java.security.PrivilegedAction<Void>() {
public Void run() {
if (stdHandles[0] == -1L)
- stdin_stream = new ProcessBuilder.NullOutputStream();
+ stdin_stream = ProcessBuilder.NullOutputStream.INSTANCE;
else {
FileDescriptor stdin_fd = new FileDescriptor();
fdAccess.setHandle(stdin_fd, stdHandles[0]);
@@ -168,7 +168,7 @@ final class ProcessImpl extends Process {
}
if (stdHandles[1] == -1L)
- stdout_stream = new ProcessBuilder.NullInputStream();
+ stdout_stream = ProcessBuilder.NullInputStream.INSTANCE;
else {
FileDescriptor stdout_fd = new FileDescriptor();
fdAccess.setHandle(stdout_fd, stdHandles[1]);
@@ -177,7 +177,7 @@ final class ProcessImpl extends Process {
}
if (stdHandles[2] == -1L)
- stderr_stream = new ProcessBuilder.NullInputStream();
+ stderr_stream = ProcessBuilder.NullInputStream.INSTANCE;
else {
FileDescriptor stderr_fd = new FileDescriptor();
fdAccess.setHandle(stderr_fd, stdHandles[2]);
diff --git a/src/windows/native/sun/nio/ch/DatagramChannelImpl.c b/src/windows/native/sun/nio/ch/DatagramChannelImpl.c
index 3dfa490f5..64156b861 100644
--- a/src/windows/native/sun/nio/ch/DatagramChannelImpl.c
+++ b/src/windows/native/sun/nio/ch/DatagramChannelImpl.c
@@ -120,6 +120,12 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jobject this,
rv = connect((SOCKET)fd, (struct sockaddr *)&sa, sa_len);
if (rv == SOCKET_ERROR) {
handleSocketError(env, WSAGetLastError());
+ } else {
+ /* Disable WSAECONNRESET errors as socket is no longer connected */
+ BOOL enable = FALSE;
+ DWORD bytesReturned = 0;
+ WSAIoctl((SOCKET)fd, SIO_UDP_CONNRESET, &enable, sizeof(enable),
+ NULL, 0, &bytesReturned, NULL, NULL);
}
}
diff --git a/src/windows/native/sun/nio/ch/Net.c b/src/windows/native/sun/nio/ch/Net.c
index da485d8e4..a145393e0 100644
--- a/src/windows/native/sun/nio/ch/Net.c
+++ b/src/windows/native/sun/nio/ch/Net.c
@@ -67,6 +67,14 @@ typedef struct my_group_source_req {
#define COPY_INET6_ADDRESS(env, source, target) \
(*env)->GetByteArrayRegion(env, source, 0, 16, target)
+/**
+ * Enable or disable receipt of WSAECONNRESET errors.
+ */
+static void setConnectionReset(SOCKET s, BOOL enable) {
+ DWORD bytesReturned = 0;
+ WSAIoctl(s, SIO_UDP_CONNRESET, &enable, sizeof(enable),
+ NULL, 0, &bytesReturned, NULL, NULL);
+}
JNIEXPORT void JNICALL
@@ -109,6 +117,12 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
(const char *)&opt, sizeof(opt));
}
+
+ /* Disable WSAECONNRESET errors for initially unconnected UDP sockets */
+ if (!stream) {
+ setConnectionReset(s, FALSE);
+ }
+
} else {
NET_ThrowNew(env, WSAGetLastError(), "socket");
}
@@ -149,12 +163,13 @@ Java_sun_nio_ch_Net_connect0(JNIEnv *env, jclass clazz, jboolean preferIPv6, job
SOCKETADDRESS sa;
int rv;
int sa_len;
+ SOCKET s = (SOCKET)fdval(env, fdo);
if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *)&sa, &sa_len, preferIPv6) != 0) {
return IOS_THROWN;
}
- rv = connect(fdval(env, fdo), (struct sockaddr *)&sa, sa_len);
+ rv = connect(s, (struct sockaddr *)&sa, sa_len);
if (rv != 0) {
int err = WSAGetLastError();
if (err == WSAEINPROGRESS || err == WSAEWOULDBLOCK) {
@@ -162,6 +177,13 @@ Java_sun_nio_ch_Net_connect0(JNIEnv *env, jclass clazz, jboolean preferIPv6, job
}
NET_ThrowNew(env, err, "connect");
return IOS_THROWN;
+ } else {
+ /* Enable WSAECONNRESET errors when a UDP socket is connected */
+ int type = 0, optlen = sizeof(type);
+ rv = getsockopt(s, SOL_SOCKET, SO_TYPE, (char*)&type, &optlen);
+ if (rv == 0 && type == SOCK_DGRAM) {
+ setConnectionReset(s, TRUE);
+ }
}
return 1;
}
diff --git a/src/windows/native/sun/nio/ch/SocketDispatcher.c b/src/windows/native/sun/nio/ch/SocketDispatcher.c
index 78265a069..0fa7c35a9 100644
--- a/src/windows/native/sun/nio/ch/SocketDispatcher.c
+++ b/src/windows/native/sun/nio/ch/SocketDispatcher.c
@@ -50,6 +50,10 @@ Java_sun_nio_ch_SocketDispatcher_read0(JNIEnv *env, jclass clazz, jobject fdo,
jint fd = fdval(env, fdo);
WSABUF buf;
+ /* limit size */
+ if (len > MAX_BUFFER_SIZE)
+ len = MAX_BUFFER_SIZE;
+
/* destination buffer and size */
buf.buf = (char *)address;
buf.len = (u_long)len;
@@ -86,6 +90,7 @@ Java_sun_nio_ch_SocketDispatcher_readv0(JNIEnv *env, jclass clazz, jobject fdo,
jint fd = fdval(env, fdo);
struct iovec *iovp = (struct iovec *)address;
WSABUF *bufs = malloc(len * sizeof(WSABUF));
+ jint rem = MAX_BUFFER_SIZE;
if (bufs == 0) {
JNU_ThrowOutOfMemoryError(env, 0);
@@ -98,8 +103,16 @@ Java_sun_nio_ch_SocketDispatcher_readv0(JNIEnv *env, jclass clazz, jobject fdo,
/* copy iovec into WSABUF */
for(i=0; i<len; i++) {
+ jint iov_len = iovp[i].iov_len;
+ if (iov_len > rem)
+ iov_len = rem;
bufs[i].buf = (char *)iovp[i].iov_base;
- bufs[i].len = (u_long)iovp[i].iov_len;
+ bufs[i].len = (u_long)iov_len;
+ rem -= iov_len;
+ if (rem == 0) {
+ len = i+1;
+ break;
+ }
}
/* read into the buffers */
@@ -136,6 +149,10 @@ Java_sun_nio_ch_SocketDispatcher_write0(JNIEnv *env, jclass clazz, jobject fdo,
jint fd = fdval(env, fdo);
WSABUF buf;
+ /* limit size */
+ if (len > MAX_BUFFER_SIZE)
+ len = MAX_BUFFER_SIZE;
+
/* copy iovec into WSABUF */
buf.buf = (char *)address;
buf.len = (u_long)len;
@@ -171,6 +188,7 @@ Java_sun_nio_ch_SocketDispatcher_writev0(JNIEnv *env, jclass clazz,
jint fd = fdval(env, fdo);
struct iovec *iovp = (struct iovec *)address;
WSABUF *bufs = malloc(len * sizeof(WSABUF));
+ jint rem = MAX_BUFFER_SIZE;
if (bufs == 0) {
JNU_ThrowOutOfMemoryError(env, 0);
@@ -183,8 +201,16 @@ Java_sun_nio_ch_SocketDispatcher_writev0(JNIEnv *env, jclass clazz,
/* copy iovec into WSABUF */
for(i=0; i<len; i++) {
+ jint iov_len = iovp[i].iov_len;
+ if (iov_len > rem)
+ iov_len = rem;
bufs[i].buf = (char *)iovp[i].iov_base;
- bufs[i].len = (u_long)iovp[i].iov_len;
+ bufs[i].len = (u_long)iov_len;
+ rem -= iov_len;
+ if (rem == 0) {
+ len = i+1;
+ break;
+ }
}
/* read into the buffers */
diff --git a/src/windows/native/sun/nio/ch/nio_util.h b/src/windows/native/sun/nio/ch/nio_util.h
index 9c7a6d958..963e93ef0 100644
--- a/src/windows/native/sun/nio/ch/nio_util.h
+++ b/src/windows/native/sun/nio/ch/nio_util.h
@@ -25,6 +25,14 @@
#include "jni.h"
+/**
+ * The maximum buffer size for WSASend/WSARecv. Microsoft recommendation for
+ * blocking operations is to use buffers no larger than 64k. We need the
+ * maximum to be less than 128k to support asynchronous close on Windows
+ * Server 2003 and newer editions of Windows.
+ */
+#define MAX_BUFFER_SIZE ((128*1024)-1)
+
jint fdval(JNIEnv *env, jobject fdo);
jlong handleval(JNIEnv *env, jobject fdo);
jboolean isNT();
diff --git a/test/Makefile b/test/Makefile
index 9272bbb4c..ad4ca1604 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -307,7 +307,7 @@ BUNDLE_UP_AND_EXIT = \
passc="`$(CAT) $(PASSLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \
failc="`$(CAT) $(FAILLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \
exclc="`$(CAT) $(EXCLUDELIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \
- $(ECHO) "TEST STATS: run=$${runc} pass=$${passc} fail=$${failc} excluded=$${exclc}" \
+ $(ECHO) "TEST STATS: name=$(UNIQUE_DIR) run=$${runc} pass=$${passc} fail=$${failc} excluded=$${exclc}" \
>> $(STATS_TXT); \
else \
$(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
@@ -326,7 +326,7 @@ all: jtreg_tests
# Prep for output
prep: clean
@$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR)
- @$(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)`
+ @$(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`
# Cleanup
clean:
@@ -376,7 +376,7 @@ else
$(EXCLUDELIST): $(PROBLEM_LISTS) $(TESTDIRS)
@$(RM) $@ $@.temp1 $@.temp2
@(($(CAT) $(PROBLEM_LISTS) | $(EGREP) -- '$(OS_NAME)-all' ) ;\
- ($(CAT) $(PROBLEM_LISTS) | $(EGREP) -- '$(OS_NAME)-$(OS_ARCH)' ) ;\
+ ($(CAT) $(PROBLEM_LISTS) | $(EGREP) -- '$(PLATFORM_OS)' ) ;\
($(CAT) $(PROBLEM_LISTS) | $(EGREP) -- '$(OS_NAME)-$(OS_ARCH2)' ) ;\
($(CAT) $(PROBLEM_LISTS) | $(EGREP) -- '$(OS_NAME)-$(OS_VERSION)') ;\
($(CAT) $(PROBLEM_LISTS) | $(EGREP) -- 'generic-$(OS_ARCH)' ) ;\
@@ -562,7 +562,7 @@ jdk_tools1: com/sun/jdi
JDK_ALL_TARGETS += jdk_tools2
jdk_tools2: com/sun/tools sun/jvmstat sun/tools tools vm com/sun/servicetag com/sun/tracing
$(call SharedLibraryPermissions,tools/launcher)
- $(call RunOthervmBatch)
+ $(call RunSamevmBatch)
# All tools tests
jdk_tools: jdk_tools1 jdk_tools2
diff --git a/test/ProblemList.txt b/test/ProblemList.txt
index c41d51376..76d34d85b 100644
--- a/test/ProblemList.txt
+++ b/test/ProblemList.txt
@@ -174,10 +174,6 @@ java/beans/Statement/Test4653179.java generic-all
java/beans/XMLEncoder/Test4625418.java solaris-sparc
# Problems with samevm and setting security manager (speculation partially)
-java/beans/Beans/Test4080522.java generic-all
-java/beans/EventHandler/Test6277246.java generic-all
-java/beans/EventHandler/Test6277266.java generic-all
-java/beans/Introspector/Test6277246.java generic-all
java/beans/Introspector/4168475/Test4168475.java generic-all
java/beans/Introspector/4520754/Test4520754.java generic-all
java/beans/Introspector/6380849/TestBeanInfo.java generic-all
@@ -191,229 +187,14 @@ java/beans/XMLEncoder/6329581/Test6329581.java generic-all
############################################################################
-# jdk_io
-
-# Many of these tests have a tendency to leave input streams open, which
-# will cause following tests to be failures when used in samevm mode.
-
-# Should be othervm, or corrected for samevm, fails with samevm:
-java/io/BufferedReader/BigMark.java generic-all
-java/io/BufferedReader/ReadLineSync.java generic-all
-
-# One of these is leaving "a.ser" file open, windows samevm
-java/io/Serializable/duplicateSerialFields/Setup.java generic-all
-java/io/Serializable/duplicateSerialFields/Test.java generic-all
-
-# One of these leaving foo.ser open, windows samevm problem
-java/io/Serializable/enum/constantSubclasses/Read.java generic-all
-java/io/Serializable/enum/constantSubclasses/Write.java generic-all
-java/io/Serializable/enum/missingConstant/Read.java generic-all
-java/io/Serializable/enum/missingConstant/Write.java generic-all
-
-# This is leaving subtest1.tmp open, windows samevm problem
-java/io/Serializable/oldTests/AnnotateClass.java generic-all
-
-# One or more of these leave a piotest* file open, windows samevm
-java/io/Serializable/oldTests/ArrayFields.java generic-all
-java/io/Serializable/oldTests/ArraysOfArrays.java generic-all
-java/io/Serializable/oldTests/BinaryTree.java generic-all
-java/io/Serializable/oldTests/CircularList.java generic-all
-java/io/Serializable/oldTests/SerializeWithException.java generic-all
-java/io/Serializable/oldTests/SimpleArrays.java generic-all
-java/io/Serializable/oldTests/WritePrimitive.java generic-all
-
-# Missing close on file 0.ser, windows samevm
-java/io/Serializable/enum/badResolve/Read.java generic-all
-java/io/Serializable/enum/badResolve/Write.java generic-all
-
-# One of these tests is leaving parents.ser open, windows samevm
-java/io/Serializable/parents/EvolvedClass.java generic-all
-java/io/Serializable/parents/OriginalClass.java generic-all
-
-# One of these tests is leaving file foo.ser and/or bar.ser open, windows samevm
-java/io/Serializable/fieldTypeString/Read.java generic-all
-java/io/Serializable/fieldTypeString/Write.java generic-all
-
-# One of these tests is leaving tmp.ser file open, windows samevm
-java/io/Serializable/ClassCastExceptionDetail/Read.java generic-all
-java/io/Serializable/ClassCastExceptionDetail/Write.java generic-all
-java/io/Serializable/GetField/Read.java generic-all
-java/io/Serializable/GetField/Read2.java generic-all
-java/io/Serializable/GetField/Write.java generic-all
-java/io/Serializable/PutField/Read.java generic-all
-java/io/Serializable/PutField/Read2.java generic-all
-java/io/Serializable/PutField/Write.java generic-all
-java/io/Serializable/PutField/Write2.java generic-all
-java/io/Serializable/arraySuidConflict/Read.java generic-all
-java/io/Serializable/arraySuidConflict/Write.java generic-all
-java/io/Serializable/backRefCNFException/Read.java generic-all
-java/io/Serializable/backRefCNFException/Write.java generic-all
-java/io/Serializable/class/Test.java generic-all
-java/io/Serializable/evolution/AddedExternField/ReadAddedField.java generic-all
-java/io/Serializable/evolution/AddedExternField/WriteAddedField.java generic-all
-java/io/Serializable/evolution/AddedExternField/run.sh generic-all
-java/io/Serializable/evolution/AddedField/ReadAddedField.java generic-all
-java/io/Serializable/evolution/AddedField/WriteAddedField.java generic-all
-java/io/Serializable/evolution/AddedSuperClass/ReadAddedSuperClass.java generic-all
-java/io/Serializable/evolution/AddedSuperClass/ReadAddedSuperClass2.java generic-all
-java/io/Serializable/evolution/AddedSuperClass/WriteAddedSuperClass.java generic-all
-java/io/Serializable/proxy/skipMissing/Read.java generic-all
-java/io/Serializable/proxy/skipMissing/Write.java generic-all
-java/io/Serializable/readObjectNoData/Read.java generic-all
-java/io/Serializable/readObjectNoData/Write.java generic-all
-java/io/Serializable/skipWriteObject/Read.java generic-all
-java/io/Serializable/skipWriteObject/Write.java generic-all
-java/io/Serializable/skippedObjCNFException/Read.java generic-all
-java/io/Serializable/skippedObjCNFException/Write.java generic-all
-java/io/Serializable/stopCustomDeserialization/Read.java generic-all
-java/io/Serializable/stopCustomDeserialization/Write.java generic-all
-java/io/Serializable/unresolvedClassDesc/Read.java generic-all
-java/io/Serializable/unresolvedClassDesc/Write.java generic-all
-java/io/Serializable/unshared/Read.java generic-all
-java/io/Serializable/unshared/Write.java generic-all
-java/io/Serializable/wrongReturnTypes/Read.java generic-all
-java/io/Serializable/wrongReturnTypes/Write.java generic-all
-
-# Windows samevm issues? triggers other tests to fail, missing close() on f.txt?
-java/io/DataInputStream/OpsAfterClose.java generic-all
-
-# Windows 32bit samevm failure: RuntimeException: File.getFreeSpace() failed
-java/io/File/MaxPathLength.java generic-all
-
-# Should be othervm, or corrected for samevm, fails with samevm:
-java/io/File/DeleteOnExit.java generic-all
-java/io/File/DeleteOnExitLong.java generic-all
-java/io/File/DeleteOnExitNPE.java generic-all
-java/io/File/IsHidden.java generic-all
-java/io/FileDescriptor/FileChannelFDTest.java generic-all
-java/io/FileDescriptor/Finalize.java generic-all
-java/io/FileInputStream/FinalizeShdCallClose.java generic-all
-
-# Known to cause samevm issues on windows, other tests fail, missing close()?
-java/io/FileInputStream/OpsAfterClose.java generic-all
-
-# Should be othervm, or corrected for samevm, fails with samevm:
-java/io/FileOutputStream/FinalizeShdCallClose.java generic-all
-
-# Known to cause samevm issues on windows, other tests fail, missing close()?
-java/io/FileOutputStream/OpsAfterClose.java generic-all
-
-# Windows samevm issues? triggers other tests to fail, missing close() on f.txt?
-java/io/InputStream/OpsAfterClose.java generic-all
-
-# Missing close() on x.ReadBounds file? Windows samevm issues
-java/io/InputStream/ReadParams.java generic-all
-
-# Known to cause samevm issues on windows, other tests fail, missing close()?
-java/io/InputStreamReader/GrowAfterEOF.java generic-all
-
-# Should be othervm, or corrected for samevm, fails with samevm:
-java/io/ObjectInputStream/ResolveProxyClass.java generic-all
-
-# Not doing a close() on x.ParameterCheck file? windows samevm cascade error
-java/io/RandomAccessFile/ParameterCheck.java generic-all
-
-# Not doing a close on x.ReadLine file? windows cascade samevm problems
-java/io/RandomAccessFile/ReadLine.java generic-all
-
-# Not doing close on file input x.WriteByteChars, windows samevm problems
-java/io/RandomAccessFile/WriteBytesChars.java generic-all
-
-# Not doing close on file input x.WriteUTF, windows samevm problems
-java/io/RandomAccessFile/WriteUTF.java generic-all
-
-# Possibly, not doing a close() on input.txt, windows samevm issues.
-java/io/RandomAccessFile/skipBytes/SkipBytes.java generic-all
-java/io/readBytes/MemoryLeak.java generic-all
-java/io/readBytes/ReadBytesBounds.java generic-all
-
-# Missing close on fields.ser, windows samevm
-java/io/Serializable/checkModifiers/CheckModifiers.java generic-all
-
-# Should be othervm, or corrected for samevm, fails with samevm:
-java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java generic-all
-java/io/Serializable/proxy/Basic.java generic-all
-
-# Possibly not doing a close() on input.txt, windows samevm issues.
-java/io/StreamTokenizer/Comment.java generic-all
-
-############################################################################
-
# jdk_lang
-# Some of these tests (like java/lang/management) may just need to be marked
-# othervm, but that is partially speculation.
-
-# Samevm failure on OpenSolaris, security manager?
-java/lang/ClassLoader/UninitializedParent.java generic-all
-
# Times out on solaris 10 sparc
java/lang/ClassLoader/Assert.java generic-all
-# Fedora 9 X64, RuntimeException: MyThread expected to be blocked on lock, but got null
-java/lang/management/ThreadMXBean/ThreadStateTest.java generic-all
-
-# RuntimeException: Uptime of the JVM is more than 30 minutes (32 minutes).
-java/lang/management/RuntimeMXBean/UpTime.java generic-all
-
# Solaris sparc, samevm, java.lang.Exception: Read from closed pipe hangs
java/lang/Runtime/exec/SleepyCat.java generic-all
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/annotation/ParameterAnnotations.java generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/ClassLoader/defineClass/DefineClassByteBuffer.java generic-all
-java/lang/ClassLoader/findSystemClass/Loader.java generic-all
-
-# Fedora 9 32bit, -client, samevm, Error while cleaning up threads after test
-java/lang/management/ThreadMXBean/Locks.java generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/management/ClassLoadingMXBean/LoadCounts.java generic-all
-java/lang/management/ManagementFactory/MBeanServerMXBeanUnsupportedTest.java generic-all
-java/lang/management/ManagementFactory/MXBeanProxyTest.java generic-all
-java/lang/management/ManagementFactory/ThreadMXBeanProxy.java generic-all
-java/lang/management/MemoryMXBean/CollectionUsageThreshold.java generic-all
-java/lang/management/MemoryMXBean/GetMBeanInfo.java generic-all
-java/lang/management/MemoryMXBean/LowMemoryTest.java generic-all
-java/lang/management/MemoryMXBean/MemoryManagement.java generic-all
-java/lang/management/MemoryMXBean/MemoryTest.java generic-all
-java/lang/management/MemoryMXBean/Pending.java generic-all
-
-# Problematic on all platforms (even as othervm)
-java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java generic-all
-
-# Causes jtreg exit samevm issues due to non-String object in system properties
-java/lang/management/RuntimeMXBean/GetSystemProperties.java generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/management/RuntimeMXBean/PropertiesTest.java generic-all
-java/lang/management/ThreadMXBean/AllThreadIds.java generic-all
-java/lang/management/ThreadMXBean/EnableTest.java generic-all
-java/lang/management/ThreadMXBean/FindMonitorDeadlock.java generic-all
-java/lang/management/ThreadMXBean/LockingThread.java generic-all
-java/lang/management/ThreadMXBean/MonitorDeadlock.java generic-all
-java/lang/management/ThreadMXBean/MyOwnSynchronizer.java generic-all
-java/lang/management/ThreadMXBean/SharedSynchronizer.java generic-all
-java/lang/management/ThreadMXBean/SynchronizerLockingThread.java generic-all
-java/lang/management/ThreadMXBean/ThreadCounts.java generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/reflect/Proxy/Boxing.java generic-all
-java/lang/reflect/Proxy/ClassRestrictions.java generic-all
-java/lang/reflect/Proxy/returnTypes/Test.java generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/Runtime/exec/LotsOfOutput.java generic-all
-java/lang/System/ExitFinalizersAndJIT.java generic-all
-java/lang/System/finalization/FinThreads.java generic-all
-java/lang/System/IgnoreNullSecurityManager.java generic-all
-java/lang/Thread/GenerifyStackTraces.java generic-all
-java/lang/Thread/StackTraces.java generic-all
-java/lang/ThreadGroup/Daemon.java generic-all
-java/lang/ThreadGroup/NullThreadName.java generic-all
-
# Times out on solaris sparc -server
java/lang/ThreadLocal/MemoryLeak.java solaris-all
@@ -427,18 +208,12 @@ java/lang/ClassLoader/deadlock/TestCrossDelegate.sh generic-all
# jdk_management
+# Failing, bug was filed: 6959636
+javax/management/loading/LibraryLoader/LibraryLoaderTest.java generic-all
+
# Access denied messages on windows/mks, filed 6954450
sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh windows-all
-# Filed 6951284, fails on linux 64bit Fedora 9, peak thread count differences
-java/lang/management/ThreadMXBean/ResetPeakThreadCount.java generic-all
-
-# Started failing on linux and solaris (filed 6950927)
-# com.sun.tools.attach.AttachNotSupportedException:
-# Unable to open socket file:
-# target process not responding or HotSpot VM not loaded
-sun/management/jmxremote/bootstrap/JvmstatCountersTest.java generic-all
-
# Fails on linux: KO: StringMonitor notification missed or not emitted
javax/management/monitor/NonComparableAttributeValueTest.java generic-all
@@ -737,9 +512,6 @@ sun/net/www/protocol/http/DigestTest.java generic-all
# Suspect many of these tests auffer from using fixed ports, no concrete
# evidence.
-# Failing on Solaris x86 and Linux x86, filed 6934585
-java/nio/channels/AsynchronousSocketChannel/Basic.java generic-all
-
# Occasionally Failing with java.lang.AssertionError on Windows X64
# at sun.nio.ch.PendingIoCache.clearPendingIoMap(PendingIoCache.java:144)
#java/nio/channels/FileChannel/ReleaseOnCloseDeadlock.java windows-all
@@ -751,26 +523,6 @@ java/nio/channels/Selector/Wakeup.java windows-all
com/sun/nio/sctp/SctpChannel/Send.java generic-all
com/sun/nio/sctp/SctpChannel/Shutdown.java generic-all
-# Fails on Windows 2000, Can't delete test directory .\x.SetLastModified.dir
-# at SetLastModified.main(SetLastModified.java:107)
-java/io/File/SetLastModified.java generic-all
-
-# Fails on Solaris 10 x64, address already in use
-java/nio/channels/DatagramChannel/SRTest.java generic-all
-
-# Fails on Solaris 10 x86, times out
-java/nio/channels/DatagramChannel/Sender.java generic-all
-
-# Fails on Fedora 9 x86, address in use
-java/nio/channels/Selector/SelectWrite.java generic-all
-
-# Fails on Fedora 9 32bit times out
-java/nio/channels/DatagramChannel/EmptyBuffer.java generic-all
-
-# Fails on Windows 2000, ExceptionInInitializerError
-# in WindowsAsynchronousServerSocketChannelImpl.java:316
-java/nio/channels/AsynchronousChannelGroup/Unbounded.java generic-all
-
# Fails on Windows 2000, times out
java/nio/channels/FileChannel/Transfer.java generic-all
@@ -784,9 +536,6 @@ com/sun/nio/sctp/SctpChannel/Receive.java generic-all
# Triggers a hotspot crash on Fedora 9 32bit -server and Windows X64 samevm
sun/nio/cs/TestUTF8.java generic-all
-# Solaris sparc, socket timeout
-java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh generic-all
-
# Runtime exception on windows X64, samevm mode
java/nio/channels/Selector/WakeupNow.java generic-all
@@ -809,14 +558,12 @@ com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java generic-all
# Linux 64bit failures. too many files open
java/nio/channels/Selector/HelperSlowToDie.java generic-all
-# Timeouts etc. on Window
-java/nio/channels/AsyncCloseAndInterrupt.java windows-all
-
-# Gets java.lang.ExceptionInInitializerError on windows: (Windows 2000 only?)
+# Gets java.lang.ExceptionInInitializerError on Windows 2000 (need XP or newer)
java/nio/channels/AsynchronousChannelGroup/Basic.java windows-5.0
java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java windows-5.0
java/nio/channels/AsynchronousChannelGroup/Identity.java windows-5.0
java/nio/channels/AsynchronousChannelGroup/Restart.java windows-5.0
+java/nio/channels/AsynchronousChannelGroup/Unbounded.java windows-5.0
java/nio/channels/AsynchronousDatagramChannel/Basic.java windows-5.0
java/nio/channels/AsynchronousFileChannel/Lock.java windows-5.0
java/nio/channels/AsynchronousServerSocketChannel/Basic.java windows-5.0
@@ -827,19 +574,10 @@ java/nio/channels/AsynchronousSocketChannel/Leaky.java windows-5.0
java/nio/channels/AsynchronousSocketChannel/StressLoopback.java windows-5.0
java/nio/channels/Channels/Basic2.java windows-5.0
-# Solaris sparc timeout
-java/nio/channels/DatagramChannel/Connect.java generic-all
-
-# Solaris i586 timeouts
-java/nio/channels/DatagramChannel/EmptyBuffer.java solaris-all
-
# Failed loopback connection? On windows 32bit?
# Considered a stress test, can consume all resources.
java/nio/channels/Selector/LotsOfChannels.java generic-all
-# Solaris sparcv9, just fails with exception
-java/nio/channels/Selector/OpRead.java solaris-sparc
-
# Windows i586 client, crashed hotspot? Unpredictable
# Considered a stress test, can consume all resources.
java/nio/channels/Selector/RegAfterPreClose.java generic-all
@@ -854,18 +592,6 @@ java/nio/channels/ServerSocketChannel/AdaptServerSocket.java windows-all
java/nio/channels/SocketChannel/ConnectState.java windows-all
java/nio/channels/SocketChannel/FinishConnect.java windows-all
-# Need to be marked othervm, or changed to be samevm safe
-java/nio/channels/SocketChannel/OpenLeak.java generic-all
-
-# Gets java.net.BindException alot (static port number?)
-java/nio/channels/SocketChannel/VectorIO.java generic-all
-
-# Solaris i586 java.net.BindExceptions
-java/nio/channels/SocketChannel/VectorParams.java solaris-all
-
-# Linux i586 address already in use, samevm issues
-java/nio/channels/SocketChannel/Write.java generic-all
-
# Fails on all platforms due to overlap of JDK jar file contents:
sun/nio/cs/Test4200310.sh generic-all
@@ -1142,97 +868,6 @@ java/text/Bidi/Bug6665028.java linux-x64
# jdk_tools
-# Filed bug 6951287, failed on Linux 64bit, sometimes?
-com/sun/jdi/PopAndInvokeTest.java generic-all
-
-# Some of the tools tests kind of require "othervm" or if they don't will
-# always be firing up another VM anyway due to the nature of tools testing.
-# So most if not all tools tests are now being run with "othervm" mode.
-# Some of these tools tests have a tendency to use fixed ports, bad idea.
-
-# Fails with -ea -esa on Solaris, Assertion error (Solaris specific test)
-com/sun/tracing/BasicFunctionality.java generic-all
-
-# Fails on Fedora 9 32bit, jps output differs problem
-sun/tools/jstatd/jstatdDefaults.sh generic-all
-
-# Fails on Linux Fedora 9 32bit, Could not read data for remote JVM 16133
-# jstat output differs from expected output
-sun/tools/jstatd/jstatdExternalRegistry.sh generic-all
-
-# Output of jps differs from expected output.
-# Invalid argument count on solaris-sparc and x64
-sun/tools/jstatd/jstatdPort.sh generic-all
-
-# othervm mode, Could not synchronize with target
-sun/tools/jps/jps-l_1.sh generic-all
-sun/tools/jps/jps-l_2.sh generic-all
-sun/tools/jps/jps-lm.sh generic-all
-sun/tools/jps/jps-Vvml_2.sh generic-all
-sun/tools/jps/jps-m_2.sh generic-all
-
-# Fails on Solaris 10 sparcv9, shell exits with 1
-# Turning off use of shared archive because of choice of garbage collector or large pages
-# Could not synchronize with target
-sun/tools/jps/jps-v_1.sh generic-all
-
-# Fails on OpenSolaris "Could not synchronize with target"
-sun/tools/jps/jps-Defaults.sh generic-all
-sun/tools/jps/jps-V_2.sh generic-all
-sun/tools/jps/jps-Vm_2.sh generic-all
-sun/tools/jps/jps-Vvm.sh generic-all
-sun/tools/jps/jps-Vvml.sh generic-all
-sun/tools/jps/jps-m.sh generic-all
-
-# Server name error, port 2098 problem?
-sun/tools/jstatd/jstatdServerName.sh generic-all
-
-# These tests fail on solaris sparc, all the time
-com/sun/servicetag/DeleteServiceTag.java generic-all
-com/sun/servicetag/DuplicateNotFound.java generic-all
-com/sun/servicetag/FindServiceTags.java generic-all
-com/sun/servicetag/InstanceUrnCheck.java generic-all
-com/sun/servicetag/InvalidRegistrationData.java generic-all
-com/sun/servicetag/InvalidServiceTag.java generic-all
-com/sun/servicetag/JavaServiceTagTest.java generic-all
-com/sun/servicetag/JavaServiceTagTest1.java generic-all
-com/sun/servicetag/NewRegistrationData.java generic-all
-com/sun/servicetag/SystemRegistryTest.java generic-all
-com/sun/servicetag/TestLoadFromXML.java generic-all
-com/sun/servicetag/UpdateServiceTagTest.java generic-all
-com/sun/servicetag/ValidRegistrationData.java generic-all
-
-# Problems on windows, jmap.exe hangs?
-com/sun/tools/attach/BasicTests.sh windows-all
-
-# Fails on Solaris 10 sparc, in othervm mode, throws unexpected exception
-sun/jvmstat/monitor/MonitoredVm/CR6672135.java generic-all
-
-# Unexpected Monitor Exception, solaris sparc -client
-sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh generic-all
-
-# Problems on windows, jmap.exe hangs? (these run jmap)
-sun/tools/jmap/Basic.sh windows-all
-
-# Invalid argument count on solaris-sparc and x64
-sun/tools/jstatd/jstatdDefaults.sh solaris-all
-
-# Solaris sparcv9, jps output does not match, x64 different
-sun/tools/jstatd/jstatdExternalRegistry.sh solaris-all
-
-# Solaris 10 sparc 32bit -client, java.lang.AssertionError: Some tests failed
-tools/jar/JarEntryTime.java generic-all
-
-# Times out on sparc?
-tools/launcher/VersionCheck.java generic-all
-
-# These tests fail on solaris sparc, all the time
-tools/jar/ChangeDir.java generic-all
-
-# Cannot write jar
-# Also, possible problems on windows, jmap.exe hangs?
-tools/jar/index/MetaInf.java windows-all
-
############################################################################
# jdk_util
@@ -1241,12 +876,6 @@ tools/jar/index/MetaInf.java windows-all
# 11 separate stacktraces created... file reuse problem?
java/util/zip/ZipFile/ReadLongZipFileName.java generic-all
-# Recent failure on all platforms
-sun/util/resources/TimeZone/Bug6317929.java generic-all
-
-# Fails with -ea -esa on all platforms with Assertion error
-java/util/ResourceBundle/Test4300693.java generic-all
-
# Failing on all -client 32bit platforms starting with b77? See 6908348.
java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java generic-all
@@ -1274,39 +903,7 @@ java/util/EnumSet/EnumSetBash.java solaris-sparc
java/util/Formatter/Constructors.java generic-all
# Need to be marked othervm, or changed to be samevm safe
-java/util/Locale/Bug4175998Test.java generic-all
-java/util/Locale/Bug4184873Test.java generic-all
-java/util/Locale/LocaleTest.java generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/util/logging/GetGlobalTest.java generic-all
-java/util/logging/LoggerSubclass.java generic-all
-java/util/logging/LoggingDeadlock.java generic-all
-java/util/logging/LoggingDeadlock2.java generic-all
-java/util/logging/LoggingMXBeanTest.java generic-all
-java/util/logging/LoggingMXBeanTest2.java generic-all
-java/util/logging/LoggingNIOChange.java generic-all
-java/util/logging/ParentLoggersTest.java generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/util/ResourceBundle/Bug4168625Test.java generic-all
-java/util/ResourceBundle/Bug6359330.java generic-all
-java/util/ResourceBundle/TestBug4179766.java generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
java/util/WeakHashMap/GCDuringIteration.java generic-all
-# Possible missing input stream close()? Causes samevm issues on windows
-java/util/zip/InfoZip.java generic-all
-
-# Missing a close() on file Test0.zip? windows samevm cascade problem
-java/util/zip/ZipFile/Comment.java generic-all
-
-# Suspect missing close() on bad*.zip files, windows cascade errors with samevm
-java/util/zip/ZipFile/CorruptedZipFiles.java generic-all
-
-# Should be samevm but causes problems with samevm, no details:
-java/util/zip/ZipFile/ManyEntries.java generic-all
-
############################################################################
diff --git a/test/com/sun/jdi/PopAndInvokeTest.java b/test/com/sun/jdi/PopAndInvokeTest.java
index 3cc6381c6..b601f5e40 100644
--- a/test/com/sun/jdi/PopAndInvokeTest.java
+++ b/test/com/sun/jdi/PopAndInvokeTest.java
@@ -24,6 +24,7 @@
/**
* @test
* @bug 6517249
+ * @ignore 6951287
* @summary JDWP: Cannot do an invokeMethod after a popFrames operation
*
* @author jjh
diff --git a/test/com/sun/servicetag/FindServiceTags.java b/test/com/sun/servicetag/FindServiceTags.java
index 0d731d2a6..0e8267399 100644
--- a/test/com/sun/servicetag/FindServiceTags.java
+++ b/test/com/sun/servicetag/FindServiceTags.java
@@ -56,8 +56,17 @@ public class FindServiceTags {
private static int expectedUrnCount = 3;
public static void main(String[] argv) throws Exception {
- registry = Util.getSvcTagClientRegistry();
+ try {
+ registry = Util.getSvcTagClientRegistry();
+ runTest();
+ } finally {
+ // restore empty registry file
+ Util.emptyRegistryFile();
+ }
+ System.out.println("Test passed.");
+ }
+ public static void runTest() throws Exception {
for (String filename : files) {
File f = new File(servicetagDir, filename);
ServiceTag svcTag = Util.newServiceTag(f);
@@ -95,7 +104,6 @@ public class FindServiceTags {
tags.size());
}
- System.out.println("Test passed.");
}
private static void findServiceTags(String productUrn) throws Exception {
diff --git a/test/com/sun/servicetag/JavaServiceTagTest1.java b/test/com/sun/servicetag/JavaServiceTagTest1.java
index eb72cc7b8..00713f999 100644
--- a/test/com/sun/servicetag/JavaServiceTagTest1.java
+++ b/test/com/sun/servicetag/JavaServiceTagTest1.java
@@ -31,7 +31,7 @@
* are both created correctly.
* @author Mandy Chung
*
- * @run build JavaServiceTagTest1
+ * @run build JavaServiceTagTest1 SvcTagClient Util
* @run main JavaServiceTagTest1
*/
@@ -46,6 +46,16 @@ public class JavaServiceTagTest1 {
private static File svcTagFile;
private static Registry registry;
public static void main(String[] argv) throws Exception {
+ try {
+ registry = Util.getSvcTagClientRegistry();
+ runTest();
+ } finally {
+ // restore empty registry file
+ Util.emptyRegistryFile();
+ }
+ }
+
+ private static void runTest() throws Exception {
// cleanup the registration.xml and servicetag file in the test directory
System.setProperty("servicetag.dir.path", registrationDir);
regFile = new File(registrationDir, "registration.xml");
@@ -54,8 +64,6 @@ public class JavaServiceTagTest1 {
svcTagFile = new File(registrationDir, "servicetag");
svcTagFile.delete();
- registry = Util.getSvcTagClientRegistry();
-
// verify that only one service tag is created
ServiceTag st1 = testJavaServiceTag("Test1");
diff --git a/test/com/sun/servicetag/SystemRegistryTest.java b/test/com/sun/servicetag/SystemRegistryTest.java
index 0e0be1ccb..7e521c1f6 100644
--- a/test/com/sun/servicetag/SystemRegistryTest.java
+++ b/test/com/sun/servicetag/SystemRegistryTest.java
@@ -50,8 +50,16 @@ public class SystemRegistryTest {
private static Registry registry;
public static void main(String[] argv) throws Exception {
- registry = Util.getSvcTagClientRegistry();
+ try {
+ registry = Util.getSvcTagClientRegistry();
+ runTest();
+ } finally {
+ // restore empty registry file
+ Util.emptyRegistryFile();
+ }
+ }
+ private static void runTest() throws Exception {
for (String filename : files) {
File f = new File(servicetagDir, filename);
ServiceTag svcTag = Util.newServiceTag(f);
diff --git a/test/com/sun/servicetag/Util.java b/test/com/sun/servicetag/Util.java
index 8fed8be55..77bc7da83 100644
--- a/test/com/sun/servicetag/Util.java
+++ b/test/com/sun/servicetag/Util.java
@@ -219,25 +219,25 @@ public class Util {
}
private static Registry registry = null;
+ private static File registryFile = null;
/**
* Returns the Registry processed by SvcTagClient that simulates
* stclient.
*/
static synchronized Registry getSvcTagClientRegistry() throws IOException {
+ String regDir = System.getProperty("test.classes");
+ File f = new File(regDir, "registry.xml");
if (registry != null) {
+ if (!f.equals(registryFile) && f.length() != 0) {
+ throw new AssertionError("Has to be empty registry.xml to run in samevm");
+ }
return registry;
}
// System.setProperty("servicetag.verbose", "true");
// enable the helper class
System.setProperty("servicetag.sthelper.supported", "true");
-
- // clean up registry.xml
- String regDir = System.getProperty("test.classes");
- File registryFile = new File(regDir, "registry.xml");
- if (registryFile.exists()) {
- registryFile.delete();
- }
+ registryFile = f;
String stclientCmd = Util.getSvcClientCommand(registryFile.getCanonicalPath());
System.out.println("stclient cmd: " + stclientCmd);
@@ -247,4 +247,17 @@ public class Util {
registry = Registry.getSystemRegistry();
return registry;
}
+
+ static void emptyRegistryFile() throws IOException {
+ if (registryFile.exists()) {
+ BufferedOutputStream out = new BufferedOutputStream(
+ new FileOutputStream(registryFile));
+ try {
+ RegistrationData data = new RegistrationData();
+ data.storeToXML(out);
+ } finally {
+ out.close();
+ }
+ }
+ }
}
diff --git a/test/com/sun/tools/attach/BasicTests.sh b/test/com/sun/tools/attach/BasicTests.sh
index 4c9236cca..3f8f85714 100644
--- a/test/com/sun/tools/attach/BasicTests.sh
+++ b/test/com/sun/tools/attach/BasicTests.sh
@@ -37,6 +37,21 @@ then
exit 1
fi
+# Windows 2000 is a problem here, so we skip it, see 6962615
+osrev=`uname -a`
+if [ "`echo ${osrev} | grep 'CYGWIN'`" != "" ] ; then
+ if [ "`echo ${osrev} | grep '5.0'`" != "" ] ; then
+ echo "Treating as a pass, not testing Windows 2000"
+ exit 0
+ fi
+fi
+if [ "`echo ${osrev} | grep 'Windows'`" != "" ] ; then
+ if [ "`echo ${osrev} | grep '5 00'`" != "" ] ; then
+ echo "Treating as a pass, not testing Windows 2000"
+ exit 0
+ fi
+fi
+
. ${TESTSRC}/CommonSetup.sh
. ${TESTSRC}/ApplicationSetup.sh
. ${TESTSRC}/AgentSetup.sh
diff --git a/test/com/sun/tracing/BasicFunctionality.java b/test/com/sun/tracing/BasicFunctionality.java
index 0311fde02..614e73e2a 100644
--- a/test/com/sun/tracing/BasicFunctionality.java
+++ b/test/com/sun/tracing/BasicFunctionality.java
@@ -24,6 +24,7 @@
/**
* @test
* @bug 6537506
+ * @ignore 6962535
* @summary Basic unit test for tracing framework
*/
diff --git a/test/java/beans/Beans/Test4080522.java b/test/java/beans/Beans/Test4080522.java
index a26a2f10e..c6ee1b89b 100644
--- a/test/java/beans/Beans/Test4080522.java
+++ b/test/java/beans/Beans/Test4080522.java
@@ -29,6 +29,7 @@
* Beans.setGuiAvailable
* Introspector.setBeanInfoSearchPath
* PropertyEditorManager.setEditorSearchPath
+ * @run main/othervm Test4080522
* @author Graham Hamilton
*/
diff --git a/test/java/beans/EventHandler/Test6277246.java b/test/java/beans/EventHandler/Test6277246.java
index e009aad34..f0d9aaaa8 100644
--- a/test/java/beans/EventHandler/Test6277246.java
+++ b/test/java/beans/EventHandler/Test6277246.java
@@ -25,6 +25,7 @@
* @test
* @bug 6277246
* @summary Tests problem with java.beans use of reflection
+ * @run main/othervm Test6277246
* @author Jeff Nisewanger
*/
diff --git a/test/java/beans/EventHandler/Test6277266.java b/test/java/beans/EventHandler/Test6277266.java
index f64f852fd..a23a4daea 100644
--- a/test/java/beans/EventHandler/Test6277266.java
+++ b/test/java/beans/EventHandler/Test6277266.java
@@ -25,6 +25,7 @@
* @test
* @bug 6277266
* @summary Tests access control issue in EventHandler
+ * @run main/othervm Test6277266
* @author Jeff Nisewanger
*/
diff --git a/test/java/beans/Introspector/Test6277246.java b/test/java/beans/Introspector/Test6277246.java
index 826f6e42f..40ea01616 100644
--- a/test/java/beans/Introspector/Test6277246.java
+++ b/test/java/beans/Introspector/Test6277246.java
@@ -25,6 +25,7 @@
* @test
* @bug 6277246
* @summary Tests problem with java.beans use of reflection
+ * @run main/othervm Test6277246
* @author Jeff Nisewanger
*/
diff --git a/test/java/io/BufferedReader/BigMark.java b/test/java/io/BufferedReader/BigMark.java
index 67b5dd3e0..fe336a41a 100644
--- a/test/java/io/BufferedReader/BigMark.java
+++ b/test/java/io/BufferedReader/BigMark.java
@@ -25,6 +25,8 @@
@summary BufferedReader should throw an OutOfMemoryError when the
read-ahead limit is very large
@bug 6350733
+ @build BigMark
+ @run main/othervm BigMark
*/
import java.io.*;
diff --git a/test/java/io/BufferedReader/ReadLineSync.java b/test/java/io/BufferedReader/ReadLineSync.java
index 1b2dd495b..2af83e47d 100644
--- a/test/java/io/BufferedReader/ReadLineSync.java
+++ b/test/java/io/BufferedReader/ReadLineSync.java
@@ -46,16 +46,20 @@ public class ReadLineSync {
BufferedReader reader = new BufferedReader(
new FileReader(f));
- int threadCount = 2;
+ try {
+ int threadCount = 2;
- ExecutorService es = Executors.newFixedThreadPool(threadCount);
+ ExecutorService es = Executors.newFixedThreadPool(threadCount);
- for (int i=0; i < threadCount; i++)
- es.execute(new BufferedReaderConsumer(reader));
+ for (int i=0; i < threadCount; i++)
+ es.execute(new BufferedReaderConsumer(reader));
- // Wait for the tasks to complete
- es.shutdown();
- while (!es.awaitTermination(60, TimeUnit.SECONDS));
+ // Wait for the tasks to complete
+ es.shutdown();
+ while (!es.awaitTermination(60, TimeUnit.SECONDS));
+ } finally {
+ reader.close();
+ }
}
static class BufferedReaderConsumer extends Thread {
diff --git a/test/java/io/DataInputStream/OpsAfterClose.java b/test/java/io/DataInputStream/OpsAfterClose.java
index a0f0fdfc3..a54926b2e 100644
--- a/test/java/io/DataInputStream/OpsAfterClose.java
+++ b/test/java/io/DataInputStream/OpsAfterClose.java
@@ -244,13 +244,19 @@ public enum OpsAfterClose {
f.deleteOnExit();
FileInputStream fis = new FileInputStream(f);
-
- DataInputStream dis = new DataInputStream(
- new FileInputStream(f));
- if (testDataInputStream(dis)) {
- failed = true;
+ try {
+ DataInputStream dis = new DataInputStream(
+ new FileInputStream(f));
+ try {
+ if (testDataInputStream(dis)) {
+ failed = true;
+ }
+ } finally {
+ dis.close();
+ }
+ } finally {
+ fis.close();
}
-
}
private static boolean testDataInputStream(DataInputStream is)
diff --git a/test/java/io/DataInputStream/ReadFully.java b/test/java/io/DataInputStream/ReadFully.java
index ad9428016..53c0ee5c4 100644
--- a/test/java/io/DataInputStream/ReadFully.java
+++ b/test/java/io/DataInputStream/ReadFully.java
@@ -43,6 +43,7 @@ public class ReadFully {
} catch (IndexOutOfBoundsException ie) {
caughtException = true;
} finally {
+ dis.close();
if (!caughtException)
throw new RuntimeException("Test failed");
}
diff --git a/test/java/io/File/DeleteOnExit.java b/test/java/io/File/DeleteOnExit.java
index 74100ee52..b332bf9c8 100644
--- a/test/java/io/File/DeleteOnExit.java
+++ b/test/java/io/File/DeleteOnExit.java
@@ -48,7 +48,9 @@ public class DeleteOnExit {
public static void main (String args[]) throws Exception{
if (args.length == 0) {
- Runtime.getRuntime().exec(java + " DeleteOnExit -test").waitFor();
+ String cmd = java + " -classpath " + System.getProperty("test.classes")
+ + " DeleteOnExit -test";
+ Runtime.getRuntime().exec(cmd).waitFor();
if (file1.exists() || file2.exists() || file3.exists() ||
dir.exists() || file4.exists() || file5.exists() ||
file6.exists() || file7.exists()) {
diff --git a/test/java/io/File/DeleteOnExitNPE.java b/test/java/io/File/DeleteOnExitNPE.java
index dff7915d0..50a29c3c8 100644
--- a/test/java/io/File/DeleteOnExitNPE.java
+++ b/test/java/io/File/DeleteOnExitNPE.java
@@ -45,7 +45,8 @@ public class DeleteOnExitNPE implements Runnable
public static void runTest() throws Exception {
String cmd = System.getProperty("java.home") + File.separator +
- "bin" + File.separator + "java";
+ "bin" + File.separator + "java" +
+ " -classpath " + System.getProperty("test.classes");
Process process = Runtime.getRuntime().exec(cmd + " DeleteOnExitNPE -test");
BufferedReader isReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader esReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
diff --git a/test/java/io/File/IsHidden.java b/test/java/io/File/IsHidden.java
index a0198d1ef..e34fcc399 100644
--- a/test/java/io/File/IsHidden.java
+++ b/test/java/io/File/IsHidden.java
@@ -27,7 +27,7 @@
*/
import java.io.*;
-
+import java.nio.file.attribute.DosFileAttributeView;
public class IsHidden {
@@ -41,15 +41,20 @@ public class IsHidden {
System.err.println(path + " ==> " + x);
}
+ private static void setHidden(File f, boolean value) throws IOException {
+ f.toPath().getFileAttributeView(DosFileAttributeView.class).setHidden(value);
+ }
+
private static void testWin32() throws Exception {
File f = new File(dir, "test");
f.deleteOnExit();
f.createNewFile();
- String name = f.getCanonicalPath();
- Process p = Runtime.getRuntime().exec("cmd.exe /c attrib +H " + name);
- p.waitFor();
- ck(name, true);
-
+ setHidden(f, true);
+ try {
+ ck(f.getPath(), true);
+ } finally {
+ setHidden(f, false);
+ }
ck(".foo", false);
ck("foo", false);
}
diff --git a/test/java/io/FileInputStream/LeadingSlash.java b/test/java/io/FileInputStream/LeadingSlash.java
index 7b72be99c..3b5724302 100644
--- a/test/java/io/FileInputStream/LeadingSlash.java
+++ b/test/java/io/FileInputStream/LeadingSlash.java
@@ -36,8 +36,8 @@ public class LeadingSlash {
File file = null;
try {
file = File.createTempFile("bug", "4487368");
- new FileInputStream("\\" + file.getPath());
- new FileOutputStream("\\" + file.getPath());
+ new FileInputStream("\\" + file.getPath()).close();
+ new FileOutputStream("\\" + file.getPath()).close();
} finally {
if (file != null)
file.delete();
diff --git a/test/java/io/InputStream/OpsAfterClose.java b/test/java/io/InputStream/OpsAfterClose.java
index 7c64c9859..9685782ff 100644
--- a/test/java/io/InputStream/OpsAfterClose.java
+++ b/test/java/io/InputStream/OpsAfterClose.java
@@ -125,23 +125,35 @@ public enum OpsAfterClose {
f.deleteOnExit();
FileInputStream fis = new FileInputStream(f);
- if (testInputStream(fis)) {
- failed = true;
- }
- if (testFileInputStream(fis)) {
- failed = true;
+ try {
+ if (testInputStream(fis)) {
+ failed = true;
+ }
+ if (testFileInputStream(fis)) {
+ failed = true;
+ }
+ } finally {
+ fis.close();
}
BufferedInputStream bs = new BufferedInputStream(
new FileInputStream(f));
- if (testInputStream(bs)) {
- failed = true;
+ try {
+ if (testInputStream(bs)) {
+ failed = true;
+ }
+ } finally {
+ bs.close();
}
DataInputStream dis = new DataInputStream(
new FileInputStream(f));
- if (testInputStream(dis)) {
- failed = true;
+ try {
+ if (testInputStream(dis)) {
+ failed = true;
+ }
+ } finally {
+ dis.close();
}
PushbackInputStream pbis = new PushbackInputStream(
diff --git a/test/java/io/InputStream/ReadParams.java b/test/java/io/InputStream/ReadParams.java
index 36713aa8e..602445cd0 100644
--- a/test/java/io/InputStream/ReadParams.java
+++ b/test/java/io/InputStream/ReadParams.java
@@ -137,6 +137,7 @@ public class ReadParams {
oos.writeInt(12345);
oos.writeObject("Today");
oos.writeObject(new Integer(32));
+ oos.close();
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(fn));
doTest(ois);
doTest1(ois);
diff --git a/test/java/io/InputStreamReader/GrowAfterEOF.java b/test/java/io/InputStreamReader/GrowAfterEOF.java
index 7434401b4..96bb2a971 100644
--- a/test/java/io/InputStreamReader/GrowAfterEOF.java
+++ b/test/java/io/InputStreamReader/GrowAfterEOF.java
@@ -33,29 +33,36 @@ public class GrowAfterEOF {
public static void main(String[] args) throws Exception {
File input = new File(".", "TestEOFInput.txt");
RandomAccessFile rf = new RandomAccessFile(input, "rw");
- BufferedReader r = new BufferedReader
- (new InputStreamReader(new FileInputStream(input)));
+ try {
+ BufferedReader r = new BufferedReader
+ (new InputStreamReader(new FileInputStream(input)));
+ try {
+ // write something
+ rf.writeBytes("a line");
- // write something
- rf.writeBytes("a line");
+ // read till the end of file
+ while (r.readLine() != null);
- // read till the end of file
- while (r.readLine() != null);
+ // append to the end of the file
+ rf.seek(rf.length());
+ rf.writeBytes("new line");
- // append to the end of the file
- rf.seek(rf.length());
- rf.writeBytes("new line");
-
- // now try to read again
- boolean readMore = false;
- while (r.readLine() != null) {
- readMore = true;
- }
- if (!readMore) {
- input.delete();
- throw new Exception("Failed test: unable to read!");
- } else {
- input.delete();
+ // now try to read again
+ boolean readMore = false;
+ while (r.readLine() != null) {
+ readMore = true;
+ }
+ if (!readMore) {
+ input.delete();
+ throw new Exception("Failed test: unable to read!");
+ } else {
+ input.delete();
+ }
+ } finally {
+ r.close();
+ }
+ } finally {
+ rf.close();
}
}
}
diff --git a/test/java/io/ObjectInputStream/ResolveProxyClass.java b/test/java/io/ObjectInputStream/ResolveProxyClass.java
index 59cd3d349..eaea1c32c 100644
--- a/test/java/io/ObjectInputStream/ResolveProxyClass.java
+++ b/test/java/io/ObjectInputStream/ResolveProxyClass.java
@@ -79,7 +79,7 @@ public class ResolveProxyClass {
* code, and it should be the first loader on the stack when
* ObjectInputStream.resolveProxyClass gets executed.
*/
- ClassLoader expectedLoader = ClassLoader.getSystemClassLoader();
+ ClassLoader expectedLoader = ResolveProxyClass.class.getClassLoader();
TestObjectInputStream in = new TestObjectInputStream();
Class proxyClass = in.resolveProxyClass(
diff --git a/test/java/io/RandomAccessFile/EOF.java b/test/java/io/RandomAccessFile/EOF.java
index aa65fd361..50b48de77 100644
--- a/test/java/io/RandomAccessFile/EOF.java
+++ b/test/java/io/RandomAccessFile/EOF.java
@@ -35,12 +35,16 @@ public class EOF {
int n;
String dir = System.getProperty("test.src", ".");
RandomAccessFile raf = new RandomAccessFile(new File(dir, "EOF.java"), "r");
- for (;;) {
- n = raf.read(buf, 0, buf.length);
- if (n <= 0) break;
+ try {
+ for (;;) {
+ n = raf.read(buf, 0, buf.length);
+ if (n <= 0) break;
+ }
+ if (n != -1)
+ throw new RuntimeException("Expected -1 for EOF, got " + n);
+ } finally {
+ raf.close();
}
- if (n != -1)
- throw new RuntimeException("Expected -1 for EOF, got " + n);
}
}
diff --git a/test/java/io/RandomAccessFile/ParameterCheck.java b/test/java/io/RandomAccessFile/ParameterCheck.java
index 97319fcff..e483929cd 100644
--- a/test/java/io/RandomAccessFile/ParameterCheck.java
+++ b/test/java/io/RandomAccessFile/ParameterCheck.java
@@ -44,6 +44,7 @@ public class ParameterCheck {
private static void doTest(String method) throws Exception {
File fn = new File("x.ParameterCheck");
+ RandomAccessFile raf = null;
try {
byte b[] = new byte[32];
@@ -55,7 +56,7 @@ public class ParameterCheck {
fout.write(i);
}
fout.close();
- RandomAccessFile raf = new RandomAccessFile(fn , "rw");
+ raf = new RandomAccessFile(fn , "rw");
System.err.println("-----------------------------" +
"-----------------------------");
@@ -125,6 +126,8 @@ public class ParameterCheck {
System.err.println("-----------------------------" +
"-----------------------------");
} finally {
+ if (raf != null)
+ raf.close();
fn.delete();
}
diff --git a/test/java/io/RandomAccessFile/ReadLine.java b/test/java/io/RandomAccessFile/ReadLine.java
index 879926f89..1d63ce08a 100644
--- a/test/java/io/RandomAccessFile/ReadLine.java
+++ b/test/java/io/RandomAccessFile/ReadLine.java
@@ -33,26 +33,30 @@ public class ReadLine {
public static void main(String args[]) throws Exception {
File fn = new File("x.ReadLine");
RandomAccessFile raf = new RandomAccessFile(fn,"rw");
- String line;
- int ctr = 1;
- String expected;
+ try {
+ String line;
+ int ctr = 1;
+ String expected;
- raf.writeBytes
- ("ln1\rln2\r\nln3\nln4\rln5\r\nln6\n\rln8\r\rln10\n\nln12\r\r\nln14");
- raf.seek(0);
+ raf.writeBytes
+ ("ln1\rln2\r\nln3\nln4\rln5\r\nln6\n\rln8\r\rln10\n\nln12\r\r\nln14");
+ raf.seek(0);
- while ((line=raf.readLine()) != null) {
- if ((ctr == 7) || (ctr == 9) ||
- (ctr == 11) || (ctr == 13)) {
- expected = "";
- } else {
- expected = "ln" + ctr;
+ while ((line=raf.readLine()) != null) {
+ if ((ctr == 7) || (ctr == 9) ||
+ (ctr == 11) || (ctr == 13)) {
+ expected = "";
+ } else {
+ expected = "ln" + ctr;
+ }
+ if (!line.equals(expected)) {
+ throw new Exception("Expected \"" + expected + "\"" +
+ ", read \"" + line + "\"");
+ }
+ ctr++;
}
- if (!line.equals(expected)) {
- throw new Exception("Expected \"" + expected + "\"" +
- ", read \"" + line + "\"");
- }
- ctr++;
+ } finally {
+ raf.close();
}
System.err.println("Successfully completed test!");
}
diff --git a/test/java/io/RandomAccessFile/Seek.java b/test/java/io/RandomAccessFile/Seek.java
index a3f15cde1..2a505e58f 100644
--- a/test/java/io/RandomAccessFile/Seek.java
+++ b/test/java/io/RandomAccessFile/Seek.java
@@ -44,6 +44,8 @@ public class Seek
throw new Exception
("Should have thrown an IOException when seek offset is < 0");
} catch (IOException e) {
+ } finally {
+ raf.close();
}
}
}
diff --git a/test/java/io/RandomAccessFile/WriteBytesChars.java b/test/java/io/RandomAccessFile/WriteBytesChars.java
index 6803f2b2d..bbb94943b 100644
--- a/test/java/io/RandomAccessFile/WriteBytesChars.java
+++ b/test/java/io/RandomAccessFile/WriteBytesChars.java
@@ -37,8 +37,8 @@ public class WriteBytesChars {
byte[] b = new byte[80];
File fn = new File("x.WriteBytesChars");
- try{
- RandomAccessFile raf = new RandomAccessFile(fn , "rw");;
+ RandomAccessFile raf = new RandomAccessFile(fn , "rw");;
+ try {
for (int i = 0; i < 80; i++) {
buf[i] = 'a';
}
@@ -71,6 +71,7 @@ public class WriteBytesChars {
RuntimeException("RandomAccessFile.writeChars, wrong result");
}
} finally {
+ raf.close();
fn.delete();
}
}
diff --git a/test/java/io/RandomAccessFile/WriteUTF.java b/test/java/io/RandomAccessFile/WriteUTF.java
index ed831273a..c3d13e049 100644
--- a/test/java/io/RandomAccessFile/WriteUTF.java
+++ b/test/java/io/RandomAccessFile/WriteUTF.java
@@ -42,8 +42,8 @@ public class WriteUTF {
s += s;
System.err.println("String length " + s.length());
+ f = new RandomAccessFile(fn, "rw");
try {
- f = new RandomAccessFile(fn, "rw");
try {
f.writeUTF(s);
}
@@ -53,6 +53,7 @@ public class WriteUTF {
throw new RuntimeException("UTFDataFormatException not thrown");
}
finally {
+ f.close();
fn.delete();
}
diff --git a/test/java/io/RandomAccessFile/skipBytes/SkipBytes.java b/test/java/io/RandomAccessFile/skipBytes/SkipBytes.java
index 9c4cf0439..0e8723ebe 100644
--- a/test/java/io/RandomAccessFile/skipBytes/SkipBytes.java
+++ b/test/java/io/RandomAccessFile/skipBytes/SkipBytes.java
@@ -96,14 +96,18 @@ public class SkipBytes{
public static void main(String[] args) throws Exception {
RandomAccessFile raf = new RandomAccessFile("input.txt" , "rw");
- int length = (int)raf.length();
-
- doTest(raf , 0 , 2*length);
- doTest(raf , 0 , length);
- doTest(raf , 0 , length/2);
- doTest(raf , length/2 , -2);
- doTest(raf , length , 0);
- doTest(raf , 0 , -1);
+ try {
+ int length = (int)raf.length();
+
+ doTest(raf , 0 , 2*length);
+ doTest(raf , 0 , length);
+ doTest(raf , 0 , length/2);
+ doTest(raf , length/2 , -2);
+ doTest(raf , length , 0);
+ doTest(raf , 0 , -1);
+ } finally{
+ raf.close();
+ }
}
diff --git a/test/java/io/Reader/Skip.java b/test/java/io/Reader/Skip.java
index cc4255bc3..08f627f7a 100644
--- a/test/java/io/Reader/Skip.java
+++ b/test/java/io/Reader/Skip.java
@@ -35,12 +35,16 @@ public class Skip {
File f = new File(System.getProperty("test.src", "."),
"SkipInput.txt");
FileReader fr = new FileReader(f);
- long nchars = 8200;
- long actual = fr.skip(nchars);
+ try {
+ long nchars = 8200;
+ long actual = fr.skip(nchars);
- if (actual > nchars) {
- throw new Exception
- ("Should skip " + nchars + ", but skipped " +actual+" chars");
+ if (actual > nchars) {
+ throw new Exception
+ ("Should skip " + nchars + ", but skipped " +actual+" chars");
+ }
+ } finally {
+ fr.close();
}
}
}
diff --git a/test/java/io/Reader/SkipNegative.java b/test/java/io/Reader/SkipNegative.java
index 17ec0c050..e1aec0ca5 100644
--- a/test/java/io/Reader/SkipNegative.java
+++ b/test/java/io/Reader/SkipNegative.java
@@ -41,6 +41,8 @@ public class SkipNegative {
} catch(IllegalArgumentException e){
// Negative argument caught
return;
+ } finally {
+ fr.close();
}
throw new Exception("Skip should not accept negative values");
}
diff --git a/test/java/io/Serializable/ClassCastExceptionDetail/Read.java b/test/java/io/Serializable/ClassCastExceptionDetail/Read.java
index a6063106b..52373c500 100644
--- a/test/java/io/Serializable/ClassCastExceptionDetail/Read.java
+++ b/test/java/io/Serializable/ClassCastExceptionDetail/Read.java
@@ -40,9 +40,9 @@ class Gub extends Foo {}
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("tmp.ser"));
+ FileInputStream in = new FileInputStream("tmp.ser");
try {
+ ObjectInputStream oin = new ObjectInputStream(in);
oin.readObject();
throw new Error("readObject should not succeed");
} catch (ClassCastException e) {
@@ -57,6 +57,8 @@ public class Read {
{
throw new Error("ClassNotFoundException message incomplete");
}
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java b/test/java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java
index c5b5bdd24..e27eaf4e9 100644
--- a/test/java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java
+++ b/test/java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java
@@ -26,6 +26,8 @@
* @summary Verify that unauthorized ObjectOutputStream and ObjectInputStream
* cannot be constructed if they override security-sensitive non-final
* methods.
+ * @build AuditStreamSubclass
+ * @run main/othervm AuditStreamSubclass
*/
import java.io.*;
diff --git a/test/java/io/Serializable/backRefCNFException/Read.java b/test/java/io/Serializable/backRefCNFException/Read.java
index e40689987..9bc69ada6 100644
--- a/test/java/io/Serializable/backRefCNFException/Read.java
+++ b/test/java/io/Serializable/backRefCNFException/Read.java
@@ -38,13 +38,17 @@ class A implements Serializable {
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("tmp.ser"));
- oin.readObject();
+ FileInputStream in = new FileInputStream("tmp.ser");
try {
+ ObjectInputStream oin = new ObjectInputStream(in);
oin.readObject();
- throw new Error("back reference read succeeded");
- } catch (ClassNotFoundException ex) {
+ try {
+ oin.readObject();
+ throw new Error("back reference read succeeded");
+ } catch (ClassNotFoundException ex) {
+ }
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/checkModifiers/CheckModifiers.java b/test/java/io/Serializable/checkModifiers/CheckModifiers.java
index 6519af87b..d984ad543 100644
--- a/test/java/io/Serializable/checkModifiers/CheckModifiers.java
+++ b/test/java/io/Serializable/checkModifiers/CheckModifiers.java
@@ -213,33 +213,39 @@ public class CheckModifiers {
FileOutputStream fos = new FileOutputStream("fields.ser");
- ObjectOutputStream oos = new ObjectOutputStream(fos);
-
- System.out.println("Writing obj 1");
- oos.writeObject(tc1);
- System.out.println("Writing obj 2");
- oos.writeObject(tc2);
- System.out.println("Writing obj 3");
- oos.writeObject(tc3);
- System.out.println("Writing obj 4");
- oos.writeObject(tc4);
+ try {
+ ObjectOutputStream oos = new ObjectOutputStream(fos);
+ System.out.println("Writing obj 1");
+ oos.writeObject(tc1);
+ System.out.println("Writing obj 2");
+ oos.writeObject(tc2);
+ System.out.println("Writing obj 3");
+ oos.writeObject(tc3);
+ System.out.println("Writing obj 4");
+ oos.writeObject(tc4);
+ oos.flush();
+ } finally {
+ fos.close();
+ }
FileInputStream fis = new FileInputStream("fields.ser");
- ObjectInputStream ois = new ObjectInputStream(fis);
-
-
- System.out.println("Test modifiers for serialPeristentFields ");
- System.out.println("---------------------------------------- ");
- System.out.println("Declaration missing final modifier");
- ois.readObject();
- System.out.println();
- System.out.println("Declaration with public instead of private access");
- ois.readObject();
- System.out.println();
- System.out.println("Declaration with different type");
- ois.readObject();
- System.out.println();
- System.out.println("Declaration as in specification");
- ois.readObject();
+ try {
+ ObjectInputStream ois = new ObjectInputStream(fis);
+ System.out.println("Test modifiers for serialPeristentFields ");
+ System.out.println("---------------------------------------- ");
+ System.out.println("Declaration missing final modifier");
+ ois.readObject();
+ System.out.println();
+ System.out.println("Declaration with public instead of private access");
+ ois.readObject();
+ System.out.println();
+ System.out.println("Declaration with different type");
+ ois.readObject();
+ System.out.println();
+ System.out.println("Declaration as in specification");
+ ois.readObject();
+ } finally {
+ fis.close();
+ }
}
};
diff --git a/test/java/io/Serializable/classDescFlagConflict/Read.java b/test/java/io/Serializable/classDescFlagConflict/Read.java
index c484379de..f7eb5e512 100644
--- a/test/java/io/Serializable/classDescFlagConflict/Read.java
+++ b/test/java/io/Serializable/classDescFlagConflict/Read.java
@@ -42,10 +42,15 @@ public class Read {
* descriptor.
*/
File f = new File(System.getProperty("test.src", "."), "Foo.ser");
- new ObjectInputStream(new FileInputStream(f)).readObject();
- throw new Error(
- "read succeeded for object whose class descriptor has " +
- "both SC_SERIALIZABLE and SC_EXTERNALIZABLE flags set");
+ FileInputStream in = new FileInputStream(f);
+ try {
+ new ObjectInputStream(in).readObject();
+ throw new Error(
+ "read succeeded for object whose class descriptor has " +
+ "both SC_SERIALIZABLE and SC_EXTERNALIZABLE flags set");
+ } finally {
+ in.close();
+ }
} catch (InvalidClassException e) {
}
}
diff --git a/test/java/io/Serializable/classDescHooks/ClassDescHooks.java b/test/java/io/Serializable/classDescHooks/ClassDescHooks.java
index c71cf338a..9e382fe70 100644
--- a/test/java/io/Serializable/classDescHooks/ClassDescHooks.java
+++ b/test/java/io/Serializable/classDescHooks/ClassDescHooks.java
@@ -93,8 +93,12 @@ public class ClassDescHooks implements ObjectStreamConstants {
bout = new ByteArrayOutputStream();
foof = new File(System.getProperty("test.src", "."), "Foo.ser");
fin = new FileInputStream(foof);
- while (fin.available() > 0)
- bout.write(fin.read());
+ try {
+ while (fin.available() > 0)
+ bout.write(fin.read());
+ } finally {
+ fin.close();
+ }
byte[] buf1 = bout.toByteArray();
bout = new ByteArrayOutputStream();
@@ -107,11 +111,16 @@ public class ClassDescHooks implements ObjectStreamConstants {
if (! Arrays.equals(buf1, buf2))
throw new Error("Incompatible stream format (write)");
+ Foo foocopy;
fin = new FileInputStream(foof);
- oin = new ObjectInputStream(fin);
- Foo foocopy = (Foo) oin.readObject();
- if (! foo.equals(foocopy))
- throw new Error("Incompatible stream format (read)");
+ try {
+ oin = new ObjectInputStream(fin);
+ foocopy = (Foo) oin.readObject();
+ if (! foo.equals(foocopy))
+ throw new Error("Incompatible stream format (read)");
+ } finally {
+ fin.close();
+ }
// make sure write hook not called when old protocol in use
bout = new ByteArrayOutputStream();
diff --git a/test/java/io/Serializable/duplicateSerialFields/Test.java b/test/java/io/Serializable/duplicateSerialFields/Test.java
index a9f21b646..020912f21 100644
--- a/test/java/io/Serializable/duplicateSerialFields/Test.java
+++ b/test/java/io/Serializable/duplicateSerialFields/Test.java
@@ -82,18 +82,26 @@ public class Test {
} catch (InvalidClassException e) {
}
+ FileInputStream in = new FileInputStream("a.ser");
try {
- new ObjectInputStream(new FileInputStream("a.ser")).readObject();
+ ObjectInputStream oin = new ObjectInputStream(in);
+ oin.readObject();
throw new Error(
"read of A should fail with InvalidClassException");
} catch (InvalidClassException e) {
+ } finally {
+ in.close();
}
+ in = new FileInputStream("b.ser");
try {
- new ObjectInputStream(new FileInputStream("b.ser")).readObject();
+ ObjectInputStream oin = new ObjectInputStream(in);
+ oin.readObject();
throw new Error(
"read of B should fail with InvalidClassException");
} catch (InvalidClassException e) {
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/enum/badResolve/Read.java b/test/java/io/Serializable/enum/badResolve/Read.java
index fb8067853..c2b4a5c1d 100644
--- a/test/java/io/Serializable/enum/badResolve/Read.java
+++ b/test/java/io/Serializable/enum/badResolve/Read.java
@@ -44,13 +44,15 @@ public class Read {
}
static void read(String filename) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream(filename));
+ FileInputStream in = new FileInputStream(filename);
try {
+ ObjectInputStream oin = new ObjectInputStream(in);
Object obj = oin.readObject();
throw new Error("read of " + obj + " should not have succeeded");
} catch (InvalidClassException e) {
System.out.println("caught expected exception " + e);
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/enum/constantSubclasses/Read.java b/test/java/io/Serializable/enum/constantSubclasses/Read.java
index e9f47fdac..d1145768b 100644
--- a/test/java/io/Serializable/enum/constantSubclasses/Read.java
+++ b/test/java/io/Serializable/enum/constantSubclasses/Read.java
@@ -38,13 +38,17 @@ enum Foo {
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("foo.ser"));
- for (Foo f : Foo.values()) {
- Object obj = oin.readObject();
- if (obj != f) {
- throw new Error("expected " + f + ", got " + obj);
+ FileInputStream in = new FileInputStream("foo.ser");
+ try {
+ ObjectInputStream oin = new ObjectInputStream(in);
+ for (Foo f : Foo.values()) {
+ Object obj = oin.readObject();
+ if (obj != f) {
+ throw new Error("expected " + f + ", got " + obj);
+ }
}
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/enum/missingConstant/Read.java b/test/java/io/Serializable/enum/missingConstant/Read.java
index c4965b8bf..4bd6075ad 100644
--- a/test/java/io/Serializable/enum/missingConstant/Read.java
+++ b/test/java/io/Serializable/enum/missingConstant/Read.java
@@ -33,19 +33,23 @@ enum Foo { foo, bar }
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("foo.ser"));
- for (Foo f : Foo.values()) {
- Object obj = oin.readObject();
- if (obj != f) {
- throw new Error("expected " + f + ", got " + obj);
- }
- }
+ FileInputStream in = new FileInputStream("foo.ser");
try {
- Object obj = oin.readObject();
- throw new Error("read of " + obj + " should not succeed");
- } catch (InvalidObjectException e) {
- System.out.println("caught expected exception: " + e);
+ ObjectInputStream oin = new ObjectInputStream(in);
+ for (Foo f : Foo.values()) {
+ Object obj = oin.readObject();
+ if (obj != f) {
+ throw new Error("expected " + f + ", got " + obj);
+ }
+ }
+ try {
+ Object obj = oin.readObject();
+ throw new Error("read of " + obj + " should not succeed");
+ } catch (InvalidObjectException e) {
+ System.out.println("caught expected exception: " + e);
+ }
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/fieldTypeString/Read.java b/test/java/io/Serializable/fieldTypeString/Read.java
index 3056ca31d..b8b7dd68b 100644
--- a/test/java/io/Serializable/fieldTypeString/Read.java
+++ b/test/java/io/Serializable/fieldTypeString/Read.java
@@ -44,23 +44,30 @@ class Bar implements Serializable {
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("foo.ser"));
- Foo foo = (Foo) oin.readObject();
- if (! foo.obj.equals("foo")) {
- throw new Error();
- }
+ FileInputStream in = new FileInputStream("foo.ser");
try {
- oin.readObject();
- throw new Error();
- } catch (ClassCastException ex) {
+ ObjectInputStream oin = new ObjectInputStream(in);
+ Foo foo = (Foo) oin.readObject();
+ if (! foo.obj.equals("foo")) {
+ throw new Error();
+ }
+ try {
+ oin.readObject();
+ throw new Error();
+ } catch (ClassCastException ex) {
+ }
+ } finally {
+ in.close();
}
- oin = new ObjectInputStream(new FileInputStream("bar.ser"));
+ in = new FileInputStream("bar.ser");
try {
+ ObjectInputStream oin = new ObjectInputStream(in);
oin.readObject();
throw new Error();
} catch (InvalidClassException ex) {
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/illegalHandle/Test.java b/test/java/io/Serializable/illegalHandle/Test.java
index af2d52663..74c7ad96c 100644
--- a/test/java/io/Serializable/illegalHandle/Test.java
+++ b/test/java/io/Serializable/illegalHandle/Test.java
@@ -38,21 +38,31 @@ public class Test {
* serialized String object followed by an illegal handle
*/
File f = new File(base, "negativeHandle.ser");
- ObjectInputStream oin = new ObjectInputStream(new FileInputStream(f));
- oin.readObject();
+ FileInputStream in = new FileInputStream(f);
try {
+ ObjectInputStream oin = new ObjectInputStream(in);
oin.readObject();
- throw new Error("negative handle read should not succeed");
- } catch (StreamCorruptedException ex) {
+ try {
+ oin.readObject();
+ throw new Error("negative handle read should not succeed");
+ } catch (StreamCorruptedException ex) {
+ }
+ } finally {
+ in.close();
}
f = new File(base, "tooHighHandle.ser");
- oin = new ObjectInputStream(new FileInputStream(f));
- oin.readObject();
+ in = new FileInputStream(f);
try {
+ ObjectInputStream oin = new ObjectInputStream(in);
oin.readObject();
- throw new Error("too-high handle read should not succeed");
- } catch (StreamCorruptedException ex) {
+ try {
+ oin.readObject();
+ throw new Error("too-high handle read should not succeed");
+ } catch (StreamCorruptedException ex) {
+ }
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/longString/LongString.java b/test/java/io/Serializable/longString/LongString.java
index bbb670100..7d342b1b9 100644
--- a/test/java/io/Serializable/longString/LongString.java
+++ b/test/java/io/Serializable/longString/LongString.java
@@ -68,17 +68,25 @@ public class LongString {
mesgf = new File(System.getProperty("test.src", "."), "mesg.ser");
fin = new FileInputStream(mesgf);
bout = new ByteArrayOutputStream();
- while (fin.available() > 0)
- bout.write(fin.read());
+ try {
+ while (fin.available() > 0)
+ bout.write(fin.read());
+ } finally {
+ fin.close();
+ }
byte[] buf2 = bout.toByteArray();
if (! Arrays.equals(buf1, buf2))
throw new Error("incompatible string format (write)");
fin = new FileInputStream(mesgf);
- oin = new ObjectInputStream(fin);
- String mesgcopy = (String) oin.readObject();
- if (! mesg.equals(mesgcopy))
- throw new Error("incompatible string format (read)");
+ try {
+ oin = new ObjectInputStream(fin);
+ String mesgcopy = (String) oin.readObject();
+ if (! mesg.equals(mesgcopy))
+ throw new Error("incompatible string format (read)");
+ } finally {
+ fin.close();
+ }
}
}
diff --git a/test/java/io/Serializable/oldTests/AnnotateClass.java b/test/java/io/Serializable/oldTests/AnnotateClass.java
index 4680b4c45..17f3ab118 100644
--- a/test/java/io/Serializable/oldTests/AnnotateClass.java
+++ b/test/java/io/Serializable/oldTests/AnnotateClass.java
@@ -37,36 +37,43 @@ public class AnnotateClass {
"methods \n");
try {
FileOutputStream ostream = new FileOutputStream("subtest1.tmp");
- TestOutputStream p = new TestOutputStream(ostream);
-
- p.writeObject(System.out);
- p.writeObject(System.err);
- p.writeObject(new PrintStream(ostream));
- p.flush();
- ostream.close();
+ try {
+ TestOutputStream p = new TestOutputStream(ostream);
+ p.writeObject(System.out);
+ p.writeObject(System.err);
+ p.writeObject(new PrintStream(ostream));
+ p.flush();
+ } finally {
+ ostream.close();
+ }
FileInputStream istream = new FileInputStream("subtest1.tmp");
- TestInputStream q = new TestInputStream(istream);
-
- PrintStream out = (PrintStream)q.readObject();
- PrintStream err = (PrintStream)q.readObject();
- Object other = q.readObject();
- if (out != System.out) {
- System.err.println(
- "\nTEST FAILED: System.out not read correctly");
- throw new Error();
- }
- if (err != System.err) {
- System.err.println(
- "\nTEST FAILED: System.err not read correctly");
- throw new Error();
- }
- if (other != null) {
- System.err.println(
- "\nTEST FAILED: Non-system PrintStream should have " +
- "been written/read as null");
- throw new Error();
+ try {
+ TestInputStream q = new TestInputStream(istream);
+
+ PrintStream out = (PrintStream)q.readObject();
+ PrintStream err = (PrintStream)q.readObject();
+ Object other = q.readObject();
+ if (out != System.out) {
+ System.err.println(
+ "\nTEST FAILED: System.out not read correctly");
+ throw new Error();
+ }
+ if (err != System.err) {
+ System.err.println(
+ "\nTEST FAILED: System.err not read correctly");
+ throw new Error();
+ }
+ if (other != null) {
+ System.err.println(
+ "\nTEST FAILED: Non-system PrintStream should have " +
+ "been written/read as null");
+ throw new Error();
+ }
+ } finally {
+ istream.close();
}
+
System.err.println("\nTEST PASSED");
} catch (Exception e) {
System.err.print("TEST FAILED: ");
diff --git a/test/java/io/Serializable/oldTests/ArrayFields.java b/test/java/io/Serializable/oldTests/ArrayFields.java
index 743268f8a..6833a039a 100644
--- a/test/java/io/Serializable/oldTests/ArrayFields.java
+++ b/test/java/io/Serializable/oldTests/ArrayFields.java
@@ -35,20 +35,22 @@ import java.io.*;
public class ArrayFields {
- public static void main (String argv[]) {
+ public static void main (String argv[]) throws IOException {
System.err.println("\nRegression test for testing of " +
"serialization/deserialization of objects with " +
"fields of array type\n");
+ FileOutputStream ostream = null;
+ FileInputStream istream = null;
try {
- FileOutputStream ostream = new FileOutputStream("piotest4.tmp");
+ ostream = new FileOutputStream("piotest4.tmp");
ObjectOutputStream p = new ObjectOutputStream(ostream);
ArrayTest array = new ArrayTest();
p.writeObject(array);
p.flush();
- FileInputStream istream = new FileInputStream("piotest4.tmp");
+ istream = new FileInputStream("piotest4.tmp");
ObjectInputStream q = new ObjectInputStream(istream);
Object obj = null;
@@ -73,6 +75,9 @@ public class ArrayFields {
System.err.print("TEST FAILED: ");
e.printStackTrace();
throw new Error();
+ } finally {
+ if (istream != null) istream.close();
+ if (ostream != null) ostream.close();
}
}
}
diff --git a/test/java/io/Serializable/oldTests/ArraysOfArrays.java b/test/java/io/Serializable/oldTests/ArraysOfArrays.java
index 934966936..ba5fc0dec 100644
--- a/test/java/io/Serializable/oldTests/ArraysOfArrays.java
+++ b/test/java/io/Serializable/oldTests/ArraysOfArrays.java
@@ -31,14 +31,15 @@
import java.io.*;
public class ArraysOfArrays {
- public static void main (String argv[]) {
+ public static void main (String argv[]) throws IOException {
System.err.println("\nRegression test for testing of " +
"serialization/deserialization of objects as " +
"arrays of arrays \n");
FileInputStream istream = null;
+ FileOutputStream ostream = null;
try {
- FileOutputStream ostream = new FileOutputStream("piotest5.tmp");
+ ostream = new FileOutputStream("piotest5.tmp");
ObjectOutputStream p = new ObjectOutputStream(ostream);
byte b[][] = {{ 0, 1}, {2,3}};
@@ -207,6 +208,9 @@ public class ArraysOfArrays {
throw new Error();
}
throw new Error();
+ } finally {
+ if (istream != null) istream.close();
+ if (ostream != null) ostream.close();
}
}
}
diff --git a/test/java/io/Serializable/oldTests/BinaryTree.java b/test/java/io/Serializable/oldTests/BinaryTree.java
index 81e8e1d78..b4d824fdf 100644
--- a/test/java/io/Serializable/oldTests/BinaryTree.java
+++ b/test/java/io/Serializable/oldTests/BinaryTree.java
@@ -37,28 +37,34 @@ public class BinaryTree {
"with BinaryTree types \n");
try {
- FileOutputStream ostream = new FileOutputStream("piotest3.tmp");
- ObjectOutputStream p = new ObjectOutputStream(ostream);
-
BinaryTreeTest base = new BinaryTreeTest(2);
- p.writeObject(null);
- p.writeObject(base);
- p.flush();
- ostream.close();
+ FileOutputStream ostream = new FileOutputStream("piotest3.tmp");
+ try {
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
+ p.writeObject(null);
+ p.writeObject(base);
+ p.flush();
+ } finally {
+ ostream.close();
+ }
FileInputStream istream = new FileInputStream("piotest3.tmp");
- ObjectInputStream q = new ObjectInputStream(istream);
-
- Object n = q.readObject();
- if (n != null) {
- System.err.println("\nnull read as " + n);
- }
- BinaryTreeTest nbase = (BinaryTreeTest)q.readObject();
- if (!base.equals(nbase)) {
- System.err.println("\nTEST FAILED: BinaryTree read " +
- "incorrectly.");
- throw new Error();
+ try {
+ ObjectInputStream q = new ObjectInputStream(istream);
+ Object n = q.readObject();
+ if (n != null) {
+ System.err.println("\nnull read as " + n);
+ }
+ BinaryTreeTest nbase = (BinaryTreeTest)q.readObject();
+ if (!base.equals(nbase)) {
+ System.err.println("\nTEST FAILED: BinaryTree read " +
+ "incorrectly.");
+ throw new Error();
+ }
+ } finally {
+ istream.close();
}
+
System.err.println("\nTEST PASSED");
} catch (Exception e) {
System.err.print("TEST FAILED: ");
diff --git a/test/java/io/Serializable/oldTests/CircularList.java b/test/java/io/Serializable/oldTests/CircularList.java
index 1a9723aae..bd5814e08 100644
--- a/test/java/io/Serializable/oldTests/CircularList.java
+++ b/test/java/io/Serializable/oldTests/CircularList.java
@@ -31,20 +31,22 @@
import java.io.*;
public class CircularList {
- public static void main (String argv[]) {
+ public static void main (String argv[]) throws IOException {
System.err.println("\nRegression test for testing of " +
"serialization/deserialization of " +
"objects with CirculalListType types \n");
+ FileInputStream istream = null;
+ FileOutputStream ostream = null;
try {
- FileOutputStream ostream = new FileOutputStream("piotest7.tmp");
+ ostream = new FileOutputStream("piotest7.tmp");
ObjectOutputStream p = new ObjectOutputStream(ostream);
CircularListTest.setup();
p.writeObject(CircularListTest.list);
p.flush();
- FileInputStream istream = new FileInputStream("piotest7.tmp");
+ istream = new FileInputStream("piotest7.tmp");
ObjectInputStream q = new ObjectInputStream(istream);
CircularListTest cv = (CircularListTest)q.readObject();
@@ -58,6 +60,9 @@ public class CircularList {
System.err.print("TEST FAILED: ");
e.printStackTrace();
throw new Error();
+ } finally {
+ if (istream != null) istream.close();
+ if (ostream != null) ostream.close();
}
}
}
diff --git a/test/java/io/Serializable/oldTests/SimpleArrays.java b/test/java/io/Serializable/oldTests/SimpleArrays.java
index c35b9b068..bbf4c8556 100644
--- a/test/java/io/Serializable/oldTests/SimpleArrays.java
+++ b/test/java/io/Serializable/oldTests/SimpleArrays.java
@@ -35,13 +35,14 @@ import java.io.*;
public class SimpleArrays {
- public static void main (String argv[]) {
+ public static void main (String argv[]) throws IOException {
System.err.println("\nRegression test for testing of " +
"serialization/deserialization of objects with Arrays types\n");
FileInputStream istream = null;
+ FileOutputStream ostream = null;
try {
- FileOutputStream ostream = new FileOutputStream("piotest2.tmp");
+ ostream = new FileOutputStream("piotest2.tmp");
ObjectOutputStream p = new ObjectOutputStream(ostream);
byte b[] = { 0, 1};
@@ -177,6 +178,9 @@ public class SimpleArrays {
throw new Error();
}
throw new Error();
+ } finally {
+ if (istream != null) istream.close();
+ if (ostream != null) ostream.close();
}
}
}
diff --git a/test/java/io/Serializable/oldTests/WritePrimitive.java b/test/java/io/Serializable/oldTests/WritePrimitive.java
index d955045a7..3976cd416 100644
--- a/test/java/io/Serializable/oldTests/WritePrimitive.java
+++ b/test/java/io/Serializable/oldTests/WritePrimitive.java
@@ -34,11 +34,12 @@
import java.io.*;
public class WritePrimitive {
- public static void main (String argv[]) {
+ public static void main (String argv[]) throws IOException {
System.err.println("\nRegression test for testing of " +
"serialization/deserialization of primitives \n");
FileInputStream istream = null;
+ FileOutputStream ostream = null;
try {
int i = 123456;
byte b = 12;
@@ -51,7 +52,7 @@ public class WritePrimitive {
String string = "The String";
PrimitivesTest prim = new PrimitivesTest();
- FileOutputStream ostream = new FileOutputStream("piotest1.tmp");
+ ostream = new FileOutputStream("piotest1.tmp");
ObjectOutputStream p = new ObjectOutputStream(ostream);
p.writeInt(i);
@@ -154,6 +155,9 @@ public class WritePrimitive {
throw new Error();
}
throw new Error();
+ } finally {
+ if (istream != null) istream.close();
+ if (ostream != null) ostream.close();
}
}
}
diff --git a/test/java/io/Serializable/packageAccess/Test.java b/test/java/io/Serializable/packageAccess/Test.java
index 180461180..15d2e4ce0 100644
--- a/test/java/io/Serializable/packageAccess/Test.java
+++ b/test/java/io/Serializable/packageAccess/Test.java
@@ -38,7 +38,8 @@ public class Test {
public static void main(String[] args) throws Exception {
ClassLoader ldr =
- new URLClassLoader(new URL[]{ new URL("file:foo.jar") });
+ new URLClassLoader(new URL[]{ new URL("file:foo.jar") },
+ Test.class.getClassLoader());
bcl = Class.forName("B", true, ldr);
dcl = Class.forName("D", true, ldr);
diff --git a/test/java/io/Serializable/parents/EvolvedClass.java b/test/java/io/Serializable/parents/EvolvedClass.java
index db8b11d1c..edb8dee81 100644
--- a/test/java/io/Serializable/parents/EvolvedClass.java
+++ b/test/java/io/Serializable/parents/EvolvedClass.java
@@ -34,8 +34,12 @@ public class EvolvedClass {
// Deserialize in to new class object
FileInputStream fi = new FileInputStream("parents.ser");
- ObjectInputStream si = new ObjectInputStream(fi);
- cnew = (ASubClass) si.readObject();
+ try {
+ ObjectInputStream si = new ObjectInputStream(fi);
+ cnew = (ASubClass) si.readObject();
+ } finally {
+ fi.close();
+ }
System.out.println("Printing the deserialized class: ");
System.out.println();
diff --git a/test/java/io/Serializable/parents/OriginalClass.java b/test/java/io/Serializable/parents/OriginalClass.java
index c83b76e22..2f21c494d 100644
--- a/test/java/io/Serializable/parents/OriginalClass.java
+++ b/test/java/io/Serializable/parents/OriginalClass.java
@@ -43,9 +43,13 @@ public class OriginalClass {
// Serialize the subclass
FileOutputStream fo = new FileOutputStream("parents.ser");
- ObjectOutputStream so = new ObjectOutputStream(fo);
- so.writeObject(corg);
- so.flush();
+ try {
+ ObjectOutputStream so = new ObjectOutputStream(fo);
+ so.writeObject(corg);
+ so.flush();
+ } finally {
+ fo.close();
+ }
System.out.println("Printing the serialized class: ");
System.out.println();
diff --git a/test/java/io/Serializable/proxy/Basic.java b/test/java/io/Serializable/proxy/Basic.java
index a9152fd78..92c989b2b 100644
--- a/test/java/io/Serializable/proxy/Basic.java
+++ b/test/java/io/Serializable/proxy/Basic.java
@@ -81,7 +81,7 @@ class ProxyBlindInputStream extends ObjectInputStream {
public class Basic {
public static void main(String[] args) throws Exception {
- ClassLoader loader = ClassLoader.getSystemClassLoader();
+ ClassLoader loader = Basic.class.getClassLoader();
Class[] interfaces = new Class[] { Foo.class, Bar.class };
Random rand = new Random();
int foo = rand.nextInt();
diff --git a/test/java/io/Serializable/proxy/skipMissing/Read.java b/test/java/io/Serializable/proxy/skipMissing/Read.java
index 2a7ede9cf..511bb42d7 100644
--- a/test/java/io/Serializable/proxy/skipMissing/Read.java
+++ b/test/java/io/Serializable/proxy/skipMissing/Read.java
@@ -49,20 +49,24 @@ class B implements Serializable {
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin = new ObjectInputStream(
- new FileInputStream("tmp.ser"));
- A a = (A) oin.readObject();
- if (! (a.a.equals("a") && a.z.equals("z"))) {
- throw new Error("A fields corrupted");
- }
- B b = (B) oin.readObject();
- if (! b.s.equals("s")) {
- throw new Error("B fields corrupted");
- }
+ FileInputStream in = new FileInputStream("tmp.ser");
try {
- oin.readObject();
- throw new Error("proxy read should not succeed");
- } catch (ClassNotFoundException ex) {
+ ObjectInputStream oin = new ObjectInputStream(in);
+ A a = (A) oin.readObject();
+ if (! (a.a.equals("a") && a.z.equals("z"))) {
+ throw new Error("A fields corrupted");
+ }
+ B b = (B) oin.readObject();
+ if (! b.s.equals("s")) {
+ throw new Error("B fields corrupted");
+ }
+ try {
+ oin.readObject();
+ throw new Error("proxy read should not succeed");
+ } catch (ClassNotFoundException ex) {
+ }
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/proxy/skipMissing/Write.java b/test/java/io/Serializable/proxy/skipMissing/Write.java
index df1d5ca3a..c4b06f2be 100644
--- a/test/java/io/Serializable/proxy/skipMissing/Write.java
+++ b/test/java/io/Serializable/proxy/skipMissing/Write.java
@@ -64,7 +64,7 @@ class B implements Serializable {
public class Write {
public static void main(String[] args) throws Exception {
Object proxy = Proxy.newProxyInstance(
- ClassLoader.getSystemClassLoader(),
+ Write.class.getClassLoader(),
new Class[] { I.class }, new Handler());
ObjectOutputStream oout = new ObjectOutputStream(
new FileOutputStream("tmp.ser"));
diff --git a/test/java/io/Serializable/readObjectNoData/Read.java b/test/java/io/Serializable/readObjectNoData/Read.java
index ccd485f1b..e786c6cc4 100644
--- a/test/java/io/Serializable/readObjectNoData/Read.java
+++ b/test/java/io/Serializable/readObjectNoData/Read.java
@@ -95,14 +95,18 @@ class F extends E {
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("tmp.ser"));
- F f = (F) oin.readObject();
- if (f.aCalled || f.bCalled || f.dCalled || f.eCalled) {
- throw new Error("readObjectNoData invoked erroneously");
- }
- if (! f.cCalled) {
- throw new Error("readObjectNoData not invoked");
+ FileInputStream in = new FileInputStream("tmp.ser");
+ try {
+ ObjectInputStream oin = new ObjectInputStream(in);
+ F f = (F) oin.readObject();
+ if (f.aCalled || f.bCalled || f.dCalled || f.eCalled) {
+ throw new Error("readObjectNoData invoked erroneously");
+ }
+ if (! f.cCalled) {
+ throw new Error("readObjectNoData not invoked");
+ }
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/skipWriteObject/Read.java b/test/java/io/Serializable/skipWriteObject/Read.java
index d8873eb40..e1fcfe79f 100644
--- a/test/java/io/Serializable/skipWriteObject/Read.java
+++ b/test/java/io/Serializable/skipWriteObject/Read.java
@@ -38,9 +38,13 @@ public class Read {
public static void main(String[] args) throws Exception {
ObjectInputStream oin =
new ObjectInputStream(new FileInputStream("tmp.ser"));
- Object[] array = (Object[]) oin.readObject();
- if (! (array[0].equals("before") && array[2].equals("after"))) {
- throw new Error();
+ try {
+ Object[] array = (Object[]) oin.readObject();
+ if (! (array[0].equals("before") && array[2].equals("after"))) {
+ throw new Error();
+ }
+ } finally {
+ oin.close();
}
}
}
diff --git a/test/java/io/Serializable/skippedObjCNFException/Read.java b/test/java/io/Serializable/skippedObjCNFException/Read.java
index 9effc2426..b50265099 100644
--- a/test/java/io/Serializable/skippedObjCNFException/Read.java
+++ b/test/java/io/Serializable/skippedObjCNFException/Read.java
@@ -44,8 +44,12 @@ class B implements Serializable {
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("tmp.ser"));
- oin.readObject();
+ FileInputStream in = new FileInputStream("tmp.ser");
+ try {
+ ObjectInputStream oin = new ObjectInputStream(in);
+ oin.readObject();
+ } finally {
+ in.close();
+ }
}
}
diff --git a/test/java/io/Serializable/stopCustomDeserialization/Read.java b/test/java/io/Serializable/stopCustomDeserialization/Read.java
index c77a0cba2..156fa50b8 100644
--- a/test/java/io/Serializable/stopCustomDeserialization/Read.java
+++ b/test/java/io/Serializable/stopCustomDeserialization/Read.java
@@ -53,16 +53,20 @@ class C extends B {
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("tmp.ser"));
+ FileInputStream in = new FileInputStream("tmp.ser");
try {
- oin.readObject();
- throw new Error("readObject should not succeed");
- } catch (ClassNotFoundException e) {
- // expected
- }
- if (!oin.readObject().equals("after")) {
- throw new Error("subsequent object corrupted");
+ ObjectInputStream oin = new ObjectInputStream(in);
+ try {
+ oin.readObject();
+ throw new Error("readObject should not succeed");
+ } catch (ClassNotFoundException e) {
+ // expected
+ }
+ if (!oin.readObject().equals("after")) {
+ throw new Error("subsequent object corrupted");
+ }
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/unresolvedClassDesc/Read.java b/test/java/io/Serializable/unresolvedClassDesc/Read.java
index 78a35453f..c3fc28bde 100644
--- a/test/java/io/Serializable/unresolvedClassDesc/Read.java
+++ b/test/java/io/Serializable/unresolvedClassDesc/Read.java
@@ -32,19 +32,23 @@ import java.io.*;
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("tmp.ser"));
- oin.readObject();
- oin.readObject();
+ FileInputStream in = new FileInputStream("tmp.ser");
try {
+ ObjectInputStream oin = new ObjectInputStream(in);
oin.readObject();
- throw new Error("read of Foo instance succeeded");
- } catch (ClassNotFoundException ex) {
- }
- try {
oin.readObject();
- throw new Error("indirect read of Foo instance succeeded");
- } catch (ClassNotFoundException ex) {
+ try {
+ oin.readObject();
+ throw new Error("read of Foo instance succeeded");
+ } catch (ClassNotFoundException ex) {
+ }
+ try {
+ oin.readObject();
+ throw new Error("indirect read of Foo instance succeeded");
+ } catch (ClassNotFoundException ex) {
+ }
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/unshared/Read.java b/test/java/io/Serializable/unshared/Read.java
index c92d07ebf..7d7c9d49b 100644
--- a/test/java/io/Serializable/unshared/Read.java
+++ b/test/java/io/Serializable/unshared/Read.java
@@ -80,20 +80,30 @@ public class Read {
}
// read in objects written by Write.main()
- oin = new ObjectInputStream(new FileInputStream("tmp.ser"));
- oin.readObject();
+ FileInputStream in = new FileInputStream("tmp.ser");
try {
+ oin = new ObjectInputStream(in);
oin.readObject();
- throw new Error();
- } catch (ObjectStreamException ex) {
+ try {
+ oin.readObject();
+ throw new Error();
+ } catch (ObjectStreamException ex) {
+ }
+ } finally {
+ in.close();
}
- oin = new ObjectInputStream(new FileInputStream("tmp.ser"));
- oin.readObject();
+ in = new FileInputStream("tmp.ser");
try {
- oin.readUnshared();
- throw new Error();
- } catch (ObjectStreamException ex) {
+ oin = new ObjectInputStream(in);
+ oin.readObject();
+ try {
+ oin.readUnshared();
+ throw new Error();
+ } catch (ObjectStreamException ex) {
+ }
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/Serializable/wrongReturnTypes/Read.java b/test/java/io/Serializable/wrongReturnTypes/Read.java
index b5ef5e086..a41599f1e 100644
--- a/test/java/io/Serializable/wrongReturnTypes/Read.java
+++ b/test/java/io/Serializable/wrongReturnTypes/Read.java
@@ -62,15 +62,19 @@ class B extends A {
public class Read {
public static void main(String[] args) throws Exception {
- ObjectInputStream oin =
- new ObjectInputStream(new FileInputStream("tmp.ser"));
- B b = (B) oin.readObject();
- if (A.readObjectNoDataCalled) {
- throw new Error("readObjectNoData with wrong return type called");
- } else if (B.readObjectCalled) {
- throw new Error("readObject with wrong return type called");
- } else if (B.readResolveCalled) {
- throw new Error("readResolve with wrong return type called");
+ FileInputStream in = new FileInputStream("tmp.ser");
+ try {
+ ObjectInputStream oin = new ObjectInputStream(in);
+ B b = (B) oin.readObject();
+ if (A.readObjectNoDataCalled) {
+ throw new Error("readObjectNoData with wrong return type called");
+ } else if (B.readObjectCalled) {
+ throw new Error("readObject with wrong return type called");
+ } else if (B.readResolveCalled) {
+ throw new Error("readResolve with wrong return type called");
+ }
+ } finally {
+ in.close();
}
}
}
diff --git a/test/java/io/StreamTokenizer/Comment.java b/test/java/io/StreamTokenizer/Comment.java
index 056362629..f1192fe62 100644
--- a/test/java/io/StreamTokenizer/Comment.java
+++ b/test/java/io/StreamTokenizer/Comment.java
@@ -41,40 +41,45 @@ public class Comment {
int slashStarComment = 4;
for (int i = 0; i < 8 ; i++) {
- StreamTokenizer st = new StreamTokenizer(new FileReader(f));
+ FileReader reader = new FileReader(f);
+ try {
+ StreamTokenizer st = new StreamTokenizer(reader);
- /* decide the state of this run */
- boolean slashCommentFlag = ((i & slashIsCommentStart) != 0);
- boolean slashSlashCommentFlag = ((i & slashSlashComment) != 0);
- boolean slashStarCommentFlag = ((i & slashStarComment) != 0);
+ /* decide the state of this run */
+ boolean slashCommentFlag = ((i & slashIsCommentStart) != 0);
+ boolean slashSlashCommentFlag = ((i & slashSlashComment) != 0);
+ boolean slashStarCommentFlag = ((i & slashStarComment) != 0);
- /* set the initial state of the tokenizer */
- if (!slashCommentFlag) {
- st.ordinaryChar('/');
- }
- st.slashSlashComments(slashSlashCommentFlag);
- st.slashStarComments(slashStarCommentFlag);
+ /* set the initial state of the tokenizer */
+ if (!slashCommentFlag) {
+ st.ordinaryChar('/');
+ }
+ st.slashSlashComments(slashSlashCommentFlag);
+ st.slashStarComments(slashStarCommentFlag);
- /* now go throgh the input file */
- while(st.nextToken() != StreamTokenizer.TT_EOF)
- {
- String token = st.sval;
- if (token == null) {
- continue;
- } else {
- if ((token.compareTo("Error1") == 0) && slashStarCommentFlag) {
- throw new Exception("Failed to pass one line C comments!");
- }
- if ((token.compareTo("Error2") == 0) && slashStarCommentFlag) {
- throw new Exception("Failed to pass multi line C comments!");
- }
- if ((token.compareTo("Error3") == 0) && slashSlashCommentFlag) {
- throw new Exception("Failed to pass C++ comments!");
- }
- if ((token.compareTo("Error4") == 0) && slashCommentFlag) {
- throw new Exception("Failed to pass / comments!");
+ /* now go throgh the input file */
+ while(st.nextToken() != StreamTokenizer.TT_EOF)
+ {
+ String token = st.sval;
+ if (token == null) {
+ continue;
+ } else {
+ if ((token.compareTo("Error1") == 0) && slashStarCommentFlag) {
+ throw new Exception("Failed to pass one line C comments!");
+ }
+ if ((token.compareTo("Error2") == 0) && slashStarCommentFlag) {
+ throw new Exception("Failed to pass multi line C comments!");
+ }
+ if ((token.compareTo("Error3") == 0) && slashSlashCommentFlag) {
+ throw new Exception("Failed to pass C++ comments!");
+ }
+ if ((token.compareTo("Error4") == 0) && slashCommentFlag) {
+ throw new Exception("Failed to pass / comments!");
+ }
}
}
+ } finally {
+ reader.close();
}
}
}
diff --git a/test/java/io/readBytes/ReadBytesBounds.java b/test/java/io/readBytes/ReadBytesBounds.java
index 4f69e68ba..eef870b74 100644
--- a/test/java/io/readBytes/ReadBytesBounds.java
+++ b/test/java/io/readBytes/ReadBytesBounds.java
@@ -57,24 +57,28 @@ public class ReadBytesBounds {
}
public static void main(String argv[]) throws Throwable {
- byte b[] = new byte[32];
- testRead(-1, -1, false);
- testRead(-1, 0, false);
- testRead( 0, -1, false);
- testRead( 0, 33, false);
- testRead(33, 0, false);
- testRead(33, 4, false);
- testRead( 0, 32, true);
- testRead(32, 0, true);
- testRead(32, 4, false);
- testRead( 4, 16, true);
- testRead( 1, 31, true);
- testRead( 0, 0, true);
- testRead(31, Integer.MAX_VALUE, false);
- testRead( 0, Integer.MAX_VALUE, false);
- testRead(-1, Integer.MAX_VALUE, false);
- testRead(-4, Integer.MIN_VALUE, false);
- testRead( 0, Integer.MIN_VALUE, false);
+ try {
+ testRead(-1, -1, false);
+ testRead(-1, 0, false);
+ testRead( 0, -1, false);
+ testRead( 0, 33, false);
+ testRead(33, 0, false);
+ testRead(33, 4, false);
+ testRead( 0, 32, true);
+ testRead(32, 0, true);
+ testRead(32, 4, false);
+ testRead( 4, 16, true);
+ testRead( 1, 31, true);
+ testRead( 0, 0, true);
+ testRead(31, Integer.MAX_VALUE, false);
+ testRead( 0, Integer.MAX_VALUE, false);
+ testRead(-1, Integer.MAX_VALUE, false);
+ testRead(-4, Integer.MIN_VALUE, false);
+ testRead( 0, Integer.MIN_VALUE, false);
+ } finally {
+ fis.close();
+ raf.close();
+ }
}
static void testRead(int off, int len, boolean expected) throws Throwable {
diff --git a/test/java/lang/ClassLoader/UninitializedParent.java b/test/java/lang/ClassLoader/UninitializedParent.java
index 9b751f664..9d4459d01 100644
--- a/test/java/lang/ClassLoader/UninitializedParent.java
+++ b/test/java/lang/ClassLoader/UninitializedParent.java
@@ -26,6 +26,7 @@
* @bug 6636650
* @summary Uninitialized class loaders should not be a parent of other
* class loaders.
+ * @run main/othervm UninitializedParent
*/
diff --git a/test/java/lang/ClassLoader/defineClass/DefineClassByteBuffer.java b/test/java/lang/ClassLoader/defineClass/DefineClassByteBuffer.java
index 0d4bf80e4..e1f79f737 100644
--- a/test/java/lang/ClassLoader/defineClass/DefineClassByteBuffer.java
+++ b/test/java/lang/ClassLoader/defineClass/DefineClassByteBuffer.java
@@ -38,14 +38,17 @@ import java.io.*;
public class DefineClassByteBuffer {
static void test(ClassLoader cl) throws Exception {
- Class c = Class.forName("TestClass", true, cl);
+ Class<?> c = Class.forName("TestClass", true, cl);
if (!"TestClass".equals(c.getName())) {
throw new RuntimeException("Got wrong class: " + c);
}
+ if (c.getClassLoader() != cl) {
+ throw new RuntimeException("TestClass defined by wrong classloader: " + c.getClassLoader());
+ }
}
public static void main(String arg[]) throws Exception {
- ClassLoader[] cls = new ClassLoader[DummyClassLoader.MAX_TYPE];
+ DummyClassLoader[] cls = new DummyClassLoader[DummyClassLoader.MAX_TYPE];
for (int i = 0; i < cls.length; i++) {
cls[i] = new DummyClassLoader(i);
}
@@ -53,7 +56,7 @@ public class DefineClassByteBuffer {
/* Create several instances of the class using different classloaders,
which are using different types of ByteBuffer. */
for (int i = 0; i < cls.length; i++) {
- test(cls[i]);
+ test(cls[i]);
}
}
@@ -100,12 +103,13 @@ public class DefineClassByteBuffer {
buffers. */
buffers[MAPPED_BUFFER] = readClassFile(CLASS_NAME + ".class");
byte[] array = new byte[buffers[MAPPED_BUFFER].limit()];
+ buffers[MAPPED_BUFFER].get(array).flip();
buffers[DIRECT_BUFFER] = ByteBuffer.allocateDirect(array.length);
- buffers[DIRECT_BUFFER].put(array);
+ buffers[DIRECT_BUFFER].put(array).flip();
buffers[ARRAY_BUFFER] = ByteBuffer.allocate(array.length);
- buffers[ARRAY_BUFFER].put(array);
+ buffers[ARRAY_BUFFER].put(array).flip();
buffers[WRAPPED_BUFFER] = ByteBuffer.wrap(array);
@@ -118,9 +122,30 @@ public class DefineClassByteBuffer {
buffers[DUP_DIRECT_BUFFER] = buffers[DIRECT_BUFFER].duplicate();
}
- public Class findClass(String name) {
- return defineClass(name, buffers[loaderType], null);
- }
+ protected Class<?> loadClass(String name, boolean resolve)
+ throws ClassNotFoundException
+ {
+ Class<?> c;
+ if (!"TestClass".equals(name)) {
+ c = super.loadClass(name, resolve);
+ } else {
+ // should not delegate to the system class loader
+ c = findClass(name);
+ if (resolve) {
+ resolveClass(c);
+ }
+ }
+ return c;
+ }
+
+ protected Class<?> findClass(String name)
+ throws ClassNotFoundException
+ {
+ if (!"TestClass".equals(name)) {
+ throw new ClassNotFoundException("Unexpected class: " + name);
+ }
+ return defineClass(name, buffers[loaderType], null);
+ }
} /* DummyClassLoader */
} /* DefineClassByteBuffer */
diff --git a/test/java/lang/ClassLoader/findSystemClass/Loader.java b/test/java/lang/ClassLoader/findSystemClass/Loader.java
index 34061485b..60f1b7972 100644
--- a/test/java/lang/ClassLoader/findSystemClass/Loader.java
+++ b/test/java/lang/ClassLoader/findSystemClass/Loader.java
@@ -21,10 +21,16 @@
* questions.
*/
+/*
+ * This test runs in othervm mode as it tests ClassLoader.findSystemClass
+ * and getSystemResource methods.
+ */
+
/* @test
@bug 4147599 4478150
@summary In 1.2beta4-I ClassLoader loaded classes can not link
against application classes.
+ @run main/othervm Loader
*/
/*
diff --git a/test/java/lang/ProcessBuilder/Basic.java b/test/java/lang/ProcessBuilder/Basic.java
index e14f665a6..f4e3c26d9 100644
--- a/test/java/lang/ProcessBuilder/Basic.java
+++ b/test/java/lang/ProcessBuilder/Basic.java
@@ -37,6 +37,7 @@ import static java.lang.ProcessBuilder.Redirect.*;
import java.io.*;
import java.util.*;
+import java.util.concurrent.CountDownLatch;
import java.security.*;
import java.util.regex.Pattern;
import static java.lang.System.getenv;
@@ -252,9 +253,9 @@ public class Basic {
return sb.toString();
}
- static void print4095(OutputStream s) throws Throwable {
+ static void print4095(OutputStream s, byte b) throws Throwable {
byte[] bytes = new byte[4095];
- Arrays.fill(bytes, (byte) '!');
+ Arrays.fill(bytes, b);
s.write(bytes); // Might hang!
}
@@ -273,7 +274,9 @@ public class Basic {
public static class JavaChild {
public static void main(String args[]) throws Throwable {
String action = args[0];
- if (action.equals("testIO")) {
+ if (action.equals("sleep")) {
+ Thread.sleep(10 * 60 * 1000L);
+ } else if (action.equals("testIO")) {
String expected = "standard input";
char[] buf = new char[expected.length()+1];
int n = new InputStreamReader(System.in).read(buf,0,buf.length);
@@ -315,7 +318,8 @@ public class Basic {
printUTF8(new File(System.getProperty("user.dir"))
.getCanonicalPath());
} else if (action.equals("print4095")) {
- print4095(System.out);
+ print4095(System.out, (byte) '!');
+ print4095(System.err, (byte) 'E');
System.exit(5);
} else if (action.equals("OutErr")) {
// You might think the system streams would be
@@ -1717,16 +1721,107 @@ public class Basic {
} catch (Throwable t) { unexpected(t); }
//----------------------------------------------------------------
- // This would deadlock, if not for the fact that
+ // Attempt to write 4095 bytes to the pipe buffer without a
+ // reader to drain it would deadlock, if not for the fact that
// interprocess pipe buffers are at least 4096 bytes.
+ //
+ // Also, check that available reports all the bytes expected
+ // in the pipe buffer, and that I/O operations do the expected
+ // things.
//----------------------------------------------------------------
try {
List<String> childArgs = new ArrayList<String>(javaChildArgs);
childArgs.add("print4095");
- Process p = new ProcessBuilder(childArgs).start();
- print4095(p.getOutputStream()); // Might hang!
- p.waitFor(); // Might hang!
+ final int SIZE = 4095;
+ final Process p = new ProcessBuilder(childArgs).start();
+ print4095(p.getOutputStream(), (byte) '!'); // Might hang!
+ p.waitFor(); // Might hang!
+ equal(SIZE, p.getInputStream().available());
+ equal(SIZE, p.getErrorStream().available());
+ THROWS(IOException.class,
+ new Fun(){void f() throws IOException {
+ p.getOutputStream().write((byte) '!');
+ p.getOutputStream().flush();
+ }});
+
+ final byte[] bytes = new byte[SIZE + 1];
+ equal(SIZE, p.getInputStream().read(bytes));
+ for (int i = 0; i < SIZE; i++)
+ equal((byte) '!', bytes[i]);
+ equal((byte) 0, bytes[SIZE]);
+
+ equal(SIZE, p.getErrorStream().read(bytes));
+ for (int i = 0; i < SIZE; i++)
+ equal((byte) 'E', bytes[i]);
+ equal((byte) 0, bytes[SIZE]);
+
+ equal(0, p.getInputStream().available());
+ equal(0, p.getErrorStream().available());
+ equal(-1, p.getErrorStream().read());
+ equal(-1, p.getInputStream().read());
+
equal(p.exitValue(), 5);
+
+ p.getInputStream().close();
+ p.getErrorStream().close();
+ p.getOutputStream().close();
+
+ InputStream[] streams = { p.getInputStream(), p.getErrorStream() };
+ for (final InputStream in : streams) {
+ Fun[] ops = {
+ new Fun(){void f() throws IOException {
+ in.read(); }},
+ new Fun(){void f() throws IOException {
+ in.read(bytes); }},
+ new Fun(){void f() throws IOException {
+ in.available(); }}
+ };
+ for (Fun op : ops) {
+ try {
+ op.f();
+ fail();
+ } catch (IOException expected) {
+ check(expected.getMessage()
+ .matches("[Ss]tream [Cc]losed"));
+ }
+ }
+ }
+ } catch (Throwable t) { unexpected(t); }
+
+ //----------------------------------------------------------------
+ // Check that reads which are pending when Process.destroy is
+ // called, get EOF, not IOException("Stream closed").
+ //----------------------------------------------------------------
+ try {
+ final int cases = 4;
+ for (int i = 0; i < cases; i++) {
+ final int action = i;
+ List<String> childArgs = new ArrayList<String>(javaChildArgs);
+ childArgs.add("sleep");
+ final byte[] bytes = new byte[10];
+ final Process p = new ProcessBuilder(childArgs).start();
+ final CountDownLatch latch = new CountDownLatch(1);
+ final Thread thread = new Thread() {
+ public void run() {
+ try {
+ latch.countDown();
+ int r;
+ switch (action) {
+ case 0: r = p.getInputStream().read(); break;
+ case 1: r = p.getErrorStream().read(); break;
+ case 2: r = p.getInputStream().read(bytes); break;
+ case 3: r = p.getErrorStream().read(bytes); break;
+ default: throw new Error();
+ }
+ equal(-1, r);
+ } catch (Throwable t) { unexpected(t); }}};
+
+ thread.start();
+ latch.await();
+ Thread.sleep(10);
+ p.destroy();
+ thread.join();
+ }
} catch (Throwable t) { unexpected(t); }
//----------------------------------------------------------------
@@ -1741,7 +1836,6 @@ public class Basic {
} catch (IOException e) {
new File("./emptyCommand").delete();
String m = e.getMessage();
- //e.printStackTrace();
if (EnglishUnix.is() &&
! matches(m, "Permission denied"))
unexpected(e);
diff --git a/test/java/lang/System/ExitFinalizersAndJIT.java b/test/java/lang/System/ExitFinalizersAndJIT.java
index bc98b12b2..4fe5078e5 100644
--- a/test/java/lang/System/ExitFinalizersAndJIT.java
+++ b/test/java/lang/System/ExitFinalizersAndJIT.java
@@ -26,6 +26,7 @@
@summary runFinalizersOnExit(true) causes JIT to be unloaded and
crashes the VM. Interim fix for 1.2 beta4 -- don't unload
native libraries loaded by system classes.
+ @run main/othervm ExitFinalizersAndJIT
*/
public class ExitFinalizersAndJIT {
diff --git a/test/java/lang/System/IgnoreNullSecurityManager.java b/test/java/lang/System/IgnoreNullSecurityManager.java
index 555238a27..03a2c0cc3 100644
--- a/test/java/lang/System/IgnoreNullSecurityManager.java
+++ b/test/java/lang/System/IgnoreNullSecurityManager.java
@@ -26,6 +26,7 @@
* @bug 4213876
* @summary Make sure "null" security manager is ignored, as specified in the
* javadocs
+ * @run main/othervm IgnoreNullSecurityManager
*/
public class IgnoreNullSecurityManager {
diff --git a/test/java/lang/Thread/GenerifyStackTraces.java b/test/java/lang/Thread/GenerifyStackTraces.java
index 416726546..98de45073 100644
--- a/test/java/lang/Thread/GenerifyStackTraces.java
+++ b/test/java/lang/Thread/GenerifyStackTraces.java
@@ -155,7 +155,7 @@ public class GenerifyStackTraces {
printStack(t, stack);
}
int frame = stack.length - 1;
- for (int i = 0; i < depth; i++) {
+ for (int i = 0; i < depth && frame >= 0; i++) {
if (! stack[frame].getMethodName().equals(methodNames[i])) {
throw new RuntimeException("Expected " + methodNames[i] +
" in frame " + frame + " but got " +
diff --git a/test/java/lang/Thread/StackTraces.java b/test/java/lang/Thread/StackTraces.java
index b5f3d0547..141c81a4a 100644
--- a/test/java/lang/Thread/StackTraces.java
+++ b/test/java/lang/Thread/StackTraces.java
@@ -159,7 +159,7 @@ public class StackTraces {
printStack(t, stack);
}
int frame = stack.length - 1;
- for (int i = 0; i < depth; i++) {
+ for (int i = 0; i < depth && frame >= 0; i++) {
if (! stack[frame].getMethodName().equals(methodNames[i])) {
throw new RuntimeException("Expected " + methodNames[i] +
" in frame " + frame + " but got " +
diff --git a/test/java/lang/annotation/ParameterAnnotations.java b/test/java/lang/annotation/ParameterAnnotations.java
index ec36608e6..7c98241f3 100644
--- a/test/java/lang/annotation/ParameterAnnotations.java
+++ b/test/java/lang/annotation/ParameterAnnotations.java
@@ -27,6 +27,7 @@
* @summary Check properties of Annotations returned from
* getParameterAnnotations, including freedom from security
* exceptions.
+ * @run main/othervm ParameterAnnotations
* @author Martin Buchholz
*/
diff --git a/test/java/lang/management/ClassLoadingMXBean/LoadCounts.java b/test/java/lang/management/ClassLoadingMXBean/LoadCounts.java
index 2eac76347..d2daf80b4 100644
--- a/test/java/lang/management/ClassLoadingMXBean/LoadCounts.java
+++ b/test/java/lang/management/ClassLoadingMXBean/LoadCounts.java
@@ -118,9 +118,21 @@ class Chain {
}
class Slave {}
-class LeftHand extends ClassLoader {}
-class RightHand extends ClassLoader {}
+class LeftHand extends ClassLoader {
+ public LeftHand() {
+ super(LeftHand.class.getClassLoader());
+ }
+}
+class RightHand extends ClassLoader {
+ public RightHand() {
+ super(RightHand.class.getClassLoader());
+ }
+}
class Body {}
-class LoaderForTwoInstances extends ClassLoader {}
+class LoaderForTwoInstances extends ClassLoader {
+ public LoaderForTwoInstances() {
+ super(LoaderForTwoInstances.class.getClassLoader());
+ }
+}
class TheSameClass {}
diff --git a/test/java/lang/management/ManagementFactory/MXBeanProxyTest.java b/test/java/lang/management/ManagementFactory/MXBeanProxyTest.java
index efcd0e935..545d7248d 100644
--- a/test/java/lang/management/ManagementFactory/MXBeanProxyTest.java
+++ b/test/java/lang/management/ManagementFactory/MXBeanProxyTest.java
@@ -25,6 +25,7 @@
* @test
* @bug 5024531
* @summary Basic Test for ManagementFactory.newPlatformMXBean().
+ * @run main/othervm MXBeanProxyTest
* @author Mandy Chung
*/
import javax.management.*;
diff --git a/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java b/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java
index f81f40b40..b7a04e030 100644
--- a/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java
+++ b/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java
@@ -41,9 +41,9 @@ import javax.management.openmbean.CompositeData;
public class CollectionUsageThreshold {
private static MemoryMXBean mm = ManagementFactory.getMemoryMXBean();
- private static List pools = ManagementFactory.getMemoryPoolMXBeans();
- private static List managers = ManagementFactory.getMemoryManagerMXBeans();
- private static Map result = new HashMap();
+ private static List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
+ private static List<MemoryManagerMXBean> managers = ManagementFactory.getMemoryManagerMXBeans();
+ private static Map<String, PoolRecord> result = new HashMap<>();
private static boolean trace = false;
private static boolean testFailed = false;
private static final int EXPECTED_NUM_POOLS = 2;
@@ -119,8 +119,7 @@ public class CollectionUsageThreshold {
}
// Find the Old generation which supports low memory detection
- for (ListIterator iter = pools.listIterator(); iter.hasNext(); ) {
- MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next();
+ for (MemoryPoolMXBean p : pools) {
MemoryUsage u = p.getUsage();
if (p.isUsageThresholdSupported() && p.isCollectionUsageThresholdSupported()) {
PoolRecord pr = new PoolRecord(p);
@@ -134,25 +133,30 @@ public class CollectionUsageThreshold {
throw new RuntimeException("Unexpected number of selected pools");
}
- checker = new Checker("Checker thread");
- checker.setDaemon(true);
- checker.start();
+ try {
+ checker = new Checker("Checker thread");
+ checker.setDaemon(true);
+ checker.start();
- for (Iterator iter = result.values().iterator(); iter.hasNext();) {
- PoolRecord pr = (PoolRecord) iter.next();
- pr.getPool().setCollectionUsageThreshold(THRESHOLD);
- System.out.println("Collection usage threshold of " +
- pr.getPool().getName() + " set to " + THRESHOLD);
- }
+ for (PoolRecord pr : result.values()) {
+ pr.getPool().setCollectionUsageThreshold(THRESHOLD);
+ System.out.println("Collection usage threshold of " +
+ pr.getPool().getName() + " set to " + THRESHOLD);
+ }
- SensorListener listener = new SensorListener();
- NotificationEmitter emitter = (NotificationEmitter) mm;
- emitter.addNotificationListener(listener, null, null);
+ SensorListener listener = new SensorListener();
+ NotificationEmitter emitter = (NotificationEmitter) mm;
+ emitter.addNotificationListener(listener, null, null);
- mm.setVerbose(true);
- for (int i = 0; i < NUM_GCS; i++) {
- invokeGC();
- checker.waitForCheckResult();
+ for (int i = 0; i < NUM_GCS; i++) {
+ invokeGC();
+ checker.waitForCheckResult();
+ }
+ } finally {
+ // restore the default
+ for (PoolRecord pr : result.values()) {
+ pr.getPool().setCollectionUsageThreshold(0);
+ }
}
if (testFailed)
@@ -168,8 +172,7 @@ public class CollectionUsageThreshold {
mm.gc();
if (trace) {
- for (Iterator iter = result.values().iterator(); iter.hasNext();) {
- PoolRecord pr = (PoolRecord) iter.next();
+ for (PoolRecord pr : result.values()) {
System.out.println("Usage after GC for: " + pr.getPool().getName());
MemoryUtil.printMemoryUsage(pr.getPool().getUsage());
}
@@ -200,8 +203,7 @@ public class CollectionUsageThreshold {
}
}
private void checkResult() {
- for (Iterator iter = result.values().iterator(); iter.hasNext();) {
- PoolRecord pr = (PoolRecord) iter.next();
+ for (PoolRecord pr : result.values()) {
if (pr.getListenerInvokedCount() != numGCs) {
throw new RuntimeException("Listeners invoked count = " +
pr.getListenerInvokedCount() + " expected to be " +
diff --git a/test/java/lang/management/MemoryMXBean/LowMemoryTest.java b/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
index f029ca23f..00d8b4d75 100644
--- a/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
+++ b/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
@@ -31,7 +31,7 @@
* @author Mandy Chung
*
* @build LowMemoryTest MemoryUtil
- * @run main/timeout=600 LowMemoryTest
+ * @run main/othervm/timeout=600 LowMemoryTest
*/
import java.lang.management.*;
diff --git a/test/java/lang/management/MemoryMXBean/MemoryManagement.java b/test/java/lang/management/MemoryMXBean/MemoryManagement.java
index 9edabf10a..f6b3b1638 100644
--- a/test/java/lang/management/MemoryMXBean/MemoryManagement.java
+++ b/test/java/lang/management/MemoryMXBean/MemoryManagement.java
@@ -31,7 +31,7 @@
* @author Mandy Chung
*
* @build MemoryManagement MemoryUtil
- * @run main/timeout=600 MemoryManagement
+ * @run main/othervm/timeout=600 MemoryManagement
*/
import java.lang.management.*;
diff --git a/test/java/lang/management/MemoryMXBean/Pending.java b/test/java/lang/management/MemoryMXBean/Pending.java
index 91c71c19f..62df8fef7 100644
--- a/test/java/lang/management/MemoryMXBean/Pending.java
+++ b/test/java/lang/management/MemoryMXBean/Pending.java
@@ -62,9 +62,21 @@ public class Pending {
trace = true;
}
- // Turn on verbose:gc to track GC
- mbean.setVerbose(true);
+ try {
+ if (trace) {
+ // Turn on verbose:gc to track GC
+ mbean.setVerbose(true);
+ }
+ test();
+ } finally {
+ if (trace) {
+ mbean.setVerbose(false);
+ }
+ }
+ System.out.println("Test passed.");
+ }
+ private static void test() throws Exception {
// Clean the memory and remove all objects that are pending
// finalization
System.gc();
@@ -130,7 +142,6 @@ public class Pending {
+ " end = " + snapshot);
}
- System.out.println("Test passed.");
}
private static void checkFinalizerCount(int expectedTotal, int curFinalized)
diff --git a/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java b/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
index b72d6c97c..da37945bd 100644
--- a/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
+++ b/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
@@ -28,7 +28,7 @@
* @author Mandy Chung
*
* @build ResetPeakMemoryUsage MemoryUtil
- * @run main ResetPeakMemoryUsage
+ * @run main/othervm ResetPeakMemoryUsage
*/
import java.lang.management.*;
diff --git a/test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java b/test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java
index f34e8d00e..622fc68a6 100644
--- a/test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java
+++ b/test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java
@@ -37,11 +37,23 @@ import java.util.*;
public class ThresholdTest {
public static void main(String args[]) throws Exception {
List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
- for (MemoryPoolMXBean p : pools) {
- // verify if isUsageThresholdExceeded() returns correct value
- checkUsageThreshold(p);
- // verify if isCollectionUsageThresholdExceeded() returns correct value
- checkCollectionUsageThreshold(p);
+ try {
+ for (MemoryPoolMXBean p : pools) {
+ // verify if isUsageThresholdExceeded() returns correct value
+ checkUsageThreshold(p);
+ // verify if isCollectionUsageThresholdExceeded() returns correct value
+ checkCollectionUsageThreshold(p);
+ }
+ } finally {
+ // restore the default
+ for (MemoryPoolMXBean p : pools) {
+ if (p.isUsageThresholdSupported()) {
+ p.setUsageThreshold(0);
+ }
+ if (p.isCollectionUsageThresholdSupported()) {
+ p.setCollectionUsageThreshold(0);
+ }
+ }
}
System.out.println("Test passed.");
diff --git a/test/java/lang/management/RuntimeMXBean/UpTime.java b/test/java/lang/management/RuntimeMXBean/UpTime.java
index fc368f683..4dca590f7 100644
--- a/test/java/lang/management/RuntimeMXBean/UpTime.java
+++ b/test/java/lang/management/RuntimeMXBean/UpTime.java
@@ -37,13 +37,18 @@ public class UpTime {
= ManagementFactory.getRuntimeMXBean();
public static void main(String argv[]) throws Exception {
+ long jvmStartTime = metrics.getStartTime();
long systemStartOuter = System.currentTimeMillis();
long metricsStart = metrics.getUptime();
long systemStartInner = System.currentTimeMillis();
+ // This JVM might have been running for some time if this test runs
+ // in samevm mode. The sanity check should apply to the test uptime.
+ long testUptime = metricsStart - (systemStartOuter - jvmStartTime);
+
// If uptime is more than 30 minutes then it looks like a bug in
// the method
- if (metricsStart > TIMEOUT * 60 * 1000)
+ if (testUptime > TIMEOUT * 60 * 1000)
throw new RuntimeException("Uptime of the JVM is more than 30 "
+ "minutes ("
+ (metricsStart / 60 / 1000)
diff --git a/test/java/lang/management/ThreadMXBean/AllThreadIds.java b/test/java/lang/management/ThreadMXBean/AllThreadIds.java
index 59df52b8b..fa6ec61c8 100644
--- a/test/java/lang/management/ThreadMXBean/AllThreadIds.java
+++ b/test/java/lang/management/ThreadMXBean/AllThreadIds.java
@@ -28,7 +28,7 @@
* @author Alexei Guibadoulline and Mandy Chung
*
* @run build Barrier
- * @run main AllThreadIds
+ * @run main/othervm AllThreadIds
*/
import java.lang.management.*;
@@ -70,6 +70,12 @@ public class AllThreadIds {
}
}
+ private static void fail(String msg) {
+ trace = true;
+ printThreadList();
+ throw new RuntimeException(msg);
+ }
+
private static void checkThreadCount(int numNewThreads,
int numTerminatedThreads)
throws Exception {
@@ -82,27 +88,27 @@ public class AllThreadIds {
if ((curLiveThreadCount - prevLiveThreadCount) !=
(numNewThreads - numTerminatedThreads)) {
- throw new RuntimeException("Unexpected number of live threads: " +
- " Prev Total = " + prevTotalThreadCount +
- " Current Total = " + curTotalThreadCount +
+ fail("Unexpected number of live threads: " +
+ " Prev live = " + prevLiveThreadCount +
+ " Current live = " + curLiveThreadCount +
" Threads added = " + numNewThreads +
" Threads terminated = " + numTerminatedThreads);
}
if (curPeakThreadCount - prevPeakThreadCount != numNewThreads) {
- throw new RuntimeException("Unexpected number of peak threads: " +
- " Prev Total = " + prevTotalThreadCount +
- " Current Total = " + curTotalThreadCount +
+ fail("Unexpected number of peak threads: " +
+ " Prev peak = " + prevPeakThreadCount +
+ " Current peak = " + curPeakThreadCount +
" Threads added = " + numNewThreads);
}
if (curTotalThreadCount - prevTotalThreadCount != numNewThreads) {
- throw new RuntimeException("Unexpected number of total threads: " +
+ fail("Unexpected number of total threads: " +
" Prev Total = " + prevTotalThreadCount +
" Current Total = " + curTotalThreadCount +
" Threads added = " + numNewThreads);
}
long[] list = mbean.getAllThreadIds();
if (list.length != curLiveThreadCount) {
- throw new RuntimeException("Array length returned by " +
+ fail("Array length returned by " +
"getAllThreadIds() = " + list.length +
" not matched count = " + curLiveThreadCount);
}
diff --git a/test/java/lang/management/ThreadMXBean/DisableTest.java b/test/java/lang/management/ThreadMXBean/DisableTest.java
index eb2776096..f5b763a5b 100644
--- a/test/java/lang/management/ThreadMXBean/DisableTest.java
+++ b/test/java/lang/management/ThreadMXBean/DisableTest.java
@@ -36,8 +36,18 @@ public class DisableTest {
private static ThreadMXBean tm = ManagementFactory.getThreadMXBean();
public static void main(String args[]) throws Exception {
- testThreadContentionMonitoring();
- testThreadCpuMonitoring();
+ try {
+ testThreadContentionMonitoring();
+ testThreadCpuMonitoring();
+ } finally {
+ // restore the default
+ if (tm.isThreadContentionMonitoringSupported()) {
+ tm.setThreadContentionMonitoringEnabled(false);
+ }
+ if (tm.isThreadCpuTimeSupported()) {
+ tm.setThreadCpuTimeEnabled(false);
+ }
+ }
System.out.println("Test passed.");
}
diff --git a/test/java/lang/management/ThreadMXBean/EnableTest.java b/test/java/lang/management/ThreadMXBean/EnableTest.java
index 57085b57c..a3530e44a 100644
--- a/test/java/lang/management/ThreadMXBean/EnableTest.java
+++ b/test/java/lang/management/ThreadMXBean/EnableTest.java
@@ -119,8 +119,19 @@ public class EnableTest {
}
public static void main(String args[]) throws Exception {
- testThreadContentionMonitoring();
- testThreadCpuTime();
+ try {
+ testThreadContentionMonitoring();
+ testThreadCpuTime();
+ } finally {
+ // restore the default
+ if (tm.isThreadContentionMonitoringSupported()) {
+ tm.setThreadContentionMonitoringEnabled(false);
+ }
+ if (tm.isThreadCpuTimeSupported()) {
+ tm.setThreadCpuTimeEnabled(false);
+ }
+ }
+
System.out.println("Test passed.");
}
diff --git a/test/java/lang/management/ThreadMXBean/FindDeadlocks.java b/test/java/lang/management/ThreadMXBean/FindDeadlocks.java
index 99c9edfe7..b913147f9 100644
--- a/test/java/lang/management/ThreadMXBean/FindDeadlocks.java
+++ b/test/java/lang/management/ThreadMXBean/FindDeadlocks.java
@@ -33,7 +33,7 @@
* @build MonitorDeadlock
* @build SynchronizerDeadlock
* @build ThreadDump
- * @run main FindDeadlocks
+ * @run main/othervm FindDeadlocks
*/
import java.lang.management.*;
diff --git a/test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java b/test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java
index 06c55c43c..7381bc002 100644
--- a/test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java
+++ b/test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java
@@ -30,7 +30,7 @@
*
* @build MonitorDeadlock
* @build ThreadDump
- * @run main FindMonitorDeadlock
+ * @run main/othervm FindMonitorDeadlock
*/
import java.lang.management.*;
diff --git a/test/java/lang/management/ThreadMXBean/Locks.java b/test/java/lang/management/ThreadMXBean/Locks.java
index 28a402713..1541a0865 100644
--- a/test/java/lang/management/ThreadMXBean/Locks.java
+++ b/test/java/lang/management/ThreadMXBean/Locks.java
@@ -29,7 +29,7 @@
* @author Mandy Chung
*
* @build ThreadExecutionSynchronizer
- * @run main Locks
+ * @run main/othervm Locks
*/
import java.lang.management.*;
diff --git a/test/java/lang/reflect/Proxy/Boxing.java b/test/java/lang/reflect/Proxy/Boxing.java
index a32a6f734..2c4c24550 100644
--- a/test/java/lang/reflect/Proxy/Boxing.java
+++ b/test/java/lang/reflect/Proxy/Boxing.java
@@ -71,8 +71,8 @@ public class Boxing {
Random random = new Random(42); // ensure consistent test domain
Test proxy = (Test) Proxy.newProxyInstance(
- ClassLoader.getSystemClassLoader(),
- new Class[] { Test.class },
+ Test.class.getClassLoader(),
+ new Class<?>[] { Test.class },
new TestHandler());
for (int rep = 0; rep < REPS; rep++) {
diff --git a/test/java/lang/reflect/Proxy/ClassRestrictions.java b/test/java/lang/reflect/Proxy/ClassRestrictions.java
index 905e35183..6c35d75e9 100644
--- a/test/java/lang/reflect/Proxy/ClassRestrictions.java
+++ b/test/java/lang/reflect/Proxy/ClassRestrictions.java
@@ -54,16 +54,16 @@ public class ClassRestrictions {
"\nTest of restrictions on parameters to Proxy.getProxyClass\n");
try {
- ClassLoader loader = ClassLoader.getSystemClassLoader();
- Class[] interfaces;
- Class proxyClass;
+ ClassLoader loader = ClassRestrictions.class.getClassLoader();
+ Class<?>[] interfaces;
+ Class<?> proxyClass;
/*
* All of the Class objects in the interfaces array must represent
* interfaces, not classes or primitive types.
*/
try {
- interfaces = new Class[] { Object.class };
+ interfaces = new Class<?>[] { Object.class };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
"proxy class created with java.lang.Object as interface");
@@ -73,7 +73,7 @@ public class ClassRestrictions {
// assume exception is for intended failure
}
try {
- interfaces = new Class[] { Integer.TYPE };
+ interfaces = new Class<?>[] { Integer.TYPE };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
"proxy class created with int.class as interface");
@@ -88,7 +88,7 @@ public class ClassRestrictions {
* Class objects.
*/
try {
- interfaces = new Class[] { Bar.class, Bar.class };
+ interfaces = new Class<?>[] { Bar.class, Bar.class };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
"proxy class created with repeated interfaces");
@@ -107,7 +107,7 @@ public class ClassRestrictions {
Class altBarClass;
altBarClass = Class.forName(Bar.class.getName(), false, altLoader);
try {
- interfaces = new Class[] { altBarClass };
+ interfaces = new Class<?>[] { altBarClass };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
"proxy class created with interface " +
@@ -121,8 +121,8 @@ public class ClassRestrictions {
/*
* All non-public interfaces must be in the same package.
*/
- Class nonPublic1 = Bashful.class;
- Class nonPublic2 = null;
+ Class<?> nonPublic1 = Bashful.class;
+ Class<?> nonPublic2 = null;
String[] nonPublicInterfaces = new String[] {
"java.awt.Conditional",
"java.util.zip.ZipConstants",
@@ -147,7 +147,7 @@ public class ClassRestrictions {
"no second non-public interface found for test");
}
try {
- interfaces = new Class[] { nonPublic1, nonPublic2 };
+ interfaces = new Class<?>[] { nonPublic1, nonPublic2 };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
"proxy class created with two non-public interfaces " +
@@ -163,7 +163,7 @@ public class ClassRestrictions {
* parameter signature but different return type.
*/
try {
- interfaces = new Class[] { Bar.class, Baz.class };
+ interfaces = new Class<?>[] { Bar.class, Baz.class };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
"proxy class created with conflicting methods");
diff --git a/test/java/lang/reflect/Proxy/returnTypes/Test.java b/test/java/lang/reflect/Proxy/returnTypes/Test.java
index d775840db..754e965bb 100644
--- a/test/java/lang/reflect/Proxy/returnTypes/Test.java
+++ b/test/java/lang/reflect/Proxy/returnTypes/Test.java
@@ -42,7 +42,7 @@ public class Test {
// additional test cases may be added to both of these lists:
- private static final Class[][] GOOD = {
+ private static final Class<?>[][] GOOD = {
{ Collection.class },
{ Iterable.class, Collection.class },
{ Iterable.class, Collection.class, List.class },
@@ -51,7 +51,7 @@ public class Test {
GetArray.class }
};
- private static final Class[][] BAD = {
+ private static final Class<?>[][] BAD = {
{ Runnable.class, PrivilegedAction.class },
{ GetSerializable.class, GetCloneable.class },
{ GetObject.class, GetSerializable.class, GetCloneable.class }
@@ -60,12 +60,12 @@ public class Test {
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 4838310\n");
- ClassLoader loader = ClassLoader.getSystemClassLoader();
+ ClassLoader loader = Test.class.getClassLoader();
System.err.println("Testing GOOD combinations:");
for (int i = 0; i < GOOD.length; i++) {
- Class[] interfaces = GOOD[i];
+ Class<?>[] interfaces = GOOD[i];
System.err.println(Arrays.asList(interfaces));
Proxy.getProxyClass(loader, interfaces);
System.err.println("--- OK.");
@@ -74,7 +74,7 @@ public class Test {
System.err.println("Testing BAD combinations:");
for (int i = 0; i < BAD.length; i++) {
- Class[] interfaces = BAD[i];
+ Class<?>[] interfaces = BAD[i];
System.err.println(Arrays.asList(interfaces));
try {
Proxy.getProxyClass(loader, interfaces);
diff --git a/test/java/net/ResponseCache/file1.cache b/test/java/net/ResponseCache/file1.cache
index 004b1e407..b00b09787 100644
--- a/test/java/net/ResponseCache/file1.cache
+++ b/test/java/net/ResponseCache/file1.cache
Binary files differ
diff --git a/test/java/nio/channels/AsyncCloseAndInterrupt.java b/test/java/nio/channels/AsyncCloseAndInterrupt.java
index a18a936cc..b0fb0cfa3 100644
--- a/test/java/nio/channels/AsyncCloseAndInterrupt.java
+++ b/test/java/nio/channels/AsyncCloseAndInterrupt.java
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135
+ * @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224
* @summary Comprehensive test of asynchronous closing and interruption
* @author Mark Reinhold
*/
@@ -88,6 +88,9 @@ public class AsyncCloseAndInterrupt {
}
private static void pumpRefuser(String msg) throws IOException {
+ // Can't reliably saturate connection backlog on Windows Server editions
+ assert !TestUtil.onWindows();
+
log.print(msg);
int n = refuserClients.size();
@@ -203,9 +206,9 @@ public class AsyncCloseAndInterrupt {
= new ChannelFactory("DatagramChannel") {
InterruptibleChannel create() throws IOException {
DatagramChannel dc = DatagramChannel.open();
- dc.socket().bind(wildcardAddress);
- InetAddress ia = InetAddress.getByName("127.0.0.1");
- dc.connect(new InetSocketAddress(ia, 80));
+ InetAddress lb = InetAddress.getByName("127.0.0.1");
+ dc.bind(new InetSocketAddress(lb, 0));
+ dc.connect(new InetSocketAddress(lb, 80));
return dc;
}
};
@@ -636,7 +639,8 @@ public class AsyncCloseAndInterrupt {
wildcardAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0);
initAcceptor();
- initRefuser();
+ if (!TestUtil.onWindows())
+ initRefuser();
initPipes();
initFile();
@@ -658,8 +662,15 @@ public class AsyncCloseAndInterrupt {
// unclear under what conditions mmap(2) will actually block.
test(connectedSocketChannelFactory);
- test(socketChannelFactory, CONNECT);
- test(socketChannelFactory, FINISH_CONNECT);
+
+ if (TestUtil.onWindows()) {
+ log.println("WARNING Cannot reliably test connect/finishConnect"
+ + " operations on Windows");
+ } else {
+ test(socketChannelFactory, CONNECT);
+ test(socketChannelFactory, FINISH_CONNECT);
+ }
+
test(serverSocketChannelFactory, ACCEPT);
test(datagramChannelFactory);
test(pipeSourceChannelFactory);
diff --git a/test/java/nio/channels/AsynchronousSocketChannel/Basic.java b/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
index 7fbe8f692..f9755de04 100644
--- a/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
+++ b/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
@@ -196,18 +196,16 @@ public class Basic {
System.out.println("-- connect to non-existent host --");
- // test failure
- InetAddress badHost = InetAddress.getByName("1.2.3.4");
- if (!badHost.isReachable(10*1000)) {
-
- ch = AsynchronousSocketChannel.open();
- try {
- ch.connect(new InetSocketAddress(badHost, 9876)).get();
- throw new RuntimeException("Connection should not be established");
- } catch (ExecutionException x) {
- }
+ // test that failure to connect closes the channel
+ ch = AsynchronousSocketChannel.open();
+ try {
+ ch.connect(genSocketAddress()).get();
+ } catch (ExecutionException x) {
+ // failed to establish connection
if (ch.isOpen())
throw new RuntimeException("Channel should be closed");
+ } finally {
+ ch.close();
}
server.close();
@@ -219,27 +217,22 @@ public class Basic {
AsynchronousSocketChannel ch;
// asynchronous close while connecting
- InetAddress rh = InetAddress.getByName("1.2.3.4");
- if (!rh.isReachable(3000)) {
- InetSocketAddress isa = new InetSocketAddress(rh, 1234);
-
- ch = AsynchronousSocketChannel.open();
- Future<Void> result = ch.connect(isa);
+ ch = AsynchronousSocketChannel.open();
+ Future<Void> connectResult = ch.connect(genSocketAddress());
- // give time to initiate the connect (SYN)
- Thread.sleep(50);
+ // give time to initiate the connect (SYN)
+ Thread.sleep(50);
- // close
- ch.close();
+ // close
+ ch.close();
- // check that AsynchronousCloseException is thrown
- try {
- result.get();
- throw new RuntimeException("Should not connect");
- } catch (ExecutionException x) {
- if (!(x.getCause() instanceof AsynchronousCloseException))
- throw new RuntimeException(x);
- }
+ // check that exception is thrown in timely manner
+ try {
+ connectResult.get(5, TimeUnit.SECONDS);
+ } catch (TimeoutException x) {
+ throw new RuntimeException("AsynchronousCloseException not thrown");
+ } catch (ExecutionException x) {
+ // expected
}
System.out.println("-- asynchronous close when reading --");
@@ -785,30 +778,47 @@ public class Basic {
ch.close();
}
- // returns ByteBuffer with random bytes
- static ByteBuffer genBuffer() {
- int size = 1024 + rand.nextInt(16000);
- byte[] buf = new byte[size];
- rand.nextBytes(buf);
- boolean useDirect = rand.nextBoolean();
- if (useDirect) {
- ByteBuffer bb = ByteBuffer.allocateDirect(buf.length);
- bb.put(buf);
- bb.flip();
- return bb;
- } else {
- return ByteBuffer.wrap(buf);
- }
- }
-
- // return ByteBuffer[] with random bytes
- static ByteBuffer[] genBuffers(int max) {
- int len = 1;
- if (max > 1)
- len += rand.nextInt(max);
- ByteBuffer[] bufs = new ByteBuffer[len];
- for (int i=0; i<len; i++)
- bufs[i] = genBuffer();
- return bufs;
- }
+ // returns ByteBuffer with random bytes
+ static ByteBuffer genBuffer() {
+ int size = 1024 + rand.nextInt(16000);
+ byte[] buf = new byte[size];
+ rand.nextBytes(buf);
+ boolean useDirect = rand.nextBoolean();
+ if (useDirect) {
+ ByteBuffer bb = ByteBuffer.allocateDirect(buf.length);
+ bb.put(buf);
+ bb.flip();
+ return bb;
+ } else {
+ return ByteBuffer.wrap(buf);
+ }
+ }
+
+ // return ByteBuffer[] with random bytes
+ static ByteBuffer[] genBuffers(int max) {
+ int len = 1;
+ if (max > 1)
+ len += rand.nextInt(max);
+ ByteBuffer[] bufs = new ByteBuffer[len];
+ for (int i=0; i<len; i++)
+ bufs[i] = genBuffer();
+ return bufs;
+ }
+
+ // return random SocketAddress
+ static SocketAddress genSocketAddress() {
+ StringBuilder sb = new StringBuilder("10.");
+ sb.append(rand.nextInt(256));
+ sb.append('.');
+ sb.append(rand.nextInt(256));
+ sb.append('.');
+ sb.append(rand.nextInt(256));
+ InetAddress rh;
+ try {
+ rh = InetAddress.getByName(sb.toString());
+ } catch (UnknownHostException x) {
+ throw new InternalError("Should not happen");
+ }
+ return new InetSocketAddress(rh, rand.nextInt(65535)+1);
+ }
}
diff --git a/test/java/nio/channels/DatagramChannel/AdaptDatagramSocket.java b/test/java/nio/channels/DatagramChannel/AdaptDatagramSocket.java
index 561d7ead4..5a855acbd 100644
--- a/test/java/nio/channels/DatagramChannel/AdaptDatagramSocket.java
+++ b/test/java/nio/channels/DatagramChannel/AdaptDatagramSocket.java
@@ -22,6 +22,7 @@
*/
/* @test
+ * @bug 4313882 4981129
* @summary Unit test for datagram-socket-channel adaptors
* @library ..
*/
@@ -93,6 +94,11 @@ public class AdaptDatagramSocket {
if (ip.getData()[ip.getOffset() + i]
!= op.getData()[op.getOffset() + i])
throw new Exception("Incorrect data received");
+
+ if (!(ip.getSocketAddress().equals(dst))) {
+ throw new Exception("Incorrect sender address, expected: " + dst
+ + " actual: " + ip.getSocketAddress());
+ }
}
static void test(InetSocketAddress dst,
diff --git a/test/java/nio/channels/DatagramChannel/Connect.java b/test/java/nio/channels/DatagramChannel/Connect.java
index 46a3068a8..318729aae 100644
--- a/test/java/nio/channels/DatagramChannel/Connect.java
+++ b/test/java/nio/channels/DatagramChannel/Connect.java
@@ -42,15 +42,15 @@ public class Connect {
}
static void test() throws Exception {
- invoke(new Actor(), new Reactor());
+ Reactor r = new Reactor();
+ Actor a = new Actor(r.port());
+ invoke(a, r);
}
static void invoke(Sprintable reader, Sprintable writer) throws Exception {
Thread writerThread = new Thread(writer);
writerThread.start();
- while (!writer.ready())
- Thread.sleep(50);
Thread readerThread = new Thread(reader);
readerThread.start();
@@ -64,34 +64,31 @@ public class Connect {
public interface Sprintable extends Runnable {
public void throwException() throws Exception;
- public boolean ready();
}
public static class Actor implements Sprintable {
+ final int port;
Exception e = null;
+ Actor(int port) {
+ this.port = port;
+ }
+
public void throwException() throws Exception {
if (e != null)
throw e;
}
- private volatile boolean ready = false;
-
- public boolean ready() {
- return ready;
- }
-
public void run() {
try {
DatagramChannel dc = DatagramChannel.open();
- ready = true;
// Send a message
ByteBuffer bb = ByteBuffer.allocateDirect(256);
bb.put("hello".getBytes());
bb.flip();
InetAddress address = InetAddress.getLocalHost();
- InetSocketAddress isa = new InetSocketAddress(address, 8888);
+ InetSocketAddress isa = new InetSocketAddress(address, port);
dc.connect(isa);
dc.write(bb);
@@ -123,26 +120,26 @@ public class Connect {
}
public static class Reactor implements Sprintable {
+ final DatagramChannel dc;
Exception e = null;
- public void throwException() throws Exception {
- if (e != null)
- throw e;
+ Reactor() throws IOException {
+ dc = DatagramChannel.open().bind(new InetSocketAddress(0));
}
- private volatile boolean ready = false;
+ int port() {
+ return dc.socket().getLocalPort();
+ }
- public boolean ready() {
- return ready;
+ public void throwException() throws Exception {
+ if (e != null)
+ throw e;
}
public void run() {
try {
// Listen for a message
- DatagramChannel dc = DatagramChannel.open();
- dc.socket().bind(new InetSocketAddress(8888));
ByteBuffer bb = ByteBuffer.allocateDirect(100);
- ready = true;
SocketAddress sa = dc.receive(bb);
bb.flip();
CharBuffer cb = Charset.forName("US-ASCII").
diff --git a/test/java/nio/channels/DatagramChannel/EmptyBuffer.java b/test/java/nio/channels/DatagramChannel/EmptyBuffer.java
index eebef9856..f7c836a19 100644
--- a/test/java/nio/channels/DatagramChannel/EmptyBuffer.java
+++ b/test/java/nio/channels/DatagramChannel/EmptyBuffer.java
@@ -42,18 +42,16 @@ public class EmptyBuffer {
}
static void test() throws Exception {
- Sprintable server = new Server();
+ Server server = new Server();
Thread serverThread = new Thread(server);
serverThread.start();
- while (!server.ready())
- Thread.sleep(50);
DatagramChannel dc = DatagramChannel.open();
ByteBuffer bb = ByteBuffer.allocateDirect(12);
bb.order(ByteOrder.BIG_ENDIAN);
bb.putInt(1).putLong(1);
bb.flip();
InetAddress address = InetAddress.getLocalHost();
- InetSocketAddress isa = new InetSocketAddress(address, 8888);
+ InetSocketAddress isa = new InetSocketAddress(address, server.port());
dc.connect(isa);
dc.write(bb);
bb.rewind();
@@ -65,22 +63,21 @@ public class EmptyBuffer {
server.throwException();
}
- public interface Sprintable extends Runnable {
- public void throwException() throws Exception;
- public boolean ready();
- }
-
- public static class Server implements Sprintable {
+ public static class Server implements Runnable {
+ final DatagramChannel dc;
Exception e = null;
- private volatile boolean ready = false;
- public void throwException() throws Exception {
- if (e != null)
- throw e;
+ Server() throws IOException {
+ this.dc = DatagramChannel.open().bind(new InetSocketAddress(0));
}
- public boolean ready() {
- return ready;
+ int port() {
+ return dc.socket().getLocalPort();
+ }
+
+ void throwException() throws Exception {
+ if (e != null)
+ throw e;
}
void showBuffer(String s, ByteBuffer bb) {
@@ -97,9 +94,6 @@ public class EmptyBuffer {
SocketAddress sa = null;
int numberReceived = 0;
try {
- DatagramChannel dc = DatagramChannel.open();
- dc.socket().bind(new InetSocketAddress(8888));
- ready = true;
ByteBuffer bb = ByteBuffer.allocateDirect(12);
bb.clear();
// Only one clear. The buffer will be full after
diff --git a/test/java/nio/channels/DatagramChannel/NoSender.java b/test/java/nio/channels/DatagramChannel/NoSender.java
index 6eb1cb1c7..ec559ce97 100644
--- a/test/java/nio/channels/DatagramChannel/NoSender.java
+++ b/test/java/nio/channels/DatagramChannel/NoSender.java
@@ -33,7 +33,7 @@ import java.nio.channels.*;
public class NoSender {
public static void main(String argv[]) throws Exception {
DatagramChannel dc = DatagramChannel.open();
- dc.socket().bind(new InetSocketAddress(5441));
+ dc.socket().bind(new InetSocketAddress(0));
dc.configureBlocking(false);
ByteBuffer buf1 = ByteBuffer.allocateDirect(256);
SocketAddress sa1 = dc.receive(buf1);
diff --git a/test/java/nio/channels/DatagramChannel/SRTest.java b/test/java/nio/channels/DatagramChannel/SRTest.java
index 50f9c2945..f99a14d52 100644
--- a/test/java/nio/channels/DatagramChannel/SRTest.java
+++ b/test/java/nio/channels/DatagramChannel/SRTest.java
@@ -42,16 +42,23 @@ public class SRTest {
}
static void test() throws Exception {
- invoke(new ClassicReader(), new ClassicWriter());
+ ClassicReader classicReader;
+ NioReader nioReader;
+
+ classicReader = new ClassicReader();
+ invoke(classicReader, new ClassicWriter(classicReader.port()));
log.println("Classic RW: OK");
- invoke(new ClassicReader(), new NioWriter());
+ classicReader = new ClassicReader();
+ invoke(classicReader, new NioWriter(classicReader.port()));
log.println("Classic R, Nio W: OK");
- invoke(new NioReader(), new ClassicWriter());
+ nioReader = new NioReader();
+ invoke(nioReader, new ClassicWriter(nioReader.port()));
log.println("Classic W, Nio R: OK");
- invoke(new NioReader(), new NioWriter());
+ nioReader = new NioReader();
+ invoke(nioReader, new NioWriter(nioReader.port()));
log.println("Nio RW: OK");
}
@@ -75,8 +82,13 @@ public class SRTest {
}
public static class ClassicWriter implements Sprintable {
+ final int port;
Exception e = null;
+ ClassicWriter(int port) {
+ this.port = port;
+ }
+
public void throwException() throws Exception {
if (e != null)
throw e;
@@ -89,7 +101,7 @@ public class SRTest {
byte[] data = dataString.getBytes();
InetAddress address = InetAddress.getLocalHost();
DatagramPacket dp = new DatagramPacket(data, data.length,
- address, 8888);
+ address, port);
ds.send(dp);
Thread.sleep(50);
ds.send(dp);
@@ -100,8 +112,13 @@ public class SRTest {
}
public static class NioWriter implements Sprintable {
+ final int port;
Exception e = null;
+ NioWriter(int port) {
+ this.port = port;
+ }
+
public void throwException() throws Exception {
if (e != null)
throw e;
@@ -114,7 +131,7 @@ public class SRTest {
bb.put("hello".getBytes());
bb.flip();
InetAddress address = InetAddress.getLocalHost();
- InetSocketAddress isa = new InetSocketAddress(address, 8888);
+ InetSocketAddress isa = new InetSocketAddress(address, port);
dc.send(bb, isa);
Thread.sleep(50);
dc.send(bb, isa);
@@ -125,8 +142,17 @@ public class SRTest {
}
public static class ClassicReader implements Sprintable {
+ final DatagramSocket ds;
Exception e = null;
+ ClassicReader() throws IOException {
+ this.ds = new DatagramSocket();
+ }
+
+ int port() {
+ return ds.getLocalPort();
+ }
+
public void throwException() throws Exception {
if (e != null)
throw e;
@@ -136,7 +162,6 @@ public class SRTest {
try {
byte[] buf = new byte[256];
DatagramPacket dp = new DatagramPacket(buf, buf.length);
- DatagramSocket ds = new DatagramSocket(8888);
ds.receive(dp);
String received = new String(dp.getData());
log.println(received);
@@ -148,8 +173,17 @@ public class SRTest {
}
public static class NioReader implements Sprintable {
+ final DatagramChannel dc;
Exception e = null;
+ NioReader() throws IOException {
+ this.dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ }
+
+ int port() {
+ return dc.socket().getLocalPort();
+ }
+
public void throwException() throws Exception {
if (e != null)
throw e;
@@ -157,8 +191,6 @@ public class SRTest {
public void run() {
try {
- DatagramChannel dc = DatagramChannel.open();
- dc.socket().bind(new InetSocketAddress(8888));
ByteBuffer bb = ByteBuffer.allocateDirect(100);
SocketAddress sa = dc.receive(bb);
bb.flip();
diff --git a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
new file mode 100644
index 000000000..fdbbd3600
--- /dev/null
+++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 6935563
+ * @summary Test that Selector does not select an unconnected DatagramChannel when
+ * ICMP port unreachable received
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.channels.*;
+import java.net.*;
+import java.io.IOException;
+
+public class SelectWhenRefused {
+
+ public static void main(String[] args) throws IOException {
+ DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ int port = dc.socket().getLocalPort();
+ dc.close();
+
+ // datagram sent to this address should be refused
+ SocketAddress refuser = new InetSocketAddress(InetAddress.getLocalHost(), port);
+
+ dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ try {
+ dc.configureBlocking(false);
+ Selector sel = Selector.open();
+ dc.register(sel, SelectionKey.OP_READ);
+
+ /* Test 1: not connected so ICMP port unreachable should not be received */
+ sendDatagram(dc, refuser);
+ int n = sel.select(2000);
+ if (n > 0) {
+ throw new RuntimeException("Unexpected wakeup");
+ }
+
+ /* Test 2: connected so ICMP port unreachable may be received */
+ dc.connect(refuser);
+ try {
+ sendDatagram(dc, refuser);
+ n = sel.select(2000);
+ if (n > 0) {
+ sel.selectedKeys().clear();
+ try {
+ n = dc.read(ByteBuffer.allocate(100));
+ throw new RuntimeException("Unexpected datagram received");
+ } catch (PortUnreachableException pue) {
+ // expected
+ }
+ }
+ } finally {
+ dc.disconnect();
+ }
+
+ /* Test 3: not connected so ICMP port unreachable should not be received */
+ sendDatagram(dc, refuser);
+ n = sel.select(2000);
+ if (n > 0) {
+ throw new RuntimeException("Unexpected wakeup after disconnect");
+ }
+
+ } finally {
+ dc.close();
+ }
+ }
+
+ static void sendDatagram(DatagramChannel dc, SocketAddress remote)
+ throws IOException
+ {
+ ByteBuffer bb = ByteBuffer.wrap("Greetings!".getBytes());
+ dc.send(bb, remote);
+ }
+}
diff --git a/test/java/nio/channels/DatagramChannel/Sender.java b/test/java/nio/channels/DatagramChannel/Sender.java
index 58d4a4af1..60336f54f 100644
--- a/test/java/nio/channels/DatagramChannel/Sender.java
+++ b/test/java/nio/channels/DatagramChannel/Sender.java
@@ -42,13 +42,11 @@ public class Sender {
}
static void test() throws Exception {
- Sprintable server = new Server();
- Sprintable client = new Client();
+ Server server = new Server();
+ Client client = new Client(server.port());
Thread serverThread = new Thread(server);
serverThread.start();
- while (!server.ready())
- Thread.sleep(50);
Thread clientThread = new Thread(client);
clientThread.start();
@@ -60,23 +58,17 @@ public class Sender {
client.throwException();
}
- public interface Sprintable extends Runnable {
- public void throwException() throws Exception;
- public boolean ready();
- }
-
- public static class Client implements Sprintable {
+ public static class Client implements Runnable {
+ final int port;
Exception e = null;
- public void throwException() throws Exception {
- if (e != null)
- throw e;
+ Client(int port) {
+ this.port = port;
}
- private volatile boolean ready = false;
-
- public boolean ready() {
- return ready;
+ void throwException() throws Exception {
+ if (e != null)
+ throw e;
}
public void run() {
@@ -87,7 +79,7 @@ public class Sender {
bb.putInt(1).putLong(1);
bb.flip();
InetAddress address = InetAddress.getLocalHost();
- InetSocketAddress isa = new InetSocketAddress(address, 8888);
+ InetSocketAddress isa = new InetSocketAddress(address, port);
dc.connect(isa);
dc.write(bb);
} catch (Exception ex) {
@@ -96,17 +88,21 @@ public class Sender {
}
}
- public static class Server implements Sprintable {
+ public static class Server implements Runnable {
+ final DatagramChannel dc;
Exception e = null;
- private volatile boolean ready = false;
- public void throwException() throws Exception {
- if (e != null)
- throw e;
+ Server() throws IOException {
+ dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ }
+
+ int port() {
+ return dc.socket().getLocalPort();
}
- public boolean ready() {
- return ready;
+ void throwException() throws Exception {
+ if (e != null)
+ throw e;
}
void showBuffer(String s, ByteBuffer bb) {
@@ -123,13 +119,10 @@ public class Sender {
SocketAddress sa = null;
try {
- DatagramChannel dc = DatagramChannel.open();
- dc.socket().bind(new InetSocketAddress(8888));
- dc.configureBlocking(false);
- ready = true;
ByteBuffer bb = ByteBuffer.allocateDirect(12);
bb.clear();
// Get the one valid datagram
+ dc.configureBlocking(false);
while (sa == null)
sa = dc.receive(bb);
sa = null;
diff --git a/test/java/nio/channels/Selector/ByteServer.java b/test/java/nio/channels/Selector/ByteServer.java
index 9cb7f9670..53ab51f0a 100644
--- a/test/java/nio/channels/Selector/ByteServer.java
+++ b/test/java/nio/channels/Selector/ByteServer.java
@@ -33,7 +33,6 @@ import java.net.ServerSocket;
public class ByteServer {
- public static final int PORT = 31415;
public static final String LOCALHOST = "localhost";
private int bytecount;
private Socket socket;
@@ -43,7 +42,11 @@ public class ByteServer {
public ByteServer(int bytecount) throws Exception{
this.bytecount = bytecount;
- serversocket = new ServerSocket(PORT);
+ serversocket = new ServerSocket(0);
+ }
+
+ public int port() {
+ return serversocket.getLocalPort();
}
public void start() {
diff --git a/test/java/nio/channels/Selector/CloseThenRegister.java b/test/java/nio/channels/Selector/CloseThenRegister.java
index 03deaf4d8..99192ea0c 100644
--- a/test/java/nio/channels/Selector/CloseThenRegister.java
+++ b/test/java/nio/channels/Selector/CloseThenRegister.java
@@ -32,17 +32,19 @@ import java.nio.channels.*;
public class CloseThenRegister {
public static void main (String [] args) throws Exception {
+ Selector sel = Selector.open();
+ sel.close();
+ ServerSocketChannel ssc = ServerSocketChannel.open();
try {
- Selector s = Selector.open();
- s.close();
- ServerSocketChannel c = ServerSocketChannel.open();
- c.socket().bind(new InetSocketAddress(40000));
- c.configureBlocking(false);
- c.register(s, SelectionKey.OP_ACCEPT);
+ ssc.bind(new InetSocketAddress(0));
+ ssc.configureBlocking(false);
+ ssc.register(sel, SelectionKey.OP_ACCEPT);
+ throw new RuntimeException("register after close does not cause CSE!");
} catch (ClosedSelectorException cse) {
- return;
+ // expected
+ } finally {
+ ssc.close();
}
- throw new RuntimeException("register after close does not cause CSE!");
}
}
diff --git a/test/java/nio/channels/Selector/OpRead.java b/test/java/nio/channels/Selector/OpRead.java
index 54a978ef2..b77feafee 100644
--- a/test/java/nio/channels/Selector/OpRead.java
+++ b/test/java/nio/channels/Selector/OpRead.java
@@ -24,59 +24,63 @@
/* @test
* @bug 4755720
* @summary Test if OP_READ is detected with OP_WRITE in interestOps
- * @library ..
*/
import java.net.*;
-import java.io.*;
import java.nio.*;
import java.nio.channels.*;
-import java.nio.channels.spi.SelectorProvider;
import java.util.*;
public class OpRead {
- static final int DAYTIME_PORT = 13;
- static final String DAYTIME_HOST = TestUtil.HOST;
-
static void test() throws Exception {
- InetSocketAddress isa
- = new InetSocketAddress(InetAddress.getByName(DAYTIME_HOST),
- DAYTIME_PORT);
- SocketChannel sc = SocketChannel.open();
+ ServerSocketChannel ssc = null;
+ SocketChannel sc = null;
+ SocketChannel peer = null;
+ try {
+ ssc = ServerSocketChannel.open().bind(new InetSocketAddress(0));
- sc.connect(isa);
+ // loopback connection
+ InetAddress lh = InetAddress.getLocalHost();
+ sc = SocketChannel.open(new InetSocketAddress(lh, ssc.socket().getLocalPort()));
+ peer = ssc.accept();
- sc.configureBlocking(false);
+ // peer sends message so that "sc" will be readable
+ int n = peer.write(ByteBuffer.wrap("Hello".getBytes()));
+ assert n > 0;
- Selector selector = SelectorProvider.provider().openSelector();
- SelectionKey key = sc.register(selector, SelectionKey.OP_READ |
- SelectionKey.OP_WRITE);
+ sc.configureBlocking(false);
- boolean done = false;
- int failCount = 0;
- while (!done) {
- if (selector.select() > 0) {
- Set keys = selector.selectedKeys();
- Iterator iterator = keys.iterator();
- while (iterator.hasNext()) {
- key = (SelectionKey)iterator.next();
- iterator.remove();
- if (key.isWritable()) {
- failCount++;
- if (failCount > 10)
- throw new RuntimeException("Test failed");
- Thread.sleep(100);
- }
- if (key.isReadable()) {
- done = true;
+ Selector selector = Selector.open();
+ SelectionKey key = sc.register(selector, SelectionKey.OP_READ |
+ SelectionKey.OP_WRITE);
+
+ boolean done = false;
+ int failCount = 0;
+ while (!done) {
+ if (selector.select() > 0) {
+ Set<SelectionKey> keys = selector.selectedKeys();
+ Iterator<SelectionKey> iterator = keys.iterator();
+ while (iterator.hasNext()) {
+ key = iterator.next();
+ iterator.remove();
+ if (key.isWritable()) {
+ failCount++;
+ if (failCount > 10)
+ throw new RuntimeException("Test failed");
+ Thread.sleep(250);
+ }
+ if (key.isReadable()) {
+ done = true;
+ }
}
}
}
+ } finally {
+ if (peer != null) peer.close();
+ if (sc != null) sc.close();
+ if (ssc != null) ssc.close();
}
-
-
- sc.close();
}
public static void main(String[] args) throws Exception {
diff --git a/test/java/nio/channels/Selector/ReadAfterConnect.java b/test/java/nio/channels/Selector/ReadAfterConnect.java
index 678a33af9..136778f4a 100644
--- a/test/java/nio/channels/Selector/ReadAfterConnect.java
+++ b/test/java/nio/channels/Selector/ReadAfterConnect.java
@@ -37,7 +37,7 @@ public class ReadAfterConnect {
ByteServer server = new ByteServer(0); // server: accept connection and do nothing
server.start();
InetSocketAddress isa = new InetSocketAddress(
- InetAddress.getByName(ByteServer.LOCALHOST), ByteServer.PORT);
+ InetAddress.getByName(ByteServer.LOCALHOST), server.port());
Selector sel = Selector.open();
SocketChannel sc = SocketChannel.open();
sc.connect(isa);
diff --git a/test/java/nio/channels/Selector/SelectAfterRead.java b/test/java/nio/channels/Selector/SelectAfterRead.java
index 974213106..d4b2bf1ea 100644
--- a/test/java/nio/channels/Selector/SelectAfterRead.java
+++ b/test/java/nio/channels/Selector/SelectAfterRead.java
@@ -37,14 +37,14 @@ public class SelectAfterRead {
final static int TIMEOUT = 1000;
public static void main(String[] argv) throws Exception {
+ InetAddress lh = InetAddress.getByName(ByteServer.LOCALHOST);
+
// server: accept connection and write one byte
ByteServer server = new ByteServer(1);
server.start();
- InetSocketAddress isa = new InetSocketAddress(
- InetAddress.getByName(ByteServer.LOCALHOST), ByteServer.PORT);
Selector sel = Selector.open();
SocketChannel sc = SocketChannel.open();
- sc.connect(isa);
+ sc.connect(new InetSocketAddress(lh, server.port()));
sc.read(ByteBuffer.allocate(1));
sc.configureBlocking(false);
sc.register(sel, SelectionKey.OP_READ);
@@ -61,7 +61,7 @@ public class SelectAfterRead {
server = new ByteServer(2);
server.start();
sc = SocketChannel.open();
- sc.connect(isa);
+ sc.connect(new InetSocketAddress(lh, server.port()));
sc.configureBlocking(false);
sel = Selector.open();
sc.register(sel, SelectionKey.OP_READ);
diff --git a/test/java/nio/channels/Selector/SelectWrite.java b/test/java/nio/channels/Selector/SelectWrite.java
index 5b15dab7b..8f18c7e0a 100644
--- a/test/java/nio/channels/Selector/SelectWrite.java
+++ b/test/java/nio/channels/Selector/SelectWrite.java
@@ -39,7 +39,7 @@ public class SelectWrite {
// server: accept connection and do nothing
server.start();
InetSocketAddress isa = new InetSocketAddress(
- InetAddress.getByName(ByteServer.LOCALHOST), ByteServer.PORT);
+ InetAddress.getByName(ByteServer.LOCALHOST), server.port());
Selector sel = Selector.open();
SocketChannel sc = SocketChannel.open();
sc.connect(isa);
diff --git a/test/java/nio/channels/SocketChannel/BigReadWrite.java b/test/java/nio/channels/SocketChannel/BigReadWrite.java
index 8a4166536..bd2ed2931 100644
--- a/test/java/nio/channels/SocketChannel/BigReadWrite.java
+++ b/test/java/nio/channels/SocketChannel/BigReadWrite.java
@@ -32,7 +32,6 @@ import java.nio.channels.*;
public class BigReadWrite {
- static int port = 40170;
static int testSize = 15;
public static void main(String[] args) throws Exception {
diff --git a/test/java/nio/channels/SocketChannel/OpenLeak.java b/test/java/nio/channels/SocketChannel/OpenLeak.java
index 9e9e6f1d0..ab5dfde69 100644
--- a/test/java/nio/channels/SocketChannel/OpenLeak.java
+++ b/test/java/nio/channels/SocketChannel/OpenLeak.java
@@ -25,6 +25,8 @@
* @bug 6548464
* @summary SocketChannel.open(SocketAddress) leaks file descriptor if
* connection cannot be established
+ * @build OpenLeak
+ * @run main/othervm OpenLeak
*/
import java.net.InetAddress;
diff --git a/test/java/nio/channels/SocketChannel/VectorIO.java b/test/java/nio/channels/SocketChannel/VectorIO.java
index 67840bed0..0dfd2d66f 100644
--- a/test/java/nio/channels/SocketChannel/VectorIO.java
+++ b/test/java/nio/channels/SocketChannel/VectorIO.java
@@ -36,8 +36,6 @@ import sun.misc.*;
public class VectorIO {
- static int port = 40170;
-
static Random generator = new Random();
static int testSize;
@@ -55,20 +53,12 @@ public class VectorIO {
System.err.println("Length " + testSize);
Server sv = new Server(testSize);
sv.start();
- do {
- try {
- Thread.currentThread().sleep(200);
- } catch (InterruptedException x) {
- if (sv.finish(8000) == 0)
- throw new Exception("Failed: Error in server thread");
- }
- } while (!sv.ready);
- bufferTest();
+ bufferTest(sv.port());
if (sv.finish(8000) == 0)
throw new Exception("Failed: Length = " + testSize);
}
- static void bufferTest() throws Exception {
+ static void bufferTest(int port) throws Exception {
ByteBuffer[] bufs = new ByteBuffer[testSize];
for(int i=0; i<testSize; i++) {
String source = "buffer" + i;
@@ -105,17 +95,19 @@ public class VectorIO {
static class Server
extends TestThread
{
- static int port = 40170;
-
static Random generator = new Random();
- int testSize;
-
- volatile boolean ready = false;
+ final int testSize;
+ final ServerSocketChannel ssc;
- Server(int testSize) {
+ Server(int testSize) throws IOException {
super("Server " + testSize);
this.testSize = testSize;
+ this.ssc = ServerSocketChannel.open().bind(new InetSocketAddress(0));
+ }
+
+ int port() {
+ return ssc.socket().getLocalPort();
}
void go() throws Exception {
@@ -133,16 +125,11 @@ public class VectorIO {
}
// Get a connection from client
- ServerSocketChannel ssc = ServerSocketChannel.open();
SocketChannel sc = null;
try {
ssc.configureBlocking(false);
- InetAddress lh = InetAddress.getLocalHost();
- InetSocketAddress isa = new InetSocketAddress(lh, port);
- ssc.socket().bind(isa);
- ready = true;
for (;;) {
sc = ssc.accept();
diff --git a/test/java/nio/channels/SocketChannel/Write.java b/test/java/nio/channels/SocketChannel/Write.java
index 9a40c015d..faa62897b 100644
--- a/test/java/nio/channels/SocketChannel/Write.java
+++ b/test/java/nio/channels/SocketChannel/Write.java
@@ -37,8 +37,6 @@ import sun.misc.*;
public class Write {
- static int port = 40170;
-
static Random generator = new Random();
static int testSize = 15;
@@ -46,20 +44,12 @@ public class Write {
public static void main(String[] args) throws Exception {
WriteServer sv = new WriteServer();
sv.start();
- do {
- try {
- Thread.currentThread().sleep(200);
- } catch (InterruptedException x) {
- if (sv.finish(8000) == 0)
- throw new Exception("Failed: Error in server thread");
- }
- } while (!sv.ready);
- bufferTest();
+ bufferTest(sv.port());
if (sv.finish(8000) == 0)
throw new Exception("Failed" );
}
- static void bufferTest() throws Exception {
+ static void bufferTest(int port) throws Exception {
ByteBuffer[] bufs = new ByteBuffer[testSize];
for(int i=0; i<testSize; i++) {
String source =
@@ -94,14 +84,18 @@ public class Write {
class WriteServer extends TestThread {
- static int port = 40170;
-
static Random generator = new Random();
- volatile boolean ready = false;
- WriteServer() {
+ final ServerSocketChannel ssc;
+
+ WriteServer() throws IOException {
super("WriteServer");
+ this.ssc = ServerSocketChannel.open().bind(new InetSocketAddress(0));
+ }
+
+ int port() {
+ return ssc.socket().getLocalPort();
}
void go() throws Exception {
@@ -112,15 +106,10 @@ class WriteServer extends TestThread {
ByteBuffer buf = ByteBuffer.allocateDirect(5);
// Get a connection from client
- ServerSocketChannel ssc = ServerSocketChannel.open();
SocketChannel sc = null;
try {
ssc.configureBlocking(false);
- InetAddress lh = InetAddress.getLocalHost();
- InetSocketAddress isa = new InetSocketAddress(lh, port);
- ssc.socket().bind(isa);
- ready = true;
for (;;) {
sc = ssc.accept();
diff --git a/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java b/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java
index 015705ffe..16298b847 100644
--- a/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java
+++ b/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/EchoTest.java
@@ -141,7 +141,7 @@ public class EchoTest {
// and receive the echo
byte b[] = new byte[msg.length() + 100];
DatagramPacket pkt2 = new DatagramPacket(b, b.length);
- dc.socket().setSoTimeout(2000);
+ dc.socket().setSoTimeout(5000);
dc.socket().receive(pkt2);
if (pkt2.getLength() != msg.length()) {
diff --git a/test/java/util/Locale/Bug4184873_he b/test/java/util/Locale/Bug4184873_he
index 37c909ac2..19bbd672f 100644
--- a/test/java/util/Locale/Bug4184873_he
+++ b/test/java/util/Locale/Bug4184873_he
Binary files differ
diff --git a/test/java/util/Locale/Bug4184873_id b/test/java/util/Locale/Bug4184873_id
index f83677201..aa0a2c23d 100644
--- a/test/java/util/Locale/Bug4184873_id
+++ b/test/java/util/Locale/Bug4184873_id
Binary files differ
diff --git a/test/java/util/Locale/Bug4184873_yi b/test/java/util/Locale/Bug4184873_yi
index c0d8f3a8b..8405fb70d 100644
--- a/test/java/util/Locale/Bug4184873_yi
+++ b/test/java/util/Locale/Bug4184873_yi
Binary files differ
diff --git a/test/java/util/ResourceBundle/Bug4168625Test.java b/test/java/util/ResourceBundle/Bug4168625Test.java
index 0c4c35ac6..1b2d2b509 100644
--- a/test/java/util/ResourceBundle/Bug4168625Test.java
+++ b/test/java/util/ResourceBundle/Bug4168625Test.java
@@ -427,9 +427,11 @@ public class Bug4168625Test extends RBTestFmwk {
private boolean network = false;
public SimpleLoader() {
+ super(SimpleLoader.class.getClassLoader());
this.network = false;
}
public SimpleLoader(boolean simulateNetworkLoad) {
+ super(SimpleLoader.class.getClassLoader());
this.network = simulateNetworkLoad;
}
public Class loadClass(final String className, final boolean resolveIt)
@@ -444,7 +446,7 @@ public class Bug4168625Test extends RBTestFmwk {
} catch (java.lang.InterruptedException e) {
}
}
- result = super.findSystemClass(className);
+ result = getParent().loadClass(className);
if ((result != null) && resolveIt) {
resolveClass(result);
}
@@ -460,11 +462,13 @@ public class Bug4168625Test extends RBTestFmwk {
private String[] classesToWaitFor;
public Loader() {
+ super(Loader.class.getClassLoader());
classesToLoad = new String[0];
classesToWaitFor = new String[0];
}
public Loader(final String[] classesToLoadIn, final String[] classesToWaitForIn) {
+ super(Loader.class.getClassLoader());
classesToLoad = classesToLoadIn;
classesToWaitFor = classesToWaitForIn;
}
@@ -540,10 +544,12 @@ public class Bug4168625Test extends RBTestFmwk {
}
/**
- * Delegate loading to the system loader
+ * Delegate loading to its parent class loader that loads the test classes.
+ * In othervm mode, the parent class loader is the system class loader;
+ * in samevm mode, the parent class loader is the jtreg URLClassLoader.
*/
private Class loadFromSystem(String className) throws ClassNotFoundException {
- return super.findSystemClass(className);
+ return getParent().loadClass(className);
}
public void logClasses(String title) {
diff --git a/test/java/util/ResourceBundle/Bug6359330.java b/test/java/util/ResourceBundle/Bug6359330.java
index 538ce9fc2..2755f3376 100644
--- a/test/java/util/ResourceBundle/Bug6359330.java
+++ b/test/java/util/ResourceBundle/Bug6359330.java
@@ -26,6 +26,7 @@
* @summary Make sure that getBundle doesn't cause a security error
* with a security manager when instantialing RBClassLoader (internal
* classloader).
+ * @run main/othervm Bug6359330
*/
import javax.xml.parsers.SAXParser;
diff --git a/test/java/util/ResourceBundle/Test4300693.java b/test/java/util/ResourceBundle/Test4300693.java
index d40b45b48..471c0c8cf 100644
--- a/test/java/util/ResourceBundle/Test4300693.java
+++ b/test/java/util/ResourceBundle/Test4300693.java
@@ -22,6 +22,7 @@
*/
/*
@test
+ @ignore 6876961
@summary test that ResourceBundle.getBundle can be called recursively
@build Test4300693RB
@run main Test4300693
diff --git a/test/java/util/ResourceBundle/TestBug4179766.java b/test/java/util/ResourceBundle/TestBug4179766.java
index 3546b1345..0c6a8b9bc 100644
--- a/test/java/util/ResourceBundle/TestBug4179766.java
+++ b/test/java/util/ResourceBundle/TestBug4179766.java
@@ -209,6 +209,7 @@ public class TestBug4179766 extends RBTestFmwk {
* Create a new loader
*/
public Loader(boolean sameHash) {
+ super(Loader.class.getClassLoader());
if (sameHash) {
thisHashCode = SAME_HASH_CODE;
} else {
@@ -287,7 +288,7 @@ public class TestBug4179766 extends RBTestFmwk {
*/
private Class loadFromSystem(String className) throws ClassNotFoundException {
try {
- Class result = super.findSystemClass(className);
+ Class result = getParent().loadClass(className);
printInfo(" ***Returning system class: "+className, result);
return result;
} catch (ClassNotFoundException e) {
diff --git a/test/java/util/logging/ParentLoggersTest.java b/test/java/util/logging/ParentLoggersTest.java
index 2f4a43442..1caacb30a 100644
--- a/test/java/util/logging/ParentLoggersTest.java
+++ b/test/java/util/logging/ParentLoggersTest.java
@@ -40,7 +40,19 @@ public class ParentLoggersTest {
static final String LOGGER_NAME_1 = PARENT_NAME_1 + ".myLogger";
static final String LOGGER_NAME_2 = PARENT_NAME_2 + ".myBar.myLogger";
+ static final List<String> initialLoggerNames = new ArrayList<String>();
public static void main(String args[]) throws Exception {
+ // cache the initial set of loggers before this test begins
+ // to add any loggers
+ Enumeration<String> e = logMgr.getLoggerNames();
+ List<String> defaultLoggers = getDefaultLoggerNames();
+ while (e.hasMoreElements()) {
+ String logger = e.nextElement();
+ if (!defaultLoggers.contains(logger)) {
+ initialLoggerNames.add(logger);
+ }
+ };
+
String tstSrc = System.getProperty(TST_SRC_PROP);
File fname = new File(tstSrc, LM_PROP_FNAME);
String prop = fname.getCanonicalPath();
@@ -56,12 +68,12 @@ public class ParentLoggersTest {
}
}
- public static Vector getDefaultLoggerNames() {
- Vector expectedLoggerNames = new Vector(0);
+ public static List<String> getDefaultLoggerNames() {
+ List<String> expectedLoggerNames = new ArrayList<String>();
// LogManager always creates two loggers:
- expectedLoggerNames.addElement(""); // root logger: ""
- expectedLoggerNames.addElement("global"); // global logger: "global"
+ expectedLoggerNames.add(""); // root logger: ""
+ expectedLoggerNames.add("global"); // global logger: "global"
return expectedLoggerNames;
}
@@ -71,7 +83,7 @@ public class ParentLoggersTest {
*/
public static boolean checkLoggers() {
String failMsg = "# checkLoggers: getLoggerNames() returned unexpected loggers";
- Vector expectedLoggerNames = getDefaultLoggerNames();
+ Vector<String> expectedLoggerNames = new Vector<String>(getDefaultLoggerNames());
// Create the logger LOGGER_NAME_1
Logger logger1 = Logger.getLogger(LOGGER_NAME_1);
@@ -83,18 +95,23 @@ public class ParentLoggersTest {
expectedLoggerNames.addElement(PARENT_NAME_2);
expectedLoggerNames.addElement(LOGGER_NAME_2);
- Enumeration returnedLoggersEnum = logMgr.getLoggerNames();
- Vector returnedLoggerNames = new Vector(0);
+ Enumeration<String> returnedLoggersEnum = logMgr.getLoggerNames();
+ Vector<String> returnedLoggerNames = new Vector<String>(0);
while (returnedLoggersEnum.hasMoreElements()) {
- returnedLoggerNames.addElement(returnedLoggersEnum.nextElement());
+ String logger = returnedLoggersEnum.nextElement();
+ if (!initialLoggerNames.contains(logger)) {
+ // filter out the loggers that have been added before this test runs
+ returnedLoggerNames.addElement(logger);
+ }
+
};
return checkNames(expectedLoggerNames, returnedLoggerNames, failMsg);
}
// Returns boolean values: PASSED or FAILED
- private static boolean checkNames(Vector expNames,
- Vector retNames,
+ private static boolean checkNames(Vector<String> expNames,
+ Vector<String> retNames,
String failMsg) {
boolean status = PASSED;
@@ -123,8 +140,8 @@ public class ParentLoggersTest {
return status;
}
- private static void printFailMsg(Vector expNames,
- Vector retNames,
+ private static void printFailMsg(Vector<String> expNames,
+ Vector<String> retNames,
String failMsg) {
out.println();
out.println(failMsg);
diff --git a/test/java/util/zip/InfoZip.java b/test/java/util/zip/InfoZip.java
index 86249b136..aea1d32dc 100644
--- a/test/java/util/zip/InfoZip.java
+++ b/test/java/util/zip/InfoZip.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -103,19 +103,25 @@ public class InfoZip {
os.close();
ZipFile zf = new ZipFile(f);
- Enumeration<? extends ZipEntry> entries = zf.entries();
- ZipEntry ze = entries.nextElement();
- check(! entries.hasMoreElements());
- checkZipEntry(ze, contents(zf, ze));
- zf.close();
+ ZipEntry ze = null;
+ try {
+ Enumeration<? extends ZipEntry> entries = zf.entries();
+ ze = entries.nextElement();
+ check(! entries.hasMoreElements());
+ checkZipEntry(ze, contents(zf, ze));
+ } finally {
+ zf.close();
+ }
ZipInputStream is = new ZipInputStream(new FileInputStream(f));
- ze = is.getNextEntry();
- checkZipEntry(ze, contents(is));
- check(is.getNextEntry() == null);
-
+ try {
+ ze = is.getNextEntry();
+ checkZipEntry(ze, contents(is));
+ check(is.getNextEntry() == null);
+ } finally {
+ is.close();
+ }
f.delete();
-
System.out.printf("passed = %d, failed = %d%n", passed, failed);
if (failed > 0) throw new Exception("Some tests failed");
}
diff --git a/test/java/util/zip/ZipFile/Comment.java b/test/java/util/zip/ZipFile/Comment.java
index db45dc876..d48cef208 100644
--- a/test/java/util/zip/ZipFile/Comment.java
+++ b/test/java/util/zip/ZipFile/Comment.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -58,13 +58,16 @@ public class Comment {
throws IOException
{
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(name));
- zos.setComment(comment);
- ZipEntry ze = new ZipEntry(entryName);
- ze.setMethod(ZipEntry.DEFLATED);
- zos.putNextEntry(ze);
- new DataOutputStream(zos).writeUTF(entryContents);
- zos.closeEntry();
- zos.close();
+ try {
+ zos.setComment(comment);
+ ZipEntry ze = new ZipEntry(entryName);
+ ze.setMethod(ZipEntry.DEFLATED);
+ zos.putNextEntry(ze);
+ new DataOutputStream(zos).writeUTF(entryContents);
+ zos.closeEntry();
+ } finally {
+ zos.close();
+ }
}
private static void verifyZipFile(String name, String comment)
@@ -91,6 +94,8 @@ public class Comment {
file.seek(file.length() - comment.length());
byte [] bytes = new byte [comment.length()];
file.readFully(bytes);
+ zipFile.close();
+ file.close();
if (! comment.equals(new String(bytes, "UTF8")))
throw new Exception("Zip file comment corrupted");
}
diff --git a/test/java/util/zip/ZipFile/CorruptedZipFiles.java b/test/java/util/zip/ZipFile/CorruptedZipFiles.java
index 55c102bdd..a53fdbee9 100644
--- a/test/java/util/zip/ZipFile/CorruptedZipFiles.java
+++ b/test/java/util/zip/ZipFile/CorruptedZipFiles.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,13 +47,14 @@ public class CorruptedZipFiles {
}
public static void main(String[] args) throws Exception {
- ZipOutputStream zos = new ZipOutputStream(
- new FileOutputStream("x.zip"));
- ZipEntry e = new ZipEntry("x");
- zos.putNextEntry(e);
- zos.write((int)'x');
- zos.close();
- zos = null;
+ ZipOutputStream zos = new ZipOutputStream(new FileOutputStream("x.zip"));
+ try {
+ ZipEntry e = new ZipEntry("x");
+ zos.putNextEntry(e);
+ zos.write((int)'x');
+ } finally {
+ zos.close();
+ }
int len = (int)(new File("x.zip").length());
byte[] good = new byte[len];
@@ -153,12 +154,15 @@ public class CorruptedZipFiles {
fos.write(data);
fos.close();
ZipFile zf = new ZipFile(zipName);
- if (getInputStream) {
- InputStream is = zf.getInputStream(new ZipEntry("x"));
- is.read();
+ try {
+ if (getInputStream) {
+ InputStream is = zf.getInputStream(new ZipEntry("x"));
+ is.read();
+ }
+ } finally {
+ zf.close();
}
fail("Failed to throw expected ZipException");
- zf.close();
} catch (ZipException e) {
if (e.getMessage().matches(msgPattern))
passed++;
diff --git a/test/java/util/zip/ZipFile/ManyEntries.java b/test/java/util/zip/ZipFile/ManyEntries.java
index cbd11f53f..4d36e7ac6 100644
--- a/test/java/util/zip/ZipFile/ManyEntries.java
+++ b/test/java/util/zip/ZipFile/ManyEntries.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,52 +55,58 @@ public class ManyEntries {
File zipFile = new File(++uniquifier + ".zip");
try {
zipFile.delete();
- ZipOutputStream zos =
- new ZipOutputStream(
- new BufferedOutputStream(
- new FileOutputStream(zipFile)));
- for (int i = 0; i < N; i++) {
- ZipEntry e = new ZipEntry("DIR/"+i);
- e.setMethod(method);
- e.setTime(time);
- if (method == ZipEntry.STORED) {
- e.setSize(1);
- crc32.reset();
- crc32.update((byte)i);
- e.setCrc(crc32.getValue());
- } else {
- e.setSize(0);
- e.setCrc(0);
+ ZipOutputStream zos = new ZipOutputStream(
+ new BufferedOutputStream(
+ new FileOutputStream(zipFile)));
+ try {
+ for (int i = 0; i < N; i++) {
+ ZipEntry e = new ZipEntry("DIR/"+i);
+ e.setMethod(method);
+ e.setTime(time);
+ if (method == ZipEntry.STORED) {
+ e.setSize(1);
+ crc32.reset();
+ crc32.update((byte)i);
+ e.setCrc(crc32.getValue());
+ } else {
+ e.setSize(0);
+ e.setCrc(0);
+ }
+ zos.putNextEntry(e);
+ zos.write(i);
}
- zos.putNextEntry(e);
- zos.write(i);
+ } finally {
+ zos.close();
+ zos = null;
}
- zos.close();
- zos = null;
- ZipFile zip = new ZipFile(zipFile);
- if (! (zip.size() == N))
- throw new Exception("Bad ZipFile size: " + zip.size());
- Enumeration entries = zip.entries();
+ ZipFile zip = zip = new ZipFile(zipFile);
+ try {
+ if (! (zip.size() == N))
+ throw new Exception("Bad ZipFile size: " + zip.size());
+ Enumeration entries = zip.entries();
- for (int i = 0; i < N; i++) {
- if (i % 1000 == 0) {System.gc(); System.runFinalization();}
- if (! (entries.hasMoreElements()))
- throw new Exception("only " + i + " elements");
- ZipEntry e = (ZipEntry)entries.nextElement();
- if (! (e.getSize() == 1))
- throw new Exception("bad size: " + e.getSize());
- if (! (e.getName().equals("DIR/" + i)))
- throw new Exception("bad name: " + i);
- if (! (e.getMethod() == method))
- throw new Exception("getMethod="+e.getMethod()+", method=" + method);
- if (! (e.getTime() == time))
- throw new Exception("getTime="+e.getTime()+", time=" + time);
- if (! (zip.getInputStream(e).read() == (i & 0xff)))
- throw new Exception("Bad file contents: " + i);
+ for (int i = 0; i < N; i++) {
+ if (i % 1000 == 0) {System.gc(); System.runFinalization();}
+ if (! (entries.hasMoreElements()))
+ throw new Exception("only " + i + " elements");
+ ZipEntry e = (ZipEntry)entries.nextElement();
+ if (! (e.getSize() == 1))
+ throw new Exception("bad size: " + e.getSize());
+ if (! (e.getName().equals("DIR/" + i)))
+ throw new Exception("bad name: " + i);
+ if (! (e.getMethod() == method))
+ throw new Exception("getMethod="+e.getMethod()+", method=" + method);
+ if (! (e.getTime() == time))
+ throw new Exception("getTime="+e.getTime()+", time=" + time);
+ if (! (zip.getInputStream(e).read() == (i & 0xff)))
+ throw new Exception("Bad file contents: " + i);
+ }
+ if (entries.hasMoreElements())
+ throw new Exception("too many elements");
+ } finally {
+ zip.close();
}
- if (entries.hasMoreElements())
- throw new Exception("too many elements");
}
finally {
zipFile.delete();
diff --git a/test/sun/jvmstat/testlibrary/utils.sh b/test/sun/jvmstat/testlibrary/utils.sh
index fc27e1c65..a2e4608da 100644
--- a/test/sun/jvmstat/testlibrary/utils.sh
+++ b/test/sun/jvmstat/testlibrary/utils.sh
@@ -189,3 +189,37 @@ kill_proc_common() {
echo "Error sending term signal to ${kpid}!"
fi
}
+
+# check to see if a port is free
+checkPort() # port
+{
+ inuse=`netstat -a | egrep "\.$1"`
+ if [ "${inuse}" = "" ] ; then
+ echo "free"
+ else
+ echo "inuse"
+ fi
+}
+
+# Get a free port, where port+1 is also free, return 0 when giving up
+freePort()
+{
+ start=3000
+ while [ ${start} -lt 3030 ] ; do
+ port1=`expr ${start} '+' $$ '%' 1000`
+ port2=`expr ${port1} '+' 1`
+ if [ "`checkPort ${port1}`" = "inuse" \
+ -o "`checkPort ${port2}`" = "inuse" ] ; then
+ start=`expr ${start} '+' 1`
+ else
+ break
+ fi
+ done
+ if [ "`checkPort ${port1}`" = "inuse" \
+ -o "`checkPort ${port2}`" = "inuse" ] ; then
+ port1="0"
+ fi
+ echo "${port1}"
+}
+
+
diff --git a/test/sun/security/krb5/auto/Context.java b/test/sun/security/krb5/auto/Context.java
index 60fa61a3b..14ba827e3 100644
--- a/test/sun/security/krb5/auto/Context.java
+++ b/test/sun/security/krb5/auto/Context.java
@@ -42,6 +42,7 @@ import org.ietf.jgss.Oid;
import com.sun.security.jgss.ExtendedGSSContext;
import com.sun.security.jgss.InquireType;
import com.sun.security.jgss.AuthorizationDataEntry;
+import java.io.File;
/**
* Context of a JGSS subject, encapsulating Subject and GSSContext.
@@ -107,7 +108,8 @@ public class Context {
* Logins with a username and a password, using Krb5LoginModule directly
* @param storeKey true if key should be saved, used on acceptor side
*/
- public static Context fromUserPass(String user, char[] pass, boolean storeKey) throws Exception {
+ public static Context fromUserPass(String user, char[] pass, boolean storeKey)
+ throws Exception {
Context out = new Context();
out.name = user;
out.s = new Subject();
@@ -137,6 +139,33 @@ public class Context {
}
/**
+ * Logins with a username and a keytab, using Krb5LoginModule directly
+ * @param storeKey true if key should be saved, used on acceptor side
+ */
+ public static Context fromUserKtab(String user, String ktab, boolean storeKey)
+ throws Exception {
+ Context out = new Context();
+ out.name = user;
+ out.s = new Subject();
+ Krb5LoginModule krb5 = new Krb5LoginModule();
+ Map<String, String> map = new HashMap<String, String>();
+
+ map.put("doNotPrompt", "true");
+ map.put("useTicketCache", "false");
+ map.put("useKeyTab", "true");
+ map.put("keyTab", ktab);
+ map.put("principal", user);
+ if (storeKey) {
+ map.put("storeKey", "true");
+ }
+
+ krb5.initialize(out.s, null, null, map);
+ krb5.login();
+ krb5.commit();
+ return out;
+ }
+
+ /**
* Starts as a client
* @param target communication peer
* @param mech GSS mech
diff --git a/test/sun/security/krb5/auto/KDC.java b/test/sun/security/krb5/auto/KDC.java
index 9e4fe5201..6aca26c7f 100644
--- a/test/sun/security/krb5/auto/KDC.java
+++ b/test/sun/security/krb5/auto/KDC.java
@@ -35,6 +35,7 @@ import sun.net.spi.nameservice.NameServiceDescriptor;
import sun.security.krb5.*;
import sun.security.krb5.internal.*;
import sun.security.krb5.internal.ccache.CredentialsCache;
+import sun.security.krb5.internal.crypto.EType;
import sun.security.krb5.internal.crypto.KeyUsage;
import sun.security.krb5.internal.ktab.KeyTab;
import sun.security.util.DerInputStream;
@@ -153,6 +154,14 @@ public class KDC {
* Whether pre-authentication is required. Default Boolean.TRUE
*/
PREAUTH_REQUIRED,
+ /**
+ * Only issue TGT in RC4
+ */
+ ONLY_RC4_TGT,
+ /**
+ * Only use RC4 in preauth, enc-type still using eTypes[0]
+ */
+ ONLY_RC4_PREAUTH,
};
static {
@@ -743,13 +752,25 @@ public class KDC {
Field f = KDCReqBody.class.getDeclaredField("eType");
f.setAccessible(true);
eTypes = (int[])f.get(body);
- if (eTypes.length < 2) {
- throw new KrbException(Krb5.KDC_ERR_ETYPE_NOSUPP);
- }
int eType = eTypes[0];
EncryptionKey ckey = keyForUser(body.cname, eType, false);
EncryptionKey skey = keyForUser(body.sname, eType, true);
+
+ if (options.containsKey(KDC.Option.ONLY_RC4_TGT)) {
+ int tgtEType = EncryptedData.ETYPE_ARCFOUR_HMAC;
+ boolean found = false;
+ for (int i=0; i<eTypes.length; i++) {
+ if (eTypes[i] == tgtEType) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw new KrbException(Krb5.KDC_ERR_ETYPE_NOSUPP);
+ }
+ skey = keyForUser(body.sname, tgtEType, true);
+ }
if (ckey == null) {
throw new KrbException(Krb5.KDC_ERR_ETYPE_NOSUPP);
}
@@ -799,7 +820,8 @@ public class KDC {
Constructor<EncryptedData> ctor = EncryptedData.class.getDeclaredConstructor(DerValue.class);
ctor.setAccessible(true);
EncryptedData data = ctor.newInstance(new DerValue(pas[0].getValue()));
- data.decrypt(ckey, KeyUsage.KU_PA_ENC_TS);
+ EncryptionKey pakey = keyForUser(body.cname, data.getEType(), false);
+ data.decrypt(pakey, KeyUsage.KU_PA_ENC_TS);
} catch (Exception e) {
throw new KrbException(Krb5.KDC_ERR_PREAUTH_FAILED);
}
@@ -887,7 +909,11 @@ public class KDC {
ke.returnCode() == Krb5.KDC_ERR_PREAUTH_FAILED) {
PAData pa;
- ETypeInfo2 ei2 = new ETypeInfo2(eTypes[0], null, null);
+ int epa = eTypes[0];
+ if (options.containsKey(KDC.Option.ONLY_RC4_PREAUTH)) {
+ epa = EncryptedData.ETYPE_ARCFOUR_HMAC;
+ }
+ ETypeInfo2 ei2 = new ETypeInfo2(epa, null, null);
DerOutputStream eid = new DerOutputStream();
eid.write(DerValue.tag_Sequence, ei2.asn1Encode());
@@ -906,7 +932,7 @@ public class KDC {
}
}
if (allOld) {
- ETypeInfo ei = new ETypeInfo(eTypes[0], null);
+ ETypeInfo ei = new ETypeInfo(epa, null);
eid = new DerOutputStream();
eid.write(DerValue.tag_Sequence, ei.asn1Encode());
pa = new PAData(Krb5.PA_ETYPE_INFO, eid.toByteArray());
diff --git a/test/sun/security/krb5/auto/W83.java b/test/sun/security/krb5/auto/W83.java
new file mode 100644
index 000000000..a0951cad2
--- /dev/null
+++ b/test/sun/security/krb5/auto/W83.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6932525 6951366 6959292
+ * @summary kerberos login failure on win2008 with AD set to win2000 compat mode
+ * and cannot login if session key and preauth does not use the same etype
+ */
+import com.sun.security.auth.module.Krb5LoginModule;
+import java.io.File;
+import sun.security.krb5.Config;
+import sun.security.krb5.EncryptedData;
+import sun.security.krb5.PrincipalName;
+import sun.security.krb5.internal.crypto.EType;
+import sun.security.krb5.internal.ktab.KeyTab;
+
+public class W83 {
+ public static void main(String[] args) throws Exception {
+
+ W83 x = new W83();
+
+ // Cannot use OneKDC. kinit command cannot resolve
+ // hostname kdc.rabbit.hole
+ KDC kdc = new KDC(OneKDC.REALM, "127.0.0.1", 0, true);
+ kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
+ kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
+ KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
+ System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
+ Config.refresh();
+
+ kdc.writeKtab(OneKDC.KTAB);
+ new File(OneKDC.KRB5_CONF).deleteOnExit();
+ new File(OneKDC.KTAB).deleteOnExit();
+
+ KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB);
+ for (int etype: EType.getBuiltInDefaults()) {
+ if (etype != EncryptedData.ETYPE_ARCFOUR_HMAC) {
+ ktab.deleteEntry(new PrincipalName(OneKDC.USER), etype);
+ }
+ }
+ ktab.save();
+
+ // For 6932525 and 6951366, make sure the etypes sent in 2nd AS-REQ
+ // is not restricted to that of preauth
+ kdc.setOption(KDC.Option.ONLY_RC4_TGT, true);
+ x.go();
+
+ // For 6959292, make sure that when etype for enc-part in 2nd AS-REQ
+ // is different from that of preauth, client can still decrypt it
+ kdc.setOption(KDC.Option.ONLY_RC4_PREAUTH, true);
+ x.go();
+ }
+
+ void go() throws Exception {
+ Krb5LoginModule krb5 = new Krb5LoginModule();
+ StringBuffer error = new StringBuffer();
+ try {
+ Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
+ } catch (Exception e) {
+ error.append("Krb5LoginModule password login error\n");
+ }
+ try {
+ Context.fromUserKtab(OneKDC.USER, OneKDC.KTAB, false);
+ } catch (Exception e) {
+ error.append("Krb5LoginModule keytab login error\n");
+ }
+ try {
+ Class.forName("sun.security.krb5.internal.tools.Kinit");
+ String cmd = System.getProperty("java.home") +
+ System.getProperty("file.separator") +
+ "bin" +
+ System.getProperty("file.separator") +
+ "kinit";
+
+ int p = execute(
+ cmd,
+ "-J-Djava.security.krb5.conf=" + OneKDC.KRB5_CONF,
+ "-c", "cache1",
+ OneKDC.USER,
+ new String(OneKDC.PASS));
+ if (p != 0) {
+ error.append("kinit password login error\n");
+ }
+ p = execute(
+ cmd,
+ "-J-Djava.security.krb5.conf=" + OneKDC.KRB5_CONF,
+ "-c", "cache2",
+ "-k", "-t", OneKDC.KTAB,
+ OneKDC.USER);
+ if (p != 0) {
+ error.append("kinit keytab login error\n");
+ }
+ } catch (ClassNotFoundException cnfe) {
+ System.out.println("No kinit, test ignored.");
+ // Ignore, not on windows
+ }
+ if (error.length() != 0) {
+ throw new Exception(error.toString());
+ }
+ }
+
+ private static int execute(String... args) throws Exception {
+ for (String arg: args) {
+ System.out.printf("%s ", arg);
+ }
+ System.out.println();
+ Process p = Runtime.getRuntime().exec(args);
+ return p.waitFor();
+ }
+}
diff --git a/test/sun/security/validator/CertReplace.java b/test/sun/security/validator/CertReplace.java
index e2a1a1bfe..e858cc765 100644
--- a/test/sun/security/validator/CertReplace.java
+++ b/test/sun/security/validator/CertReplace.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
* 2 along 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.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
*/
/*
@@ -37,25 +37,28 @@ import sun.security.validator.Validator;
public class CertReplace {
- private final static String cacerts = "certreplace.jks";
- private final static String certs = "certreplace.certs";
-
+ /**
+ * @param args {cacerts keystore, cert chain}
+ */
public static void main(String[] args) throws Exception {
KeyStore ks = KeyStore.getInstance("JKS");
- ks.load(new FileInputStream(cacerts), "changeit".toCharArray());
+ ks.load(new FileInputStream(args[0]), "changeit".toCharArray());
Validator v = Validator.getInstance
(Validator.TYPE_PKIX, Validator.VAR_GENERIC, ks);
- X509Certificate[] chain = createPath();
- System.out.println(Arrays.toString(v.validate(chain)));
-
+ X509Certificate[] chain = createPath(args[1]);
+ System.out.println("Chain: ");
+ for (X509Certificate c: v.validate(chain)) {
+ System.out.println(" " + c.getSubjectX500Principal() +
+ " issued by " + c.getIssuerX500Principal());
+ }
}
- public static X509Certificate[] createPath() throws Exception {
+ public static X509Certificate[] createPath(String chain) throws Exception {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
List list = new ArrayList();
for (Certificate c: cf.generateCertificates(
- new FileInputStream(certs))) {
+ new FileInputStream(chain))) {
list.add((X509Certificate)c);
}
return (X509Certificate[]) list.toArray(new X509Certificate[0]);
diff --git a/test/sun/security/validator/certreplace.sh b/test/sun/security/validator/certreplace.sh
index af5ed1c54..16470a399 100644
--- a/test/sun/security/validator/certreplace.sh
+++ b/test/sun/security/validator/certreplace.sh
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
# 2 along 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.
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
#
# @test
@@ -82,4 +82,4 @@ $KT -delete -alias user
# 5. Build and run test
$JAVAC -d . ${TESTSRC}${FS}CertReplace.java
-$JAVA CertReplace
+$JAVA CertReplace certreplace.jks certreplace.certs
diff --git a/test/sun/security/validator/samedn.sh b/test/sun/security/validator/samedn.sh
new file mode 100644
index 000000000..9d5afd40a
--- /dev/null
+++ b/test/sun/security/validator/samedn.sh
@@ -0,0 +1,82 @@
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# @test
+# @bug 6958869
+# @summary regression: PKIXValidator fails when multiple trust anchors
+# have same dn
+#
+
+if [ "${TESTSRC}" = "" ] ; then
+ TESTSRC="."
+fi
+if [ "${TESTJAVA}" = "" ] ; then
+ JAVAC_CMD=`which javac`
+ TESTJAVA=`dirname $JAVAC_CMD`/..
+fi
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+ Windows_* )
+ FS="\\"
+ ;;
+ * )
+ FS="/"
+ ;;
+esac
+
+KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit \
+ -keypass changeit -keystore samedn.jks"
+JAVAC=$TESTJAVA${FS}bin${FS}javac
+JAVA=$TESTJAVA${FS}bin${FS}java
+
+rm -rf samedn.jks 2> /dev/null
+
+# 1. Generate 3 aliases in a keystore: ca1, ca2, user. The CAs' startdate
+# is set to one year ago so that they are expired now
+
+$KT -genkeypair -alias ca1 -dname CN=CA -keyalg rsa -sigalg md5withrsa -ext bc -startdate -1y
+$KT -genkeypair -alias ca2 -dname CN=CA -keyalg rsa -sigalg sha1withrsa -ext bc -startdate -1y
+$KT -genkeypair -alias user -dname CN=User -keyalg rsa
+
+# 2. Signing: ca -> user
+
+$KT -certreq -alias user | $KT -gencert -rfc -alias ca1 > samedn1.certs
+$KT -certreq -alias user | $KT -gencert -rfc -alias ca2 > samedn2.certs
+
+# 3. Append the ca file
+
+$KT -export -rfc -alias ca1 >> samedn1.certs
+$KT -export -rfc -alias ca2 >> samedn2.certs
+
+# 4. Remove user for cacerts
+
+$KT -delete -alias user
+
+# 5. Build and run test. Make sure the CA certs are ignored for validity check.
+# Check both, one of them might be dropped out of map in old codes.
+
+$JAVAC -d . ${TESTSRC}${FS}CertReplace.java
+$JAVA CertReplace samedn.jks samedn1.certs || exit 1
+$JAVA CertReplace samedn.jks samedn2.certs || exit 2
diff --git a/test/sun/tools/jps/jps-Vvml_2.sh b/test/sun/tools/jps/jps-Vvml_2.sh
index 96f867828..83f9a0524 100644
--- a/test/sun/tools/jps/jps-Vvml_2.sh
+++ b/test/sun/tools/jps/jps-Vvml_2.sh
@@ -51,3 +51,9 @@ ${JAVA} -cp ${TESTCLASSES} Sleeper &
SLEEPER_PID=$!
${JPS} -J-XX:Flags=${TESTSRC}/vmflags -Vvml | awk -f ${TESTSRC}/jps-Vvml_Output2.awk
+RC=$?
+
+cleanup
+
+exit ${RC}
+
diff --git a/test/sun/tools/jps/jps-m_2.sh b/test/sun/tools/jps/jps-m_2.sh
index 2846ff32d..afa045180 100644
--- a/test/sun/tools/jps/jps-m_2.sh
+++ b/test/sun/tools/jps/jps-m_2.sh
@@ -50,3 +50,9 @@ ${JAVA} -cp ${TESTCLASSES} Sleeper &
SLEEPER_PID=$!
${JPS} -m | awk -f ${TESTSRC}/jps-m_Output2.awk
+RC=$?
+
+cleanup
+
+exit ${RC}
+
diff --git a/test/sun/tools/jstat/classloadOutput1.awk b/test/sun/tools/jstat/classloadOutput1.awk
new file mode 100644
index 000000000..66e2b5dcd
--- /dev/null
+++ b/test/sun/tools/jstat/classloadOutput1.awk
@@ -0,0 +1,31 @@
+#
+# matching the following output specified as a pattern that verifies
+# that the numerical values conform to a specific pattern, rather than
+# specific values.
+#
+# Loaded Time Inited Time Shared Kbytes LoadTime SysClass Kbytes LoadTime Lookup Parse Linked Time Verified Time AppClass Kbytes AppCL DefineClass Time FindClass Time Delegation URLCL Read
+# 956 0.115 777 0.032 0 0.0 0.000 956 3437.5 0.085 0.013 0.045 918 0.032 917 0.011 13 1.0 0.003 1 0.000 1 0.004 0.005 0.000
+#
+
+BEGIN {
+ headerlines=0; datalines=0; totallines=0
+ }
+
+/^Loaded Time Inited Time Shared Kbytes LoadTime SysClass Kbytes LoadTime Lookup Parse Linked Time Verified Time AppClass Kbytes AppCL DefineClass Time FindClass Time Delegation URLCL Read$/ {
+ headerlines++;
+ }
+
+/^[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9][ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9][ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9][ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ {
+ datalines++;
+ }
+
+ { totallines++; print $0 }
+
+END {
+ if ((headerlines == 1) && (datalines == 1) && (totallines == 2)) {
+ exit 0
+ }
+ else {
+ exit 1
+ }
+ }
diff --git a/test/sun/tools/jstat/jstatClassloadOutput1.sh b/test/sun/tools/jstat/jstatClassloadOutput1.sh
new file mode 100644
index 000000000..42e5bf1b0
--- /dev/null
+++ b/test/sun/tools/jstat/jstatClassloadOutput1.sh
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# @test
+# @bug 6959965
+# @run shell jstatClassloadOutput1.sh
+# @summary Test that output of 'jstat -classload 0' has expected line counts
+
+. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
+
+setup
+verify_os
+
+JSTAT="${TESTJAVA}/bin/jstat"
+
+${JSTAT} -classload -J-Djstat.showUnsupported=true 0 2>&1 | awk -f ${TESTSRC}/classloadOutput1.awk
diff --git a/test/sun/tools/jstat/jstatOptions1.sh b/test/sun/tools/jstat/jstatOptions1.sh
index c8d012003..af9367f79 100644
--- a/test/sun/tools/jstat/jstatOptions1.sh
+++ b/test/sun/tools/jstat/jstatOptions1.sh
@@ -32,7 +32,9 @@ setup
JSTAT="${TESTJAVA}/bin/jstat"
-rm -f jstat.out 2>/dev/null
-${JSTAT} -options > jstat.out 2>&1
+rm -f jstat.out1 jstat.out2 2>/dev/null
+${JSTAT} -options > jstat.out1 2>&1
+${JSTAT} -options -J-Djstat.showUnsupported=true > jstat.out2 2>&1
-diff -w jstat.out ${TESTSRC}/options1.out
+diff -w jstat.out1 ${TESTSRC}/options1.out
+diff -w jstat.out2 ${TESTSRC}/options2.out
diff --git a/test/sun/tools/jstat/options2.out b/test/sun/tools/jstat/options2.out
new file mode 100644
index 000000000..5d05d60f0
--- /dev/null
+++ b/test/sun/tools/jstat/options2.out
@@ -0,0 +1,13 @@
+-class
+-classload
+-compiler
+-gc
+-gccapacity
+-gccause
+-gcnew
+-gcnewcapacity
+-gcold
+-gcoldcapacity
+-gcpermcapacity
+-gcutil
+-printcompilation
diff --git a/test/sun/tools/jstatd/jstatdDefaults.sh b/test/sun/tools/jstatd/jstatdDefaults.sh
index 1e25137e2..34b218011 100644
--- a/test/sun/tools/jstatd/jstatdDefaults.sh
+++ b/test/sun/tools/jstatd/jstatdDefaults.sh
@@ -56,12 +56,11 @@ ${JPS} ${HOSTNAME} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
if [ $? -ne 0 ]
then
echo "Output of jps differs from expected output. Failed."
+ cleanup
exit 1
fi
-TARGET_PID=`${JPS} | grep "Jstatd" | cut -d" " -f1`
-
-${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+${JSTAT} -gcutil ${JSTATD_PID}@${HOSTNAME} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
RC=$?
if [ ${RC} -ne 0 ]
@@ -75,4 +74,6 @@ then
RC=1
fi
+cleanup
+
exit ${RC}
diff --git a/test/sun/tools/jstatd/jstatdExternalRegistry.sh b/test/sun/tools/jstatd/jstatdExternalRegistry.sh
index ce5236819..3385c821e 100644
--- a/test/sun/tools/jstatd/jstatdExternalRegistry.sh
+++ b/test/sun/tools/jstatd/jstatdExternalRegistry.sh
@@ -44,7 +44,11 @@ JPS="${TESTJAVA}/bin/jps"
JSTAT="${TESTJAVA}/bin/jstat"
HOSTNAME=`uname -n`
-PORT=2099
+PORT=`freePort`
+if [ "${PORT}" = "0" ] ; then
+ echo "Cannot get free port"
+ exit 1
+fi
RMIREGISTRY_OUT="rmiregistry_$$.out"
JSTATD_OUT="jstatd_$$.out"
@@ -69,12 +73,7 @@ then
exit 1
fi
-# get the process id for the target app (jstatd). note, don't rely
-# on JSTATD_PID as mks interposes a shell when starting a process in
-# the background
-TARGET_PID=`${JPS} | grep "Jstatd" | cut -d" " -f1`
-
-${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+${JSTAT} -gcutil ${JSTATD_PID}@${HOSTNAME}:${PORT} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
RC=$?
if [ ${RC} -ne 0 ]
diff --git a/test/sun/tools/jstatd/jstatdPort.sh b/test/sun/tools/jstatd/jstatdPort.sh
index 48bed6616..7e8f4455d 100644
--- a/test/sun/tools/jstatd/jstatdPort.sh
+++ b/test/sun/tools/jstatd/jstatdPort.sh
@@ -42,7 +42,11 @@ JPS="${TESTJAVA}/bin/jps"
JSTAT="${TESTJAVA}/bin/jstat"
HOSTNAME=`uname -n`
-PORT=2099
+PORT=`freePort`
+if [ "${PORT}" = "0" ] ; then
+ echo "Cannot get free port"
+ exit 1
+fi
JSTATD_OUT="jstatd_$$.out"
@@ -57,12 +61,11 @@ ${JPS} ${HOSTNAME}:${PORT} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
if [ $? -ne 0 ]
then
echo "Output of jps differs from expected output. Failed."
+ cleanup
exit 1
fi
-TARGET_PID=`${JPS} | grep "Jstatd" | cut -d" " -f1`
-
-${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+${JSTAT} -gcutil ${JSTATD_PID}@${HOSTNAME}:${PORT} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
RC=$?
if [ ${RC} -ne 0 ]
@@ -76,4 +79,6 @@ then
RC=1
fi
+cleanup
+
exit ${RC}
diff --git a/test/sun/tools/jstatd/jstatdServerName.sh b/test/sun/tools/jstatd/jstatdServerName.sh
index 4215035d3..723a26c2e 100644
--- a/test/sun/tools/jstatd/jstatdServerName.sh
+++ b/test/sun/tools/jstatd/jstatdServerName.sh
@@ -43,8 +43,12 @@ JPS="${TESTJAVA}/bin/jps"
JSTAT="${TESTJAVA}/bin/jstat"
HOSTNAME=`uname -n`
-PORT_1=2098
-PORT_2=2099
+PORT_1=`freePort`
+if [ "${PORT_1}" = "0" ] ; then
+ echo "ERROR: No free port"
+ exit 1
+fi
+PORT_2=`expr ${PORT_1} '+' 1`
SERVERNAME="SecondJstatdServer"
JSTATD_1_OUT="jstatd_$$_1.out"
@@ -68,6 +72,7 @@ ${JPS} ${HOSTNAME}:${PORT_1} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk
if [ $? -ne 0 ]
then
echo "Output of jps differs from expected output. Failed."
+ cleanup
exit 1
fi
@@ -77,13 +82,12 @@ ${JPS} ${HOSTNAME}:${PORT_2}/${SERVERNAME} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.a
if [ $? -ne 0 ]
then
echo "Output of jps differs from expected output. Failed."
+ cleanup
exit 1
fi
-TARGET_PID=`${JPS} | grep "Jstatd" | cut -d" " -f1 | head -1`
-
-echo "running: ${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT_1} 250 5"
-${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT_1} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+echo "running: ${JSTAT} -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_1} 250 5"
+${JSTAT} -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_1} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
RC=$?
if [ ${RC} -ne 0 ]
@@ -91,8 +95,8 @@ then
echo "jstat output differs from expected output"
fi
-echo "running: ${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5"
-${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
+echo "running: ${JSTAT} -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5"
+${JSTAT} -gcutil ${JSTATD_1_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk
RC=$?
if [ ${RC} -ne 0 ]
@@ -112,4 +116,6 @@ then
RC=1
fi
+cleanup
+
exit ${RC}
diff --git a/test/tools/jar/UpdateManifest.java b/test/tools/jar/UpdateManifest.java
index f2b5ca4e3..2bcd25081 100644
--- a/test/tools/jar/UpdateManifest.java
+++ b/test/tools/jar/UpdateManifest.java
@@ -143,6 +143,7 @@ public class UpdateManifest {
} else {
fail("did not match specVersion nor specTitle");
}
+ zf.close();
}
// --------------------- Convenience ---------------------------
diff --git a/test/tools/jar/index/MetaInf.java b/test/tools/jar/index/MetaInf.java
index 2ffaa4afb..ea62e2ba7 100644
--- a/test/tools/jar/index/MetaInf.java
+++ b/test/tools/jar/index/MetaInf.java
@@ -62,7 +62,13 @@ public class MetaInf {
static boolean contains(File jarFile, String entryName)
throws IOException {
- return new ZipFile(jarFile).getEntry(entryName) != null;
+ ZipFile zf = new ZipFile(jarFile);
+ if ( zf != null ) {
+ boolean result = zf.getEntry(entryName) != null;
+ zf.close();
+ return result;
+ }
+ return false;
}
static void checkContains(File jarFile, String entryName)
@@ -94,9 +100,13 @@ public class MetaInf {
String line;
while ((line = index.readLine()) != null) {
if (line.equals(SERVICES)) {
+ index.close();
+ f.close();
return;
}
}
+ index.close();
+ f.close();
throw new Error(SERVICES + " not indexed.");
}
diff --git a/test/tools/pack200/Pack200Test.java b/test/tools/pack200/Pack200Test.java
index ec0489af3..631b50709 100644
--- a/test/tools/pack200/Pack200Test.java
+++ b/test/tools/pack200/Pack200Test.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2010 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,8 @@ import java.util.zip.*;
*/
public class Pack200Test {
- private static ArrayList <File> jarList = new ArrayList();
- private static final String PACKEXT = ".pack";
+ private static ArrayList <File> jarList = new ArrayList<File>();
+ static final String PACKEXT = ".pack";
/** Creates a new instance of Pack200Test */
private Pack200Test() {}
@@ -48,7 +48,7 @@ public class Pack200Test {
private static void doPackUnpack() {
for (File in : jarList) {
Pack200.Packer packer = Pack200.newPacker();
- Map p = packer.properties();
+ Map<String, String> p = packer.properties();
// Take the time optimization vs. space
p.put(packer.EFFORT, "1"); // CAUTION: do not use 0.
// Make the memory consumption as effective as possible
@@ -96,7 +96,7 @@ public class Pack200Test {
}
private static ArrayList <String> getZipFileEntryNames(ZipFile z) {
- ArrayList <String> out = new ArrayList();
+ ArrayList <String> out = new ArrayList<String>();
for (ZipEntry ze : Collections.list(z.entries())) {
out.add(ze.getName());
}
diff --git a/test/tools/pack200/PackageVersionTest.java b/test/tools/pack200/PackageVersionTest.java
new file mode 100644
index 000000000..0cd9ca264
--- /dev/null
+++ b/test/tools/pack200/PackageVersionTest.java
@@ -0,0 +1,169 @@
+
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6712743
+ * @summary verify package versioning
+ * @compile -XDignore.symbol.file PackageVersionTest.java
+ * @run main PackageVersionTest
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.jar.JarFile;
+import java.util.jar.Pack200;
+import java.util.jar.Pack200.Packer;
+
+public class PackageVersionTest {
+ private static final File javaHome = new File(System.getProperty("java.home"));
+
+ public final static int JAVA5_PACKAGE_MAJOR_VERSION = 150;
+ public final static int JAVA5_PACKAGE_MINOR_VERSION = 7;
+
+ public final static int JAVA6_PACKAGE_MAJOR_VERSION = 160;
+ public final static int JAVA6_PACKAGE_MINOR_VERSION = 1;
+
+ public static void main(String... args) {
+ if (!javaHome.getName().endsWith("jre")) {
+ throw new RuntimeException("Error: requires an SDK to run");
+ }
+
+ File out = new File("test.pack");
+ createClassFile("Test5");
+ createClassFile("Test6");
+ createClassFile("Test7");
+
+ verifyPack("Test5.class", JAVA5_PACKAGE_MAJOR_VERSION,
+ JAVA5_PACKAGE_MINOR_VERSION);
+
+ verifyPack("Test6.class", JAVA6_PACKAGE_MAJOR_VERSION,
+ JAVA6_PACKAGE_MINOR_VERSION);
+
+ // TODO: change this to the java7 package version as needed.
+ verifyPack("Test7.class", JAVA6_PACKAGE_MAJOR_VERSION,
+ JAVA6_PACKAGE_MINOR_VERSION);
+
+ // test for resource file, ie. no class files
+ verifyPack("Test6.java", JAVA5_PACKAGE_MAJOR_VERSION,
+ JAVA5_PACKAGE_MINOR_VERSION);
+ }
+
+ static void close(Closeable c) {
+ if (c == null) {
+ return;
+ }
+ try {
+ c.close();
+ } catch (IOException ignore) {}
+ }
+
+ static void createClassFile(String name) {
+ createJavaFile(name);
+ String target = name.substring(name.length() - 1);
+ String javacCmds[] = {
+ "-source",
+ "5",
+ "-target",
+ name.substring(name.length() - 1),
+ name + ".java"
+ };
+ compileJava(javacCmds);
+ }
+
+ static void createJavaFile(String name) {
+ PrintStream ps = null;
+ FileOutputStream fos = null;
+ File outputFile = new File(name + ".java");
+ outputFile.delete();
+ try {
+ fos = new FileOutputStream(outputFile);
+ ps = new PrintStream(fos);
+ ps.format("public class %s {}", name);
+ } catch (IOException ioe) {
+ throw new RuntimeException("creation of test file failed");
+ } finally {
+ close(ps);
+ close(fos);
+ }
+ }
+
+ static void compileJava(String... javacCmds) {
+ if (com.sun.tools.javac.Main.compile(javacCmds) != 0) {
+ throw new RuntimeException("compilation failed");
+ }
+ }
+
+ static void makeJar(String... jargs) {
+ sun.tools.jar.Main jarTool =
+ new sun.tools.jar.Main(System.out, System.err, "jartool");
+ if (!jarTool.run(jargs)) {
+ throw new RuntimeException("jar command failed");
+ }
+ }
+
+ static void verifyPack(String filename, int expected_major, int expected_minor) {
+
+ File jarFileName = new File("test.jar");
+ jarFileName.delete();
+ String jargs[] = {
+ "cvf",
+ jarFileName.getName(),
+ filename
+ };
+ makeJar(jargs);
+ JarFile jfin = null;
+
+ try {
+ jfin = new JarFile(jarFileName);
+ Packer packer = Pack200.newPacker();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ packer.pack(jfin, baos);
+ baos.flush();
+ baos.close();
+ byte[] buf = baos.toByteArray();
+
+ int minor = buf[4] & 0x000000ff;
+ int major = buf[5] & 0x000000ff;
+
+ if (major != expected_major || minor != expected_minor) {
+ String msg =
+ String.format("test fails: expected:%d.%d but got %d.%d\n",
+ expected_major, expected_minor,
+ major, minor);
+ throw new Error(msg);
+ }
+
+ System.out.println(filename + ": OK");
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe.getMessage());
+ } finally {
+ close(jfin);
+ }
+ }
+}
diff --git a/test/tools/pack200/SegmentLimit.java b/test/tools/pack200/SegmentLimit.java
new file mode 100644
index 000000000..249e47b03
--- /dev/null
+++ b/test/tools/pack200/SegmentLimit.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6575373
+ * @summary verify default segment limit
+ * @compile SegmentLimit.java
+ * @run main SegmentLimit
+ */
+
+import java.io.BufferedReader;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+
+/*
+ * Run this against a large jar file, by default the packer should generate only
+ * one segment, parse the output of the packer to verify if this is indeed true.
+ */
+
+public class SegmentLimit {
+
+ private static final File javaHome = new File(System.getProperty("java.home"));
+
+ public static void main(String... args) {
+ if (!javaHome.getName().endsWith("jre")) {
+ throw new RuntimeException("Error: requires an SDK to run");
+ }
+
+ File out = new File("test" + Pack200Test.PACKEXT);
+ out.delete();
+ runPack200(out);
+ }
+
+ static void close(Closeable c) {
+ if (c == null) {
+ return;
+ }
+ try {
+ c.close();
+ } catch (IOException ignore) {}
+ }
+
+ static void runPack200(File outFile) {
+ File binDir = new File(javaHome, "bin");
+ File pack200Exe = System.getProperty("os.name").startsWith("Windows")
+ ? new File(binDir, "pack200.exe")
+ : new File(binDir, "pack200");
+ File sdkHome = javaHome.getParentFile();
+ File testJar = new File(new File(sdkHome, "lib"), "tools.jar");
+
+ System.out.println("using pack200: " + pack200Exe.getAbsolutePath());
+
+ String[] cmds = { pack200Exe.getAbsolutePath(),
+ "--effort=1",
+ "--verbose",
+ "--no-gzip",
+ outFile.getName(),
+ testJar.getAbsolutePath()
+ };
+ InputStream is = null;
+ BufferedReader br = null;
+ InputStreamReader ir = null;
+
+ FileOutputStream fos = null;
+ PrintStream ps = null;
+
+ try {
+ ProcessBuilder pb = new ProcessBuilder(cmds);
+ pb.redirectErrorStream(true);
+ Process p = pb.start();
+ is = p.getInputStream();
+ ir = new InputStreamReader(is);
+ br = new BufferedReader(ir);
+
+ File logFile = new File("pack200.log");
+ fos = new FileOutputStream(logFile);
+ ps = new PrintStream(fos);
+
+ String line = br.readLine();
+ int count = 0;
+ while (line != null) {
+ line = line.trim();
+ if (line.matches(".*Transmitted.*files of.*input bytes in a segment of.*bytes")) {
+ count++;
+ }
+ ps.println(line);
+ line=br.readLine();
+ }
+ p.waitFor();
+ if (p.exitValue() != 0) {
+ throw new RuntimeException("pack200 failed");
+ }
+ p.destroy();
+ if (count > 1) {
+ throw new Error("test fails: check for multiple segments(" +
+ count + ") in: " + logFile.getAbsolutePath());
+ }
+ } catch (IOException ex) {
+ throw new RuntimeException(ex.getMessage());
+ } catch (InterruptedException ignore){
+ } finally {
+ close(is);
+ close(ps);
+ close(fos);
+ }
+ }
+}
+