diff --git a/.hgtags b/.hgtags index e7144757c53..f50083fb987 100644 --- a/.hgtags +++ b/.hgtags @@ -257,3 +257,4 @@ efe7dbc6088691757404e0c8745f894e3ca9c022 jdk9-b09 0d1f816217dce5e72187f167cc1816080cbeb453 jdk9-b12 1a30593dcb9802faec3b6edb24d86ca088594e4e jdk9-b13 97932f6ad950ae5a73a9da5c96e6e58503ff646b jdk9-b14 +74eb0778e4f2dbff6628e718378449fba27c4265 jdk9-b15 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index b370baabdcc..e60713ac318 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -257,3 +257,4 @@ ab55a18a95e1990a588929d5d29db3eb9985fea0 jdk9-b11 59f6350295f9681fe5956d8bc889bf341914c6cb jdk9-b12 5800456add07e1a68170a229fb5e27376f8875e5 jdk9-b13 4e3aa9723e9972623e3dafc321b368e7db7e9b3b jdk9-b14 +b114474fb25af4e73cb7219f7c04bd8994da03a5 jdk9-b15 diff --git a/corba/.hgtags b/corba/.hgtags index 3f510f7c8a2..29ff1978725 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -257,3 +257,4 @@ a4bf701ac316946c2e5e83138ad8e687da6a4b30 jdk9-b06 e212cdcc8c11f0ba5acf6f5ddb596c4c545a93f9 jdk9-b12 088eec4c36f4d7f250fcd19c4969bf698e3d2cdc jdk9-b13 a2b82f863ba95a596da555a4c1b871c404863e7e jdk9-b14 +e54022d0dd92106fff7f7fe670010cd7e6517ee3 jdk9-b15 diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 00898012217..ab6aa356e85 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -417,3 +417,4 @@ ebc44d040cd149d2120d69fe183a3dae7840f4b4 jdk9-b10 1c383bb39e2849ca62cb763f4e182a29b421d60a jdk9-b12 456ad9c99133803d4e1433124c85a6fd141b9ac9 jdk9-b13 bd333491bb6c012d7b606939406d0fa9a5ac7ffd jdk9-b14 +170f6d733d7aec062f743a6b8c1cce940a7a984a jdk9-b15 diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 7cda4470598..f6504ed115a 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -257,3 +257,4 @@ f93a792fe37279d4d37aea86a99f3abbdc6fe79b jdk9-b09 e88cecf5a21b760ff7d7761c2db6bb8c82bc9f0c jdk9-b12 5eaf717f6e36037a6d3744ffeee0e4c88e64a0d2 jdk9-b13 32b3fc4bc7374a34d52b7f4e2391b4b4b0c084e8 jdk9-b14 +6bad71866c7598587860e0981b0b0e51ec8c0476 jdk9-b15 diff --git a/jaxws/.hgtags b/jaxws/.hgtags index c7dda23a67d..7f510c46e5f 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -260,3 +260,4 @@ c9e8bb8c1144a966ca7b481142c6b5e55d14a29c jdk9-b09 779f8b21c75f83e3918dac8499e4d0ecb3a54ed7 jdk9-b12 3d42204854c9f703e3ccdc8891248e73057713ab jdk9-b13 02e58850b7062825308413d420f2b02c1f25a724 jdk9-b14 +e9780330017a6b464a385356d77e5136f9de8d09 jdk9-b15 diff --git a/jdk/.hgtags b/jdk/.hgtags index fdf62aef521..0316b38ce62 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -257,3 +257,4 @@ ab06ba2894313a47e4969ca37792ff119c49e711 jdk9-b10 83d9bc20973de232cae45b139fdff8a4549c130f jdk9-b12 c7c8002d02721e02131d104549ebeb8b379fb8d2 jdk9-b13 5c7a17a81afd0906b53ee31d95a3211c96ff6b25 jdk9-b14 +4537360f09fe23ab339ee588747b657feb12d0c8 jdk9-b15 diff --git a/jdk/make/CompileLaunchers.gmk b/jdk/make/CompileLaunchers.gmk index 68786a0a5b3..efd11dca099 100644 --- a/jdk/make/CompileLaunchers.gmk +++ b/jdk/make/CompileLaunchers.gmk @@ -442,11 +442,6 @@ else endif -ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) - UNPACKEXE_CFLAGS += -xregs=no%appl - UNPACKEXE_LDFLAGS_solaris += -xmemalign=4s -endif - UNPACKEXE_LANG := C ifeq ($(OPENJDK_TARGET_OS), solaris) UNPACKEXE_LANG := C++ diff --git a/jdk/make/CopyIntoClasses.gmk b/jdk/make/CopyIntoClasses.gmk index b3a216fb90e..fdf2a173aca 100644 --- a/jdk/make/CopyIntoClasses.gmk +++ b/jdk/make/CopyIntoClasses.gmk @@ -30,7 +30,6 @@ COPY_PATTERNS := .icu _dict .dat _options .js aliasmap .spp .wav .css \ # These directories should not be copied at all EXCLUDES += \ - com/sun/org/apache/xml/internal/security/resource/schema \ java/awt/doc-files \ java/lang/doc-files \ javax/swing/doc-files \ diff --git a/jdk/make/CreateJars.gmk b/jdk/make/CreateJars.gmk index eebdcf666f0..9d79394539c 100644 --- a/jdk/make/CreateJars.gmk +++ b/jdk/make/CreateJars.gmk @@ -552,40 +552,53 @@ $(eval $(call SetupArchive,BUILD_CT_SYM, $(IMAGES_OUTPUTDIR)/symbols/_the.symbol ########################################################################################## -SRC_ZIP_INCLUDES = \ - com/sun/corba \ - com/sun/image/codec/jpeg \ - com/sun/imageio \ - com/sun/java_cup \ - com/sun/javadoc \ - com/sun/java/swing \ - com/sun/jmx \ - com/sun/naming \ - com/sun/org/apache \ - com/sun/security/auth \ - com/sun/security/jgss \ - com/sun/source \ - java \ - javax/accessibility \ - javax/annotation \ - javax/imageio \ - javax/lang \ - javax/management \ - javax/naming \ - javax/print \ - javax/rmi \ - javax/script \ - javax/security \ - javax/sound \ - javax/sql \ - javax/swing \ - javax/tools \ - javax/xml \ - org/ietf \ - org/omg \ - org/w3c/dom \ - org/xml/sax \ - # +ifdef OPENJDK + SRC_ZIP_INCLUDES = \ + com \ + java \ + javax \ + jdk \ + org \ + sun \ + # + SRC_ZIP_EXCLUDES = +else + SRC_ZIP_INCLUDES = \ + com/sun/corba \ + com/sun/image/codec/jpeg \ + com/sun/imageio \ + com/sun/java_cup \ + com/sun/javadoc \ + com/sun/java/swing \ + com/sun/jmx \ + com/sun/naming \ + com/sun/org/apache \ + com/sun/security/auth \ + com/sun/security/jgss \ + com/sun/source \ + java \ + javax/accessibility \ + javax/annotation \ + javax/imageio \ + javax/lang \ + javax/management \ + javax/naming \ + javax/print \ + javax/rmi \ + javax/script \ + javax/security \ + javax/sound \ + javax/sql \ + javax/swing \ + javax/tools \ + javax/xml \ + org/ietf \ + org/omg \ + org/w3c/dom \ + org/xml/sax \ + # + SRC_ZIP_EXCLUDES = javax/swing/beaninfo +endif SRC_ZIP_SRCS = $(JDK_TOPDIR)/src/share/classes $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes SRC_ZIP_SRCS += $(JDK_OUTPUTDIR)/gensrc @@ -616,7 +629,7 @@ $(eval $(call MakeDir, $(IMAGES_OUTPUTDIR)/src)) $(eval $(call SetupZipArchive,BUILD_SRC_ZIP, \ SRC := $(SRC_ZIP_SRCS) $(IMAGES_OUTPUTDIR)/src, \ INCLUDES := $(SRC_ZIP_INCLUDES) launcher, \ - EXCLUDES := javax/swing/beaninfo, \ + EXCLUDES := $(SRC_ZIP_EXCLUDES), \ SUFFIXES := .java .c .h, \ ZIP := $(IMAGES_OUTPUTDIR)/src.zip, \ EXTRA_DEPS := $(LAUNCHER_ZIP_SRC))) diff --git a/jdk/make/Setup.gmk b/jdk/make/Setup.gmk index aab0adec464..123a03e2c17 100644 --- a/jdk/make/Setup.gmk +++ b/jdk/make/Setup.gmk @@ -27,7 +27,7 @@ DISABLE_WARNINGS := -Xlint:all,-deprecation,-unchecked,-rawtypes,-cast,-serial,- # To build with all warnings enabled, do the following: # make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000" -JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,-overrides,auxiliaryclass,cast,classfile,dep-ann,divzero,empty,overloads,serial,static,try,varargs -Werror +JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,-overrides,auxiliaryclass,cast,classfile,dep-ann,divzero,empty,fallthrough,overloads,serial,static,try,varargs -Werror # Any java code executed during a JDK build to build other parts of the JDK must be # executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this diff --git a/jdk/make/profile-rtjar-includes.txt b/jdk/make/profile-rtjar-includes.txt index b20031a017e..1e954ad625c 100644 --- a/jdk/make/profile-rtjar-includes.txt +++ b/jdk/make/profile-rtjar-includes.txt @@ -88,7 +88,7 @@ PROFILE_2_RTJAR_INCLUDE_PACKAGES := \ java/sql \ javax/rmi/ssl \ javax/sql \ - javax/transaction \ + javax/transaction/xa \ javax/xml \ org/w3c \ org/xml/sax \ @@ -223,7 +223,8 @@ FULL_JRE_RTJAR_INCLUDE_TYPES := \ javax/management/remote/rmi/_RMIConnection_Stub.class \ javax/management/remote/rmi/_RMIServerImpl_Tie.class \ javax/management/remote/rmi/_RMIServer_Stub.class \ - javax/rmi/*.class + javax/rmi/*.class \ + javax/transaction/*.class FULL_JRE_RTJAR_EXCLUDE_TYPES := diff --git a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java index 4f64ef41b7a..aeb6b7736bb 100644 --- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java +++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java @@ -512,7 +512,7 @@ class ConstantPool { } static String qualifiedStringValue(String s1, String s234) { // Qualification by dot must decompose uniquely. Second string might already be qualified. - assert(s1.indexOf(".") < 0); + assert(s1.indexOf('.') < 0); return s1+"."+s234; } diff --git a/jdk/src/share/classes/com/sun/jndi/cosnaming/CorbanameUrl.java b/jdk/src/share/classes/com/sun/jndi/cosnaming/CorbanameUrl.java index f24f87c947e..6b32bb17aa0 100644 --- a/jdk/src/share/classes/com/sun/jndi/cosnaming/CorbanameUrl.java +++ b/jdk/src/share/classes/com/sun/jndi/cosnaming/CorbanameUrl.java @@ -102,7 +102,7 @@ public final class CorbanameUrl { } location = url.substring(addrStart, addrEnd); - int keyStart = location.indexOf("/"); + int keyStart = location.indexOf('/'); if (keyStart >= 0) { // Has key string if (keyStart == (location.length() -1)) { diff --git a/jdk/src/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java b/jdk/src/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java index 2990ed8b549..a6de4af5cd8 100644 --- a/jdk/src/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java +++ b/jdk/src/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java @@ -336,7 +336,7 @@ public class RegistryContext implements Context, Referenceable { String url = "rmi://"; // Enclose IPv6 literal address in '[' and ']' - url = (host.indexOf(":") > -1) ? url + "[" + host + "]" : + url = (host.indexOf(':') > -1) ? url + "[" + host + "]" : url + host; if (port > 0) { url += ":" + Integer.toString(port); diff --git a/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java b/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java index 3e90b27bcce..cb5255d0a7b 100644 --- a/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java +++ b/jdk/src/share/classes/com/sun/jndi/toolkit/url/GenericURLContext.java @@ -149,7 +149,7 @@ abstract public class GenericURLContext implements Context { * foo:rest/of/name foo: */ protected String getURLPrefix(String url) throws NamingException { - int start = url.indexOf(":"); + int start = url.indexOf(':'); if (start < 0) { throw new OperationNotSupportedException("Invalid URL: " + url); @@ -160,7 +160,7 @@ abstract public class GenericURLContext implements Context { start += 2; // skip double slash // find last slash - int posn = url.indexOf("/", start); + int posn = url.indexOf('/', start); if (posn >= 0) { start = posn; } else { diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd deleted file mode 100644 index d69852ff842..00000000000 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/etsi.xsd +++ /dev/null @@ -1,347 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xenc-schema.rng b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xenc-schema.rng deleted file mode 100644 index 895e033a626..00000000000 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xenc-schema.rng +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xenc-schema.xsd b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xenc-schema.xsd deleted file mode 100644 index 85af68b5518..00000000000 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xenc-schema.xsd +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - ]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.dtd b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.dtd deleted file mode 100644 index b2cc19f63a1..00000000000 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.dtd +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.rng b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.rng deleted file mode 100644 index 03330fb1fee..00000000000 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.rng +++ /dev/null @@ -1,339 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.xsd b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.xsd deleted file mode 100644 index e8288a526c3..00000000000 --- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.xsd +++ /dev/null @@ -1,318 +0,0 @@ - - - - - - ]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java b/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java index 616922429b4..28119ef169f 100644 --- a/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java +++ b/jdk/src/share/classes/com/sun/rmi/rmid/ExecOptionPermission.java @@ -303,7 +303,7 @@ public final class ExecOptionPermission extends Permission offset = pname.length() - 1; - while ((last = pname.lastIndexOf(".", offset)) != -1) { + while ((last = pname.lastIndexOf('.', offset)) != -1) { pname = pname.substring(0, last+1) + "*"; x = permissions.get(pname); @@ -318,7 +318,7 @@ public final class ExecOptionPermission extends Permission pname = p.getName(); offset = pname.length() - 1; - while ((last = pname.lastIndexOf("=", offset)) != -1) { + while ((last = pname.lastIndexOf('=', offset)) != -1) { pname = pname.substring(0, last+1) + "*"; x = permissions.get(pname); diff --git a/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java b/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java index cfb728e9910..2d7cc6bf73c 100644 --- a/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java +++ b/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java @@ -6831,7 +6831,7 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern // table name else isolate table name. indexFrom = command.toLowerCase().indexOf("from"); - indexComma = command.indexOf(",", indexFrom); + indexComma = command.indexOf(',', indexFrom); if(indexComma == -1) { // implies only one table diff --git a/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java b/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java index 46637217d1f..ef281db9b10 100644 --- a/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java +++ b/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java @@ -910,7 +910,7 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet { // now remove the last "," strWhereClause = strWhereClause.substring - (0, strWhereClause.lastIndexOf(",")); + (0, strWhereClause.lastIndexOf(',')); // Add from clause strWhereClause = strWhereClause.concat(" from "); @@ -920,7 +920,7 @@ public class JoinRowSetImpl extends WebRowSetImpl implements JoinRowSet { //Remove the last "," strWhereClause = strWhereClause.substring - (0, strWhereClause.lastIndexOf(",")); + (0, strWhereClause.lastIndexOf(',')); // Add the where clause strWhereClause = strWhereClause.concat(" where "); diff --git a/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java b/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java index 3b04d1c748c..d3c22eaf128 100644 --- a/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java +++ b/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java @@ -240,7 +240,7 @@ public class WebRowSetXmlWriter implements XmlWriter, Serializable { // Remove the string after "@xxxx" // before writing it to the xml file. String strProviderInstance = (caller.getSyncProvider()).toString(); - String strProvider = strProviderInstance.substring(0, (caller.getSyncProvider()).toString().indexOf("@")); + String strProvider = strProviderInstance.substring(0, (caller.getSyncProvider()).toString().indexOf('@')); propString("sync-provider-name", strProvider); propString("sync-provider-vendor", "Oracle Corporation"); diff --git a/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java b/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java index 31d714187aa..45aeecc2341 100644 --- a/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java +++ b/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java @@ -1147,7 +1147,7 @@ public class XmlReaderContentHandler extends DefaultHandler { if (nullValue) { rs.setSyncProvider(null); } else { - String str = s.substring(0,s.indexOf("@")+1); + String str = s.substring(0,s.indexOf('@')+1); rs.setSyncProvider(str); } break; diff --git a/jdk/src/share/classes/com/sun/rowset/internal/XmlResolver.java b/jdk/src/share/classes/com/sun/rowset/internal/XmlResolver.java index a51df227d51..a3fa6afc9a2 100644 --- a/jdk/src/share/classes/com/sun/rowset/internal/XmlResolver.java +++ b/jdk/src/share/classes/com/sun/rowset/internal/XmlResolver.java @@ -39,7 +39,7 @@ import org.xml.sax.InputSource; public class XmlResolver implements EntityResolver { public InputSource resolveEntity(String publicId, String systemId) { - String schemaName = systemId.substring(systemId.lastIndexOf("/")); + String schemaName = systemId.substring(systemId.lastIndexOf('/')); if(systemId.startsWith("http://java.sun.com/xml/ns/jdbc")) { return new InputSource(this.getClass().getResourceAsStream(schemaName)); diff --git a/jdk/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java b/jdk/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java index 6bce9361380..e287f858804 100644 --- a/jdk/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java +++ b/jdk/src/share/classes/com/sun/security/auth/module/JndiLoginModule.java @@ -694,7 +694,7 @@ public class JndiLoginModule implements LoginModule { throw new LoginException("Error: no CallbackHandler available " + "to garner authentication information from the user"); - String protocol = userProvider.substring(0, userProvider.indexOf(":")); + String protocol = userProvider.substring(0, userProvider.indexOf(':')); Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback(protocol + " " diff --git a/jdk/src/share/classes/com/sun/security/auth/module/LdapLoginModule.java b/jdk/src/share/classes/com/sun/security/auth/module/LdapLoginModule.java index e161b0ee8de..1de82aa98b6 100644 --- a/jdk/src/share/classes/com/sun/security/auth/module/LdapLoginModule.java +++ b/jdk/src/share/classes/com/sun/security/auth/module/LdapLoginModule.java @@ -400,7 +400,7 @@ public class LdapLoginModule implements LoginModule { // Add any JNDI properties to the environment for (String key : options.keySet()) { - if (key.indexOf(".") > -1) { + if (key.indexOf('.') > -1) { ldapEnvironment.put(key, options.get(key)); } } diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java b/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java index 034a986eac2..8b7e88facac 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/gui/CommandInterpreter.java @@ -857,7 +857,7 @@ public class CommandInterpreter { bpSpec = runtime.createClassLineBreakpoint(classId, lineNumber); } else { // Try stripping method from class.method token. - int idot = token.lastIndexOf("."); + int idot = token.lastIndexOf('.'); if ( (idot <= 0) || /* No dot or dot in first char */ (idot >= token.length() - 1) ) { /* dot in last char */ return null; diff --git a/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java b/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java index 640a8c53ed9..33f6e3ddf7f 100644 --- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java +++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java @@ -1079,7 +1079,7 @@ class Commands { } } else { // Try stripping method from class.method token. - int idot = token.lastIndexOf("."); + int idot = token.lastIndexOf('.'); if ( (idot <= 0) || /* No dot or dot in first char */ (idot >= token.length() - 1) ) { /* dot in last char */ printBreakpointCommandUsage(atForm, inForm); diff --git a/jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java b/jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java index 64d5abe848a..d453d82c38c 100644 --- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java +++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java @@ -67,7 +67,7 @@ class AllClassesQuery extends QueryHandler { continue; } String name = clazz.getName(); - int pos = name.lastIndexOf("."); + int pos = name.lastIndexOf('.'); String pkg; if (name.startsWith("[")) { // Only in ancient heap dumps pkg = ""; diff --git a/jdk/src/share/classes/java/awt/geom/Path2D.java b/jdk/src/share/classes/java/awt/geom/Path2D.java index 9f7df213546..7a401d36cf4 100644 --- a/jdk/src/share/classes/java/awt/geom/Path2D.java +++ b/jdk/src/share/classes/java/awt/geom/Path2D.java @@ -1926,9 +1926,9 @@ public abstract class Path2D implements Shape, Cloneable { * maintains, but it may contain no more precision either. * If the tradeoff of precision vs. storage size in the result is * important then the convenience constructors in the - * {@link Path2D.Float#Path2D.Float(Shape, AffineTransform) Path2D.Float} + * {@link Path2D.Float#Float(Shape, AffineTransform) Path2D.Float} * and - * {@link Path2D.Double#Path2D.Double(Shape, AffineTransform) Path2D.Double} + * {@link Path2D.Double#Double(Shape, AffineTransform) Path2D.Double} * subclasses should be used to make the choice explicit. * * @param at the {@code AffineTransform} used to transform a diff --git a/jdk/src/share/classes/java/lang/Class.java b/jdk/src/share/classes/java/lang/Class.java index a8aee7ffe62..262a126fafc 100644 --- a/jdk/src/share/classes/java/lang/Class.java +++ b/jdk/src/share/classes/java/lang/Class.java @@ -1296,7 +1296,7 @@ public final class Class implements java.io.Serializable, String simpleName = getSimpleBinaryName(); if (simpleName == null) { // top level class simpleName = getName(); - return simpleName.substring(simpleName.lastIndexOf(".")+1); // strip the package name + return simpleName.substring(simpleName.lastIndexOf('.')+1); // strip the package name } // According to JLS3 "Binary Compatibility" (13.1) the binary // name of non-package classes (not top level) is the binary diff --git a/jdk/src/share/classes/java/lang/ClassLoader.java b/jdk/src/share/classes/java/lang/ClassLoader.java index 078c1502176..876b1855012 100644 --- a/jdk/src/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/share/classes/java/lang/ClassLoader.java @@ -2133,7 +2133,7 @@ public abstract class ClassLoader { return result.booleanValue(); // Check for most specific package entry - int dotIndex = className.lastIndexOf("."); + int dotIndex = className.lastIndexOf('.'); if (dotIndex < 0) { // default package result = packageAssertionStatus.get(null); if (result != null) @@ -2144,7 +2144,7 @@ public abstract class ClassLoader { result = packageAssertionStatus.get(className); if (result != null) return result.booleanValue(); - dotIndex = className.lastIndexOf(".", dotIndex-1); + dotIndex = className.lastIndexOf('.', dotIndex-1); } // Return the classloader default diff --git a/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index 7bcdfaf5e89..d881fe5d18d 100644 --- a/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/jdk/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -85,7 +85,7 @@ class InvokerBytecodeGenerator { private InvokerBytecodeGenerator(LambdaForm lambdaForm, int localsMapSize, String className, String invokerName, MethodType invokerType) { if (invokerName.contains(".")) { - int p = invokerName.indexOf("."); + int p = invokerName.indexOf('.'); className = invokerName.substring(0, p); invokerName = invokerName.substring(p+1); } diff --git a/jdk/src/share/classes/java/lang/invoke/LambdaForm.java b/jdk/src/share/classes/java/lang/invoke/LambdaForm.java index 36630459b88..0676b7b3ab0 100644 --- a/jdk/src/share/classes/java/lang/invoke/LambdaForm.java +++ b/jdk/src/share/classes/java/lang/invoke/LambdaForm.java @@ -607,7 +607,7 @@ class LambdaForm { assert(m.getName().equals("interpret" + sig.substring(sig.indexOf('_')))); LambdaForm form = new LambdaForm(sig); form.vmentry = m; - mt.form().setCachedLambdaForm(MethodTypeForm.LF_COUNTER, form); + form = mt.form().setCachedLambdaForm(MethodTypeForm.LF_COUNTER, form); // FIXME: get rid of PREPARED_FORMS; use MethodTypeForm cache only forms.put(sig, form); } diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java index 6abceb5ad19..abd8999aeaa 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -692,8 +692,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; lform = new LambdaForm("guardWithCatch", lambdaType.parameterCount(), names); - basicType.form().setCachedLambdaForm(MethodTypeForm.LF_GWC, lform); - return lform; + return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_GWC, lform); } static diff --git a/jdk/src/share/classes/java/lang/invoke/MethodTypeForm.java b/jdk/src/share/classes/java/lang/invoke/MethodTypeForm.java index ee5e6221b11..d34a2998cab 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodTypeForm.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodTypeForm.java @@ -91,8 +91,10 @@ final class MethodTypeForm { return lambdaForms[which]; } - public LambdaForm setCachedLambdaForm(int which, LambdaForm form) { - // Should we perform some sort of CAS, to avoid racy duplication? + synchronized public LambdaForm setCachedLambdaForm(int which, LambdaForm form) { + // Simulate a CAS, to avoid racy duplication of results. + LambdaForm prev = lambdaForms[which]; + if (prev != null) return prev; return lambdaForms[which] = form; } diff --git a/jdk/src/share/classes/java/net/CookieManager.java b/jdk/src/share/classes/java/net/CookieManager.java index f2d29cda82b..15d4cc33e08 100644 --- a/jdk/src/share/classes/java/net/CookieManager.java +++ b/jdk/src/share/classes/java/net/CookieManager.java @@ -294,7 +294,7 @@ public class CookieManager extends CookieHandler // the path is the directory of the page/doc String path = uri.getPath(); if (!path.endsWith("/")) { - int i = path.lastIndexOf("/"); + int i = path.lastIndexOf('/'); if (i > 0) { path = path.substring(0, i + 1); } else { @@ -364,7 +364,7 @@ public class CookieManager extends CookieHandler static private boolean isInPortList(String lst, int port) { - int i = lst.indexOf(","); + int i = lst.indexOf(','); int val = -1; while (i > 0) { try { @@ -375,7 +375,7 @@ public class CookieManager extends CookieHandler } catch (NumberFormatException numberFormatException) { } lst = lst.substring(i+1); - i = lst.indexOf(","); + i = lst.indexOf(','); } if (!lst.isEmpty()) { try { diff --git a/jdk/src/share/classes/java/net/InetAddress.java b/jdk/src/share/classes/java/net/InetAddress.java index 77c6a1f6c57..5bbdf0fd187 100644 --- a/jdk/src/share/classes/java/net/InetAddress.java +++ b/jdk/src/share/classes/java/net/InetAddress.java @@ -1138,7 +1138,7 @@ class InetAddress implements java.io.Serializable { // This is supposed to be an IPv6 literal // Check if a numeric or string zone id is present int pos; - if ((pos=host.indexOf ("%")) != -1) { + if ((pos=host.indexOf ('%')) != -1) { numericZone = checkNumericZone (host); if (numericZone == -1) { /* remainder of string must be an ifname */ ifname = host.substring (pos+1); diff --git a/jdk/src/share/classes/java/net/Socket.java b/jdk/src/share/classes/java/net/Socket.java index d4b7656ce5e..43fe4bfd940 100644 --- a/jdk/src/share/classes/java/net/Socket.java +++ b/jdk/src/share/classes/java/net/Socket.java @@ -1017,7 +1017,7 @@ class Socket implements java.io.Closeable { if (isClosed()) throw new SocketException("Socket is closed"); if (!on) { - getImpl().setOption(SocketOptions.SO_LINGER, new Boolean(on)); + getImpl().setOption(SocketOptions.SO_LINGER, on); } else { if (linger < 0) { throw new IllegalArgumentException("invalid value for SO_LINGER"); diff --git a/jdk/src/share/classes/java/net/SocketPermission.java b/jdk/src/share/classes/java/net/SocketPermission.java index 51777d90385..d44c8471613 100644 --- a/jdk/src/share/classes/java/net/SocketPermission.java +++ b/jdk/src/share/classes/java/net/SocketPermission.java @@ -777,7 +777,7 @@ public final class SocketPermission extends Permission // Literal IPv6 address host = getName().substring(1, getName().indexOf(']')); } else { - int i = getName().indexOf(":"); + int i = getName().indexOf(':'); if (i == -1) host = getName(); else { diff --git a/jdk/src/share/classes/java/net/SocksSocketImpl.java b/jdk/src/share/classes/java/net/SocksSocketImpl.java index b05a4d4c853..7c0f899b8e6 100644 --- a/jdk/src/share/classes/java/net/SocksSocketImpl.java +++ b/jdk/src/share/classes/java/net/SocksSocketImpl.java @@ -368,7 +368,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { String host = epoint.getHostString(); // IPv6 litteral? if (epoint.getAddress() instanceof Inet6Address && - (!host.startsWith("[")) && (host.indexOf(":") >= 0)) { + (!host.startsWith("[")) && (host.indexOf(':') >= 0)) { host = "[" + host + "]"; } try { @@ -688,7 +688,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts { String host = saddr.getHostString(); // IPv6 litteral? if (saddr.getAddress() instanceof Inet6Address && - (!host.startsWith("[")) && (host.indexOf(":") >= 0)) { + (!host.startsWith("[")) && (host.indexOf(':') >= 0)) { host = "[" + host + "]"; } try { diff --git a/jdk/src/share/classes/java/net/URI.java b/jdk/src/share/classes/java/net/URI.java index 0a05793b9a9..0035d00ead7 100644 --- a/jdk/src/share/classes/java/net/URI.java +++ b/jdk/src/share/classes/java/net/URI.java @@ -1851,9 +1851,9 @@ public final class URI sb.append("//"); if (authority.startsWith("[")) { // authority should (but may not) contain an embedded IPv6 address - int end = authority.indexOf("]"); + int end = authority.indexOf(']'); String doquote = authority, dontquote = ""; - if (end != -1 && authority.indexOf(":") != -1) { + if (end != -1 && authority.indexOf(':') != -1) { // the authority contains an IPv6 address if (end == authority.length()) { dontquote = authority; @@ -1889,8 +1889,8 @@ public final class URI * because we must not quote a literal IPv6 address */ if (opaquePart.startsWith("//[")) { - int end = opaquePart.indexOf("]"); - if (end != -1 && opaquePart.indexOf(":")!=-1) { + int end = opaquePart.indexOf(']'); + if (end != -1 && opaquePart.indexOf(':')!=-1) { String doquote, dontquote; if (end == opaquePart.length()) { dontquote = opaquePart; diff --git a/jdk/src/share/classes/java/security/BasicPermission.java b/jdk/src/share/classes/java/security/BasicPermission.java index 89cc2f92152..0abbfa7c047 100644 --- a/jdk/src/share/classes/java/security/BasicPermission.java +++ b/jdk/src/share/classes/java/security/BasicPermission.java @@ -430,7 +430,7 @@ final class BasicPermissionCollection offset = path.length()-1; - while ((last = path.lastIndexOf(".", offset)) != -1) { + while ((last = path.lastIndexOf('.', offset)) != -1) { path = path.substring(0, last+1) + "*"; //System.out.println("check "+path); diff --git a/jdk/src/share/classes/java/security/Provider.java b/jdk/src/share/classes/java/security/Provider.java index e8c7a081b5a..346aca9474c 100644 --- a/jdk/src/share/classes/java/security/Provider.java +++ b/jdk/src/share/classes/java/security/Provider.java @@ -931,7 +931,7 @@ public abstract class Provider extends Properties { } private String[] getTypeAndAlgorithm(String key) { - int i = key.indexOf("."); + int i = key.indexOf('.'); if (i < 1) { if (debug != null) { debug.println("Ignoring invalid entry in provider " diff --git a/jdk/src/share/classes/java/security/Security.java b/jdk/src/share/classes/java/security/Security.java index 0db09da7061..e24c0023f77 100644 --- a/jdk/src/share/classes/java/security/Security.java +++ b/jdk/src/share/classes/java/security/Security.java @@ -1114,7 +1114,7 @@ public final class Security { // implementation of an algorithm. We are only interested // in entries which lead to the implementation // classes. - if (currentKey.indexOf(" ") < 0) { + if (currentKey.indexOf(' ') < 0) { result.add(currentKey.substring( serviceName.length() + 1)); } diff --git a/jdk/src/share/classes/java/util/PropertyPermission.java b/jdk/src/share/classes/java/util/PropertyPermission.java index b772e1b12f8..d532bddabf6 100644 --- a/jdk/src/share/classes/java/util/PropertyPermission.java +++ b/jdk/src/share/classes/java/util/PropertyPermission.java @@ -546,7 +546,7 @@ final class PropertyPermissionCollection extends PermissionCollection offset = name.length()-1; - while ((last = name.lastIndexOf(".", offset)) != -1) { + while ((last = name.lastIndexOf('.', offset)) != -1) { name = name.substring(0, last+1) + "*"; //System.out.println("check "+name); diff --git a/jdk/src/share/classes/java/util/jar/JarVerifier.java b/jdk/src/share/classes/java/util/jar/JarVerifier.java index 0c24af26f28..c1468a1be1c 100644 --- a/jdk/src/share/classes/java/util/jar/JarVerifier.java +++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java @@ -276,7 +276,7 @@ class JarVerifier { // now we are parsing a signature block file - String key = uname.substring(0, uname.lastIndexOf(".")); + String key = uname.substring(0, uname.lastIndexOf('.')); if (signerCache == null) signerCache = new ArrayList<>(); diff --git a/jdk/src/share/classes/java/util/logging/LogManager.java b/jdk/src/share/classes/java/util/logging/LogManager.java index d2f7004bb27..ffd9d96300d 100644 --- a/jdk/src/share/classes/java/util/logging/LogManager.java +++ b/jdk/src/share/classes/java/util/logging/LogManager.java @@ -779,7 +779,7 @@ public class LogManager { int ix = 1; for (;;) { - int ix2 = name.indexOf(".", ix); + int ix2 = name.indexOf('.', ix); if (ix2 < 0) { break; } @@ -802,7 +802,7 @@ public class LogManager { } LogNode node = root; while (name.length() > 0) { - int ix = name.indexOf("."); + int ix = name.indexOf('.'); String head; if (ix > 0) { head = name.substring(0, ix); diff --git a/jdk/src/share/classes/java/util/logging/XMLFormatter.java b/jdk/src/share/classes/java/util/logging/XMLFormatter.java index 541c73fafff..075da9a3681 100644 --- a/jdk/src/share/classes/java/util/logging/XMLFormatter.java +++ b/jdk/src/share/classes/java/util/logging/XMLFormatter.java @@ -174,7 +174,7 @@ public class XMLFormatter extends Formatter { // Check to see if the parameter was not a messagetext format // or was not null or empty if (parameters != null && parameters.length != 0 - && record.getMessage().indexOf("{") == -1 ) { + && record.getMessage().indexOf('{') == -1 ) { for (Object parameter : parameters) { sb.append(" "); try { diff --git a/jdk/src/share/classes/javax/management/MBeanPermission.java b/jdk/src/share/classes/javax/management/MBeanPermission.java index 3c998e4ea01..4a3442511a3 100644 --- a/jdk/src/share/classes/javax/management/MBeanPermission.java +++ b/jdk/src/share/classes/javax/management/MBeanPermission.java @@ -290,7 +290,7 @@ public class MBeanPermission extends Permission { // Parse ObjectName - int openingBracket = name.indexOf("["); + int openingBracket = name.indexOf('['); if (openingBracket == -1) { // If "[on]" missing then ObjectName("*:*") // @@ -329,7 +329,7 @@ public class MBeanPermission extends Permission { // Parse member - int poundSign = name.indexOf("#"); + int poundSign = name.indexOf('#'); if (poundSign == -1) setMember("*"); diff --git a/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java b/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java index 0605713bf7a..f2534a62269 100644 --- a/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java +++ b/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java @@ -329,7 +329,7 @@ public class DescriptorSupport inFld = false; } else if (inFld && inDesc) { // want kw=value, eg, name="myname" value="myvalue" - int eq_separator = tok.indexOf("="); + int eq_separator = tok.indexOf('='); if (eq_separator > 0) { String kwPart = tok.substring(0,eq_separator); String valPart = tok.substring(eq_separator+1); @@ -458,7 +458,7 @@ public class DescriptorSupport if ((fields[i] == null) || (fields[i].equals(""))) { continue; } - int eq_separator = fields[i].indexOf("="); + int eq_separator = fields[i].indexOf('='); if (eq_separator < 0) { // illegal if no = or is first character if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { diff --git a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java index d19aa48fde6..7483ab13188 100644 --- a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java +++ b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java @@ -934,7 +934,7 @@ public class RequiredModelMBean String opMethodName; // Parse for class name and method - int opSplitter = opName.lastIndexOf("."); + int opSplitter = opName.lastIndexOf('.'); if (opSplitter > 0) { opClassName = opName.substring(0,opSplitter); opMethodName = opName.substring(opSplitter+1); @@ -943,7 +943,7 @@ public class RequiredModelMBean /* Ignore anything after a left paren. We keep this for compatibility but it isn't specified. */ - opSplitter = opMethodName.indexOf("("); + opSplitter = opMethodName.indexOf('('); if (opSplitter > 0) opMethodName = opMethodName.substring(0,opSplitter); diff --git a/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java b/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java index 37a2660cb03..9aa0e6352a2 100644 --- a/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java +++ b/jdk/src/share/classes/javax/security/auth/PrivateCredentialPermission.java @@ -495,7 +495,7 @@ public final class PrivateCredentialPermission extends Permission { // perform new initialization from the permission name - if (getName().indexOf(" ") == -1 && getName().indexOf("\"") == -1) { + if (getName().indexOf(' ') == -1 && getName().indexOf('"') == -1) { // name only has a credential class specified credentialClass = getName(); diff --git a/jdk/src/share/classes/javax/security/sasl/Sasl.java b/jdk/src/share/classes/javax/security/sasl/Sasl.java index 1ce36c74311..74f21c1b215 100644 --- a/jdk/src/share/classes/javax/security/sasl/Sasl.java +++ b/jdk/src/share/classes/javax/security/sasl/Sasl.java @@ -600,7 +600,7 @@ public class Sasl { // implementation of an algorithm. We are only interested // in entries which lead to the implementation // classes. - if (currentKey.indexOf(" ") < 0) { + if (currentKey.indexOf(' ') < 0) { String className = providers[i].getProperty(currentKey); if (!classes.contains(className)) { classes.add(className); diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java index 66e8e7e3f11..f5b24254ece 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/ClassWriter.java @@ -785,11 +785,29 @@ public class ClassWriter extends ClassVisitor { if (innerClasses == null) { innerClasses = new ByteVector(); } - ++innerClassesCount; - innerClasses.putShort(name == null ? 0 : newClass(name)); - innerClasses.putShort(outerName == null ? 0 : newClass(outerName)); - innerClasses.putShort(innerName == null ? 0 : newUTF8(innerName)); - innerClasses.putShort(access); + // Sec. 4.7.6 of the JVMS states "Every CONSTANT_Class_info entry in the + // constant_pool table which represents a class or interface C that is + // not a package member must have exactly one corresponding entry in the + // classes array". To avoid duplicates we keep track in the intVal field + // of the Item of each CONSTANT_Class_info entry C whether an inner + // class entry has already been added for C (this field is unused for + // class entries, and changing its value does not change the hashcode + // and equality tests). If so we store the index of this inner class + // entry (plus one) in intVal. This hack allows duplicate detection in + // O(1) time. + Item nameItem = newClassItem(name); + if (nameItem.intVal == 0) { + ++innerClassesCount; + innerClasses.putShort(nameItem.index); + innerClasses.putShort(outerName == null ? 0 : newClass(outerName)); + innerClasses.putShort(innerName == null ? 0 : newUTF8(innerName)); + innerClasses.putShort(access); + nameItem.intVal = innerClassesCount; + } else { + // Compare the inner classes entry nameItem.intVal - 1 with the + // arguments of this method and throw an exception if there is a + // difference? + } } @Override diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Frame.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Frame.java index e32a13af942..811b74c7242 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Frame.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Frame.java @@ -1455,16 +1455,20 @@ final class Frame { | cw.getMergedType(t & BASE_VALUE, u & BASE_VALUE); } else { // if u and t are array types, but not with the same element - // type, merge(u,t)=java/lang/Object - v = OBJECT | cw.addType("java/lang/Object"); + // type, merge(u,t) = dim(u) - 1 | java/lang/Object + int vdim = ELEMENT_OF + (u & DIM); + v = vdim | OBJECT | cw.addType("java/lang/Object"); } } else if ((t & BASE_KIND) == OBJECT || (t & DIM) != 0) { // if t is any other reference or array type, the merged type - // is Object, or min(dim(u), dim(t)) | java/lang/Object is u - // and t have different array dimensions - int tdim = t & DIM; - int udim = u & DIM; - v = (udim != tdim ? Math.min(tdim, udim) : 0) | OBJECT + // is min(udim, tdim) | java/lang/Object, where udim is the + // array dimension of u, minus 1 if u is an array type with a + // primitive element type (and similarly for tdim). + int tdim = (((t & DIM) == 0 || (t & BASE_KIND) == OBJECT) ? 0 + : ELEMENT_OF) + (t & DIM); + int udim = (((u & DIM) == 0 || (u & BASE_KIND) == OBJECT) ? 0 + : ELEMENT_OF) + (u & DIM); + v = Math.min(tdim, udim) | OBJECT | cw.addType("java/lang/Object"); } else { // if t is any other type, merge(u,t)=TOP diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Item.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Item.java index 90ff74377ff..25ed37718dd 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Item.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Item.java @@ -230,6 +230,7 @@ final class Item { * @param strVal3 * third part of the value of this item. */ + @SuppressWarnings("fallthrough") void set(final int type, final String strVal1, final String strVal2, final String strVal3) { this.type = type; @@ -237,9 +238,10 @@ final class Item { this.strVal2 = strVal2; this.strVal3 = strVal3; switch (type) { + case ClassWriter.CLASS: + this.intVal = 0; // intVal of a class must be zero, see visitInnerClass case ClassWriter.UTF8: case ClassWriter.STR: - case ClassWriter.CLASS: case ClassWriter.MTYPE: case ClassWriter.TYPE_NORMAL: hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()); diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Label.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Label.java index f4bc30df4bd..bbea0001235 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Label.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Label.java @@ -502,7 +502,7 @@ public class Label { void addToSubroutine(final long id, final int nbSubroutines) { if ((status & VISITED) == 0) { status |= VISITED; - srcAndRefPositions = new int[(nbSubroutines - 1) / 32 + 1]; + srcAndRefPositions = new int[nbSubroutines / 32 + 1]; } srcAndRefPositions[(int) (id >>> 32)] |= (int) id; } diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java index 81a82804d6e..e02fad465d9 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/MethodWriter.java @@ -1430,6 +1430,14 @@ class MethodWriter extends MethodVisitor { @Override public void visitMaxs(final int maxStack, final int maxLocals) { + if (resize) { + // replaces the temporary jump opcodes introduced by Label.resolve. + if (ClassReader.RESIZE) { + resizeInstructions(); + } else { + throw new RuntimeException("Method code too large!"); + } + } if (ClassReader.FRAMES && compute == FRAMES) { // completes the control flow graph with exception handler blocks Handler handler = firstHandler; @@ -1987,43 +1995,43 @@ class MethodWriter extends MethodVisitor { stackMap.putByte(v); } } else { - StringBuffer buf = new StringBuffer(); + StringBuilder sb = new StringBuilder(); d >>= 28; while (d-- > 0) { - buf.append('['); + sb.append('['); } if ((t & Frame.BASE_KIND) == Frame.OBJECT) { - buf.append('L'); - buf.append(cw.typeTable[t & Frame.BASE_VALUE].strVal1); - buf.append(';'); + sb.append('L'); + sb.append(cw.typeTable[t & Frame.BASE_VALUE].strVal1); + sb.append(';'); } else { switch (t & 0xF) { case 1: - buf.append('I'); + sb.append('I'); break; case 2: - buf.append('F'); + sb.append('F'); break; case 3: - buf.append('D'); + sb.append('D'); break; case 9: - buf.append('Z'); + sb.append('Z'); break; case 10: - buf.append('B'); + sb.append('B'); break; case 11: - buf.append('C'); + sb.append('C'); break; case 12: - buf.append('S'); + sb.append('S'); break; default: - buf.append('J'); + sb.append('J'); } } - stackMap.putByte(7).putShort(cw.newClass(buf.toString())); + stackMap.putByte(7).putShort(cw.newClass(sb.toString())); } } } @@ -2051,14 +2059,6 @@ class MethodWriter extends MethodVisitor { if (classReaderOffset != 0) { return 6 + classReaderLength; } - if (resize) { - // replaces the temporary jump opcodes introduced by Label.resolve. - if (ClassReader.RESIZE) { - resizeInstructions(); - } else { - throw new RuntimeException("Method code too large!"); - } - } int size = 8; if (code.length > 0) { if (code.length > 65536) { @@ -2715,49 +2715,50 @@ class MethodWriter extends MethodVisitor { } } - // recomputes the stack map frames - if (frameCount > 0) { - if (compute == FRAMES) { - frameCount = 0; - stackMap = null; - previousFrame = null; - frame = null; - Frame f = new Frame(); - f.owner = labels; - Type[] args = Type.getArgumentTypes(descriptor); - f.initInputFrame(cw, access, args, maxLocals); - visitFrame(f); - Label l = labels; - while (l != null) { - /* - * here we need the original label position. getNewOffset - * must therefore never have been called for this label. - */ - u = l.position - 3; - if ((l.status & Label.STORE) != 0 || (u >= 0 && resize[u])) { - getNewOffset(allIndexes, allSizes, l); - // TODO update offsets in UNINITIALIZED values - visitFrame(l.frame); - } - l = l.successor; - } - } else { + // updates the stack map frame labels + if (compute == FRAMES) { + Label l = labels; + while (l != null) { /* - * Resizing an existing stack map frame table is really hard. - * Not only the table must be parsed to update the offets, but - * new frames may be needed for jump instructions that were - * inserted by this method. And updating the offsets or - * inserting frames can change the format of the following - * frames, in case of packed frames. In practice the whole table - * must be recomputed. For this the frames are marked as - * potentially invalid. This will cause the whole class to be - * reread and rewritten with the COMPUTE_FRAMES option (see the - * ClassWriter.toByteArray method). This is not very efficient - * but is much easier and requires much less code than any other - * method I can think of. + * Detects the labels that are just after an IF instruction that + * has been resized with the IFNOT GOTO_W pattern. These labels + * are now the target of a jump instruction (the IFNOT + * instruction). Note that we need the original label position + * here. getNewOffset must therefore never have been called for + * this label. */ - cw.invalidFrames = true; + u = l.position - 3; + if (u >= 0 && resize[u]) { + l.status |= Label.TARGET; + } + getNewOffset(allIndexes, allSizes, l); + l = l.successor; } + // Update the offsets in the uninitialized types + for (i = 0; i < cw.typeTable.length; ++i) { + Item item = cw.typeTable[i]; + if (item != null && item.type == ClassWriter.TYPE_UNINIT) { + item.intVal = getNewOffset(allIndexes, allSizes, 0, + item.intVal); + } + } + // The stack map frames are not serialized yet, so we don't need + // to update them. They will be serialized in visitMaxs. + } else if (frameCount > 0) { + /* + * Resizing an existing stack map frame table is really hard. Not + * only the table must be parsed to update the offets, but new + * frames may be needed for jump instructions that were inserted by + * this method. And updating the offsets or inserting frames can + * change the format of the following frames, in case of packed + * frames. In practice the whole table must be recomputed. For this + * the frames are marked as potentially invalid. This will cause the + * whole class to be reread and rewritten with the COMPUTE_FRAMES + * option (see the ClassWriter.toByteArray method). This is not very + * efficient but is much easier and requires much less code than any + * other method I can think of. + */ + cw.invalidFrames = true; } // updates the exception handler block labels Handler h = firstHandler; diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Type.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Type.java index e385f9f6491..633a4a024ea 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Type.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/Type.java @@ -585,11 +585,11 @@ public class Type { case DOUBLE: return "double"; case ARRAY: - StringBuffer b = new StringBuffer(getElementType().getClassName()); + StringBuilder sb = new StringBuilder(getElementType().getClassName()); for (int i = getDimensions(); i > 0; --i) { - b.append("[]"); + sb.append("[]"); } - return b.toString(); + return sb.toString(); case OBJECT: return new String(buf, off, len).replace('/', '.'); default: diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java index 4ece2dba90d..2c54ea475fd 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java @@ -1089,7 +1089,7 @@ public class InstructionAdapter extends MethodVisitor { @Deprecated public void invokestatic(final String owner, final String name, final String desc) { - if (api < Opcodes.ASM5) { + if (api >= Opcodes.ASM5) { invokestatic(owner, name, desc, false); return; } diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/Method.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/Method.java index df97a36575f..92a83ff8ecc 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/Method.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/Method.java @@ -205,7 +205,7 @@ public class Method { } String returnType = method.substring(0, space); String methodName = method.substring(space + 1, start - 1).trim(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append('('); int p; do { @@ -229,7 +229,7 @@ public class Method { return type; } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int index = 0; while ((index = type.indexOf("[]", index) + 1) > 0) { sb.append('['); diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java index 2b4f7201d69..d5edd06363f 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java @@ -147,17 +147,17 @@ public abstract class Remapper { } Type[] args = Type.getArgumentTypes(desc); - StringBuffer s = new StringBuffer("("); + StringBuilder sb = new StringBuilder("("); for (int i = 0; i < args.length; i++) { - s.append(mapDesc(args[i].getDescriptor())); + sb.append(mapDesc(args[i].getDescriptor())); } Type returnType = Type.getReturnType(desc); if (returnType == Type.VOID_TYPE) { - s.append(")V"); - return s.toString(); + sb.append(")V"); + return sb.toString(); } - s.append(')').append(mapDesc(returnType.getDescriptor())); - return s.toString(); + sb.append(')').append(mapDesc(returnType.getDescriptor())); + return sb.toString(); } public Object mapValue(Object value) { diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java index de8915125ff..51fcb4c46f6 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/commons/SerialVersionUIDAdder.java @@ -239,7 +239,9 @@ public class SerialVersionUIDAdder extends ClassVisitor { if (computeSVUID) { this.name = name; this.access = access; - this.interfaces = Arrays.copyOf(interfaces, interfaces.length); + this.interfaces = new String[interfaces.length]; + System.arraycopy(interfaces, 0, this.interfaces, 0, + interfaces.length); } super.visit(version, access, name, signature, superName, interfaces); diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java index b6e2075de8b..bb01f7a7a3d 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/MethodNode.java @@ -351,7 +351,7 @@ public class MethodNode extends MethodVisitor { } @Override - @SuppressWarnings("serial") // Anonymous class + @SuppressWarnings("serial") public AnnotationVisitor visitAnnotationDefault() { return new AnnotationNode(new ArrayList(0) { @Override diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/AnalyzerException.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/AnalyzerException.java index 92b570b17f0..fc22dc3200a 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/AnalyzerException.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/AnalyzerException.java @@ -66,7 +66,7 @@ import jdk.internal.org.objectweb.asm.tree.AbstractInsnNode; * @author Bing Ran * @author Eric Bruneton */ -@SuppressWarnings("serial") // implementation class +@SuppressWarnings("serial") public class AnalyzerException extends Exception { public final AbstractInsnNode node; diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java index f6b8db3ddfb..cbb5f86f534 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/tree/analysis/Frame.java @@ -754,14 +754,14 @@ public class Frame { */ @Override public String toString() { - StringBuffer b = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < getLocals(); ++i) { - b.append(getLocal(i)); + sb.append(getLocal(i)); } - b.append(' '); + sb.append(' '); for (int i = 0; i < getStackSize(); ++i) { - b.append(getStack(i).toString()); + sb.append(getStack(i).toString()); } - return b.toString(); + return sb.toString(); } } diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java index a9487e16f5e..26e208a4cef 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/ASMifier.java @@ -206,7 +206,6 @@ public class ASMifier extends Printer { } text.add("import java.util.*;\n"); text.add("import jdk.internal.org.objectweb.asm.*;\n"); - text.add("import jdk.internal.org.objectweb.asm.attrs.*;\n"); text.add("public class " + simpleName + "Dump implements Opcodes {\n\n"); text.add("public static byte[] dump () throws Exception {\n\n"); text.add("ClassWriter cw = new ClassWriter(0);\n"); diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java index 5105db7f9c2..22dddf2d5e1 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/CheckClassAdapter.java @@ -298,26 +298,26 @@ public class CheckClassAdapter extends ClassVisitor { for (int j = 0; j < method.instructions.size(); ++j) { method.instructions.get(j).accept(mv); - StringBuffer s = new StringBuffer(); + StringBuilder sb = new StringBuilder(); Frame f = frames[j]; if (f == null) { - s.append('?'); + sb.append('?'); } else { for (int k = 0; k < f.getLocals(); ++k) { - s.append(getShortName(f.getLocal(k).toString())) + sb.append(getShortName(f.getLocal(k).toString())) .append(' '); } - s.append(" : "); + sb.append(" : "); for (int k = 0; k < f.getStackSize(); ++k) { - s.append(getShortName(f.getStack(k).toString())) + sb.append(getShortName(f.getStack(k).toString())) .append(' '); } } - while (s.length() < method.maxStack + method.maxLocals + 1) { - s.append(' '); + while (sb.length() < method.maxStack + method.maxLocals + 1) { + sb.append(' '); } pw.print(Integer.toString(j + 100000).substring(1)); - pw.print(" " + s + " : " + t.text.get(t.text.size() - 1)); + pw.print(" " + sb + " : " + t.text.get(t.text.size() - 1)); } for (int j = 0; j < method.tryCatchBlocks.size(); ++j) { method.tryCatchBlocks.get(j).accept(mv); diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java index 5c2c8bf4776..c210e2c4033 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/util/Textifier.java @@ -443,7 +443,7 @@ public class Textifier extends Printer { } buf.append(tab); - appendAccess(access); + appendAccess(access & ~Opcodes.ACC_VOLATILE); if ((access & Opcodes.ACC_NATIVE) != 0) { buf.append("native "); } diff --git a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/version.txt b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/version.txt index c6f8ad648af..b1d916092e5 100644 --- a/jdk/src/share/classes/jdk/internal/org/objectweb/asm/version.txt +++ b/jdk/src/share/classes/jdk/internal/org/objectweb/asm/version.txt @@ -1,12 +1,12 @@ Path: . -Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-03-12 +Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-05-27 URL: file:///svnroot/asm/trunk/asm Repository Root: file:///svnroot/asm Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9 -Revision: 1721 +Revision: 1748 Node Kind: directory Schedule: normal Last Changed Author: ebruneton -Last Changed Rev: 1721 -Last Changed Date: 2014-03-02 17:25:35 +0100 (Sun, 02 Mar 2014) +Last Changed Rev: 1747 +Last Changed Date: 2014-05-24 10:22:13 +0200 (Sat, 24 May 2014) diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java b/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java index 80789de60c5..c615df26eb5 100644 --- a/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java +++ b/jdk/src/share/classes/sun/jvmstat/monitor/AbstractMonitor.java @@ -84,7 +84,7 @@ public abstract class AbstractMonitor implements Monitor { * {@inheritDoc} */ public String getBaseName() { - int baseIndex = name.lastIndexOf(".")+1; + int baseIndex = name.lastIndexOf('.') + 1; return name.substring(baseIndex); } diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/HostIdentifier.java b/jdk/src/share/classes/sun/jvmstat/monitor/HostIdentifier.java index 4ac28a1034a..470de36e64a 100644 --- a/jdk/src/share/classes/sun/jvmstat/monitor/HostIdentifier.java +++ b/jdk/src/share/classes/sun/jvmstat/monitor/HostIdentifier.java @@ -138,8 +138,8 @@ public class HostIdentifier { String frag = u.getFragment(); URI u2 = null; - int c1index = uriString.indexOf(":"); - int c2index = uriString.lastIndexOf(":"); + int c1index = uriString.indexOf(':'); + int c2index = uriString.lastIndexOf(':'); if (c2index != c1index) { /* * this is the scheme:hostname:port case. Attempt to diff --git a/jdk/src/share/classes/sun/management/StackTraceElementCompositeData.java b/jdk/src/share/classes/sun/management/StackTraceElementCompositeData.java index 27eed847dac..cb863fe27ba 100644 --- a/jdk/src/share/classes/sun/management/StackTraceElementCompositeData.java +++ b/jdk/src/share/classes/sun/management/StackTraceElementCompositeData.java @@ -68,7 +68,7 @@ public class StackTraceElementCompositeData extends LazyCompositeData { ste.getMethodName(), ste.getFileName(), new Integer(ste.getLineNumber()), - new Boolean(ste.isNativeMethod()), + ste.isNativeMethod(), }; try { return new CompositeDataSupport(stackTraceElementCompositeType, diff --git a/jdk/src/share/classes/sun/management/ThreadInfoCompositeData.java b/jdk/src/share/classes/sun/management/ThreadInfoCompositeData.java index 2e12104dced..cef28271e7e 100644 --- a/jdk/src/share/classes/sun/management/ThreadInfoCompositeData.java +++ b/jdk/src/share/classes/sun/management/ThreadInfoCompositeData.java @@ -120,8 +120,8 @@ public class ThreadInfoCompositeData extends LazyCompositeData { new Long(threadInfo.getLockOwnerId()), threadInfo.getLockOwnerName(), stackTraceData, - new Boolean(threadInfo.isSuspended()), - new Boolean(threadInfo.isInNative()), + threadInfo.isSuspended(), + threadInfo.isInNative(), lockedMonitorsData, lockedSyncsData, }; diff --git a/jdk/src/share/classes/sun/management/VMOptionCompositeData.java b/jdk/src/share/classes/sun/management/VMOptionCompositeData.java index 51d8181451a..6eeac787000 100644 --- a/jdk/src/share/classes/sun/management/VMOptionCompositeData.java +++ b/jdk/src/share/classes/sun/management/VMOptionCompositeData.java @@ -59,7 +59,7 @@ public class VMOptionCompositeData extends LazyCompositeData { final Object[] vmOptionItemValues = { option.getName(), option.getValue(), - new Boolean(option.isWriteable()), + option.isWriteable(), option.getOrigin().toString(), }; diff --git a/jdk/src/share/classes/sun/management/snmp/jvminstr/NotificationTargetImpl.java b/jdk/src/share/classes/sun/management/snmp/jvminstr/NotificationTargetImpl.java index 9e080001ad0..d6574e3ebf9 100644 --- a/jdk/src/share/classes/sun/management/snmp/jvminstr/NotificationTargetImpl.java +++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/NotificationTargetImpl.java @@ -70,8 +70,8 @@ public class NotificationTargetImpl implements NotificationTarget { String addrStr; if (target.startsWith("[")) { - final int index = target.indexOf("]"); - final int index2 = target.lastIndexOf(":"); + final int index = target.indexOf(']'); + final int index2 = target.lastIndexOf(':'); if(index == -1) throw new IllegalArgumentException("Host starts with [ but " + "does not end with ]"); @@ -85,8 +85,8 @@ public class NotificationTargetImpl implements NotificationTarget { if (addrStr.startsWith("[")) throw new IllegalArgumentException("More than one [[...]]"); } else { - final int index = target.indexOf(":"); - final int index2 = target.lastIndexOf(":"); + final int index = target.indexOf(':'); + final int index2 = target.lastIndexOf(':'); if(index == -1) throw new IllegalArgumentException("Missing port separator \":\""); addrStr = target.substring(0, index); @@ -98,7 +98,7 @@ public class NotificationTargetImpl implements NotificationTarget { address = InetAddress.getByName(addrStr); //THE CHECK SHOULD BE STRONGER!!! - final int index = target.lastIndexOf(":"); + final int index = target.lastIndexOf(':'); community = target.substring(index + 1, target.length()); diff --git a/jdk/src/share/classes/sun/misc/ExtensionInfo.java b/jdk/src/share/classes/sun/misc/ExtensionInfo.java index 8b536379558..3fc17bf7339 100644 --- a/jdk/src/share/classes/sun/misc/ExtensionInfo.java +++ b/jdk/src/share/classes/sun/misc/ExtensionInfo.java @@ -273,8 +273,8 @@ public class ExtensionInfo { else { // Look for index of "." in the string - int sIdx = source.indexOf("."); - int tIdx = target.indexOf("."); + int sIdx = source.indexOf('.'); + int tIdx = target.indexOf('.'); if (sIdx == -1) sIdx = source.length() - 1; @@ -304,10 +304,10 @@ public class ExtensionInfo { String versionError = mf.format(args); // Look for "-" for pre-release - int prIndex = token.indexOf("-"); + int prIndex = token.indexOf('-'); // Look for "_" for patch release - int patchIndex = token.indexOf("_"); + int patchIndex = token.indexOf('_'); if (prIndex == -1 && patchIndex == -1) { diff --git a/jdk/src/share/classes/sun/misc/JarIndex.java b/jdk/src/share/classes/sun/misc/JarIndex.java index e43b9ee7f2e..d459751186b 100644 --- a/jdk/src/share/classes/sun/misc/JarIndex.java +++ b/jdk/src/share/classes/sun/misc/JarIndex.java @@ -172,7 +172,7 @@ public class JarIndex { if ((jarFiles = indexMap.get(fileName)) == null) { /* try the package name again */ int pos; - if((pos = fileName.lastIndexOf("/")) != -1) { + if((pos = fileName.lastIndexOf('/')) != -1) { jarFiles = indexMap.get(fileName.substring(0, pos)); } } @@ -195,7 +195,7 @@ public class JarIndex { public void add(String fileName, String jarName) { String packageName; int pos; - if((pos = fileName.lastIndexOf("/")) != -1) { + if((pos = fileName.lastIndexOf('/')) != -1) { packageName = fileName.substring(0, pos); } else { packageName = fileName; diff --git a/jdk/src/share/classes/sun/misc/URLClassPath.java b/jdk/src/share/classes/sun/misc/URLClassPath.java index 11dae819751..dca817148a5 100644 --- a/jdk/src/share/classes/sun/misc/URLClassPath.java +++ b/jdk/src/share/classes/sun/misc/URLClassPath.java @@ -793,7 +793,7 @@ public class URLClassPath { boolean validIndex(final String name) { String packageName = name; int pos; - if((pos = name.lastIndexOf("/")) != -1) { + if((pos = name.lastIndexOf('/')) != -1) { packageName = name.substring(0, pos); } @@ -803,7 +803,7 @@ public class URLClassPath { while (enum_.hasMoreElements()) { entry = enum_.nextElement(); entryName = entry.getName(); - if((pos = entryName.lastIndexOf("/")) != -1) + if((pos = entryName.lastIndexOf('/')) != -1) entryName = entryName.substring(0, pos); if (entryName.equals(packageName)) { return true; @@ -900,7 +900,7 @@ public class URLClassPath { */ JarIndex newIndex = newLoader.getIndex(); if(newIndex != null) { - int pos = jarName.lastIndexOf("/"); + int pos = jarName.lastIndexOf('/'); newIndex.merge(this.index, (pos == -1 ? null : jarName.substring(0, pos + 1))); } diff --git a/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java b/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java index 9c3fb964f0a..b490caa8f5e 100644 --- a/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java +++ b/jdk/src/share/classes/sun/net/ftp/impl/FtpClient.java @@ -258,7 +258,7 @@ public class FtpClient extends sun.net.ftp.FtpClient { d = null; } if (d != null && time != null) { - int c = time.indexOf(":"); + int c = time.indexOf(':'); now.setTime(d); now.set(Calendar.HOUR, Integer.parseInt(time.substring(0, c))); now.set(Calendar.MINUTE, Integer.parseInt(time.substring(c + 1))); @@ -294,7 +294,7 @@ public class FtpClient extends sun.net.ftp.FtpClient { public FtpDirEntry parseLine(String line) { String name = null; - int i = line.lastIndexOf(";"); + int i = line.lastIndexOf(';'); if (i > 0) { name = line.substring(i + 1).trim(); line = line.substring(0, i); @@ -305,7 +305,7 @@ public class FtpClient extends sun.net.ftp.FtpClient { FtpDirEntry file = new FtpDirEntry(name); while (!line.isEmpty()) { String s; - i = line.indexOf(";"); + i = line.indexOf(';'); if (i > 0) { s = line.substring(0, i); line = line.substring(i + 1); @@ -313,7 +313,7 @@ public class FtpClient extends sun.net.ftp.FtpClient { s = line; line = ""; } - i = s.indexOf("="); + i = s.indexOf('='); if (i > 0) { String fact = s.substring(0, i); String value = s.substring(i + 1); diff --git a/jdk/src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java b/jdk/src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java index aa28e556adf..2abeddc5d88 100644 --- a/jdk/src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java +++ b/jdk/src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java @@ -325,7 +325,7 @@ public final class DNSNameService implements NameService { while (i.hasNext()) { String parentDomain = i.next(); int start = 0; - while ((start = parentDomain.indexOf(".")) != -1 + while ((start = parentDomain.indexOf('.')) != -1 && start < parentDomain.length() -1) { try { results = resolve(ctx, host+"."+parentDomain, ids, 0); diff --git a/jdk/src/share/classes/sun/net/util/IPAddressUtil.java b/jdk/src/share/classes/sun/net/util/IPAddressUtil.java index 4dafa8a1d0b..a4cc9842a2b 100644 --- a/jdk/src/share/classes/sun/net/util/IPAddressUtil.java +++ b/jdk/src/share/classes/sun/net/util/IPAddressUtil.java @@ -132,7 +132,7 @@ public class IPAddressUtil { byte[] dst = new byte[INADDR16SZ]; int srcb_length = srcb.length; - int pc = src.indexOf ("%"); + int pc = src.indexOf ('%'); if (pc == srcb_length -1) { return null; } diff --git a/jdk/src/share/classes/sun/net/www/ParseUtil.java b/jdk/src/share/classes/sun/net/www/ParseUtil.java index d671c077291..cb8311996b1 100644 --- a/jdk/src/share/classes/sun/net/www/ParseUtil.java +++ b/jdk/src/share/classes/sun/net/www/ParseUtil.java @@ -356,8 +356,8 @@ public class ParseUtil { * because we must not quote a literal IPv6 address */ if (opaquePart.startsWith("//[")) { - int end = opaquePart.indexOf("]"); - if (end != -1 && opaquePart.indexOf(":")!=-1) { + int end = opaquePart.indexOf(']'); + if (end != -1 && opaquePart.indexOf(':')!=-1) { String doquote, dontquote; if (end == opaquePart.length()) { dontquote = opaquePart; @@ -408,8 +408,8 @@ public class ParseUtil { } else if (authority != null) { sb.append("//"); if (authority.startsWith("[")) { - int end = authority.indexOf("]"); - if (end != -1 && authority.indexOf(":")!=-1) { + int end = authority.indexOf(']'); + if (end != -1 && authority.indexOf(':')!=-1) { String doquote, dontquote; if (end == authority.length()) { dontquote = authority; diff --git a/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java b/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java index 482f6b5ca2a..aa41880319b 100644 --- a/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java +++ b/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java @@ -341,6 +341,6 @@ public final class ReflectUtil { * (not to be confused with a Java Language anonymous inner class). */ public static boolean isVMAnonymousClass(Class cls) { - return cls.getName().indexOf("/") > -1; + return cls.getName().indexOf('/') > -1; } } diff --git a/jdk/src/share/classes/sun/rmi/runtime/Log.java b/jdk/src/share/classes/sun/rmi/runtime/Log.java index 507622a3acd..9a152b69e2c 100644 --- a/jdk/src/share/classes/sun/rmi/runtime/Log.java +++ b/jdk/src/share/classes/sun/rmi/runtime/Log.java @@ -426,7 +426,7 @@ public abstract class Log { * Mimic old log messages that only contain unqualified names. */ private static String unqualifiedName(String name) { - int lastDot = name.lastIndexOf("."); + int lastDot = name.lastIndexOf('.'); if (lastDot >= 0) { name = name.substring(lastDot + 1); } diff --git a/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java b/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java index c561216b985..343810da8ae 100644 --- a/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java +++ b/jdk/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java @@ -141,7 +141,7 @@ public final class CGIHandler { { try { String command, param; - int delim = QueryString.indexOf("="); + int delim = QueryString.indexOf('='); if (delim == -1) { command = QueryString; param = ""; diff --git a/jdk/src/share/classes/sun/security/jgss/GSSManagerImpl.java b/jdk/src/share/classes/sun/security/jgss/GSSManagerImpl.java index 602f1807d05..736ef98fcd8 100644 --- a/jdk/src/share/classes/sun/security/jgss/GSSManagerImpl.java +++ b/jdk/src/share/classes/sun/security/jgss/GSSManagerImpl.java @@ -50,8 +50,8 @@ public class GSSManagerImpl extends GSSManager { if (osname.startsWith("SunOS") || osname.contains("OS X") || osname.startsWith("Linux")) { - return new Boolean(System.getProperty - (USE_NATIVE_PROP)); + return Boolean.valueOf(System.getProperty + (USE_NATIVE_PROP)); } return Boolean.FALSE; } diff --git a/jdk/src/share/classes/sun/security/jgss/wrapper/Krb5Util.java b/jdk/src/share/classes/sun/security/jgss/wrapper/Krb5Util.java index 730c6fa17fa..77d5a3598e8 100644 --- a/jdk/src/share/classes/sun/security/jgss/wrapper/Krb5Util.java +++ b/jdk/src/share/classes/sun/security/jgss/wrapper/Krb5Util.java @@ -39,7 +39,7 @@ class Krb5Util { static String getTGSName(GSSNameElement name) throws GSSException { String krbPrinc = name.getKrbName(); - int atIndex = krbPrinc.indexOf("@"); + int atIndex = krbPrinc.indexOf('@'); String realm = krbPrinc.substring(atIndex + 1); StringBuffer buf = new StringBuffer("krbtgt/"); buf.append(realm).append('@').append(realm); diff --git a/jdk/src/share/classes/sun/security/krb5/KdcComm.java b/jdk/src/share/classes/sun/security/krb5/KdcComm.java index caaf20a86f8..721c105d345 100644 --- a/jdk/src/share/classes/sun/security/krb5/KdcComm.java +++ b/jdk/src/share/classes/sun/security/krb5/KdcComm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, 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 @@ -144,7 +144,8 @@ public final class KdcComm { try { Config cfg = Config.getInstance(); String temp = cfg.get("libdefaults", "kdc_timeout"); - timeout = parsePositiveIntString(temp); + timeout = parseTimeString(temp); + temp = cfg.get("libdefaults", "max_retries"); max_retries = parsePositiveIntString(temp); temp = cfg.get("libdefaults", "udp_preference_limit"); @@ -425,6 +426,25 @@ public final class KdcComm { } } + /** + * Parses a time value string. If it ends with "s", parses as seconds. + * Otherwise, parses as milliseconds. + * @param s the time string + * @return the integer value in milliseconds, or -1 if input is null or + * has an invalid format + */ + private static int parseTimeString(String s) { + if (s == null) { + return -1; + } + if (s.endsWith("s")) { + int seconds = parsePositiveIntString(s.substring(0, s.length()-1)); + return (seconds < 0) ? -1 : (seconds*1000); + } else { + return parsePositiveIntString(s); + } + } + /** * Returns krb5.conf setting of {@code key} for a specific realm, * which can be: @@ -446,7 +466,11 @@ public final class KdcComm { try { String value = Config.getInstance().get("realms", realm, key); - temp = parsePositiveIntString(value); + if (key.equals("kdc_timeout")) { + temp = parseTimeString(value); + } else { + temp = parsePositiveIntString(value); + } } catch (Exception exc) { // Ignored, defValue will be picked up } diff --git a/jdk/src/share/classes/sun/security/provider/PolicyFile.java b/jdk/src/share/classes/sun/security/provider/PolicyFile.java index ec3b54c2dcb..70fae4361fa 100644 --- a/jdk/src/share/classes/sun/security/provider/PolicyFile.java +++ b/jdk/src/share/classes/sun/security/provider/PolicyFile.java @@ -1271,7 +1271,7 @@ public class PolicyFile extends java.security.Policy { Boolean imp = AccessController.doPrivileged (new PrivilegedAction() { public Boolean run() { - return new Boolean(entry.getCodeSource().implies(cs)); + return entry.getCodeSource().implies(cs); } }); if (!imp.booleanValue()) { @@ -1856,7 +1856,7 @@ public class PolicyFile extends java.security.Policy { int colonIndex; String prefix = value; String suffix; - if ((colonIndex = value.indexOf(":")) != -1) { + if ((colonIndex = value.indexOf(':')) != -1) { prefix = value.substring(0, colonIndex); } diff --git a/jdk/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java b/jdk/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java index 46e0678fb0c..7cdffffecf9 100644 --- a/jdk/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java +++ b/jdk/src/share/classes/sun/security/ssl/SunX509KeyManagerImpl.java @@ -338,7 +338,7 @@ final class SunX509KeyManagerImpl extends X509ExtendedKeyManager { } String sigType; if (keyType.contains("_")) { - int k = keyType.indexOf("_"); + int k = keyType.indexOf('_'); sigType = keyType.substring(k + 1); keyType = keyType.substring(0, k); } else { diff --git a/jdk/src/share/classes/sun/security/ssl/X509KeyManagerImpl.java b/jdk/src/share/classes/sun/security/ssl/X509KeyManagerImpl.java index b6a5034cad8..b817cde7fd7 100644 --- a/jdk/src/share/classes/sun/security/ssl/X509KeyManagerImpl.java +++ b/jdk/src/share/classes/sun/security/ssl/X509KeyManagerImpl.java @@ -302,7 +302,7 @@ final class X509KeyManagerImpl extends X509ExtendedKeyManager final String sigKeyAlgorithm; KeyType(String algorithm) { - int k = algorithm.indexOf("_"); + int k = algorithm.indexOf('_'); if (k == -1) { keyAlgorithm = algorithm; sigKeyAlgorithm = null; diff --git a/jdk/src/share/classes/sun/security/util/HostnameChecker.java b/jdk/src/share/classes/sun/security/util/HostnameChecker.java index 77f17f71a10..1a6f3c2a446 100644 --- a/jdk/src/share/classes/sun/security/util/HostnameChecker.java +++ b/jdk/src/share/classes/sun/security/util/HostnameChecker.java @@ -300,8 +300,8 @@ public class HostnameChecker { template = template.toLowerCase(Locale.ENGLISH); // Retreive leftmost component - int templateIdx = template.indexOf("."); - int nameIdx = name.indexOf("."); + int templateIdx = template.indexOf('.'); + int nameIdx = name.indexOf('.'); if (templateIdx == -1) templateIdx = template.length(); @@ -326,7 +326,7 @@ public class HostnameChecker { */ private static boolean matchWildCards(String name, String template) { - int wildcardIdx = template.indexOf("*"); + int wildcardIdx = template.indexOf('*'); if (wildcardIdx == -1) return name.equals(template); @@ -349,7 +349,7 @@ public class HostnameChecker { // update the match scope name = name.substring(beforeStartIdx + beforeWildcard.length()); - wildcardIdx = afterWildcard.indexOf("*"); + wildcardIdx = afterWildcard.indexOf('*'); } return name.endsWith(afterWildcard); } diff --git a/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java b/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java index 083e23a3700..5222e8a04c5 100644 --- a/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java @@ -98,7 +98,7 @@ public class SignatureFileVerifier { } finally { Providers.stopJarVerification(obj); } - this.name = name.substring(0, name.lastIndexOf(".")) + this.name = name.substring(0, name.lastIndexOf('.')) .toUpperCase(Locale.ENGLISH); this.md = md; this.signerCache = signerCache; diff --git a/jdk/src/share/classes/sun/security/x509/CRLExtensions.java b/jdk/src/share/classes/sun/security/x509/CRLExtensions.java index 628e1125add..834f78fa642 100644 --- a/jdk/src/share/classes/sun/security/x509/CRLExtensions.java +++ b/jdk/src/share/classes/sun/security/x509/CRLExtensions.java @@ -185,7 +185,7 @@ public class CRLExtensions { String name; String id = attr.getPrefix(); if (id.equalsIgnoreCase(X509CertImpl.NAME)) { // fully qualified - int index = alias.lastIndexOf("."); + int index = alias.lastIndexOf('.'); name = alias.substring(index + 1); } else name = alias; diff --git a/jdk/src/share/classes/sun/tools/jconsole/ConnectDialog.java b/jdk/src/share/classes/sun/tools/jconsole/ConnectDialog.java index 3198fd6cd6a..70125a07b2d 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/ConnectDialog.java +++ b/jdk/src/share/classes/sun/tools/jconsole/ConnectDialog.java @@ -325,7 +325,7 @@ public class ConnectDialog extends InternalDialog } else { String host = remoteTF.getText().trim(); String port = "0"; - int index = host.lastIndexOf(":"); + int index = host.lastIndexOf(':'); if (index >= 0) { port = host.substring(index + 1); host = host.substring(0, index); diff --git a/jdk/src/share/classes/sun/tools/jconsole/inspector/Utils.java b/jdk/src/share/classes/sun/tools/jconsole/inspector/Utils.java index ebdda0bbdbc..eb1f6b1be80 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/inspector/Utils.java +++ b/jdk/src/share/classes/sun/tools/jconsole/inspector/Utils.java @@ -210,7 +210,7 @@ public class Utils { public static String getArrayClassName(String name) { String className = null; if (name.startsWith("[")) { - int index = name.lastIndexOf("["); + int index = name.lastIndexOf('['); className = name.substring(index, name.length()); if (className.startsWith("[L")) { className = className.substring(2, className.length() - 1); @@ -241,7 +241,7 @@ public class Utils { if (className == null) { return name; } - int index = name.lastIndexOf("["); + int index = name.lastIndexOf('['); StringBuilder brackets = new StringBuilder(className); for (int i = 0; i <= index; i++) { brackets.append("[]"); diff --git a/jdk/src/share/classes/sun/tools/jconsole/inspector/XOperations.java b/jdk/src/share/classes/sun/tools/jconsole/inspector/XOperations.java index c29be4b9f0e..45538a28bc3 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/inspector/XOperations.java +++ b/jdk/src/share/classes/sun/tools/jconsole/inspector/XOperations.java @@ -113,7 +113,7 @@ public abstract class XOperations extends JPanel implements ActionListener { if (methodLabel.getText().length() > 20) { methodLabel.setText(methodLabel.getText(). substring(methodLabel.getText(). - lastIndexOf(".") + 1, + lastIndexOf('.') + 1, methodLabel.getText().length())); } diff --git a/jdk/src/share/classes/sun/tools/jconsole/inspector/XTree.java b/jdk/src/share/classes/sun/tools/jconsole/inspector/XTree.java index 26d968fa506..ed5658cc9ae 100644 --- a/jdk/src/share/classes/sun/tools/jconsole/inspector/XTree.java +++ b/jdk/src/share/classes/sun/tools/jconsole/inspector/XTree.java @@ -475,7 +475,7 @@ public class XTree extends JTree { private static Map extractKeyValuePairs( String props, ObjectName mbean) { Map map = new LinkedHashMap(); - int eq = props.indexOf("="); + int eq = props.indexOf('='); while (eq != -1) { String key = props.substring(0, eq); String value = mbean.getKeyProperty(key); @@ -484,7 +484,7 @@ public class XTree extends JTree { if (props.startsWith(",")) { props = props.substring(1); } - eq = props.indexOf("="); + eq = props.indexOf('='); } return map; } @@ -821,7 +821,7 @@ public class XTree extends JTree { } private void buildKeyValue() { - int index = tokenValue.indexOf("="); + int index = tokenValue.indexOf('='); if (index < 0) { key = tokenValue; value = tokenValue; diff --git a/jdk/src/share/lib/security/sunpkcs11-solaris.cfg b/jdk/src/share/lib/security/sunpkcs11-solaris.cfg index 74096efea5f..c120c5e3242 100644 --- a/jdk/src/share/lib/security/sunpkcs11-solaris.cfg +++ b/jdk/src/share/lib/security/sunpkcs11-solaris.cfg @@ -18,18 +18,5 @@ attributes = compatibility disabledMechanisms = { CKM_DSA_KEY_PAIR_GEN -# the following mechanisms are disabled due to performance issues -# (Solaris bug 6337157) - CKM_DSA_SHA1 - CKM_MD5_RSA_PKCS - CKM_SHA1_RSA_PKCS - CKM_SHA256_RSA_PKCS - CKM_SHA384_RSA_PKCS - CKM_SHA512_RSA_PKCS -# the following mechanisms are disabled to ensure backward compatibility -# (Solaris bug 6545046) - CKM_DES_CBC_PAD - CKM_DES3_CBC_PAD - CKM_AES_CBC_PAD } diff --git a/jdk/src/share/native/sun/security/smartcardio/pcsc.c b/jdk/src/share/native/sun/security/smartcardio/pcsc.c index ec2d21a3a1c..b837234761d 100644 --- a/jdk/src/share/native/sun/security/smartcardio/pcsc.c +++ b/jdk/src/share/native/sun/security/smartcardio/pcsc.c @@ -122,28 +122,35 @@ JNIEXPORT jlong JNICALL Java_sun_security_smartcardio_PCSC_SCardEstablishContext /** * Convert a multi string to a java string array, */ -jobjectArray pcsc_multi2jstring(JNIEnv *env, char *spec, DWORD size) { +jobjectArray pcsc_multi2jstring(JNIEnv *env, char *spec) { jobjectArray result; jclass stringClass; - char* tab[PCSCLITE_MAX_READERS_CONTEXTS]; + char *cp, **tab = NULL; jstring js; int cnt = 0; - DWORD i; - if (spec && size) { - spec[size - 1] = 0; - for (i = 0; i < size && spec[i]; ++i) { - tab[cnt++] = spec + i; - if (cnt == PCSCLITE_MAX_READERS_CONTEXTS) { - break; - } - for (++i; i < size && spec[i]; ++i) { - } - } + cp = spec; + while (*cp != 0) { + cp += (strlen(cp) + 1); + ++cnt; + } + + tab = (char **)malloc(cnt * sizeof(char *)); + if (tab == NULL) { + throwOutOfMemoryError(env, NULL); + return NULL; + } + + cnt = 0; + cp = spec; + while (*cp != 0) { + tab[cnt++] = cp; + cp += (strlen(cp) + 1); } stringClass = (*env)->FindClass(env, "java/lang/String"); if (stringClass == NULL) { + free(tab); return NULL; } @@ -152,15 +159,18 @@ jobjectArray pcsc_multi2jstring(JNIEnv *env, char *spec, DWORD size) { while (cnt-- > 0) { js = (*env)->NewStringUTF(env, tab[cnt]); if ((*env)->ExceptionCheck(env)) { + free(tab); return NULL; } (*env)->SetObjectArrayElement(env, result, cnt, js); if ((*env)->ExceptionCheck(env)) { + free(tab); return NULL; } (*env)->DeleteLocalRef(env, js); } } + free(tab); return result; } @@ -195,7 +205,7 @@ JNIEXPORT jobjectArray JNICALL Java_sun_security_smartcardio_PCSC_SCardListReade dprintf1("-String: %s\n", mszReaders); } - result = pcsc_multi2jstring(env, mszReaders, size); + result = pcsc_multi2jstring(env, mszReaders); free(mszReaders); return result; } diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index dd045badca7..64c5ba9036a 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -261,6 +261,10 @@ com/sun/jdi/JdbMethodExitTest.sh generic-all # 8041934 com/sun/jdi/RepStep.java generic-all +# 8044419 +com/sun/jdi/JdbReadTwiceTest.sh generic-all + + ############################################################################ # jdk_util diff --git a/jdk/test/java/lang/ProcessBuilder/Basic.java b/jdk/test/java/lang/ProcessBuilder/Basic.java index 039feb16404..d59688e9d7d 100644 --- a/jdk/test/java/lang/ProcessBuilder/Basic.java +++ b/jdk/test/java/lang/ProcessBuilder/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, 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 @@ -937,18 +937,13 @@ public class Basic { equal(pb.redirectError(), Redirect.to(efile)); THROWS(IllegalArgumentException.class, - new Fun(){void f() { - pb.redirectInput(Redirect.to(ofile)); }}, - new Fun(){void f() { - pb.redirectInput(Redirect.appendTo(ofile)); }}, - new Fun(){void f() { - pb.redirectOutput(Redirect.from(ifile)); }}, - new Fun(){void f() { - pb.redirectError(Redirect.from(ifile)); }}); + () -> pb.redirectInput(Redirect.to(ofile)), + () -> pb.redirectOutput(Redirect.from(ifile)), + () -> pb.redirectError(Redirect.from(ifile))); THROWS(IOException.class, // Input file does not exist - new Fun(){void f() throws Throwable { pb.start(); }}); + () -> pb.start()); setFileContents(ifile, "standard input"); //---------------------------------------------------------------- @@ -1084,18 +1079,15 @@ public class Basic { = new FilePermission("<>", "read,write,execute"); THROWS(SecurityException.class, - new Fun() { void f() throws IOException { - policy.setPermissions(xPermission); - redirectIO(pb, from(tmpFile), PIPE, PIPE); - pb.start();}}, - new Fun() { void f() throws IOException { - policy.setPermissions(rxPermission); - redirectIO(pb, PIPE, to(ofile), PIPE); - pb.start();}}, - new Fun() { void f() throws IOException { - policy.setPermissions(rxPermission); - redirectIO(pb, PIPE, PIPE, to(efile)); - pb.start();}}); + () -> { policy.setPermissions(xPermission); + redirectIO(pb, from(tmpFile), PIPE, PIPE); + pb.start();}, + () -> { policy.setPermissions(rxPermission); + redirectIO(pb, PIPE, to(ofile), PIPE); + pb.start();}, + () -> { policy.setPermissions(rxPermission); + redirectIO(pb, PIPE, PIPE, to(efile)); + pb.start();}); { policy.setPermissions(rxPermission); @@ -1258,10 +1250,10 @@ public class Basic { // System.getenv() is read-only. //---------------------------------------------------------------- THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ getenv().put("FOO","BAR");}}, - new Fun(){void f(){ getenv().remove("PATH");}}, - new Fun(){void f(){ getenv().keySet().remove("PATH");}}, - new Fun(){void f(){ getenv().values().remove("someValue");}}); + () -> getenv().put("FOO","BAR"), + () -> getenv().remove("PATH"), + () -> getenv().keySet().remove("PATH"), + () -> getenv().values().remove("someValue")); try { Collection> c = getenv().entrySet(); @@ -1286,19 +1278,17 @@ public class Basic { { final Map m = new ProcessBuilder().environment(); THROWS(IllegalArgumentException.class, - new Fun(){void f(){ m.put("FOO=","BAR");}}, - new Fun(){void f(){ m.put("FOO\u0000","BAR");}}, - new Fun(){void f(){ m.put("FOO","BAR\u0000");}}); + () -> m.put("FOO=","BAR"), + () -> m.put("FOO\u0000","BAR"), + () -> m.put("FOO","BAR\u0000")); } //---------------------------------------------------------------- // Commands must never be null. //---------------------------------------------------------------- THROWS(NullPointerException.class, - new Fun(){void f(){ - new ProcessBuilder((List)null);}}, - new Fun(){void f(){ - new ProcessBuilder().command((List)null);}}); + () -> new ProcessBuilder((List)null), + () -> new ProcessBuilder().command((List)null)); //---------------------------------------------------------------- // Put in a command; get the same one back out. @@ -1323,25 +1313,18 @@ public class Basic { // Commands must contain at least one element. //---------------------------------------------------------------- THROWS(IndexOutOfBoundsException.class, - new Fun() { void f() throws IOException { - new ProcessBuilder().start();}}, - new Fun() { void f() throws IOException { - new ProcessBuilder(new ArrayList()).start();}}, - new Fun() { void f() throws IOException { - Runtime.getRuntime().exec(new String[]{});}}); + () -> new ProcessBuilder().start(), + () -> new ProcessBuilder(new ArrayList()).start(), + () -> Runtime.getRuntime().exec(new String[]{})); //---------------------------------------------------------------- // Commands must not contain null elements at start() time. //---------------------------------------------------------------- THROWS(NullPointerException.class, - new Fun() { void f() throws IOException { - new ProcessBuilder("foo",null,"bar").start();}}, - new Fun() { void f() throws IOException { - new ProcessBuilder((String)null).start();}}, - new Fun() { void f() throws IOException { - new ProcessBuilder(new String[]{null}).start();}}, - new Fun() { void f() throws IOException { - new ProcessBuilder(new String[]{"foo",null,"bar"}).start();}}); + () -> new ProcessBuilder("foo",null,"bar").start(), + () -> new ProcessBuilder((String)null).start(), + () -> new ProcessBuilder(new String[]{null}).start(), + () -> new ProcessBuilder(new String[]{"foo",null,"bar"}).start()); //---------------------------------------------------------------- // Command lists are growable. @@ -1358,15 +1341,13 @@ public class Basic { try { final Map env = new ProcessBuilder().environment(); THROWS(NullPointerException.class, - new Fun(){void f(){ env.put("foo",null);}}, - new Fun(){void f(){ env.put(null,"foo");}}, - new Fun(){void f(){ env.remove(null);}}, - new Fun(){void f(){ - for (Map.Entry e : env.entrySet()) - e.setValue(null);}}, - new Fun() { void f() throws IOException { - Runtime.getRuntime().exec(new String[]{"foo"}, - new String[]{null});}}); + () -> env.put("foo",null), + () -> env.put(null,"foo"), + () -> env.remove(null), + () -> { for (Map.Entry e : env.entrySet()) + e.setValue(null);}, + () -> Runtime.getRuntime().exec(new String[]{"foo"}, + new String[]{null})); } catch (Throwable t) { unexpected(t); } //---------------------------------------------------------------- @@ -1375,10 +1356,10 @@ public class Basic { try { final Map env = new ProcessBuilder().environment(); THROWS(ClassCastException.class, - new Fun(){void f(){ env.remove(TRUE);}}, - new Fun(){void f(){ env.keySet().remove(TRUE);}}, - new Fun(){void f(){ env.values().remove(TRUE);}}, - new Fun(){void f(){ env.entrySet().remove(TRUE);}}); + () -> env.remove(TRUE), + () -> env.keySet().remove(TRUE), + () -> env.values().remove(TRUE), + () -> env.entrySet().remove(TRUE)); } catch (Throwable t) { unexpected(t); } //---------------------------------------------------------------- @@ -1394,22 +1375,22 @@ public class Basic { // Nulls in environment queries are forbidden. //---------------------------------------------------------------- THROWS(NullPointerException.class, - new Fun(){void f(){ getenv(null);}}, - new Fun(){void f(){ env.get(null);}}, - new Fun(){void f(){ env.containsKey(null);}}, - new Fun(){void f(){ env.containsValue(null);}}, - new Fun(){void f(){ env.keySet().contains(null);}}, - new Fun(){void f(){ env.values().contains(null);}}); + () -> getenv(null), + () -> env.get(null), + () -> env.containsKey(null), + () -> env.containsValue(null), + () -> env.keySet().contains(null), + () -> env.values().contains(null)); //---------------------------------------------------------------- // Non-String types in environment queries are forbidden. //---------------------------------------------------------------- THROWS(ClassCastException.class, - new Fun(){void f(){ env.get(TRUE);}}, - new Fun(){void f(){ env.containsKey(TRUE);}}, - new Fun(){void f(){ env.containsValue(TRUE);}}, - new Fun(){void f(){ env.keySet().contains(TRUE);}}, - new Fun(){void f(){ env.values().contains(TRUE);}}); + () -> env.get(TRUE), + () -> env.containsKey(TRUE), + () -> env.containsValue(TRUE), + () -> env.keySet().contains(TRUE), + () -> env.values().contains(TRUE)); //---------------------------------------------------------------- // Illegal String values in environment queries are (grumble) OK @@ -1427,12 +1408,11 @@ public class Basic { final Set> entrySet = new ProcessBuilder().environment().entrySet(); THROWS(NullPointerException.class, - new Fun(){void f(){ entrySet.contains(null);}}); + () -> entrySet.contains(null)); THROWS(ClassCastException.class, - new Fun(){void f(){ entrySet.contains(TRUE);}}, - new Fun(){void f(){ - entrySet.contains( - new SimpleImmutableEntry(TRUE,""));}}); + () -> entrySet.contains(TRUE), + () -> entrySet.contains( + new SimpleImmutableEntry(TRUE,""))); check(! entrySet.contains (new SimpleImmutableEntry("", ""))); @@ -1902,8 +1882,7 @@ public class Basic { final ProcessBuilder pb = new ProcessBuilder(new String[]{"unliKely"}); pb.environment().put("PATH", "suBdiR"); - THROWS(IOException.class, - new Fun() {void f() throws Throwable {pb.start();}}); + THROWS(IOException.class, () -> pb.start()); } catch (Throwable t) { unexpected(t); } finally { new File("suBdiR/unliKely").delete(); @@ -1976,10 +1955,8 @@ public class Basic { equal(SIZE, p.getInputStream().available()); equal(SIZE, p.getErrorStream().available()); THROWS(IOException.class, - new Fun(){void f() throws IOException { - p.getOutputStream().write((byte) '!'); - p.getOutputStream().flush(); - }}); + () -> { p.getOutputStream().write((byte) '!'); + p.getOutputStream().flush();}); final byte[] bytes = new byte[SIZE + 1]; equal(SIZE, p.getInputStream().read(bytes)); @@ -2006,12 +1983,9 @@ public class Basic { InputStream[] streams = { p.getInputStream(), p.getErrorStream() }; for (final InputStream in : streams) { Fun[] ops = { - new Fun(){void f() throws IOException { - in.read(); }}, - new Fun(){void f() throws IOException { - in.read(bytes); }}, - new Fun(){void f() throws IOException { - in.available(); }} + () -> in.read(), + () -> in.read(bytes), + () -> in.available() }; for (Fun op : ops) { try { @@ -2215,21 +2189,17 @@ public class Basic { } catch (Throwable t) { unexpected(t); } THROWS(SecurityException.class, - new Fun() { void f() throws IOException { - policy.setPermissions(/* Nothing */); - System.getenv("foo");}}, - new Fun() { void f() throws IOException { - policy.setPermissions(/* Nothing */); - System.getenv();}}, - new Fun() { void f() throws IOException { - policy.setPermissions(/* Nothing */); - new ProcessBuilder("echo").start();}}, - new Fun() { void f() throws IOException { - policy.setPermissions(/* Nothing */); - Runtime.getRuntime().exec("echo");}}, - new Fun() { void f() throws IOException { - policy.setPermissions(new RuntimePermission("getenv.bar")); - System.getenv("foo");}}); + () -> { policy.setPermissions(/* Nothing */); + System.getenv("foo");}, + () -> { policy.setPermissions(/* Nothing */); + System.getenv();}, + () -> { policy.setPermissions(/* Nothing */); + new ProcessBuilder("echo").start();}, + () -> { policy.setPermissions(/* Nothing */); + Runtime.getRuntime().exec("echo");}, + () -> { policy.setPermissions( + new RuntimePermission("getenv.bar")); + System.getenv("foo");}); try { policy.setPermissions(new RuntimePermission("getenv.foo")); @@ -2246,18 +2216,16 @@ public class Basic { = new FilePermission("<>", "execute"); THROWS(SecurityException.class, - new Fun() { void f() throws IOException { - // environment permission by itself insufficient - policy.setPermissions(new RuntimePermission("getenv.*")); - ProcessBuilder pb = new ProcessBuilder("env"); - pb.environment().put("foo","bar"); - pb.start();}}, - new Fun() { void f() throws IOException { - // exec permission by itself insufficient - policy.setPermissions(execPermission); - ProcessBuilder pb = new ProcessBuilder("env"); - pb.environment().put("foo","bar"); - pb.start();}}); + () -> { // environment permission by itself insufficient + policy.setPermissions(new RuntimePermission("getenv.*")); + ProcessBuilder pb = new ProcessBuilder("env"); + pb.environment().put("foo","bar"); + pb.start();}, + () -> { // exec permission by itself insufficient + policy.setPermissions(execPermission); + ProcessBuilder pb = new ProcessBuilder("env"); + pb.environment().put("foo","bar"); + pb.start();}); try { // Both permissions? OK. @@ -2585,7 +2553,7 @@ public class Basic { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/nio/charset/StandardCharsets/Standard.java b/jdk/test/java/nio/charset/StandardCharsets/Standard.java index 66d1b112a1b..c570a955857 100644 --- a/jdk/test/java/nio/charset/StandardCharsets/Standard.java +++ b/jdk/test/java/nio/charset/StandardCharsets/Standard.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, 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 @@ -99,13 +99,6 @@ public class Standard { System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new Exception("Some tests failed"); } - private static abstract class Fun {abstract void f() throws Throwable;} - private static void THROWS(Class k, Fun... fs) { - for (Fun f : fs) - try { f.f(); fail("Expected " + k.getName() + " not thrown"); } - catch (Throwable t) { - if (k.isAssignableFrom(t.getClass())) pass(); - else unexpected(t);}} static byte[] serializedForm(Object obj) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/jdk/test/java/util/Collection/BiggernYours.java b/jdk/test/java/util/Collection/BiggernYours.java index 24ce930e713..37bbe072c7a 100644 --- a/jdk/test/java/util/Collection/BiggernYours.java +++ b/jdk/test/java/util/Collection/BiggernYours.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, 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 @@ -236,13 +236,6 @@ public class BiggernYours { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} - static void THROWS(Class k, Fun... fs) { - for (Fun f : fs) - try { f.f(); fail("Expected " + k.getName() + " not thrown"); } - catch (Throwable t) { - if (k.isAssignableFrom(t.getClass())) pass(); - else unexpected(t);}} private static abstract class CheckedThread extends Thread { abstract void realRun() throws Throwable; public void run() { diff --git a/jdk/test/java/util/Collection/IteratorAtEnd.java b/jdk/test/java/util/Collection/IteratorAtEnd.java index fffc7f70fa1..be3a7e116cc 100644 --- a/jdk/test/java/util/Collection/IteratorAtEnd.java +++ b/jdk/test/java/util/Collection/IteratorAtEnd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, 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 @@ -84,9 +84,9 @@ public class IteratorAtEnd { try { final Iterator it = c.iterator(); THROWS(NoSuchElementException.class, - new Fun() {void f() { while (true) it.next(); }}); + () -> { while (true) it.next(); }); try { it.remove(); } - catch (UnsupportedOperationException _) { return; } + catch (UnsupportedOperationException exc) { return; } pass(); } catch (Throwable t) { unexpected(t); } @@ -96,10 +96,9 @@ public class IteratorAtEnd { final ListIterator it = list.listIterator(0); it.next(); final Object x = it.previous(); - THROWS(NoSuchElementException.class, - new Fun() {void f() { it.previous(); }}); + THROWS(NoSuchElementException.class, () -> it.previous()); try { it.remove(); } - catch (UnsupportedOperationException _) { return; } + catch (UnsupportedOperationException exc) { return; } pass(); check(! list.get(0).equals(x)); } catch (Throwable t) { unexpected(t); } @@ -108,10 +107,9 @@ public class IteratorAtEnd { final ListIterator it = list.listIterator(list.size()); it.previous(); final Object x = it.next(); - THROWS(NoSuchElementException.class, - new Fun() {void f() { it.next(); }}); + THROWS(NoSuchElementException.class, () -> it.next()); try { it.remove(); } - catch (UnsupportedOperationException _) { return; } + catch (UnsupportedOperationException exc) { return; } pass(); check(! list.get(list.size()-1).equals(x)); } catch (Throwable t) { unexpected(t); } @@ -132,7 +130,7 @@ public class IteratorAtEnd { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/util/Collection/MOAT.java b/jdk/test/java/util/Collection/MOAT.java index f50682fea24..f55a1e87745 100644 --- a/jdk/test/java/util/Collection/MOAT.java +++ b/jdk/test/java/util/Collection/MOAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, 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 @@ -117,10 +117,8 @@ public class MOAT { final List emptyArray = Arrays.asList(new Integer[]{}); testCollection(emptyArray); testEmptyList(emptyArray); - THROWS(IndexOutOfBoundsException.class, - new Fun(){void f(){ emptyArray.set(0,1); }}); - THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ emptyArray.add(0,1); }}); + THROWS(IndexOutOfBoundsException.class, () -> emptyArray.set(0,1)); + THROWS(UnsupportedOperationException.class, () -> emptyArray.add(0,1)); List noOne = nCopies(0,1); testCollection(noOne); @@ -204,8 +202,7 @@ public class MOAT { if (rnd.nextBoolean()) check(! it.hasNext()); - THROWS(NoSuchElementException.class, - new Fun(){void f(){ it.next(); }}); + THROWS(NoSuchElementException.class, () -> it.next()); try { it.remove(); } catch (IllegalStateException ignored) { pass(); } @@ -232,16 +229,15 @@ public class MOAT { private static void testImmutableCollection(final Collection c) { THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ c.add(99); }}, - new Fun(){void f(){ c.addAll(singleton(99)); }}); + () -> c.add(99), + () -> c.addAll(singleton(99))); if (! c.isEmpty()) { final Integer first = c.iterator().next(); THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ c.clear(); }}, - new Fun(){void f(){ c.remove(first); }}, - new Fun(){void f(){ c.removeAll(singleton(first)); }}, - new Fun(){void f(){ c.retainAll(emptyList()); }} - ); + () -> c.clear(), + () -> c.remove(first), + () -> c.removeAll(singleton(first)), + () -> c.retainAll(emptyList())); } } @@ -253,17 +249,17 @@ public class MOAT { testList(c); testImmutableCollection(c); THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ c.set(0,42); }}, - new Fun(){void f(){ c.add(0,42); }}, - new Fun(){void f(){ c.addAll(0,singleton(86)); }}); + () -> c.set(0,42), + () -> c.add(0,42), + () -> c.addAll(0,singleton(86))); if (! c.isEmpty()) THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ - Iterator it = c.iterator(); - it.next(); it.remove();}}, - new Fun(){void f(){ - ListIterator it = c.listIterator(); - it.next(); it.remove();}}); + () -> { Iterator it = c.iterator(); + it.next(); + it.remove(); }, + () -> { ListIterator it = c.listIterator(); + it.next(); + it.remove(); }); } private static void clear(Collection c) { @@ -290,19 +286,19 @@ public class MOAT { private static void testImmutableMap(final Map m) { THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ m.put(1,1); }}, - new Fun(){void f(){ m.putAll(singletonMap(1,1)); }}); + () -> m.put(1,1), + () -> m.putAll(singletonMap(1,1))); if (! m.isEmpty()) { final Integer first = m.keySet().iterator().next(); THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ m.remove(first); }}, - new Fun(){void f(){ m.clear(); }}); + () -> m.remove(first), + () -> m.clear()); final Map.Entry me = m.entrySet().iterator().next(); Integer key = me.getKey(); Integer val = me.getValue(); THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ me.setValue(3); }}); + () -> me.setValue(3)); equal(key, me.getKey()); equal(val, me.getValue()); } @@ -492,9 +488,9 @@ public class MOAT { // insert, query, remove element at head if (isEmpty) { THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.getFirst(); }}, - new Fun(){void f(){ deq.element(); }}, - new Fun(){void f(){ deq.iterator().next(); }}); + () -> deq.getFirst(), + () -> deq.element(), + () -> deq.iterator().next()); check(deq.peekFirst() == null); check(deq.peek() == null); } else { @@ -546,9 +542,9 @@ public class MOAT { } if (isEmpty) { THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.getFirst(); }}, - new Fun(){void f(){ deq.element(); }}, - new Fun(){void f(){ deq.iterator().next(); }}); + () -> deq.getFirst(), + () -> deq.element(), + () -> deq.iterator().next()); check(deq.peekFirst() == null); check(deq.peek() == null); } else { @@ -571,8 +567,7 @@ public class MOAT { // insert, query, remove element at tail if (isEmpty) { check(deq.peekLast() == null); - THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.getLast(); }}); + THROWS(NoSuchElementException.class, () -> deq.getLast()); } else { check(deq.peekLast() != e); check(deq.getLast() != e); @@ -615,8 +610,7 @@ public class MOAT { } if (isEmpty) { check(deq.peekLast() == null); - THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.getLast(); }}); + THROWS(NoSuchElementException.class, () -> deq.getLast()); } else { check(deq.peekLast() != e); check(deq.getLast() != e); @@ -649,17 +643,17 @@ public class MOAT { if (isList) { check(!asList.listIterator().hasPrevious()); THROWS(NoSuchElementException.class, - new Fun(){void f(){ asList.listIterator().previous(); }}); + () -> asList.listIterator().previous()); } THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.iterator().next(); }}, - new Fun(){void f(){ deq.element(); }}, - new Fun(){void f(){ deq.getFirst(); }}, - new Fun(){void f(){ deq.getLast(); }}, - new Fun(){void f(){ deq.pop(); }}, - new Fun(){void f(){ deq.remove(); }}, - new Fun(){void f(){ deq.removeFirst(); }}, - new Fun(){void f(){ deq.removeLast(); }}); + () -> deq.iterator().next(), + () -> deq.element(), + () -> deq.getFirst(), + () -> deq.getLast(), + () -> deq.pop(), + () -> deq.remove(), + () -> deq.removeFirst(), + () -> deq.removeLast()); check(deq.poll() == null); check(deq.pollFirst() == null); @@ -728,8 +722,8 @@ public class MOAT { l.listIterator(0); l.listIterator(l.size()); THROWS(IndexOutOfBoundsException.class, - new Fun(){void f(){l.listIterator(-1);}}, - new Fun(){void f(){l.listIterator(l.size() + 1);}}); + () -> l.listIterator(-1), + () -> l.listIterator(l.size() + 1)); if (l instanceof AbstractList) { try { @@ -1004,22 +998,22 @@ public class MOAT { ? (ConcurrentMap) m : null; List fs = new ArrayList(); - fs.add(new Fun(){void f(){ check(! m.containsKey(null));}}); - fs.add(new Fun(){void f(){ equal(m.remove(null), null);}}); - fs.add(new Fun(){void f(){ equal(m.get(null), null);}}); - if (cm != null) { - fs.add(new Fun(){void f(){ check(! cm.remove(null,null));}});} + fs.add(() -> check(! m.containsKey(null))); + fs.add(() -> equal(m.remove(null), null)); + fs.add(() -> equal(m.get(null), null)); + if (cm != null) + fs.add(() -> check(! cm.remove(null,null))); throwsConsistently(NullPointerException.class, fs); fs.clear(); final Map sm = singletonMap(null,1); - fs.add(new Fun(){void f(){ equal(m.put(null,1), null); m.clear();}}); - fs.add(new Fun(){void f(){ m.putAll(sm); m.clear();}}); + fs.add(() -> { equal(m.put(null,1), null); m.clear();}); + fs.add(() -> { m.putAll(sm); m.clear();}); if (cm != null) { - fs.add(new Fun(){void f(){ check(! cm.remove(null,null));}}); - fs.add(new Fun(){void f(){ equal(cm.putIfAbsent(null,1), 1);}}); - fs.add(new Fun(){void f(){ equal(cm.replace(null,1), null);}}); - fs.add(new Fun(){void f(){ equal(cm.replace(null,1, 1), 1);}}); + fs.add(() -> check(! cm.remove(null,null))); + fs.add(() -> equal(cm.putIfAbsent(null,1), 1)); + fs.add(() -> equal(cm.replace(null,1), null)); + fs.add(() -> equal(cm.replace(null,1, 1), 1)); } throwsConsistently(NullPointerException.class, fs); } @@ -1180,8 +1174,7 @@ public class MOAT { equalNext(it, 3); equalNext(it, 1); check(! it.hasNext()); - THROWS(NoSuchElementException.class, - new Fun(){void f(){it.next();}}); + THROWS(NoSuchElementException.class, () -> it.next()); } { @@ -1191,8 +1184,7 @@ public class MOAT { check(it.hasNext()); equal(it.next().getKey(), 3); check(it.hasNext()); equal(it.next().getKey(), 1); check(! it.hasNext()); - THROWS(NoSuchElementException.class, - new Fun(){void f(){it.next();}}); + THROWS(NoSuchElementException.class, () -> it.next()); } prepMapForDescItrTests(m); @@ -1262,8 +1254,7 @@ public class MOAT { equalNext(it, 3); equalNext(it, 1); check(! it.hasNext()); - THROWS(NoSuchElementException.class, - new Fun(){void f(){it.next();}}); + THROWS(NoSuchElementException.class, () -> it.next()); } prepSetForDescItrTests(s); @@ -1365,7 +1356,7 @@ public class MOAT { System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new Exception("Some tests failed"); } - private static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} private static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/util/Collections/AsLifoQueue.java b/jdk/test/java/util/Collections/AsLifoQueue.java index ddb98a74517..59c08e85c75 100644 --- a/jdk/test/java/util/Collections/AsLifoQueue.java +++ b/jdk/test/java/util/Collections/AsLifoQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, 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 @@ -56,8 +56,7 @@ public class AsLifoQueue { equal(q.size(), 3); check(! q.offer("d")); equal(q.size(), 3); - THROWS(IllegalStateException.class, - new Fun(){void f(){ q.add("d"); }}); + THROWS(IllegalStateException.class, () -> q.add("d")); equal(q.size(), 3); equal(q.toString(), "[c, b, a]"); equal(q.peek(), "c"); @@ -66,8 +65,7 @@ public class AsLifoQueue { equal(q.poll(), "b"); equal(q.peek(), "a"); equal(q.remove(), "a"); - THROWS(NoSuchElementException.class, - new Fun(){void f(){ q.remove(); }}); + THROWS(NoSuchElementException.class, () -> q.remove()); equal(q.poll(), null); check(q.isEmpty()); equal(q.size(), 0); @@ -88,7 +86,7 @@ public class AsLifoQueue { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - static abstract class Fun { abstract void f() throws Throwable; } + interface Fun {void f() throws Throwable;} private static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/util/NavigableMap/LockStep.java b/jdk/test/java/util/NavigableMap/LockStep.java index adb8b1978c9..62ffc72877d 100644 --- a/jdk/test/java/util/NavigableMap/LockStep.java +++ b/jdk/test/java/util/NavigableMap/LockStep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, 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 @@ -236,8 +236,8 @@ public class LockStep { Comparator cmp = comparator(s); if (s.isEmpty()) { THROWS(NoSuchElementException.class, - new Fun(){void f(){ s.first(); }}, - new Fun(){void f(){ s.last(); }}); + () -> s.first(), + () -> s.last()); equal(null, s.lower(1)); equal(null, s.floor(1)); equal(null, s.ceiling(1)); @@ -265,8 +265,7 @@ public class LockStep { }; for (final Iterator it : its) if (maybe(4)) - THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + THROWS(IllegalStateException.class, () -> it.remove()); Object prev = null; for (Object e : s) { check(s.contains(e)); @@ -284,7 +283,7 @@ public class LockStep { for (final Iterator it : its) { if (maybe(2)) check(! it.hasNext()); - Fun fun = new Fun(){void f(){ it.next(); }}; + Fun fun = () -> it.next(); THROWS(NoSuchElementException.class, fun, fun, fun); } } @@ -380,8 +379,8 @@ public class LockStep { Comparator cmp = comparator(m); if (m.isEmpty()) { THROWS(NoSuchElementException.class, - new Fun(){void f(){ m.firstKey(); }}, - new Fun(){void f(){ m.lastKey(); }}); + () -> m.firstKey(), + () -> m.lastKey()); equal(null, m.firstEntry()); equal(null, m.lastEntry()); equal(null, m.pollFirstEntry()); @@ -430,8 +429,7 @@ public class LockStep { Iterator[] its = concat(kits, vits, eits); for (final Iterator it : its) if (maybe(4)) - THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + THROWS(IllegalStateException.class, () -> it.remove()); Map.Entry prev = null; for (Map.Entry e : (Set) m.entrySet()) { Object k = e.getKey(); @@ -459,7 +457,7 @@ public class LockStep { for (final Iterator it : its) { if (maybe(2)) check(! it.hasNext()); - Fun fun = new Fun(){void f(){ it.next(); }}; + Fun fun = () -> it.next(); THROWS(NoSuchElementException.class, fun, fun, fun); } } @@ -633,7 +631,7 @@ public class LockStep { } static Fun remover(final Iterator it) { - return new Fun(){void f(){ it.remove(); }}; + return () -> it.remove(); } static MapFrobber randomRemover(NavigableMap m) { @@ -663,7 +661,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedKey(m, k);}}, new MapFrobber() {void frob(NavigableMap m) { @@ -673,7 +671,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedKey(m, k);}}, new MapFrobber() {void frob(NavigableMap m) { @@ -718,7 +716,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedElt(s, e);}}, new SetFrobber() {void frob(NavigableSet s) { @@ -728,7 +726,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedElt(s, e);}}, new SetFrobber() {void frob(NavigableSet s) { @@ -738,7 +736,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedElt(s, e);}} }; @@ -769,12 +767,12 @@ public class LockStep { for (final NavigableMap m : maps) { final Object e = usedKey(m); THROWS(IllegalArgumentException.class, - new Fun(){void f(){m.subMap(e,true,e,false) - .subMap(e,true,e,true);}}, - new Fun(){void f(){m.subMap(e,false,e,true) - .subMap(e,true,e,true);}}, - new Fun(){void f(){m.tailMap(e,false).tailMap(e,true);}}, - new Fun(){void f(){m.headMap(e,false).headMap(e,true);}}); + () -> {m.subMap(e,true,e,false) + .subMap(e,true,e,true);}, + () -> {m.subMap(e,false,e,true) + .subMap(e,true,e,true);}, + () -> m.tailMap(e,false).tailMap(e,true), + () -> m.headMap(e,false).headMap(e,true)); } //System.out.printf("%s%n", m1); for (int i = size; i > 0; i--) { @@ -811,12 +809,12 @@ public class LockStep { for (final NavigableSet s : sets) { final Object e = usedElt(s); THROWS(IllegalArgumentException.class, - new Fun(){void f(){s.subSet(e,true,e,false) - .subSet(e,true,e,true);}}, - new Fun(){void f(){s.subSet(e,false,e,true) - .subSet(e,true,e,true);}}, - new Fun(){void f(){s.tailSet(e,false).tailSet(e,true);}}, - new Fun(){void f(){s.headSet(e,false).headSet(e,true);}}); + () -> {s.subSet(e,true,e,false) + .subSet(e,true,e,true);}, + () -> {s.subSet(e,false,e,true) + .subSet(e,true,e,true);}, + () -> s.tailSet(e,false).tailSet(e,true), + () -> s.headSet(e,false).headSet(e,true)); } //System.out.printf("%s%n", s1); for (int i = size; i > 0; i--) { @@ -847,7 +845,7 @@ public class LockStep { System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new Exception("Some tests failed"); } - static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/util/PriorityQueue/ForgetMeNot.java b/jdk/test/java/util/PriorityQueue/ForgetMeNot.java index f6970fa73f7..7778d1d793d 100644 --- a/jdk/test/java/util/PriorityQueue/ForgetMeNot.java +++ b/jdk/test/java/util/PriorityQueue/ForgetMeNot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,16 +37,14 @@ public class ForgetMeNot { private static void noMoreElements(final Iterator it) { for (int j = 0; j < 2; j++) { - THROWS(NoSuchElementException.class, - new Fun() { void f() { it.next(); }}); + THROWS(NoSuchElementException.class, () -> it.next()); check(! it.hasNext()); } } private static void removeIsCurrentlyIllegal(final Iterator it) { for (int j = 0; j < 2; j++) { - THROWS(IllegalStateException.class, - new Fun() { void f() { it.remove(); }}); + THROWS(IllegalStateException.class, () -> it.remove()); } } @@ -146,7 +144,7 @@ public class ForgetMeNot { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java b/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java index cdfd9e88bdb..94ad2a172bb 100644 --- a/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java +++ b/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, 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 @@ -69,19 +69,13 @@ public class Interrupt { (BlockingDeque) q : null; q.clear(); List fs = new ArrayList(); - fs.add(new Fun() { void f() throws Throwable - { q.take(); }}); - fs.add(new Fun() { void f() throws Throwable - { q.poll(60, SECONDS); }}); + fs.add(() -> q.take()); + fs.add(() -> q.poll(60, SECONDS)); if (deq != null) { - fs.add(new Fun() { void f() throws Throwable - { deq.takeFirst(); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.takeLast(); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.pollFirst(7, SECONDS); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.pollLast(7, SECONDS); }}); + fs.add(() -> deq.takeFirst()); + fs.add(() -> deq.takeLast()); + fs.add(() -> deq.pollFirst(7, SECONDS)); + fs.add(() -> deq.pollLast(7, SECONDS)); } checkInterrupted(fs); @@ -92,19 +86,13 @@ public class Interrupt { catch (Throwable t) { unexpected(t); } fs.clear(); - fs.add(new Fun() { void f() throws Throwable - { q.put(1); }}); - fs.add(new Fun() { void f() throws Throwable - { q.offer(1, 7, SECONDS); }}); + fs.add(() -> q.put(1)); + fs.add(() -> q.offer(1, 7, SECONDS)); if (deq != null) { - fs.add(new Fun() { void f() throws Throwable - { deq.putFirst(1); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.putLast(1); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.offerFirst(1, 7, SECONDS); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.offerLast(1, 7, SECONDS); }}); + fs.add(() -> deq.putFirst(1)); + fs.add(() -> deq.putLast(1)); + fs.add(() -> deq.offerFirst(1, 7, SECONDS)); + fs.add(() -> deq.offerLast(1, 7, SECONDS)); } checkInterrupted(fs); } catch (Throwable t) { @@ -135,5 +123,5 @@ public class Interrupt { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} } diff --git a/jdk/test/java/util/concurrent/CyclicBarrier/Basic.java b/jdk/test/java/util/concurrent/CyclicBarrier/Basic.java index 123481985b2..b6b8d637b2f 100644 --- a/jdk/test/java/util/concurrent/CyclicBarrier/Basic.java +++ b/jdk/test/java/util/concurrent/CyclicBarrier/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, 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 @@ -40,10 +40,8 @@ public class Basic { equal(barrier.getNumberWaiting(), 0); THROWS(BrokenBarrierException.class, - new Fun() { public void f() throws Throwable { - barrier.await(); }}, - new Fun() { public void f() throws Throwable { - barrier.await(100, MILLISECONDS); }}); + () -> barrier.await(), + () -> barrier.await(100, MILLISECONDS)); } private static void reset(CyclicBarrier barrier) { @@ -417,7 +415,7 @@ public class Basic { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - abstract static class Fun { abstract void f() throws Throwable; } + interface Fun {void f() throws Throwable;} private static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/util/concurrent/Executors/Throws.java b/jdk/test/java/util/concurrent/Executors/Throws.java index 424b60d6d72..402472df366 100644 --- a/jdk/test/java/util/concurrent/Executors/Throws.java +++ b/jdk/test/java/util/concurrent/Executors/Throws.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,33 +45,31 @@ public class Throws { ThreadPoolExecutor executor) {}}; final RejectedExecutionHandler nullHandler = null; - THROWS( - NullPointerException.class, - new Fun(){void f(){ newFixedThreadPool(3, null); }}, - new Fun(){void f(){ newCachedThreadPool(null); }}, - new Fun(){void f(){ newSingleThreadScheduledExecutor(null); }}, - new Fun(){void f(){ newScheduledThreadPool(0, null); }}, - new Fun(){void f(){ unconfigurableExecutorService(null); }}, - new Fun(){void f(){ unconfigurableScheduledExecutorService(null); }}, - new Fun(){void f(){ callable(null, "foo"); }}, - new Fun(){void f(){ callable((Runnable) null); }}, - new Fun(){void f(){ callable((PrivilegedAction) null); }}, - new Fun(){void f(){ callable((PrivilegedExceptionAction) null); }}, - new Fun(){void f(){ privilegedCallable((Callable) null); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(0, nullFactory); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(0, nullFactory, reh); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(0, fac, nullHandler); }}); + THROWS(NullPointerException.class, + () -> newFixedThreadPool(3, null), + () -> newCachedThreadPool(null), + () -> newSingleThreadScheduledExecutor(null), + () -> newScheduledThreadPool(0, null), + () -> unconfigurableExecutorService(null), + () -> unconfigurableScheduledExecutorService(null), + () -> callable(null, "foo"), + () -> callable((Runnable) null), + () -> callable((PrivilegedAction) null), + () -> callable((PrivilegedExceptionAction) null), + () -> privilegedCallable((Callable) null), + () -> new ScheduledThreadPoolExecutor(0, nullFactory), + () -> new ScheduledThreadPoolExecutor(0, nullFactory, reh), + () -> new ScheduledThreadPoolExecutor(0, fac, nullHandler)); - THROWS( - IllegalArgumentException.class, - new Fun(){void f(){ newFixedThreadPool(-42); }}, - new Fun(){void f(){ newFixedThreadPool(0) ; }}, - new Fun(){void f(){ newFixedThreadPool(-42, fac); }}, - new Fun(){void f(){ newFixedThreadPool(0, fac); }}, - new Fun(){void f(){ newScheduledThreadPool(-42); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(-42); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(-42, reh); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(-42, fac, reh); }}); + THROWS(IllegalArgumentException.class, + () -> newFixedThreadPool(-42), + () -> newFixedThreadPool(0), + () -> newFixedThreadPool(-42, fac), + () -> newFixedThreadPool(0, fac), + () -> newScheduledThreadPool(-42), + () -> new ScheduledThreadPoolExecutor(-42), + () -> new ScheduledThreadPoolExecutor(-42, reh), + () -> new ScheduledThreadPoolExecutor(-42, fac, reh)); try { newFixedThreadPool(1).shutdownNow(); pass(); } catch (Throwable t) { unexpected(t); } @@ -122,7 +120,7 @@ public class Throws { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/util/concurrent/FutureTask/Customized.java b/jdk/test/java/util/concurrent/FutureTask/Customized.java index 15159ca0aab..a1afd9015a1 100644 --- a/jdk/test/java/util/concurrent/FutureTask/Customized.java +++ b/jdk/test/java/util/concurrent/FutureTask/Customized.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,8 +70,7 @@ public class Customized { check(! task.isDone()); check(! task.isCancelled()); THROWS(TimeoutException.class, - new Fun(){void f() throws Throwable { - task.get(0L, TimeUnit.SECONDS); }}); + () -> task.get(0L, TimeUnit.SECONDS)); } static void checkDone(final FutureTask task) { @@ -86,20 +85,16 @@ public class Customized { check(task.isDone()); check(task.isCancelled()); THROWS(CancellationException.class, - new Fun(){void f() throws Throwable { - task.get(0L, TimeUnit.SECONDS); }}, - new Fun(){void f() throws Throwable { - task.get(); }}); + () -> task.get(0L, TimeUnit.SECONDS), + () -> task.get()); } static void checkThrew(final FutureTask task) { check(task.isDone()); check(! task.isCancelled()); THROWS(ExecutionException.class, - new Fun(){void f() throws Throwable { - task.get(0L, TimeUnit.SECONDS); }}, - new Fun(){void f() throws Throwable { - task.get(); }}); + () -> task.get(0L, TimeUnit.SECONDS), + () -> task.get()); } static void cancel(FutureTask task, boolean mayInterruptIfRunning) { @@ -203,7 +198,7 @@ public class Customized { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java index aed43ac68a8..d89ee28333e 100644 --- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java +++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, 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 @@ -72,7 +72,7 @@ public class ConfigChanges { check(((ThreadPoolExecutor) es).isTerminating() || es.isTerminated()); THROWS(RejectedExecutionException.class, - new Fun() {void f() {es.execute(nop);}}); + () -> es.execute(nop)); } } catch (Throwable t) { unexpected(t); } } @@ -241,7 +241,7 @@ public class ConfigChanges { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java index dbf82f22ece..780aa4eeb06 100644 --- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java +++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, 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 @@ -81,13 +81,6 @@ public class ShutdownNowExecuteRace { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} - static void THROWS(Class k, Fun... fs) { - for (Fun f : fs) - try { f.f(); fail("Expected " + k.getName() + " not thrown"); } - catch (Throwable t) { - if (k.isAssignableFrom(t.getClass())) pass(); - else unexpected(t);}} private abstract static class CheckedThread extends Thread { abstract void realRun() throws Throwable; public void run() { diff --git a/jdk/test/sun/nio/cs/FindOneCharEncoderBugs.java b/jdk/test/sun/nio/cs/FindOneCharEncoderBugs.java index 0b244e8c0e6..95ce0fca6fa 100644 --- a/jdk/test/sun/nio/cs/FindOneCharEncoderBugs.java +++ b/jdk/test/sun/nio/cs/FindOneCharEncoderBugs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2014, 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 @@ -155,13 +155,6 @@ public class FindOneCharEncoderBugs { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} - static void THROWS(Class k, Fun... fs) { - for (Fun f : fs) - try { f.f(); fail("Expected " + k.getName() + " not thrown"); } - catch (Throwable t) { - if (k.isAssignableFrom(t.getClass())) pass(); - else unexpected(t);}} private static abstract class CheckedThread extends Thread { abstract void realRun() throws Throwable; public void run() { diff --git a/jdk/test/sun/security/krb5/auto/KDC.java b/jdk/test/sun/security/krb5/auto/KDC.java index 356f84e9856..686e238579e 100644 --- a/jdk/test/sun/security/krb5/auto/KDC.java +++ b/jdk/test/sun/security/krb5/auto/KDC.java @@ -141,6 +141,8 @@ public class KDC { private BlockingQueue q = new ArrayBlockingQueue<>(100); // Options private Map options = new HashMap<>(); + // Realm-specific krb5.conf settings + private List conf = new ArrayList<>(); private Thread thread1, thread2, thread3; DatagramSocket u1 = null; @@ -243,7 +245,7 @@ public class KDC { /** * Sets an option * @param key the option name - * @param obj the value + * @param value the value */ public void setOption(Option key, Object value) { if (value == null) { @@ -372,6 +374,13 @@ public class KDC { return kdc; } + /** + * Add realm-specific krb5.conf setting + */ + public void addConf(String s) { + conf.add(s); + } + /** * Writes a krb5.conf for one or more KDC that includes KDC locations for * each realm and the default realm name. You can also add extra strings @@ -397,6 +406,7 @@ public class KDC { * [realms] * REALM.NAME = { * kdc = host:port_number + * # realm-specific settings * } * * @@ -444,10 +454,10 @@ public class KDC { } } sb.append("\n[realms]\n"); - sb.append(realmLineForKDC(kdc)); + sb.append(kdc.realmLine()); for (Object o: more) { if (o instanceof KDC) { - sb.append(realmLineForKDC((KDC)o)); + sb.append(((KDC)o).realmLine()); } } FileOutputStream fos = new FileOutputStream(f); @@ -1133,14 +1143,16 @@ public class KDC { /** * Generates a line for a KDC to put inside [realms] of krb5.conf - * @param kdc the KDC - * @return REALM.NAME = { kdc = host:port } + * @return REALM.NAME = { kdc = host:port etc } */ - private static String realmLineForKDC(KDC kdc) { - return String.format("%s = {\n kdc = %s:%d\n}\n", - kdc.realm, - kdc.kdc, - kdc.port); + private String realmLine() { + StringBuilder sb = new StringBuilder(); + sb.append(realm).append(" = {\n kdc = ") + .append(kdc).append(':').append(port).append('\n'); + for (String s: conf) { + sb.append(" ").append(s).append('\n'); + } + return sb.append("}\n").toString(); } /** diff --git a/jdk/test/sun/security/krb5/auto/UdpTcp.java b/jdk/test/sun/security/krb5/auto/UdpTcp.java index e66f5d459fb..ae54b793527 100644 --- a/jdk/test/sun/security/krb5/auto/UdpTcp.java +++ b/jdk/test/sun/security/krb5/auto/UdpTcp.java @@ -43,9 +43,15 @@ public class UdpTcp { OneKDC kdc = new OneKDC(null); kdc.writeJAASConf(); - KDC.saveConfig(OneKDC.KRB5_CONF, kdc, - "udp_preference_limit = " - + (args[0].equals("UDP") ? "1000" : "100")); + // Two styles of kdc_timeout setting. One global, one realm-specific. + if (args[0].equals("UDP")) { + KDC.saveConfig(OneKDC.KRB5_CONF, kdc, + "kdc_timeout = 10s"); + } else { + kdc.addConf("kdc_timeout = 10s"); + KDC.saveConfig(OneKDC.KRB5_CONF, kdc, + "udp_preference_limit = 1"); + } Config.refresh(); ByteArrayOutputStream bo = new ByteArrayOutputStream(); @@ -56,7 +62,7 @@ public class UdpTcp { for (String line: new String(bo.toByteArray()).split("\n")) { if (line.contains(">>> KDCCommunication")) { - if (!line.contains(args[0])) { + if (!line.contains(args[0]) || !line.contains("timeout=10000")) { throw new Exception("No " + args[0] + " in: " + line); } } diff --git a/langtools/.hgtags b/langtools/.hgtags index d59728d0fb2..d963cacab98 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -257,3 +257,4 @@ f04fccfbd880c819affc3ef33e0083aab9556409 jdk9-b11 72efbe612e494f98b9c3ede1b4a3d02304e1e9cc jdk9-b12 2c8bb81b5d48161019218c7604fa88c67edc6105 jdk9-b13 1df3f53b9d980b66739f05e14053381ffb0f38ee jdk9-b14 +8666a9611eb8ba711b001bf8d942282e3e2d8e3d jdk9-b15 diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index 9066a03ae2a..783f6282d10 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -4696,7 +4696,7 @@ public class Types { assembleClassSig(rawOuter ? types.erasure(outer) : outer); - append('.'); + append(rawOuter ? '$' : '.'); Assert.check(c.flatname.startsWith(c.owner.enclClass().flatname)); append(rawOuter ? c.flatname.subName(c.owner.enclClass().flatname.getByteLength() + 1, c.flatname.getByteLength()) diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index 6265199a8d7..151794853f6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -1221,25 +1221,102 @@ public class DeferredAttr extends JCTree.Visitor { } //slow path + Symbol sym = quicklyResolveMethod(env, tree); + + if (sym == null) { + result = ArgumentExpressionKind.POLY; + return; + } + + result = analyzeCandidateMethods(sym, ArgumentExpressionKind.PRIMITIVE, + argumentKindAnalyzer); + } + //where + private boolean isSimpleReceiver(JCTree rec) { + switch (rec.getTag()) { + case IDENT: + return true; + case SELECT: + return isSimpleReceiver(((JCFieldAccess)rec).selected); + case TYPEAPPLY: + case TYPEARRAY: + return true; + case ANNOTATED_TYPE: + return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType); + case APPLY: + return true; + default: + return false; + } + } + private ArgumentExpressionKind reduce(ArgumentExpressionKind kind) { + return argumentKindAnalyzer.reduce(result, kind); + } + MethodAnalyzer argumentKindAnalyzer = + new MethodAnalyzer() { + @Override + public ArgumentExpressionKind process(MethodSymbol ms) { + return ArgumentExpressionKind.methodKind(ms, types); + } + @Override + public ArgumentExpressionKind reduce(ArgumentExpressionKind kind1, + ArgumentExpressionKind kind2) { + switch (kind1) { + case PRIMITIVE: return kind2; + case NO_POLY: return kind2.isPoly() ? kind2 : kind1; + case POLY: return kind1; + default: + Assert.error(); + return null; + } + } + @Override + public boolean shouldStop(ArgumentExpressionKind result) { + return result.isPoly(); + } + }; + + @Override + public void visitLiteral(JCLiteral tree) { + Type litType = attr.litType(tree.typetag); + result = ArgumentExpressionKind.standaloneKind(litType, types); + } + + @Override + void skip(JCTree tree) { + result = ArgumentExpressionKind.NO_POLY; + } + + private Symbol quicklyResolveMethod(Env env, final JCMethodInvocation tree) { final JCExpression rec = tree.meth.hasTag(SELECT) ? ((JCFieldAccess)tree.meth).selected : null; if (rec != null && !isSimpleReceiver(rec)) { - //give up if receiver is too complex (to cut down analysis time) - result = ArgumentExpressionKind.POLY; - return; + return null; } - Type site = rec != null ? - attribSpeculative(rec, env, attr.unknownTypeExprInfo).type : - env.enclClass.sym.type; + Type site; - while (site.hasTag(TYPEVAR)) { - site = site.getUpperBound(); + if (rec != null) { + if (rec.hasTag(APPLY)) { + Symbol recSym = quicklyResolveMethod(env, (JCMethodInvocation) rec); + if (recSym == null) + return null; + Symbol resolvedReturnType = + analyzeCandidateMethods(recSym, syms.errSymbol, returnSymbolAnalyzer); + if (resolvedReturnType == null) + return null; + site = resolvedReturnType.type; + } else { + site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type; + } + } else { + site = env.enclClass.sym.type; } List args = rs.dummyArgs(tree.args.length()); + Name name = TreeInfo.name(tree.meth); Resolve.LookupHelper lh = rs.new LookupHelper(name, site, args, List.nil(), MethodResolutionPhase.VARARITY) { @Override @@ -1254,61 +1331,60 @@ public class DeferredAttr extends JCTree.Visitor { } }; - Symbol sym = rs.lookupMethod(env, tree, site.tsym, rs.arityMethodCheck, lh); + return rs.lookupMethod(env, tree, site.tsym, rs.arityMethodCheck, lh); + } + //where: + MethodAnalyzer returnSymbolAnalyzer = new MethodAnalyzer() { + @Override + public Symbol process(MethodSymbol ms) { + ArgumentExpressionKind kind = ArgumentExpressionKind.methodKind(ms, types); + return kind != ArgumentExpressionKind.POLY ? ms.getReturnType().tsym : null; + } + @Override + public Symbol reduce(Symbol s1, Symbol s2) { + return s1 == syms.errSymbol ? s2 : s1 == s2 ? s1 : null; + } + @Override + public boolean shouldStop(Symbol result) { + return result == null; + } + }; - if (sym.kind == Kinds.AMBIGUOUS) { - Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol(); - result = ArgumentExpressionKind.PRIMITIVE; - for (Symbol s : err.ambiguousSyms) { - if (result.isPoly()) break; - if (s.kind == Kinds.MTH) { - result = reduce(ArgumentExpressionKind.methodKind(s, types)); + /** + * Process the result of Resolve.lookupMethod. If sym is a method symbol, the result of + * MethodAnalyzer.process is returned. If sym is an ambiguous symbol, all the candidate + * methods are inspected one by one, using MethodAnalyzer.process. The outcomes are + * reduced using MethodAnalyzer.reduce (using defaultValue as the first value over which + * the reduction runs). MethodAnalyzer.shouldStop can be used to stop the inspection early. + */ + E analyzeCandidateMethods(Symbol sym, E defaultValue, MethodAnalyzer analyzer) { + switch (sym.kind) { + case Kinds.MTH: + return analyzer.process((MethodSymbol) sym); + case Kinds.AMBIGUOUS: + Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol(); + E res = defaultValue; + for (Symbol s : err.ambiguousSyms) { + if (s.kind == Kinds.MTH) { + res = analyzer.reduce(res, analyzer.process((MethodSymbol) s)); + if (analyzer.shouldStop(res)) + return res; + } } - } - } else { - result = (sym.kind == Kinds.MTH) ? - ArgumentExpressionKind.methodKind(sym, types) : - ArgumentExpressionKind.NO_POLY; + return res; + default: + return defaultValue; } } - //where - private boolean isSimpleReceiver(JCTree rec) { - switch (rec.getTag()) { - case IDENT: - return true; - case SELECT: - return isSimpleReceiver(((JCFieldAccess)rec).selected); - case TYPEAPPLY: - case TYPEARRAY: - return true; - case ANNOTATED_TYPE: - return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType); - default: - return false; - } - } - private ArgumentExpressionKind reduce(ArgumentExpressionKind kind) { - switch (result) { - case PRIMITIVE: return kind; - case NO_POLY: return kind.isPoly() ? kind : result; - case POLY: return result; - default: - Assert.error(); - return null; - } - } - - @Override - public void visitLiteral(JCLiteral tree) { - Type litType = attr.litType(tree.typetag); - result = ArgumentExpressionKind.standaloneKind(litType, types); - } - - @Override - void skip(JCTree tree) { - result = ArgumentExpressionKind.NO_POLY; - } } + + /** Analyzer for methods - used by analyzeCandidateMethods. */ + interface MethodAnalyzer { + E process(MethodSymbol ms); + E reduce(E e1, E e2); + boolean shouldStop(E result); + } + //where private EnumSet deferredCheckerTags = EnumSet.of(LAMBDA, REFERENCE, PARENS, TYPECAST, diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java index 8f28fa0550e..b933b4632b6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java @@ -1925,6 +1925,13 @@ public class Code { return aliveRanges.isEmpty() ? null : aliveRanges.get(aliveRanges.size() - 1); } + void removeLastRange() { + Range lastRange = lastRange(); + if (lastRange != null) { + aliveRanges.remove(lastRange); + } + } + @Override public String toString() { if (aliveRanges == null) { @@ -1955,9 +1962,7 @@ public class Code { } } } else { - if (!aliveRanges.isEmpty()) { - aliveRanges.remove(aliveRanges.size() - 1); - } + removeLastRange(); } } @@ -1965,16 +1970,14 @@ public class Code { if (aliveRanges.isEmpty()) { return false; } - Range range = lastRange(); - return range.length == Character.MAX_VALUE; + return lastRange().length == Character.MAX_VALUE; } public boolean isLastRangeInitialized() { if (aliveRanges.isEmpty()) { return false; } - Range range = lastRange(); - return range.start_pc != Character.MAX_VALUE; + return lastRange().start_pc != Character.MAX_VALUE; } public Range getWidestRange() { @@ -2095,7 +2098,7 @@ public class Code { v.closeRange(length); putVar(v); } else { - v.lastRange().start_pc = Character.MAX_VALUE; + v.removeLastRange(); } } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java index 943fbb58d62..37050775fb8 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -1800,8 +1800,7 @@ public class Gen extends JCTree.Visitor { genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET); thenExit = code.branch(goto_); if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.thenpart)) { - code.closeAliveRanges(tree.thenpart, - thenExit != null && tree.elsepart == null ? thenExit.pc : code.cp); + code.closeAliveRanges(tree.thenpart, code.cp); } } if (elseChain != null) { diff --git a/langtools/test/tools/javac/flow/LVTHarness.java b/langtools/test/tools/javac/flow/LVTHarness.java index c679f52f526..7039a626a57 100644 --- a/langtools/test/tools/javac/flow/LVTHarness.java +++ b/langtools/test/tools/javac/flow/LVTHarness.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,8 @@ /* * @test - * @bug 7047734 8027660 - * @summary The LVT is not generated correctly during some try/catch scenarios; + * @bug 7047734 8027660 8037937 + * @summary The LVT is not generated correctly during some try/catch scenarios * javac crash while creating LVT entry for a local variable defined in * an inner block * @library /tools/javac/lib @@ -120,7 +120,7 @@ public class LVTHarness { for (Map.Entry entry : aliveRangeMap.entrySet()) { if (!seenAliveRanges.contains(entry.getKey())) { error("Redundant @AliveRanges annotation on method " + - entry.getKey().elem); + entry.getKey().elem + " with key " + entry.getKey()); } } } @@ -134,7 +134,7 @@ public class LVTHarness { for (Method method : classFile.methods) { for (ElementKey elementKey: aliveRangeMap.keySet()) { String methodDesc = method.getName(constantPool) + - method.descriptor.getParameterTypes(constantPool); + method.descriptor.getParameterTypes(constantPool).replace(" ", ""); if (methodDesc.equals(elementKey.elem.toString())) { checkMethod(constantPool, method, aliveRangeMap.get(elementKey)); seenAliveRanges.add(elementKey); diff --git a/langtools/test/tools/javac/flow/tests/TestCaseIfElse.java b/langtools/test/tools/javac/flow/tests/TestCaseIfElse.java index 3e6cc893794..d789853b43a 100644 --- a/langtools/test/tools/javac/flow/tests/TestCaseIfElse.java +++ b/langtools/test/tools/javac/flow/tests/TestCaseIfElse.java @@ -33,7 +33,7 @@ public class TestCaseIfElse { @AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8) @AliveRange(varName="o", bytecodeStart=21, bytecodeLength=9) - void m2(String[] args) { + void m2() { Object o; int i = 5; if (i != 5) { @@ -45,4 +45,19 @@ public class TestCaseIfElse { } o = "finish"; } + + @AliveRange(varName="o", bytecodeStart=11, bytecodeLength=3) + @AliveRange(varName="o", bytecodeStart=17, bytecodeLength=2) + Object m3(boolean cond1, boolean cond2) { + Object o; + if (cond1) { + if (cond2) { + o = "then"; + } else { + o = "else"; + return null; + } + } + return null; + } } diff --git a/langtools/test/tools/javac/lambda/T8031967.java b/langtools/test/tools/javac/lambda/T8031967.java new file mode 100644 index 00000000000..3836ecd0406 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8031967.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2014, 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 8031967 + * @summary Ensure javac can handle very deeply nested chain of method invocations occurring as + * a parameter to other method invocations. + * @run main T8031967 + */ + +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; +import java.util.List; + +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; + +public class T8031967 { + + public static void main(String... args) throws IOException { + new T8031967().run(); + } + + final int depth = 50; + + private void run() throws IOException { + runTestCase(true); + runTestCase(false); + } + + private void runTestCase(boolean withErrors) throws IOException { + StringBuilder code = new StringBuilder(); + + code.append("public class Test {\n" + + " private void test() {\n" + + " GroupLayout l = new GroupLayout();\n" + + " l.setHorizontalGroup(\n"); + + gen(code, depth); + code.append(" );\n" + + " }\n"); + if (!withErrors) { + code.append(" class GroupLayout {\n" + + " ParallelGroup createParallelGroup() {return null;}\n" + + " ParallelGroup createParallelGroup(int i) {return null;}\n" + + " ParallelGroup createParallelGroup(int i, int j) {return null;}\n" + + " void setHorizontalGroup(Group g) { }\n" + + " }\n" + + " \n" + + " class Group {\n" + + " Group addGroup(Group g) { return this; }\n" + + " Group addGroup(int i, Group g) { return this; }\n" + + " Group addGap(int i) { return this; }\n" + + " Group addGap(long l) { return this; }\n" + + " Group addGap(int i, int j) { return this; }\n" + + " Group addComponent(Object c) { return this; }\n" + + " Group addComponent(int i, Object c) { return this; }\n" + + " }\n" + + " class ParallelGroup extends Group {\n" + + " Group addGroup(Group g) { return this; }\n" + + " Group addGroup(int i, Group g) { return this; }\n" + + " Group addGap(int i) { return this; }\n" + + " Group addGap(int i, int j) { return this; }\n" + + " Group addComponent(Object c) { return this; }\n" + + " Group addComponent(int i, Object c) { return this; }\n" + + " }\n"); + } + + code.append("}\n"); + + JavaSource source = new JavaSource(code.toString()); + List sourceList = Arrays.asList(source); + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + DiagnosticListener noErrors = (diagnostic) -> { + throw new IllegalStateException("Should not produce errors: " + diagnostic); + }; + JavacTask task = (JavacTask) compiler.getTask(null, null, withErrors ? null : noErrors, + null, null, sourceList); + + task.analyze(); + } + + private void gen(StringBuilder code, int depth) { + code.append("l.createParallelGroup()\n"); + if (depth > 0) { + code.append(".addGroup(\n"); + gen(code, depth - 1); + code.append(")"); + } + + code.append(".addGap(1)\n" + + ".addComponent(new Object())\n" + + ".addGap(1)\n" + + ".addComponent(new Object())"); + } + + class JavaSource extends SimpleJavaFileObject { + + final String code; + public JavaSource(String code) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + this.code = code; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return code; + } + } +} diff --git a/langtools/test/tools/javac/types/BadSigTest.java b/langtools/test/tools/javac/types/BadSigTest.java new file mode 100644 index 00000000000..14b3ff9cbb0 --- /dev/null +++ b/langtools/test/tools/javac/types/BadSigTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, 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 8037934 + * @summary Javac generates invalid signatures for local types + * @run main BadSigTest + */ + +public class BadSigTest { + void m(){ + class Local1{} + class Local2 extends Local1{} + Local2.class.getTypeParameters(); + } + public static void main(String[] args) { + new BadSigTest().m(); + } +} diff --git a/nashorn/.hgtags b/nashorn/.hgtags index f5e58e3f192..0a256647f7b 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -248,3 +248,4 @@ b3517e51f40477f10db8bc30a557aa0ea712c274 jdk9-b02 282e9a675e079cc84dbfaa4c10050f08397faab0 jdk9-b12 be4580ae56e2ef0ce521d3f840753eaa83cacf33 jdk9-b13 806df06b6ac58d3e9c9c6a680dbdd7a6c94ca700 jdk9-b14 +32b66f4661eac52f8b04fb3d7703feb2c96febb7 jdk9-b15 diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index 88c4e9cf379..83cbb91bd4b 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -196,14 +196,16 @@ - - + + - + @@ -211,6 +213,19 @@ + + + + + + + + + + + + diff --git a/nashorn/samples/filebrowser.js b/nashorn/samples/filebrowser.js new file mode 100644 index 00000000000..da00553a4ec --- /dev/null +++ b/nashorn/samples/filebrowser.js @@ -0,0 +1,100 @@ +#// Usage: jjs -fx filebrowser.js -- + +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Uses -fx and javafx TreeView to visualize directories +if (!$OPTIONS._fx) { + print("Usage: jjs -fx filebrowser.js -- "); + exit(1); +} + +// Java classes used +var File = Java.type("java.io.File"); +var Files = Java.type("java.nio.file.Files"); + +// check directory argument, if passed +var dir = arguments.length > 0? new File(arguments[0]) : new File("."); +if (! dir.isDirectory()) { + print(dir + " is not a directory!"); + exit(2); +} + +// JavaFX classes used +var FXCollections = Java.type("javafx.collections.FXCollections"); +var Scene = Java.type("javafx.scene.Scene"); +var TreeItem = Java.type("javafx.scene.control.TreeItem"); +var TreeView = Java.type("javafx.scene.control.TreeView"); + +// create a subclass of JavaFX TreeItem class +var LazyTreeItem = Java.extend(TreeItem); + +// lazily filling children of a directory LazyTreeItem +function buildChildren(dir) { + var children = FXCollections.observableArrayList(); + var stream = Files.list(dir.toPath()); + stream.forEach(function(path) { + var file = path.toFile(); + var item = file.isDirectory()? + makeLazyTreeItem(file) : new TreeItem(file.name); + children.add(item); + }); + stream.close(); + return children; +} + +// create an instance LazyTreeItem with override methods +function makeLazyTreeItem(dir) { + var item = new LazyTreeItem(dir.name) { + expanded: false, + isLeaf: function() false, + getChildren: function() { + if (! this.expanded) { + // call super class (TreeItem) method + Java.super(item).getChildren().setAll(buildChildren(dir)); + this.expanded = true; + } + // call super class (TreeItem) method + return Java.super(item).getChildren(); + } + } + return item; +} + +// JavaFX start method +function start(stage) { + stage.title = dir.absolutePath; + var rootItem = makeLazyTreeItem(dir); + rootItem.expanded = true; + var tree = new TreeView(rootItem); + stage.scene = new Scene(tree, 300, 450); + stage.show(); +} diff --git a/nashorn/samples/word_histogram.js b/nashorn/samples/word_histogram.js new file mode 100644 index 00000000000..9c739ea0375 --- /dev/null +++ b/nashorn/samples/word_histogram.js @@ -0,0 +1,53 @@ +#nashorn word histogram of a file + +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This example demonstrates how to print word histogram + * of a given text file using regex, array and JSON + * functions. + */ + +if (arguments.length < 1) { + print("Usage: jjs -scripting word_histogram.js -- "); + exit(1); +} + +var obj = {}; + +readFully(arguments[0]). + split(/[^\w+]/). + forEach(function(x) + (x in obj? obj[x]++ : obj[x] = 1)); + +print(JSON.stringify(obj)); + diff --git a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java index b12553369d4..07f4e8a6864 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java +++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java @@ -621,6 +621,7 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin /** * Utilitity to convert this script object to the given type. * + * @param destination type to convert to * @param type destination type to convert to * @return converted object */ diff --git a/nashorn/src/jdk/nashorn/api/scripting/package-info.java b/nashorn/src/jdk/nashorn/api/scripting/package-info.java index 6876151e330..f017ba9ef4f 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/package-info.java +++ b/nashorn/src/jdk/nashorn/api/scripting/package-info.java @@ -32,7 +32,8 @@ * ScriptEngine nashornEngine = new ScriptEngineManager().getEngineByName("Nashorn"); * *

Nashorn script engines implement the optional {@link javax.script.Invocable} and {@link javax.script.Compilable} - * interfaces, allowing for efficient pre-compilation and repeated execution of scripts. See + * interfaces, allowing for efficient pre-compilation and repeated execution of scripts. In addition, + * this package provides nashorn specific extension classes, interfaces and methods. See * {@link jdk.nashorn.api.scripting.NashornScriptEngineFactory} for further details. */ package jdk.nashorn.api.scripting; diff --git a/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java b/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java index 20c8ffca53b..27f6a697666 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java +++ b/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java @@ -32,9 +32,7 @@ import java.lang.annotation.RetentionPolicy; * Reference node in AST, i.e. anything not a copy. Important for * AST traversal and cloning. Cloning currently as a rule uses * existingOrSame for references and otherwise existingOrCopy - *

*/ - @Retention(value=RetentionPolicy.RUNTIME) public @interface Reference { // EMPTY