diff --git a/make/common/Rules.gmk b/make/common/Rules.gmk index 041e1d20226d5146a8274c2053017ba80aaa6b60..65eda677fc83e966b497b59fd8bed8c3edf9ced3 100644 --- a/make/common/Rules.gmk +++ b/make/common/Rules.gmk @@ -239,7 +239,7 @@ classes : $(CLASSES_INIT) .delete.classlist .compile.classlist $(CAT) $<.filtered; \ $(ECHO) "# Running javac: $$numfiles files; in $(CURDIR)"; \ $(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \ - $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \ + $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered && \ $(ECHO) "# javac finished"; \ fi @$(java-vm-cleanup) diff --git a/make/jprt.properties b/make/jprt.properties index e07910e18b927b7c3cbbdb446c3882b4e82fd29a..9fb29299805063071f4f7a493311d8508525c5d1 100644 --- a/make/jprt.properties +++ b/make/jprt.properties @@ -25,15 +25,15 @@ # Properties for jprt -# Release to build for +# Locked down to jdk8 jprt.tools.default.release=jdk8 # The different build flavors we want, we override here so we just get these 2 jprt.build.flavors=product,fastdebug # Standard list of jprt build targets for this source tree -jprt.build.targets= \ - solaris_sparc_5.10-{product|fastdebug}, \ +jprt.build.targets= \ + solaris_sparc_5.10-{product|fastdebug}, \ solaris_sparcv9_5.10-{product|fastdebug}, \ solaris_i586_5.10-{product|fastdebug}, \ solaris_x64_5.10-{product|fastdebug}, \ @@ -45,247 +45,59 @@ jprt.build.targets= \ # User can select the test set with jprt submit "-testset name" option jprt.my.test.set=${jprt.test.set} -# Standard vm test target -jprt.vm.default.test.targets= \ - solaris_sparc_5.10-product-c1-jvm98, \ - solaris_sparcv9_5.10-product-c2-jvm98, \ - solaris_i586_5.10-product-c1-jvm98, \ - solaris_x64_5.10-product-c2-jvm98, \ - linux_i586_2.6-product-{c1|c2}-jvm98, \ - linux_x64_2.6-product-c2-jvm98, \ - windows_i586_5.1-product-c1-jvm98, \ - windows_x64_5.2-product-c2-jvm98 +# Test target list (no fastdebug & limited c2 testing) +jprt.my.test.target.set= \ + solaris_sparc_5.10-product-c1-TESTNAME, \ + solaris_sparcv9_5.10-product-c2-TESTNAME, \ + solaris_i586_5.10-product-c1-TESTNAME, \ + solaris_x64_5.10-product-c2-TESTNAME, \ + linux_i586_2.6-product-{c1|c2}-TESTNAME, \ + linux_x64_2.6-product-c2-TESTNAME, \ + windows_i586_5.1-product-c1-TESTNAME, \ + windows_x64_5.2-product-c2-TESTNAME -# Select vm testlist to use (allow for testset to be empty too) -jprt.vm.all.test.targets=${jprt.vm.default.test.targets} -jprt.vm..test.targets=${jprt.vm.default.test.targets} -jprt.test.targets=${jprt.vm.${jprt.my.test.set}.test.targets} +# Default vm test targets (testset=default) +jprt.vm.default.test.targets= \ + ${jprt.my.test.target.set:TESTNAME=jvm98} -# Default jdk test targets in test/Makefile (no fastdebug & limited c2) +# Default jdk test targets (testset=default) jprt.make.rule.default.test.targets= \ - \ - solaris_sparc_5.10-product-c1-jdk_beans1, \ - solaris_sparcv9_5.10-product-c2-jdk_beans1, \ - solaris_i586_5.10-product-c1-jdk_beans1, \ - solaris_x64_5.10-product-c2-jdk_beans1, \ - linux_i586_2.6-product-{c1|c2}-jdk_beans1, \ - linux_x64_2.6-product-c2-jdk_beans1, \ - windows_i586_5.1-product-c1-jdk_beans1, \ - windows_x64_5.2-product-c2-jdk_beans1, \ - \ - solaris_sparc_5.10-product-c1-jdk_io, \ - solaris_sparcv9_5.10-product-c2-jdk_io, \ - solaris_i586_5.10-product-c1-jdk_io, \ - solaris_x64_5.10-product-c2-jdk_io, \ - linux_i586_2.6-product-{c1|c2}-jdk_io, \ - linux_x64_2.6-product-c2-jdk_io, \ - windows_i586_5.1-product-c1-jdk_io, \ - windows_x64_5.2-product-c2-jdk_io, \ - \ - solaris_sparc_5.10-product-c1-jdk_lang, \ - solaris_sparcv9_5.10-product-c2-jdk_lang, \ - solaris_i586_5.10-product-c1-jdk_lang, \ - solaris_x64_5.10-product-c2-jdk_lang, \ - linux_i586_2.6-product-{c1|c2}-jdk_lang, \ - linux_x64_2.6-product-c2-jdk_lang, \ - windows_i586_5.1-product-c1-jdk_lang, \ - windows_x64_5.2-product-c2-jdk_lang, \ - \ - solaris_sparc_5.10-product-c1-jdk_math, \ - solaris_sparcv9_5.10-product-c2-jdk_math, \ - solaris_i586_5.10-product-c1-jdk_math, \ - solaris_x64_5.10-product-c2-jdk_math, \ - linux_i586_2.6-product-{c1|c2}-jdk_math, \ - linux_x64_2.6-product-c2-jdk_math, \ - windows_i586_5.1-product-c1-jdk_math, \ - windows_x64_5.2-product-c2-jdk_math, \ - \ - solaris_sparc_5.10-product-c1-jdk_misc, \ - solaris_sparcv9_5.10-product-c2-jdk_misc, \ - solaris_i586_5.10-product-c1-jdk_misc, \ - solaris_x64_5.10-product-c2-jdk_misc, \ - linux_i586_2.6-product-{c1|c2}-jdk_misc, \ - linux_x64_2.6-product-c2-jdk_misc, \ - windows_i586_5.1-product-c1-jdk_misc, \ - windows_x64_5.2-product-c2-jdk_misc, \ - \ - solaris_sparc_5.10-product-c1-jdk_net, \ - solaris_sparcv9_5.10-product-c2-jdk_net, \ - solaris_i586_5.10-product-c1-jdk_net, \ - solaris_x64_5.10-product-c2-jdk_net, \ - linux_i586_2.6-product-{c1|c2}-jdk_net, \ - linux_x64_2.6-product-c2-jdk_net, \ - windows_i586_5.1-product-c1-jdk_net, \ - windows_x64_5.2-product-c2-jdk_net, \ - \ - solaris_sparc_5.10-product-c1-jdk_nio1, \ - solaris_sparcv9_5.10-product-c2-jdk_nio1, \ - solaris_i586_5.10-product-c1-jdk_nio1, \ - solaris_x64_5.10-product-c2-jdk_nio1, \ - linux_i586_2.6-product-{c1|c2}-jdk_nio1, \ - linux_x64_2.6-product-c2-jdk_nio1, \ - windows_i586_5.1-product-c1-jdk_nio1, \ - windows_x64_5.2-product-c2-jdk_nio1, \ - \ - solaris_sparc_5.10-product-c1-jdk_nio2, \ - solaris_sparcv9_5.10-product-c2-jdk_nio2, \ - solaris_i586_5.10-product-c1-jdk_nio2, \ - solaris_x64_5.10-product-c2-jdk_nio2, \ - linux_i586_2.6-product-{c1|c2}-jdk_nio2, \ - linux_x64_2.6-product-c2-jdk_nio2, \ - windows_i586_5.1-product-c1-jdk_nio2, \ - windows_x64_5.2-product-c2-jdk_nio2, \ - \ - solaris_sparc_5.10-product-c1-jdk_nio3, \ - solaris_sparcv9_5.10-product-c2-jdk_nio3, \ - solaris_i586_5.10-product-c1-jdk_nio3, \ - solaris_x64_5.10-product-c2-jdk_nio3, \ - linux_i586_2.6-product-{c1|c2}-jdk_nio3, \ - linux_x64_2.6-product-c2-jdk_nio3, \ - windows_i586_5.1-product-c1-jdk_nio3, \ - windows_x64_5.2-product-c2-jdk_nio3, \ - \ - solaris_sparc_5.10-product-c1-jdk_security1, \ - solaris_sparcv9_5.10-product-c2-jdk_security1, \ - solaris_i586_5.10-product-c1-jdk_security1, \ - solaris_x64_5.10-product-c2-jdk_security1, \ - linux_i586_2.6-product-{c1|c2}-jdk_security1, \ - linux_x64_2.6-product-c2-jdk_security1, \ - windows_i586_5.1-product-c1-jdk_security1, \ - windows_x64_5.2-product-c2-jdk_security1, \ - \ - solaris_sparc_5.10-product-c1-jdk_text, \ - solaris_sparcv9_5.10-product-c2-jdk_text, \ - solaris_i586_5.10-product-c1-jdk_text, \ - solaris_x64_5.10-product-c2-jdk_text, \ - linux_i586_2.6-product-{c1|c2}-jdk_text, \ - linux_x64_2.6-product-c2-jdk_text, \ - windows_i586_5.1-product-c1-jdk_text, \ - windows_x64_5.2-product-c2-jdk_text, \ - \ - solaris_sparc_5.10-product-c1-jdk_tools1, \ - solaris_sparcv9_5.10-product-c2-jdk_tools1, \ - solaris_i586_5.10-product-c1-jdk_tools1, \ - solaris_x64_5.10-product-c2-jdk_tools1, \ - linux_i586_2.6-product-{c1|c2}-jdk_tools1, \ - linux_x64_2.6-product-c2-jdk_tools1, \ - windows_i586_5.1-product-c1-jdk_tools1, \ - windows_x64_5.2-product-c2-jdk_tools1, \ - \ - solaris_sparc_5.10-product-c1-jdk_util, \ - solaris_sparcv9_5.10-product-c2-jdk_util, \ - solaris_i586_5.10-product-c1-jdk_util, \ - solaris_x64_5.10-product-c2-jdk_util, \ - linux_i586_2.6-product-{c1|c2}-jdk_util, \ - linux_x64_2.6-product-c2-jdk_util, \ - windows_i586_5.1-product-c1-jdk_util, \ - windows_x64_5.2-product-c2-jdk_util + ${jprt.my.test.target.set:TESTNAME=jdk_beans1}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_io}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_lang}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_math}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_misc}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_net}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_nio1}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_nio2}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_nio3}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_security1}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_text}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_util} + +# All vm test targets (testset=all) +jprt.vm.all.test.targets= \ + ${jprt.vm.default.test.targets}, \ + ${jprt.my.test.target.set:TESTNAME=runThese}, \ + ${jprt.my.test.target.set:TESTNAME=jbb_default} -# All jdk test targets in test/Makefile (still no fastdebug & limited c2) +# All jdk test targets (testset=all) jprt.make.rule.all.test.targets= \ - \ - ${jprt.make.rule.default.test.targets}, \ - \ - solaris_sparc_5.10-product-c1-jdk_awt, \ - solaris_sparcv9_5.10-product-c2-jdk_awt, \ - solaris_i586_5.10-product-c1-jdk_awt, \ - solaris_x64_5.10-product-c2-jdk_awt, \ - linux_i586_2.6-product-{c1|c2}-jdk_awt, \ - linux_x64_2.6-product-c2-jdk_awt, \ - windows_i586_5.1-product-c1-jdk_awt, \ - windows_x64_5.2-product-c2-jdk_awt, \ - \ - solaris_sparc_5.10-product-c1-jdk_beans2, \ - solaris_sparcv9_5.10-product-c2-jdk_beans2, \ - solaris_i586_5.10-product-c1-jdk_beans2, \ - solaris_x64_5.10-product-c2-jdk_beans2, \ - linux_i586_2.6-product-{c1|c2}-jdk_beans2, \ - linux_x64_2.6-product-c2-jdk_beans2, \ - windows_i586_5.1-product-c1-jdk_beans2, \ - windows_x64_5.2-product-c2-jdk_beans2, \ - \ - solaris_sparc_5.10-product-c1-jdk_beans3, \ - solaris_sparcv9_5.10-product-c2-jdk_beans3, \ - solaris_i586_5.10-product-c1-jdk_beans3, \ - solaris_x64_5.10-product-c2-jdk_beans3, \ - linux_i586_2.6-product-{c1|c2}-jdk_beans3, \ - linux_x64_2.6-product-c2-jdk_beans3, \ - windows_i586_5.1-product-c1-jdk_beans3, \ - windows_x64_5.2-product-c2-jdk_beans3, \ - \ - solaris_sparc_5.10-product-c1-jdk_management1, \ - solaris_sparcv9_5.10-product-c2-jdk_management1, \ - solaris_i586_5.10-product-c1-jdk_management1, \ - solaris_x64_5.10-product-c2-jdk_management1, \ - linux_i586_2.6-product-{c1|c2}-jdk_management1, \ - linux_x64_2.6-product-c2-jdk_management1, \ - windows_i586_5.1-product-c1-jdk_management1, \ - windows_x64_5.2-product-c2-jdk_management1, \ - \ - solaris_sparc_5.10-product-c1-jdk_management2, \ - solaris_sparcv9_5.10-product-c2-jdk_management2, \ - solaris_i586_5.10-product-c1-jdk_management2, \ - solaris_x64_5.10-product-c2-jdk_management2, \ - linux_i586_2.6-product-{c1|c2}-jdk_management2, \ - linux_x64_2.6-product-c2-jdk_management2, \ - windows_i586_5.1-product-c1-jdk_management2, \ - windows_x64_5.2-product-c2-jdk_management2, \ - \ - solaris_sparc_5.10-product-c1-jdk_rmi, \ - solaris_sparcv9_5.10-product-c2-jdk_rmi, \ - solaris_i586_5.10-product-c1-jdk_rmi, \ - solaris_x64_5.10-product-c2-jdk_rmi, \ - linux_i586_2.6-product-{c1|c2}-jdk_rmi, \ - linux_x64_2.6-product-c2-jdk_rmi, \ - windows_i586_5.1-product-c1-jdk_rmi, \ - windows_x64_5.2-product-c2-jdk_rmi, \ - \ - solaris_sparc_5.10-product-c1-jdk_security2, \ - solaris_sparcv9_5.10-product-c2-jdk_security2, \ - solaris_i586_5.10-product-c1-jdk_security2, \ - solaris_x64_5.10-product-c2-jdk_security2, \ - linux_i586_2.6-product-{c1|c2}-jdk_security2, \ - linux_x64_2.6-product-c2-jdk_security2, \ - windows_i586_5.1-product-c1-jdk_security2, \ - windows_x64_5.2-product-c2-jdk_security2, \ - \ - solaris_sparc_5.10-product-c1-jdk_security3, \ - solaris_sparcv9_5.10-product-c2-jdk_security3, \ - solaris_i586_5.10-product-c1-jdk_security3, \ - solaris_x64_5.10-product-c2-jdk_security3, \ - linux_i586_2.6-product-{c1|c2}-jdk_security3, \ - linux_x64_2.6-product-c2-jdk_security3, \ - windows_i586_5.1-product-c1-jdk_security3, \ - windows_x64_5.2-product-c2-jdk_security3, \ - \ - solaris_sparc_5.10-product-c1-jdk_sound, \ - solaris_sparcv9_5.10-product-c2-jdk_sound, \ - solaris_i586_5.10-product-c1-jdk_sound, \ - solaris_x64_5.10-product-c2-jdk_sound, \ - linux_i586_2.6-product-{c1|c2}-jdk_sound, \ - linux_x64_2.6-product-c2-jdk_sound, \ - windows_i586_5.1-product-c1-jdk_sound, \ - windows_x64_5.2-product-c2-jdk_sound, \ - \ - solaris_sparc_5.10-product-c1-jdk_swing, \ - solaris_sparcv9_5.10-product-c2-jdk_swing, \ - solaris_i586_5.10-product-c1-jdk_swing, \ - solaris_x64_5.10-product-c2-jdk_swing, \ - linux_i586_2.6-product-{c1|c2}-jdk_swing, \ - linux_x64_2.6-product-c2-jdk_swing, \ - windows_i586_5.1-product-c1-jdk_swing, \ - windows_x64_5.2-product-c2-jdk_swing, \ - \ - solaris_sparc_5.10-product-c1-jdk_tools2, \ - solaris_sparcv9_5.10-product-c2-jdk_tools2, \ - solaris_i586_5.10-product-c1-jdk_tools2, \ - solaris_x64_5.10-product-c2-jdk_tools2, \ - linux_i586_2.6-product-{c1|c2}-jdk_tools2, \ - linux_x64_2.6-product-c2-jdk_tools2, \ - windows_i586_5.1-product-c1-jdk_tools2, \ - windows_x64_5.2-product-c2-jdk_tools2 + ${jprt.make.rule.default.test.targets}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_awt}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_beans2}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_beans3}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_management1}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_management2}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_rmi}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_security2}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_security3}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_sound}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_swing}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_tools1}, \ + ${jprt.my.test.target.set:TESTNAME=jdk_tools2} -# JCK test targets in test/Makefile (no fastdebug & limited c2, windows broken) +# JCK test targets in test/Makefile (no windows) jprt.my.jck.test.target.set= \ solaris_sparc_5.10-product-c1-JCK7TESTRULE, \ solaris_sparcv9_5.10-product-c2-JCK7TESTRULE, \ @@ -301,8 +113,10 @@ jprt.make.rule.jck.test.targets= \ ${jprt.my.jck.test.target.set:JCK7TESTRULE=jck7compiler} # Select list to use (allow for testset to be empty too) -jprt.make.rule..test.targets=${jprt.make.rule.default.test.targets} -jprt.make.rule.test.targets=${jprt.make.rule.${jprt.my.test.set}.test.targets} +jprt.make.rule..test.targets=${jprt.make.rule.default.test.targets} +jprt.make.rule.test.targets=${jprt.make.rule.${jprt.my.test.set}.test.targets} +jprt.vm..test.targets=${jprt.vm.default.test.targets} +jprt.test.targets=${jprt.vm.${jprt.my.test.set}.test.targets} # Directories to be excluded from the source bundles jprt.bundle.exclude.src.dirs=build dist webrev diff --git a/make/tools/src/build/tools/jdwpgen/ArrayRegionTypeNode.java b/make/tools/src/build/tools/jdwpgen/ArrayRegionTypeNode.java index bc4d7bae1b61fea5634181fd3dab1d0fb1512490..04afd02129c6d972ec86376cfd217a86e1d0c041 100644 --- a/make/tools/src/build/tools/jdwpgen/ArrayRegionTypeNode.java +++ b/make/tools/src/build/tools/jdwpgen/ArrayRegionTypeNode.java @@ -35,7 +35,7 @@ class ArrayRegionTypeNode extends AbstractSimpleTypeNode { } String javaType() { - return "List"; + return "List"; } public void genJavaWrite(PrintWriter writer, int depth, diff --git a/make/tools/src/build/tools/jdwpgen/OutNode.java b/make/tools/src/build/tools/jdwpgen/OutNode.java index 1a0b426ae75756a238aad912c0c79443e15ee080..a4c673a444a82627331375dc879c1813404de9ba 100644 --- a/make/tools/src/build/tools/jdwpgen/OutNode.java +++ b/make/tools/src/build/tools/jdwpgen/OutNode.java @@ -89,7 +89,7 @@ class OutNode extends AbstractTypeListNode { if (Main.genDebug) { indent(writer, depth+1); writer.println( - "if ((vm.traceFlags & vm.TRACE_SENDS) != 0) {"); + "if ((vm.traceFlags & VirtualMachineImpl.TRACE_SENDS) != 0) {"); indent(writer, depth+2); writer.print( "vm.printTrace(\"Sending Command(id=\" + ps.pkt.id + \") "); diff --git a/src/share/classes/com/sun/jdi/AbsentInformationException.java b/src/share/classes/com/sun/jdi/AbsentInformationException.java index f5ef5b876526987101dbba479ad476a82e36dfa8..cc296a0b87b324ab5721123e2e38e5bc21ee90c0 100644 --- a/src/share/classes/com/sun/jdi/AbsentInformationException.java +++ b/src/share/classes/com/sun/jdi/AbsentInformationException.java @@ -33,6 +33,7 @@ package com.sun.jdi; */ public class AbsentInformationException extends Exception { + private static final long serialVersionUID = 4988939309582416373L; public AbsentInformationException() { super(); diff --git a/src/share/classes/com/sun/jdi/ClassNotLoadedException.java b/src/share/classes/com/sun/jdi/ClassNotLoadedException.java index b139b3f065b799a0085262b072ee8dd79a26ea44..5b2cebfc9043bb6ffc2d088c2a05f1a4f201b6b9 100644 --- a/src/share/classes/com/sun/jdi/ClassNotLoadedException.java +++ b/src/share/classes/com/sun/jdi/ClassNotLoadedException.java @@ -69,6 +69,7 @@ package com.sun.jdi; */ public class ClassNotLoadedException extends Exception { + private static final long serialVersionUID = -6242978768444298722L; private String className; public ClassNotLoadedException(String className) { diff --git a/src/share/classes/com/sun/jdi/ClassNotPreparedException.java b/src/share/classes/com/sun/jdi/ClassNotPreparedException.java index cbee2bcd2c92b6c8106665929e17129c3245c0a4..1455d8e8c7d373dc86b9175e692eee6ef8ac5336 100644 --- a/src/share/classes/com/sun/jdi/ClassNotPreparedException.java +++ b/src/share/classes/com/sun/jdi/ClassNotPreparedException.java @@ -33,6 +33,7 @@ package com.sun.jdi; * @since 1.3 */ public class ClassNotPreparedException extends RuntimeException { + private static final long serialVersionUID = -6120698967144079642L; public ClassNotPreparedException() { super(); diff --git a/src/share/classes/com/sun/jdi/IncompatibleThreadStateException.java b/src/share/classes/com/sun/jdi/IncompatibleThreadStateException.java index 894762c96fc59404f54e0f24912f8f798d4c7cab..af9cac9ad854ca6518b39c0b405674ef14544c6e 100644 --- a/src/share/classes/com/sun/jdi/IncompatibleThreadStateException.java +++ b/src/share/classes/com/sun/jdi/IncompatibleThreadStateException.java @@ -34,6 +34,7 @@ package com.sun.jdi; */ public class IncompatibleThreadStateException extends Exception { + private static final long serialVersionUID = 6199174323414551389L; public IncompatibleThreadStateException() { super(); diff --git a/src/share/classes/com/sun/jdi/InconsistentDebugInfoException.java b/src/share/classes/com/sun/jdi/InconsistentDebugInfoException.java index 022895ffed6799093bc296726057f1c17b052e43..f03e3ba145e71889d419ff78f91a3ad3219e51ea 100644 --- a/src/share/classes/com/sun/jdi/InconsistentDebugInfoException.java +++ b/src/share/classes/com/sun/jdi/InconsistentDebugInfoException.java @@ -35,6 +35,7 @@ package com.sun.jdi; * @since 1.3 */ public class InconsistentDebugInfoException extends RuntimeException { + private static final long serialVersionUID = 7964236415376861808L; public InconsistentDebugInfoException() { super(); } diff --git a/src/share/classes/com/sun/jdi/InternalException.java b/src/share/classes/com/sun/jdi/InternalException.java index 071d35fcba91c53b06ed47e84272642753e71f46..c263c98703540aa82d5d947a0b782662c86ce20d 100644 --- a/src/share/classes/com/sun/jdi/InternalException.java +++ b/src/share/classes/com/sun/jdi/InternalException.java @@ -33,6 +33,7 @@ package com.sun.jdi; * @since 1.3 */ public class InternalException extends RuntimeException { + private static final long serialVersionUID = -9171606393104480607L; private int errorCode; public InternalException() { diff --git a/src/share/classes/com/sun/jdi/InvalidCodeIndexException.java b/src/share/classes/com/sun/jdi/InvalidCodeIndexException.java index 5bdb17802363168a5bdfbe8a14e4675c4fb8cf2f..5959af4c3291a0adf76aade6f522c83269274c13 100644 --- a/src/share/classes/com/sun/jdi/InvalidCodeIndexException.java +++ b/src/share/classes/com/sun/jdi/InvalidCodeIndexException.java @@ -36,6 +36,7 @@ package com.sun.jdi; */ @Deprecated public class InvalidCodeIndexException extends RuntimeException { + private static final long serialVersionUID = 7416010225133747805L; public InvalidCodeIndexException() { super(); } diff --git a/src/share/classes/com/sun/jdi/InvalidLineNumberException.java b/src/share/classes/com/sun/jdi/InvalidLineNumberException.java index 279fcc01718563d341acf8ac0d56ce02a854b7a3..9e8a476e64ad201c39770cbd4928bb5d137e12a7 100644 --- a/src/share/classes/com/sun/jdi/InvalidLineNumberException.java +++ b/src/share/classes/com/sun/jdi/InvalidLineNumberException.java @@ -36,6 +36,7 @@ package com.sun.jdi; */ @Deprecated public class InvalidLineNumberException extends RuntimeException { + private static final long serialVersionUID = 4048709912372692875L; public InvalidLineNumberException() { super(); } diff --git a/src/share/classes/com/sun/jdi/InvalidStackFrameException.java b/src/share/classes/com/sun/jdi/InvalidStackFrameException.java index 86f68c8cb94813776efa0b5afa382977a3d6b8de..f552e93d954aaf7b5399fe71ef7c757d4487bbfa 100644 --- a/src/share/classes/com/sun/jdi/InvalidStackFrameException.java +++ b/src/share/classes/com/sun/jdi/InvalidStackFrameException.java @@ -33,6 +33,7 @@ package com.sun.jdi; * @since 1.3 */ public class InvalidStackFrameException extends RuntimeException { + private static final long serialVersionUID = -1919378296505827922L; public InvalidStackFrameException() { super(); } diff --git a/src/share/classes/com/sun/jdi/InvalidTypeException.java b/src/share/classes/com/sun/jdi/InvalidTypeException.java index c6cfb295dd8a077d8d0e23d470c6717f993a32c1..9797e208bc8421f8e0009c5dc0dd2eaf11c8f642 100644 --- a/src/share/classes/com/sun/jdi/InvalidTypeException.java +++ b/src/share/classes/com/sun/jdi/InvalidTypeException.java @@ -34,6 +34,7 @@ package com.sun.jdi; */ public class InvalidTypeException extends Exception { + private static final long serialVersionUID = 2256667231949650806L; public InvalidTypeException() { super(); diff --git a/src/share/classes/com/sun/jdi/InvocationException.java b/src/share/classes/com/sun/jdi/InvocationException.java index 2130e53180b78e20a888501bc77582f9a14ab00b..176f982e91f70a3f2a4e86a68209c7140a9f37f9 100644 --- a/src/share/classes/com/sun/jdi/InvocationException.java +++ b/src/share/classes/com/sun/jdi/InvocationException.java @@ -34,6 +34,7 @@ package com.sun.jdi; */ public class InvocationException extends Exception { + private static final long serialVersionUID = 6066780907971918568L; ObjectReference exception; public InvocationException(ObjectReference exception) diff --git a/src/share/classes/com/sun/jdi/JDIPermission.java b/src/share/classes/com/sun/jdi/JDIPermission.java index d915b3d709741bb4550b7b6a72f4dd975d4e4274..2d1174da25690069aab70c2c5f7b757e5990f3d0 100644 --- a/src/share/classes/com/sun/jdi/JDIPermission.java +++ b/src/share/classes/com/sun/jdi/JDIPermission.java @@ -79,7 +79,7 @@ package com.sun.jdi; */ public final class JDIPermission extends java.security.BasicPermission { - + private static final long serialVersionUID = -6988461416938786271L; /** * The JDIPermission class represents access rights to the * VirtualMachineManager diff --git a/src/share/classes/com/sun/jdi/NativeMethodException.java b/src/share/classes/com/sun/jdi/NativeMethodException.java index b25f47d5b9e0b52695eeb10e3eafb4221e5326c1..c1dabad3a63bbc717b857dc655463e200e7ef5bc 100644 --- a/src/share/classes/com/sun/jdi/NativeMethodException.java +++ b/src/share/classes/com/sun/jdi/NativeMethodException.java @@ -34,6 +34,7 @@ package com.sun.jdi; */ public class NativeMethodException extends RuntimeException { + private static final long serialVersionUID = 3924951669039469992L; public NativeMethodException() { super(); } diff --git a/src/share/classes/com/sun/jdi/ObjectCollectedException.java b/src/share/classes/com/sun/jdi/ObjectCollectedException.java index e31a87cc7b76cdbca6cd972a55dee2265c6906d3..f26f53d931828116eb79bc8bab55f9f862dfacfd 100644 --- a/src/share/classes/com/sun/jdi/ObjectCollectedException.java +++ b/src/share/classes/com/sun/jdi/ObjectCollectedException.java @@ -33,6 +33,7 @@ package com.sun.jdi; * @since 1.3 */ public class ObjectCollectedException extends RuntimeException { + private static final long serialVersionUID = -1928428056197269588L; public ObjectCollectedException() { super(); } diff --git a/src/share/classes/com/sun/jdi/VMCannotBeModifiedException.java b/src/share/classes/com/sun/jdi/VMCannotBeModifiedException.java index 855c36b7dda3c78ce673fb7e556905450fe4dde6..d70c55e39efbb89b6d9f4469ed6f25af51bd914d 100644 --- a/src/share/classes/com/sun/jdi/VMCannotBeModifiedException.java +++ b/src/share/classes/com/sun/jdi/VMCannotBeModifiedException.java @@ -33,6 +33,7 @@ package com.sun.jdi; * @since 1.5 */ public class VMCannotBeModifiedException extends UnsupportedOperationException { + private static final long serialVersionUID = -4063879815130164009L; public VMCannotBeModifiedException() { super(); } diff --git a/src/share/classes/com/sun/jdi/VMDisconnectedException.java b/src/share/classes/com/sun/jdi/VMDisconnectedException.java index 4025995767d720df2133de8fa5b04052695a2311..8622e7f35233345975f2ef4146eb9586ac723636 100644 --- a/src/share/classes/com/sun/jdi/VMDisconnectedException.java +++ b/src/share/classes/com/sun/jdi/VMDisconnectedException.java @@ -35,6 +35,7 @@ package com.sun.jdi; */ public class VMDisconnectedException extends RuntimeException { + private static final long serialVersionUID = 2892975269768351637L; public VMDisconnectedException() { super(); } diff --git a/src/share/classes/com/sun/jdi/VMMismatchException.java b/src/share/classes/com/sun/jdi/VMMismatchException.java index cfa7fd69456fd5166cbc16c1cf0c158709c96ab3..f3b55756808fe8f641432bca73ce6beb28b786ad 100644 --- a/src/share/classes/com/sun/jdi/VMMismatchException.java +++ b/src/share/classes/com/sun/jdi/VMMismatchException.java @@ -34,6 +34,7 @@ package com.sun.jdi; * @since 1.3 */ public class VMMismatchException extends RuntimeException { + private static final long serialVersionUID = 289169358790459564L; public VMMismatchException() { super(); } diff --git a/src/share/classes/com/sun/jdi/VMOutOfMemoryException.java b/src/share/classes/com/sun/jdi/VMOutOfMemoryException.java index 0908aa1d461a20ca0429928eb78dcc96aa99700a..74f07b4d7d4e4cb881e38274ea3f38b70b36d185 100644 --- a/src/share/classes/com/sun/jdi/VMOutOfMemoryException.java +++ b/src/share/classes/com/sun/jdi/VMOutOfMemoryException.java @@ -33,6 +33,7 @@ package com.sun.jdi; * @since 1.3 */ public class VMOutOfMemoryException extends RuntimeException { + private static final long serialVersionUID = 71504228548910686L; public VMOutOfMemoryException() { super(); } diff --git a/src/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java b/src/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java index f8c693d4294efe7acb728e392f41a3b4a1b9593f..004a6856489b916bac81f3ad48df5bd9469ee43a 100644 --- a/src/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java +++ b/src/share/classes/com/sun/jdi/connect/IllegalConnectorArgumentsException.java @@ -38,6 +38,7 @@ import java.util.Collections; */ public class IllegalConnectorArgumentsException extends Exception { + private static final long serialVersionUID = -3042212603611350941L; List names; /** diff --git a/src/share/classes/com/sun/jdi/connect/TransportTimeoutException.java b/src/share/classes/com/sun/jdi/connect/TransportTimeoutException.java index 759b44f3d3c141a5d6a2a5a1681a81f087345068..423c9ccf31fac1a59083da44ad91fc708c13def8 100644 --- a/src/share/classes/com/sun/jdi/connect/TransportTimeoutException.java +++ b/src/share/classes/com/sun/jdi/connect/TransportTimeoutException.java @@ -55,7 +55,7 @@ package com.sun.jdi.connect; * @since 1.5 */ public class TransportTimeoutException extends java.io.IOException { - + private static final long serialVersionUID = 4107035242623365074L; /** * Constructs a TransportTimeoutException with no detail * message. diff --git a/src/share/classes/com/sun/jdi/connect/VMStartException.java b/src/share/classes/com/sun/jdi/connect/VMStartException.java index 9eb6fc5e494de4f3ff783ded76a9aef3393800b6..93919ff04997f55e857c793503ad45d2b5b85211 100644 --- a/src/share/classes/com/sun/jdi/connect/VMStartException.java +++ b/src/share/classes/com/sun/jdi/connect/VMStartException.java @@ -36,6 +36,7 @@ package com.sun.jdi.connect; */ public class VMStartException extends Exception { + private static final long serialVersionUID = 6408644824640801020L; Process process; public VMStartException(Process process) { diff --git a/src/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java b/src/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java index 36d8a08a965bbd030c5cf2f72bcbddfde65bf819..e167547748e206a136898bc1323fcdea3cadbd69 100644 --- a/src/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java +++ b/src/share/classes/com/sun/jdi/connect/spi/ClosedConnectionException.java @@ -46,7 +46,7 @@ package com.sun.jdi.connect.spi; * @since 1.5 */ public class ClosedConnectionException extends java.io.IOException { - + private static final long serialVersionUID = 3877032124297204774L; /** * Constructs a ClosedConnectionException with no detail * message. diff --git a/src/share/classes/com/sun/jdi/request/DuplicateRequestException.java b/src/share/classes/com/sun/jdi/request/DuplicateRequestException.java index 56c8d58e358ccb8d4471aa423a301daf555562cc..731f15d89b92c1158a09e6c29fd3e2cfadd00c81 100644 --- a/src/share/classes/com/sun/jdi/request/DuplicateRequestException.java +++ b/src/share/classes/com/sun/jdi/request/DuplicateRequestException.java @@ -33,6 +33,7 @@ package com.sun.jdi.request; */ public class DuplicateRequestException extends RuntimeException { + private static final long serialVersionUID = -3719784920313411060L; public DuplicateRequestException() { super(); diff --git a/src/share/classes/com/sun/jdi/request/InvalidRequestStateException.java b/src/share/classes/com/sun/jdi/request/InvalidRequestStateException.java index 674980b5b785282f38d7df86ec4dee4b97f2d93d..b444620666fe19222314a7f30a1fdd6440baf028 100644 --- a/src/share/classes/com/sun/jdi/request/InvalidRequestStateException.java +++ b/src/share/classes/com/sun/jdi/request/InvalidRequestStateException.java @@ -36,6 +36,7 @@ package com.sun.jdi.request; * @since 1.3 */ public class InvalidRequestStateException extends RuntimeException { + private static final long serialVersionUID = -3774632428543322148L; public InvalidRequestStateException() { super(); diff --git a/src/share/classes/com/sun/tools/jdi/ArrayReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ArrayReferenceImpl.java index afeb49be7a4b9e6f1abf96763e1d162adf4761e3..5d1ff516d9a88b91c7848ec093aa9d8514c17043 100644 --- a/src/share/classes/com/sun/tools/jdi/ArrayReferenceImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ArrayReferenceImpl.java @@ -70,8 +70,8 @@ public class ArrayReferenceImpl extends ObjectReferenceImpl } public Value getValue(int index) { - List list = getValues(index, 1); - return (Value)list.get(0); + List list = getValues(index, 1); + return list.get(0); } public List getValues() { diff --git a/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java index a10cc05758f3420705e79e10981f3acd763190b4..b31e8236b504adac5e2777a4bf4f7b4b95c2181b 100644 --- a/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java @@ -61,7 +61,7 @@ public class ArrayTypeImpl extends ReferenceTypeImpl return findType(componentSignature()); } - void addVisibleMethods(Map map) { + void addVisibleMethods(Map map) { // arrays don't have methods } @@ -83,10 +83,10 @@ public class ArrayTypeImpl extends ReferenceTypeImpl if (PacketStream.isObjectTag(tag)) { // It's a reference type JNITypeParser parser = new JNITypeParser(componentSignature()); - List list = vm.classesByName(parser.typeName()); - Iterator iter = list.iterator(); + List list = vm.classesByName(parser.typeName()); + Iterator iter = list.iterator(); while (iter.hasNext()) { - ReferenceType type = (ReferenceType)iter.next(); + ReferenceType type = iter.next(); ClassLoaderReference cl = type.classLoader(); if ((cl == null)? (classLoader() == null) : diff --git a/src/share/classes/com/sun/tools/jdi/BooleanValueImpl.java b/src/share/classes/com/sun/tools/jdi/BooleanValueImpl.java index b2975baca47383b5296df045700fb7c60d34a96a..c5aaed4632adb7daf71b96219a6a53649be01b7c 100644 --- a/src/share/classes/com/sun/tools/jdi/BooleanValueImpl.java +++ b/src/share/classes/com/sun/tools/jdi/BooleanValueImpl.java @@ -78,7 +78,7 @@ public class BooleanValueImpl extends PrimitiveValueImpl } public int intValue() { - return(int)((value)?1:0); + return (value)?1:0; } public long longValue() { @@ -90,7 +90,7 @@ public class BooleanValueImpl extends PrimitiveValueImpl } public double doubleValue() { - return(double)((value)?1.0:0.0); + return (value)?1.0:0.0; } public String toString() { diff --git a/src/share/classes/com/sun/tools/jdi/CharValueImpl.java b/src/share/classes/com/sun/tools/jdi/CharValueImpl.java index b29e1cb2093b91026f856259db7c493dd5fa8f79..d71a220ebbab18e40b3107c40743a17b94bf81cb 100644 --- a/src/share/classes/com/sun/tools/jdi/CharValueImpl.java +++ b/src/share/classes/com/sun/tools/jdi/CharValueImpl.java @@ -75,7 +75,7 @@ public class CharValueImpl extends PrimitiveValueImpl } public char charValue() { - return(char)value; + return value; } public short shortValue() { diff --git a/src/share/classes/com/sun/tools/jdi/ClassLoaderReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ClassLoaderReferenceImpl.java index 8023f1f807e17055dfe247514a545996092458c8..ebac996da31f0b0dd3045a9960486a370cf1a4d3 100644 --- a/src/share/classes/com/sun/tools/jdi/ClassLoaderReferenceImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ClassLoaderReferenceImpl.java @@ -80,7 +80,7 @@ public class ClassLoaderReferenceImpl extends ObjectReferenceImpl classes = Collections.unmodifiableList(classes); if (local != null) { local.visibleClasses = classes; - if ((vm.traceFlags & vm.TRACE_OBJREFS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace(description() + " temporarily caching visible classes (count = " + classes.size() + ")"); @@ -95,9 +95,9 @@ public class ClassLoaderReferenceImpl extends ObjectReferenceImpl Type findType(String signature) throws ClassNotLoadedException { List types = visibleClasses(); - Iterator iter = types.iterator(); + Iterator iter = types.iterator(); while (iter.hasNext()) { - ReferenceType type = (ReferenceType)iter.next(); + ReferenceType type = iter.next(); if (type.signature().equals(signature)) { return type; } diff --git a/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java index 8644957e0ff31e71a9ef13625833510f516d70e2..cbb4e7a7477802452d9a49b74b6ea3c5f7c8d849 100644 --- a/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ClassTypeImpl.java @@ -76,7 +76,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl List immediate = interfaces(); list.addAll(interfaces()); - Iterator iter = immediate.iterator(); + Iterator iter = immediate.iterator(); while (iter.hasNext()) { InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next(); interfaze.addSuperinterfaces(list); @@ -389,7 +389,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl * overwrite them in the hash table */ - Iterator iter = interfaces().iterator(); + Iterator iter = interfaces().iterator(); while (iter.hasNext()) { InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next(); interfaze.addVisibleMethods(methodMap); @@ -411,7 +411,7 @@ public class ClassTypeImpl extends ReferenceTypeImpl return true; } else { List interfaces = interfaces(); - Iterator iter = interfaces.iterator(); + Iterator iter = interfaces.iterator(); while (iter.hasNext()) { InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next(); if (interfaze.isAssignableTo(type)) { diff --git a/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java b/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java index 435255b9e2ac937d8665e62e7d5e749c57753f5b..f2e9233cd2bf5620e8aa1393c0de20ec4786d51c 100644 --- a/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ConcreteMethodImpl.java @@ -192,7 +192,7 @@ public class ConcreteMethodImpl extends MethodImpl { return super.codeIndexToLineInfo(stratum, codeIndex); } - Iterator iter = lineLocations.iterator(); + Iterator iter = lineLocations.iterator(); /* * Treat code before the beginning of the first line table * entry as part of the first line. javac will generate @@ -221,9 +221,9 @@ public class ConcreteMethodImpl extends MethodImpl { List variables = getVariables(); List retList = new ArrayList(2); - Iterator iter = variables.iterator(); + Iterator iter = variables.iterator(); while(iter.hasNext()) { - LocalVariable variable = (LocalVariable)iter.next(); + LocalVariable variable = iter.next(); if (variable.name().equals(name)) { retList.add(variable); } @@ -235,9 +235,9 @@ public class ConcreteMethodImpl extends MethodImpl { List variables = getVariables(); List retList = new ArrayList(variables.size()); - Iterator iter = variables.iterator(); + Iterator iter = variables.iterator(); while(iter.hasNext()) { - LocalVariable variable = (LocalVariable)iter.next(); + LocalVariable variable = iter.next(); if (variable.isArgument()) { retList.add(variable); } @@ -291,7 +291,7 @@ public class ConcreteMethodImpl extends MethodImpl { SDE.LineStratum lastLineStratum = null; SDE.Stratum baseStratum = declaringType.stratum(SDE.BASE_STRATUM_NAME); - Iterator it = getBaseLocations().lineLocations.iterator(); + Iterator it = getBaseLocations().lineLocations.iterator(); while(it.hasNext()) { LocationImpl loc = (LocationImpl)it.next(); int baseLineNumber = loc.lineNumber(baseStratum); diff --git a/src/share/classes/com/sun/tools/jdi/ConnectorImpl.java b/src/share/classes/com/sun/tools/jdi/ConnectorImpl.java index 3b594b90f77e5912fcff633ba972e22291368f75..e777a6cbaed4b739d300e6020e2a3806f9c1001d 100644 --- a/src/share/classes/com/sun/tools/jdi/ConnectorImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ConnectorImpl.java @@ -47,9 +47,9 @@ abstract class ConnectorImpl implements Connector { public Map defaultArguments() { Map defaults = new java.util.LinkedHashMap(); - Collection values = defaultArguments.values(); + Collection values = defaultArguments.values(); - Iterator iter = values.iterator(); + Iterator iter = values.iterator(); while (iter.hasNext()) { ArgumentImpl argument = (ArgumentImpl)iter.next(); defaults.put(argument.name(), (Argument)argument.clone()); @@ -96,7 +96,7 @@ abstract class ConnectorImpl implements Connector { mustSpecify, list)); } - ArgumentImpl argument(String name, Map arguments) + ArgumentImpl argument(String name, Map arguments) throws IllegalConnectorArgumentsException { ArgumentImpl argument = (ArgumentImpl)arguments.get(name); @@ -130,7 +130,7 @@ abstract class ConnectorImpl implements Connector { public String toString() { String string = name() + " (defaults: "; - Iterator iter = defaultArguments().values().iterator(); + Iterator iter = defaultArguments().values().iterator(); boolean first = true; while (iter.hasNext()) { ArgumentImpl argument = (ArgumentImpl)iter.next(); @@ -222,7 +222,7 @@ abstract class ConnectorImpl implements Connector { class BooleanArgumentImpl extends ConnectorImpl.ArgumentImpl implements Connector.BooleanArgument { - + private static final long serialVersionUID = 1624542968639361316L; BooleanArgumentImpl(String name, String label, String description, boolean value, boolean mustSpecify) { @@ -277,7 +277,7 @@ abstract class ConnectorImpl implements Connector { class IntegerArgumentImpl extends ConnectorImpl.ArgumentImpl implements Connector.IntegerArgument { - + private static final long serialVersionUID = 763286081923797770L; private final int min; private final int max; @@ -378,7 +378,7 @@ abstract class ConnectorImpl implements Connector { class StringArgumentImpl extends ConnectorImpl.ArgumentImpl implements Connector.StringArgument { - + private static final long serialVersionUID = 7500484902692107464L; StringArgumentImpl(String name, String label, String description, String value, boolean mustSpecify) { @@ -396,7 +396,7 @@ abstract class ConnectorImpl implements Connector { class SelectedArgumentImpl extends ConnectorImpl.ArgumentImpl implements Connector.SelectedArgument { - + private static final long serialVersionUID = -5689584530908382517L; private final List choices; SelectedArgumentImpl(String name, String label, String description, diff --git a/src/share/classes/com/sun/tools/jdi/DoubleValueImpl.java b/src/share/classes/com/sun/tools/jdi/DoubleValueImpl.java index 5f6d38738b793ccfd48c9c84a68d46a6e7b9f1d4..ef98b8d82b80e7b05e338799bf8b2555085ed5b0 100644 --- a/src/share/classes/com/sun/tools/jdi/DoubleValueImpl.java +++ b/src/share/classes/com/sun/tools/jdi/DoubleValueImpl.java @@ -101,7 +101,7 @@ public class DoubleValueImpl extends PrimitiveValueImpl } public double doubleValue() { - return(double)value; + return value; } byte checkedByteValue() throws InvalidTypeException { diff --git a/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java b/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java index d9f27f6bd237c3131a317cf13773d3efa02b761a..60ace7f0f9cc495254184cd83868232c3a319b77 100644 --- a/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java +++ b/src/share/classes/com/sun/tools/jdi/EventRequestManagerImpl.java @@ -43,7 +43,7 @@ import java.util.*; class EventRequestManagerImpl extends MirrorImpl implements EventRequestManager { - List[] requestLists; + List[] requestLists; private static int methodExitEventCmd = 0; static int JDWPtoJDISuspendPolicy(byte jdwpPolicy) { @@ -91,7 +91,7 @@ class EventRequestManagerImpl extends MirrorImpl * access/modification should be protected by synchronizing on * the enclosing instance of EventRequestImpl. */ - List filters = new ArrayList(); + List filters = new ArrayList<>(); boolean isEnabled = false; boolean deleted = false; @@ -195,7 +195,6 @@ class EventRequestManagerImpl extends MirrorImpl */ synchronized void set() { JDWP.EventRequest.Set.Modifier[] mods = - (JDWP.EventRequest.Set.Modifier[]) filters.toArray( new JDWP.EventRequest.Set.Modifier[filters.size()]); try { @@ -582,10 +581,10 @@ class EventRequestManagerImpl extends MirrorImpl /* * Make sure this isn't a duplicate */ - List requests = stepRequests(); - Iterator iter = requests.iterator(); + List requests = stepRequests(); + Iterator iter = requests.iterator(); while (iter.hasNext()) { - StepRequest request = (StepRequest)iter.next(); + StepRequest request = iter.next(); if ((request != this) && request.isEnabled() && request.thread().equals(thread)) { @@ -735,7 +734,7 @@ class EventRequestManagerImpl extends MirrorImpl } requestLists = new List[highest+1]; for (int i=0; i <= highest; i++) { - requestLists[i] = new ArrayList(); + requestLists[i] = new ArrayList<>(); } } @@ -852,7 +851,7 @@ class EventRequestManagerImpl extends MirrorImpl public void deleteEventRequests(List eventRequests) { validateMirrors(eventRequests); // copy the eventRequests to avoid ConcurrentModificationException - Iterator iter = (new ArrayList(eventRequests)).iterator(); + Iterator iter = (new ArrayList<>(eventRequests)).iterator(); while (iter.hasNext()) { ((EventRequestImpl)iter.next()).delete(); } @@ -869,76 +868,76 @@ class EventRequestManagerImpl extends MirrorImpl } public List stepRequests() { - return unmodifiableRequestList(JDWP.EventKind.SINGLE_STEP); + return (List)unmodifiableRequestList(JDWP.EventKind.SINGLE_STEP); } public List classPrepareRequests() { - return unmodifiableRequestList(JDWP.EventKind.CLASS_PREPARE); + return (List)unmodifiableRequestList(JDWP.EventKind.CLASS_PREPARE); } public List classUnloadRequests() { - return unmodifiableRequestList(JDWP.EventKind.CLASS_UNLOAD); + return (List)unmodifiableRequestList(JDWP.EventKind.CLASS_UNLOAD); } public List threadStartRequests() { - return unmodifiableRequestList(JDWP.EventKind.THREAD_START); + return (List)unmodifiableRequestList(JDWP.EventKind.THREAD_START); } public List threadDeathRequests() { - return unmodifiableRequestList(JDWP.EventKind.THREAD_DEATH); + return (List)unmodifiableRequestList(JDWP.EventKind.THREAD_DEATH); } public List exceptionRequests() { - return unmodifiableRequestList(JDWP.EventKind.EXCEPTION); + return (List)unmodifiableRequestList(JDWP.EventKind.EXCEPTION); } public List breakpointRequests() { - return unmodifiableRequestList(JDWP.EventKind.BREAKPOINT); + return (List)unmodifiableRequestList(JDWP.EventKind.BREAKPOINT); } public List accessWatchpointRequests() { - return unmodifiableRequestList(JDWP.EventKind.FIELD_ACCESS); + return (List)unmodifiableRequestList(JDWP.EventKind.FIELD_ACCESS); } public List modificationWatchpointRequests() { - return unmodifiableRequestList(JDWP.EventKind.FIELD_MODIFICATION); + return (List)unmodifiableRequestList(JDWP.EventKind.FIELD_MODIFICATION); } public List methodEntryRequests() { - return unmodifiableRequestList(JDWP.EventKind.METHOD_ENTRY); + return (List)unmodifiableRequestList(JDWP.EventKind.METHOD_ENTRY); } public List methodExitRequests() { - return unmodifiableRequestList( + return (List)unmodifiableRequestList( EventRequestManagerImpl.methodExitEventCmd); } public List monitorContendedEnterRequests() { - return unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTER); + return (List)unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTER); } public List monitorContendedEnteredRequests() { - return unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTERED); + return (List)unmodifiableRequestList(JDWP.EventKind.MONITOR_CONTENDED_ENTERED); } public List monitorWaitRequests() { - return unmodifiableRequestList(JDWP.EventKind.MONITOR_WAIT); + return (List)unmodifiableRequestList(JDWP.EventKind.MONITOR_WAIT); } public List monitorWaitedRequests() { - return unmodifiableRequestList(JDWP.EventKind.MONITOR_WAITED); + return (List)unmodifiableRequestList(JDWP.EventKind.MONITOR_WAITED); } public List vmDeathRequests() { - return unmodifiableRequestList(JDWP.EventKind.VM_DEATH); + return (List)unmodifiableRequestList(JDWP.EventKind.VM_DEATH); } - List unmodifiableRequestList(int eventCmd) { + List unmodifiableRequestList(int eventCmd) { return Collections.unmodifiableList(requestList(eventCmd)); } EventRequest request(int eventCmd, int requestId) { - List rl = requestList(eventCmd); + List rl = requestList(eventCmd); for (int i = rl.size() - 1; i >= 0; i--) { EventRequestImpl er = (EventRequestImpl)rl.get(i); if (er.id == requestId) { diff --git a/src/share/classes/com/sun/tools/jdi/EventSetImpl.java b/src/share/classes/com/sun/tools/jdi/EventSetImpl.java index ad3d7e4c559440f257c772906396fe940210c320..caead97f938f64accaf84d352e91a0287c998968 100644 --- a/src/share/classes/com/sun/tools/jdi/EventSetImpl.java +++ b/src/share/classes/com/sun/tools/jdi/EventSetImpl.java @@ -47,7 +47,7 @@ enum EventDestination {UNKNOWN_EVENT, INTERNAL_EVENT, CLIENT_EVENT}; * that is on the queues are all for client requests. */ public class EventSetImpl extends ArrayList implements EventSet { - + private static final long serialVersionUID = -4857338819787924570L; private VirtualMachineImpl vm; // we implement Mirror private Packet pkt; private byte suspendPolicy; @@ -607,7 +607,7 @@ public class EventSetImpl extends ArrayList implements EventSet { PacketStream ps = new PacketStream(vm, pkt); JDWP.Event.Composite compEvt = new JDWP.Event.Composite(vm, ps); suspendPolicy = compEvt.suspendPolicy; - if ((vm.traceFlags & vm.TRACE_EVENTS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) { switch(suspendPolicy) { case JDWP.SuspendPolicy.ALL: vm.printTrace("EventSet: SUSPEND_ALL"); @@ -626,7 +626,7 @@ public class EventSetImpl extends ArrayList implements EventSet { ThreadReference fix6485605 = null; for (int i = 0; i < compEvt.events.length; i++) { EventImpl evt = createEvent(compEvt.events[i]); - if ((vm.traceFlags & vm.TRACE_EVENTS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) { try { vm.printTrace("Event: " + evt); } catch (VMDisconnectedException ee) { diff --git a/src/share/classes/com/sun/tools/jdi/FloatValueImpl.java b/src/share/classes/com/sun/tools/jdi/FloatValueImpl.java index cf100d2e2504a042db6b6db2a0ed9664dca2c563..182e4fb3a6cc3d33d35e77a46398f173a48113a7 100644 --- a/src/share/classes/com/sun/tools/jdi/FloatValueImpl.java +++ b/src/share/classes/com/sun/tools/jdi/FloatValueImpl.java @@ -97,7 +97,7 @@ public class FloatValueImpl extends PrimitiveValueImpl } public float floatValue() { - return(float)value; + return value; } public double doubleValue() { diff --git a/src/share/classes/com/sun/tools/jdi/GenericAttachingConnector.java b/src/share/classes/com/sun/tools/jdi/GenericAttachingConnector.java index 39d087ef539c62a6e50bfbb64c0eda9c4375696b..6b86eb3f18932bf87207564b6756c3bdfe6deabe 100644 --- a/src/share/classes/com/sun/tools/jdi/GenericAttachingConnector.java +++ b/src/share/classes/com/sun/tools/jdi/GenericAttachingConnector.java @@ -105,7 +105,7 @@ public class GenericAttachingConnector /** * Attach to a target VM using the specified address and Connector arguments. */ - public VirtualMachine attach(String address, Map args) + public VirtualMachine attach(String address, Map args) throws IOException, IllegalConnectorArgumentsException { String ts = argument(ARG_TIMEOUT, args).value(); diff --git a/src/share/classes/com/sun/tools/jdi/IntegerValueImpl.java b/src/share/classes/com/sun/tools/jdi/IntegerValueImpl.java index c4551032c357d07de86471ae22820a16bfd443a0..5de8a5708b78c6f51283b68cecb15730efd56ebd 100644 --- a/src/share/classes/com/sun/tools/jdi/IntegerValueImpl.java +++ b/src/share/classes/com/sun/tools/jdi/IntegerValueImpl.java @@ -83,7 +83,7 @@ public class IntegerValueImpl extends PrimitiveValueImpl } public int intValue() { - return(int)value; + return value; } public long longValue() { diff --git a/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java b/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java index 2de46373cf2bd7cdfe6623d4e9593e4ecf379e0f..a408c771839de1bead90e2ad8b732a34e1108399 100644 --- a/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java +++ b/src/share/classes/com/sun/tools/jdi/InterfaceTypeImpl.java @@ -128,9 +128,9 @@ public class InterfaceTypeImpl extends ReferenceTypeImpl * list being built. */ List immediate = new ArrayList(superinterfaces()); - Iterator iter = immediate.iterator(); + Iterator iter = immediate.iterator(); while (iter.hasNext()) { - InterfaceType interfaze = (InterfaceType)iter.next(); + InterfaceType interfaze = iter.next(); if (list.contains(interfaze)) { iter.remove(); } diff --git a/src/share/classes/com/sun/tools/jdi/InternalEventHandler.java b/src/share/classes/com/sun/tools/jdi/InternalEventHandler.java index d8b02fb129bb5a844bfdc9f9a1667c6af8fe33da..f554fc94ab16fa815209670dbf9af8904f7f294c 100644 --- a/src/share/classes/com/sun/tools/jdi/InternalEventHandler.java +++ b/src/share/classes/com/sun/tools/jdi/InternalEventHandler.java @@ -59,7 +59,7 @@ public class InternalEventHandler implements Runnable ClassUnloadEvent cuEvent = (ClassUnloadEvent)event; vm.removeReferenceType(cuEvent.classSignature()); - if ((vm.traceFlags & vm.TRACE_EVENTS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) { vm.printTrace("Handled Unload Event for " + cuEvent.classSignature()); } @@ -68,7 +68,7 @@ public class InternalEventHandler implements Runnable ((ReferenceTypeImpl)cpEvent.referenceType()) .markPrepared(); - if ((vm.traceFlags & vm.TRACE_EVENTS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_EVENTS) != 0) { vm.printTrace("Handled Prepare Event for " + cpEvent.referenceType().name()); } diff --git a/src/share/classes/com/sun/tools/jdi/JDWPException.java b/src/share/classes/com/sun/tools/jdi/JDWPException.java index 125689c6ca4e0ad3be6a68f5946f19f6b8668adc..3d0cc4d2253de7b65b4f20cb20dc63ecbc9e0d6f 100644 --- a/src/share/classes/com/sun/tools/jdi/JDWPException.java +++ b/src/share/classes/com/sun/tools/jdi/JDWPException.java @@ -27,7 +27,7 @@ package com.sun.tools.jdi; import com.sun.jdi.*; class JDWPException extends Exception { - + private static final long serialVersionUID = -6321344442751299874L; short errorCode; JDWPException(short errorCode) { diff --git a/src/share/classes/com/sun/tools/jdi/LinkedHashMap.java b/src/share/classes/com/sun/tools/jdi/LinkedHashMap.java deleted file mode 100644 index fb055ee255f4c5612d73a64e23ea9f9dcad42c31..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/tools/jdi/LinkedHashMap.java +++ /dev/null @@ -1,904 +0,0 @@ -/* - * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.tools.jdi; - -import java.io.*; -import java.util.*; - -/** - * Hash table based implementation of the Map interface. This implementation - * provides all of the optional Map operations, and permits null values and - * the null key. (HashMap is roughly equivalent to Hashtable, except that it - * is unsynchronized and permits nulls.) In addition, elements in the map are - * ordered and doubly linked together. - *

- * This implementation provides constant-time performance for the basic - * operations (get and put), assuming the the hash function disperses the - * elements properly among the buckets. Iteration over Collection views - * requires time proportional to its size (the number of key-value mappings) - * and returns elements in the order they are linked. In a HashMap the - * iteration would require time proportional to the capacity of the map - * plus the map size. - *

- * An instance of LinkedHashMap has two parameters that affect its efficiency: - * its capacity and its load factor. The load factor should be - * between 0.0 and 1.0. When the number of mappings in the LinkedHashMap exceeds - * the product of the load factor and the current capacity, the capacity is - * increased by calling the rehash method which requires time proportional - * to the number of key-value mappings in the map. Larger load factors - * use memory more efficiently, at the expense of larger expected time per - * lookup. - *

- * If many mappings are to be stored in a LinkedHashMap, creating it with a - * sufficiently large capacity will allow the mappings to be stored more - * efficiently than letting it perform automatic rehashing as needed to grow - * the table. - *

- * Note that this implementation is not synchronized. If - * multiple threads access a LinkedHashMap concurrently, and at least one of the - * threads modifies the LinkedHashMap structurally, it must be - * synchronized externally. (A structural modification is any operation that - * adds or deletes one or more mappings; merely changing the value associated - * with a key that is already contained in the Table is not a structural - * modification.) This is typically accomplished by synchronizing on some - * object that naturally encapsulates the LinkedHashMap. If no such object - * exists, the LinkedHashMap should be "wrapped" using the - * Collections.synchronizedSet method. This is best done at creation time, to - * prevent accidental unsynchronized access to the LinkedHashMap: - *

- *      Map m = Collections.synchronizedMap(new LinkedHashMap(...));
- * 
- *

- * The Iterators returned by the iterator methods of the Collections returned - * by all of LinkedHashMap's "collection view methods" are fail-fast: - * if the LinkedHashMap is structurally modified at any time after the Iterator - * is created, in any way except through the Iterator's own remove or add - * methods, the Iterator will throw a ConcurrentModificationException. Thus, - * in the face of concurrent modification, the Iterator fails quickly and - * cleanly, rather than risking arbitrary, non-deterministic behavior at an - * undetermined time in the future. - * - * @author Josh Bloch - * @author Arthur van Hoff - * @author Zhenghua Li - * @see Object#hashCode() - * @see java.util.Collection - * @see java.util.Map - * @see java.util.TreeMap - * @see java.util.Hashtable - * @see java.util.HashMap - */ - -import java.io.Serializable; - -public class LinkedHashMap extends AbstractMap implements Map, Serializable { - /** - * The hash table data. - */ - private transient Entry table[]; - - /** - * The head of the double linked list. - */ - private transient Entry header; - - /** - * The total number of mappings in the hash table. - */ - private transient int count; - - /** - * Rehashes the table when count exceeds this threshold. - */ - private int threshold; - - /** - * The load factor for the LinkedHashMap. - */ - private float loadFactor; - - /** - * The number of times this LinkedHashMap has been structurally modified - * Structural modifications are those that change the number of mappings in - * the LinkedHashMap or otherwise modify its internal structure (e.g., - * rehash). This field is used to make iterators on Collection-views of - * the LinkedHashMap fail-fast. (See ConcurrentModificationException). - */ - private transient int modCount = 0; - - /** - * Constructs a new, empty LinkedHashMap with the specified initial - * capacity and the specified load factor. - * - * @param initialCapacity the initial capacity of the LinkedHashMap. - * @param loadFactor a number between 0.0 and 1.0. - * @exception IllegalArgumentException if the initial capacity is less - * than or equal to zero, or if the load factor is less than - * or equal to zero. - */ - public LinkedHashMap(int initialCapacity, float loadFactor) { - if (initialCapacity < 0) - throw new IllegalArgumentException("Illegal Initial Capacity: "+ - initialCapacity); - if ((loadFactor > 1) || (loadFactor <= 0)) - throw new IllegalArgumentException("Illegal Load factor: "+ - loadFactor); - if (initialCapacity==0) - initialCapacity = 1; - this.loadFactor = loadFactor; - table = new Entry[initialCapacity]; - threshold = (int)(initialCapacity * loadFactor); - header = new Entry(-1, null, null, null); - header.before = header.after = header; - } - - /** - * Constructs a new, empty LinkedHashMap with the specified initial capacity - * and default load factor. - * - * @param initialCapacity the initial capacity of the LinkedHashMap. - */ - public LinkedHashMap(int initialCapacity) { - this(initialCapacity, 0.75f); - } - - /** - * Constructs a new, empty LinkedHashMap with a default capacity and load - * factor. - */ - public LinkedHashMap() { - this(101, 0.75f); - } - - /** - * Constructs a new LinkedHashMap with the same mappings as the given - * Map. The LinkedHashMap is created with a capacity of thrice the number - * of mappings in the given Map or 11 (whichever is greater), and a - * default load factor. - */ - public LinkedHashMap(Map t) { - this(Math.max(3*t.size(), 11), 0.75f); - putAll(t); - } - - /** - * Returns the number of key-value mappings in this Map. - */ - public int size() { - return count; - } - - /** - * Returns true if this Map contains no key-value mappings. - */ - public boolean isEmpty() { - return count == 0; - } - - /** - * Returns true if this LinkedHashMap maps one or more keys to the specified - * value. - * - * @param value value whose presence in this Map is to be tested. - */ - public boolean containsValue(Object value) { - if (value==null) { - for (Entry e = header.after; e != header; e = e.after) - if (e.value==null) - return true; - } else { - for (Entry e = header.after; e != header; e = e.after) - if (value.equals(e.value)) - return true; - } - return false; - } - - /** - * Returns true if this LinkedHashMap contains a mapping for the specified - * key. - * - * @param key key whose presence in this Map is to be tested. - */ - public boolean containsKey(Object key) { - Entry tab[] = table; - if (key != null) { - int hash = key.hashCode(); - int index = (hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[index]; e != null; e = e.next) - if (e.hash==hash && e.key.equals(key)) - return true; - } else { - for (Entry e = tab[0]; e != null; e = e.next) - if (e.key==null) - return true; - } - - return false; - } - - /** - * Returns the value to which this LinkedHashMap maps the specified key. - * Returns null if the LinkedHashMap contains no mapping for this key. - * A return value of null does not necessarily indicate that the - * LinkedHashMap contains no mapping for the key; it's also possible that - * the LinkedHashMap explicitly maps the key to null. The containsKey - * operation may be used to distinguish these two cases. - * - * @param key key whose associated value is to be returned. - */ - public Object get(Object key) { - Entry e = getEntry(key); - return e==null ? null : e.value; - } - - /** - * Returns the entry associated with the specified key in the LinkedHashMap. - * Returns null if the LinkedHashMap contains no mapping for this key. - */ - private Entry getEntry(Object key) { - Entry tab[] = table; - - if (key != null) { - int hash = key.hashCode(); - int index = (hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[index]; e != null; e = e.next) - if ((e.hash == hash) && e.key.equals(key)) - return e; - } else { - for (Entry e = tab[0]; e != null; e = e.next) - if (e.key==null) - return e; - } - - return null; - } - - /** - * Rehashes the contents of the LinkedHashMap into a LinkedHashMap with a - * larger capacity. This method is called automatically when the - * number of keys in the LinkedHashMap exceeds this LinkedHashMap's capacity - * and load factor. - */ - private void rehash() { - int oldCapacity = table.length; - Entry oldMap[] = table; - - int newCapacity = oldCapacity * 2 + 1; - Entry newMap[] = new Entry[newCapacity]; - - modCount++; - threshold = (int)(newCapacity * loadFactor); - table = newMap; - - for (Entry e = header.after; e != header; e = e.after) { - int index = (e.hash & 0x7FFFFFFF) % newCapacity; - e.next = newMap[index]; - newMap[index] = e; - } - } - - /** - * Remove an entry from the linked list. - */ - private void listRemove(Entry entry) { - if (entry == null) { - return; - } - entry.before.after = entry.after; - entry.after.before = entry.before; - } - - /** - * Add the specified entry before the specified existing entry to - * the linked list. - */ - private void listAddBefore(Entry entry, Entry existEntry) { - entry.after = existEntry; - entry.before = existEntry.before; - entry.before.after = entry; - entry.after.before = entry; - } - - /** - * Returns the position of the mapping for the specified key - * in the ordered map. - * - * @param key the specified key. - * @return index of the key mapping. - */ - public int indexOf(Object key) { - int i = 0; - if (key == null) { - for (Entry e = header.after; e != header; e = e.after, i++) - if (e.key == null) - return i; - } else { - for (Entry e = header.after; e != header; e = e.after, i++) - if(key.equals(e.key)) - return i; - } - return -1; - } - - /** - * Associates the specified value with the specified key in this - * LinkedHashMap. If the LinkedHashMap previously contained a mapping for - * this key, the old value is replaced and the position of this mapping - * entry in the double linked list remains the same. Otherwise, a new - * mapping entry is created and inserted into the list before the specified - * existing mapping entry. The method returns the previous value associated - * with the specified key, or null if there was no mapping for key. A null - * return can also indicate that the LinkedHashMap previously associated - * null with the specified key. - */ - private Object putAhead(Object key, Object value, Entry existEntry) { - // Makes sure the key is not already in the LinkedHashMap. - Entry tab[] = table; - int hash = 0; - int index = 0; - - if (key != null) { - hash = key.hashCode(); - index = (hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[index] ; e != null ; e = e.next) { - if ((e.hash == hash) && e.key.equals(key)) { - Object old = e.value; - e.value = value; - return old; - } - } - } else { - for (Entry e = tab[0] ; e != null ; e = e.next) { - if (e.key == null) { - Object old = e.value; - e.value = value; - return old; - } - } - } - - modCount++; - if (count >= threshold) { - // Rehash the table if the threshold is exceeded - rehash(); - tab = table; - index = (hash & 0x7FFFFFFF) % tab.length; - } - - // Creates the new entry. - Entry e = new Entry(hash, key, value, tab[index]); - tab[index] = e; - listAddBefore(e, existEntry); - count++; - return null; - } - - /** - * Associates the specified value with the specified key in this - * LinkedHashMap and position the mapping at the specified index. - * If the LinkedHashMap previously contained a mapping for this key, - * the old value is replaced and the position of this mapping entry - * in the double linked list remains the same. Otherwise, a new mapping - * entry is created and inserted into the list at the specified - * position. - * - * @param index the position to put the key-value mapping. - * @param key key with which the specified value is to be associated. - * @param value value to be associated with the specified key. - * @return previous value associated with specified key, or null if there - * was no mapping for key. A null return can also indicate that - * the LinkedHashMap previously associated null with the specified - * key. - */ - public Object put(int index, Object key, Object value) { - if (index < 0 || index > count) - throw new IndexOutOfBoundsException(); - Entry e = header.after; - if (index == count) - return putAhead(key, value, header); //fast approach for append - else { - for (int i = 0; i < index; i++) - e = e.after; - return putAhead(key, value, e); - } - } - - - /** - * Associates the specified value with the specified key in this - * LinkedHashMap. If the LinkedHashMap previously contained a mapping for - * this key, the old value is replaced. The mapping entry is also appended - * to the end of the ordered linked list. - * - * @param key key with which the specified value is to be associated. - * @param value value to be associated with the specified key. - * @return previous value associated with specified key, or null if there - * was no mapping for key. A null return can also indicate that - * the LinkedHashMap previously associated null with the specified - * key. - */ - public Object put(Object key, Object value) { - return putAhead(key, value, header); - } - - /** - * Removes the mapping for this key from this LinkedHashMap if present. - * The mapping would also be removed from the double linked list. - * - * @param key key whose mapping is to be removed from the Map. - * @return previous value associated with specified key, or null if there - * was no mapping for key. A null return can also indicate that - * the LinkedHashMap previously associated null with the specified - * key. - */ - public Object remove(Object key) { - Entry tab[] = table; - - if (key != null) { - int hash = key.hashCode(); - int index = (hash & 0x7FFFFFFF) % tab.length; - - for (Entry e = tab[index], prev = null; e != null; - prev = e, e = e.next) { - if ((e.hash == hash) && e.key.equals(key)) { - modCount++; - if (prev != null) - prev.next = e.next; - else - tab[index] = e.next; - - count--; - Object oldValue = e.value; - e.value = null; - - listRemove(e); - return oldValue; - } - } - } else { - for (Entry e = tab[0], prev = null; e != null; - prev = e, e = e.next) { - if (e.key == null) { - modCount++; - if (prev != null) - prev.next = e.next; - else - tab[0] = e.next; - - count--; - Object oldValue = e.value; - e.value = null; - - listRemove(e); - return oldValue; - } - } - } - - return null; - } - - /** - * Copies all of the mappings from the specified Map to this LinkedHashMap - * These mappings will replace any mappings that this LinkedHashMap had for - * any of the keys currently in the specified Map. - * - * @param t Mappings to be stored in this Map. - */ - public void putAll(Map t) { - Iterator i = t.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry e = (Map.Entry) i.next(); - put(e.getKey(), e.getValue()); - } - } - - /** - * Removes all mappings from this LinkedHashMap. - */ - public void clear() { - Entry tab[] = table; - modCount++; - for (int index = tab.length; --index >= 0; ) - tab[index] = null; - count = 0; - header.before = header.after = header; - } - - /** - * Returns a shallow copy of this LinkedHashMap. The keys and values - * themselves are not cloned. - */ - public Object clone() { - return new LinkedHashMap(this); - } - - // Views - - private transient Set keySet = null; - private transient Set entries = null; - private transient Collection values = null; - - /** - * Returns a Set view of the keys contained in this LinkedHashMap. The Set - * is backed by the LinkedHashMap, so changes to the LinkedHashMap are - * reflected in the Set, and vice-versa. The Set supports element removal, - * which removes the corresponding mapping from the LinkedHashMap, via the - * Iterator.remove, Set.remove, removeAll retainAll, and clear operations. - * It does not support the add or addAll operations. - */ - public Set keySet() { - if (keySet == null) { - keySet = new AbstractSet() { - public Iterator iterator() { - return new HashIterator(KEYS); - } - public int size() { - return count; - } - public boolean contains(Object o) { - return containsKey(o); - } - public boolean remove(Object o) { - return LinkedHashMap.this.remove(o) != null; - } - public void clear() { - LinkedHashMap.this.clear(); - } - }; - } - return keySet; - } - - /** - * Returns a Collection view of the values contained in this LinkedHashMap. - * The Collection is backed by the LinkedHashMap, so changes to the - * LinkedHashMap are reflected in the Collection, and vice-versa. The - * Collection supports element removal, which removes the corresponding - * mapping from the LinkedHashMap, via the Iterator.remove, - * Collection.remove, removeAll, retainAll and clear operations. It does - * not support the add or addAll operations. - */ - public Collection values() { - if (values==null) { - values = new AbstractCollection() { - public Iterator iterator() { - return new HashIterator(VALUES); - } - public int size() { - return count; - } - public boolean contains(Object o) { - return containsValue(o); - } - public void clear() { - LinkedHashMap.this.clear(); - } - }; - } - return values; - } - - /** - * Returns a Collection view of the mappings contained in this - * LinkedHashMap. Each element in the returned collection is a Map.Entry. - * The Collection is backed by the LinkedHashMap, so changes to the - * LinkedHashMap are reflected in the Collection, and vice-versa. The - * Collection supports element removal, which removes the corresponding - * mapping from the LinkedHashMap, via the Iterator.remove, - * Collection.remove, removeAll, retainAll and clear operations. It does - * not support the add or addAll operations. - * - * @see java.util.Map.Entry - */ - public Set entrySet() { - if (entries==null) { - entries = new AbstractSet() { - public Iterator iterator() { - return new HashIterator(ENTRIES); - } - - public boolean contains(Object o) { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry entry = (Map.Entry)o; - Object key = entry.getKey(); - Entry tab[] = table; - int hash = (key==null ? 0 : key.hashCode()); - int index = (hash & 0x7FFFFFFF) % tab.length; - - for (Entry e = tab[index]; e != null; e = e.next) - if (e.hash==hash && e.equals(entry)) - return true; - return false; - } - - public boolean remove(Object o) { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry entry = (Map.Entry)o; - Object key = entry.getKey(); - Entry tab[] = table; - int hash = (key==null ? 0 : key.hashCode()); - int index = (hash & 0x7FFFFFFF) % tab.length; - - for (Entry e = tab[index], prev = null; e != null; - prev = e, e = e.next) { - if (e.hash==hash && e.equals(entry)) { - modCount++; - if (prev != null) - prev.next = e.next; - else - tab[index] = e.next; - - count--; - e.value = null; - listRemove(e); - return true; - } - } - return false; - } - - public int size() { - return count; - } - - public void clear() { - LinkedHashMap.this.clear(); - } - }; - } - - return entries; - } - - /** - * Compares the specified Object with this Map for equality. - * Returns true if the given object is also a LinkedHashMap and the two - * Maps represent the same mappings in the same order. More formally, - * two Maps t1 and t2 represent the same mappings - * if t1.keySet().equals(t2.keySet()) and for every - * key k in t1.keySet(), - * (t1.get(k)==null ? t2.get(k)==null : t1.get(k).equals(t2.get(k))) - * . - *

- * This implementation first checks if the specified Object is this Map; - * if so it returns true. Then, it checks if the specified Object is - * a Map whose size is identical to the size of this Set; if not, it - * it returns false. If so, it iterates over this Map and the specified - * Map's entrySet() Collection, and checks that the specified Map contains - * each mapping that this Map contains at the same position. If the - * specified Map fails to contain such a mapping in the right order, false - * is returned. If the iteration completes, true is returned. - * - * @param o Object to be compared for equality with this Map. - * @return true if the specified Object is equal to this Map. - * - */ - public boolean equals(Object o) { - if (o == this) - return true; - - if (!(o instanceof LinkedHashMap)) - return false; - LinkedHashMap t = (LinkedHashMap) o; - if (t.size() != size()) - return false; - - Iterator i1 = entrySet().iterator(); - Iterator i2 = t.entrySet().iterator(); - - while (i1.hasNext()) { - Entry e1 = (Entry) i1.next(); - Entry e2 = (Entry) i2.next(); - - Object key1 = e1.getKey(); - Object value1 = e1.getValue(); - Object key2 = e2.getKey(); - Object value2 = e2.getValue(); - - if ((key1 == null ? key2 == null : key1.equals(key2)) && - (value1 == null ? value2 == null : value1.equals(value2))) { - continue; - } else { - return false; - } - } - return true; - } - - /** - * LinkedHashMap collision list entry. - */ - private static class Entry implements Map.Entry { - int hash; - Object key; - Object value; - Entry next; - - // These fields comprise the doubly linked list that is used for - // iteration. - Entry before, after; - - Entry(int hash, Object key, Object value, Entry next) { - this.hash = hash; - this.key = key; - this.value = value; - this.next = next; - } - - // Map.Entry Ops - - public Object getKey() { - return key; - } - - public Object getValue() { - return value; - } - - public Object setValue(Object value) { - Object oldValue = this.value; - this.value = value; - return oldValue; - } - - public boolean equals(Object o) { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry e = (Map.Entry)o; - - return (key==null ? e.getKey()==null : key.equals(e.getKey())) && - (value==null ? e.getValue()==null : value.equals(e.getValue())); - } - - public int hashCode() { - return hash ^ (value==null ? 0 : value.hashCode()); - } - - public String toString() { - return key+"="+value; - } - } - - // Types of Iterators - private static final int KEYS = 0; - private static final int VALUES = 1; - private static final int ENTRIES = 2; - - private class HashIterator implements Iterator { - private Entry[] table = LinkedHashMap.this.table; - private Entry entry = null; - private Entry lastReturned = null; - private int type; - - /** - * The modCount value that the iterator believes that the backing - * List should have. If this expectation is violated, the iterator - * has detected concurrent modification. - */ - private int expectedModCount = modCount; - - HashIterator(int type) { - this.type = type; - this.entry = LinkedHashMap.this.header.after; - } - - public boolean hasNext() { - return entry != header; - } - - public Object next() { - if (modCount != expectedModCount) - throw new ConcurrentModificationException(); - if (entry == LinkedHashMap.this.header) - throw new NoSuchElementException(); - - Entry e = lastReturned = entry; - entry = e.after; - return type == KEYS ? e.key : (type == VALUES ? e.value : e); - } - - public void remove() { - if (lastReturned == null) - throw new IllegalStateException(); - if (modCount != expectedModCount) - throw new ConcurrentModificationException(); - - Entry[] tab = LinkedHashMap.this.table; - int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length; - - for (Entry e = tab[index], prev = null; e != null; - prev = e, e = e.next) { - if (e == lastReturned) { - modCount++; - expectedModCount++; - if (prev == null) - tab[index] = e.next; - else - prev.next = e.next; - count--; - listRemove(e); - lastReturned = null; - return; - } - } - throw new ConcurrentModificationException(); - } - } - - /** - * Save the state of the LinkedHashMap to a stream (i.e., serialize it). - * The objects will be written out in the order they are linked - * in the list. - */ - private void writeObject(java.io.ObjectOutputStream s) - throws IOException - { - // Write out the threshold, loadfactor, and any hidden stuff - s.defaultWriteObject(); - - // Write out number of buckets - s.writeInt(table.length); - - // Write out size (number of Mappings) - s.writeInt(count); - - // Write out keys and values (alternating) - for (Entry e = header.after; e != header; e = e.after) { - s.writeObject(e.key); - s.writeObject(e.value); - } - } - - /** - * Reconstitute the LinkedHashMap from a stream (i.e., deserialize it). - */ - private void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException - { - // Read in the threshold, loadfactor, and any hidden stuff - s.defaultReadObject(); - - // Read in number of buckets and allocate the bucket array; - int numBuckets = s.readInt(); - table = new Entry[numBuckets]; - header = new Entry(-1, null, null, null); - header.before = header; - header.after = header; - - // Read in size (number of Mappings) - int size = s.readInt(); - - // Read the keys and values, and put the mappings in the LinkedHashMap - for (int i=0; i signatures = parser.argumentSignatures(); if (signatures.size() != argSize) { throw new IllegalArgumentException("Invalid argument count: expected " + diff --git a/src/share/classes/com/sun/tools/jdi/MirrorImpl.java b/src/share/classes/com/sun/tools/jdi/MirrorImpl.java index 9a68f23f15a1a01817b3481e6ce3430089e8aecc..f3942c0804f4c9b1a75d3d9e207eb8ec39a2eb45 100644 --- a/src/share/classes/com/sun/tools/jdi/MirrorImpl.java +++ b/src/share/classes/com/sun/tools/jdi/MirrorImpl.java @@ -83,8 +83,8 @@ abstract class MirrorImpl extends Object implements Mirror { * Throw NullPointerException on null mirrors. * Throw VMMismatchException on wrong VM. */ - void validateMirrors(Collection mirrors) { - Iterator iter = mirrors.iterator(); + void validateMirrors(Collection mirrors) { + Iterator iter = mirrors.iterator(); while (iter.hasNext()) { MirrorImpl mirror = (MirrorImpl)iter.next(); if (!vm.equals(mirror.vm)) { @@ -96,8 +96,8 @@ abstract class MirrorImpl extends Object implements Mirror { * Allow null mirrors. * Throw VMMismatchException on wrong VM. */ - void validateMirrorsOrNulls(Collection mirrors) { - Iterator iter = mirrors.iterator(); + void validateMirrorsOrNulls(Collection mirrors) { + Iterator iter = mirrors.iterator(); while (iter.hasNext()) { MirrorImpl mirror = (MirrorImpl)iter.next(); if ((mirror != null) && !vm.equals(mirror.vm)) { diff --git a/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java index 1c2a8cbafc357a8ad4c379c8da28de0d3ae46142..b93d898f1f77e909ce5f292f8cfa194bde2fa470 100644 --- a/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java @@ -110,7 +110,7 @@ public class ObjectReferenceImpl extends ValueImpl public boolean vmNotSuspended(VMAction action) { // make sure that cache and listener management are synchronized synchronized (vm.state()) { - if (cache != null && (vm.traceFlags & vm.TRACE_OBJREFS) != 0) { + if (cache != null && (vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace("Clearing temporary cache for " + description()); } disableCache(); @@ -163,8 +163,8 @@ public class ObjectReferenceImpl extends ValueImpl public Value getValue(Field sig) { List list = new ArrayList(1); list.add(sig); - Map map = getValues(list); - return(Value)map.get(sig); + Map map = getValues(list); + return map.get(sig); } public Map getValues(List theFields) { @@ -487,7 +487,7 @@ public class ObjectReferenceImpl extends ValueImpl info = JDWP.ObjectReference.MonitorInfo.process(vm, this); if (local != null) { local.monitorInfo = info; - if ((vm.traceFlags & vm.TRACE_OBJREFS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace("ObjectReference " + uniqueID() + " temporarily caching monitor info"); } diff --git a/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java b/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java index 6b5d05588869fcfa8e9dcdc9291820af4b498cec..03f7b4778297ecec4e950470e5bbe44d88919038 100644 --- a/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java +++ b/src/share/classes/com/sun/tools/jdi/ProcessAttachingConnector.java @@ -127,7 +127,7 @@ public class ProcessAttachingConnector } else { if (lib.equals("dt_shmem")) { try { - Class c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService"); + Class c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService"); ts = (TransportService)c.newInstance(); } catch (Exception x) { } } diff --git a/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java b/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java index 133193c01a5536a1bf76eb7f3a982f17e1908357..cef298df314932bc1bfda7ff175c6378bd82c826 100644 --- a/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java +++ b/src/share/classes/com/sun/tools/jdi/RawCommandLineLauncher.java @@ -53,7 +53,7 @@ public class RawCommandLineLauncher extends AbstractLauncher implements Launchin super(); try { - Class c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService"); + Class c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService"); transportService = (TransportService)c.newInstance(); transport = new Transport() { public String name() { diff --git a/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java b/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java index ec0909076decc246192d9aa6c08f32d91fab490b..35543cae762c1f04dae06e52b01ec3bfd5b7585b 100644 --- a/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ReferenceTypeImpl.java @@ -99,7 +99,7 @@ implements ReferenceType { // Fetch all methods for the class, check performance impact // Needs no synchronization now, since methods() returns // unmodifiable local data - Iterator it = methods().iterator(); + Iterator it = methods().iterator(); while (it.hasNext()) { MethodImpl method = (MethodImpl)it.next(); if (method.ref() == ref) { @@ -113,7 +113,7 @@ implements ReferenceType { // Fetch all fields for the class, check performance impact // Needs no synchronization now, since fields() returns // unmodifiable local data - Iterator it = fields().iterator(); + Iteratorit = fields().iterator(); while (it.hasNext()) { FieldImpl field = (FieldImpl)it.next(); if (field.ref() == ref) { @@ -385,7 +385,7 @@ implements ReferenceType { /* Add inherited, visible fields */ List types = inheritedTypes(); - Iterator iter = types.iterator(); + Iterator iter = types.iterator(); while (iter.hasNext()) { /* * TO DO: Be defensive and check for cyclic interface inheritance @@ -419,7 +419,7 @@ implements ReferenceType { /* Add inherited fields */ List types = inheritedTypes(); - Iterator iter = types.iterator(); + Iterator iter = types.iterator(); while (iter.hasNext()) { ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next(); type.addAllFields(fieldList, typeSet); @@ -434,13 +434,10 @@ implements ReferenceType { } public Field fieldByName(String fieldName) { - java.util.List searchList; - Field f; - - searchList = visibleFields(); + List searchList = visibleFields(); for (int i=0; i nestedTypes() { - List all = vm.allClasses(); + List all = vm.allClasses(); List nested = new ArrayList(); String outername = name(); int outerlen = outername.length(); - Iterator iter = all.iterator(); + Iterator iter = all.iterator(); while (iter.hasNext()) { - ReferenceType refType = (ReferenceType)iter.next(); + ReferenceType refType = iter.next(); String name = refType.name(); int len = name.length(); /* The separator is historically '$' but could also be '#' */ @@ -598,8 +595,8 @@ implements ReferenceType { public Value getValue(Field sig) { List list = new ArrayList(1); list.add(sig); - Map map = getValues(list); - return(Value)map.get(sig); + Map map = getValues(list); + return map.get(sig); } @@ -847,7 +844,7 @@ implements ReferenceType { SDE.Stratum stratum = stratum(stratumID); List list = new ArrayList(); // location list - for (Iterator iter = methods().iterator(); iter.hasNext(); ) { + for (Iterator iter = methods().iterator(); iter.hasNext(); ) { MethodImpl method = (MethodImpl)iter.next(); try { list.addAll( @@ -887,7 +884,7 @@ implements ReferenceType { List list = new ArrayList(); - Iterator iter = methods.iterator(); + Iterator iter = methods.iterator(); while(iter.hasNext()) { MethodImpl method = (MethodImpl)iter.next(); // eliminate native and abstract to eliminate diff --git a/src/share/classes/com/sun/tools/jdi/ShortValueImpl.java b/src/share/classes/com/sun/tools/jdi/ShortValueImpl.java index 7ed631dc18f6c7e92f3f20f7db8abae4f94a9cbd..ea9ec0b2b16b9d60047e5363ef9dfd64c139f1a3 100644 --- a/src/share/classes/com/sun/tools/jdi/ShortValueImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ShortValueImpl.java @@ -79,7 +79,7 @@ public class ShortValueImpl extends PrimitiveValueImpl } public short shortValue() { - return(short)value; + return value; } public int intValue() { diff --git a/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java b/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java index 8b16fc69134cb68d7ef8e927a6b58d124b3da105..40ff2223ae499a4c4d88274fac609c918b27b467 100644 --- a/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java +++ b/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java @@ -64,7 +64,7 @@ public class SunCommandLineLauncher extends AbstractLauncher implements Launchin * transport or the socket transport */ try { - Class c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService"); + Class c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService"); transportService = (TransportService)c.newInstance(); transport = new Transport() { public String name() { diff --git a/src/share/classes/com/sun/tools/jdi/TargetVM.java b/src/share/classes/com/sun/tools/jdi/TargetVM.java index 2853e0155bbe6b8ff3faa501c34dd2cf5812eaf3..0feac853687605e59168f595eb67c5aa46b14c5b 100644 --- a/src/share/classes/com/sun/tools/jdi/TargetVM.java +++ b/src/share/classes/com/sun/tools/jdi/TargetVM.java @@ -178,7 +178,7 @@ public class TargetVM implements Runnable { // Closing a queue causes a VMDisconnectEvent to // be put onto the queue. synchronized(eventQueues) { - Iterator iter = eventQueues.iterator(); + Iterator iter = eventQueues.iterator(); while (iter.hasNext()) { ((EventQueueImpl)iter.next()).close(); } @@ -187,9 +187,9 @@ public class TargetVM implements Runnable { // indirectly throw VMDisconnectedException to // command requesters. synchronized(waitingQueue) { - Iterator iter = waitingQueue.values().iterator(); + Iterator iter = waitingQueue.values().iterator(); while (iter.hasNext()) { - Packet packet = (Packet)iter.next(); + Packet packet = iter.next(); synchronized(packet) { packet.notify(); } @@ -252,7 +252,7 @@ public class TargetVM implements Runnable { void notifyDequeueEventSet() { int maxQueueSize = 0; synchronized(eventQueues) { - Iterator iter = eventQueues.iterator(); + Iterator iter = eventQueues.iterator(); while (iter.hasNext()) { EventQueueImpl queue = (EventQueueImpl)iter.next(); maxQueueSize = Math.max(maxQueueSize, queue.size()); @@ -265,7 +265,7 @@ public class TargetVM implements Runnable { int maxQueueSize = 0; synchronized(eventQueues) { - Iterator iter = eventQueues.iterator(); + Iterator iter = eventQueues.iterator(); while (iter.hasNext()) { EventQueueImpl queue = (EventQueueImpl)iter.next(); queue.enqueue(eventSet); diff --git a/src/share/classes/com/sun/tools/jdi/ThreadAction.java b/src/share/classes/com/sun/tools/jdi/ThreadAction.java index 53943410cef9742652aa9c4c88abaa286fe1ab74..818714285ea402407fa7b51bb0f6aa2477a57042 100644 --- a/src/share/classes/com/sun/tools/jdi/ThreadAction.java +++ b/src/share/classes/com/sun/tools/jdi/ThreadAction.java @@ -33,6 +33,7 @@ import java.util.EventObject; * with JDI events. */ class ThreadAction extends EventObject { + private static final long serialVersionUID = 5690763191100515283L; // Event ids /*static final int THREAD_SUSPENDED = 1;*/ static final int THREAD_RESUMABLE = 2; diff --git a/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java index 3d5d20365f8b66956f5e9c55ccfbd97d48751152..5cc79f7462365c3c63a7ba57d7c0d8972c6ffd0a 100644 --- a/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ThreadGroupReferenceImpl.java @@ -118,7 +118,7 @@ public class ThreadGroupReferenceImpl extends ObjectReferenceImpl .process(vm, this); if (local != null) { local.kids = kids; - if ((vm.traceFlags & vm.TRACE_OBJREFS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace(description() + " temporarily caching children "); } diff --git a/src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java b/src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java index f694afc2aa382b84c102ce2157ed146695e52c27..d76f60c2c6334a4c175ee50f67c7af414bc884ba 100644 --- a/src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java +++ b/src/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java @@ -240,7 +240,7 @@ public class ThreadReferenceImpl extends ObjectReferenceImpl public void stop(ObjectReference throwable) throws InvalidTypeException { validateMirror(throwable); // Verify that the given object is a Throwable instance - List list = vm.classesByName("java.lang.Throwable"); + List list = vm.classesByName("java.lang.Throwable"); ClassTypeImpl throwableClass = (ClassTypeImpl)list.get(0); if ((throwable == null) || !throwableClass.isAssignableFrom(throwable)) { @@ -296,10 +296,10 @@ public class ThreadReferenceImpl extends ObjectReferenceImpl try { StackFrame frame = frame(0); Location location = frame.location(); - List requests = vm.eventRequestManager().breakpointRequests(); - Iterator iter = requests.iterator(); + List requests = vm.eventRequestManager().breakpointRequests(); + Iterator iter = requests.iterator(); while (iter.hasNext()) { - BreakpointRequest request = (BreakpointRequest)iter.next(); + BreakpointRequest request = iter.next(); if (location.equals(request.location())) { return true; } @@ -352,8 +352,8 @@ public class ThreadReferenceImpl extends ObjectReferenceImpl } public StackFrame frame(int index) throws IncompatibleThreadStateException { - List list = privateFrames(index, 1); - return (StackFrame)list.get(0); + List list = privateFrames(index, 1); + return list.get(0); } /** @@ -447,7 +447,7 @@ public class ThreadReferenceImpl extends ObjectReferenceImpl snapshot.ownedMonitors = Arrays.asList( (ObjectReference[])JDWP.ThreadReference.OwnedMonitors. process(vm, this).owned); - if ((vm.traceFlags & vm.TRACE_OBJREFS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace(description() + " temporarily caching owned monitors"+ " (count = " + snapshot.ownedMonitors.size() + ")"); @@ -475,7 +475,7 @@ public class ThreadReferenceImpl extends ObjectReferenceImpl process(vm, this).monitor; snapshot.triedCurrentContended = true; if ((snapshot.contendedMonitor != null) && - ((vm.traceFlags & vm.TRACE_OBJREFS) != 0)) { + ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0)) { vm.printTrace(description() + " temporarily caching contended monitor"+ " (id = " + snapshot.contendedMonitor.uniqueID() + ")"); @@ -509,7 +509,7 @@ public class ThreadReferenceImpl extends ObjectReferenceImpl snapshot.ownedMonitorsInfo.add(mon); } - if ((vm.traceFlags & vm.TRACE_OBJREFS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace(description() + " temporarily caching owned monitors"+ " (count = " + snapshot.ownedMonitorsInfo.size() + ")"); @@ -601,9 +601,9 @@ public class ThreadReferenceImpl extends ObjectReferenceImpl void removeListener(ThreadListener listener) { synchronized (vm.state()) { - Iterator iter = listeners.iterator(); + Iterator> iter = listeners.iterator(); while (iter.hasNext()) { - WeakReference ref = (WeakReference)iter.next(); + WeakReference ref = iter.next(); if (listener.equals(ref.get())) { iter.remove(); break; @@ -619,10 +619,10 @@ public class ThreadReferenceImpl extends ObjectReferenceImpl */ private void processThreadAction(ThreadAction action) { synchronized (vm.state()) { - Iterator iter = listeners.iterator(); + Iterator> iter = listeners.iterator(); while (iter.hasNext()) { - WeakReference ref = (WeakReference)iter.next(); - ThreadListener listener = (ThreadListener)ref.get(); + WeakReference ref = iter.next(); + ThreadListener listener = ref.get(); if (listener != null) { switch (action.id()) { case ThreadAction.THREAD_RESUMABLE: diff --git a/src/share/classes/com/sun/tools/jdi/VMAction.java b/src/share/classes/com/sun/tools/jdi/VMAction.java index 7b9dc049a0199d4fd49fbfc2866cd2e5d3bb3704..91d69725c9c014bf1e44082bb17bfc0e102196ea 100644 --- a/src/share/classes/com/sun/tools/jdi/VMAction.java +++ b/src/share/classes/com/sun/tools/jdi/VMAction.java @@ -33,6 +33,8 @@ import java.util.EventObject; * with JDI events. */ class VMAction extends EventObject { + private static final long serialVersionUID = -1701944679310296090L; + // Event ids static final int VM_SUSPENDED = 1; static final int VM_NOT_SUSPENDED = 2; diff --git a/src/share/classes/com/sun/tools/jdi/VMState.java b/src/share/classes/com/sun/tools/jdi/VMState.java index de49e8a68df02c79d4c183e35a541ce00ea589d3..76c6804d45be8309228e7d7cc6cb98c6219e1d04 100644 --- a/src/share/classes/com/sun/tools/jdi/VMState.java +++ b/src/share/classes/com/sun/tools/jdi/VMState.java @@ -34,7 +34,7 @@ class VMState { private final VirtualMachineImpl vm; // Listeners - private final List listeners = new ArrayList(); // synchronized (this) + private final List> listeners = new ArrayList>(); // synchronized (this) private boolean notifyingListeners = false; // synchronized (this) /* @@ -129,7 +129,7 @@ class VMState { */ synchronized void thaw(ThreadReference resumingThread) { if (cache != null) { - if ((vm.traceFlags & vm.TRACE_OBJREFS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace("Clearing VM suspended cache"); } disableCache(); @@ -142,10 +142,10 @@ class VMState { // Prevent recursion notifyingListeners = true; - Iterator iter = listeners.iterator(); + Iterator> iter = listeners.iterator(); while (iter.hasNext()) { - WeakReference ref = (WeakReference)iter.next(); - VMListener listener = (VMListener)ref.get(); + WeakReference ref = iter.next(); + VMListener listener = ref.get(); if (listener != null) { boolean keep = true; switch (action.id()) { @@ -178,9 +178,9 @@ class VMState { } synchronized void removeListener(VMListener listener) { - Iterator iter = listeners.iterator(); + Iterator> iter = listeners.iterator(); while (iter.hasNext()) { - WeakReference ref = (WeakReference)iter.next(); + WeakReference ref = iter.next(); if (listener.equals(ref.get())) { iter.remove(); break; @@ -202,7 +202,7 @@ class VMState { process(vm).threads); if (local != null) { local.threads = threads; - if ((vm.traceFlags & vm.TRACE_OBJREFS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace("Caching all threads (count = " + threads.size() + ") while VM suspended"); } @@ -229,7 +229,7 @@ class VMState { process(vm).groups); if (local != null) { local.groups = groups; - if ((vm.traceFlags & vm.TRACE_OBJREFS) != 0) { + if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace( "Caching top level thread groups (count = " + groups.size() + ") while VM suspended"); diff --git a/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java b/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java index 7367b938a9f631f238934c4401d871b128e9181f..6cde25ee84be3d856e9c0b234247128911bab860 100644 --- a/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java +++ b/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java @@ -300,9 +300,9 @@ class VirtualMachineImpl extends MirrorImpl if (!canRedefineClasses()) { throw new UnsupportedOperationException(); } - Iterator it = classToBytes.entrySet().iterator(); + Iterator it = classToBytes.entrySet().iterator(); for (int i = 0; it.hasNext(); i++) { - Map.Entry entry = (Map.Entry)it.next(); + Map.Entry entry = (Map.Entry)it.next(); ReferenceTypeImpl refType = (ReferenceTypeImpl)entry.getKey(); validateMirror(refType); defs[i] = new JDWP.VirtualMachine.RedefineClasses @@ -801,7 +801,7 @@ class VirtualMachineImpl extends MirrorImpl * we can't differentiate here, we first remove all * matching classes from our cache... */ - Iterator iter = typesBySignature.iterator(); + Iterator iter = typesBySignature.iterator(); int matches = 0; while (iter.hasNext()) { ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next(); @@ -833,7 +833,7 @@ class VirtualMachineImpl extends MirrorImpl if (typesByID == null) { return new ArrayList(0); } - Iterator iter = typesBySignature.iterator(); + Iterator iter = typesBySignature.iterator(); List list = new ArrayList(); while (iter.hasNext()) { ReferenceTypeImpl type = (ReferenceTypeImpl)iter.next(); @@ -1041,10 +1041,10 @@ class VirtualMachineImpl extends MirrorImpl } Type findBootType(String signature) throws ClassNotLoadedException { - List types = allClasses(); - Iterator iter = types.iterator(); + List types = allClasses(); + Iterator iter = types.iterator(); while (iter.hasNext()) { - ReferenceType type = (ReferenceType)iter.next(); + ReferenceType type = iter.next(); if ((type.classLoader() == null) && (type.signature().equals(signature))) { return type; @@ -1227,7 +1227,7 @@ class VirtualMachineImpl extends MirrorImpl } private void processQueue() { - Reference ref; + Reference ref; //if ((traceFlags & TRACE_OBJREFS) != 0) { // printTrace("Checking for softly reachable objects"); //} diff --git a/src/share/classes/java/lang/Boolean.java b/src/share/classes/java/lang/Boolean.java index 9bf79a320f7f1b317d8a2a510ba827134bcde5ab..feb199465eccda0db481475093cd4c12d558e93c 100644 --- a/src/share/classes/java/lang/Boolean.java +++ b/src/share/classes/java/lang/Boolean.java @@ -60,7 +60,8 @@ public final class Boolean implements java.io.Serializable, * * @since JDK1.1 */ - public static final Class TYPE = Class.getPrimitiveClass("boolean"); + @SuppressWarnings("unchecked") + public static final Class TYPE = (Class) Class.getPrimitiveClass("boolean"); /** * The value of the Boolean. diff --git a/src/share/classes/java/lang/Byte.java b/src/share/classes/java/lang/Byte.java index cb260f803c9d99f714028c4b849a39bad051b041..4c0b1c2233bb97b90b962560f48af5c0c99385d5 100644 --- a/src/share/classes/java/lang/Byte.java +++ b/src/share/classes/java/lang/Byte.java @@ -59,6 +59,7 @@ public final class Byte extends Number implements Comparable { * The {@code Class} instance representing the primitive type * {@code byte}. */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("byte"); /** diff --git a/src/share/classes/java/lang/Character.java b/src/share/classes/java/lang/Character.java index 216098bd5335bc3579d344bbb70b5578f87fdfc0..c03896d987d28e3dc3b4f28245d6405d602f9b38 100644 --- a/src/share/classes/java/lang/Character.java +++ b/src/share/classes/java/lang/Character.java @@ -172,7 +172,7 @@ class Character implements java.io.Serializable, Comparable { * @since 1.1 */ @SuppressWarnings("unchecked") - public static final Class TYPE = Class.getPrimitiveClass("char"); + public static final Class TYPE = (Class) Class.getPrimitiveClass("char"); /* * Normative general types diff --git a/src/share/classes/java/lang/CharacterName.java b/src/share/classes/java/lang/CharacterName.java index a2d84635151c256b42650becf73ce9145f023763..b8e66e39c9f1a356da5296d0741af20ab8e854a1 100644 --- a/src/share/classes/java/lang/CharacterName.java +++ b/src/share/classes/java/lang/CharacterName.java @@ -101,6 +101,8 @@ class CharacterName { if (lookup[cp>>8] == null || (off = lookup[cp>>8][cp&0xff]) == 0) return null; - return new String(strPool, 0, off >>> 8, off & 0xff); // ASCII + @SuppressWarnings("deprecation") + String result = new String(strPool, 0, off >>> 8, off & 0xff); // ASCII + return result; } } diff --git a/src/share/classes/java/lang/Class.java b/src/share/classes/java/lang/Class.java index ca7f1be7927ae4710e38c4bf77240501bfc0cff7..f762d16707ea1c73884ae3122793275ccb43f331 100644 --- a/src/share/classes/java/lang/Class.java +++ b/src/share/classes/java/lang/Class.java @@ -631,6 +631,7 @@ public final * The Java™ Virtual Machine Specification * @since 1.5 */ + @SuppressWarnings("unchecked") public TypeVariable>[] getTypeParameters() { if (getGenericSignature() != null) return (TypeVariable>[])getGenericInfo().getTypeParameters(); @@ -1303,7 +1304,7 @@ public final return java.security.AccessController.doPrivileged( new java.security.PrivilegedAction[]>() { - public Class[] run() { + public Class[] run() { List> list = new ArrayList<>(); Class currentClass = Class.this; while (currentClass != null) { @@ -1315,7 +1316,7 @@ public final } currentClass = currentClass.getSuperclass(); } - return list.toArray(new Class[0]); + return list.toArray(new Class[0]); } }); } @@ -2150,7 +2151,7 @@ public final * Return the Virtual Machine's Class object for the named * primitive type. */ - static native Class getPrimitiveClass(String name); + static native Class getPrimitiveClass(String name); /* @@ -2395,7 +2396,9 @@ public final } // No cached value available; request value from VM if (isInterface()) { - res = new Constructor[0]; + @SuppressWarnings("unchecked") + Constructor[] temporaryRes = (Constructor[]) new Constructor[0]; + res = temporaryRes; } else { res = getDeclaredConstructors0(publicOnly); } @@ -2951,7 +2954,9 @@ public final return null; } }); - enumConstants = (T[])values.invoke(null); + @SuppressWarnings("unchecked") + T[] temporaryConstants = (T[])values.invoke(null); + enumConstants = temporaryConstants; } // These can happen when users concoct enum-like classes // that don't comply with the enum spec. @@ -2996,6 +3001,7 @@ public final * * @since 1.5 */ + @SuppressWarnings("unchecked") public T cast(Object obj) { if (obj != null && !isInstance(obj)) throw new ClassCastException(cannotCastMsg(obj)); @@ -3026,6 +3032,7 @@ public final * the class itself). * @since 1.5 */ + @SuppressWarnings("unchecked") public Class asSubclass(Class clazz) { if (clazz.isAssignableFrom(this)) return (Class) this; @@ -3037,6 +3044,7 @@ public final * @throws NullPointerException {@inheritDoc} * @since 1.5 */ + @SuppressWarnings("unchecked") public A getAnnotation(Class annotationClass) { if (annotationClass == null) throw new NullPointerException(); diff --git a/src/share/classes/java/lang/ClassLoader.java b/src/share/classes/java/lang/ClassLoader.java index d599396e8ad016e3c14c5c1767a5d243572c9e51..3dc1a1076b5884dbb57fbebcbb9a4875909945da 100644 --- a/src/share/classes/java/lang/ClassLoader.java +++ b/src/share/classes/java/lang/ClassLoader.java @@ -1167,7 +1167,8 @@ public abstract class ClassLoader { * @since 1.2 */ public Enumeration getResources(String name) throws IOException { - Enumeration[] tmp = new Enumeration[2]; + @SuppressWarnings("unchecked") + Enumeration[] tmp = (Enumeration[]) new Enumeration[2]; if (parent != null) { tmp[0] = parent.getResources(name); } else { diff --git a/src/share/classes/java/lang/ConditionalSpecialCasing.java b/src/share/classes/java/lang/ConditionalSpecialCasing.java index f45fe3a70298fe2e52cea69f25410d3be08d4e2a..9b2c85004caeb8f195d77f118bf2fc53fa42d55b 100644 --- a/src/share/classes/java/lang/ConditionalSpecialCasing.java +++ b/src/share/classes/java/lang/ConditionalSpecialCasing.java @@ -92,15 +92,15 @@ final class ConditionalSpecialCasing { }; // A hash table that contains the above entries - static Hashtable entryTable = new Hashtable(); + static Hashtable> entryTable = new Hashtable<>(); static { // create hashtable from the entry for (int i = 0; i < entry.length; i ++) { Entry cur = entry[i]; Integer cp = new Integer(cur.getCodePoint()); - HashSet set = (HashSet)entryTable.get(cp); + HashSet set = entryTable.get(cp); if (set == null) { - set = new HashSet(); + set = new HashSet(); } set.add(cur); entryTable.put(cp, set); @@ -151,13 +151,13 @@ final class ConditionalSpecialCasing { } private static char[] lookUpTable(String src, int index, Locale locale, boolean bLowerCasing) { - HashSet set = (HashSet)entryTable.get(new Integer(src.codePointAt(index))); + HashSet set = entryTable.get(new Integer(src.codePointAt(index))); if (set != null) { - Iterator iter = set.iterator(); + Iterator iter = set.iterator(); String currentLang = locale.getLanguage(); while (iter.hasNext()) { - Entry entry = (Entry)iter.next(); + Entry entry = iter.next(); String conditionLang= entry.getLanguage(); if (((conditionLang == null) || (conditionLang.equals(currentLang))) && isConditionMet(src, index, locale, entry.getCondition())) { diff --git a/src/share/classes/java/lang/Double.java b/src/share/classes/java/lang/Double.java index 70e6a7c60f321834e3adedfc572907bd3fbb3d21..8bf9853537d69117a498ddbf1f35720fc7fe72ce 100644 --- a/src/share/classes/java/lang/Double.java +++ b/src/share/classes/java/lang/Double.java @@ -128,6 +128,7 @@ public final class Double extends Number implements Comparable { * * @since JDK1.1 */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("double"); /** @@ -715,7 +716,7 @@ public final class Double extends Number implements Comparable { * @return the {@code double} value represented by this object */ public double doubleValue() { - return (double)value; + return value; } /** diff --git a/src/share/classes/java/lang/EnumConstantNotPresentException.java b/src/share/classes/java/lang/EnumConstantNotPresentException.java index 76bfd2715b5e9e2191c3b94320563e17674e136f..6db7df4a4eabf962c9e5bcf5bd49ccbae0347a94 100644 --- a/src/share/classes/java/lang/EnumConstantNotPresentException.java +++ b/src/share/classes/java/lang/EnumConstantNotPresentException.java @@ -36,6 +36,7 @@ package java.lang; * @see java.lang.reflect.AnnotatedElement * @since 1.5 */ +@SuppressWarnings("rawtypes") /* rawtypes are part of the public api */ public class EnumConstantNotPresentException extends RuntimeException { private static final long serialVersionUID = -6046998521960521108L; diff --git a/src/share/classes/java/lang/Float.java b/src/share/classes/java/lang/Float.java index bd32e366a3d9f1df3c5212d95dc5a1bba615ee5a..65a230a12a59cb3ea5785a3b042f7e06703c182d 100644 --- a/src/share/classes/java/lang/Float.java +++ b/src/share/classes/java/lang/Float.java @@ -126,7 +126,8 @@ public final class Float extends Number implements Comparable { * * @since JDK1.1 */ - public static final Class TYPE = Class.getPrimitiveClass("float"); + @SuppressWarnings("unchecked") + public static final Class TYPE = (Class) Class.getPrimitiveClass("float"); /** * Returns a string representation of the {@code float} diff --git a/src/share/classes/java/lang/Integer.java b/src/share/classes/java/lang/Integer.java index f3bba73b60ddce298c9822b09418c1a20f7ae831..dee52ae1fa852717c2730b7b4120d94f1460b1a1 100644 --- a/src/share/classes/java/lang/Integer.java +++ b/src/share/classes/java/lang/Integer.java @@ -68,6 +68,7 @@ public final class Integer extends Number implements Comparable { * * @since JDK1.1 */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("int"); /** diff --git a/src/share/classes/java/lang/Long.java b/src/share/classes/java/lang/Long.java index 31648edd9e2db4a9964523e47eef47289b0d749f..a87f4096d4df77eaf41d37ce490bb56960547136 100644 --- a/src/share/classes/java/lang/Long.java +++ b/src/share/classes/java/lang/Long.java @@ -66,6 +66,7 @@ public final class Long extends Number implements Comparable { * * @since JDK1.1 */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("long"); /** @@ -734,7 +735,7 @@ public final class Long extends Number implements Comparable { * {@code long} value. */ public long longValue() { - return (long)value; + return value; } /** diff --git a/src/share/classes/java/lang/Short.java b/src/share/classes/java/lang/Short.java index 15a00e17ff65c2ad2af06b725f2b3754182fe62a..6509039fe0ce209b0fdfca7350bcabd9aaf8b7c9 100644 --- a/src/share/classes/java/lang/Short.java +++ b/src/share/classes/java/lang/Short.java @@ -58,6 +58,7 @@ public final class Short extends Number implements Comparable { * The {@code Class} instance representing the primitive type * {@code short}. */ + @SuppressWarnings("unchecked") public static final Class TYPE = (Class) Class.getPrimitiveClass("short"); /** diff --git a/src/share/classes/java/lang/System.java b/src/share/classes/java/lang/System.java index 6e4f7436cf826bdf905c7b72935c501bff658597..e2b010e086bd7e346ffe5dfc0905d20d1f3feee6 100644 --- a/src/share/classes/java/lang/System.java +++ b/src/share/classes/java/lang/System.java @@ -1032,7 +1032,7 @@ public final class System { */ @Deprecated public static void runFinalizersOnExit(boolean value) { - Runtime.getRuntime().runFinalizersOnExit(value); + Runtime.runFinalizersOnExit(value); } /** diff --git a/src/share/classes/java/lang/ThreadLocal.java b/src/share/classes/java/lang/ThreadLocal.java index 50dcf9bfc7d47035aedfd2b944c17b08ff7bc1a5..e5c6e1f78b5b4983eb0e8acf93fa27f6553a0246 100644 --- a/src/share/classes/java/lang/ThreadLocal.java +++ b/src/share/classes/java/lang/ThreadLocal.java @@ -144,8 +144,11 @@ public class ThreadLocal { ThreadLocalMap map = getMap(t); if (map != null) { ThreadLocalMap.Entry e = map.getEntry(this); - if (e != null) - return (T)e.value; + if (e != null) { + @SuppressWarnings("unchecked") + T result = (T)e.value; + return result; + } } return setInitialValue(); } @@ -268,11 +271,11 @@ public class ThreadLocal { * entry can be expunged from table. Such entries are referred to * as "stale entries" in the code that follows. */ - static class Entry extends WeakReference { + static class Entry extends WeakReference> { /** The value associated with this ThreadLocal. */ Object value; - Entry(ThreadLocal k, Object v) { + Entry(ThreadLocal k, Object v) { super(k); value = v; } @@ -325,7 +328,7 @@ public class ThreadLocal { * ThreadLocalMaps are constructed lazily, so we only create * one when we have at least one entry to put in it. */ - ThreadLocalMap(ThreadLocal firstKey, Object firstValue) { + ThreadLocalMap(ThreadLocal firstKey, Object firstValue) { table = new Entry[INITIAL_CAPACITY]; int i = firstKey.threadLocalHashCode & (INITIAL_CAPACITY - 1); table[i] = new Entry(firstKey, firstValue); @@ -348,7 +351,8 @@ public class ThreadLocal { for (int j = 0; j < len; j++) { Entry e = parentTable[j]; if (e != null) { - ThreadLocal key = e.get(); + @SuppressWarnings("unchecked") + ThreadLocal key = (ThreadLocal) e.get(); if (key != null) { Object value = key.childValue(e.value); Entry c = new Entry(key, value); @@ -372,7 +376,7 @@ public class ThreadLocal { * @param key the thread local object * @return the entry associated with key, or null if no such */ - private Entry getEntry(ThreadLocal key) { + private Entry getEntry(ThreadLocal key) { int i = key.threadLocalHashCode & (table.length - 1); Entry e = table[i]; if (e != null && e.get() == key) @@ -390,12 +394,12 @@ public class ThreadLocal { * @param e the entry at table[i] * @return the entry associated with key, or null if no such */ - private Entry getEntryAfterMiss(ThreadLocal key, int i, Entry e) { + private Entry getEntryAfterMiss(ThreadLocal key, int i, Entry e) { Entry[] tab = table; int len = tab.length; while (e != null) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); if (k == key) return e; if (k == null) @@ -413,7 +417,7 @@ public class ThreadLocal { * @param key the thread local object * @param value the value to be set */ - private void set(ThreadLocal key, Object value) { + private void set(ThreadLocal key, Object value) { // We don't use a fast path as with get() because it is at // least as common to use set() to create new entries as @@ -427,7 +431,7 @@ public class ThreadLocal { for (Entry e = tab[i]; e != null; e = tab[i = nextIndex(i, len)]) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); if (k == key) { e.value = value; @@ -449,7 +453,7 @@ public class ThreadLocal { /** * Remove the entry for key. */ - private void remove(ThreadLocal key) { + private void remove(ThreadLocal key) { Entry[] tab = table; int len = tab.length; int i = key.threadLocalHashCode & (len-1); @@ -479,7 +483,7 @@ public class ThreadLocal { * @param staleSlot index of the first stale entry encountered while * searching for key. */ - private void replaceStaleEntry(ThreadLocal key, Object value, + private void replaceStaleEntry(ThreadLocal key, Object value, int staleSlot) { Entry[] tab = table; int len = tab.length; @@ -501,7 +505,7 @@ public class ThreadLocal { for (int i = nextIndex(staleSlot, len); (e = tab[i]) != null; i = nextIndex(i, len)) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); // If we find key, then we need to swap it // with the stale entry to maintain hash table order. @@ -563,7 +567,7 @@ public class ThreadLocal { for (i = nextIndex(staleSlot, len); (e = tab[i]) != null; i = nextIndex(i, len)) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); if (k == null) { e.value = null; tab[i] = null; @@ -650,7 +654,7 @@ public class ThreadLocal { for (int j = 0; j < oldLen; ++j) { Entry e = oldTab[j]; if (e != null) { - ThreadLocal k = e.get(); + ThreadLocal k = e.get(); if (k == null) { e.value = null; // Help the GC } else { diff --git a/src/share/classes/java/lang/Void.java b/src/share/classes/java/lang/Void.java index 52a6f2f56c7bf119bcd42f3440e158dc7870fd6e..9231b88a107d0051d8ba5e8695d30366585c174c 100644 --- a/src/share/classes/java/lang/Void.java +++ b/src/share/classes/java/lang/Void.java @@ -40,7 +40,8 @@ class Void { * The {@code Class} object representing the pseudo-type corresponding to * the keyword {@code void}. */ - public static final Class TYPE = Class.getPrimitiveClass("void"); + @SuppressWarnings("unchecked") + public static final Class TYPE = (Class) Class.getPrimitiveClass("void"); /* * The Void class cannot be instantiated. diff --git a/src/share/classes/java/net/HttpCookie.java b/src/share/classes/java/net/HttpCookie.java index 52d1218835ac62b73ea88d59c1da3be57cc074ff..bb12564193d9c7ede6dafe2d40040331372d5b8d 100644 --- a/src/share/classes/java/net/HttpCookie.java +++ b/src/share/classes/java/net/HttpCookie.java @@ -72,6 +72,10 @@ public final class HttpCookie implements Cloneable { private boolean httpOnly; // HttpOnly ... i.e. not accessible to scripts private int version = 1; // Version=1 ... RFC 2965 style + // The original header this cookie was consructed from, if it was + // constructed by parsing a header, otherwise null. + private final String header; + // Hold the creation time (in seconds) of the http cookie for later // expiration calculation private final long whenCreated; @@ -128,6 +132,10 @@ public final class HttpCookie implements Cloneable { * @see #setVersion */ public HttpCookie(String name, String value) { + this(name, value, null /*header*/); + } + + private HttpCookie(String name, String value, String header) { name = name.trim(); if (name.length() == 0 || !isToken(name) || isReserved(name)) { throw new IllegalArgumentException("Illegal cookie name"); @@ -140,6 +148,7 @@ public final class HttpCookie implements Cloneable { whenCreated = System.currentTimeMillis(); portlist = null; + this.header = header; } /** @@ -163,6 +172,15 @@ public final class HttpCookie implements Cloneable { * if the header string is {@code null} */ public static List parse(String header) { + return parse(header, false); + } + + // Private version of parse() that will store the original header used to + // create the cookie, in the cookie itself. This can be useful for filtering + // Set-Cookie[2] headers, using the internal parsing logic defined in this + // class. + private static List parse(String header, boolean retainHeader) { + int version = guessCookieVersion(header); // if header start with set-cookie or set-cookie2, strip it off @@ -178,7 +196,7 @@ public final class HttpCookie implements Cloneable { // so the parse logic is slightly different if (version == 0) { // Netscape draft cookie - HttpCookie cookie = parseInternal(header); + HttpCookie cookie = parseInternal(header, retainHeader); cookie.setVersion(0); cookies.add(cookie); } else { @@ -187,7 +205,7 @@ public final class HttpCookie implements Cloneable { // it'll separate them with comma List cookieStrings = splitMultiCookies(header); for (String cookieStr : cookieStrings) { - HttpCookie cookie = parseInternal(cookieStr); + HttpCookie cookie = parseInternal(cookieStr, retainHeader); cookie.setVersion(1); cookies.add(cookie); } @@ -804,7 +822,8 @@ public final class HttpCookie implements Cloneable { * @throws IllegalArgumentException * if header string violates the cookie specification */ - private static HttpCookie parseInternal(String header) + private static HttpCookie parseInternal(String header, + boolean retainHeader) { HttpCookie cookie = null; String namevaluePair = null; @@ -819,7 +838,13 @@ public final class HttpCookie implements Cloneable { if (index != -1) { String name = namevaluePair.substring(0, index).trim(); String value = namevaluePair.substring(index + 1).trim(); - cookie = new HttpCookie(name, stripOffSurroundingQuote(value)); + if (retainHeader) + cookie = new HttpCookie(name, + stripOffSurroundingQuote(value), + header); + else + cookie = new HttpCookie(name, + stripOffSurroundingQuote(value)); } else { // no "=" in name-value pair; it's an error throw new IllegalArgumentException("Invalid cookie name-value pair"); @@ -972,6 +997,28 @@ public final class HttpCookie implements Cloneable { } } + static { + sun.misc.SharedSecrets.setJavaNetHttpCookieAccess( + new sun.misc.JavaNetHttpCookieAccess() { + public List parse(String header) { + return HttpCookie.parse(header, true); + } + + public String header(HttpCookie cookie) { + return cookie.header; + } + } + ); + } + + /* + * Returns the original header this cookie was consructed from, if it was + * constructed by parsing a header, otherwise null. + */ + private String header() { + return header; + } + /* * Constructs a string representation of this cookie. The string format is * as Netscape spec, but without leading "Cookie:" token. diff --git a/src/share/classes/java/nio/file/spi/FileSystemProvider.java b/src/share/classes/java/nio/file/spi/FileSystemProvider.java index 6d676a5734c2e554f0612e4de16a5186a745eb8e..84e92d9cb9296d71b34755f4331c2daf6bd6f872 100644 --- a/src/share/classes/java/nio/file/spi/FileSystemProvider.java +++ b/src/share/classes/java/nio/file/spi/FileSystemProvider.java @@ -373,11 +373,13 @@ public abstract class FileSystemProvider { { if (options.length > 0) { for (OpenOption opt: options) { - if (opt != StandardOpenOption.READ) + // All OpenOption values except for APPEND and WRITE are allowed + if (opt == StandardOpenOption.APPEND || + opt == StandardOpenOption.WRITE) throw new UnsupportedOperationException("'" + opt + "' not allowed"); } } - return Channels.newInputStream(Files.newByteChannel(path)); + return Channels.newInputStream(Files.newByteChannel(path, options)); } /** diff --git a/src/share/classes/java/util/Locale.java b/src/share/classes/java/util/Locale.java index 100144ebe367c7eedd026d71e3653f3544f11b88..4cf700eafc6553e650fb97d411f615732b267c8d 100644 --- a/src/share/classes/java/util/Locale.java +++ b/src/share/classes/java/util/Locale.java @@ -737,10 +737,6 @@ public final class Locale implements Cloneable, Serializable { */ public static Locale getDefault() { // do not synchronize this method - see 4071298 - // it's OK if more than one default locale happens to be created - if (defaultLocale == null) { - initDefault(); - } return defaultLocale; } @@ -762,16 +758,23 @@ public final class Locale implements Cloneable, Serializable { */ public static Locale getDefault(Locale.Category category) { // do not synchronize this method - see 4071298 - // it's OK if more than one default locale happens to be created switch (category) { case DISPLAY: if (defaultDisplayLocale == null) { - initDefault(category); + synchronized(Locale.class) { + if (defaultDisplayLocale == null) { + defaultDisplayLocale = initDefault(category); + } + } } return defaultDisplayLocale; case FORMAT: if (defaultFormatLocale == null) { - initDefault(category); + synchronized(Locale.class) { + if (defaultFormatLocale == null) { + defaultFormatLocale = initDefault(category); + } + } } return defaultFormatLocale; default: @@ -780,7 +783,7 @@ public final class Locale implements Cloneable, Serializable { return getDefault(); } - private static void initDefault() { + private static Locale initDefault() { String language, region, script, country, variant; language = AccessController.doPrivileged( new GetPropertyAction("user.language", "en")); @@ -806,16 +809,12 @@ public final class Locale implements Cloneable, Serializable { variant = AccessController.doPrivileged( new GetPropertyAction("user.variant", "")); } - defaultLocale = getInstance(language, script, country, variant, null); - } - private static void initDefault(Locale.Category category) { - // make sure defaultLocale is initialized - if (defaultLocale == null) { - initDefault(); - } + return getInstance(language, script, country, variant, null); + } - Locale defaultCategoryLocale = getInstance( + private static Locale initDefault(Locale.Category category) { + return getInstance( AccessController.doPrivileged( new GetPropertyAction(category.languageKey, defaultLocale.getLanguage())), AccessController.doPrivileged( @@ -825,15 +824,6 @@ public final class Locale implements Cloneable, Serializable { AccessController.doPrivileged( new GetPropertyAction(category.variantKey, defaultLocale.getVariant())), null); - - switch (category) { - case DISPLAY: - defaultDisplayLocale = defaultCategoryLocale; - break; - case FORMAT: - defaultFormatLocale = defaultCategoryLocale; - break; - } } /** @@ -1916,9 +1906,9 @@ public final class Locale implements Cloneable, Serializable { */ private transient volatile int hashCodeValue = 0; - private static Locale defaultLocale = null; - private static Locale defaultDisplayLocale = null; - private static Locale defaultFormatLocale = null; + private volatile static Locale defaultLocale = initDefault(); + private volatile static Locale defaultDisplayLocale = null; + private volatile static Locale defaultFormatLocale = null; /** * Return an array of the display names of the variant. diff --git a/src/share/classes/java/util/concurrent/ArrayBlockingQueue.java b/src/share/classes/java/util/concurrent/ArrayBlockingQueue.java index 32fd50470d6a40abfb168dad0a6ae7049121cbbf..74f1e985523b41d02a3b59ca2a46216790a76b9f 100644 --- a/src/share/classes/java/util/concurrent/ArrayBlockingQueue.java +++ b/src/share/classes/java/util/concurrent/ArrayBlockingQueue.java @@ -131,8 +131,9 @@ public class ArrayBlockingQueue extends AbstractQueue /** * Returns item at index i. */ + @SuppressWarnings("unchecked") final E itemAt(int i) { - return this.cast(items[i]); + return (E) items[i]; } /** @@ -162,7 +163,8 @@ public class ArrayBlockingQueue extends AbstractQueue */ private E extract() { final Object[] items = this.items; - E x = this.cast(items[takeIndex]); + @SuppressWarnings("unchecked") + E x = (E) items[takeIndex]; items[takeIndex] = null; takeIndex = inc(takeIndex); --count; @@ -647,7 +649,9 @@ public class ArrayBlockingQueue extends AbstractQueue int n = 0; int max = count; while (n < max) { - c.add(this.cast(items[i])); + @SuppressWarnings("unchecked") + E x = (E) items[i]; + c.add(x); items[i] = null; i = inc(i); ++n; @@ -684,7 +688,9 @@ public class ArrayBlockingQueue extends AbstractQueue int n = 0; int max = (maxElements < count) ? maxElements : count; while (n < max) { - c.add(this.cast(items[i])); + @SuppressWarnings("unchecked") + E x = (E) items[i]; + c.add(x); items[i] = null; i = inc(i); ++n; diff --git a/src/share/classes/java/util/concurrent/ConcurrentHashMap.java b/src/share/classes/java/util/concurrent/ConcurrentHashMap.java index e82148069b40fb94e2b697c75810fb7ca465ae0b..48b00212ed2e2016350e47edc739f695e1f0b5c0 100644 --- a/src/share/classes/java/util/concurrent/ConcurrentHashMap.java +++ b/src/share/classes/java/util/concurrent/ConcurrentHashMap.java @@ -37,9 +37,6 @@ package java.util.concurrent; import java.util.concurrent.locks.*; import java.util.*; import java.io.Serializable; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; /** * A hash table supporting full concurrency of retrievals and @@ -228,7 +225,7 @@ public class ConcurrentHashMap extends AbstractMap static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = HashEntry.class; + Class k = HashEntry.class; nextOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("next")); } catch (Exception e) { @@ -433,7 +430,7 @@ public class ConcurrentHashMap extends AbstractMap int newCapacity = oldCapacity << 1; threshold = (int)(newCapacity * loadFactor); HashEntry[] newTable = - (HashEntry[]) new HashEntry[newCapacity]; + (HashEntry[]) new HashEntry[newCapacity]; int sizeMask = newCapacity - 1; for (int i = 0; i < oldCapacity ; i++) { HashEntry e = oldTable[i]; @@ -677,7 +674,7 @@ public class ConcurrentHashMap extends AbstractMap int cap = proto.table.length; float lf = proto.loadFactor; int threshold = (int)(cap * lf); - HashEntry[] tab = (HashEntry[])new HashEntry[cap]; + HashEntry[] tab = (HashEntry[])new HashEntry[cap]; if ((seg = (Segment)UNSAFE.getObjectVolatile(ss, u)) == null) { // recheck Segment s = new Segment(lf, threshold, tab); @@ -694,7 +691,7 @@ public class ConcurrentHashMap extends AbstractMap // Hash-based segment and entry accesses /** - * Get the segment for the given hash + * Gets the segment for the given hash code. */ @SuppressWarnings("unchecked") private Segment segmentForHash(int h) { @@ -703,7 +700,7 @@ public class ConcurrentHashMap extends AbstractMap } /** - * Gets the table entry for the given segment and hash + * Gets the table entry for the given segment and hash code. */ @SuppressWarnings("unchecked") static final HashEntry entryForHash(Segment seg, int h) { @@ -758,8 +755,8 @@ public class ConcurrentHashMap extends AbstractMap // create segments and segments[0] Segment s0 = new Segment(loadFactor, (int)(cap * loadFactor), - (HashEntry[])new HashEntry[cap]); - Segment[] ss = (Segment[])new Segment[ssize]; + (HashEntry[])new HashEntry[cap]); + Segment[] ss = (Segment[])new Segment[ssize]; UNSAFE.putOrderedObject(ss, SBASE, s0); // ordered write of segments[0] this.segments = ss; } @@ -916,6 +913,7 @@ public class ConcurrentHashMap extends AbstractMap * * @throws NullPointerException if the specified key is null */ + @SuppressWarnings("unchecked") public V get(Object key) { Segment s; // manually integrate access methods to reduce overhead HashEntry[] tab; @@ -1026,7 +1024,7 @@ public class ConcurrentHashMap extends AbstractMap * full compatibility with class {@link java.util.Hashtable}, * which supported this method prior to introduction of the * Java Collections framework. - + * * @param value a value to search for * @return true if and only if some key maps to the * value argument in this table as @@ -1262,7 +1260,7 @@ public class ConcurrentHashMap extends AbstractMap } /** - * Set nextEntry to first node of next non-empty table + * Sets nextEntry to first node of next non-empty table * (in backwards order, to simplify checks). */ final void advance() { @@ -1326,12 +1324,14 @@ public class ConcurrentHashMap extends AbstractMap final class WriteThroughEntry extends AbstractMap.SimpleEntry { + static final long serialVersionUID = 7249069246763182397L; + WriteThroughEntry(K k, V v) { super(k,v); } /** - * Set our entry's value and write through to the map. The + * Sets our entry's value and writes through to the map. The * value to return is somewhat arbitrary here. Since a * WriteThroughEntry does not necessarily track asynchronous * changes, the most recent "previous" value could be @@ -1427,15 +1427,16 @@ public class ConcurrentHashMap extends AbstractMap /* ---------------- Serialization Support -------------- */ /** - * Save the state of the ConcurrentHashMap instance to a - * stream (i.e., serialize it). + * Saves the state of the ConcurrentHashMap instance to a + * stream (i.e., serializes it). * @param s the stream * @serialData * the key (Object) and value (Object) * for each key-value mapping, followed by a null pair. * The key-value mappings are emitted in no particular order. */ - private void writeObject(java.io.ObjectOutputStream s) throws IOException { + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { // force all segments for serialization compatibility for (int k = 0; k < segments.length; ++k) ensureSegment(k); @@ -1463,13 +1464,13 @@ public class ConcurrentHashMap extends AbstractMap } /** - * Reconstitute the ConcurrentHashMap instance from a - * stream (i.e., deserialize it). + * Reconstitutes the ConcurrentHashMap instance from a + * stream (i.e., deserializes it). * @param s the stream */ @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException { + throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); // Re-initialize segments to be minimally sized, and let grow. @@ -1479,7 +1480,7 @@ public class ConcurrentHashMap extends AbstractMap Segment seg = segments[k]; if (seg != null) { seg.threshold = (int)(cap * seg.loadFactor); - seg.table = (HashEntry[]) new HashEntry[cap]; + seg.table = (HashEntry[]) new HashEntry[cap]; } } @@ -1504,8 +1505,8 @@ public class ConcurrentHashMap extends AbstractMap int ss, ts; try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class tc = HashEntry[].class; - Class sc = Segment[].class; + Class tc = HashEntry[].class; + Class sc = Segment[].class; TBASE = UNSAFE.arrayBaseOffset(tc); SBASE = UNSAFE.arrayBaseOffset(sc); ts = UNSAFE.arrayIndexScale(tc); diff --git a/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java b/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java index 21d59cfc460e841dc71fcc44844de15565541771..c26e371f9d137fdf363e4d5e3b16c4d416c596cc 100644 --- a/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java +++ b/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java @@ -335,7 +335,7 @@ public class ConcurrentLinkedDeque static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = Node.class; + Class k = Node.class; prevOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("prev")); itemOffset = UNSAFE.objectFieldOffset @@ -1457,7 +1457,7 @@ public class ConcurrentLinkedDeque NEXT_TERMINATOR.prev = NEXT_TERMINATOR; try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = ConcurrentLinkedDeque.class; + Class k = ConcurrentLinkedDeque.class; headOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("head")); tailOffset = UNSAFE.objectFieldOffset diff --git a/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java b/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java index fcdfcf97eb6f8430db6004b7b2d39702df966193..dfac05c6d401417199a88ec21b5d5b7afc8cc13d 100644 --- a/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java +++ b/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java @@ -208,7 +208,7 @@ public class ConcurrentLinkedQueue extends AbstractQueue static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = Node.class; + Class k = Node.class; itemOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("item")); nextOffset = UNSAFE.objectFieldOffset @@ -823,7 +823,7 @@ public class ConcurrentLinkedQueue extends AbstractQueue static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = ConcurrentLinkedQueue.class; + Class k = ConcurrentLinkedQueue.class; headOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("head")); tailOffset = UNSAFE.objectFieldOffset diff --git a/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java b/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java index 8d23964512b70022d7bb69e0749e60405831e8b2..fdf83d1cc81542ab45548f6d4aaade06a0d87723 100644 --- a/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java +++ b/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java @@ -35,7 +35,6 @@ package java.util.concurrent; import java.util.*; -import java.util.concurrent.atomic.*; /** * A scalable concurrent {@link ConcurrentNavigableMap} implementation. @@ -90,6 +89,7 @@ import java.util.concurrent.atomic.*; * @param the type of mapped values * @since 1.6 */ +@SuppressWarnings("unchecked") public class ConcurrentSkipListMap extends AbstractMap implements ConcurrentNavigableMap, Cloneable, @@ -352,11 +352,11 @@ public class ConcurrentSkipListMap extends AbstractMap private transient int randomSeed; /** Lazily initialized key set */ - private transient KeySet keySet; + private transient KeySet keySet; /** Lazily initialized entry set */ - private transient EntrySet entrySet; + private transient EntrySet entrySet; /** Lazily initialized values collection */ - private transient Values values; + private transient Values values; /** Lazily initialized descending key set */ private transient ConcurrentNavigableMap descendingMap; @@ -517,7 +517,7 @@ public class ConcurrentSkipListMap extends AbstractMap static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = Node.class; + Class k = Node.class; valueOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("value")); nextOffset = UNSAFE.objectFieldOffset @@ -597,7 +597,7 @@ public class ConcurrentSkipListMap extends AbstractMap static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = Index.class; + Class k = Index.class; rightOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("right")); } catch (Exception e) { @@ -933,7 +933,7 @@ public class ConcurrentSkipListMap extends AbstractMap * direction. */ level = max + 1; - Index[] idxs = (Index[])new Index[level+1]; + Index[] idxs = (Index[])new Index[level+1]; Index idx = null; for (int i = 1; i <= level; ++i) idxs[i] = idx = new Index(z, idx, null); @@ -1436,16 +1436,16 @@ public class ConcurrentSkipListMap extends AbstractMap * @return a shallow copy of this map */ public ConcurrentSkipListMap clone() { - ConcurrentSkipListMap clone = null; try { - clone = (ConcurrentSkipListMap) super.clone(); + @SuppressWarnings("unchecked") + ConcurrentSkipListMap clone = + (ConcurrentSkipListMap) super.clone(); + clone.initialize(); + clone.buildFromSorted(this); + return clone; } catch (CloneNotSupportedException e) { throw new InternalError(); } - - clone.initialize(); - clone.buildFromSorted(this); - return clone; } /** @@ -1507,7 +1507,7 @@ public class ConcurrentSkipListMap extends AbstractMap /* ---------------- Serialization -------------- */ /** - * Save the state of this map to a stream. + * Saves the state of this map to a stream (that is, serializes it). * * @serialData The key (Object) and value (Object) for each * key-value mapping represented by the map, followed by @@ -1532,7 +1532,9 @@ public class ConcurrentSkipListMap extends AbstractMap } /** - * Reconstitute the map from a stream. + * Reconstitutes the map from a stream (that is, deserializes it). + * + * @param s the stream */ private void readObject(final java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { @@ -1755,13 +1757,13 @@ public class ConcurrentSkipListMap extends AbstractMap * @return a navigable set view of the keys in this map */ public NavigableSet keySet() { - KeySet ks = keySet; - return (ks != null) ? ks : (keySet = new KeySet(this)); + KeySet ks = keySet; + return (ks != null) ? ks : (keySet = new KeySet(this)); } public NavigableSet navigableKeySet() { - KeySet ks = keySet; - return (ks != null) ? ks : (keySet = new KeySet(this)); + KeySet ks = keySet; + return (ks != null) ? ks : (keySet = new KeySet(this)); } /** @@ -1783,8 +1785,8 @@ public class ConcurrentSkipListMap extends AbstractMap * reflect any modifications subsequent to construction. */ public Collection values() { - Values vs = values; - return (vs != null) ? vs : (values = new Values(this)); + Values vs = values; + return (vs != null) ? vs : (values = new Values(this)); } /** @@ -1812,8 +1814,8 @@ public class ConcurrentSkipListMap extends AbstractMap * sorted in ascending key order */ public Set> entrySet() { - EntrySet es = entrySet; - return (es != null) ? es : (entrySet = new EntrySet(this)); + EntrySet es = entrySet; + return (es != null) ? es : (entrySet = new EntrySet(this)); } public ConcurrentNavigableMap descendingMap() { @@ -2304,8 +2306,8 @@ public class ConcurrentSkipListMap extends AbstractMap static final class KeySet extends AbstractSet implements NavigableSet { - private final ConcurrentNavigableMap m; - KeySet(ConcurrentNavigableMap map) { m = map; } + private final ConcurrentNavigableMap m; + KeySet(ConcurrentNavigableMap map) { m = map; } public int size() { return m.size(); } public boolean isEmpty() { return m.isEmpty(); } public boolean contains(Object o) { return m.containsKey(o); } @@ -2319,11 +2321,11 @@ public class ConcurrentSkipListMap extends AbstractMap public E first() { return m.firstKey(); } public E last() { return m.lastKey(); } public E pollFirst() { - Map.Entry e = m.pollFirstEntry(); + Map.Entry e = m.pollFirstEntry(); return (e == null) ? null : e.getKey(); } public E pollLast() { - Map.Entry e = m.pollLastEntry(); + Map.Entry e = m.pollLastEntry(); return (e == null) ? null : e.getKey(); } public Iterator iterator() { @@ -2374,20 +2376,20 @@ public class ConcurrentSkipListMap extends AbstractMap return tailSet(fromElement, true); } public NavigableSet descendingSet() { - return new KeySet(m.descendingMap()); + return new KeySet(m.descendingMap()); } } static final class Values extends AbstractCollection { - private final ConcurrentNavigableMap m; - Values(ConcurrentNavigableMap map) { + private final ConcurrentNavigableMap m; + Values(ConcurrentNavigableMap map) { m = map; } public Iterator iterator() { if (m instanceof ConcurrentSkipListMap) - return ((ConcurrentSkipListMap)m).valueIterator(); + return ((ConcurrentSkipListMap)m).valueIterator(); else - return ((SubMap)m).valueIterator(); + return ((SubMap)m).valueIterator(); } public boolean isEmpty() { return m.isEmpty(); @@ -2421,14 +2423,14 @@ public class ConcurrentSkipListMap extends AbstractMap public boolean contains(Object o) { if (!(o instanceof Map.Entry)) return false; - Map.Entry e = (Map.Entry)o; + Map.Entry e = (Map.Entry)o; V1 v = m.get(e.getKey()); return v != null && v.equals(e.getValue()); } public boolean remove(Object o) { if (!(o instanceof Map.Entry)) return false; - Map.Entry e = (Map.Entry)o; + Map.Entry e = (Map.Entry)o; return m.remove(e.getKey(), e.getValue()); } @@ -2568,9 +2570,9 @@ public class ConcurrentSkipListMap extends AbstractMap if (lo == null) return m.findFirst(); else if (loInclusive) - return m.findNear(lo, m.GT|m.EQ); + return m.findNear(lo, GT|EQ); else - return m.findNear(lo, m.GT); + return m.findNear(lo, GT); } /** @@ -2581,9 +2583,9 @@ public class ConcurrentSkipListMap extends AbstractMap if (hi == null) return m.findLast(); else if (hiInclusive) - return m.findNear(hi, m.LT|m.EQ); + return m.findNear(hi, LT|EQ); else - return m.findNear(hi, m.LT); + return m.findNear(hi, LT); } /** @@ -2665,15 +2667,15 @@ public class ConcurrentSkipListMap extends AbstractMap */ private Map.Entry getNearEntry(K key, int rel) { if (isDescending) { // adjust relation for direction - if ((rel & m.LT) == 0) - rel |= m.LT; + if ((rel & LT) == 0) + rel |= LT; else - rel &= ~m.LT; + rel &= ~LT; } if (tooLow(key)) - return ((rel & m.LT) != 0) ? null : lowestEntry(); + return ((rel & LT) != 0) ? null : lowestEntry(); if (tooHigh(key)) - return ((rel & m.LT) != 0) ? highestEntry() : null; + return ((rel & LT) != 0) ? highestEntry() : null; for (;;) { Node n = m.findNear(key, rel); if (n == null || !inBounds(n.key)) @@ -2688,13 +2690,13 @@ public class ConcurrentSkipListMap extends AbstractMap // Almost the same as getNearEntry, except for keys private K getNearKey(K key, int rel) { if (isDescending) { // adjust relation for direction - if ((rel & m.LT) == 0) - rel |= m.LT; + if ((rel & LT) == 0) + rel |= LT; else - rel &= ~m.LT; + rel &= ~LT; } if (tooLow(key)) { - if ((rel & m.LT) == 0) { + if ((rel & LT) == 0) { ConcurrentSkipListMap.Node n = loNode(); if (isBeforeEnd(n)) return n.key; @@ -2702,7 +2704,7 @@ public class ConcurrentSkipListMap extends AbstractMap return null; } if (tooHigh(key)) { - if ((rel & m.LT) != 0) { + if ((rel & LT) != 0) { ConcurrentSkipListMap.Node n = hiNode(); if (n != null) { K last = n.key; @@ -2734,7 +2736,7 @@ public class ConcurrentSkipListMap extends AbstractMap public V get(Object key) { if (key == null) throw new NullPointerException(); K k = (K)key; - return ((!inBounds(k)) ? null : m.get(k)); + return (!inBounds(k)) ? null : m.get(k); } public V put(K key, V value) { @@ -2901,35 +2903,35 @@ public class ConcurrentSkipListMap extends AbstractMap /* ---------------- Relational methods -------------- */ public Map.Entry ceilingEntry(K key) { - return getNearEntry(key, (m.GT|m.EQ)); + return getNearEntry(key, GT|EQ); } public K ceilingKey(K key) { - return getNearKey(key, (m.GT|m.EQ)); + return getNearKey(key, GT|EQ); } public Map.Entry lowerEntry(K key) { - return getNearEntry(key, (m.LT)); + return getNearEntry(key, LT); } public K lowerKey(K key) { - return getNearKey(key, (m.LT)); + return getNearKey(key, LT); } public Map.Entry floorEntry(K key) { - return getNearEntry(key, (m.LT|m.EQ)); + return getNearEntry(key, LT|EQ); } public K floorKey(K key) { - return getNearKey(key, (m.LT|m.EQ)); + return getNearKey(key, LT|EQ); } public Map.Entry higherEntry(K key) { - return getNearEntry(key, (m.GT)); + return getNearEntry(key, GT); } public K higherKey(K key) { - return getNearKey(key, (m.GT)); + return getNearKey(key, GT); } public K firstKey() { @@ -2960,22 +2962,22 @@ public class ConcurrentSkipListMap extends AbstractMap public NavigableSet keySet() { KeySet ks = keySetView; - return (ks != null) ? ks : (keySetView = new KeySet(this)); + return (ks != null) ? ks : (keySetView = new KeySet(this)); } public NavigableSet navigableKeySet() { KeySet ks = keySetView; - return (ks != null) ? ks : (keySetView = new KeySet(this)); + return (ks != null) ? ks : (keySetView = new KeySet(this)); } public Collection values() { Collection vs = valuesView; - return (vs != null) ? vs : (valuesView = new Values(this)); + return (vs != null) ? vs : (valuesView = new Values(this)); } public Set> entrySet() { Set> es = entrySetView; - return (es != null) ? es : (entrySetView = new EntrySet(this)); + return (es != null) ? es : (entrySetView = new EntrySet(this)); } public NavigableSet descendingKeySet() { @@ -3109,7 +3111,7 @@ public class ConcurrentSkipListMap extends AbstractMap static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = ConcurrentSkipListMap.class; + Class k = ConcurrentSkipListMap.class; headOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("head")); } catch (Exception e) { diff --git a/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java b/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java index 7b5dc79a932b0f786440e29c5197641b4837a7b8..b250c1a5108432a52811b046a6299d42e11fe33b 100644 --- a/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java +++ b/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java @@ -35,7 +35,6 @@ package java.util.concurrent; import java.util.*; -import sun.misc.Unsafe; /** * A scalable concurrent {@link NavigableSet} implementation based on @@ -158,15 +157,15 @@ public class ConcurrentSkipListSet * @return a shallow copy of this set */ public ConcurrentSkipListSet clone() { - ConcurrentSkipListSet clone = null; try { - clone = (ConcurrentSkipListSet) super.clone(); - clone.setMap(new ConcurrentSkipListMap(m)); + @SuppressWarnings("unchecked") + ConcurrentSkipListSet clone = + (ConcurrentSkipListSet) super.clone(); + clone.setMap(new ConcurrentSkipListMap(m)); + return clone; } catch (CloneNotSupportedException e) { throw new InternalError(); } - - return clone; } /* ---------------- Set operations -------------- */ @@ -322,8 +321,8 @@ public class ConcurrentSkipListSet public boolean removeAll(Collection c) { // Override AbstractSet version to avoid unnecessary call to size() boolean modified = false; - for (Iterator i = c.iterator(); i.hasNext(); ) - if (remove(i.next())) + for (Object e : c) + if (remove(e)) modified = true; return modified; } @@ -468,7 +467,7 @@ public class ConcurrentSkipListSet * @return a reverse order view of this set */ public NavigableSet descendingSet() { - return new ConcurrentSkipListSet(m.descendingMap()); + return new ConcurrentSkipListSet(m.descendingMap()); } // Support for resetting map in clone @@ -481,7 +480,7 @@ public class ConcurrentSkipListSet static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = ConcurrentSkipListSet.class; + Class k = ConcurrentSkipListSet.class; mapOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("m")); } catch (Exception e) { diff --git a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java index 785ec6fcede229d4c1f7e32c1a6a8ac6b13eee14..e61dd7921fd7d15923bb96b12df4c549bff71ca1 100644 --- a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java +++ b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java @@ -36,7 +36,6 @@ package java.util.concurrent; import java.util.*; import java.util.concurrent.locks.*; -import sun.misc.Unsafe; /** * A thread-safe variant of {@link java.util.ArrayList} in which all mutative @@ -281,9 +280,11 @@ public class CopyOnWriteArrayList */ public Object clone() { try { - CopyOnWriteArrayList c = (CopyOnWriteArrayList)(super.clone()); - c.resetLock(); - return c; + @SuppressWarnings("unchecked") + CopyOnWriteArrayList clone = + (CopyOnWriteArrayList) super.clone(); + clone.resetLock(); + return clone; } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); @@ -1330,7 +1331,7 @@ public class CopyOnWriteArrayList static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = CopyOnWriteArrayList.class; + Class k = CopyOnWriteArrayList.class; lockOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("lock")); } catch (Exception e) { diff --git a/src/share/classes/java/util/concurrent/DelayQueue.java b/src/share/classes/java/util/concurrent/DelayQueue.java index dd36cc79ac279de1d946e3a7d3c45826dcce8461..aa68b749d7b19c2388a8069017f65444f9787f98 100644 --- a/src/share/classes/java/util/concurrent/DelayQueue.java +++ b/src/share/classes/java/util/concurrent/DelayQueue.java @@ -531,7 +531,7 @@ public class DelayQueue extends AbstractQueue // not just a .equals element. lock.lock(); try { - for (Iterator it = q.iterator(); it.hasNext(); ) { + for (Iterator it = q.iterator(); it.hasNext(); ) { if (it.next() == x) { it.remove(); return; diff --git a/src/share/classes/java/util/concurrent/Exchanger.java b/src/share/classes/java/util/concurrent/Exchanger.java index 99e3a35967bd7d174615be1b0a7d79d5f9dd7092..5accdb1ce58f73c9a3b24f85132b57f318910c8b 100644 --- a/src/share/classes/java/util/concurrent/Exchanger.java +++ b/src/share/classes/java/util/concurrent/Exchanger.java @@ -279,6 +279,7 @@ public class Exchanger { * into hole. This class cannot be parameterized as "V" because * of the use of non-V CANCEL sentinels. */ + @SuppressWarnings("serial") private static final class Node extends AtomicReference { /** The element offered by the Thread creating this node. */ public final Object item; @@ -303,6 +304,7 @@ public class Exchanger { * would improve throughput more than enough to outweigh using * extra space. */ + @SuppressWarnings("serial") private static final class Slot extends AtomicReference { // Improve likelihood of isolation on <= 64 byte cache lines long q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, qa, qb, qc, qd, qe; @@ -616,13 +618,14 @@ public class Exchanger { * @throws InterruptedException if the current thread was * interrupted while waiting */ + @SuppressWarnings("unchecked") public V exchange(V x) throws InterruptedException { if (!Thread.interrupted()) { - Object v = doExchange((x == null) ? NULL_ITEM : x, false, 0); - if (v == NULL_ITEM) + Object o = doExchange((x == null) ? NULL_ITEM : x, false, 0); + if (o == NULL_ITEM) return null; - if (v != CANCEL) - return (V)v; + if (o != CANCEL) + return (V)o; Thread.interrupted(); // Clear interrupt status on IE throw } throw new InterruptedException(); @@ -670,15 +673,16 @@ public class Exchanger { * @throws TimeoutException if the specified waiting time elapses * before another thread enters the exchange */ + @SuppressWarnings("unchecked") public V exchange(V x, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException { if (!Thread.interrupted()) { - Object v = doExchange((x == null) ? NULL_ITEM : x, + Object o = doExchange((x == null) ? NULL_ITEM : x, true, unit.toNanos(timeout)); - if (v == NULL_ITEM) + if (o == NULL_ITEM) return null; - if (v != CANCEL) - return (V)v; + if (o != CANCEL) + return (V)o; if (!Thread.interrupted()) throw new TimeoutException(); } diff --git a/src/share/classes/java/util/concurrent/ForkJoinPool.java b/src/share/classes/java/util/concurrent/ForkJoinPool.java index 9c90f36adb40a36b4a8905a77aed0015b7a4a198..0887e83f0e8a18cde71aa219d03ec94fd765169a 100644 --- a/src/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/src/share/classes/java/util/concurrent/ForkJoinPool.java @@ -2150,7 +2150,7 @@ public class ForkJoinPool extends AbstractExecutorService { int s; try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = ForkJoinPool.class; + Class k = ForkJoinPool.class; ctlOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("ctl")); stealCountOffset = UNSAFE.objectFieldOffset @@ -2163,7 +2163,7 @@ public class ForkJoinPool extends AbstractExecutorService { (k.getDeclaredField("scanGuard")); nextWorkerNumberOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("nextWorkerNumber")); - Class a = ForkJoinTask[].class; + Class a = ForkJoinTask[].class; ABASE = UNSAFE.arrayBaseOffset(a); s = UNSAFE.arrayIndexScale(a); } catch (Exception e) { diff --git a/src/share/classes/java/util/concurrent/ForkJoinTask.java b/src/share/classes/java/util/concurrent/ForkJoinTask.java index fbab843f78b73fb3fcdf9518b37638a33fdc8d58..de4b1231359ebcdb613223f083ff156b9963e775 100644 --- a/src/share/classes/java/util/concurrent/ForkJoinTask.java +++ b/src/share/classes/java/util/concurrent/ForkJoinTask.java @@ -520,7 +520,7 @@ public abstract class ForkJoinTask implements Future, Serializable { if (e == null || (ex = e.ex) == null) return null; if (e.thrower != Thread.currentThread().getId()) { - Class ec = ex.getClass(); + Class ec = ex.getClass(); try { Constructor noArgCtor = null; Constructor[] cs = ec.getConstructors();// public ctors only diff --git a/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java index 3504abb73c7d82f4ddef96a95518cb55c86f6b58..c60b23b1bbe27bb0479db38950b24d217485283e 100644 --- a/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java +++ b/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java @@ -192,7 +192,7 @@ public class ForkJoinWorkerThread extends Thread { /** * The work-stealing queue array. Size must be a power of two. - * Initialized when started (as oposed to when constructed), to + * Initialized when started (as opposed to when constructed), to * improve memory locality. */ ForkJoinTask[] queue; @@ -360,7 +360,7 @@ public class ForkJoinWorkerThread extends Thread { */ protected void onStart() { queue = new ForkJoinTask[INITIAL_QUEUE_CAPACITY]; - int r = pool.workerSeedGenerator.nextInt(); + int r = ForkJoinPool.workerSeedGenerator.nextInt(); seed = (r == 0) ? 1 : r; // must be nonzero } @@ -846,7 +846,7 @@ public class ForkJoinWorkerThread extends Thread { (b = v.queueBase) != v.queueTop && (q = v.queue) != null && (i = (q.length - 1) & b) >= 0 && - q[i] == t) { + q[i] == t) { long u = (i << ASHIFT) + ABASE; if (v.queueBase == b && UNSAFE.compareAndSwapObject(q, u, t, null)) { @@ -984,7 +984,7 @@ public class ForkJoinWorkerThread extends Thread { int s; try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class a = ForkJoinTask[].class; + Class a = ForkJoinTask[].class; ABASE = UNSAFE.arrayBaseOffset(a); s = UNSAFE.arrayIndexScale(a); } catch (Exception e) { diff --git a/src/share/classes/java/util/concurrent/LinkedTransferQueue.java b/src/share/classes/java/util/concurrent/LinkedTransferQueue.java index ebdf223ff6cc861fe271da872214a830d180cd13..171523f1643969ad2611f1de45712cde783f3a9a 100644 --- a/src/share/classes/java/util/concurrent/LinkedTransferQueue.java +++ b/src/share/classes/java/util/concurrent/LinkedTransferQueue.java @@ -330,8 +330,8 @@ public class LinkedTransferQueue extends AbstractQueue * of less-contended queues. During spins threads check their * interrupt status and generate a thread-local random number * to decide to occasionally perform a Thread.yield. While - * yield has underdefined specs, we assume that might it help, - * and will not hurt in limiting impact of spinning on busy + * yield has underdefined specs, we assume that it might help, + * and will not hurt, in limiting impact of spinning on busy * systems. We also use smaller (1/2) spins for nodes that are * not known to be front but whose predecessors have not * blocked -- these "chained" spins avoid artifacts of @@ -542,7 +542,7 @@ public class LinkedTransferQueue extends AbstractQueue static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = Node.class; + Class k = Node.class; itemOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("item")); nextOffset = UNSAFE.objectFieldOffset @@ -627,7 +627,7 @@ public class LinkedTransferQueue extends AbstractQueue break; // unless slack < 2 } LockSupport.unpark(p.waiter); - return this.cast(item); + return LinkedTransferQueue.cast(item); } } Node n = p.next; @@ -705,7 +705,7 @@ public class LinkedTransferQueue extends AbstractQueue if (item != e) { // matched // assert item != s; s.forgetContents(); // avoid garbage - return this.cast(item); + return LinkedTransferQueue.cast(item); } if ((w.isInterrupted() || (timed && nanos <= 0)) && s.casItem(e, s)) { // cancel @@ -786,7 +786,7 @@ public class LinkedTransferQueue extends AbstractQueue Object item = p.item; if (p.isData) { if (item != null && item != p) - return this.cast(item); + return LinkedTransferQueue.cast(item); } else if (item == null) return null; @@ -1008,7 +1008,6 @@ public class LinkedTransferQueue extends AbstractQueue return false; } - /** * Creates an initially empty {@code LinkedTransferQueue}. */ @@ -1045,7 +1044,8 @@ public class LinkedTransferQueue extends AbstractQueue * return {@code false}. * * @return {@code true} (as specified by - * {@link BlockingQueue#offer(Object,long,TimeUnit) BlockingQueue.offer}) + * {@link java.util.concurrent.BlockingQueue#offer(Object,long,TimeUnit) + * BlockingQueue.offer}) * @throws NullPointerException if the specified element is null */ public boolean offer(E e, long timeout, TimeUnit unit) { @@ -1162,8 +1162,7 @@ public class LinkedTransferQueue extends AbstractQueue if (c == this) throw new IllegalArgumentException(); int n = 0; - E e; - while ( (e = poll()) != null) { + for (E e; (e = poll()) != null;) { c.add(e); ++n; } @@ -1180,8 +1179,7 @@ public class LinkedTransferQueue extends AbstractQueue if (c == this) throw new IllegalArgumentException(); int n = 0; - E e; - while (n < maxElements && (e = poll()) != null) { + for (E e; n < maxElements && (e = poll()) != null;) { c.add(e); ++n; } @@ -1288,7 +1286,8 @@ public class LinkedTransferQueue extends AbstractQueue * {@code LinkedTransferQueue} is not capacity constrained. * * @return {@code Integer.MAX_VALUE} (as specified by - * {@link BlockingQueue#remainingCapacity()}) + * {@link java.util.concurrent.BlockingQueue#remainingCapacity() + * BlockingQueue.remainingCapacity}) */ public int remainingCapacity() { return Integer.MAX_VALUE; @@ -1320,7 +1319,8 @@ public class LinkedTransferQueue extends AbstractQueue throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); for (;;) { - @SuppressWarnings("unchecked") E item = (E) s.readObject(); + @SuppressWarnings("unchecked") + E item = (E) s.readObject(); if (item == null) break; else @@ -1337,7 +1337,7 @@ public class LinkedTransferQueue extends AbstractQueue static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = LinkedTransferQueue.class; + Class k = LinkedTransferQueue.class; headOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("head")); tailOffset = UNSAFE.objectFieldOffset diff --git a/src/share/classes/java/util/concurrent/Phaser.java b/src/share/classes/java/util/concurrent/Phaser.java index bdafbbb7a9da29206415192b586b0fc94e8e1ea1..c8afecc3c00ef5ef82fae7382c44f9ab84deacda 100644 --- a/src/share/classes/java/util/concurrent/Phaser.java +++ b/src/share/classes/java/util/concurrent/Phaser.java @@ -1142,7 +1142,7 @@ public class Phaser { static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = Phaser.class; + Class k = Phaser.class; stateOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("state")); } catch (Exception e) { diff --git a/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java b/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java index 83dbb4dd7785616a025579c5039c9d1ca35083db..37b44a1038e111ac9e67bccc0b64cdbc0f6e068f 100644 --- a/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java +++ b/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java @@ -94,6 +94,7 @@ import java.util.*; * @author Doug Lea * @param the type of elements held in this collection */ +@SuppressWarnings("unchecked") public class PriorityBlockingQueue extends AbstractQueue implements BlockingQueue, java.io.Serializable { private static final long serialVersionUID = 5595510919245408276L; @@ -168,7 +169,7 @@ public class PriorityBlockingQueue extends AbstractQueue * to maintain compatibility with previous versions * of this class. Non-null only during serialization/deserialization. */ - private PriorityQueue q; + private PriorityQueue q; /** * Creates a {@code PriorityBlockingQueue} with the default @@ -968,7 +969,7 @@ public class PriorityBlockingQueue extends AbstractQueue static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = PriorityBlockingQueue.class; + Class k = PriorityBlockingQueue.class; allocationSpinLockOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("allocationSpinLock")); } catch (Exception e) { diff --git a/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java b/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java index 5101a9c458ef66908e2651df530f0c65bf924ee8..49195b87c69b9a6856c94ebd2335a09f85871b5b 100644 --- a/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java +++ b/src/share/classes/java/util/concurrent/ScheduledThreadPoolExecutor.java @@ -34,8 +34,10 @@ */ package java.util.concurrent; -import java.util.concurrent.atomic.*; -import java.util.concurrent.locks.*; +import static java.util.concurrent.TimeUnit.NANOSECONDS; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.ReentrantLock; import java.util.*; /** @@ -166,7 +168,7 @@ public class ScheduledThreadPoolExecutor * Sequence number to break scheduling ties, and in turn to * guarantee FIFO order among tied entries. */ - private static final AtomicLong sequencer = new AtomicLong(0); + private static final AtomicLong sequencer = new AtomicLong(); /** * Returns current nanosecond time. @@ -231,7 +233,7 @@ public class ScheduledThreadPoolExecutor } public long getDelay(TimeUnit unit) { - return unit.convert(time - now(), TimeUnit.NANOSECONDS); + return unit.convert(time - now(), NANOSECONDS); } public int compareTo(Delayed other) { @@ -249,8 +251,8 @@ public class ScheduledThreadPoolExecutor else return 1; } - long d = (getDelay(TimeUnit.NANOSECONDS) - - other.getDelay(TimeUnit.NANOSECONDS)); + long d = (getDelay(NANOSECONDS) - + other.getDelay(NANOSECONDS)); return (d == 0) ? 0 : ((d < 0) ? -1 : 1); } @@ -424,7 +426,7 @@ public class ScheduledThreadPoolExecutor * @throws IllegalArgumentException if {@code corePoolSize < 0} */ public ScheduledThreadPoolExecutor(int corePoolSize) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, + super(corePoolSize, Integer.MAX_VALUE, 0, NANOSECONDS, new DelayedWorkQueue()); } @@ -441,7 +443,7 @@ public class ScheduledThreadPoolExecutor */ public ScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, + super(corePoolSize, Integer.MAX_VALUE, 0, NANOSECONDS, new DelayedWorkQueue(), threadFactory); } @@ -458,7 +460,7 @@ public class ScheduledThreadPoolExecutor */ public ScheduledThreadPoolExecutor(int corePoolSize, RejectedExecutionHandler handler) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, + super(corePoolSize, Integer.MAX_VALUE, 0, NANOSECONDS, new DelayedWorkQueue(), handler); } @@ -479,7 +481,7 @@ public class ScheduledThreadPoolExecutor public ScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler) { - super(corePoolSize, Integer.MAX_VALUE, 0, TimeUnit.NANOSECONDS, + super(corePoolSize, Integer.MAX_VALUE, 0, NANOSECONDS, new DelayedWorkQueue(), threadFactory, handler); } @@ -508,7 +510,7 @@ public class ScheduledThreadPoolExecutor private long overflowFree(long delay) { Delayed head = (Delayed) super.getQueue().peek(); if (head != null) { - long headDelay = head.getDelay(TimeUnit.NANOSECONDS); + long headDelay = head.getDelay(NANOSECONDS); if (headDelay < 0 && (delay - headDelay < 0)) delay = Long.MAX_VALUE + headDelay; } @@ -616,7 +618,7 @@ public class ScheduledThreadPoolExecutor * @throws NullPointerException {@inheritDoc} */ public void execute(Runnable command) { - schedule(command, 0, TimeUnit.NANOSECONDS); + schedule(command, 0, NANOSECONDS); } // Override AbstractExecutorService methods @@ -626,7 +628,7 @@ public class ScheduledThreadPoolExecutor * @throws NullPointerException {@inheritDoc} */ public Future submit(Runnable task) { - return schedule(task, 0, TimeUnit.NANOSECONDS); + return schedule(task, 0, NANOSECONDS); } /** @@ -634,8 +636,7 @@ public class ScheduledThreadPoolExecutor * @throws NullPointerException {@inheritDoc} */ public Future submit(Runnable task, T result) { - return schedule(Executors.callable(task, result), - 0, TimeUnit.NANOSECONDS); + return schedule(Executors.callable(task, result), 0, NANOSECONDS); } /** @@ -643,7 +644,7 @@ public class ScheduledThreadPoolExecutor * @throws NullPointerException {@inheritDoc} */ public Future submit(Callable task) { - return schedule(task, 0, TimeUnit.NANOSECONDS); + return schedule(task, 0, NANOSECONDS); } /** @@ -831,8 +832,8 @@ public class ScheduledThreadPoolExecutor */ private static final int INITIAL_CAPACITY = 16; - private RunnableScheduledFuture[] queue = - new RunnableScheduledFuture[INITIAL_CAPACITY]; + private RunnableScheduledFuture[] queue = + new RunnableScheduledFuture[INITIAL_CAPACITY]; private final ReentrantLock lock = new ReentrantLock(); private int size = 0; @@ -863,7 +864,7 @@ public class ScheduledThreadPoolExecutor /** * Set f's heapIndex if it is a ScheduledFutureTask. */ - private void setIndex(RunnableScheduledFuture f, int idx) { + private void setIndex(RunnableScheduledFuture f, int idx) { if (f instanceof ScheduledFutureTask) ((ScheduledFutureTask)f).heapIndex = idx; } @@ -872,10 +873,10 @@ public class ScheduledThreadPoolExecutor * Sift element added at bottom up to its heap-ordered spot. * Call only when holding lock. */ - private void siftUp(int k, RunnableScheduledFuture key) { + private void siftUp(int k, RunnableScheduledFuture key) { while (k > 0) { int parent = (k - 1) >>> 1; - RunnableScheduledFuture e = queue[parent]; + RunnableScheduledFuture e = queue[parent]; if (key.compareTo(e) >= 0) break; queue[k] = e; @@ -890,11 +891,11 @@ public class ScheduledThreadPoolExecutor * Sift element added at top down to its heap-ordered spot. * Call only when holding lock. */ - private void siftDown(int k, RunnableScheduledFuture key) { + private void siftDown(int k, RunnableScheduledFuture key) { int half = size >>> 1; while (k < half) { int child = (k << 1) + 1; - RunnableScheduledFuture c = queue[child]; + RunnableScheduledFuture c = queue[child]; int right = child + 1; if (right < size && c.compareTo(queue[right]) > 0) c = queue[child = right]; @@ -959,7 +960,7 @@ public class ScheduledThreadPoolExecutor setIndex(queue[i], -1); int s = --size; - RunnableScheduledFuture replacement = queue[s]; + RunnableScheduledFuture replacement = queue[s]; queue[s] = null; if (s != i) { siftDown(i, replacement); @@ -990,7 +991,7 @@ public class ScheduledThreadPoolExecutor return Integer.MAX_VALUE; } - public RunnableScheduledFuture peek() { + public RunnableScheduledFuture peek() { final ReentrantLock lock = this.lock; lock.lock(); try { @@ -1003,7 +1004,7 @@ public class ScheduledThreadPoolExecutor public boolean offer(Runnable x) { if (x == null) throw new NullPointerException(); - RunnableScheduledFuture e = (RunnableScheduledFuture)x; + RunnableScheduledFuture e = (RunnableScheduledFuture)x; final ReentrantLock lock = this.lock; lock.lock(); try { @@ -1045,9 +1046,9 @@ public class ScheduledThreadPoolExecutor * holding lock. * @param f the task to remove and return */ - private RunnableScheduledFuture finishPoll(RunnableScheduledFuture f) { + private RunnableScheduledFuture finishPoll(RunnableScheduledFuture f) { int s = --size; - RunnableScheduledFuture x = queue[s]; + RunnableScheduledFuture x = queue[s]; queue[s] = null; if (s != 0) siftDown(0, x); @@ -1055,12 +1056,12 @@ public class ScheduledThreadPoolExecutor return f; } - public RunnableScheduledFuture poll() { + public RunnableScheduledFuture poll() { final ReentrantLock lock = this.lock; lock.lock(); try { - RunnableScheduledFuture first = queue[0]; - if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) + RunnableScheduledFuture first = queue[0]; + if (first == null || first.getDelay(NANOSECONDS) > 0) return null; else return finishPoll(first); @@ -1069,16 +1070,16 @@ public class ScheduledThreadPoolExecutor } } - public RunnableScheduledFuture take() throws InterruptedException { + public RunnableScheduledFuture take() throws InterruptedException { final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { for (;;) { - RunnableScheduledFuture first = queue[0]; + RunnableScheduledFuture first = queue[0]; if (first == null) available.await(); else { - long delay = first.getDelay(TimeUnit.NANOSECONDS); + long delay = first.getDelay(NANOSECONDS); if (delay <= 0) return finishPoll(first); else if (leader != null) @@ -1102,21 +1103,21 @@ public class ScheduledThreadPoolExecutor } } - public RunnableScheduledFuture poll(long timeout, TimeUnit unit) + public RunnableScheduledFuture poll(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { for (;;) { - RunnableScheduledFuture first = queue[0]; + RunnableScheduledFuture first = queue[0]; if (first == null) { if (nanos <= 0) return null; else nanos = available.awaitNanos(nanos); } else { - long delay = first.getDelay(TimeUnit.NANOSECONDS); + long delay = first.getDelay(NANOSECONDS); if (delay <= 0) return finishPoll(first); if (nanos <= 0) @@ -1148,7 +1149,7 @@ public class ScheduledThreadPoolExecutor lock.lock(); try { for (int i = 0; i < size; i++) { - RunnableScheduledFuture t = queue[i]; + RunnableScheduledFuture t = queue[i]; if (t != null) { queue[i] = null; setIndex(t, -1); @@ -1164,9 +1165,10 @@ public class ScheduledThreadPoolExecutor * Return and remove first element only if it is expired. * Used only by drainTo. Call only when holding lock. */ - private RunnableScheduledFuture pollExpired() { - RunnableScheduledFuture first = queue[0]; - if (first == null || first.getDelay(TimeUnit.NANOSECONDS) > 0) + private RunnableScheduledFuture pollExpired() { + // assert lock.isHeldByCurrentThread(); + RunnableScheduledFuture first = queue[0]; + if (first == null || first.getDelay(NANOSECONDS) > 0) return null; return finishPoll(first); } @@ -1179,7 +1181,7 @@ public class ScheduledThreadPoolExecutor final ReentrantLock lock = this.lock; lock.lock(); try { - RunnableScheduledFuture first; + RunnableScheduledFuture first; int n = 0; while ((first = pollExpired()) != null) { c.add(first); @@ -1201,7 +1203,7 @@ public class ScheduledThreadPoolExecutor final ReentrantLock lock = this.lock; lock.lock(); try { - RunnableScheduledFuture first; + RunnableScheduledFuture first; int n = 0; while (n < maxElements && (first = pollExpired()) != null) { c.add(first); diff --git a/src/share/classes/java/util/concurrent/SynchronousQueue.java b/src/share/classes/java/util/concurrent/SynchronousQueue.java index a1fa8e21af63d21a4382f1dacbe28906e33d0768..9d0d830c265c09c2c9c906ba691fe227182c1d75 100644 --- a/src/share/classes/java/util/concurrent/SynchronousQueue.java +++ b/src/share/classes/java/util/concurrent/SynchronousQueue.java @@ -36,7 +36,6 @@ package java.util.concurrent; import java.util.concurrent.locks.*; -import java.util.concurrent.atomic.*; import java.util.*; /** @@ -163,7 +162,7 @@ public class SynchronousQueue extends AbstractQueue /** * Shared internal API for dual stacks and queues. */ - abstract static class Transferer { + abstract static class Transferer { /** * Performs a put or take. * @@ -177,7 +176,7 @@ public class SynchronousQueue extends AbstractQueue * the caller can distinguish which of these occurred * by checking Thread.interrupted. */ - abstract Object transfer(Object e, boolean timed, long nanos); + abstract E transfer(E e, boolean timed, long nanos); } /** The number of CPUs, for spin control */ @@ -206,7 +205,7 @@ public class SynchronousQueue extends AbstractQueue static final long spinForTimeoutThreshold = 1000L; /** Dual stack */ - static final class TransferStack extends Transferer { + static final class TransferStack extends Transferer { /* * This extends Scherer-Scott dual stack algorithm, differing, * among other ways, by using "covering" nodes rather than @@ -286,7 +285,7 @@ public class SynchronousQueue extends AbstractQueue static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = SNode.class; + Class k = SNode.class; matchOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("match")); nextOffset = UNSAFE.objectFieldOffset @@ -322,7 +321,8 @@ public class SynchronousQueue extends AbstractQueue /** * Puts or takes an item. */ - Object transfer(Object e, boolean timed, long nanos) { + @SuppressWarnings("unchecked") + E transfer(E e, boolean timed, long nanos) { /* * Basic algorithm is to loop trying one of three actions: * @@ -363,7 +363,7 @@ public class SynchronousQueue extends AbstractQueue } if ((h = head) != null && h.next == s) casHead(h, s.next); // help s's fulfiller - return (mode == REQUEST) ? m.item : s.item; + return (E) ((mode == REQUEST) ? m.item : s.item); } } else if (!isFulfilling(h.mode)) { // try to fulfill if (h.isCancelled()) // already cancelled @@ -379,7 +379,7 @@ public class SynchronousQueue extends AbstractQueue SNode mn = m.next; if (m.tryMatch(s)) { casHead(s, mn); // pop both s and m - return (mode == REQUEST) ? m.item : s.item; + return (E) ((mode == REQUEST) ? m.item : s.item); } else // lost match s.casNext(m, mn); // help unlink } @@ -513,7 +513,7 @@ public class SynchronousQueue extends AbstractQueue static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = TransferStack.class; + Class k = TransferStack.class; headOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("head")); } catch (Exception e) { @@ -523,7 +523,7 @@ public class SynchronousQueue extends AbstractQueue } /** Dual Queue */ - static final class TransferQueue extends Transferer { + static final class TransferQueue extends Transferer { /* * This extends Scherer-Scott dual queue algorithm, differing, * among other ways, by using modes within nodes rather than @@ -583,7 +583,7 @@ public class SynchronousQueue extends AbstractQueue static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = QNode.class; + Class k = QNode.class; itemOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("item")); nextOffset = UNSAFE.objectFieldOffset @@ -640,7 +640,8 @@ public class SynchronousQueue extends AbstractQueue /** * Puts or takes an item. */ - Object transfer(Object e, boolean timed, long nanos) { + @SuppressWarnings("unchecked") + E transfer(E e, boolean timed, long nanos) { /* Basic algorithm is to loop trying to take either of * two actions: * @@ -703,7 +704,7 @@ public class SynchronousQueue extends AbstractQueue s.item = s; s.waiter = null; } - return (x != null) ? x : e; + return (x != null) ? (E)x : e; } else { // complementary-mode QNode m = h.next; // node to fulfill @@ -720,7 +721,7 @@ public class SynchronousQueue extends AbstractQueue advanceHead(h, m); // successfully fulfilled LockSupport.unpark(m.waiter); - return (x != null) ? x : e; + return (x != null) ? (E)x : e; } } } @@ -734,7 +735,7 @@ public class SynchronousQueue extends AbstractQueue * @param nanos timeout value * @return matched item, or s if cancelled */ - Object awaitFulfill(QNode s, Object e, boolean timed, long nanos) { + Object awaitFulfill(QNode s, E e, boolean timed, long nanos) { /* Same idea as TransferStack.awaitFulfill */ long lastTime = timed ? System.nanoTime() : 0; Thread w = Thread.currentThread(); @@ -827,7 +828,7 @@ public class SynchronousQueue extends AbstractQueue static { try { UNSAFE = sun.misc.Unsafe.getUnsafe(); - Class k = TransferQueue.class; + Class k = TransferQueue.class; headOffset = UNSAFE.objectFieldOffset (k.getDeclaredField("head")); tailOffset = UNSAFE.objectFieldOffset @@ -847,7 +848,7 @@ public class SynchronousQueue extends AbstractQueue * isn't a noticeable performance penalty for using volatile * instead of final here. */ - private transient volatile Transferer transferer; + private transient volatile Transferer transferer; /** * Creates a SynchronousQueue with nonfair access policy. @@ -863,7 +864,7 @@ public class SynchronousQueue extends AbstractQueue * access; otherwise the order is unspecified. */ public SynchronousQueue(boolean fair) { - transferer = fair ? new TransferQueue() : new TransferStack(); + transferer = fair ? new TransferQueue() : new TransferStack(); } /** @@ -922,9 +923,9 @@ public class SynchronousQueue extends AbstractQueue * @throws InterruptedException {@inheritDoc} */ public E take() throws InterruptedException { - Object e = transferer.transfer(null, false, 0); + E e = transferer.transfer(null, false, 0); if (e != null) - return (E)e; + return e; Thread.interrupted(); throw new InterruptedException(); } @@ -939,9 +940,9 @@ public class SynchronousQueue extends AbstractQueue * @throws InterruptedException {@inheritDoc} */ public E poll(long timeout, TimeUnit unit) throws InterruptedException { - Object e = transferer.transfer(null, true, unit.toNanos(timeout)); + E e = transferer.transfer(null, true, unit.toNanos(timeout)); if (e != null || !Thread.interrupted()) - return (E)e; + return e; throw new InterruptedException(); } @@ -953,7 +954,7 @@ public class SynchronousQueue extends AbstractQueue * element is available. */ public E poll() { - return (E)transferer.transfer(null, true, 0); + return transferer.transfer(null, true, 0); } /** @@ -1065,8 +1066,19 @@ public class SynchronousQueue extends AbstractQueue * * @return an empty iterator */ + @SuppressWarnings("unchecked") public Iterator iterator() { - return Collections.emptyIterator(); + return (Iterator) EmptyIterator.EMPTY_ITERATOR; + } + + // Replicated from a previous version of Collections + private static class EmptyIterator implements Iterator { + static final EmptyIterator EMPTY_ITERATOR + = new EmptyIterator(); + + public boolean hasNext() { return false; } + public E next() { throw new NoSuchElementException(); } + public void remove() { throw new IllegalStateException(); } } /** @@ -1103,8 +1115,7 @@ public class SynchronousQueue extends AbstractQueue if (c == this) throw new IllegalArgumentException(); int n = 0; - E e; - while ( (e = poll()) != null) { + for (E e; (e = poll()) != null;) { c.add(e); ++n; } @@ -1123,8 +1134,7 @@ public class SynchronousQueue extends AbstractQueue if (c == this) throw new IllegalArgumentException(); int n = 0; - E e; - while (n < maxElements && (e = poll()) != null) { + for (E e; n < maxElements && (e = poll()) != null;) { c.add(e); ++n; } @@ -1139,6 +1149,7 @@ public class SynchronousQueue extends AbstractQueue * object is ever serialized or deserialized. */ + @SuppressWarnings("serial") static class WaitQueue implements java.io.Serializable { } static class LifoWaitQueue extends WaitQueue { private static final long serialVersionUID = -3633113410248163686L; @@ -1151,7 +1162,7 @@ public class SynchronousQueue extends AbstractQueue private WaitQueue waitingConsumers; /** - * Save the state to a stream (that is, serialize it). + * Saves the state to a stream (that is, serializes it). * * @param s the stream */ @@ -1175,9 +1186,9 @@ public class SynchronousQueue extends AbstractQueue throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); if (waitingProducers instanceof FifoWaitQueue) - transferer = new TransferQueue(); + transferer = new TransferQueue(); else - transferer = new TransferStack(); + transferer = new TransferStack(); } // Unsafe mechanics diff --git a/src/share/classes/java/util/jar/JarFile.java b/src/share/classes/java/util/jar/JarFile.java index 79d0f84b7e17cbb9f861576d13f77b23ac12125d..513d509e2f839d29024f5f16dccdf484eb96a674 100644 --- a/src/share/classes/java/util/jar/JarFile.java +++ b/src/share/classes/java/util/jar/JarFile.java @@ -183,7 +183,7 @@ class JarFile extends ZipFile { } else { man = new Manifest(super.getInputStream(manEntry)); } - manRef = new SoftReference(man); + manRef = new SoftReference<>(man); } } return man; @@ -233,13 +233,13 @@ class JarFile extends ZipFile { * Returns an enumeration of the zip file entries. */ public Enumeration entries() { - final Enumeration enum_ = super.entries(); + final Enumeration enum_ = super.entries(); return new Enumeration() { public boolean hasMoreElements() { return enum_.hasMoreElements(); } public JarFileEntry nextElement() { - ZipEntry ze = (ZipEntry)enum_.nextElement(); + ZipEntry ze = enum_.nextElement(); return new JarFileEntry(ze); } }; @@ -608,7 +608,7 @@ class JarFile extends ZipFile { } // screen out entries which are never signed - final Enumeration enum_ = super.entries(); + final Enumeration enum_ = super.entries(); return new Enumeration() { ZipEntry entry; @@ -618,7 +618,7 @@ class JarFile extends ZipFile { return true; } while (enum_.hasMoreElements()) { - ZipEntry ze = (ZipEntry) enum_.nextElement(); + ZipEntry ze = enum_.nextElement(); if (JarVerifier.isSigningRelated(ze.getName())) { continue; } @@ -649,7 +649,7 @@ class JarFile extends ZipFile { * JAR file has no signed content. Is there a non-signing * code source? */ - Enumeration unsigned = unsignedEntryNames(); + Enumeration unsigned = unsignedEntryNames(); if (unsigned.hasMoreElements()) { return new CodeSource[]{JarVerifier.getUnsignedCS(url)}; } else { @@ -658,7 +658,7 @@ class JarFile extends ZipFile { } private Enumeration unsignedEntryNames() { - final Enumeration entries = entries(); + final Enumeration entries = entries(); return new Enumeration() { String name; @@ -673,7 +673,7 @@ class JarFile extends ZipFile { } while (entries.hasMoreElements()) { String value; - ZipEntry e = (ZipEntry) entries.nextElement(); + ZipEntry e = entries.nextElement(); value = e.getName(); if (e.isDirectory() || JarVerifier.isSigningRelated(value)) { continue; @@ -726,11 +726,11 @@ class JarFile extends ZipFile { } } - List getManifestDigests() { + List getManifestDigests() { ensureInitialization(); if (jv != null) { return jv.getManifestDigests(); } - return new ArrayList(); + return new ArrayList(); } } diff --git a/src/share/classes/java/util/jar/Manifest.java b/src/share/classes/java/util/jar/Manifest.java index 8023d1759c9b0d7c094ded6730043bdf63cb1e04..3bb567152823b209e418a56f8b6f7c3d8126cb0b 100644 --- a/src/share/classes/java/util/jar/Manifest.java +++ b/src/share/classes/java/util/jar/Manifest.java @@ -51,7 +51,7 @@ public class Manifest implements Cloneable { private Attributes attr = new Attributes(); // manifest entries - private Map entries = new HashMap(); + private Map entries = new HashMap<>(); /** * Constructs a new, empty Manifest. @@ -148,11 +148,11 @@ public class Manifest implements Cloneable { // Write out the main attributes for the manifest attr.writeMain(dos); // Now write out the pre-entry attributes - Iterator it = entries.entrySet().iterator(); + Iterator> it = entries.entrySet().iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry)it.next(); + Map.Entry e = it.next(); StringBuffer buffer = new StringBuffer("Name: "); - String value = (String)e.getKey(); + String value = e.getKey(); if (value != null) { byte[] vb = value.getBytes("UTF8"); value = new String(vb, 0, 0, vb.length); @@ -161,7 +161,7 @@ public class Manifest implements Cloneable { buffer.append("\r\n"); make72Safe(buffer); dos.writeBytes(buffer.toString()); - ((Attributes)e.getValue()).write(dos); + e.getValue().write(dos); } dos.flush(); } diff --git a/src/share/classes/java/util/logging/LogManager.java b/src/share/classes/java/util/logging/LogManager.java index a28b0d8a8244a5752ef84dbf2496c34580f8047f..bf8a486868349d1745ed09d7c1ef91fcefe84217 100644 --- a/src/share/classes/java/util/logging/LogManager.java +++ b/src/share/classes/java/util/logging/LogManager.java @@ -179,10 +179,10 @@ public class LogManager { cname = System.getProperty("java.util.logging.manager"); if (cname != null) { try { - Class clz = ClassLoader.getSystemClassLoader().loadClass(cname); + Class clz = ClassLoader.getSystemClassLoader().loadClass(cname); manager = (LogManager) clz.newInstance(); } catch (ClassNotFoundException ex) { - Class clz = Thread.currentThread().getContextClassLoader().loadClass(cname); + Class clz = Thread.currentThread().getContextClassLoader().loadClass(cname); manager = (LogManager) clz.newInstance(); } } @@ -200,8 +200,8 @@ public class LogManager { // Adding the global Logger. Doing so in the Logger. // would deadlock with the LogManager.. - Logger.global.setLogManager(manager); - manager.addLogger(Logger.global); + Logger.getGlobal().setLogManager(manager); + manager.addLogger(Logger.getGlobal()); // We don't call readConfiguration() here, as we may be running // very early in the JVM startup sequence. Instead readConfiguration @@ -415,8 +415,8 @@ public class LogManager { for (int i = 0; i < names.length; i++) { String word = names[i]; try { - Class clz = ClassLoader.getSystemClassLoader().loadClass(word); - Handler hdl = (Handler) clz.newInstance(); + Class clz = ClassLoader.getSystemClassLoader().loadClass(word); + Handler hdl = (Handler) clz.newInstance(); try { // Check if there is a property defining the // this handler's level. @@ -782,11 +782,11 @@ public class LogManager { // responsibility to initialize the logging configuration, by // calling readConfiguration(InputStream) with a suitable stream. try { - Class clz = ClassLoader.getSystemClassLoader().loadClass(cname); + Class clz = ClassLoader.getSystemClassLoader().loadClass(cname); clz.newInstance(); return; } catch (ClassNotFoundException ex) { - Class clz = Thread.currentThread().getContextClassLoader().loadClass(cname); + Class clz = Thread.currentThread().getContextClassLoader().loadClass(cname); clz.newInstance(); return; } @@ -837,9 +837,9 @@ public class LogManager { // the global handlers, if they haven't been initialized yet. initializedGlobalHandlers = true; } - Enumeration enum_ = getLoggerNames(); + Enumeration enum_ = getLoggerNames(); while (enum_.hasMoreElements()) { - String name = (String)enum_.nextElement(); + String name = enum_.nextElement(); resetLogger(name); } } @@ -926,7 +926,7 @@ public class LogManager { for (int i = 0; i < names.length; i++) { String word = names[i]; try { - Class clz = ClassLoader.getSystemClassLoader().loadClass(word); + Class clz = ClassLoader.getSystemClassLoader().loadClass(word); clz.newInstance(); } catch (Exception ex) { System.err.println("Can't load config class \"" + word + "\""); @@ -1024,7 +1024,7 @@ public class LogManager { String val = getProperty(name); try { if (val != null) { - Class clz = ClassLoader.getSystemClassLoader().loadClass(val); + Class clz = ClassLoader.getSystemClassLoader().loadClass(val); return (Filter) clz.newInstance(); } } catch (Exception ex) { @@ -1045,7 +1045,7 @@ public class LogManager { String val = getProperty(name); try { if (val != null) { - Class clz = ClassLoader.getSystemClassLoader().loadClass(val); + Class clz = ClassLoader.getSystemClassLoader().loadClass(val); return (Formatter) clz.newInstance(); } } catch (Exception ex) { @@ -1163,7 +1163,7 @@ public class LogManager { // Private method to be called when the configuration has // changed to apply any level settings to any pre-existing loggers. synchronized private void setLevelsOnExistingLoggers() { - Enumeration enum_ = props.propertyNames(); + Enumeration enum_ = props.propertyNames(); while (enum_.hasMoreElements()) { String key = (String)enum_.nextElement(); if (!key.endsWith(".level")) { diff --git a/src/share/classes/java/util/prefs/Preferences.java b/src/share/classes/java/util/prefs/Preferences.java index fe20a74b6f0384c9a8f7cc3497429a474ec7e725..de85e071706a6fa85e7bb364a986cdc01f130144 100644 --- a/src/share/classes/java/util/prefs/Preferences.java +++ b/src/share/classes/java/util/prefs/Preferences.java @@ -413,7 +413,7 @@ public abstract class Preferences { * @throws IllegalArgumentException if the package has node preferences * node associated with it. */ - private static String nodeName(Class c) { + private static String nodeName(Class c) { if (c.isArray()) throw new IllegalArgumentException( "Arrays have no associated preferences node."); diff --git a/src/share/classes/java/util/prefs/XmlSupport.java b/src/share/classes/java/util/prefs/XmlSupport.java index 33aa387d40a08e856ddfd1459e7ba406897725b9..08f19d82df23b2430b60f4fe51145d207b961ba8 100644 --- a/src/share/classes/java/util/prefs/XmlSupport.java +++ b/src/share/classes/java/util/prefs/XmlSupport.java @@ -106,7 +106,7 @@ class XmlSupport { xmlRoot.setAttribute("type", (p.isUserNode() ? "user" : "system")); // Get bottom-up list of nodes from p to root, excluding root - List ancestors = new ArrayList(); + List ancestors = new ArrayList<>(); for (Preferences kid = p, dad = kid.parent(); dad != null; kid = dad, dad = kid.parent()) { @@ -116,7 +116,7 @@ class XmlSupport { for (int i=ancestors.size()-1; i >= 0; i--) { e.appendChild(doc.createElement("map")); e = (Element) e.appendChild(doc.createElement("node")); - e.setAttribute("name", ((Preferences)ancestors.get(i)).name()); + e.setAttribute("name", ancestors.get(i).name()); } putPreferencesInXml(e, doc, p, subTree); @@ -339,17 +339,17 @@ class XmlSupport { * @throws IOException if writing to the specified output stream * results in an IOException. */ - static void exportMap(OutputStream os, Map map) throws IOException { + static void exportMap(OutputStream os, Map map) throws IOException { Document doc = createPrefsDoc("map"); Element xmlMap = doc.getDocumentElement( ) ; xmlMap.setAttribute("MAP_XML_VERSION", MAP_XML_VERSION); - for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) { - Map.Entry e = (Map.Entry) i.next(); + for (Iterator> i = map.entrySet().iterator(); i.hasNext(); ) { + Map.Entry e = i.next(); Element xe = (Element) xmlMap.appendChild(doc.createElement("entry")); - xe.setAttribute("key", (String) e.getKey()); - xe.setAttribute("value", (String) e.getValue()); + xe.setAttribute("key", e.getKey()); + xe.setAttribute("value", e.getValue()); } writeDoc(doc, os); @@ -368,7 +368,7 @@ class XmlSupport { * @throws InvalidPreferencesFormatException Data on input stream does not * constitute a valid XML document with the mandated document type. */ - static void importMap(InputStream is, Map m) + static void importMap(InputStream is, Map m) throws IOException, InvalidPreferencesFormatException { try { diff --git a/src/share/classes/java/util/regex/Pattern.java b/src/share/classes/java/util/regex/Pattern.java index d89eca9845d7c915f629021a30cd7419264669f5..626d5b08657cf087e55bf8ce82b6dd90327aff96 100644 --- a/src/share/classes/java/util/regex/Pattern.java +++ b/src/share/classes/java/util/regex/Pattern.java @@ -1583,13 +1583,26 @@ loop: for(int x=0, offset=0; x> 25) & 0x7f) + 80), (int)(((dtime >> 21) & 0x0f) - 1), (int)((dtime >> 16) & 0x1f), @@ -293,6 +294,7 @@ class ZipEntry implements ZipConstants, Cloneable { /* * Converts Java time to DOS time. */ + @SuppressWarnings("deprecation") // Use of date methods private static long javaToDosTime(long time) { Date d = new Date(time); int year = d.getYear() + 1900; diff --git a/src/share/classes/javax/script/ScriptException.java b/src/share/classes/javax/script/ScriptException.java index 6ad481085f7c1402d74ff6b7e93fb58c459ef7a0..e9ffaabb220e69a0c94bfd4d6acd558be5e41b8e 100644 --- a/src/share/classes/javax/script/ScriptException.java +++ b/src/share/classes/javax/script/ScriptException.java @@ -36,6 +36,8 @@ package javax.script; */ public class ScriptException extends Exception { + private static final long serialVersionUID = 8265071037049225001L; + private String fileName; private int lineNumber; private int columnNumber; diff --git a/src/share/classes/javax/xml/crypto/NodeSetData.java b/src/share/classes/javax/xml/crypto/NodeSetData.java index a34302acfe321b388f7794f9c9f191bcea7b98b4..d83572993305a9209b340916b06bf7657489266a 100644 --- a/src/share/classes/javax/xml/crypto/NodeSetData.java +++ b/src/share/classes/javax/xml/crypto/NodeSetData.java @@ -52,5 +52,6 @@ public interface NodeSetData extends Data { * @return an Iterator over the nodes in this * NodeSetData in document order */ + @SuppressWarnings("rawtypes") Iterator iterator(); } diff --git a/src/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java b/src/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java index 79f72940148b6e3f0d22e5dfbce00c0aa7a81788..d13f384ba5a062c629e0801542dc5b8cbf19c275 100644 --- a/src/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java +++ b/src/share/classes/javax/xml/crypto/dom/DOMCryptoContext.java @@ -47,13 +47,13 @@ import org.w3c.dom.Element; */ public class DOMCryptoContext implements XMLCryptoContext { - private HashMap nsMap = new HashMap(); - private HashMap idMap = new HashMap(); - private HashMap objMap = new HashMap(); + private HashMap nsMap = new HashMap<>(); + private HashMap idMap = new HashMap<>(); + private HashMap objMap = new HashMap<>(); private String baseURI; private KeySelector ks; private URIDereferencer dereferencer; - private HashMap propMap = new HashMap(); + private HashMap propMap = new HashMap<>(); private String defaultPrefix; /** @@ -73,7 +73,7 @@ public class DOMCryptoContext implements XMLCryptoContext { if (namespaceURI == null) { throw new NullPointerException("namespaceURI cannot be null"); } - String prefix = (String) nsMap.get(namespaceURI); + String prefix = nsMap.get(namespaceURI); return (prefix != null ? prefix : defaultPrefix); } @@ -87,7 +87,7 @@ public class DOMCryptoContext implements XMLCryptoContext { if (namespaceURI == null) { throw new NullPointerException("namespaceURI is null"); } - return (String) nsMap.put(namespaceURI, prefix); + return nsMap.put(namespaceURI, prefix); } public String getDefaultNamespacePrefix() { @@ -170,7 +170,7 @@ public class DOMCryptoContext implements XMLCryptoContext { if (idValue == null) { throw new NullPointerException("idValue is null"); } - return (Element) idMap.get(idValue); + return idMap.get(idValue); } /** @@ -219,6 +219,7 @@ public class DOMCryptoContext implements XMLCryptoContext { * * @return a read-only iterator over the set of mappings */ + @SuppressWarnings("rawtypes") public Iterator iterator() { return Collections.unmodifiableMap(idMap).entrySet().iterator(); } diff --git a/src/share/classes/javax/xml/crypto/dsig/Manifest.java b/src/share/classes/javax/xml/crypto/dsig/Manifest.java index ebb0ec1fa74dda536715cc6a32c0e1ad022c4c7a..0800a6435d0bef1ad7f148092125777eacfa3000 100644 --- a/src/share/classes/javax/xml/crypto/dsig/Manifest.java +++ b/src/share/classes/javax/xml/crypto/dsig/Manifest.java @@ -86,5 +86,6 @@ public interface Manifest extends XMLStructure { * * @return an unmodifiable list of one or more References */ + @SuppressWarnings("rawtypes") List getReferences(); } diff --git a/src/share/classes/javax/xml/crypto/dsig/Reference.java b/src/share/classes/javax/xml/crypto/dsig/Reference.java index 6725b14af57b8e4636c47f782c8b01c0872538e2..be71bbb9e12ffae6df92cb8ba87ae19b3a212265 100644 --- a/src/share/classes/javax/xml/crypto/dsig/Reference.java +++ b/src/share/classes/javax/xml/crypto/dsig/Reference.java @@ -85,6 +85,7 @@ public interface Reference extends URIReference, XMLStructure { * @return an unmodifiable list of Transforms * (may be empty but never null) */ + @SuppressWarnings("rawtypes") List getTransforms(); /** diff --git a/src/share/classes/javax/xml/crypto/dsig/SignatureProperties.java b/src/share/classes/javax/xml/crypto/dsig/SignatureProperties.java index 127143e84bea77342894e88e4b2c9e20233ebaf8..a6ef8e1e5d7669ba5bee3a1b0b52d8a5b8e7866f 100644 --- a/src/share/classes/javax/xml/crypto/dsig/SignatureProperties.java +++ b/src/share/classes/javax/xml/crypto/dsig/SignatureProperties.java @@ -87,5 +87,6 @@ public interface SignatureProperties extends XMLStructure { * @return an unmodifiable list of one or more * SignaturePropertys */ + @SuppressWarnings("rawtypes") List getProperties(); } diff --git a/src/share/classes/javax/xml/crypto/dsig/SignatureProperty.java b/src/share/classes/javax/xml/crypto/dsig/SignatureProperty.java index d6c8c8f123cd4c92090d5d0f5c3d43da56e6e3b9..c808456bab6c4f43bbc67cd5dbeffb03eb69b0f0 100644 --- a/src/share/classes/javax/xml/crypto/dsig/SignatureProperty.java +++ b/src/share/classes/javax/xml/crypto/dsig/SignatureProperty.java @@ -91,5 +91,6 @@ public interface SignatureProperty extends XMLStructure { * * @return an unmodifiable list of one or more XMLStructures */ + @SuppressWarnings("rawtypes") List getContent(); } diff --git a/src/share/classes/javax/xml/crypto/dsig/SignedInfo.java b/src/share/classes/javax/xml/crypto/dsig/SignedInfo.java index a603906ebe655a424fa8fe758ba277306d8d2df3..cba06dc57522ce2d7239745d8359f04fc8a88b18 100644 --- a/src/share/classes/javax/xml/crypto/dsig/SignedInfo.java +++ b/src/share/classes/javax/xml/crypto/dsig/SignedInfo.java @@ -80,6 +80,7 @@ public interface SignedInfo extends XMLStructure { * * @return an unmodifiable list of one or more {@link Reference}s */ + @SuppressWarnings("rawtypes") List getReferences(); /** diff --git a/src/share/classes/javax/xml/crypto/dsig/TransformService.java b/src/share/classes/javax/xml/crypto/dsig/TransformService.java index 70f4182bf370834676772ae0b3b63b0cb1193e60..b009b9a20ef89d6aab97a6c0011ea933a1ba1d2f 100644 --- a/src/share/classes/javax/xml/crypto/dsig/TransformService.java +++ b/src/share/classes/javax/xml/crypto/dsig/TransformService.java @@ -157,9 +157,9 @@ public abstract class TransformService implements Transform { if (mechanismType.equals("DOM")) { dom = true; } - List services = GetInstance.getServices("TransformService", algorithm); - for (Iterator t = services.iterator(); t.hasNext(); ) { - Service s = (Service)t.next(); + List services = GetInstance.getServices("TransformService", algorithm); + for (Iterator t = services.iterator(); t.hasNext(); ) { + Service s = t.next(); String value = s.getAttribute("MechanismType"); if ((value == null && dom) || (value != null && value.equals(mechanismType))) { @@ -277,7 +277,7 @@ public abstract class TransformService implements Transform { + " mechanism not available"); } - private static class MechanismMapEntry implements Map.Entry { + private static class MechanismMapEntry implements Map.Entry { private final String mechanism; private final String algorithm; private final String key; @@ -290,19 +290,19 @@ public abstract class TransformService implements Transform { if (!(o instanceof Map.Entry)) { return false; } - Map.Entry e = (Map.Entry) o; + Map.Entry e = (Map.Entry) o; return (getKey()==null ? e.getKey()==null : getKey().equals(e.getKey())) && (getValue()==null ? e.getValue()==null : getValue().equals(e.getValue())); } - public Object getKey() { + public String getKey() { return key; } - public Object getValue() { + public String getValue() { return mechanism; } - public Object setValue(Object value) { + public String setValue(String value) { throw new UnsupportedOperationException(); } public int hashCode() { diff --git a/src/share/classes/javax/xml/crypto/dsig/XMLObject.java b/src/share/classes/javax/xml/crypto/dsig/XMLObject.java index 88db693a73a814961b11aa5db9f229db5298d359..5763ba664236eda2a7fe42453e169bdb1820877f 100644 --- a/src/share/classes/javax/xml/crypto/dsig/XMLObject.java +++ b/src/share/classes/javax/xml/crypto/dsig/XMLObject.java @@ -100,6 +100,7 @@ public interface XMLObject extends XMLStructure { * @return an unmodifiable list of XMLStructures (may be empty * but never null) */ + @SuppressWarnings("rawtypes") List getContent(); /** diff --git a/src/share/classes/javax/xml/crypto/dsig/XMLSignature.java b/src/share/classes/javax/xml/crypto/dsig/XMLSignature.java index 829a41a17b7444231fc9c7f786110c2374367a60..533976a672a57b237d043ecc5e522cc62db0fe55 100644 --- a/src/share/classes/javax/xml/crypto/dsig/XMLSignature.java +++ b/src/share/classes/javax/xml/crypto/dsig/XMLSignature.java @@ -136,6 +136,7 @@ public interface XMLSignature extends XMLStructure { * @return an unmodifiable list of XMLObjects (may be empty * but never null) */ + @SuppressWarnings("rawtypes") List getObjects(); /** diff --git a/src/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java b/src/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java index 3d3426bf3c784cda030a306af4005f9459b9585d..e9932d5b4f194196caff702a4cb1cef2fe2ee488 100644 --- a/src/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java +++ b/src/share/classes/javax/xml/crypto/dsig/XMLSignatureFactory.java @@ -365,6 +365,7 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if any of the objects are not of * type XMLObject */ + @SuppressWarnings("rawtypes") public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki, List objects, String id, String signatureValueId); @@ -398,6 +399,7 @@ public abstract class XMLSignatureFactory { * compliant * @throws NullPointerException if dm is null */ + @SuppressWarnings("rawtypes") public abstract Reference newReference(String uri, DigestMethod dm, List transforms, String type, String id); @@ -428,6 +430,7 @@ public abstract class XMLSignatureFactory { * @throws NullPointerException if dm or * digestValue is null */ + @SuppressWarnings("rawtypes") public abstract Reference newReference(String uri, DigestMethod dm, List transforms, String type, String id, byte[] digestValue); @@ -470,6 +473,7 @@ public abstract class XMLSignatureFactory { * appliedTransforms or result is * null */ + @SuppressWarnings("rawtypes") public abstract Reference newReference(String uri, DigestMethod dm, List appliedTransforms, Data result, List transforms, String type, String id); @@ -489,6 +493,7 @@ public abstract class XMLSignatureFactory { * @throws NullPointerException if any of the parameters * are null */ + @SuppressWarnings("rawtypes") public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List references); @@ -507,6 +512,7 @@ public abstract class XMLSignatureFactory { * @throws NullPointerException if cm, sm, or * references are null */ + @SuppressWarnings("rawtypes") public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List references, String id); @@ -524,6 +530,7 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if content contains any * entries that are not of type {@link XMLStructure} */ + @SuppressWarnings("rawtypes") public abstract XMLObject newXMLObject(List content, String id, String mimeType, String encoding); @@ -540,6 +547,7 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if references contains any * entries that are not of type {@link Reference} */ + @SuppressWarnings("rawtypes") public abstract Manifest newManifest(List references); /** @@ -556,6 +564,7 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if references contains any * entries that are not of type {@link Reference} */ + @SuppressWarnings("rawtypes") public abstract Manifest newManifest(List references, String id); /** @@ -574,6 +583,7 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if content contains any * entries that are not of type {@link XMLStructure} */ + @SuppressWarnings("rawtypes") public abstract SignatureProperty newSignatureProperty (List content, String target, String id); @@ -592,6 +602,7 @@ public abstract class XMLSignatureFactory { * @throws ClassCastException if properties contains any * entries that are not of type {@link SignatureProperty} */ + @SuppressWarnings("rawtypes") public abstract SignatureProperties newSignatureProperties (List properties, String id); diff --git a/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java b/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java index a9f9833b597bef788e5be9236eba0f9485f41972..74d8215c1bb69e96bb1be267b99e4e0666bc0f5e 100644 --- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java +++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfo.java @@ -94,6 +94,7 @@ public interface KeyInfo extends XMLStructure { * in this KeyInfo. Never returns null or an * empty list. */ + @SuppressWarnings("rawtypes") List getContent(); /** diff --git a/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java b/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java index 54fd53bc790cb724182b532633fcb0b90935e6cf..b1fbbd0e4b586cf1090baac50e96cf20cdab1e5c 100644 --- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java +++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java @@ -305,6 +305,7 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if content contains any entries * that are not of type {@link XMLStructure} */ + @SuppressWarnings("rawtypes") public abstract KeyInfo newKeyInfo(List content); /** @@ -324,6 +325,7 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if content contains any entries * that are not of type {@link XMLStructure} */ + @SuppressWarnings("rawtypes") public abstract KeyInfo newKeyInfo(List content, String id); /** @@ -385,6 +387,7 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if other contains any * entries that are not of type {@link XMLStructure} */ + @SuppressWarnings("rawtypes") public abstract PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other); @@ -408,6 +411,7 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if other contains any * entries that are not of type {@link XMLStructure} */ + @SuppressWarnings("rawtypes") public abstract PGPData newPGPData(byte[] keyPacket, List other); /** @@ -439,6 +443,7 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if transforms contains any * entries that are not of type {@link Transform} */ + @SuppressWarnings("rawtypes") public abstract RetrievalMethod newRetrievalMethod(String uri, String type, List transforms); @@ -464,6 +469,7 @@ public abstract class KeyInfoFactory { * @throws ClassCastException if content contains any entries * that are not of one of the valid types mentioned above */ + @SuppressWarnings("rawtypes") public abstract X509Data newX509Data(List content); /** diff --git a/src/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java b/src/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java index 917cbdd2cef41e2b95c09f1b88606ac85aaa30a7..c60eb4267b5f035c6ada754afc57b5c1378c058a 100644 --- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java +++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/PGPData.java @@ -112,5 +112,6 @@ public interface PGPData extends XMLStructure { * @return an unmodifiable list of XMLStructures (may be * empty, but never null) */ + @SuppressWarnings("rawtypes") List getExternalElements(); } diff --git a/src/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java b/src/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java index bffbe1a6bddf197eaaf174bcb9fbb242adfdfd81..0b3402db471206b15c6b1d79ec257b2eec2e6ff7 100644 --- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java +++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java @@ -80,6 +80,7 @@ public interface RetrievalMethod extends URIReference, XMLStructure { * @return an unmodifiable list of Transform objects (may be * empty but never null). */ + @SuppressWarnings("rawtypes") List getTransforms(); /** diff --git a/src/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java b/src/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java index 88d696103defca7ce3db70970b91576acc98838f..e2c8c6a08d9c40f01895b4dc432473118cd65014 100644 --- a/src/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java +++ b/src/share/classes/javax/xml/crypto/dsig/keyinfo/X509Data.java @@ -109,5 +109,6 @@ public interface X509Data extends XMLStructure { * @return an unmodifiable list of the content in this X509Data * (never null or empty) */ + @SuppressWarnings("rawtypes") List getContent(); } diff --git a/src/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java b/src/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java index af07c1fa27cbe13c9e66f082fb0bb0dc49288149..c686cfbbe4cb0d89dfe3c9b5508c078531ca8bf6 100644 --- a/src/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java +++ b/src/share/classes/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java @@ -59,7 +59,7 @@ import java.util.List; */ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec { - private List preList; + private List preList; /** * Indicates the default namespace ("#default"). @@ -71,7 +71,7 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec { * list. */ public ExcC14NParameterSpec() { - preList = Collections.EMPTY_LIST; + preList = Collections.emptyList(); } /** @@ -86,17 +86,22 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec { * @throws ClassCastException if any of the entries in the list are not * of type String */ + @SuppressWarnings("rawtypes") public ExcC14NParameterSpec(List prefixList) { if (prefixList == null) { throw new NullPointerException("prefixList cannot be null"); } - this.preList = new ArrayList(prefixList); - for (int i = 0, size = preList.size(); i < size; i++) { - if (!(preList.get(i) instanceof String)) { + List copy = new ArrayList<>((List)prefixList); + for (int i = 0, size = copy.size(); i < size; i++) { + if (!(copy.get(i) instanceof String)) { throw new ClassCastException("not a String"); } } - preList = Collections.unmodifiableList(preList); + + @SuppressWarnings("unchecked") + List temp = (List)copy; + + preList = Collections.unmodifiableList(temp); } /** @@ -109,6 +114,7 @@ public final class ExcC14NParameterSpec implements C14NMethodParameterSpec { * @return the inclusive namespace prefix list (may be empty but never * null) */ + @SuppressWarnings("rawtypes") public List getPrefixList() { return preList; } diff --git a/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java b/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java index 35854ab42a32f5dce25cdbd18df876c3e7857eae..6320f620238dfc7b67b227b904983206eb28bfa2 100644 --- a/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java +++ b/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilter2ParameterSpec.java @@ -46,7 +46,7 @@ import javax.xml.crypto.dsig.Transform; */ public final class XPathFilter2ParameterSpec implements TransformParameterSpec { - private final List xPathList; + private final List xPathList; /** * Creates an XPathFilter2ParameterSpec. @@ -59,11 +59,12 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec { * @throws NullPointerException if xPathList is * null */ + @SuppressWarnings("rawtypes") public XPathFilter2ParameterSpec(List xPathList) { if (xPathList == null) { throw new NullPointerException("xPathList cannot be null"); } - List xPathListCopy = new ArrayList(xPathList); + List xPathListCopy = new ArrayList<>((List)xPathList); if (xPathListCopy.isEmpty()) { throw new IllegalArgumentException("xPathList cannot be empty"); } @@ -74,7 +75,11 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec { ("xPathList["+i+"] is not a valid type"); } } - this.xPathList = Collections.unmodifiableList(xPathListCopy); + + @SuppressWarnings("unchecked") + List temp = (List)xPathListCopy; + + this.xPathList = Collections.unmodifiableList(temp); } /** @@ -86,6 +91,7 @@ public final class XPathFilter2ParameterSpec implements TransformParameterSpec { * @return a List of XPathType objects * (never null or empty) */ + @SuppressWarnings("rawtypes") public List getXPathList() { return xPathList; } diff --git a/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java b/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java index 486bf27e9a9f3e3a0b5fda30cfcf9b7728ecd2c4..36adde5e8a84b8b82df17b62d784d741a83156cc 100644 --- a/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java +++ b/src/share/classes/javax/xml/crypto/dsig/spec/XPathFilterParameterSpec.java @@ -52,7 +52,7 @@ import java.util.Map.Entry; public final class XPathFilterParameterSpec implements TransformParameterSpec { private String xPath; - private Map nsMap; + private Map nsMap; /** * Creates an XPathFilterParameterSpec with the specified @@ -66,7 +66,7 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec { throw new NullPointerException(); } this.xPath = xPath; - this.nsMap = Collections.EMPTY_MAP; + this.nsMap = Collections.emptyMap(); } /** @@ -83,21 +83,26 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec { * @throws ClassCastException if any of the map's keys or entries are not * of type String */ + @SuppressWarnings("rawtypes") public XPathFilterParameterSpec(String xPath, Map namespaceMap) { if (xPath == null || namespaceMap == null) { throw new NullPointerException(); } this.xPath = xPath; - nsMap = new HashMap(namespaceMap); - Iterator entries = nsMap.entrySet().iterator(); + Map copy = new HashMap<>((Map)namespaceMap); + Iterator> entries = copy.entrySet().iterator(); while (entries.hasNext()) { - Map.Entry me = (Map.Entry) entries.next(); + Map.Entry me = entries.next(); if (!(me.getKey() instanceof String) || !(me.getValue() instanceof String)) { throw new ClassCastException("not a String"); } } - nsMap = Collections.unmodifiableMap(nsMap); + + @SuppressWarnings("unchecked") + Map temp = (Map)copy; + + nsMap = Collections.unmodifiableMap(temp); } /** @@ -120,6 +125,7 @@ public final class XPathFilterParameterSpec implements TransformParameterSpec { * @return a Map of namespace prefixes to namespace URIs (may * be empty, but never null) */ + @SuppressWarnings("rawtypes") public Map getNamespaceMap() { return nsMap; } diff --git a/src/share/classes/javax/xml/crypto/dsig/spec/XPathType.java b/src/share/classes/javax/xml/crypto/dsig/spec/XPathType.java index 8ad417c4410c940564b8cc732ae2affc90ec6111..751df6c515f6174f3d76222531352c182f31fc32 100644 --- a/src/share/classes/javax/xml/crypto/dsig/spec/XPathType.java +++ b/src/share/classes/javax/xml/crypto/dsig/spec/XPathType.java @@ -106,7 +106,7 @@ public class XPathType { private final String expression; private final Filter filter; - private Map nsMap; + private Map nsMap; /** * Creates an XPathType instance with the specified XPath @@ -127,7 +127,7 @@ public class XPathType { } this.expression = expression; this.filter = filter; - this.nsMap = Collections.EMPTY_MAP; + this.nsMap = Collections.emptyMap(); } /** @@ -147,21 +147,26 @@ public class XPathType { * @throws ClassCastException if any of the map's keys or entries are * not of type String */ + @SuppressWarnings("rawtypes") public XPathType(String expression, Filter filter, Map namespaceMap) { this(expression, filter); if (namespaceMap == null) { throw new NullPointerException("namespaceMap cannot be null"); } - nsMap = new HashMap(namespaceMap); - Iterator entries = nsMap.entrySet().iterator(); + Map copy = new HashMap<>((Map)namespaceMap); + Iterator> entries = copy.entrySet().iterator(); while (entries.hasNext()) { - Map.Entry me = (Map.Entry) entries.next(); + Map.Entry me = entries.next(); if (!(me.getKey() instanceof String) || !(me.getValue() instanceof String)) { throw new ClassCastException("not a String"); } } - nsMap = Collections.unmodifiableMap(nsMap); + + @SuppressWarnings("unchecked") + Map temp = (Map)copy; + + nsMap = Collections.unmodifiableMap(temp); } /** @@ -193,6 +198,7 @@ public class XPathType { * @return a Map of namespace prefixes to namespace URIs * (may be empty, but never null) */ + @SuppressWarnings("rawtypes") public Map getNamespaceMap() { return nsMap; } diff --git a/src/share/classes/sun/misc/JavaNetHttpCookieAccess.java b/src/share/classes/sun/misc/JavaNetHttpCookieAccess.java new file mode 100644 index 0000000000000000000000000000000000000000..8149a222bdb6963131aabeaee442b3d538906ddd --- /dev/null +++ b/src/share/classes/sun/misc/JavaNetHttpCookieAccess.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.misc; + +import java.net.HttpCookie; +import java.util.List; + +public interface JavaNetHttpCookieAccess { + /* + * Constructs cookies from Set-Cookie or Set-Cookie2 header string, + * retaining the original header String in the cookie itself. + */ + public List parse(String header); + + /* + * Returns the original header this cookie was consructed from, if it was + * constructed by parsing a header, otherwise null. + */ + public String header(HttpCookie cookie); +} + diff --git a/src/share/classes/sun/misc/SharedSecrets.java b/src/share/classes/sun/misc/SharedSecrets.java index 0bd39b4a5d42f0b12478143bad17dce21db3ba11..a81e754a278abb10c009b59669ccda341d5ea12a 100644 --- a/src/share/classes/sun/misc/SharedSecrets.java +++ b/src/share/classes/sun/misc/SharedSecrets.java @@ -47,6 +47,7 @@ public class SharedSecrets { private static JavaLangAccess javaLangAccess; private static JavaIOAccess javaIOAccess; private static JavaNetAccess javaNetAccess; + private static JavaNetHttpCookieAccess javaNetHttpCookieAccess; private static JavaNioAccess javaNioAccess; private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess; private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess; @@ -81,6 +82,16 @@ public class SharedSecrets { return javaNetAccess; } + public static void setJavaNetHttpCookieAccess(JavaNetHttpCookieAccess a) { + javaNetHttpCookieAccess = a; + } + + public static JavaNetHttpCookieAccess getJavaNetHttpCookieAccess() { + if (javaNetHttpCookieAccess == null) + unsafe.ensureClassInitialized(java.net.HttpCookie.class); + return javaNetHttpCookieAccess; + } + public static void setJavaNioAccess(JavaNioAccess jna) { javaNioAccess = jna; } diff --git a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 3a7737aec74e2b94481c10da02ff5f2adeff0f5f..ae2d682c9b9a831362a0d01c7ee74e2870178181 100644 --- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -32,6 +32,7 @@ import java.net.ProtocolException; import java.net.HttpRetryException; import java.net.PasswordAuthentication; import java.net.Authenticator; +import java.net.HttpCookie; import java.net.InetAddress; import java.net.UnknownHostException; import java.net.SocketTimeoutException; @@ -46,6 +47,8 @@ import java.net.SecureCacheResponse; import java.net.CacheRequest; import java.net.Authenticator.RequestorType; import java.io.*; +import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.Map; import java.util.List; @@ -2580,6 +2583,80 @@ public class HttpURLConnection extends java.net.HttpURLConnection { return false; } + // constant strings represent set-cookie header names + private final static String SET_COOKIE = "set-cookie"; + private final static String SET_COOKIE2 = "set-cookie2"; + + /** + * Returns a filtered version of the given headers value. + * + * Note: The implementation currently only filters out HttpOnly cookies + * from Set-Cookie and Set-Cookie2 headers. + */ + private String filterHeaderField(String name, String value) { + if (value == null) + return null; + + if (SET_COOKIE.equalsIgnoreCase(name) || + SET_COOKIE2.equalsIgnoreCase(name)) { + // Filtering only if there is a cookie handler. [Assumption: the + // cookie handler will store/retrieve the HttpOnly cookies] + if (cookieHandler == null) + return value; + + sun.misc.JavaNetHttpCookieAccess access = + sun.misc.SharedSecrets.getJavaNetHttpCookieAccess(); + StringBuilder retValue = new StringBuilder(); + List cookies = access.parse(value); + boolean multipleCookies = false; + for (HttpCookie cookie : cookies) { + // skip HttpOnly cookies + if (cookie.isHttpOnly()) + continue; + if (multipleCookies) + retValue.append(','); // RFC 2965, comma separated + retValue.append(access.header(cookie)); + multipleCookies = true; + } + + return retValue.length() == 0 ? null : retValue.toString(); + } + + return value; + } + + // Cache the filtered response headers so that they don't need + // to be generated for every getHeaderFields() call. + private Map> filteredHeaders; // null + + private Map> getFilteredHeaderFields() { + if (filteredHeaders != null) + return filteredHeaders; + + filteredHeaders = new HashMap<>(); + Map> headers; + + if (cachedHeaders != null) + headers = cachedHeaders.getHeaders(); + else + headers = responses.getHeaders(); + + for (Map.Entry> e: headers.entrySet()) { + String key = e.getKey(); + List values = e.getValue(), filteredVals = new ArrayList<>(); + for (String value : values) { + String fVal = filterHeaderField(key, value); + if (fVal != null) + filteredVals.add(fVal); + } + if (!filteredVals.isEmpty()) + filteredHeaders.put(key, + Collections.unmodifiableList(filteredVals)); + } + + return filteredHeaders; + } + /** * Gets a header field by name. Returns null if not known. * @param name the name of the header field @@ -2591,10 +2668,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection { } catch (IOException e) {} if (cachedHeaders != null) { - return cachedHeaders.findValue(name); + return filterHeaderField(name, cachedHeaders.findValue(name)); } - return responses.findValue(name); + return filterHeaderField(name, responses.findValue(name)); } /** @@ -2613,11 +2690,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { getInputStream(); } catch (IOException e) {} - if (cachedHeaders != null) { - return cachedHeaders.getHeaders(); - } - - return responses.getHeaders(); + return getFilteredHeaderFields(); } /** @@ -2631,9 +2704,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection { } catch (IOException e) {} if (cachedHeaders != null) { - return cachedHeaders.getValue(n); + return filterHeaderField(cachedHeaders.getKey(n), + cachedHeaders.getValue(n)); } - return responses.getValue(n); + return filterHeaderField(responses.getKey(n), responses.getValue(n)); } /** diff --git a/src/solaris/classes/java/lang/ProcessEnvironment.java b/src/solaris/classes/java/lang/ProcessEnvironment.java index bb60c71b604b16dc9b527ccdc03fe45966449b5a..c5cfbaa5da4740ba3dcd479f9eee63d19a8f0b32 100644 --- a/src/solaris/classes/java/lang/ProcessEnvironment.java +++ b/src/solaris/classes/java/lang/ProcessEnvironment.java @@ -91,6 +91,7 @@ final class ProcessEnvironment } /* Only for use by ProcessBuilder.environment() */ + @SuppressWarnings("unchecked") static Map environment() { return new StringEnvironment ((Map)(theEnvironment.clone())); diff --git a/src/solaris/native/java/net/Inet4AddressImpl.c b/src/solaris/native/java/net/Inet4AddressImpl.c index ea68408efec0d8d5cab7ff95cfd421d1983d1e70..e6bd2cca54f62012d36ddfb61aae2928ebb14629 100644 --- a/src/solaris/native/java/net/Inet4AddressImpl.c +++ b/src/solaris/native/java/net/Inet4AddressImpl.c @@ -367,11 +367,11 @@ ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout, sizeof(struct sockaddr)); if (n < 0 && errno != EINPROGRESS ) { #ifdef __linux__ - if (errno != EINVAL) + if (errno != EINVAL && errno != EHOSTUNREACH) /* * On some Linuxes, when bound to the loopback interface, sendto - * will fail and errno will be set to EINVAL. When that happens, - * don't throw an exception, just return false. + * will fail and errno will be set to EINVAL or EHOSTUNREACH. + * When that happens, don't throw an exception, just return false. */ #endif /*__linux__ */ NET_ThrowNew(env, errno, "Can't send ICMP packet"); @@ -525,10 +525,11 @@ Java_java_net_Inet4AddressImpl_isReachable0(JNIEnv *env, jobject this, case EADDRNOTAVAIL: /* address is not available on the remote machine */ #ifdef __linux__ case EINVAL: + case EHOSTUNREACH: /* * On some Linuxes, when bound to the loopback interface, connect - * will fail and errno will be set to EINVAL. When that happens, - * don't throw an exception, just return false. + * will fail and errno will be set to EINVAL or EHOSTUNREACH. + * When that happens, don't throw an exception, just return false. */ #endif /* __linux__ */ close(fd); diff --git a/src/solaris/native/java/net/Inet6AddressImpl.c b/src/solaris/native/java/net/Inet6AddressImpl.c index 4f3f5869ca0a3a2f0700e4b381818e42a5f4937a..051326b8ee96a10aa7f7a8042607a1cecffa0cb3 100644 --- a/src/solaris/native/java/net/Inet6AddressImpl.c +++ b/src/solaris/native/java/net/Inet6AddressImpl.c @@ -502,11 +502,11 @@ ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout, n = sendto(fd, sendbuf, plen, 0, (struct sockaddr*) him, sizeof(struct sockaddr_in6)); if (n < 0 && errno != EINPROGRESS) { #ifdef __linux__ - if (errno != EINVAL) + if (errno != EINVAL && errno != EHOSTUNREACH) /* * On some Linuxes, when bound to the loopback interface, sendto - * will fail and errno will be set to EINVAL. When that happens, - * don't throw an exception, just return false. + * will fail and errno will be set to EINVAL or EHOSTUNREACH. + * When that happens, don't throw an exception, just return false. */ #endif /*__linux__ */ NET_ThrowNew(env, errno, "Can't send ICMP packet"); @@ -670,10 +670,11 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this, case EADDRNOTAVAIL: /* address is not available on the remote machine */ #ifdef __linux__ case EINVAL: + case EHOSTUNREACH: /* * On some Linuxes, when bound to the loopback interface, connect - * will fail and errno will be set to EINVAL. When that happens, - * don't throw an exception, just return false. + * will fail and errno will be set to EINVAL or EHOSTUNREACH. + * When that happens, don't throw an exception, just return false. */ #endif /* __linux__ */ close(fd); diff --git a/src/windows/classes/java/lang/ProcessEnvironment.java b/src/windows/classes/java/lang/ProcessEnvironment.java index 89e468999998a911ddadd821848ffca9d1fad636..c49f1f327819d993653f9f910c5b2c4129eac81e 100644 --- a/src/windows/classes/java/lang/ProcessEnvironment.java +++ b/src/windows/classes/java/lang/ProcessEnvironment.java @@ -68,6 +68,9 @@ import java.util.*; final class ProcessEnvironment extends HashMap { + + private static final long serialVersionUID = -8017839552603542824L; + private static String validateName(String name) { // An initial `=' indicates a magic Windows variable name -- OK if (name.indexOf('=', 1) != -1 || @@ -144,6 +147,7 @@ final class ProcessEnvironment extends HashMap }; } private static Map.Entry checkedEntry(Object o) { + @SuppressWarnings("unchecked") Map.Entry e = (Map.Entry) o; nonNullString(e.getKey()); nonNullString(e.getValue()); @@ -281,6 +285,7 @@ final class ProcessEnvironment extends HashMap } // Only for use by ProcessBuilder.environment() + @SuppressWarnings("unchecked") static Map environment() { return (Map) theEnvironment.clone(); } diff --git a/test/Makefile b/test/Makefile index 7571c8756124759decb127b04cc25c61a0bdd964..e94a561695e611db539892c1eba291c34e09c176 100644 --- a/test/Makefile +++ b/test/Makefile @@ -322,8 +322,8 @@ BUNDLE_UP_AND_EXIT = \ ################################################################ -# Default make rule (runs jtreg_tests) -all: jtreg_tests +# Default make rule (runs default jdk tests) +all: jdk_default @$(ECHO) "Testing completed successfully" # Prep for output @@ -422,6 +422,7 @@ endef # ------------------------------------------------------------------ # Batches of tests (somewhat arbitrary assigments to jdk_* targets) +JDK_DEFAULT_TARGETS = JDK_ALL_TARGETS = # Stable othervm testruns (minus items from PROBLEM_LIST) @@ -433,6 +434,7 @@ jdk_awt: $(call TestDirs, com/sun/awt java/awt sun/awt \ # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_beans1 +JDK_DEFAULT_TARGETS += jdk_beans1 jdk_beans1: $(call TestDirs, \ java/beans/beancontext java/beans/PropertyChangeSupport \ java/beans/Introspector java/beans/Performance \ @@ -459,11 +461,13 @@ jdk_beans: jdk_beans1 jdk_beans2 jdk_beans3 # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_io +JDK_DEFAULT_TARGETS += jdk_io jdk_io: $(call TestDirs, java/io) $(call RunAgentvmBatch) # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_lang +JDK_DEFAULT_TARGETS += jdk_lang jdk_lang: $(call TestDirs, java/lang) $(call RunAgentvmBatch) @@ -485,11 +489,13 @@ jdk_management: jdk_management1 jdk_management2 # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_math +JDK_DEFAULT_TARGETS += jdk_math jdk_math: $(call TestDirs, java/math) $(call RunAgentvmBatch) # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_misc +JDK_DEFAULT_TARGETS += jdk_misc jdk_misc: $(call TestDirs, \ demo/jvmti demo/zipfs javax/naming javax/script \ javax/smartcardio com/sun/jndi com/sun/xml sun/misc) @@ -497,16 +503,19 @@ jdk_misc: $(call TestDirs, \ # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_net +JDK_DEFAULT_TARGETS += jdk_net jdk_net: $(call TestDirs, com/sun/net java/net sun/net) $(call RunAgentvmBatch) # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_nio1 +JDK_DEFAULT_TARGETS += jdk_nio1 jdk_nio1: $(call TestDirs, java/nio/file) $(call RunAgentvmBatch) # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_nio2 +JDK_DEFAULT_TARGETS += jdk_nio2 jdk_nio2: $(call TestDirs, java/nio/Buffer java/nio/ByteOrder \ java/nio/channels java/nio/MappedByteBuffer) $(call SharedLibraryPermissions,java/nio/channels) @@ -514,6 +523,7 @@ jdk_nio2: $(call TestDirs, java/nio/Buffer java/nio/ByteOrder \ # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_nio3 +JDK_DEFAULT_TARGETS += jdk_nio3 jdk_nio3: $(call TestDirs, sun/nio) $(call RunAgentvmBatch) @@ -533,6 +543,7 @@ jdk_rmi: $(call TestDirs, java/rmi javax/rmi sun/rmi) # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_security1 +JDK_DEFAULT_TARGETS += jdk_security1 jdk_security1: $(call TestDirs, java/security) $(call RunAgentvmBatch) @@ -566,6 +577,7 @@ jdk_swing: $(call TestDirs, javax/swing sun/java2d \ # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_text +JDK_DEFAULT_TARGETS += jdk_text jdk_text: $(call TestDirs, java/text sun/text) $(call RunAgentvmBatch) @@ -589,15 +601,18 @@ jdk_tools: jdk_tools1 jdk_tools2 # Stable agentvm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_util +JDK_DEFAULT_TARGETS += jdk_util jdk_util: $(call TestDirs, java/util sun/util) $(call RunAgentvmBatch) # ------------------------------------------------------------------ +# Run default tests +jdk_default: $(JDK_DEFAULT_TARGETS) + @$(SummaryInfo) + # Run all tests -FILTER_OUT_LIST=jdk_awt jdk_rmi jdk_swing -JDK_ALL_STABLE_TARGETS := $(filter-out $(FILTER_OUT_LIST), $(JDK_ALL_TARGETS)) -jdk_all: $(JDK_ALL_STABLE_TARGETS) +jdk_all: $(JDK_ALL_TARGETS) @$(SummaryInfo) # These are all phony targets diff --git a/test/java/nio/file/Files/CustomOptions.java b/test/java/nio/file/Files/CustomOptions.java new file mode 100644 index 0000000000000000000000000000000000000000..a39cc6a6c9311ac7afb6fd0a71e3af63417a7aec --- /dev/null +++ b/test/java/nio/file/Files/CustomOptions.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 7087549 + * @summary Test custom options with newInputStream. + * @author Brandon Passanisi + * @library .. + * @build CustomOptions PassThroughFileSystem + */ + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.nio.file.*; +import java.nio.file.attribute.FileAttribute; +import java.nio.file.spi.FileSystemProvider; +import java.nio.channels.SeekableByteChannel; +import java.util.Collections; +import java.util.Set; +import java.util.Map; + +public class CustomOptions { + + // Create a custom option + static enum CustomOption implements OpenOption { + IGNORE, + } + + // number of times that IGNORE option is observed + static int ignoreCount; + + // A pass through provider that supports a custom open option + static class MyCustomProvider extends PassThroughFileSystem.PassThroughProvider { + public MyCustomProvider() { } + + @Override + public SeekableByteChannel newByteChannel(Path path, + Set options, + FileAttribute... attrs) + throws IOException + { + if (options.contains(CustomOption.IGNORE)) { + ignoreCount++; + options.remove(CustomOption.IGNORE); + } + return super.newByteChannel(path, options, attrs); + } + } + + public static void main(String[] args) throws Exception { + FileSystemProvider provider = new MyCustomProvider(); + Map env = Collections.emptyMap(); + URI uri = URI.create("pass:///"); + FileSystem fs = provider.newFileSystem(uri, env); + + // Create temp dir for testing + Path dir = TestUtil.createTemporaryDirectory(); + try { + + // Create temp file for testing + Path path = fs.getPath(dir.resolve("foo").toString()); + Files.createFile(path); + + // Test custom option + Files.newInputStream(path, CustomOption.IGNORE).close(); + if (ignoreCount != 1) + throw new RuntimeException("IGNORE option not passed through"); + + // Test null option + try { + Files.newInputStream(path, new OpenOption[] { null }).close(); + throw new RuntimeException("NullPointerException expected"); + } catch (NullPointerException ignore) { } + + // Test unsupported options + try { + Files.newInputStream(path, StandardOpenOption.WRITE).close(); + throw new RuntimeException("UnsupportedOperationException expected"); + } catch (UnsupportedOperationException uoe) { } + try { + Files.newInputStream(path, StandardOpenOption.APPEND).close(); + throw new RuntimeException("UnsupportedOperationException expected"); + } catch (UnsupportedOperationException uoe) { } + + } finally { + // Cleanup + TestUtil.removeAll(dir); + } + } +} diff --git a/test/java/util/Collections/EmptyIterator.java b/test/java/util/Collections/EmptyIterator.java index a2b2f41742ca529e9bc6befb40b8b96603fad61b..902f03407dcf0ff4253bfc751fe6b2d90ae49d9e 100644 --- a/test/java/util/Collections/EmptyIterator.java +++ b/test/java/util/Collections/EmptyIterator.java @@ -35,8 +35,6 @@ public class EmptyIterator { void test(String[] args) throws Throwable { testEmptyCollection(Collections.emptyList()); testEmptyCollection(Collections.emptySet()); - testEmptyCollection(new java.util.concurrent. - SynchronousQueue()); testEmptyMap(Collections.emptyMap()); diff --git a/test/java/util/regex/RegExTest.java b/test/java/util/regex/RegExTest.java index 10644e491aa11bf89aaebe71bb0642fb7cfa2edf..159e9afddd92830132035c2ec03387269a4e5649 100644 --- a/test/java/util/regex/RegExTest.java +++ b/test/java/util/regex/RegExTest.java @@ -32,7 +32,7 @@ * 4872664 4803179 4892980 4900747 4945394 4938995 4979006 4994840 4997476 * 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940 * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133 - * 6350801 6676425 6878475 6919132 6931676 6948903 7014645 7039066 + * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066 */ import java.util.regex.*; @@ -50,6 +50,7 @@ public class RegExTest { private static Random generator = new Random(); private static boolean failure = false; private static int failCount = 0; + private static String firstFailure = null; /** * Main to interpret arguments and run several tests. @@ -133,15 +134,19 @@ public class RegExTest { hitEndTest(); toMatchResultTest(); surrogatesInClassTest(); + removeQEQuotingTest(); namedGroupCaptureTest(); nonBmpClassComplementTest(); unicodePropertiesTest(); unicodeHexNotationTest(); unicodeClassesTest(); - if (failure) - throw new RuntimeException("Failure in the RE handling."); - else + if (failure) { + throw new + RuntimeException("RegExTest failed, 1st failure: " + + firstFailure); + } else { System.err.println("OKAY: All tests passed."); + } } // Utility functions @@ -215,8 +220,14 @@ public class RegExTest { String paddedName = paddedNameBuffer.toString(); System.err.println(paddedName + ": " + (failCount==0 ? "Passed":"Failed("+failCount+")")); - if (failCount > 0) + if (failCount > 0) { failure = true; + + if (firstFailure == null) { + firstFailure = testName; + } + } + failCount = 0; } @@ -295,6 +306,22 @@ public class RegExTest { Matcher matcher = pattern.matcher("\ud834\udd22"); if (!matcher.find()) failCount++; + + report("Surrogate pair in Unicode escape"); + } + + // This is for bug6990617 + // Test if Pattern.RemoveQEQuoting works correctly if the octal unicode + // char encoding is only 2 or 3 digits instead of 4 and the first quoted + // char is an octal digit. + private static void removeQEQuotingTest() throws Exception { + Pattern pattern = + Pattern.compile("\\011\\Q1sometext\\E\\011\\Q2sometext\\E"); + Matcher matcher = pattern.matcher("\t1sometext\t2sometext"); + if (!matcher.find()) + failCount++; + + report("Remove Q/E Quoting"); } // This is for bug 4988891 diff --git a/test/sun/net/www/protocol/http/HttpOnly.java b/test/sun/net/www/protocol/http/HttpOnly.java new file mode 100644 index 0000000000000000000000000000000000000000..60596bad219653e59c30c85bccfb8596ba7b1a0c --- /dev/null +++ b/test/sun/net/www/protocol/http/HttpOnly.java @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 7095980 + * @summary Ensure HttpURLConnection (and supporting APIs) don't expose + * HttpOnly cookies + */ + +import java.io.IOException; +import java.net.CookieHandler; +import java.net.CookieManager; +import java.net.CookiePolicy; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.URI; +import java.net.HttpURLConnection; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; + +/* + * 1) start the HTTP server + * 2) populate cookie store with HttpOnly cookies + * 3) make HTTP request that should contain HttpOnly cookies + * 4) check HttpOnly cookies received by server + * 5) server reply with Set-Cookie containing HttpOnly cookie + * 6) check HttpOnly cookies are not accessible from Http client + */ + +public class HttpOnly { + + static final String URI_PATH = "/xxyyzz/"; + static final int SESSION_ID = 12345; + + void test(String[] args) throws Exception { + HttpServer server = startHttpServer(); + CookieHandler previousHandler = CookieHandler.getDefault(); + try { + InetSocketAddress address = server.getAddress(); + URI uri = new URI("http://" + InetAddress.getLocalHost().getHostAddress() + + ":" + address.getPort() + URI_PATH); + populateCookieStore(uri); + doClient(uri); + } finally { + CookieHandler.setDefault(previousHandler); + server.stop(0); + } + } + + void populateCookieStore(URI uri) + throws IOException { + + CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL); + CookieHandler.setDefault(cm); + Map> header = new HashMap<>(); + List values = new ArrayList<>(); + values.add("JSESSIONID=" + SESSION_ID + "; version=1; Path=" + + URI_PATH +"; HttpOnly"); + values.add("CUSTOMER=WILE_E_COYOTE; version=1; Path=" + URI_PATH); + header.put("Set-Cookie", values); + cm.put(uri, header); + } + + void doClient(URI uri) throws Exception { + HttpURLConnection uc = (HttpURLConnection) uri.toURL().openConnection(); + int resp = uc.getResponseCode(); + check(resp == 200, + "Unexpected response code. Expected 200, got " + resp); + + // TEST 1: check getRequestProperty doesn't return the HttpOnly cookie + // In fact, that it doesn't return any automatically set cookies. + String cookie = uc.getRequestProperty("Cookie"); + check(cookie == null, + "Cookie header returned from getRequestProperty, value " + cookie); + + // TEST 2: check getRequestProperties doesn't return the HttpOnly cookie. + // In fact, that it doesn't return any automatically set cookies. + Map> reqHeaders = uc.getRequestProperties(); + Set>> entries = reqHeaders.entrySet(); + for (Map.Entry> entry : entries) { + String header = entry.getKey(); + check(!"Cookie".equalsIgnoreCase(header), + "Cookie header returned from getRequestProperties, value " + + entry.getValue()); + } + + // TEST 3: check getHeaderField doesn't return Set-Cookie with HttpOnly + String setCookie = uc.getHeaderField("Set-Cookie"); + if (setCookie != null) { + debug("Set-Cookie:" + setCookie); + check(!setCookie.toLowerCase().contains("httponly"), + "getHeaderField returned Set-Cookie header with HttpOnly, " + + "value = " + setCookie); + } + + // TEST 3.5: check getHeaderField doesn't return Set-Cookie2 with HttpOnly + String setCookie2 = uc.getHeaderField("Set-Cookie2"); + if (setCookie2 != null) { + debug("Set-Cookie2:" + setCookie2); + check(!setCookie2.toLowerCase().contains("httponly"), + "getHeaderField returned Set-Cookie2 header with HttpOnly, " + + "value = " + setCookie2); + } + + // TEST 4: check getHeaderFields doesn't return Set-Cookie + // or Set-Cookie2 headers with HttpOnly + Map> respHeaders = uc.getHeaderFields(); + Set>> respEntries = respHeaders.entrySet(); + for (Map.Entry> entry : respEntries) { + String header = entry.getKey(); + if ("Set-Cookie".equalsIgnoreCase(header)) { + List setCookieValues = entry.getValue(); + debug("Set-Cookie:" + setCookieValues); + for (String value : setCookieValues) + check(!value.toLowerCase().contains("httponly"), + "getHeaderFields returned Set-Cookie header with HttpOnly, " + + "value = " + value); + } + if ("Set-Cookie2".equalsIgnoreCase(header)) { + List setCookieValues = entry.getValue(); + debug("Set-Cookie2:" + setCookieValues); + for (String value : setCookieValues) + check(!value.toLowerCase().contains("httponly"), + "getHeaderFields returned Set-Cookie2 header with HttpOnly, " + + "value = " + value); + } + } + + // Now add some user set cookies into the mix. + uc = (HttpURLConnection) uri.toURL().openConnection(); + uc.addRequestProperty("Cookie", "CUSTOMER_ID=CHEGAR;"); + resp = uc.getResponseCode(); + check(resp == 200, + "Unexpected response code. Expected 200, got " + resp); + + // TEST 5: check getRequestProperty doesn't return the HttpOnly cookie + cookie = uc.getRequestProperty("Cookie"); + check(!cookie.toLowerCase().contains("httponly"), + "HttpOnly cookie returned from getRequestProperty, value " + cookie); + + // TEST 6: check getRequestProperties doesn't return the HttpOnly cookie. + reqHeaders = uc.getRequestProperties(); + entries = reqHeaders.entrySet(); + for (Map.Entry> entry : entries) { + String header = entry.getKey(); + if ("Cookie".equalsIgnoreCase(header)) { + for (String val : entry.getValue()) + check(!val.toLowerCase().contains("httponly"), + "HttpOnly cookie returned from getRequestProperties," + + " value " + val); + } + } + } + + // HTTP Server + HttpServer startHttpServer() throws IOException { + HttpServer httpServer = HttpServer.create(new InetSocketAddress(0), 0); + httpServer.createContext(URI_PATH, new SimpleHandler()); + httpServer.start(); + return httpServer; + } + + class SimpleHandler implements HttpHandler { + @Override + public void handle(HttpExchange t) throws IOException { + Headers reqHeaders = t.getRequestHeaders(); + + // some small sanity check + List cookies = reqHeaders.get("Cookie"); + for (String cookie : cookies) { + if (!cookie.contains("JSESSIONID") + || !cookie.contains("WILE_E_COYOTE")) + t.sendResponseHeaders(400, -1); + } + + // return some cookies so we can check getHeaderField(s) + Headers respHeaders = t.getResponseHeaders(); + List values = new ArrayList<>(); + values.add("ID=JOEBLOGGS; version=1; Path=" + URI_PATH); + values.add("NEW_JSESSIONID=" + (SESSION_ID+1) + "; version=1; Path=" + + URI_PATH +"; HttpOnly"); + values.add("NEW_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + URI_PATH); + respHeaders.put("Set-Cookie", values); + values = new ArrayList<>(); + values.add("COOKIE2_CUSTOMER=WILE_E_COYOTE2; version=1; Path=" + + URI_PATH); + respHeaders.put("Set-Cookie2", values); + values.add("COOKIE2_JSESSIONID=" + (SESSION_ID+100) + + "; version=1; Path=" + URI_PATH +"; HttpOnly"); + respHeaders.put("Set-Cookie2", values); + + t.sendResponseHeaders(200, -1); + t.close(); + } + } + + volatile int passed = 0, failed = 0; + boolean debug = false; + void pass() {passed++;} + void fail() {failed++;} + void fail(String msg) {System.err.println(msg); fail();} + void unexpected(Throwable t) {failed++; t.printStackTrace();} + void debug(String message) { if (debug) System.out.println(message); } + void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} + public static void main(String[] args) throws Throwable { + Class k = new Object(){}.getClass().getEnclosingClass(); + try {k.getMethod("instanceMain",String[].class) + .invoke( k.newInstance(), (Object) args);} + catch (Throwable e) {throw e.getCause();}} + public void instanceMain(String[] args) throws Throwable { + try {test(args);} catch (Throwable t) {unexpected(t);} + System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); + if (failed > 0) throw new AssertionError("Some tests failed");} +} +