From bbb2e94d1646103ede6ef5d53cc4624323f42503 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Mon, 18 Aug 2014 20:09:25 -0700 Subject: [PATCH 1/7] 8055353: libsplashscreen build fails on MacOSX Mavericks Reviewed-by: mchung, dholmes --- jdk/make/lib/Awt2dLibraries.gmk | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index 774a2675836..694db74f196 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -973,7 +973,6 @@ ifndef BUILD_HEADLESS_ONLY # ifeq ($(OPENJDK_TARGET_OS), macosx) - LIBSPLASHSCREEN_CFLAGS += -F/System/Library/Frameworks/JavaVM.framework/Frameworks LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX LIBSPLASHSCREEN_CFLAGS += -I$(JDK_TOPDIR)/src/java.desktop/macosx/native/libosxapp From 0613e548bb5d9d250eb7ec1c22e6164a0c6ff77e Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Mon, 18 Aug 2014 21:06:45 -0700 Subject: [PATCH 2/7] 8055253: test/java/util/Currency/PropertiesTest.sh modifies the test JDK Always make a temp copy of the test JDK before destructively modifying Reviewed-by: naoto, alanb --- jdk/test/TEST.ROOT | 2 +- jdk/test/java/util/Currency/PropertiesTest.sh | 29 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/jdk/test/TEST.ROOT b/jdk/test/TEST.ROOT index e6cb16998ed..7288a0921d8 100644 --- a/jdk/test/TEST.ROOT +++ b/jdk/test/TEST.ROOT @@ -8,7 +8,7 @@ keys=2d dnd i18n othervm.dirs=java/awt java/beans javax/accessibility javax/imageio javax/sound javax/print javax/management com/sun/awt sun/awt sun/java2d sun/pisces # Tests that cannot run concurrently -exclusiveAccess.dirs=java/rmi/Naming java/util/Currency java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi +exclusiveAccess.dirs=java/rmi/Naming java/util/prefs sun/management/jmxremote sun/tools/jstatd sun/security/mscapi # Group definitions groups=TEST.groups [closed/TEST.groups] diff --git a/jdk/test/java/util/Currency/PropertiesTest.sh b/jdk/test/java/util/Currency/PropertiesTest.sh index 01f1326cd2d..cae14e6013c 100644 --- a/jdk/test/java/util/Currency/PropertiesTest.sh +++ b/jdk/test/java/util/Currency/PropertiesTest.sh @@ -97,25 +97,16 @@ run PropertiesTest -c dump1 dump2 ${PROPS} # Dump built-in currency data + overrides in properties file copied into # JRE image. -# Copy the test properties file. If testjava is not a typical jdk-image -# or testjava is not writable, make a private copy of it. -COPIED=0 -if [ -w ${TESTJAVA}${FS}jre${FS}lib ] -then - WRITABLEJDK=$TESTJAVA +# Make a private copy of the jdk so we can write to the properties file location +# without disturbing other users, including concurrently executing tests. +WRITABLEJDK=.${FS}testjava +cp -Hr $TESTJAVA $WRITABLEJDK +if [ -d ${TESTJAVA}${FS}jre ]; then PROPLOCATION=${WRITABLEJDK}${FS}jre${FS}lib else - WRITABLEJDK=.${FS}testjava - if [ -d ${TESTJAVA}${FS}jre ] - then - PROPLOCATION=${WRITABLEJDK}${FS}jre${FS}lib - else - PROPLOCATION=${WRITABLEJDK}${FS}lib - fi - cp -r $TESTJAVA $WRITABLEJDK - chmod -R +w $WRITABLEJDK - COPIED=1 + PROPLOCATION=${WRITABLEJDK}${FS}lib fi +chmod -R +w $WRITABLEJDK cp ${PROPS} $PROPLOCATION echo "Properties location: ${PROPLOCATION}" @@ -125,11 +116,7 @@ sh -xc "${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} Propert if [ $? != 0 ]; then failures=`expr $failures + 1`; fi # Cleanup -rm -f ${PROPLOCATION}${FS}currency.properties -if [ $COPIED -eq 1 ] -then - rm -rf $WRITABLEJDK -fi +rm -rf $WRITABLEJDK # compare the two dump files run PropertiesTest -c dump1 dump3 ${PROPS} From 391a556d146e49f35a9fbf9cb2331f0f4851b180 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Tue, 19 Aug 2014 14:30:12 +0800 Subject: [PATCH 3/7] 8054817: File ccache only recognizes Linux and Solaris defaults Reviewed-by: mullan --- .../internal/ccache/FileCredentialsCache.java | 55 +++++++------------ .../sun/security/krb5/ccache/DefaultFile.java | 47 ++++++++++++++++ 2 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 jdk/test/sun/security/krb5/ccache/DefaultFile.java diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java index 3337d9fd5cf..2335cc23eb9 100644 --- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java +++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java @@ -43,7 +43,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; -import java.lang.reflect.*; /** * CredentialsCache stores credentials(tickets, session keys, etc) in a @@ -388,52 +387,36 @@ public class FileCredentialsCache extends CredentialsCache /* * For Unix platforms we use the default cache name to be - * /tmp/krbcc_uid ; for all other platforms we use - * {user_home}/krb5_cc{user_name} - * Please note that for Windows 2K we will use LSA to get + * /tmp/krb5cc_uid ; for all other platforms we use + * {user_home}/krb5cc_{user_name} + * Please note that for Windows we will use LSA to get * the TGT from the the default cache even before we come here; * however when we create cache we will create a cache under - * {user_home}/krb5_cc{user_name} for non-Unix platforms including - * Windows 2K. + * {user_home}/krb5cc_{user_name} for non-Unix platforms including + * Windows. */ - if (osname != null) { - String cmd = null; - String uidStr = null; - long uid = 0; - - if (osname.startsWith("SunOS") || - (osname.startsWith("Linux"))) { - try { - Class c = Class.forName - ("com.sun.security.auth.module.UnixSystem"); - Constructor constructor = c.getConstructor(); - Object obj = constructor.newInstance(); - Method method = c.getMethod("getUid"); - uid = ((Long)method.invoke(obj)).longValue(); - name = File.separator + "tmp" + + if (osname != null && !osname.startsWith("Windows")) { + long uid = sun.misc.VM.getuid(); + if (uid != -1) { + name = File.separator + "tmp" + File.separator + stdCacheNameComponent + "_" + uid; - if (DEBUG) { - System.out.println(">>>KinitOptions cache name is " + - name); - } - return name; - } catch (Exception e) { - if (DEBUG) { - System.out.println("Exception in obtaining uid " + - "for Unix platforms " + - "Using user's home directory"); - - - e.printStackTrace(); - } + if (DEBUG) { + System.out.println(">>>KinitOptions cache name is " + + name); + } + return name; + } else { + if (DEBUG) { + System.out.println("Error in obtaining uid " + + "for Unix platforms " + + "Using user's home directory"); } } } // we did not get the uid; - String user_name = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("user.name")); diff --git a/jdk/test/sun/security/krb5/ccache/DefaultFile.java b/jdk/test/sun/security/krb5/ccache/DefaultFile.java new file mode 100644 index 00000000000..b2348e3507f --- /dev/null +++ b/jdk/test/sun/security/krb5/ccache/DefaultFile.java @@ -0,0 +1,47 @@ +/* + * 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 8054817 + * @summary File ccache only recognizes Linux and Solaris defaults + */ + +import sun.security.krb5.internal.ccache.FileCredentialsCache; + +public class DefaultFile { + public static void main(String[] args) throws Exception { + // There are 2 cases where default ccache name is not + // /tmp/krb5cc_uid. + if (System.getenv("KRB5CCNAME") != null) { + return; + } + if (System.getProperty("os.name").startsWith("Windows")) { + return; + } + String name = FileCredentialsCache.getDefaultCacheName(); + if (!name.startsWith("/tmp/krb5cc_")) { + throw new Exception("default name is " + name); + } + } +} From 46c981faef2c7936c0784804b2400c86426293d2 Mon Sep 17 00:00:00 2001 From: Masayoshi Okutsu Date: Tue, 19 Aug 2014 16:02:48 +0900 Subject: [PATCH 4/7] 8055088: Optimization for locale resources loading isn't working Reviewed-by: naoto --- jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk | 11 ++++- .../util/cldr/CLDRLocaleProviderAdapter.java | 6 ++- .../provider/JRELocaleProviderAdapter.java | 6 ++- .../LocaleDataMetaInfo-XLocales.java.template | 8 +++- .../provider/LocaleProviderAdapter.java | 4 +- .../sun/util/resources/LocaleData.java | 47 ++++++++----------- 6 files changed, 47 insertions(+), 35 deletions(-) diff --git a/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk b/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk index b3f0335d7e0..12b80d7fcbe 100644 --- a/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk +++ b/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, 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 @@ -34,7 +34,8 @@ LOCALE_FILES := $(shell $(FIND) $(JDK_TOPDIR)/src/*/share/classes \ -name "TimeZoneNames_*.java" -o -name "TimeZoneNames_*.properties" -o \ -name "LocaleNames_*.java" -o -name "LocaleNames_*.properties" -o \ -name "CurrencyNames_*.java" -o -name "CurrencyNames_*.properties" -o \ - -name "CalendarData_*.java" -o -name "CalendarData_*.properties") + -name "CalendarData_*.java" -o -name "CalendarData_*.properties" -o \ + -name "BreakIteratorInfo_*.java" -o -name "BreakIteratorRules_*.java") # Then translate the locale files into for example: FormatData_sv LOCALE_RESOURCES := $(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES))))) @@ -86,6 +87,12 @@ $(eval $(call CaptureLocale,FormatData)) #sun.text.resources.CollationData $(eval $(call CaptureLocale,CollationData)) +#sun.text.resources.BreakIteratorInfo +$(eval $(call CaptureLocale,BreakIteratorInfo)) + +#sun.text.resources.BreakIteratorRules +$(eval $(call CaptureLocale,BreakIteratorRules)) + #sun.util.resources.TimeZoneNames $(eval $(call CaptureLocale,TimeZoneNames)) diff --git a/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java b/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java index 77f7b843d64..bda94f63bec 100644 --- a/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java +++ b/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -30,6 +30,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.text.spi.BreakIteratorProvider; import java.text.spi.CollatorProvider; +import java.util.Collections; import java.util.HashSet; import java.util.Locale; import java.util.ResourceBundle; @@ -102,6 +103,9 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter { @Override protected Set createLanguageTagSet(String category) { ResourceBundle rb = ResourceBundle.getBundle("sun.util.cldr.CLDRLocaleDataMetaInfo", Locale.ROOT); + if (rb.containsKey(category)) { + return Collections.emptySet(); + } String supportedLocaleString = rb.getString(category); Set tagset = new HashSet<>(); StringTokenizer tokens = new StringTokenizer(supportedLocaleString); diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java index 50473cde715..f07d793a88d 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -34,6 +34,7 @@ import java.text.spi.DateFormatProvider; import java.text.spi.DateFormatSymbolsProvider; import java.text.spi.DecimalFormatSymbolsProvider; import java.text.spi.NumberFormatProvider; +import java.util.Collections; import java.util.HashSet; import java.util.Locale; import java.util.Set; @@ -356,6 +357,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R protected Set createLanguageTagSet(String category) { String supportedLocaleString = LocaleDataMetaInfo.getSupportedLocaleString(category); + if (supportedLocaleString == null) { + return Collections.emptySet(); + } Set tagset = new HashSet<>(); StringTokenizer tokens = new StringTokenizer(supportedLocaleString); while (tokens.hasMoreTokens()) { diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template index 17d9af65817..52ac29de777 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template +++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template @@ -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 @@ -57,6 +57,12 @@ public class LocaleDataMetaInfo { resourceNameToLocales.put("CollationData", " #CollationData_ENLocales# | #CollationData_NonENLocales# "); + resourceNameToLocales.put("BreakIteratorInfo", + " #BreakIteratorInfo_ENLocales# | #BreakIteratorInfo_NonENLocales# "); + + resourceNameToLocales.put("BreakIteratorRules", + " #BreakIteratorRules_ENLocales# | #BreakIteratorRules_NonENLocales# "); + resourceNameToLocales.put("TimeZoneNames", " #TimeZoneNames_ENLocales# | #TimeZoneNames_NonENLocales# "); diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java index b7ba7361d2b..3f7222172d7 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -295,7 +295,7 @@ public abstract class LocaleProviderAdapter { * A utility method for implementing the default LocaleServiceProvider.isSupportedLocale * for the JRE, CLDR, and FALLBACK adapters. */ - static boolean isSupportedLocale(Locale locale, LocaleProviderAdapter.Type type, Set langtags) { + public static boolean isSupportedLocale(Locale locale, LocaleProviderAdapter.Type type, Set langtags) { assert type == Type.JRE || type == Type.CLDR || type == Type.FALLBACK; if (Locale.ROOT.equals(locale)) { return true; diff --git a/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java b/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java index 00ba6dec959..679baf6ebbb 100644 --- a/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java +++ b/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -48,8 +48,11 @@ import java.util.List; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; +import java.util.Set; +import sun.util.locale.provider.JRELocaleProviderAdapter; import sun.util.locale.provider.LocaleDataMetaInfo; import sun.util.locale.provider.LocaleProviderAdapter; +import static sun.util.locale.provider.LocaleProviderAdapter.Type.CLDR; import static sun.util.locale.provider.LocaleProviderAdapter.Type.JRE; /** @@ -204,35 +207,23 @@ public class LocaleData { @Override public List getCandidateLocales(String baseName, Locale locale) { List candidates = super.getCandidateLocales(baseName, locale); - /* Get the locale string list from LocaleDataMetaInfo class. */ - String localeString = LocaleDataMetaInfo.getSupportedLocaleString(baseName); - - if (localeString != null && localeString.length() != 0) { - for (Iterator l = candidates.iterator(); l.hasNext();) { - Locale loc = l.next(); - String lstr; - if (loc.getScript().length() > 0) { - lstr = loc.toLanguageTag().replace('-', '_'); - } else { - lstr = loc.toString(); - int idx = lstr.indexOf("_#"); - if (idx >= 0) { - lstr = lstr.substring(0, idx); - } - } - /* Every locale string in the locale string list returned from - the above getSupportedLocaleString is enclosed - within two white spaces so that we could check some locale - such as "en". - */ - if (lstr.length() != 0 && localeString.indexOf(" " + lstr + " ") == -1) { - l.remove(); + // Weed out Locales which are known to have no resource bundles + int lastDot = baseName.lastIndexOf('.'); + String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName; + LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE; + LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); + Set langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category); + if (!langtags.isEmpty()) { + for (Iterator itr = candidates.iterator(); itr.hasNext();) { + if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) { + itr.remove(); } } } + // Force fallback to Locale.ENGLISH for CLDR time zone names support if (locale.getLanguage() != "en" - && baseName.contains(CLDR) && baseName.endsWith("TimeZoneNames")) { + && type == CLDR && category.equals("TimeZoneNames")) { candidates.add(candidates.size() - 1, Locale.ENGLISH); } return candidates; @@ -254,7 +245,7 @@ public class LocaleData { return null; } - private static final String CLDR = ".cldr"; + private static final String DOTCLDR = ".cldr"; /** * Changes baseName to its per-language package name and @@ -275,8 +266,8 @@ public class LocaleData { assert JRE.getUtilResourcesPackage().length() == JRE.getTextResourcesPackage().length(); int index = JRE.getUtilResourcesPackage().length(); - if (baseName.indexOf(CLDR, index) > 0) { - index += CLDR.length(); + if (baseName.indexOf(DOTCLDR, index) > 0) { + index += DOTCLDR.length(); } newBaseName = baseName.substring(0, index + 1) + lang + baseName.substring(index); From 482e4a88597cb171a5a78bd7c764ca8c3ff1f2c2 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Tue, 19 Aug 2014 06:56:59 -0700 Subject: [PATCH 5/7] 8055012: [TESTBUG] NMTHelper fails to parse NMT output Fixed the regular expression to parse the slightly changed output format of the new NMT implementation Reviewed-by: olagneau, sla --- jdk/test/java/lang/instrument/NMTHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/lang/instrument/NMTHelper.java b/jdk/test/java/lang/instrument/NMTHelper.java index ad08fdb7708..c5843f8f49b 100644 --- a/jdk/test/java/lang/instrument/NMTHelper.java +++ b/jdk/test/java/lang/instrument/NMTHelper.java @@ -32,8 +32,8 @@ public class NMTHelper executeDcmd("vmNativeMemory", "baseline"); } - // Total: reserved=3484685KB +293KB, committed=266629KB +293KB - private static Pattern totalLine = Pattern.compile("^Total: reserved=\\d+KB .*KB, committed=\\d+KB (.*)KB$"); + // Total: reserved=3484685KB +293KB, committed=266629KB +293KB + private static Pattern totalLine = Pattern.compile("^Total: reserved=\\d+KB .*KB, committed=\\d+KB (.*)KB$"); public static long committedDiff() throws Exception { String res = (String) executeDcmd("vmNativeMemory", "detail.diff"); From f0133ac1a0d9b22c88387da6e49e6accd52e6a3f Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Tue, 19 Aug 2014 17:11:28 +0200 Subject: [PATCH 6/7] 8052403: java/util/logging/CheckZombieLockTest.java fails with NoSuchFileException CheckZombieLockTest and CheckLockLocationTest should work with different temporary log directories so that they can be run concurrently. This fix changes the name of the log directory used by CheckZombieLockTest. Reviewed-by: mchung --- .../util/logging/CheckZombieLockTest.java | 87 ++++++++++--------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/jdk/test/java/util/logging/CheckZombieLockTest.java b/jdk/test/java/util/logging/CheckZombieLockTest.java index f0b0a930c68..ab65a814f0b 100644 --- a/jdk/test/java/util/logging/CheckZombieLockTest.java +++ b/jdk/test/java/util/logging/CheckZombieLockTest.java @@ -51,23 +51,23 @@ import java.util.logging.Level; import java.util.logging.LogRecord; public class CheckZombieLockTest { - private static final String WRITABLE_DIR = "writable-dir"; + private static final String WRITABLE_DIR = "writable-lockfile-dir"; private static volatile boolean supportsLocking = true; static enum TestCase { - WRITABLE, // just verifies that we can create a file in our 'writable-dir' + WRITABLE, // just verifies that we can create a file in our 'writable-lockfile-dir' CLOSE, // checks that closing a FileHandler removes its lock file - CREATE_FIRST, // verifies that 'writable-dir' contains no lock, then creates a first FileHandler. - CREATE_NEXT, // verifies that 'writable-dir' contains a single lock, then creates the next FileHandler + CREATE_FIRST, // verifies that 'writable-lockfile-dir' contains no lock, then creates a first FileHandler. + CREATE_NEXT, // verifies that 'writable-lockfile-dir' contains a single lock, then creates the next FileHandler REUSE, // verifies that zombie lock files can be reused - CLEANUP // removes "writable-dir" + CLEANUP // removes "writable-lockfile-dir" }; public static void main(String... args) throws IOException { // we'll base all file creation attempts on the system temp directory, // %t File writableDir = setup(); - System.out.println("Writable dir is: "+writableDir.getAbsolutePath()); + System.out.println("Writable dir is: " + writableDir.getAbsolutePath()); // we now have one writable directory to work with: // writableDir if (args == null || args.length == 0) { @@ -104,7 +104,7 @@ public class CheckZombieLockTest { case REUSE: testFileHandlerReuse(writableDir); break; // Removes the writableDir case CLEANUP: delete(writableDir); break; - default: throw new RuntimeException("No such test case: "+arg); + default: throw new RuntimeException("No such test case: " + arg); } } } @@ -120,7 +120,7 @@ public class CheckZombieLockTest { // Test 1: make sure we can create/delete files in the writable dir. final File file = new File(writableDir, "test.txt"); if (!createFile(file, false)) { - throw new IOException("Can't create "+file+"\n\tUnable to run test"); + throw new IOException("Can't create " + file + "\n\tUnable to run test"); } else { delete(file); } @@ -159,22 +159,22 @@ public class CheckZombieLockTest { private static void testFileHandlerClose(File writableDir) throws IOException { File fakeLock = new File(writableDir, "log.log.lck"); if (!createFile(fakeLock, false)) { - throw new IOException("Can't create fake lock file: "+fakeLock); + throw new IOException("Can't create fake lock file: " + fakeLock); } try { List before = listLocks(writableDir, true); - System.out.println("before: " +before.size() + " locks found"); + System.out.println("before: " + before.size() + " locks found"); FileHandler handler = createFileHandler(writableDir); - System.out.println("handler created: "+handler); + System.out.println("handler created: " + handler); List after = listLocks(writableDir, true); System.out.println("after creating handler: " + after.size() + " locks found"); handler.close(); - System.out.println("handler closed: "+handler); + System.out.println("handler closed: " + handler); List afterClose = listLocks(writableDir, true); System.out.println("after closing handler: " + afterClose.size() + " locks found"); afterClose.removeAll(before); if (!afterClose.isEmpty()) { - throw new RuntimeException("Zombie lock file detected: "+ afterClose); + throw new RuntimeException("Zombie lock file detected: " + afterClose); } } finally { if (fakeLock.canRead()) delete(fakeLock); @@ -186,21 +186,22 @@ public class CheckZombieLockTest { private static void testFileHandlerReuse(File writableDir) throws IOException { List before = listLocks(writableDir, true); - System.out.println("before: " +before.size() + " locks found"); + System.out.println("before: " + before.size() + " locks found"); try { if (!before.isEmpty()) { - throw new RuntimeException("Expected no lock file! Found: "+before); + throw new RuntimeException("Expected no lock file! Found: " + before); } } finally { before.stream().forEach(CheckZombieLockTest::delete); } FileHandler handler1 = createFileHandler(writableDir); - System.out.println("handler created: "+handler1); + System.out.println("handler created: " + handler1); List after = listLocks(writableDir, true); System.out.println("after creating handler: " + after.size() + " locks found"); if (after.size() != 1) { - throw new RuntimeException("Unexpected number of lock files found for "+handler1+": "+after); + throw new RuntimeException("Unexpected number of lock files found for " + + handler1 + ": " + after); } final File lock = after.get(0); after.clear(); @@ -208,33 +209,34 @@ public class CheckZombieLockTest { after = listLocks(writableDir, true); System.out.println("after closing handler: " + after.size() + " locks found"); if (!after.isEmpty()) { - throw new RuntimeException("Unexpected number of lock files found for "+handler1+": "+after); + throw new RuntimeException("Unexpected number of lock files found for " + + handler1 + ": " + after); } if (!createFile(lock, false)) { - throw new IOException("Can't create fake lock file: "+lock); + throw new IOException("Can't create fake lock file: " + lock); } try { before = listLocks(writableDir, true); - System.out.println("before: " +before.size() + " locks found"); + System.out.println("before: " + before.size() + " locks found"); if (before.size() != 1) { - throw new RuntimeException("Unexpected number of lock files found: "+before+" expected [" - +lock+"]."); + throw new RuntimeException("Unexpected number of lock files found: " + + before + " expected [" + lock + "]."); } FileHandler handler2 = createFileHandler(writableDir); - System.out.println("handler created: "+handler2); + System.out.println("handler created: " + handler2); after = listLocks(writableDir, true); System.out.println("after creating handler: " + after.size() + " locks found"); after.removeAll(before); if (!after.isEmpty()) { - throw new RuntimeException("Unexpected lock file found: "+after + throw new RuntimeException("Unexpected lock file found: " + after + "\n\t" + lock + " should have been reused"); } handler2.close(); - System.out.println("handler closed: "+handler2); + System.out.println("handler closed: " + handler2); List afterClose = listLocks(writableDir, true); System.out.println("after closing handler: " + afterClose.size() + " locks found"); if (!afterClose.isEmpty()) { - throw new RuntimeException("Zombie lock file detected: "+ afterClose); + throw new RuntimeException("Zombie lock file detected: " + afterClose); } if (supportsLocking) { @@ -243,18 +245,19 @@ public class CheckZombieLockTest { StandardOpenOption.WRITE); try { if (fc.tryLock() != null) { - System.out.println("locked: "+lock); + System.out.println("locked: " + lock); handler2 = createFileHandler(writableDir); - System.out.println("handler created: "+handler2); + System.out.println("handler created: " + handler2); after = listLocks(writableDir, true); - System.out.println("after creating handler: " + after.size() + " locks found"); + System.out.println("after creating handler: " + after.size() + + " locks found"); after.removeAll(before); if (after.size() != 1) { - throw new RuntimeException("Unexpected lock files found: "+after + throw new RuntimeException("Unexpected lock files found: " + after + "\n\t" + lock + " should not have been reused"); } } else { - throw new RuntimeException("Failed to lock: "+lock); + throw new RuntimeException("Failed to lock: " + lock); } } finally { delete(lock); @@ -271,22 +274,23 @@ public class CheckZombieLockTest { private static void testFileHandlerCreate(File writableDir, boolean first) throws IOException { List before = listLocks(writableDir, true); - System.out.println("before: " +before.size() + " locks found"); + System.out.println("before: " + before.size() + " locks found"); try { if (first && !before.isEmpty()) { - throw new RuntimeException("Expected no lock file! Found: "+before); + throw new RuntimeException("Expected no lock file! Found: " + before); } else if (!first && before.size() != 1) { - throw new RuntimeException("Expected a single lock file! Found: "+before); + throw new RuntimeException("Expected a single lock file! Found: " + before); } } finally { before.stream().forEach(CheckZombieLockTest::delete); } FileHandler handler = createFileHandler(writableDir); - System.out.println("handler created: "+handler); + System.out.println("handler created: " + handler); List after = listLocks(writableDir, true); System.out.println("after creating handler: " + after.size() + " locks found"); if (after.size() != 1) { - throw new RuntimeException("Unexpected number of lock files found for "+handler+": "+after); + throw new RuntimeException("Unexpected number of lock files found for " + + handler + ": " + after); } } @@ -305,7 +309,7 @@ public class CheckZombieLockTest { tmpDir = System.getProperty("user.home"); } File tmpOrHomeDir = new File(tmpDir); - // Create a writable directory here (%t/writable-dir) + // Create a writable directory here (%t/writable-lockfile-dir) File writableDir = new File(tmpOrHomeDir, WRITABLE_DIR); if (!createFile(writableDir, true)) { throw new RuntimeException("Test setup failed: unable to create" @@ -314,9 +318,10 @@ public class CheckZombieLockTest { } // try to determine whether file locking is supported + final String uniqueFileName = UUID.randomUUID().toString()+".lck"; try { FileChannel fc = FileChannel.open(Paths.get(writableDir.getAbsolutePath(), - UUID.randomUUID().toString()+".lck"), + uniqueFileName), StandardOpenOption.CREATE_NEW, StandardOpenOption.APPEND, StandardOpenOption.DELETE_ON_CLOSE); try { @@ -326,9 +331,11 @@ public class CheckZombieLockTest { } finally { fc.close(); } - } catch(Throwable t) { + } catch (IOException t) { // should not happen - t.printStackTrace(); + System.err.println("Failed to create new file " + uniqueFileName + + " in " + writableDir.getAbsolutePath()); + throw new RuntimeException("Test setup failed: unable to run test", t); } return writableDir; } From 73e818fea992d751406e28cd80f61fcaf7f6264e Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Tue, 19 Aug 2014 12:18:09 +0200 Subject: [PATCH 7/7] 8035939: java/lang/management/MemoryMXBean/MemoryManagement.java timed out on Linux-amd64 Reviewed-by: sla, brutisso, mgerdin --- .../MemoryMXBean/LowMemoryTest.java | 24 +++++++++++++++---- .../MemoryMXBean/MemoryManagement.java | 14 ++++++++++- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java index 891e2fbd4cb..450cc870296 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java +++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java @@ -50,6 +50,7 @@ public class LowMemoryTest { private static boolean testFailed = false; private static final int NUM_TRIGGERS = 5; private static final int NUM_CHUNKS = 2; + private static final int YOUNG_GEN_SIZE = 8 * 1024 * 1024; private static long chunkSize; /** @@ -59,11 +60,14 @@ public class LowMemoryTest { */ public static void main(String a[]) throws Throwable { final String main = "LowMemoryTest$TestMain"; - RunUtil.runTestKeepGcOpts(main); - RunUtil.runTestClearGcOpts(main, "-XX:+UseSerialGC"); - RunUtil.runTestClearGcOpts(main, "-XX:+UseParallelGC"); - RunUtil.runTestClearGcOpts(main, "-XX:+UseG1GC"); - RunUtil.runTestClearGcOpts(main, "-XX:+UseConcMarkSweepGC"); + // Use a low young gen size to ensure that the + // allocated objects are put in the old gen. + final String nmFlag = "-Xmn" + YOUNG_GEN_SIZE; + RunUtil.runTestKeepGcOpts(main, nmFlag); + RunUtil.runTestClearGcOpts(main, nmFlag, "-XX:+UseSerialGC"); + RunUtil.runTestClearGcOpts(main, nmFlag, "-XX:+UseParallelGC"); + RunUtil.runTestClearGcOpts(main, nmFlag, "-XX:+UseG1GC"); + RunUtil.runTestClearGcOpts(main, nmFlag, "-XX:+UseConcMarkSweepGC"); } private static volatile boolean listenerInvoked = false; @@ -156,6 +160,16 @@ public class LowMemoryTest { chunkSize = (mu.getMax() - mu.getUsed()) / 20; newThreshold = mu.getUsed() + (chunkSize * NUM_CHUNKS); + // Sanity check. Make sure the chunkSize is large than the YOUNG_GEN_SIZE + // If the chunkSize are lower than the YOUNG_GEN_SIZE, we will get intermittent + // failures when objects end up in the young gen instead of the old gen. + // Tweak the test if this fails. + if (chunkSize < YOUNG_GEN_SIZE) { + throw new RuntimeException("TEST FAILED: " + + " chunkSize: " + chunkSize + " is less than YOUNG_GEN_SIZE: " + YOUNG_GEN_SIZE + + " max: " + mu.getMax() + " used: " + mu.getUsed() + " newThreshold: " + newThreshold); + } + System.out.println("Setting threshold for " + mpool.getName() + " from " + mpool.getUsageThreshold() + " to " + newThreshold + ". Current used = " + mu.getUsed()); diff --git a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java index 4077d2a08ef..b9db049946f 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java +++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java @@ -31,7 +31,7 @@ * @author Mandy Chung * * @build MemoryManagement MemoryUtil - * @run main/othervm/timeout=600 MemoryManagement + * @run main/othervm/timeout=600 -Xmn8m MemoryManagement */ import java.lang.management.*; @@ -49,6 +49,8 @@ public class MemoryManagement { private static volatile boolean trace = false; private static volatile boolean testFailed = false; private static final int NUM_CHUNKS = 2; + // Must match -Xmn set on the @run line + private static final int YOUNG_GEN_SIZE = 8 * 1024 * 1024; private static volatile long chunkSize; private static volatile int listenerInvoked = 0; @@ -112,6 +114,16 @@ public class MemoryManagement { } newThreshold = mu.getUsed() + (chunkSize * NUM_CHUNKS); + // Sanity check. Make sure the chunkSize is large than the YOUNG_GEN_SIZE + // If the chunkSize are lower than the YOUNG_GEN_SIZE, we will get intermittent + // failures when objects end up in the young gen instead of the old gen. + // Tweak the test if this fails. + if (chunkSize < YOUNG_GEN_SIZE) { + throw new RuntimeException("TEST FAILED: " + + " chunkSize: " + chunkSize + " is less than YOUNG_GEN_SIZE: " + YOUNG_GEN_SIZE + + " max: " + mu.getMax() + " used: " + mu.getUsed() + " newThreshold: " + newThreshold); + } + System.out.println("Setting threshold for " + mpool.getName() + " from " + mpool.getUsageThreshold() + " to " + newThreshold + ". Current used = " + mu.getUsed());