diff --git a/jdk/make/data/tzdata/VERSION b/jdk/make/data/tzdata/VERSION index 9987fde6dcb..034114ae6ca 100644 --- a/jdk/make/data/tzdata/VERSION +++ b/jdk/make/data/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2014j +tzdata2015a diff --git a/jdk/make/data/tzdata/antarctica b/jdk/make/data/tzdata/antarctica index 0cdac270861..1f3e4347b21 100644 --- a/jdk/make/data/tzdata/antarctica +++ b/jdk/make/data/tzdata/antarctica @@ -70,8 +70,8 @@ Rule ChileAQ 2009 only - Mar Sun>=9 3:00u 0 - Rule ChileAQ 2010 only - Apr Sun>=1 3:00u 0 - Rule ChileAQ 2011 only - May Sun>=2 3:00u 0 - Rule ChileAQ 2011 only - Aug Sun>=16 4:00u 1:00 S -Rule ChileAQ 2012 max - Apr Sun>=23 3:00u 0 - -Rule ChileAQ 2012 max - Sep Sun>=2 4:00u 1:00 S +Rule ChileAQ 2012 2015 - Apr Sun>=23 3:00u 0 - +Rule ChileAQ 2012 2014 - Sep Sun>=2 4:00u 1:00 S # Argentina - year-round bases # Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05 @@ -377,9 +377,10 @@ Zone Antarctica/Rothera 0 - zzz 1976 Dec 1 # # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Antarctica/Palmer 0 - zzz 1965 - -4:00 ArgAQ AR%sT 1969 Oct 5 + -4:00 ArgAQ AR%sT 1969 Oct 5 -3:00 ArgAQ AR%sT 1982 May - -4:00 ChileAQ CL%sT + -4:00 ChileAQ CL%sT 2015 Apr 26 3:00u + -3:00 - CLT # # # McMurdo Station, Ross Island, since 1955-12 diff --git a/jdk/make/data/tzdata/asia b/jdk/make/data/tzdata/asia index 960cab5062e..bff837c48d8 100644 --- a/jdk/make/data/tzdata/asia +++ b/jdk/make/data/tzdata/asia @@ -168,10 +168,7 @@ Zone Asia/Baku 3:19:24 - LMT 1924 May 2 4:00 Azer AZ%sT # Bahrain -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Bahrain 3:22:20 - LMT 1920 # Manamah - 4:00 - GST 1972 Jun - 3:00 - AST +# See Asia/Qatar. # Bangladesh # From Alexander Krivenyshev (2009-05-13): @@ -1754,9 +1751,7 @@ Zone Asia/Pyongyang 8:23:00 - LMT 1908 Apr 1 ############################################################################### # Kuwait -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Kuwait 3:11:56 - LMT 1950 - 3:00 - AST +# See Asia/Riyadh. # Laos # See Asia/Bangkok. @@ -1977,12 +1972,7 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920 5:45 - NPT # Nepal Time # Oman - -# Milne says 3:54:24 was the meridian of the Muscat Tidal Observatory. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Muscat 3:54:24 - LMT 1920 - 4:00 - GST +# See Asia/Dubai. # Pakistan @@ -2476,6 +2466,7 @@ Zone Asia/Manila -15:56:00 - LMT 1844 Dec 31 Zone Asia/Qatar 3:26:08 - LMT 1920 # Al Dawhah / Doha 4:00 - GST 1972 Jun 3:00 - AST +Link Asia/Qatar Asia/Bahrain # Saudi Arabia # @@ -2502,6 +2493,8 @@ Zone Asia/Qatar 3:26:08 - LMT 1920 # Al Dawhah / Doha # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Riyadh 3:06:52 - LMT 1947 Mar 14 3:00 - AST +Link Asia/Riyadh Asia/Aden # Yemen +Link Asia/Riyadh Asia/Kuwait # Singapore # taken from Mok Ly Yng (2003-10-30) @@ -2790,6 +2783,7 @@ Zone Asia/Ashgabat 3:53:32 - LMT 1924 May 2 # or Ashkhabad # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Dubai 3:41:12 - LMT 1920 4:00 - GST +Link Asia/Dubai Asia/Muscat # Oman # Uzbekistan # Byalokoz 1919 says Uzbekistan was 4:27:53. @@ -2874,10 +2868,4 @@ Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jul 1 7:00 - ICT # Yemen - -# Milne says 2:59:54 was the meridian of the saluting battery at Aden, -# and that Yemen was at 1:55:56, the meridian of the Hagia Sophia. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Aden 2:59:54 - LMT 1950 - 3:00 - AST +# See Asia/Riyadh. diff --git a/jdk/make/data/tzdata/backward b/jdk/make/data/tzdata/backward index ba012f45733..95266a6f16c 100644 --- a/jdk/make/data/tzdata/backward +++ b/jdk/make/data/tzdata/backward @@ -28,7 +28,7 @@ # and their old names. Many names changed in late 1993. # Link TARGET LINK-NAME -Link Africa/Asmara Africa/Asmera +Link Africa/Nairobi Africa/Asmera Link Africa/Abidjan Africa/Timbuktu Link America/Argentina/Catamarca America/Argentina/ComodRivadavia Link America/Adak America/Atka diff --git a/jdk/make/data/tzdata/europe b/jdk/make/data/tzdata/europe index 2ed6ad36b5d..89790f06c17 100644 --- a/jdk/make/data/tzdata/europe +++ b/jdk/make/data/tzdata/europe @@ -1430,35 +1430,32 @@ Zone Europe/Budapest 1:16:20 - LMT 1890 Oct # might be a reference to the Julian calendar as opposed to Gregorian, or it # might mean something else (???). # -# From Paul Eggert (2006-03-22): -# The Iceland Almanak, Shanks & Pottenger, and Whitman disagree on many points. -# We go with the Almanak, except for one claim from Shanks & Pottenger, namely -# that Reykavik was 21W57 from 1837 to 1908, local mean time before that. +# From Paul Eggert (2014-11-22): +# The information below is taken from the 1988 Almanak; see +# http://www.almanak.hi.is/klukkan.html # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Iceland 1917 1918 - Feb 19 23:00 1:00 S +Rule Iceland 1917 1919 - Feb 19 23:00 1:00 S Rule Iceland 1917 only - Oct 21 1:00 0 - -Rule Iceland 1918 only - Nov 16 1:00 0 - +Rule Iceland 1918 1919 - Nov 16 1:00 0 - +Rule Iceland 1921 only - Mar 19 23:00 1:00 S +Rule Iceland 1921 only - Jun 23 1:00 0 - Rule Iceland 1939 only - Apr 29 23:00 1:00 S -Rule Iceland 1939 only - Nov 29 2:00 0 - +Rule Iceland 1939 only - Oct 29 2:00 0 - Rule Iceland 1940 only - Feb 25 2:00 1:00 S -Rule Iceland 1940 only - Nov 3 2:00 0 - -Rule Iceland 1941 only - Mar 2 1:00s 1:00 S -Rule Iceland 1941 only - Nov 2 1:00s 0 - -Rule Iceland 1942 only - Mar 8 1:00s 1:00 S -Rule Iceland 1942 only - Oct 25 1:00s 0 - +Rule Iceland 1940 1941 - Nov Sun>=2 1:00s 0 - +Rule Iceland 1941 1942 - Mar Sun>=2 1:00s 1:00 S # 1943-1946 - first Sunday in March until first Sunday in winter Rule Iceland 1943 1946 - Mar Sun>=1 1:00s 1:00 S -Rule Iceland 1943 1948 - Oct Sun>=22 1:00s 0 - +Rule Iceland 1942 1948 - Oct Sun>=22 1:00s 0 - # 1947-1967 - first Sunday in April until first Sunday in winter Rule Iceland 1947 1967 - Apr Sun>=1 1:00s 1:00 S -# 1949 Oct transition delayed by 1 week +# 1949 and 1967 Oct transitions delayed by 1 week Rule Iceland 1949 only - Oct 30 1:00s 0 - Rule Iceland 1950 1966 - Oct Sun>=22 1:00s 0 - Rule Iceland 1967 only - Oct 29 1:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Atlantic/Reykjavik -1:27:24 - LMT 1837 - -1:27:48 - RMT 1908 # Reykjavik Mean Time? +Zone Atlantic/Reykjavik -1:28 - LMT 1908 -1:00 Iceland IS%sT 1968 Apr 7 1:00s 0:00 - GMT diff --git a/jdk/make/data/tzdata/leapseconds b/jdk/make/data/tzdata/leapseconds index 7612f2bc9b7..9b0a2278433 100644 --- a/jdk/make/data/tzdata/leapseconds +++ b/jdk/make/data/tzdata/leapseconds @@ -77,3 +77,7 @@ Leap 1998 Dec 31 23:59:60 + S Leap 2005 Dec 31 23:59:60 + S Leap 2008 Dec 31 23:59:60 + S Leap 2012 Jun 30 23:59:60 + S +Leap 2015 Jun 30 23:59:60 + S + +# Updated through IERS Bulletin C49 +# File expires on: 28 December 2015 diff --git a/jdk/make/data/tzdata/northamerica b/jdk/make/data/tzdata/northamerica index 86c9503a4eb..5943cfeec4b 100644 --- a/jdk/make/data/tzdata/northamerica +++ b/jdk/make/data/tzdata/northamerica @@ -147,7 +147,7 @@ Rule US 1918 1919 - Mar lastSun 2:00 1:00 D Rule US 1918 1919 - Oct lastSun 2:00 0 S Rule US 1942 only - Feb 9 2:00 1:00 W # War Rule US 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule US 1945 only - Sep 30 2:00 0 S +Rule US 1945 only - Sep lastSun 2:00 0 S Rule US 1967 2006 - Oct lastSun 2:00 0 S Rule US 1967 1973 - Apr lastSun 2:00 1:00 D Rule US 1974 only - Jan 6 2:00 1:00 D @@ -2147,11 +2147,11 @@ Zone America/Dawson -9:17:40 - LMT 1900 Aug 20 # Mexico -# From Paul Eggert (2001-03-05): +# From Paul Eggert (2014-12-07): # The Investigation and Analysis Service of the # Mexican Library of Congress (MLoC) has published a # history of Mexican local time (in Spanish) -# http://www.cddhcu.gob.mx/bibliot/publica/inveyana/polisoc/horver/ +# http://www.diputados.gob.mx/bibliot/publica/inveyana/polisoc/horver/index.htm # # Here are the discrepancies between Shanks & Pottenger (S&P) and the MLoC. # (In all cases we go with the MLoC.) @@ -2320,6 +2320,24 @@ Zone America/Dawson -9:17:40 - LMT 1900 Aug 20 # efecto desde las dos horas del segundo domingo de marzo y concluirá a # las dos horas del primer domingo de noviembre. +# From Steffen Thorsen (2014-12-08), translated by Gwillim Law: +# The Mexican state of Quintana Roo will likely change to EST in 2015. +# +# http://www.unioncancun.mx/articulo/2014/12/04/medio-ambiente/congreso-aprueba-una-hora-mas-de-sol-en-qroo +# "With this change, the time conflict that has existed between the municipios +# of Quintana Roo and the municipio of Felipe Carrillo Puerto may come to an +# end. The latter declared itself in rebellion 15 years ago when a time change +# was initiated in Mexico, and since then it has refused to change its time +# zone along with the rest of the country." +# +# From Steffen Thorsen (2015-01-14), translated by Gwillim Law: +# http://sipse.com/novedades/confirman-aplicacion-de-nueva-zona-horaria-para-quintana-roo-132331.html +# "...the new time zone will come into effect at two o'clock on the first Sunday +# of February, when we will have to advance the clock one hour from its current +# time..." +# +# Also, the new zone will not use DST. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Mexico 1939 only - Feb 5 0:00 1:00 D Rule Mexico 1939 only - Jun 25 0:00 0 S @@ -2340,7 +2358,8 @@ Rule Mexico 2002 max - Oct lastSun 2:00 0 S Zone America/Cancun -5:47:04 - LMT 1922 Jan 1 0:12:56 -6:00 - CST 1981 Dec 23 -5:00 Mexico E%sT 1998 Aug 2 2:00 - -6:00 Mexico C%sT + -6:00 Mexico C%sT 2015 Feb 1 2:00 + -5:00 - EST # Campeche, Yucatán; represented by Mérida Zone America/Merida -5:58:28 - LMT 1922 Jan 1 0:01:32 -6:00 - CST 1981 Dec 23 diff --git a/jdk/make/data/tzdata/southamerica b/jdk/make/data/tzdata/southamerica index 0b70dea5616..02cf12113a0 100644 --- a/jdk/make/data/tzdata/southamerica +++ b/jdk/make/data/tzdata/southamerica @@ -1229,6 +1229,11 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC) # http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf +# From Juan Correa (2015-01-28): +# ... today the Ministry of Energy announced that Chile will drop DST, will keep +# "summer time" (UTC -3 / UTC -5) all year round.... +# http://www.minenergia.cl/ministerio/noticias/generales/ministerio-de-energia-anuncia.html + # NOTE: ChileAQ rules for Antarctic bases are stored separately in the # 'antarctica' file. @@ -1270,8 +1275,8 @@ Rule Chile 2009 only - Mar Sun>=9 3:00u 0 - Rule Chile 2010 only - Apr Sun>=1 3:00u 0 - Rule Chile 2011 only - May Sun>=2 3:00u 0 - Rule Chile 2011 only - Aug Sun>=16 4:00u 1:00 S -Rule Chile 2012 max - Apr Sun>=23 3:00u 0 - -Rule Chile 2012 max - Sep Sun>=2 4:00u 1:00 S +Rule Chile 2012 2015 - Apr Sun>=23 3:00u 0 - +Rule Chile 2012 2014 - Sep Sun>=2 4:00u 1:00 S # IATA SSIM anomalies: (1992-02) says 1992-03-14; # (1996-09) says 1998-03-08. Ignore these. # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -1282,11 +1287,13 @@ Zone America/Santiago -4:42:46 - LMT 1890 -4:00 - CLT 1919 Jul 1 # Chile Time -4:42:46 - SMT 1927 Sep 1 # Santiago Mean Time -5:00 Chile CL%sT 1947 May 22 # Chile Time - -4:00 Chile CL%sT + -4:00 Chile CL%sT 2015 Apr 26 3:00u + -3:00 - CLT Zone Pacific/Easter -7:17:44 - LMT 1890 -7:17:28 - EMT 1932 Sep # Easter Mean Time - -7:00 Chile EAS%sT 1982 Mar 13 21:00 # Easter Time - -6:00 Chile EAS%sT + -7:00 Chile EAS%sT 1982 Mar 13 3:00u # Easter Time + -6:00 Chile EAS%sT 2015 Apr 26 3:00u + -5:00 - EAST # # Salas y Gómez Island is uninhabited. # Other Chilean locations, including Juan Fernández Is, Desventuradas Is, diff --git a/jdk/make/data/tzdata/zone.tab b/jdk/make/data/tzdata/zone.tab index 0ef9ba869ea..ffb6469676e 100644 --- a/jdk/make/data/tzdata/zone.tab +++ b/jdk/make/data/tzdata/zone.tab @@ -297,7 +297,7 @@ MU -2010+05730 Indian/Mauritius MV +0410+07330 Indian/Maldives MW -1547+03500 Africa/Blantyre MX +1924-09909 America/Mexico_City Central Time - most locations -MX +2105-08646 America/Cancun Central Time - Quintana Roo +MX +2105-08646 America/Cancun Eastern Standard Time - Quintana Roo MX +2058-08937 America/Merida Central Time - Campeche, Yucatan MX +2540-10019 America/Monterrey Mexican Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas away from US border MX +2550-09730 America/Matamoros US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas near US border diff --git a/jdk/make/src/classes/build/tools/module/boot.modules b/jdk/make/src/classes/build/tools/module/boot.modules index 9763b9287d4..d51fbfb4913 100644 --- a/jdk/make/src/classes/build/tools/module/boot.modules +++ b/jdk/make/src/classes/build/tools/module/boot.modules @@ -11,7 +11,6 @@ java.naming java.prefs java.rmi java.scripting -java.security.acl java.security.jgss java.security.sasl java.smartcardio diff --git a/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c b/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c index 802d8742dee..eb432c12e08 100644 --- a/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c +++ b/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -1059,6 +1059,7 @@ JVMInit(InvocationFunctions* ifn, jlong threadStackSize, void PostJVMInit(JNIEnv *env, jstring mainClass, JavaVM *vm) { jvmInstance = vm; SetMainClassForAWT(env, mainClass); + CHECK_EXCEPTION_RETURN(); ShowSplashScreen(); } diff --git a/jdk/src/java.base/share/classes/java/lang/Number.java b/jdk/src/java.base/share/classes/java/lang/Number.java index b89ed7190f0..019ed9c56c3 100644 --- a/jdk/src/java.base/share/classes/java/lang/Number.java +++ b/jdk/src/java.base/share/classes/java/lang/Number.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2015, 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,7 +37,7 @@ package java.lang; * * For platform classes, the conversion is often analogous to a * narrowing primitive conversion or a widening primitive conversion - * as defining in The Java™ Language Specification + * as defined in The Java™ Language Specification * for converting between primitive types. Therefore, conversions may * lose information about the overall magnitude of a numeric value, may * lose precision, and may even return a result of a different sign @@ -54,8 +54,7 @@ package java.lang; */ public abstract class Number implements java.io.Serializable { /** - * Returns the value of the specified number as an {@code int}, - * which may involve rounding or truncation. + * Returns the value of the specified number as an {@code int}. * * @return the numeric value represented by this object after conversion * to type {@code int}. @@ -63,8 +62,7 @@ public abstract class Number implements java.io.Serializable { public abstract int intValue(); /** - * Returns the value of the specified number as a {@code long}, - * which may involve rounding or truncation. + * Returns the value of the specified number as a {@code long}. * * @return the numeric value represented by this object after conversion * to type {@code long}. @@ -72,8 +70,7 @@ public abstract class Number implements java.io.Serializable { public abstract long longValue(); /** - * Returns the value of the specified number as a {@code float}, - * which may involve rounding. + * Returns the value of the specified number as a {@code float}. * * @return the numeric value represented by this object after conversion * to type {@code float}. @@ -81,8 +78,7 @@ public abstract class Number implements java.io.Serializable { public abstract float floatValue(); /** - * Returns the value of the specified number as a {@code double}, - * which may involve rounding. + * Returns the value of the specified number as a {@code double}. * * @return the numeric value represented by this object after conversion * to type {@code double}. @@ -90,8 +86,7 @@ public abstract class Number implements java.io.Serializable { public abstract double doubleValue(); /** - * Returns the value of the specified number as a {@code byte}, - * which may involve rounding or truncation. + * Returns the value of the specified number as a {@code byte}. * *

This implementation returns the result of {@link #intValue} cast * to a {@code byte}. @@ -105,8 +100,7 @@ public abstract class Number implements java.io.Serializable { } /** - * Returns the value of the specified number as a {@code short}, - * which may involve rounding or truncation. + * Returns the value of the specified number as a {@code short}. * *

This implementation returns the result of {@link #intValue} cast * to a {@code short}. diff --git a/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java b/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java index 8d4576bd40c..a62594383fc 100644 --- a/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java +++ b/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java @@ -951,6 +951,9 @@ public final class ProcessBuilder * {@code command} array as its argument. This may result in * a {@link SecurityException} being thrown. * + *

If the operating system does not support the creation of + * processes, an {@link UnsupportedOperationException} will be thrown. + * *

Starting an operating system process is highly system-dependent. * Among the many things that can go wrong are: *

* + * @throws UnsupportedOperationException + * If the operating system does not support the creation of processes. + * * @throws IOException if an I/O error occurs * * @see Runtime#exec(String[], String[], java.io.File) diff --git a/jdk/src/java.base/share/classes/java/lang/Runtime.java b/jdk/src/java.base/share/classes/java/lang/Runtime.java index 66c78537d39..98bfe2887b5 100644 --- a/jdk/src/java.base/share/classes/java/lang/Runtime.java +++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java @@ -564,6 +564,9 @@ public class Runtime { * cmdarray as its argument. This may result in a * {@link SecurityException} being thrown. * + *

If the operating system does not support the creation of + * processes, an {@link UnsupportedOperationException} will be thrown. + * *

Starting an operating system process is highly system-dependent. * Among the many things that can go wrong are: *

*

* Multiple calendar systems is an awkward addition to the design challenges. - * The first principal is that most users want the standard ISO calendar system. - * As such, the main classes are ISO-only. The second principal is that most of those that want a + * The first principle is that most users want the standard ISO calendar system. + * As such, the main classes are ISO-only. The second principle is that most of those that want a * non-ISO calendar system want it for user interaction, thus it is a UI localization issue. * As such, date and time objects should be held as ISO objects in the data model and persistent * storage, only being converted to and from a local calendar for display. diff --git a/jdk/src/java.base/share/classes/java/util/Formatter.java b/jdk/src/java.base/share/classes/java/util/Formatter.java index ef07fcaef34..9344d15051f 100644 --- a/jdk/src/java.base/share/classes/java/util/Formatter.java +++ b/jdk/src/java.base/share/classes/java/util/Formatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, 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,7 @@ import java.time.ZoneOffset; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQueries; +import java.time.temporal.UnsupportedTemporalTypeException; import sun.misc.DoubleConsts; import sun.misc.FormattedFloatingDecimal; @@ -4056,7 +4057,12 @@ public final class Formatter implements Closeable, Flushable { break; } case DateTime.NANOSECOND: { // 'N' (000000000 - 999999999) - int i = t.get(ChronoField.MILLI_OF_SECOND) * 1000000; + int i; + try { + i = t.get(ChronoField.NANO_OF_SECOND); + } catch (UnsupportedTemporalTypeException u) { + i = t.get(ChronoField.MILLI_OF_SECOND) * 1000000; + } Flags flags = Flags.ZERO_PAD; sb.append(localizedMagnitude(null, i, flags, 9, l)); break; diff --git a/jdk/src/java.base/share/classes/java/util/Optional.java b/jdk/src/java.base/share/classes/java/util/Optional.java index d471058ec16..eb8301b2361 100644 --- a/jdk/src/java.base/share/classes/java/util/Optional.java +++ b/jdk/src/java.base/share/classes/java/util/Optional.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -28,6 +28,7 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; +import java.util.stream.Stream; /** * A container object which may or may not contain a non-null value. @@ -155,8 +156,9 @@ public final class Optional { * null */ public void ifPresent(Consumer consumer) { - if (value != null) + if (value != null) { consumer.accept(value); + } } /** @@ -172,10 +174,11 @@ public final class Optional { */ public Optional filter(Predicate predicate) { Objects.requireNonNull(predicate); - if (!isPresent()) + if (!isPresent()) { return this; - else + } else { return predicate.test(value) ? this : empty(); + } } /** @@ -209,9 +212,9 @@ public final class Optional { */ public Optional map(Function mapper) { Objects.requireNonNull(mapper); - if (!isPresent()) + if (!isPresent()) { return empty(); - else { + } else { return Optional.ofNullable(mapper.apply(value)); } } @@ -235,13 +238,36 @@ public final class Optional { */ public Optional flatMap(Function> mapper) { Objects.requireNonNull(mapper); - if (!isPresent()) + if (!isPresent()) { return empty(); - else { + } else { return Objects.requireNonNull(mapper.apply(value)); } } + /** + * If a value is present return a sequential {@link Stream} containing only + * that value, otherwise return an empty {@code Stream}. + * + * @apiNote This method can be used to transform a {@code Stream} of + * optional elements to a {@code Stream} of present value elements: + * + *

{@code
+     *     Stream> os = ..
+     *     Stream s = os.flatMap(Optional::stream)
+     * }
+ * + * @return the optional value as a {@code Stream} + * @since 1.9 + */ + public Stream stream() { + if (!isPresent()) { + return Stream.empty(); + } else { + return Stream.of(value); + } + } + /** * Return the value if present, otherwise return {@code other}. * diff --git a/jdk/src/java.base/share/classes/java/util/OptionalDouble.java b/jdk/src/java.base/share/classes/java/util/OptionalDouble.java index 0efc770fa03..e699c53d517 100644 --- a/jdk/src/java.base/share/classes/java/util/OptionalDouble.java +++ b/jdk/src/java.base/share/classes/java/util/OptionalDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -27,6 +27,7 @@ package java.util; import java.util.function.DoubleConsumer; import java.util.function.DoubleSupplier; import java.util.function.Supplier; +import java.util.stream.DoubleStream; /** * A container object which may or may not contain a {@code double} value. @@ -138,8 +139,32 @@ public final class OptionalDouble { * null */ public void ifPresent(DoubleConsumer consumer) { - if (isPresent) + if (isPresent) { consumer.accept(value); + } + } + + /** + * If a value is present return a sequential {@link DoubleStream} containing + * only that value, otherwise return an empty {@code DoubleStream}. + * + * @apiNote This method can be used to transform a {@code Stream} of + * optional doubles to a {@code DoubleStream} of present doubles: + * + *
{@code
+     *     Stream os = ..
+     *     DoubleStream s = os.flatMapToDouble(OptionalDouble::stream)
+     * }
+ * + * @return the optional value as a {@code DoubleStream} + * @since 1.9 + */ + public DoubleStream stream() { + if (isPresent) { + return DoubleStream.of(value); + } else { + return DoubleStream.empty(); + } } /** @@ -182,7 +207,7 @@ public final class OptionalDouble { * @throws NullPointerException if no value is present and * {@code exceptionSupplier} is null */ - public double orElseThrow(Supplier exceptionSupplier) throws X { + public double orElseThrow(Supplier exceptionSupplier) throws X { if (isPresent) { return value; } else { diff --git a/jdk/src/java.base/share/classes/java/util/OptionalInt.java b/jdk/src/java.base/share/classes/java/util/OptionalInt.java index 5cb9275242b..d8d9382633d 100644 --- a/jdk/src/java.base/share/classes/java/util/OptionalInt.java +++ b/jdk/src/java.base/share/classes/java/util/OptionalInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -27,6 +27,7 @@ package java.util; import java.util.function.IntConsumer; import java.util.function.IntSupplier; import java.util.function.Supplier; +import java.util.stream.IntStream; /** * A container object which may or may not contain a {@code int} value. @@ -138,8 +139,32 @@ public final class OptionalInt { * null */ public void ifPresent(IntConsumer consumer) { - if (isPresent) + if (isPresent) { consumer.accept(value); + } + } + + /** + * If a value is present return a sequential {@link IntStream} containing + * only that value, otherwise return an empty {@code IntStream}. + * + * @apiNote This method can be used to transform a {@code Stream} of + * optional integers to an {@code IntStream} of present integers: + * + *
{@code
+     *     Stream os = ..
+     *     IntStream s = os.flatMapToInt(OptionalInt::stream)
+     * }
+ * + * @return the optional value as an {@code IntStream} + * @since 1.9 + */ + public IntStream stream() { + if (isPresent) { + return IntStream.of(value); + } else { + return IntStream.empty(); + } } /** @@ -182,7 +207,7 @@ public final class OptionalInt { * @throws NullPointerException if no value is present and * {@code exceptionSupplier} is null */ - public int orElseThrow(Supplier exceptionSupplier) throws X { + public int orElseThrow(Supplier exceptionSupplier) throws X { if (isPresent) { return value; } else { diff --git a/jdk/src/java.base/share/classes/java/util/OptionalLong.java b/jdk/src/java.base/share/classes/java/util/OptionalLong.java index 589a59fd3ae..4e2a44873b3 100644 --- a/jdk/src/java.base/share/classes/java/util/OptionalLong.java +++ b/jdk/src/java.base/share/classes/java/util/OptionalLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -27,6 +27,7 @@ package java.util; import java.util.function.LongConsumer; import java.util.function.LongSupplier; import java.util.function.Supplier; +import java.util.stream.LongStream; /** * A container object which may or may not contain a {@code long} value. @@ -138,8 +139,32 @@ public final class OptionalLong { * null */ public void ifPresent(LongConsumer consumer) { - if (isPresent) + if (isPresent) { consumer.accept(value); + } + } + + /** + * If a value is present return a sequential {@link LongStream} containing + * only that value, otherwise return an empty {@code LongStream}. + * + * @apiNote This method can be used to transform a {@code Stream} of + * optional longs to a {@code LongStream} of present longs: + * + *
{@code
+     *     Stream os = ..
+     *     LongStream s = os.flatMapToLong(OptionalLong::stream)
+     * }
+ * + * @return the optional value as a {@code LongStream} + * @since 1.9 + */ + public LongStream stream() { + if (isPresent) { + return LongStream.of(value); + } else { + return LongStream.empty(); + } } /** @@ -182,7 +207,7 @@ public final class OptionalLong { * @throws NullPointerException if no value is present and * {@code exceptionSupplier} is null */ - public long orElseThrow(Supplier exceptionSupplier) throws X { + public long orElseThrow(Supplier exceptionSupplier) throws X { if (isPresent) { return value; } else { diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java b/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java index e5c007d8c5f..7a8e40b9e43 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java @@ -131,6 +131,7 @@ public enum TimeUnit { /** * Time unit representing sixty seconds + * @since 1.6 */ MINUTES { public long toNanos(long d) { return x(d, C4/C0, MAX/(C4/C0)); } @@ -146,6 +147,7 @@ public enum TimeUnit { /** * Time unit representing sixty minutes + * @since 1.6 */ HOURS { public long toNanos(long d) { return x(d, C5/C0, MAX/(C5/C0)); } @@ -161,6 +163,7 @@ public enum TimeUnit { /** * Time unit representing twenty four hours + * @since 1.6 */ DAYS { public long toNanos(long d) { return x(d, C6/C0, MAX/(C6/C0)); } diff --git a/jdk/src/java.base/share/classes/java/util/stream/BaseStream.java b/jdk/src/java.base/share/classes/java/util/stream/BaseStream.java index 61e74867a19..0328b25cafd 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/BaseStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/BaseStream.java @@ -79,6 +79,14 @@ public interface BaseStream> *

This is a terminal * operation. * + *

+ * The returned spliterator should report the set of characteristics derived + * from the stream pipeline (namely the characteristics derived from the + * stream source spliterator and the intermediate operations). + * Implementations may report a sub-set of those characteristics. For + * example, it may be too expensive to compute the entire set for some or + * all possible stream pipelines. + * * @return the element spliterator for this stream */ Spliterator spliterator(); diff --git a/jdk/src/java.base/share/classes/sun/misc/VM.java b/jdk/src/java.base/share/classes/sun/misc/VM.java index c877e40446f..36bfb606495 100644 --- a/jdk/src/java.base/share/classes/sun/misc/VM.java +++ b/jdk/src/java.base/share/classes/sun/misc/VM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2015, 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 @@ -402,6 +402,36 @@ public class VM { */ public static native long getegid(); + /** + * Get a nanosecond time stamp adjustment in the form of a single long. + * + * This value can be used to create an instant using + * {@link java.time.Instant#ofEpochSecond(long, long) + * java.time.Instant.ofEpochSecond(offsetInSeconds, + * getNanoTimeAdjustment(offsetInSeconds))}. + *

+ * The value returned has the best resolution available to the JVM on + * the current system. + * This is usually down to microseconds - or tenth of microseconds - + * depending on the OS/Hardware and the JVM implementation. + * + * @param offsetInSeconds The offset in seconds from which the nanosecond + * time stamp should be computed. + * + * @apiNote The offset should be recent enough - so that + * {@code offsetInSeconds} is within {@code +/- 2^32} seconds of the + * current UTC time. If the offset is too far off, {@code -1} will be + * returned. As such, {@code -1} must not be considered as a valid + * nano time adjustment, but as an exception value indicating + * that an offset closer to the current time should be used. + * + * @return A nanosecond time stamp adjustment in the form of a single long. + * If the offset is too far off the current time, this method returns -1. + * In that case, the caller should call this method again, passing a + * more accurate offset. + */ + public static native long getNanoTimeAdjustment(long offsetInSeconds); + static { initialize(); } diff --git a/jdk/src/java.security.acl/share/classes/sun/security/acl/AclEntryImpl.java b/jdk/src/java.base/share/classes/sun/security/acl/AclEntryImpl.java similarity index 100% rename from jdk/src/java.security.acl/share/classes/sun/security/acl/AclEntryImpl.java rename to jdk/src/java.base/share/classes/sun/security/acl/AclEntryImpl.java diff --git a/jdk/src/java.security.acl/share/classes/sun/security/acl/AclImpl.java b/jdk/src/java.base/share/classes/sun/security/acl/AclImpl.java similarity index 100% rename from jdk/src/java.security.acl/share/classes/sun/security/acl/AclImpl.java rename to jdk/src/java.base/share/classes/sun/security/acl/AclImpl.java diff --git a/jdk/src/java.security.acl/share/classes/sun/security/acl/AllPermissionsImpl.java b/jdk/src/java.base/share/classes/sun/security/acl/AllPermissionsImpl.java similarity index 100% rename from jdk/src/java.security.acl/share/classes/sun/security/acl/AllPermissionsImpl.java rename to jdk/src/java.base/share/classes/sun/security/acl/AllPermissionsImpl.java diff --git a/jdk/src/java.security.acl/share/classes/sun/security/acl/GroupImpl.java b/jdk/src/java.base/share/classes/sun/security/acl/GroupImpl.java similarity index 100% rename from jdk/src/java.security.acl/share/classes/sun/security/acl/GroupImpl.java rename to jdk/src/java.base/share/classes/sun/security/acl/GroupImpl.java diff --git a/jdk/src/java.security.acl/share/classes/sun/security/acl/OwnerImpl.java b/jdk/src/java.base/share/classes/sun/security/acl/OwnerImpl.java similarity index 100% rename from jdk/src/java.security.acl/share/classes/sun/security/acl/OwnerImpl.java rename to jdk/src/java.base/share/classes/sun/security/acl/OwnerImpl.java diff --git a/jdk/src/java.security.acl/share/classes/sun/security/acl/PermissionImpl.java b/jdk/src/java.base/share/classes/sun/security/acl/PermissionImpl.java similarity index 100% rename from jdk/src/java.security.acl/share/classes/sun/security/acl/PermissionImpl.java rename to jdk/src/java.base/share/classes/sun/security/acl/PermissionImpl.java diff --git a/jdk/src/java.security.acl/share/classes/sun/security/acl/PrincipalImpl.java b/jdk/src/java.base/share/classes/sun/security/acl/PrincipalImpl.java similarity index 100% rename from jdk/src/java.security.acl/share/classes/sun/security/acl/PrincipalImpl.java rename to jdk/src/java.base/share/classes/sun/security/acl/PrincipalImpl.java diff --git a/jdk/src/java.security.acl/share/classes/sun/security/acl/WorldGroupImpl.java b/jdk/src/java.base/share/classes/sun/security/acl/WorldGroupImpl.java similarity index 100% rename from jdk/src/java.security.acl/share/classes/sun/security/acl/WorldGroupImpl.java rename to jdk/src/java.base/share/classes/sun/security/acl/WorldGroupImpl.java diff --git a/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java b/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java index 679a5c10033..75efc60e0db 100644 --- a/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java +++ b/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2015, 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 @@ -408,7 +408,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"Venezuela Time", "VET", "Venezuela Summer Time", "VEST", "Venezuela Time", "VET"}}, diff --git a/jdk/src/java.base/share/native/include/jvm.h b/jdk/src/java.base/share/native/include/jvm.h index 514378df9b2..7177f2e1d1e 100644 --- a/jdk/src/java.base/share/native/include/jvm.h +++ b/jdk/src/java.base/share/native/include/jvm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -104,6 +104,9 @@ JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored); JNIEXPORT jlong JNICALL JVM_NanoTime(JNIEnv *env, jclass ignored); +JNIEXPORT jlong JNICALL +JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs); + JNIEXPORT void JNICALL JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length); diff --git a/jdk/src/java.base/share/native/libjava/VM.c b/jdk/src/java.base/share/native/libjava/VM.c index 1968a06b01b..14fd1a63487 100644 --- a/jdk/src/java.base/share/native/libjava/VM.c +++ b/jdk/src/java.base/share/native/libjava/VM.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2015, 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 @@ -33,6 +33,11 @@ #include "sun_misc_VM.h" +/* Only register the performance-critical methods */ +static JNINativeMethod methods[] = { + {"getNanoTimeAdjustment", "(J)J", (void *)&JVM_GetNanoTimeAdjustment} +}; + JNIEXPORT jobject JNICALL Java_sun_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) { return JVM_LatestUserDefinedLoader(env); @@ -49,6 +54,14 @@ Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) { return; } + // Registers implementations of native methods described in methods[] + // above. + // In particular, registers JVM_GetNanoTimeAdjustment as the implementation + // of the native sun.misc.VM.getNanoTimeAdjustment - avoiding the cost of + // introducing a Java_sun_misc_VM_getNanoTimeAdjustment wrapper + (*env)->RegisterNatives(env, cls, + methods, sizeof(methods)/sizeof(methods[0])); + func_p = (GetJvmVersionInfo_fp) JDK_FindJvmEntry("JVM_GetVersionInfo"); if (func_p != NULL) { jvm_version_info info; diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c index 2f1e7e17971..d988ac3cec2 100644 --- a/jdk/src/java.base/share/native/libjli/java.c +++ b/jdk/src/java.base/share/native/libjli/java.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2015, 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 @@ -350,12 +350,6 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ } \ } while (JNI_FALSE) -#define CHECK_EXCEPTION_RETURN() \ - do { \ - if ((*env)->ExceptionOccurred(env)) { \ - return; \ - } \ - } while (JNI_FALSE) int JNICALL JavaMain(void * _args) @@ -466,6 +460,7 @@ JavaMain(void * _args) * of the application class. */ PostJVMInit(env, appClass, vm); + CHECK_EXCEPTION_LEAVE(1); /* * The LoadMainClass not only loads the main class, it will also ensure * that the main method's signature is correct, therefore further checking diff --git a/jdk/src/java.base/share/native/libjli/java.h b/jdk/src/java.base/share/native/libjli/java.h index 615b16cd9c3..5cc7608b566 100644 --- a/jdk/src/java.base/share/native/libjli/java.h +++ b/jdk/src/java.base/share/native/libjli/java.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, 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 @@ -254,4 +254,11 @@ typedef struct { #define NULL_CHECK(NC_check_pointer) \ NULL_CHECK_RETURN_VALUE(NC_check_pointer, ) +#define CHECK_EXCEPTION_RETURN() \ + do { \ + if ((*env)->ExceptionOccurred(env)) { \ + return; \ + } \ + } while (JNI_FALSE) + #endif /* _JAVA_H_ */ diff --git a/jdk/src/java.management/share/classes/META-INF/services/sun.management.spi.PlatformMBeanProvider b/jdk/src/java.management/share/classes/META-INF/services/sun.management.spi.PlatformMBeanProvider new file mode 100644 index 00000000000..a5611e80f23 --- /dev/null +++ b/jdk/src/java.management/share/classes/META-INF/services/sun.management.spi.PlatformMBeanProvider @@ -0,0 +1,25 @@ +# +# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# +com.sun.management.internal.PlatformMBeanProviderImpl diff --git a/jdk/src/java.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java b/jdk/src/java.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java new file mode 100644 index 00000000000..42d41b65992 --- /dev/null +++ b/jdk/src/java.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.management.internal; + +import java.lang.management.ManagementFactory; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.management.DynamicMBean; +import javax.management.ObjectName; +import sun.management.ManagementFactoryHelper; +import sun.management.spi.PlatformMBeanProvider; + +public final class PlatformMBeanProviderImpl extends PlatformMBeanProvider { + private final List> mxbeanList; + + public PlatformMBeanProviderImpl() { + mxbeanList = Collections.unmodifiableList(init()); + } + + @Override + public List> getPlatformComponentList() { + return mxbeanList; + } + + private List> init() { + ArrayList> initMBeanList = new ArrayList<>(); + /** + * Garbage Collector in the Java virtual machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set garbageCollectorMXBeanInterfaceNames + = Collections.unmodifiableSet( + Stream.of("java.lang.management.MemoryManagerMXBean", + "java.lang.management.GarbageCollectorMXBean", + "com.sun.management.GarbageCollectorMXBean") + .collect(Collectors.toSet())); + + @Override + public Set> mbeanInterfaces() { + return Stream.of(java.lang.management.MemoryManagerMXBean.class, + java.lang.management.GarbageCollectorMXBean.class, + com.sun.management.GarbageCollectorMXBean.class) + .collect(Collectors.toSet()); + } + + @Override + public Set mbeanInterfaceNames() { + return garbageCollectorMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=*"; + } + + @Override + public boolean isSingleton() { + return false; // zero or more instances + } + + @Override + public Map nameToMBeanMap() { + List list + = ManagementFactoryHelper.getGarbageCollectorMXBeans();; + Map map; + if (list.isEmpty()) { + map = Collections.emptyMap(); + } else { + map = new HashMap<>(list.size()); + for (java.lang.management.MemoryManagerMXBean gcm : list) { + map.put(gcm.getObjectName().getCanonicalName(), + gcm); + } + } + return map; + } + }); + + /** + * OperatingSystemMXBean + */ + initMBeanList.add(new PlatformComponent() { + private final Set operatingSystemMXBeanInterfaceNames + = Collections.unmodifiableSet( + Stream.of("java.lang.management.OperatingSystemMXBean", + "com.sun.management.OperatingSystemMXBean", + "com.sun.management.UnixOperatingSystemMXBean") + .collect(Collectors.toSet())); + + @Override + public Set> mbeanInterfaces() { + return Stream.of(java.lang.management.OperatingSystemMXBean.class, + com.sun.management.OperatingSystemMXBean.class, + com.sun.management.UnixOperatingSystemMXBean.class) + .collect(Collectors.toSet()); + } + + @Override + public Set mbeanInterfaceNames() { + return operatingSystemMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME; + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, + ManagementFactoryHelper.getOperatingSystemMXBean()); + } + }); + + /** + * Diagnostic support for the HotSpot Virtual Machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set hotSpotDiagnosticMXBeanInterfaceNames = + Collections.unmodifiableSet(Collections.singleton("com.sun.management.HotSpotDiagnosticMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(com.sun.management.HotSpotDiagnosticMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return hotSpotDiagnosticMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return "com.sun.management:type=HotSpotDiagnostic"; + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + "com.sun.management:type=HotSpotDiagnostic", + ManagementFactoryHelper.getDiagnosticMXBean()); + } + }); + + /** + * DynamicMBean + */ + HashMap dynmbeans + = ManagementFactoryHelper.getPlatformDynamicMBeans(); + final Set dynamicMBeanInterfaceNames = + Collections.unmodifiableSet(Collections.singleton("javax.management.DynamicMBean")); + for (Map.Entry e : dynmbeans.entrySet()) { + initMBeanList.add(new PlatformComponent() { + @Override + public Set mbeanInterfaceNames() { + return dynamicMBeanInterfaceNames; + } + + @Override + public Set> mbeanInterfaces() { + return Collections.emptySet(); // DynamicMBean cannot be used to find an MBean by ManagementFactory + } + + @Override + public String getObjectNamePattern() { + return e.getKey().getCanonicalName(); + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + e.getKey().getCanonicalName(), + e.getValue()); + } + }); + } + initMBeanList.trimToSize(); + return initMBeanList; + } +} diff --git a/jdk/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java b/jdk/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java new file mode 100644 index 00000000000..128b0ba8afd --- /dev/null +++ b/jdk/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java @@ -0,0 +1,503 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package java.lang.management; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.management.DynamicMBean; +import javax.management.ObjectName; +import sun.management.ManagementFactoryHelper; +import sun.management.spi.PlatformMBeanProvider; + +class DefaultPlatformMBeanProvider extends PlatformMBeanProvider { + private final List> mxbeanList; + + DefaultPlatformMBeanProvider() { + mxbeanList = Collections.unmodifiableList(init()); + } + + @Override + public List> getPlatformComponentList() { + return mxbeanList; + } + + private List> init() { + ArrayList> initMBeanList = new ArrayList<>(); + /** + * Class loading system of the Java virtual machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set classLoadingInterfaceNames = + Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.ClassLoadingMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(ClassLoadingMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return classLoadingInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.CLASS_LOADING_MXBEAN_NAME; + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + ManagementFactory.CLASS_LOADING_MXBEAN_NAME, + ManagementFactoryHelper.getClassLoadingMXBean()); + } + }); + + /** + * Compilation system of the Java virtual machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set compilationMXBeanInterfaceNames + = Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.CompilationMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(CompilationMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return compilationMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.COMPILATION_MXBEAN_NAME; + } + + @Override + public Map nameToMBeanMap() { + CompilationMXBean m = ManagementFactoryHelper.getCompilationMXBean(); + if (m == null) { + return Collections.emptyMap(); + } else { + return Collections.singletonMap( + ManagementFactory.COMPILATION_MXBEAN_NAME, + ManagementFactoryHelper.getCompilationMXBean()); + } + } + }); + + /** + * Memory system of the Java virtual machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set memoryMXBeanInterfaceNames + = Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.MemoryMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(MemoryMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return memoryMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.MEMORY_MXBEAN_NAME; + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + ManagementFactory.MEMORY_MXBEAN_NAME, + ManagementFactoryHelper.getMemoryMXBean()); + } + }); + + /** + * Garbage Collector in the Java virtual machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set garbageCollectorMXBeanInterfaceNames + = Collections.unmodifiableSet( + Stream.of("java.lang.management.MemoryManagerMXBean", + "java.lang.management.GarbageCollectorMXBean") + .collect(Collectors.toSet())); + @Override + public Set> mbeanInterfaces() { + return Stream.of(MemoryManagerMXBean.class, + GarbageCollectorMXBean.class, + com.sun.management.GarbageCollectorMXBean.class).collect(Collectors.toSet()); + } + + @Override + public Set mbeanInterfaceNames() { + return garbageCollectorMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=*"; + } + + @Override + public boolean isSingleton() { + return false; // zero or more instances + } + + @Override + public Map nameToMBeanMap() { + List list + = ManagementFactoryHelper.getGarbageCollectorMXBeans(); + Map map; + if (list.isEmpty()) { + map = Collections.emptyMap(); + } else { + map = new HashMap<>(list.size()); + for (MemoryManagerMXBean gcm : list) { + map.put(gcm.getObjectName().getCanonicalName(), + gcm); + } + } + return map; + } + + }); + + /** + * Memory manager in the Java virtual machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set memoryManagerMXBeanInterfaceNames + = Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.MemoryManagerMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(MemoryManagerMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return memoryManagerMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE + ",name=*"; + } + + @Override + public boolean isSingleton() { + return false; // zero or more instances + } + + @Override + public Map nameToMBeanMap() { + List list + = ManagementFactoryHelper.getMemoryManagerMXBeans(); + return list.stream() + .filter(this::isMemoryManager) + .collect(Collectors.toMap( + pmo -> pmo.getObjectName().getCanonicalName(), Function.identity())); + } + + // ManagementFactoryHelper.getMemoryManagerMXBeans() returns all + // memory managers - we need to filter out those that do not match + // the pattern for which we are registered + private boolean isMemoryManager(MemoryManagerMXBean mbean) { + final ObjectName name = mbean.getObjectName(); + return ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE.startsWith(name.getDomain()) + && ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE.contains( + "type="+name.getKeyProperty("type")); + } + }); + + /** + * Memory pool in the Java virtual machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set memoryPoolMXBeanInterfaceNames + = Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.MemoryPoolMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(MemoryPoolMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return memoryPoolMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE + ",name=*"; + } + + @Override + public boolean isSingleton() { + return false; // zero or more instances + } + + @Override + public Map nameToMBeanMap() { + List list + = ManagementFactoryHelper.getMemoryPoolMXBeans(); + Map map; + if (list.isEmpty()) { + map = Collections.emptyMap(); + } else { + map = new HashMap<>(list.size()); + for (MemoryPoolMXBean mpm : list) { + map.put(mpm.getObjectName().getCanonicalName(), + mpm); + } + } + return map; + } + }); + + /** + * Runtime system of the Java virtual machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set runtimeMXBeanInterfaceNames + = Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.RuntimeMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(RuntimeMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return runtimeMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.RUNTIME_MXBEAN_NAME; + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + ManagementFactory.RUNTIME_MXBEAN_NAME, + ManagementFactoryHelper.getRuntimeMXBean()); + } + }); + + /** + * Threading system of the Java virtual machine. + */ + initMBeanList.add(new PlatformComponent() { + private final Set threadMXBeanInterfaceNames + = Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.ThreadMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(ThreadMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return threadMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.THREAD_MXBEAN_NAME; + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + ManagementFactory.THREAD_MXBEAN_NAME, + ManagementFactoryHelper.getThreadMXBean()); + } + }); + + /** + * Logging facility. + */ + initMBeanList.add(new PlatformComponent() { + private final Set platformLoggingMXBeanInterfaceNames + = Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.PlatformLoggingMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(PlatformLoggingMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return platformLoggingMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return "java.util.logging:type=Logging"; + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + "java.util.logging:type=Logging", + ManagementFactoryHelper.getPlatformLoggingMXBean()); + } + }); + + /** + * Buffer pools. + */ + initMBeanList.add(new PlatformComponent() { + private final Set bufferPoolMXBeanInterfaceNames + = Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.BufferPoolMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(BufferPoolMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return bufferPoolMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return "java.nio:type=BufferPool,name=*"; + } + + @Override + public boolean isSingleton() { + return false; // zero or more instances + } + + @Override + public Map nameToMBeanMap() { + List list + = ManagementFactoryHelper.getBufferPoolMXBeans(); + Map map; + if (list.isEmpty()) { + map = Collections.emptyMap(); + } else { + map = new HashMap<>(list.size()); + list.stream() + .forEach(mbean -> map.put(mbean.getObjectName().getCanonicalName(),mbean)); + } + return map; + } + }); + + /** + * OperatingSystemMXBean + */ + initMBeanList.add(new PlatformComponent() { + private final Set operatingSystemMXBeanInterfaceNames + = Collections.unmodifiableSet(Collections.singleton( + "java.lang.management.OperatingSystemMXBean")); + + @Override + public Set> mbeanInterfaces() { + return Collections.singleton(OperatingSystemMXBean.class); + } + + @Override + public Set mbeanInterfaceNames() { + return operatingSystemMXBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME; + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, + ManagementFactoryHelper.getOperatingSystemMXBean()); + } + + }); + + /** + * DynamicMBean + */ + HashMap dynmbeans + = ManagementFactoryHelper.getPlatformDynamicMBeans(); + final Set dynamicMBeanInterfaceNames = + Collections.unmodifiableSet(Collections.singleton("javax.management.DynamicMBean")); + for (Map.Entry e : dynmbeans.entrySet()) { + initMBeanList.add(new PlatformComponent() { + @Override + public Set> mbeanInterfaces() { + return Collections.emptySet(); + } + + @Override + public Set mbeanInterfaceNames() { + return dynamicMBeanInterfaceNames; + } + + @Override + public String getObjectNamePattern() { + return e.getKey().getCanonicalName(); + } + + @Override + public Map nameToMBeanMap() { + return Collections.singletonMap( + e.getKey().getCanonicalName(), + e.getValue()); + } + }); + } + + initMBeanList.trimToSize(); + return initMBeanList; + } +} diff --git a/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java b/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java index e17514227fd..9a0e1ebbd61 100644 --- a/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java +++ b/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, 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 @@ -24,35 +24,40 @@ */ package java.lang.management; +import java.io.FilePermission; +import java.io.IOException; import javax.management.DynamicMBean; import javax.management.MBeanServer; import javax.management.MBeanServerConnection; import javax.management.MBeanServerFactory; import javax.management.MBeanServerPermission; import javax.management.NotificationEmitter; -import javax.management.ObjectInstance; import javax.management.ObjectName; -import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.MalformedObjectNameException; -import javax.management.MBeanRegistrationException; -import javax.management.NotCompliantMBeanException; import javax.management.StandardEmitterMBean; import javax.management.StandardMBean; import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Optional; +import java.util.ServiceLoader; +import java.util.function.Function; +import java.util.stream.Collectors; +import static java.util.stream.Collectors.toMap; +import java.util.stream.Stream; import javax.management.JMX; -import sun.management.ManagementFactoryHelper; -import sun.management.ExtendedPlatformComponent; +import sun.management.Util; +import sun.management.spi.PlatformMBeanProvider; +import sun.management.spi.PlatformMBeanProvider.PlatformComponent; /** * The {@code ManagementFactory} class is a factory class for getting @@ -316,7 +321,7 @@ public class ManagementFactory { * the Java virtual machine. */ public static ClassLoadingMXBean getClassLoadingMXBean() { - return ManagementFactoryHelper.getClassLoadingMXBean(); + return getPlatformMXBean(ClassLoadingMXBean.class); } /** @@ -326,7 +331,7 @@ public class ManagementFactory { * @return a {@link MemoryMXBean} object for the Java virtual machine. */ public static MemoryMXBean getMemoryMXBean() { - return ManagementFactoryHelper.getMemoryMXBean(); + return getPlatformMXBean(MemoryMXBean.class); } /** @@ -336,7 +341,7 @@ public class ManagementFactory { * @return a {@link ThreadMXBean} object for the Java virtual machine. */ public static ThreadMXBean getThreadMXBean() { - return ManagementFactoryHelper.getThreadMXBean(); + return getPlatformMXBean(ThreadMXBean.class); } /** @@ -347,7 +352,7 @@ public class ManagementFactory { */ public static RuntimeMXBean getRuntimeMXBean() { - return ManagementFactoryHelper.getRuntimeMXBean(); + return getPlatformMXBean(RuntimeMXBean.class); } /** @@ -360,7 +365,7 @@ public class ManagementFactory { * no compilation system. */ public static CompilationMXBean getCompilationMXBean() { - return ManagementFactoryHelper.getCompilationMXBean(); + return getPlatformMXBean(CompilationMXBean.class); } /** @@ -371,7 +376,7 @@ public class ManagementFactory { * the Java virtual machine. */ public static OperatingSystemMXBean getOperatingSystemMXBean() { - return ManagementFactoryHelper.getOperatingSystemMXBean(); + return getPlatformMXBean(OperatingSystemMXBean.class); } /** @@ -384,7 +389,7 @@ public class ManagementFactory { * */ public static List getMemoryPoolMXBeans() { - return ManagementFactoryHelper.getMemoryPoolMXBeans(); + return getPlatformMXBeans(MemoryPoolMXBean.class); } /** @@ -397,7 +402,7 @@ public class ManagementFactory { * */ public static List getMemoryManagerMXBeans() { - return ManagementFactoryHelper.getMemoryManagerMXBeans(); + return getPlatformMXBeans(MemoryManagerMXBean.class); } @@ -413,7 +418,7 @@ public class ManagementFactory { * */ public static List getGarbageCollectorMXBeans() { - return ManagementFactoryHelper.getGarbageCollectorMXBeans(); + return getPlatformMXBeans(GarbageCollectorMXBean.class); } private static MBeanServer platformMBeanServer; @@ -467,35 +472,11 @@ public class ManagementFactory { if (platformMBeanServer == null) { platformMBeanServer = MBeanServerFactory.createMBeanServer(); - for (PlatformComponent pc : PlatformComponent.values()) { - List list = - pc.getMXBeans(pc.getMXBeanInterface()); - for (PlatformManagedObject o : list) { - // Each PlatformComponent represents one management - // interface. Some MXBean may extend another one. - // The MXBean instances for one platform component - // (returned by pc.getMXBeans()) might be also - // the MXBean instances for another platform component. - // e.g. com.sun.management.GarbageCollectorMXBean - // - // So need to check if an MXBean instance is registered - // before registering into the platform MBeanServer - if (!platformMBeanServer.isRegistered(o.getObjectName())) { - addMXBean(platformMBeanServer, o); - } - } - } - HashMap dynmbeans = - ManagementFactoryHelper.getPlatformDynamicMBeans(); - for (Map.Entry e : dynmbeans.entrySet()) { - addDynamicMBean(platformMBeanServer, e.getValue(), e.getKey()); - } - for (final PlatformManagedObject o : - ExtendedPlatformComponent.getMXBeans()) { - if (!platformMBeanServer.isRegistered(o.getObjectName())) { - addMXBean(platformMBeanServer, o); - } - } + platformComponents() + .stream() + .filter(PlatformComponent::shouldRegister) + .flatMap(pc -> pc.nameToMBeanMap().entrySet().stream()) + .forEach(entry -> addMXBean(platformMBeanServer, entry.getKey(), entry.getValue())); } return platformMBeanServer; } @@ -600,11 +581,8 @@ public class ManagementFactory { // bootstrap class loader final Class cls = mxbeanInterface; ClassLoader loader = - AccessController.doPrivileged(new PrivilegedAction() { - public ClassLoader run() { - return cls.getClassLoader(); - } - }); + AccessController.doPrivileged( + (PrivilegedAction) () -> cls.getClassLoader()); if (!sun.misc.VM.isSystemDomainLoader(loader)) { throw new IllegalArgumentException(mxbeanName + " is not a platform MXBean"); @@ -619,7 +597,6 @@ public class ManagementFactory { " is not an instance of " + mxbeanInterface); } - final Class[] interfaces; // check if the registered MBean is a notification emitter boolean emitter = connection.isInstanceOf(objName, NOTIF_EMITTER); @@ -661,20 +638,11 @@ public class ManagementFactory { */ public static T getPlatformMXBean(Class mxbeanInterface) { - PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); - if (pc == null) { - T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface); - if (mbean != null) { - return mbean; - } - throw new IllegalArgumentException(mxbeanInterface.getName() + - " is not a platform management interface"); - } - if (!pc.isSingleton()) - throw new IllegalArgumentException(mxbeanInterface.getName() + - " can have zero or more than one instances"); + PlatformComponent pc = PlatformMBeanFinder.findSingleton(mxbeanInterface); - return pc.getSingletonMXBean(mxbeanInterface); + List mbeans = pc.getMBeans(mxbeanInterface); + assert mbeans.isEmpty() || mbeans.size() == 1; + return mbeans.isEmpty() ? null : mbeans.get(0); } /** @@ -701,16 +669,19 @@ public class ManagementFactory { */ public static List getPlatformMXBeans(Class mxbeanInterface) { - PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); + // Validates at first the specified interface by finding at least one + // PlatformComponent whose MXBean implements this interface. + // An interface can be implemented by different MBeans, provided by + // different platform components. + PlatformComponent pc = PlatformMBeanFinder.findFirst(mxbeanInterface); if (pc == null) { - T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface); - if (mbean != null) { - return Collections.singletonList(mbean); - } - throw new IllegalArgumentException(mxbeanInterface.getName() + - " is not a platform management interface"); + throw new IllegalArgumentException(mxbeanInterface.getName() + + " is not a platform management interface"); } - return Collections.unmodifiableList(pc.getMXBeans(mxbeanInterface)); + + return platformComponents().stream() + .flatMap(p -> p.getMBeans(mxbeanInterface).stream()) + .collect(Collectors.toList()); } /** @@ -753,22 +724,8 @@ public class ManagementFactory { Class mxbeanInterface) throws java.io.IOException { - PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); - if (pc == null) { - T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface); - if (mbean != null) { - ObjectName on = mbean.getObjectName(); - return ManagementFactory.newPlatformMXBeanProxy(connection, - on.getCanonicalName(), - mxbeanInterface); - } - throw new IllegalArgumentException(mxbeanInterface.getName() + - " is not a platform management interface"); - } - if (!pc.isSingleton()) - throw new IllegalArgumentException(mxbeanInterface.getName() + - " can have zero or more than one instances"); - return pc.getSingletonMXBean(connection, mxbeanInterface); + PlatformComponent pc = PlatformMBeanFinder.findSingleton(mxbeanInterface); + return newPlatformMXBeanProxy(connection, pc.getObjectNamePattern(), mxbeanInterface); } /** @@ -804,19 +761,56 @@ public class ManagementFactory { Class mxbeanInterface) throws java.io.IOException { - PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface); + // Validates at first the specified interface by finding at least one + // PlatformComponent whose MXBean implements this interface. + // An interface can be implemented by different MBeans, provided by + // different platform components. + PlatformComponent pc = PlatformMBeanFinder.findFirst(mxbeanInterface); if (pc == null) { - T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface); - if (mbean != null) { - ObjectName on = mbean.getObjectName(); - T proxy = ManagementFactory.newPlatformMXBeanProxy(connection, - on.getCanonicalName(), mxbeanInterface); - return Collections.singletonList(proxy); - } - throw new IllegalArgumentException(mxbeanInterface.getName() + - " is not a platform management interface"); + throw new IllegalArgumentException(mxbeanInterface.getName() + + " is not a platform management interface"); } - return Collections.unmodifiableList(pc.getMXBeans(connection, mxbeanInterface)); + + // Collect all names, eliminate duplicates. + Stream names = Stream.empty(); + for (PlatformComponent p : platformComponents()) { + names = Stream.concat(names, getProxyNames(p, connection, mxbeanInterface)); + } + Set objectNames = names.collect(Collectors.toSet()); + if (objectNames.isEmpty()) return Collections.emptyList(); + + // Map names on proxies. + List proxies = new ArrayList<>(); + for (String name : objectNames) { + proxies.add(newPlatformMXBeanProxy(connection, name, mxbeanInterface)); + } + return proxies; + } + + // Returns a stream containing all ObjectNames of the MBeans represented by + // the specified PlatformComponent and implementing the specified interface. + // If the PlatformComponent is a singleton, the name returned by + // PlatformComponent.getObjectNamePattern() will be used, otherwise + // we will query the specified MBeanServerConnection (conn.queryNames) + // with the pattern returned by PlatformComponent.getObjectNamePattern() + // in order to find the names of matching MBeans. + // In case of singleton, we do not check whether the MBean is registered + // in the connection because the caller "getPlatformMXBeans" will do the check + // when creating a proxy. + private static Stream getProxyNames(PlatformComponent pc, + MBeanServerConnection conn, + Class intf) + throws IOException + { + if (pc.mbeanInterfaceNames().contains(intf.getName())) { + if (pc.isSingleton()) { + return Stream.of(pc.getObjectNamePattern()); + } else { + return conn.queryNames(Util.newObjectName(pc.getObjectNamePattern()), null) + .stream().map(ObjectName::getCanonicalName); + } + } + return Stream.empty(); } /** @@ -835,63 +829,145 @@ public class ManagementFactory { public static Set> getPlatformManagementInterfaces() { - Set> result = - new HashSet<>(); - for (PlatformComponent component: PlatformComponent.values()) { - result.add(component.getMXBeanInterface()); - } - return Collections.unmodifiableSet(result); + return platformComponents() + .stream() + .flatMap(pc -> pc.mbeanInterfaces().stream()) + .filter(clazz -> PlatformManagedObject.class.isAssignableFrom(clazz)) + .map(clazz -> clazz.asSubclass(PlatformManagedObject.class)) + .collect(Collectors.toSet()); } private static final String NOTIF_EMITTER = "javax.management.NotificationEmitter"; - /** - * Registers an MXBean. - */ - private static void addMXBean(final MBeanServer mbs, final PlatformManagedObject pmo) { - // Make DynamicMBean out of MXBean by wrapping it with a StandardMBean + private static void addMXBean(final MBeanServer mbs, String name, final Object pmo) + { try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Void run() throws InstanceAlreadyExistsException, - MBeanRegistrationException, - NotCompliantMBeanException { - final DynamicMBean dmbean; - if (pmo instanceof DynamicMBean) { - dmbean = DynamicMBean.class.cast(pmo); - } else if (pmo instanceof NotificationEmitter) { - dmbean = new StandardEmitterMBean(pmo, null, true, (NotificationEmitter) pmo); - } else { - dmbean = new StandardMBean(pmo, null, true); - } - - mbs.registerMBean(dmbean, pmo.getObjectName()); - return null; + ObjectName oname = ObjectName.getInstance(name); + // Make DynamicMBean out of MXBean by wrapping it with a StandardMBean + AccessController.doPrivileged((PrivilegedExceptionAction) () -> { + final DynamicMBean dmbean; + if (pmo instanceof DynamicMBean) { + dmbean = DynamicMBean.class.cast(pmo); + } else if (pmo instanceof NotificationEmitter) { + dmbean = new StandardEmitterMBean(pmo, null, true, (NotificationEmitter) pmo); + } else { + dmbean = new StandardMBean(pmo, null, true); } + + mbs.registerMBean(dmbean, oname); + return null; }); + } catch (MalformedObjectNameException mone) { + throw new IllegalArgumentException(mone); } catch (PrivilegedActionException e) { throw new RuntimeException(e.getException()); } } - /** - * Registers a DynamicMBean. - */ - private static void addDynamicMBean(final MBeanServer mbs, - final DynamicMBean dmbean, - final ObjectName on) { - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Void run() throws InstanceAlreadyExistsException, - MBeanRegistrationException, - NotCompliantMBeanException { - mbs.registerMBean(dmbean, on); - return null; - } - }); - } catch (PrivilegedActionException e) { - throw new RuntimeException(e.getException()); + private static Collection> platformComponents() + { + return PlatformMBeanFinder.getMap().values(); + } + + private static class PlatformMBeanFinder + { + private static final Map> componentMap; + static { + // get all providers + List providers = AccessController.doPrivileged( + (PrivilegedAction>) () -> { + List all = new ArrayList<>(); + ServiceLoader.loadInstalled(PlatformMBeanProvider.class) + .forEach(all::add); + all.add(new DefaultPlatformMBeanProvider()); + return all; + }, null, new FilePermission("<>", "read"), + new RuntimePermission("sun.management.spi.PlatformMBeanProvider")); + + // load all platform components into a map + componentMap = providers.stream() + .flatMap(p -> toPlatformComponentStream(p)) + // The first one wins if multiple PlatformComponents + // with same ObjectName pattern, + .collect(toMap(PlatformComponent::getObjectNamePattern, + Function.identity(), + (p1, p2) -> p1)); + } + + static Map> getMap() { + return componentMap; + } + + // Loads all platform components from a provider into a stream + // Ensures that two different components are not declared with the same + // object name pattern. Throws InternalError if the provider incorrectly + // declares two platform components with the same pattern. + private static Stream> + toPlatformComponentStream(PlatformMBeanProvider provider) + { + return provider.getPlatformComponentList() + .stream() + .collect(toMap(PlatformComponent::getObjectNamePattern, + Function.identity(), + (p1, p2) -> { + throw new InternalError( + p1.getObjectNamePattern() + + " has been used as key for " + p1 + + ", it cannot be reused for " + p2); + })) + .values().stream(); + } + + // Finds the first PlatformComponent whose mbeanInterfaceNames() list + // contains the specified class name. An MBean interface can be implemented + // by different MBeans, provided by different platform components. + // For instance the MemoryManagerMXBean interface is implemented both by + // regular memory managers, and garbage collector MXBeans. This method is + // mainly used to verify that there is at least one PlatformComponent + // which provides an implementation of the desired interface. + static PlatformComponent findFirst(Class mbeanIntf) + { + String name = mbeanIntf.getName(); + Optional> op = getMap().values() + .stream() + .filter(pc -> pc.mbeanInterfaceNames().contains(name)) + .findFirst(); + + if (op.isPresent()) { + return op.get(); + } else { + return null; + } + } + + // Finds a PlatformComponent whose mbeanInterface name list contains + // the specified class name, and make sure that one and only one exists. + static PlatformComponent findSingleton(Class mbeanIntf) + { + String name = mbeanIntf.getName(); + Optional> op = getMap().values() + .stream() + .filter(pc -> pc.mbeanInterfaceNames().contains(name)) + .reduce((p1, p2) -> { + if (p2 != null) { + throw new IllegalArgumentException(mbeanIntf.getName() + + " can have more than one instance"); + } else { + return p1; + } + }); + + PlatformComponent singleton = op.isPresent() ? op.get() : null; + if (singleton == null) { + throw new IllegalArgumentException(mbeanIntf.getName() + + " is not a platform management interface"); + } + if (!singleton.isSingleton()) { + throw new IllegalArgumentException(mbeanIntf.getName() + + " can have more than one instance"); + } + return singleton; } } } diff --git a/jdk/src/java.management/share/classes/java/lang/management/PlatformComponent.java b/jdk/src/java.management/share/classes/java/lang/management/PlatformComponent.java deleted file mode 100644 index 0c67543eec4..00000000000 --- a/jdk/src/java.management/share/classes/java/lang/management/PlatformComponent.java +++ /dev/null @@ -1,468 +0,0 @@ -/* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.lang.management; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.HashSet; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import javax.management.MBeanServerConnection; -import javax.management.ObjectName; - -import com.sun.management.HotSpotDiagnosticMXBean; -import com.sun.management.UnixOperatingSystemMXBean; - -import sun.management.ManagementFactoryHelper; -import sun.management.Util; - -/** - * This enum class defines the list of platform components - * that provides monitoring and management support. - * Each enum represents one MXBean interface. A MXBean - * instance could implement one or more MXBean interfaces. - * - * For example, com.sun.management.GarbageCollectorMXBean - * extends java.lang.management.GarbageCollectorMXBean - * and there is one set of garbage collection MXBean instances, - * each of which implements both c.s.m. and j.l.m. interfaces. - * There are two separate enums GARBAGE_COLLECTOR - * and SUN_GARBAGE_COLLECTOR so that ManagementFactory.getPlatformMXBeans(Class) - * will return the list of MXBeans of the specified type. - * - * To add a new MXBean interface for the Java platform, - * add a new enum constant and implement the MXBeanFetcher. - */ -enum PlatformComponent { - - /** - * Class loading system of the Java virtual machine. - */ - CLASS_LOADING( - "java.lang.management.ClassLoadingMXBean", - "java.lang", "ClassLoading", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - return Collections.singletonList(ManagementFactoryHelper.getClassLoadingMXBean()); - } - }), - - /** - * Compilation system of the Java virtual machine. - */ - COMPILATION( - "java.lang.management.CompilationMXBean", - "java.lang", "Compilation", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - CompilationMXBean m = ManagementFactoryHelper.getCompilationMXBean(); - if (m == null) { - return Collections.emptyList(); - } else { - return Collections.singletonList(m); - } - } - }), - - /** - * Memory system of the Java virtual machine. - */ - MEMORY( - "java.lang.management.MemoryMXBean", - "java.lang", "Memory", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - return Collections.singletonList(ManagementFactoryHelper.getMemoryMXBean()); - } - }), - - /** - * Garbage Collector in the Java virtual machine. - */ - GARBAGE_COLLECTOR( - "java.lang.management.GarbageCollectorMXBean", - "java.lang", "GarbageCollector", keyProperties("name"), - false, // zero or more instances - new MXBeanFetcher() { - public List getMXBeans() { - return ManagementFactoryHelper. - getGarbageCollectorMXBeans(); - } - }), - - /** - * Memory manager in the Java virtual machine. - */ - MEMORY_MANAGER( - "java.lang.management.MemoryManagerMXBean", - "java.lang", "MemoryManager", keyProperties("name"), - false, // zero or more instances - new MXBeanFetcher() { - public List getMXBeans() { - return ManagementFactoryHelper.getMemoryManagerMXBeans(); - } - }, - GARBAGE_COLLECTOR), - - /** - * Memory pool in the Java virtual machine. - */ - MEMORY_POOL( - "java.lang.management.MemoryPoolMXBean", - "java.lang", "MemoryPool", keyProperties("name"), - false, // zero or more instances - new MXBeanFetcher() { - public List getMXBeans() { - return ManagementFactoryHelper.getMemoryPoolMXBeans(); - } - }), - - /** - * Operating system on which the Java virtual machine is running - */ - OPERATING_SYSTEM( - "java.lang.management.OperatingSystemMXBean", - "java.lang", "OperatingSystem", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - return Collections.singletonList(ManagementFactoryHelper.getOperatingSystemMXBean()); - } - }), - - /** - * Runtime system of the Java virtual machine. - */ - RUNTIME( - "java.lang.management.RuntimeMXBean", - "java.lang", "Runtime", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - return Collections.singletonList(ManagementFactoryHelper.getRuntimeMXBean()); - } - }), - - /** - * Threading system of the Java virtual machine. - */ - THREADING( - "java.lang.management.ThreadMXBean", - "java.lang", "Threading", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - return Collections.singletonList(ManagementFactoryHelper.getThreadMXBean()); - } - }), - - - /** - * Logging facility. - */ - LOGGING( - "java.lang.management.PlatformLoggingMXBean", - "java.util.logging", "Logging", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - PlatformLoggingMXBean m = ManagementFactoryHelper.getPlatformLoggingMXBean(); - if (m == null) { - return Collections.emptyList(); - } else { - return Collections.singletonList(m); - } - } - }), - - /** - * Buffer pools. - */ - BUFFER_POOL( - "java.lang.management.BufferPoolMXBean", - "java.nio", "BufferPool", keyProperties("name"), - false, // zero or more instances - new MXBeanFetcher() { - public List getMXBeans() { - return ManagementFactoryHelper.getBufferPoolMXBeans(); - } - }), - - - // Sun Platform Extension - - /** - * Sun extension garbage collector that performs collections in cycles. - */ - SUN_GARBAGE_COLLECTOR( - "com.sun.management.GarbageCollectorMXBean", - "java.lang", "GarbageCollector", keyProperties("name"), - false, // zero or more instances - new MXBeanFetcher() { - public List getMXBeans() { - return getGcMXBeanList(com.sun.management.GarbageCollectorMXBean.class); - } - }), - - /** - * Sun extension operating system on which the Java virtual machine - * is running. - */ - SUN_OPERATING_SYSTEM( - "com.sun.management.OperatingSystemMXBean", - "java.lang", "OperatingSystem", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - return getOSMXBeanList(com.sun.management.OperatingSystemMXBean.class); - } - }), - - /** - * Unix operating system. - */ - SUN_UNIX_OPERATING_SYSTEM( - "com.sun.management.UnixOperatingSystemMXBean", - "java.lang", "OperatingSystem", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - return getOSMXBeanList(com.sun.management.UnixOperatingSystemMXBean.class); - } - }), - - /** - * Diagnostic support for the HotSpot Virtual Machine. - */ - HOTSPOT_DIAGNOSTIC( - "com.sun.management.HotSpotDiagnosticMXBean", - "com.sun.management", "HotSpotDiagnostic", defaultKeyProperties(), - true, // singleton - new MXBeanFetcher() { - public List getMXBeans() { - return Collections.singletonList(ManagementFactoryHelper.getDiagnosticMXBean()); - } - }); - - - /** - * A task that returns the MXBeans for a component. - */ - interface MXBeanFetcher { - public List getMXBeans(); - } - - /* - * Returns a list of the GC MXBeans of the given type. - */ - private static - List getGcMXBeanList(Class gcMXBeanIntf) { - List list = - ManagementFactoryHelper.getGarbageCollectorMXBeans(); - List result = new ArrayList<>(list.size()); - for (GarbageCollectorMXBean m : list) { - if (gcMXBeanIntf.isInstance(m)) { - result.add(gcMXBeanIntf.cast(m)); - } - } - return result; - } - - /* - * Returns the OS mxbean instance of the given type. - */ - private static - List getOSMXBeanList(Class osMXBeanIntf) { - OperatingSystemMXBean m = - ManagementFactoryHelper.getOperatingSystemMXBean(); - if (osMXBeanIntf.isInstance(m)) { - return Collections.singletonList(osMXBeanIntf.cast(m)); - } else { - return Collections.emptyList(); - } - } - - private final String mxbeanInterfaceName; - private final String domain; - private final String type; - private final Set keyProperties; - private final MXBeanFetcher fetcher; - private final PlatformComponent[] subComponents; - private final boolean singleton; - - private PlatformComponent(String intfName, - String domain, String type, - Set keyProperties, - boolean singleton, - MXBeanFetcher fetcher, - PlatformComponent... subComponents) { - this.mxbeanInterfaceName = intfName; - this.domain = domain; - this.type = type; - this.keyProperties = keyProperties; - this.singleton = singleton; - this.fetcher = fetcher; - this.subComponents = subComponents; - } - - private static Set defaultKeyProps; - private static Set defaultKeyProperties() { - if (defaultKeyProps == null) { - defaultKeyProps = Collections.singleton("type"); - } - return defaultKeyProps; - } - - private static Set keyProperties(String... keyNames) { - Set set = new HashSet<>(); - set.add("type"); - for (String s : keyNames) { - set.add(s); - } - return set; - } - - boolean isSingleton() { - return singleton; - } - - String getMXBeanInterfaceName() { - return mxbeanInterfaceName; - } - - @SuppressWarnings("unchecked") - Class getMXBeanInterface() { - try { - // Lazy loading the MXBean interface only when it is needed - return (Class) - Class.forName(mxbeanInterfaceName, false, - PlatformManagedObject.class.getClassLoader()); - } catch (ClassNotFoundException x) { - throw new AssertionError(x); - } - } - - @SuppressWarnings("unchecked") - - List getMXBeans(Class mxbeanInterface) - { - return (List) fetcher.getMXBeans(); - } - - T getSingletonMXBean(Class mxbeanInterface) - { - if (!singleton) - throw new IllegalArgumentException(mxbeanInterfaceName + - " can have zero or more than one instances"); - - List list = getMXBeans(mxbeanInterface); - assert list.size() == 1; - return list.isEmpty() ? null : list.get(0); - } - - - T getSingletonMXBean(MBeanServerConnection mbs, Class mxbeanInterface) - throws java.io.IOException - { - if (!singleton) - throw new IllegalArgumentException(mxbeanInterfaceName + - " can have zero or more than one instances"); - - // ObjectName of a singleton MXBean contains only domain and type - assert keyProperties.size() == 1; - String on = domain + ":type=" + type; - return ManagementFactory.newPlatformMXBeanProxy(mbs, - on, - mxbeanInterface); - } - - - List getMXBeans(MBeanServerConnection mbs, Class mxbeanInterface) - throws java.io.IOException - { - List result = new ArrayList<>(); - for (ObjectName on : getObjectNames(mbs)) { - result.add(ManagementFactory. - newPlatformMXBeanProxy(mbs, - on.getCanonicalName(), - mxbeanInterface) - ); - } - return result; - } - - private Set getObjectNames(MBeanServerConnection mbs) - throws java.io.IOException - { - String domainAndType = domain + ":type=" + type; - if (keyProperties.size() > 1) { - // if there are more than 1 key properties (i.e. other than "type") - domainAndType += ",*"; - } - ObjectName on = Util.newObjectName(domainAndType); - Set set = mbs.queryNames(on, null); - for (PlatformComponent pc : subComponents) { - set.addAll(pc.getObjectNames(mbs)); - } - return set; - } - - // a map from MXBean interface name to PlatformComponent - private static Map enumMap; - private static synchronized void ensureInitialized() { - if (enumMap == null) { - enumMap = new HashMap<>(); - for (PlatformComponent pc: PlatformComponent.values()) { - // Use String as the key rather than Class to avoid - // causing unnecessary class loading of management interface - enumMap.put(pc.getMXBeanInterfaceName(), pc); - } - } - } - - static boolean isPlatformMXBean(String cn) { - ensureInitialized(); - return enumMap.containsKey(cn); - } - - static - PlatformComponent getPlatformComponent(Class mxbeanInterface) - { - ensureInitialized(); - String cn = mxbeanInterface.getName(); - PlatformComponent pc = enumMap.get(cn); - if (pc != null && pc.getMXBeanInterface() == mxbeanInterface) - return pc; - return null; - } - - private static final long serialVersionUID = 6992337162326171013L; -} diff --git a/jdk/src/java.management/share/classes/sun/management/ExtendedPlatformComponent.java b/jdk/src/java.management/share/classes/sun/management/ExtendedPlatformComponent.java deleted file mode 100644 index ff33ff9b52e..00000000000 --- a/jdk/src/java.management/share/classes/sun/management/ExtendedPlatformComponent.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.management; - -import java.util.Collections; -import java.util.List; -import java.lang.management.PlatformManagedObject; - -/** - * Class to allow for an extended set of platform MXBeans - */ -public final class ExtendedPlatformComponent { - private ExtendedPlatformComponent() {} // Don't create any instances - - /** - * Get the extended set of platform MXBeans that should be registered in the - * platform MBeanServer, or an empty list if there are no such MXBeans. - */ - public static List getMXBeans() { - return Collections.emptyList(); - } - - /** - * Returns the extended platform MXBean implementing the given - * mxbeanInterface, or null if there is no such MXBean. - */ - public static - T getMXBean(Class mxbeanInterface) { - return null; - } -} diff --git a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java index be82ddae27e..c06fb71b27d 100644 --- a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java +++ b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java @@ -42,14 +42,11 @@ import java.security.PrivilegedExceptionAction; import sun.util.logging.LoggingSupport; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import com.sun.management.DiagnosticCommandMBean; import com.sun.management.HotSpotDiagnosticMXBean; -import static java.lang.management.ManagementFactory.*; - /** * ManagementFactoryHelper provides static factory methods to create * instances of the management interface. diff --git a/jdk/src/java.management/share/classes/sun/management/spi/PlatformMBeanProvider.java b/jdk/src/java.management/share/classes/sun/management/spi/PlatformMBeanProvider.java new file mode 100644 index 00000000000..6f224c95e68 --- /dev/null +++ b/jdk/src/java.management/share/classes/sun/management/spi/PlatformMBeanProvider.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.management.spi; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * The PlatformMBeanProvider class defines the abstract service interface + * that the {@link java.lang.management.ManagementFactory} will invoke to find, + * load, and register Platform MBeans. + * + * ManagementFactory loads the {@linkplain ServiceLoader#loadInstalled(java.lang.Class) + * installed providers} of this service interface and each provides the + * {@linkplain PlatformComponent platform components} that defines MXBean + * or DynamicMBean to be registered in the platform MBeanServer. + * + * A {@code PlatformMBeanProvider} will implement the {@code getPlatformComponentList()} + * method to return the list of {@code PlatformComponents} it provides. + */ +public abstract class PlatformMBeanProvider { + /** + * {@code PlatformComponent} models MBeans of a management interface supported + * by the platform. + * + * If a PlatformComponent models a singleton MBean, the {@link #getObjectNamePattern() + * ObjectName pattern} must be the {@link + * javax.management.ObjectName#getCanonicalName() canonical name} of that + * singleton MBean. Otherwise, it must be an ObjectName pattern + * that can be used to query the MBeans for this + * PlatformComponent registered in a {@code MBeanServer}. + *
+ * The {@link #getObjectNamePattern() ObjectName pattern} serves as a unique + * key for identifying the instance of PlatformComponent. It is thus illegal + * for a given {@link PlatformMBeanProvider} to export several instance of + * PlatformComponent with the same + * {@link #getObjectNamePattern() ObjectName pattern} string. + *
+ * If two different provider instances export a PlatformComponent for the + * same ObjectName pattern, only the PlatformComponent instance of the first + * provider will be taken into account. + * + * @param The higher level interface for which the MBeans modeled by + * this object should be recognized. For instance, for the {@link + * java.lang.management.ManagementFactory#getOperatingSystemMXBean() + * Operating System MXBean}, this should be {@link + * java.lang.management.OperatingSystemMXBean + * java.lang.management.OperatingSystemMXBean}. + */ + public interface PlatformComponent { + /** + * Returns the names of the management interfaces implemented by the + * MBeans modeled by this {@code PlatformComponent}. + * + * @implNote + * When {@link java.lang.management.ManagementFactory#getPlatformMXBean(java.lang.Class) + * ManagementFactory.getPlatformMXBean(mxbeanInterface)} or {@link + * java.lang.management.ManagementFactory#getPlatformMXBeans(java.lang.Class) + * ManagementFactory.getPlatformMXBeans(mxbeanInterface)} are invoked, + * this PlatformComponent instance will match only if the name of the + * given {@code mxbeanInterface} is found in this list. + * + * @return the names of the management interfaces exported by the MBeans + * modeled by this object. + */ + public Set mbeanInterfaceNames(); + + /** + * A map from ObjectName string to the MBean instance this + * {@code PlatformComponent} creates. + * + * @implNote + * If {@link #shouldRegister()} is {@code true}, this method + * will be called when the {@link java.lang.management.ManagementFactory + * #getPlatformMBeanServer() Platform MBeanServer} is initialized. + * By default, this method will also be called by {@link + * #getMBeans(java.lang.Class)}, when {@link + * java.lang.management.ManagementFactory#getPlatformMXBean(java.lang.Class) + * ManagementFactory.getPlatformMXBean(mxbeanInterface)} or {@link + * java.lang.management.ManagementFactory#getPlatformMXBeans(java.lang.Class) + * ManagementFactory.getPlatformMXBeans(mxbeanInterface)} are invoked, + * and when the name of the given {@code mxbeanInterface} is contained + * in the names of management interfaces returned by {@link + * #mbeanInterfaceNames()}. + * + * @return A map with, for each MBean, the ObjectName string as key + * and the MBean as value. + */ + public Map nameToMBeanMap(); + + /** + * An ObjectName pattern uniquely identifies the MBeans + * modeled by this {@code PlatformComponent}. + * If this instance models a singleton MBean, this must be + * the {@link + * javax.management.ObjectName#getCanonicalName() canonical name} + * of that singleton MBean. + * + * @return An ObjectName pattern uniquely identifies the MBeans + * modeled by this instance. + */ + public String getObjectNamePattern(); + + /** + * Returns {@code true} if this {@code PlatformComponent} models + * a singleton MBean. By default, {@code true} is assumed. + * + * @return {@code true} if this instance models a singleton MBean. + */ + public default boolean isSingleton() { + return true; + } + + /** + * Returns {@code true} if the MBeans modeled by this {@code PlatformComponent} + * should automatically be registered in the {@link + * java.lang.management.ManagementFactory#getPlatformMBeanServer() + * Platform MBeanServer}. By default, {@code true} is assumed. + * + * @return {@code true} if the MBeans modeled by this instance should + * automatically be registered in the Platform MBeanServer. + */ + public default boolean shouldRegister() { + return true; + } + + /** + * The set of interfaces implemented by the MBeans modeled + * by this {@code PlatformComponent}. + * + * @implNote + * {@link java.lang.management.ManagementFactory#getPlatformManagementInterfaces() + * ManagementFactory.getPlatformManagementInterfaces()} calls this + * method to find the management interfaces supported by the platform. + * + * @return The set of interfaces implemented by the MBeans modeled + * by this instance + */ + public Set> mbeanInterfaces(); + + /** + * Return the list of MBeans that implement the given {@code mbeanIntf} + * modeled by this {@code PlatformComponent}. This method returns an + * empty list if no MBean implements the given {@code mbeanIntf}. + * + * @implNote This method will be called when {@link + * java.lang.management.ManagementFactory#getPlatformMXBean(java.lang.Class) + * ManagementFactory.getPlatformMXBean(mbeanIntf)} or {@link + * java.lang.management.ManagementFactory#getPlatformMXBeans(java.lang.Class) + * ManagementFactory.getPlatformMXBeans(mbeanIntf)} are invoked. + * By default it first checks whether the specified {@code mbeanIntf} + * name is contained in the returned list from the {@link #mbeanInterfaceNames()} + * method. If yes, it proceeds and calls + * {@link #mbeans().values()} and filters out all + * MBeans which are not instances of the given {@code mbeanIntf}. + * Otherwise, it returns an empty list. + * + * @param mbeanIntf A management interface. + * @return A (possibly empty) list of MBeans implementing the given + * {@code mbeanIntf}. + */ + public default List getMBeans(Class mbeanIntf) { + List list; + + if (!mbeanInterfaceNames().contains(mbeanIntf.getName())) { + list = Collections.emptyList(); + } else { + list = nameToMBeanMap().values().stream() + .filter(mbeanIntf::isInstance) + .map(mbeanIntf::cast) + .collect(Collectors.toList()); + } + return list; + } + } + + /** + * Instantiates a new PlatformMBeanProvider. + * + * @throws SecurityException if the subclass (and calling code) does not + * have {@code RuntimePermission("sun.management.spi.PlatformMBeanProvider", "subclass")} + */ + protected PlatformMBeanProvider () { + this(checkSubclassPermission()); + } + + private PlatformMBeanProvider(Void unused) { + } + + /** + * Returns a list of PlatformComponent instances describing the Platform + * MBeans provided by this provider. + * + * @return a list of PlatformComponent instances describing the Platform + * MBeans provided by this provider. + */ + public abstract List> getPlatformComponentList(); + + private static Void checkSubclassPermission() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission(PlatformMBeanProvider.class.getName(), "subclass")); + } + return null; + } +} diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java index a7361abdec1..6dc93773d7a 100644 --- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java +++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java @@ -60,16 +60,6 @@ public class KrbApReq { private static boolean DEBUG = Krb5.DEBUG; private static final char[] hexConst = "0123456789ABCDEF".toCharArray(); - private static final MessageDigest md; - - static { - try { - md = MessageDigest.getInstance("MD5"); - } catch (NoSuchAlgorithmException ex) { - throw new RuntimeException("Impossible"); - } - } - /** * Constructs an AP-REQ message to send to the peer. * @param tgsCred the Credentials to be used to construct the @@ -99,10 +89,10 @@ public class KrbApReq { * @param tgsCred the Credentials to be used to construct the * AP Request protocol message. * @param mutualRequired Whether mutual authentication is required - * @param useSubkey Whether the subkey is to be used to protect this + * @param useSubKey Whether the subkey is to be used to protect this * specific application session. If this is not set then the * session key from the ticket will be used. - * @param checksum checksum of the application data that accompanies + * @param cksum checksum of the application data that accompanies * the KRB_AP_REQ. * @throws KrbException for any Kerberos protocol specific error * @throws IOException for any IO related errors @@ -142,8 +132,8 @@ public class KrbApReq { * Constructs an AP-REQ message from the bytes received from the * peer. * @param message The message received from the peer - * @param keys EncrtyptionKeys to decrypt the message; - * key selected will depend on etype used to encrypte data + * @param cred KrbAcceptCredential containing keys to decrypt + * the message; key selected will depend on etype used to encrypt data * @throws KrbException for any Kerberos protocol specific error * @throws IOException for any IO related errors * (e.g. socket operations) @@ -311,7 +301,14 @@ public class KrbApReq { if (!authenticator.ctime.inClockSkew()) throw new KrbApErrException(Krb5.KRB_AP_ERR_SKEW); - byte[] hash = md.digest(apReqMessg.authenticator.cipher); + byte[] hash; + try { + hash = MessageDigest.getInstance("MD5") + .digest(apReqMessg.authenticator.cipher); + } catch (NoSuchAlgorithmException ex) { + throw new AssertionError("Impossible"); + } + char[] h = new char[hash.length * 2]; for (int i=0; i>4]; diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java index 83ba779778b..7dd97ebd058 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"Venezuelanische Zeit", "VET", "Venezuelanische Sommerzeit", "VEST", "Venezuelanische Zeit", "VET"}}, diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java index 2b472669498..99f48b2d902 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"Hora de Venezuela", "VET", "Hora de verano de Venezuela", "VEST", "Hora de Venezuela", "VET"}}, diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java index 41aefbdad90..9a89c8508df 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"Heure du Venezuela", "VET", "Heure d'\u00e9t\u00e9 du Venezuela", "VEST", "Heure du Venezuela", "VET"}}, diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java index 8f350fbf337..b3edb6e4236 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"Ora del Venezuela", "VET", "Ora estiva del Venezuela", "VEST", "Ora del Venezuela", "VET"}}, diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java index 5ae2aa07994..df5d3acbba2 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"\u30d9\u30cd\u30ba\u30a8\u30e9\u6642\u9593", "VET", "\u30d9\u30cd\u30ba\u30a8\u30e9\u590f\u6642\u9593", "VEST", "\u30D9\u30CD\u30BA\u30A8\u30E9\u6642\u9593", "VET"}}, diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java index a35768503d1..2ef152babc1 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"\ubca0\ub124\uc218\uc5d8\ub77c \uc2dc\uac04", "VET", "\ubca0\ub124\uc218\uc5d8\ub77c \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "VEST", "\uBCA0\uB124\uC218\uC5D8\uB77C \uD45C\uC900\uC2DC", "VET"}}, diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java index 942081c5315..9ff7e574c84 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"Fuso hor\u00e1rio da Venezuela", "VET", "Fuso hor\u00e1rio de ver\u00e3o da Venezuela", "VEST", "Hor\u00E1rio da Venezuela", "VET"}}, diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java index bd77d58b881..916c2c5d981 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"Venezuela, normaltid", "VET", "Venezuela, sommartid", "VEST", "Venezuelansk tid", "VET"}}, diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java index c0590e574b1..5cb70c85eb9 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"\u59d4\u5185\u745e\u62c9\u65f6\u95f4", "VET", "\u59d4\u5185\u745e\u62c9\u590f\u4ee4\u65f6", "VEST", "\u59D4\u5185\u745E\u62C9\u65F6\u95F4", "VET"}}, diff --git a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java index 19c332dea10..0074f49da8b 100644 --- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java +++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, 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 @@ -409,7 +409,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"America/Buenos_Aires", AGT}, {"America/Cambridge_Bay", MST}, {"America/Campo_Grande", AMT}, - {"America/Cancun", CST}, + {"America/Cancun", EST}, {"America/Caracas", new String[] {"\u59d4\u5167\u745e\u62c9\u6642\u9593", "VET", "\u59d4\u5167\u745e\u62c9\u590f\u4ee4\u6642\u9593", "VEST", "\u59D4\u5167\u745E\u62C9\u6642\u9593", "VET"}}, diff --git a/jdk/test/Makefile b/jdk/test/Makefile index 52700cd58d0..792ee4151a6 100644 --- a/jdk/test/Makefile +++ b/jdk/test/Makefile @@ -267,8 +267,8 @@ ifdef CONCURRENCY EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY) endif -# Default JTREG to run (win32 script works for everybody) -JTREG = $(JT_HOME)/win32/bin/jtreg +# Default JTREG to run +JTREG = $(JT_HOME)/bin/jtreg # run in agentvm mode JTREG_BASIC_OPTIONS += -agentvm # Only run automatic tests diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index fde49fa1203..9a313918574 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -1,6 +1,6 @@ ########################################################################### # -# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2015, 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 @@ -123,7 +123,6 @@ # 8029891 java/lang/ClassLoader/deadlock/GetResource.java generic-all - ############################################################################ # jdk_instrument @@ -132,6 +131,9 @@ java/lang/ClassLoader/deadlock/GetResource.java generic-all java/lang/instrument/RedefineBigClass.sh generic-all java/lang/instrument/RetransformBigClass.sh generic-all +# 8072130 +java/lang/instrument/BootClassPath/BootClassPathTest.sh macosx-all + ############################################################################ # jdk_management @@ -139,6 +141,9 @@ java/lang/instrument/RetransformBigClass.sh generic-all # 8058492 java/lang/management/ThreadMXBean/FindDeadlocks.java generic-all +# 8069286 +java/lang/management/MemoryMXBean/LowMemoryTest.java generic-all + ############################################################################ # jdk_jmx @@ -162,6 +167,9 @@ javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java generi # 6988950 demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all +# 8071968 +javax/xml/ws/8046817/GenerateEnumSchema.java windows-all + ############################################################################ # jdk_net @@ -290,15 +298,18 @@ com/sun/jdi/JdbMethodExitTest.sh generic-all # 8043571 com/sun/jdi/RepStep.java generic-all -# 8044419 -com/sun/jdi/JdbReadTwiceTest.sh generic-all - # 8058616 com/sun/jdi/RedefinePop.sh generic-all # 8068645 com/sun/jdi/CatchPatternTest.sh generic-all +# 8069402 +com/sun/jdi/ConnectedVMs.java generic-all + +# 8067354 +com/sun/jdi/GetLocalVariables4Test.sh windows-all + ############################################################################ # jdk_util @@ -317,6 +328,9 @@ java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java generic- # 8031482 sun/tools/jcmd/TestJcmdSanity.java windows-all +# 8072131 +sun/tools/jmap/heapconfig/JMapHeapConfigTest.java macosx-all + # 8027668 sun/tools/jstatd/TestJstatdDefaults.java generic-all sun/tools/jstatd/TestJstatdServer.java generic-all diff --git a/jdk/test/com/sun/jdi/ImmutableResourceTest.sh b/jdk/test/com/sun/jdi/ImmutableResourceTest.sh index 29c72ed6254..95bc8778b6e 100644 --- a/jdk/test/com/sun/jdi/ImmutableResourceTest.sh +++ b/jdk/test/com/sun/jdi/ImmutableResourceTest.sh @@ -92,7 +92,7 @@ fi # echo "JDK under test is: $TESTJAVA" # -CP="-classpath ${TESTCLASSES}${PATHSEP}${TESTJAVA}/lib/tools.jar" +CP="-classpath ${TESTCLASSES}" # Compile the test class using the classpath we need: # env diff --git a/jdk/test/com/sun/jdi/JITDebug.sh b/jdk/test/com/sun/jdi/JITDebug.sh index c647e1153b5..423fe26521a 100644 --- a/jdk/test/com/sun/jdi/JITDebug.sh +++ b/jdk/test/com/sun/jdi/JITDebug.sh @@ -103,15 +103,15 @@ if [ -z "${TESTJAVA}" ] ; then #if running standalone (no test harness of any kind), compile the #support files and the test case ${TESTJAVA}/bin/javac -d ${TESTCLASSES} \ - -classpath "$TESTJAVA/lib/tools.jar${PATHSEP}${TESTSRC}" \ + -classpath "${TESTSRC}" \ TestScaffold.java VMConnection.java TargetListener.java TargetAdapter.java ${TESTJAVA}/bin/javac -d ${TESTCLASSES} \ - -classpath "$TESTJAVA/lib/tools.jar${PATHSEP}${TESTSRC}" -g \ + -classpath "${TESTSRC}" -g \ JITDebug.java fi echo "JDK under test is: $TESTJAVA" # -CLASSPATH="$TESTJAVA/lib/tools.jar${PATHSEP}${TESTCLASSES}" +CLASSPATH="${TESTCLASSES}" export CLASSPATH CP="-classpath \"${CLASSPATH}\"" # diff --git a/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh b/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh index b7ca50de096..0c78fe5ec81 100644 --- a/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh +++ b/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh @@ -204,27 +204,37 @@ if [ ! -r c:/ ] ; then clean fi +echo +echo "+++++++++++++++++++++++++++++++++++" +echo "Read an unreadable file - verify the read fails." -if [ ! -r c:/ ] ; then - # Can't make a file unreadable under MKS. - echo - echo "+++++++++++++++++++++++++++++++++++" - echo "Read an unreadable file - verify the read fails." - # If the file exists, we try to read it. The - # read will fail. - mkFiles $HOME/jdb.ini - id > $HOME/jdb.ini - chmod a-r $HOME/jdb.ini - if grep -q "uid=" $HOME/jdb.ini ; then - echo "Unable to make file unreadable, so test will fail. chmod: $HOME/jdb.ini" - if grep -q "uid=0" $HOME/jdb.ini ; then - echo "The test is running as root. Fix infrastructure!" - fi - fi +canMakeUnreadable=No +id > $HOME/jdb.ini +if chmod a-r $HOME/jdb.ini +then + grep -q 'uid=0(' $HOME/jdb.ini 2> /dev/null + case $? in + 0) + echo "Error! Can't make file unreadable running as root" + ;; + 1) + echo "Error! Can't make file unreadable for some other reason (windows?)" + ;; + *) + echo "OK. the file is unreadable" + canMakeUnreadable=Yes + ;; + esac +else + echo "Error! Can't create or chmod file" +fi + +if [ "$canMakeUnreadable" = "Yes" ] +then doit failIfNot 1 "open: $HOME/jdb.ini" - clean fi +clean echo @@ -246,8 +256,8 @@ echo "read $fred" > $here/jdb.ini doit failIfNot 1 "from $fred" - if [ ! -r c:/ ] ; then - # Can't make a file unreadable under MKS + if [ "$canMakeUnreadable" = "Yes" ] + then chmod a-r $fred doit failIfNot 1 "open: $fred" diff --git a/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.java b/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.java index c01f54a79f4..11a522c727f 100644 --- a/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.java +++ b/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.java @@ -22,9 +22,8 @@ */ /* - * Creates a URLClassLoader from 2 file URLs. The first - * file URL is constructed from the given argument. The - * second is the SDK tools.jar. Once created the test + * Creates a URLClassLoader from a file URL. The file URL + * is constructed from the given argument. Once created the test * attempts to load another test case (ListConnectors) * using the class loader and then it invokes the list() * method. @@ -39,13 +38,9 @@ public class JdiLoadedByCustomLoader { public static void main(String args[]) throws Exception { // create files from given arguments and tools.jar File f1 = new File(args[0]); - String home = System.getProperty("java.home"); - String tools = ".." + File.separatorChar + "lib" + - File.separatorChar + "tools.jar"; - File f2 = (new File(home, tools)).getCanonicalFile(); // create class loader - URL[] urls = { f1.toURL(), f2.toURL() }; + URL[] urls = { f1.toURL() }; URLClassLoader cl = new URLClassLoader(urls); // load ListConnectors using the class loader diff --git a/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh b/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh index 2b104822b17..d508c00c727 100644 --- a/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh +++ b/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh @@ -68,7 +68,7 @@ SOMEOTHERDIR="${TESTCLASSES}"/someotherdir $JAVAC -d "${TESTCLASSES}" "${TESTSRC}"/JdiLoadedByCustomLoader.java mkdir "${SOMEOTHERDIR}" -$JAVAC -d "${SOMEOTHERDIR}" -classpath "${TESTSRC}${PS}${TESTJAVA}/lib/tools.jar" \ +$JAVAC -d "${SOMEOTHERDIR}" -classpath "${TESTSRC}" \ "${TESTSRC}"/ListConnectors.java # Run the test diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java index 378310cf56a..27d80ffa106 100644 --- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java +++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java @@ -62,7 +62,7 @@ public class CheckOrigin { "-XX:+UseConcMarkSweepGC", // this will cause UseParNewGC to be FLAG_SET_ERGO "-XX:+PrintGCDetails", "-XX:Flags=" + flagsFile.getAbsolutePath(), - "-cp", System.getProperty("test.class.path") + File.pathSeparator + getToolsJarPath(), + "-cp", System.getProperty("test.class.path"), "CheckOrigin", "-runtests"); @@ -137,8 +137,4 @@ public class CheckOrigin { vm.detach(); } - private static String getToolsJarPath() { - return System.getProperty("java.home") + - "/../lib/tools.jar".replace("/", File.separator); - } } diff --git a/jdk/test/com/sun/tools/attach/BasicTests.java b/jdk/test/com/sun/tools/attach/BasicTests.java index e462cf6463f..e5f4b4bd941 100644 --- a/jdk/test/com/sun/tools/attach/BasicTests.java +++ b/jdk/test/com/sun/tools/attach/BasicTests.java @@ -80,8 +80,7 @@ public class BasicTests { // Need to add jdk/lib/tools.jar to classpath. String classpath = - System.getProperty("test.class.path", "") + File.pathSeparator + - System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar"; + System.getProperty("test.class.path", ""); String testClassDir = System.getProperty("test.classes", "") + sep; // Argumenta : -classpath cp BasicTests$TestMain pid agent badagent redefineagent diff --git a/jdk/test/com/sun/tools/attach/PermissionTest.java b/jdk/test/com/sun/tools/attach/PermissionTest.java index 471f6fc5953..b171fcea593 100644 --- a/jdk/test/com/sun/tools/attach/PermissionTest.java +++ b/jdk/test/com/sun/tools/attach/PermissionTest.java @@ -71,10 +71,8 @@ public class PermissionTest { private static void runTests(long pid) throws Throwable { final String sep = File.separator; - // Need to add jdk/lib/tools.jar to classpath. String classpath = - System.getProperty("test.class.path", "") + File.pathSeparator + - System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar"; + System.getProperty("test.class.path", ""); String testSrc = System.getProperty("test.src", "") + sep; // Use a policy that will NOT allow attach. Test will verify exception. diff --git a/jdk/test/com/sun/tools/attach/ProviderTest.java b/jdk/test/com/sun/tools/attach/ProviderTest.java index 883951f444d..146c17f071b 100644 --- a/jdk/test/com/sun/tools/attach/ProviderTest.java +++ b/jdk/test/com/sun/tools/attach/ProviderTest.java @@ -68,11 +68,10 @@ public class ProviderTest { String testClasses = System.getProperty("test.classes", "") + sep; String jdkLib = System.getProperty("test.jdk", ".") + sep + "lib" + sep; - // Need to add SimpleProvider.jar and tools.jar to classpath. + // Need to add SimpleProvider.jar to classpath. String classpath = testClassPath + File.pathSeparator + - testClasses + "SimpleProvider.jar" + File.pathSeparator + - jdkLib + "tools.jar"; + testClasses + "SimpleProvider.jar"; String[] args = { "-classpath", diff --git a/jdk/test/com/sun/tools/attach/TempDirTest.java b/jdk/test/com/sun/tools/attach/TempDirTest.java index 86e3edda742..7aa41dc80d6 100644 --- a/jdk/test/com/sun/tools/attach/TempDirTest.java +++ b/jdk/test/com/sun/tools/attach/TempDirTest.java @@ -120,10 +120,8 @@ public class TempDirTest { private static void launchTests(long pid, Path clientTmpDir) throws Throwable { final String sep = File.separator; - // Need to add jdk/lib/tools.jar to classpath. String classpath = - System.getProperty("test.class.path", "") + File.pathSeparator + - System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar"; + System.getProperty("test.class.path", ""); String[] tmpDirArg = null; if (clientTmpDir != null) { diff --git a/jdk/test/java/lang/instrument/IsModifiableClassAgent.java b/jdk/test/java/lang/instrument/IsModifiableClassAgent.java index 31329dfd3a1..bb2130924ba 100644 --- a/jdk/test/java/lang/instrument/IsModifiableClassAgent.java +++ b/jdk/test/java/lang/instrument/IsModifiableClassAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, 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,7 +23,6 @@ /** * @test - * @ignore JDK-8068162 * @bug 6331574 * @summary test isModifiableClass * @author Robert Field, Sun Microsystems diff --git a/jdk/test/java/nio/channels/FileLock/FileLockConstructor.java b/jdk/test/java/nio/channels/FileLock/FileLockConstructor.java new file mode 100644 index 00000000000..4655ebf80e9 --- /dev/null +++ b/jdk/test/java/nio/channels/FileLock/FileLockConstructor.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2015, 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. + */ + +import java.io.File; +import java.io.IOException; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; +import java.nio.file.StandardOpenOption; + +/* + * @test + * @bug 6880737 + * @summary Test FileLock constructor parameter validation. + */ +public class FileLockConstructor { + public static void main(String[] args) throws IOException { + FileLock fileLock = null; + int failures = 0; + + // null FileChannel + boolean exceptionThrown = false; + try { + fileLock = new FileLockSub((FileChannel)null, 0, 0, false); + } catch (NullPointerException npe) { + exceptionThrown = true; + } + if (!exceptionThrown) { + System.err.println("FileLock constructor did not throw NPE for null FileChannel"); + failures++; + } + + // null AsynchronousFileChannel + exceptionThrown = false; + try { + fileLock = new FileLockSub((AsynchronousFileChannel)null, 0, 0, true); + } catch (NullPointerException npe) { + exceptionThrown = true; + } + if (!exceptionThrown) { + System.err.println("FileLock constructor did not throw NPE for null AsynchronousFileChannel"); + failures++; + } + + // create temporary file + File tmpFile = File.createTempFile("FileLock", "tmp"); + tmpFile.deleteOnExit(); + + // position and size preconditions + long[][] posAndSize = new long[][] { + {0, 42}, // valid + {-1, 42}, // invalid: position < 0 + {0, -1}, // invalid: size < 0 + {Long.MAX_VALUE, 1} // invalid: position + size < 0 + }; + + // test position and size preconditions for FileChannel case + try (FileChannel syncChannel = FileChannel.open(tmpFile.toPath(), + StandardOpenOption.READ, StandardOpenOption.WRITE)) { + + for (int i = 0; i < posAndSize.length; i++) { + boolean preconditionsHold = i == 0; + exceptionThrown = false; + try { + fileLock = new FileLockSub(syncChannel, posAndSize[i][0], + posAndSize[i][1], true); + } catch (IllegalArgumentException iae) { + exceptionThrown = true; + } catch (Exception e) { + System.err.println("Unexpected exception \"" + e + "\" caught" + + " for position " + posAndSize[i][0] + " and size " + + posAndSize[i][1] + " for FileChannel variant"); + failures++; + continue; + } + if (preconditionsHold && exceptionThrown) { + System.err.println("FileLock constructor incorrectly threw IAE" + + " for position " + posAndSize[i][0] + " and size " + + posAndSize[i][1] + " for FileChannel variant"); + failures++; + } else if (!preconditionsHold && !exceptionThrown) { + System.err.println("FileLock constructor did not throw IAE" + + " for position " + posAndSize[i][0] + " and size " + + posAndSize[i][1] + " for FileChannel variant"); + failures++; + } + } + } + + // test position and size preconditions for AsynchronousFileChannel case + try (AsynchronousFileChannel asyncChannel + = AsynchronousFileChannel.open(tmpFile.toPath(), + StandardOpenOption.READ, StandardOpenOption.WRITE)) { + for (int i = 0; i < posAndSize.length; i++) { + boolean preconditionsHold = i == 0; + exceptionThrown = false; + try { + fileLock = new FileLockSub(asyncChannel, posAndSize[i][0], + posAndSize[i][1], true); + } catch (IllegalArgumentException iae) { + exceptionThrown = true; + } catch (Exception e) { + System.err.println("Unexpected exception \"" + e + "\" caught" + + " for position " + posAndSize[i][0] + " and size " + + posAndSize[i][1] + " for AsynchronousFileChannel variant"); + failures++; + continue; + } + if (preconditionsHold && exceptionThrown) { + System.err.println("FileLock constructor incorrectly threw IAE" + + " for position " + posAndSize[i][0] + " and size " + + posAndSize[i][1] + " for AsynchronousFileChannel variant"); + failures++; + } else if (!preconditionsHold && !exceptionThrown) { + System.err.println("FileLock constructor did not throw IAE" + + " for position " + posAndSize[i][0] + " and size " + + posAndSize[i][1] + " for AsynchronousFileChannel variant"); + failures++; + } + } + } + + if (failures > 0) { + throw new RuntimeException("Incurred " + failures + + " failures while testing FileLock."); + } + } +} + +class FileLockSub extends FileLock { + FileLockSub(FileChannel channel, long position, long size, boolean shared) { + super(channel, position, size, shared); + } + + FileLockSub(AsynchronousFileChannel channel, long position, long size, + boolean shared) { + super(channel, position, size, shared); + } + + @Override + public boolean isValid() { + return false; + } + + @Override + public void release() throws IOException { + // do nothing + } +} diff --git a/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java b/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java index 40ed5347589..51b1163dbca 100644 --- a/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java +++ b/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -292,7 +292,8 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { expected = LocalDateTime.now(Clock.system(zone)); test = LocalDateTime.now(zone); } - assertEquals(test, expected); + assertEquals(test.truncatedTo(ChronoUnit.SECONDS), + expected.truncatedTo(ChronoUnit.SECONDS)); } //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/tck/java/time/TCKLocalTime.java b/jdk/test/java/time/tck/java/time/TCKLocalTime.java index f79e8fc41f6..88f99ca8c65 100644 --- a/jdk/test/java/time/tck/java/time/TCKLocalTime.java +++ b/jdk/test/java/time/tck/java/time/TCKLocalTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -246,7 +246,8 @@ public class TCKLocalTime extends AbstractDateTimeTest { expected = LocalTime.now(Clock.system(zone)); test = LocalTime.now(zone); } - assertEquals(test, expected); + assertEquals(test.truncatedTo(ChronoUnit.SECONDS), + expected.truncatedTo(ChronoUnit.SECONDS)); } //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java b/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java index fb743e87b14..11ace2decf4 100644 --- a/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java +++ b/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -260,7 +260,8 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { expected = ZonedDateTime.now(Clock.system(zone)); test = ZonedDateTime.now(zone); } - assertEquals(test, expected); + assertEquals(test.truncatedTo(ChronoUnit.SECONDS), + expected.truncatedTo(ChronoUnit.SECONDS)); } //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java b/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java index de83e1d3bc3..8e2d341aaa5 100644 --- a/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java +++ b/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java @@ -59,6 +59,7 @@ package tck.java.time.chrono; import static java.time.temporal.ChronoField.ERA; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.time.chrono.Era; import java.time.chrono.JapaneseChronology; @@ -69,7 +70,8 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** - * Test. + * Tests for JapaneseEra + * @bug 8068278 */ @Test public class TCKJapaneseEra { @@ -84,6 +86,20 @@ public class TCKJapaneseEra { }; } + @DataProvider(name = "InvalidJapaneseEras") + Object[][] data_of_invalid_eras() { + return new Object[][] { + {-2}, + {-3}, + {3}, + {Integer.MIN_VALUE}, + {Integer.MAX_VALUE}, + }; + } + + //----------------------------------------------------------------------- + // JapaneseEra value test + //----------------------------------------------------------------------- @Test(dataProvider="JapaneseEras") public void test_valueOf(JapaneseEra era , String eraName, int eraValue) { assertEquals(era.getValue(), eraValue); @@ -118,4 +134,11 @@ public class TCKJapaneseEra { } } + //----------------------------------------------------------------------- + // JapaneseChronology.INSTANCE.eraOf invalid era test + //----------------------------------------------------------------------- + @Test(dataProvider="InvalidJapaneseEras", expectedExceptions=java.time.DateTimeException.class) + public void test_outofrange(int era) { + JapaneseChronology.INSTANCE.eraOf(era); + } } diff --git a/jdk/test/java/time/test/java/time/TestClock_System.java b/jdk/test/java/time/test/java/time/TestClock_System.java index 881a76060a1..527008920cc 100644 --- a/jdk/test/java/time/test/java/time/TestClock_System.java +++ b/jdk/test/java/time/test/java/time/TestClock_System.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -62,7 +62,9 @@ package test.java.time; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertSame; +import java.lang.reflect.Field; import java.time.Clock; +import java.time.Instant; import java.time.ZoneId; import org.testng.annotations.Test; @@ -87,4 +89,298 @@ public class TestClock_System { assertEquals(test.toString(), "SystemClock[Europe/Paris]"); } + //----------------------------------------------------------------------- + + private static String formatTime(String prefix, Instant time) { + return prefix + ": " + time + " - seconds: " + + time.getEpochSecond() + ", nanos: " + + time.getNano(); + } + + public void test_ClockResolution() { + Clock highestUTC = Clock.systemUTC(); + + Instant start = Instant.ofEpochMilli(System.currentTimeMillis()); + + try { + // smoke test + Instant system1 = Instant.ofEpochMilli(System.currentTimeMillis()); + Instant system2 = Instant.ofEpochMilli(System.currentTimeMillis()); + Instant highest1 = highestUTC.instant(); + Instant highest2 = highestUTC.instant(); + System.out.println(formatTime("\nsystemUTC #1 ", system1)); + System.out.println(formatTime("systemUTC #2 ", system2)); + System.out.println(formatTime("highestResolutionUTC #1 ", highest1)); + System.out.println(formatTime("highestResolutionUTC #2 ", highest2)); + + if (system2.isBefore(system1)) { + System.err.println("system2 is before system1!"); + System.err.println(formatTime("\n\tsystem1", system1)); + System.err.println(formatTime("\n\tsystem2", system2)); + throw new RuntimeException("system2 is before system1!" + + formatTime("\n\tsystem1", system1) + + formatTime("\n\tsystem2", system2)); + } + if (highest2.isBefore(highest1)) { + System.err.println("highest2 is before highest1!"); + System.err.println(formatTime("\n\thighest1", system1)); + System.err.println(formatTime("\n\tsystem2", highest2)); + throw new RuntimeException("highest2 is before system1!" + + formatTime("\n\thighest1", system1) + + formatTime("\n\tsystem2", highest2)); + } + + // better test - but depends on implementation details. + // we're not rounding - so highest1 should be greater or equal to + // system1 + system1 = Instant.ofEpochMilli(System.currentTimeMillis()); + highest1 = highestUTC.instant(); + + System.out.println(formatTime("\nsystemUTC ", system1)); + System.out.println(formatTime("highestResolutionUTC ", highest1)); + + if (highest1.isBefore(system1)) { + System.err.println("highest1 is before system1!"); + System.err.println(formatTime("\n\tsystem1", system1)); + System.err.println(formatTime("\n\thighest1", highest1)); + throw new RuntimeException("highest1 is before system1!" + + formatTime("\n\tsystem1", system1) + + formatTime("\n\thighest1", highest1)); + } + + int count=0; + // let's preheat the system a bit: + for (int i = 0; i < 1000 ; i++) { + system1 = Instant.ofEpochMilli(System.currentTimeMillis()); + highest1 = highestUTC.instant(); + final int sysnan = system1.getNano(); + final int nanos = highest1.getNano(); + if ((nanos % 1000000) > 0) { + count++; // we have micro seconds + } + if ((sysnan % 1000000) > 0) { + throw new RuntimeException("Expected only millisecconds " + + "precision for systemUTC, found " + + (sysnan % 1000000) + " remainder."); + } + } + System.out.println("\nNumber of time stamps which had better than" + + " millisecond precision: "+count+"/"+1000); + System.out.println(formatTime("\nsystemUTC ", system1)); + System.out.println(formatTime("highestResolutionUTC ", highest1)); + if (count == 0) { + System.err.println("Something is strange: no microsecond " + + "precision with highestResolutionUTC?"); + throw new RuntimeException("Micro second preccision not reached"); + } + + // check again + if (highest1.isBefore(system1)) { + System.err.println("highest1 is before system1!"); + System.err.println(formatTime("\n\tsystem1", system1)); + System.err.println(formatTime("\n\thighest1", highest1)); + throw new RuntimeException("highest1 is before system1!" + + formatTime("\n\tsystem1", system1) + + formatTime("\n\thighest1", highest1)); + } + + // leap of faith: ensure that highest1 is from within 10 secs of + // system1 + if (highest1.toEpochMilli() != system1.toEpochMilli()) { + long delta = highest1.getEpochSecond() - system1.getEpochSecond(); + if (delta > 10) { + throw new RuntimeException("Unexpected long delay between two clocks (" + + delta + " seconds)" + + formatTime("\n\t system1", system1) + + formatTime("\n\t highest1", highest1)); + + } + } else { + System.out.println("You won the lottery: the two dates are within 1 millisecond!\n"); + } + + } finally { + Instant stop = Instant.ofEpochMilli(System.currentTimeMillis()); + if (start.isAfter(stop)) { + // This should not happen - but can (un)probably be observed + // when switching to summer time, or if another application + // is switching the system date... + System.err.println("Cannot test - date was setback: " + + formatTime("\n\tstarted at", start) + + formatTime("\n\tstopped at", stop) + "\n"); + return; // will prevent exceptions from being propagated. + } + } + } + + static final long MAX_OFFSET = 0x0100000000L; + static final long MIN_OFFSET = -MAX_OFFSET; + + // A helper class to test that SystemClock correctly recomputes + // its offset. + static class SystemClockOffset { + + static final int MILLIS_IN_SECOND = 1000; + static final int NANOS_IN_MILLI = 1000_000; + static final int NANOS_IN_MICRO = 1000; + static final int NANOS_IN_SECOND = 1000_000_000; + + static final boolean verbose = true; + static final Clock systemUTC = Clock.systemUTC(); + static final Field offsetField; + + static { + try { + offsetField = Class.forName("java.time.Clock$SystemClock").getDeclaredField("offset"); + offsetField.setAccessible(true); + } catch (ClassNotFoundException | NoSuchFieldException ex) { + throw new ExceptionInInitializerError(ex); + } + } + + static enum Answer { + + YES, // isOffLimit = YES: we must get -1 + NO, // isOffLimit = NO: we must not not get -1 + MAYBE // isOffLimit = MAYBE: we might get -1 or a valid adjustment. + }; + + static long distance(long one, long two) { + return one > two ? Math.subtractExact(one, two) + : Math.subtractExact(two, one); + } + + static Answer isOffLimits(long before, long after, long offset) { + long relativeDistanceBefore = distance(before, offset); + long relativeDistanceAfter = distance(after, offset); + if (relativeDistanceBefore >= MAX_OFFSET && relativeDistanceAfter >= MAX_OFFSET) { + return Answer.YES; + } + if (relativeDistanceBefore < MAX_OFFSET && relativeDistanceAfter < MAX_OFFSET) { + if (relativeDistanceBefore == 0 || relativeDistanceAfter == 0) { + return Answer.MAYBE; // unlucky case where + } + return Answer.NO; + } + return Answer.MAYBE; + } + + static void testWithOffset(String name, long offset) + throws IllegalAccessException { + testWithOffset(name, offset, systemUTC); + } + + static void testWithOffset(String name, long offset, Clock clock) + throws IllegalAccessException { + offsetField.set(clock, offset); + long beforeMillis = System.currentTimeMillis(); + final Instant instant = clock.instant(); + long afterMillis = System.currentTimeMillis(); + long actualOffset = offsetField.getLong(clock); + long instantMillis = instant.getEpochSecond() * MILLIS_IN_SECOND + + instant.getNano() / NANOS_IN_MILLI; + if (instantMillis < beforeMillis || instantMillis > afterMillis) { + throw new RuntimeException(name + + ": Invalid instant: " + instant + + " (~" + instantMillis + "ms)" + + " when time in millis is in [" + + beforeMillis + ", " + afterMillis + + "] and offset in seconds is " + offset); + } + Answer isOffLimits = isOffLimits(beforeMillis / MILLIS_IN_SECOND, + afterMillis / MILLIS_IN_SECOND, offset); + switch (isOffLimits) { + case YES: + if (actualOffset == offset) { + throw new RuntimeException(name + + ": offset was offlimit but was not recomputed " + + " when time in millis is in [" + + beforeMillis + ", " + afterMillis + + "] and offset in seconds was " + offset); + } + break; + case NO: + if (actualOffset != offset) { + throw new RuntimeException(name + + ": offset was not offlimit but was recomputed."); + } + break; + default: + break; + } + if (distance(actualOffset, instant.getEpochSecond()) >= MAX_OFFSET) { + throw new RuntimeException(name + ": Actual offset is too far off:" + + " offset=" + actualOffset + + "instant.seconds=" + instant.getEpochSecond()); + } + long adjustment = (instant.getEpochSecond() - actualOffset) * NANOS_IN_SECOND + + instant.getNano(); + validateAdjustment(name, actualOffset, beforeMillis, afterMillis, adjustment); + } + + static void validateAdjustment(String name, long offset, long beforeMillis, + long afterMillis, long adjustment) { + System.out.println("Validating adjustment: " + adjustment); + long expectedMax = distance(offset, beforeMillis / MILLIS_IN_SECOND) + * NANOS_IN_SECOND + + (beforeMillis % MILLIS_IN_SECOND) * NANOS_IN_MILLI + + (afterMillis - beforeMillis + 1) * NANOS_IN_MILLI; + long absoluteAdjustment = distance(0, adjustment); + if (absoluteAdjustment > expectedMax) { + long adjSec = absoluteAdjustment / NANOS_IN_SECOND; + long adjMil = (absoluteAdjustment % NANOS_IN_SECOND) / NANOS_IN_MILLI; + long adjMic = (absoluteAdjustment % NANOS_IN_MILLI) / NANOS_IN_MICRO; + long adjNan = (absoluteAdjustment % NANOS_IN_MICRO); + long expSec = expectedMax / NANOS_IN_SECOND; + long expMil = (expectedMax % NANOS_IN_SECOND) / NANOS_IN_MILLI; + long expMic = (expectedMax % NANOS_IN_MILLI) / NANOS_IN_MICRO; + long expNan = (expectedMax % NANOS_IN_MICRO); + System.err.println("Excessive adjustment: " + adjSec + "s, " + + adjMil + "ms, " + adjMic + "mics, " + adjNan + "ns"); + System.err.println("Epected max: " + expSec + "s, " + + expMil + "ms, " + expMic + "mics, " + expNan + "ns"); + + throw new RuntimeException(name + + ": Excessive adjustment: " + adjustment + + " when time in millis is in [" + + beforeMillis + ", " + afterMillis + + "] and offset in seconds is " + offset); + } + } + } + + public void test_OffsetRegular() throws IllegalAccessException { + System.out.println("*** Testing regular cases ***"); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000", + System.currentTimeMillis()/1000); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - 1024", + System.currentTimeMillis()/1000 - 1024); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 + 1024", + System.currentTimeMillis()/1000 + 1024); + } + + public void test_OffsetLimits() throws IllegalAccessException { + System.out.println("*** Testing limits ***"); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET + 1", + System.currentTimeMillis()/1000 - MAX_OFFSET + 1); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET - 1", + System.currentTimeMillis()/1000 + MAX_OFFSET - 1); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET", + System.currentTimeMillis()/1000 - MAX_OFFSET); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET", + System.currentTimeMillis()/1000 + MAX_OFFSET); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET - 1024", + System.currentTimeMillis()/1000 - MAX_OFFSET - 1024); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET + 1024", + System.currentTimeMillis()/1000 + MAX_OFFSET + 1024); + SystemClockOffset.testWithOffset("0", 0); + SystemClockOffset.testWithOffset("-1", -1); + SystemClockOffset.testWithOffset("Integer.MAX_VALUE + System.currentTimeMillis()/1000", + ((long)Integer.MAX_VALUE) + System.currentTimeMillis()/1000); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - Integer.MIN_VALUE", + System.currentTimeMillis()/1000 - Integer.MIN_VALUE); + SystemClockOffset.testWithOffset("Long.MAX_VALUE", Long.MAX_VALUE); + SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - Long.MIN_VALUE", + (Long.MIN_VALUE + System.currentTimeMillis()/1000)*-1); + } } diff --git a/jdk/test/java/time/test/java/util/TestFormatter.java b/jdk/test/java/time/test/java/util/TestFormatter.java index 67a73cee697..5cf2163412c 100644 --- a/jdk/test/java/time/test/java/util/TestFormatter.java +++ b/jdk/test/java/time/test/java/util/TestFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -38,6 +38,7 @@ import java.time.chrono.Chronology; import java.time.temporal.ChronoField; import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalAccessor; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.*; @@ -153,6 +154,44 @@ public class TestFormatter { if (verbose) { System.out.printf("%-24s : %s%n", getClassName(dt), out); } + + // expected usually comes from Calendar which only has milliseconds + // precision. So we're going to replace it's N:[nanos] stamp with + // the correct value for nanos. + if ((dt instanceof TemporalAccessor) && expected != null) { + try { + // Get millis & nanos from the dt + final TemporalAccessor ta = (TemporalAccessor) dt; + final int nanos = ta.get(ChronoField.NANO_OF_SECOND); + final int millis = ta.get(ChronoField.MILLI_OF_SECOND); + final String nanstr = String.valueOf(nanos); + final String mistr = String.valueOf(millis); + + // Compute the value of the N:[nanos] field that we expect + // to find in 'out' + final StringBuilder sb = new StringBuilder(); + sb.append("N:["); + for (int i=nanstr.length(); i<9; i++) { + sb.append('0'); + } + sb.append(nanos).append("]"); + + // Compute the truncated value of N:[nanos] field that might + // be in 'expected' when expected was built from Calendar. + final StringBuilder sbm = new StringBuilder(); + sbm.append("N:["); + for (int i=mistr.length(); i<3; i++) { + sbm.append('0'); + } + sbm.append(mistr).append("000000]"); + + // if expected contains the truncated value, replace it with + // the complete value. + expected = expected.replace(sbm.toString(), sb.toString()); + } catch (UnsupportedTemporalTypeException e) { + // nano seconds unsupported - nothing to do... + } + } if (expected != null && !out.equals(expected)) { System.out.printf("%-24s actual: %s%n FAILED; expected: %s%n", getClassName(dt), out, expected); diff --git a/jdk/test/java/util/Optional/Basic.java b/jdk/test/java/util/Optional/Basic.java index dc05ff97a78..f37397d90b9 100644 --- a/jdk/test/java/util/Optional/Basic.java +++ b/jdk/test/java/util/Optional/Basic.java @@ -29,6 +29,7 @@ import java.util.NoSuchElementException; import java.util.Optional; +import java.util.stream.Stream; import static org.testng.Assert.*; import org.testng.annotations.Test; @@ -54,8 +55,8 @@ public class Basic { assertSame(null, empty.orElse(null)); RuntimeException orElse = new RuntimeException() { }; assertSame(Boolean.FALSE, empty.orElse(Boolean.FALSE)); - assertSame(null, empty.orElseGet(()-> null)); - assertSame(Boolean.FALSE, empty.orElseGet(()-> Boolean.FALSE)); + assertSame(null, empty.orElseGet(() -> null)); + assertSame(Boolean.FALSE, empty.orElseGet(() -> Boolean.FALSE)); } @Test(expectedExceptions=NoSuchElementException.class) @@ -104,15 +105,15 @@ public class Basic { try { present.ifPresent(v -> { throw new ObscureException(); }); fail(); - } catch(ObscureException expected) { + } catch (ObscureException expected) { } assertSame(Boolean.TRUE, present.orElse(null)); assertSame(Boolean.TRUE, present.orElse(Boolean.FALSE)); assertSame(Boolean.TRUE, present.orElseGet(null)); - assertSame(Boolean.TRUE, present.orElseGet(()-> null)); - assertSame(Boolean.TRUE, present.orElseGet(()-> Boolean.FALSE)); - assertSame(Boolean.TRUE, present.orElseThrow( null)); + assertSame(Boolean.TRUE, present.orElseGet(() -> null)); + assertSame(Boolean.TRUE, present.orElseGet(() -> Boolean.FALSE)); + assertSame(Boolean.TRUE, present.orElseThrow(null)); assertSame(Boolean.TRUE, present.orElseThrow(ObscureException::new)); } @@ -226,6 +227,26 @@ public class Basic { assertSame(l, fixture); } + @Test(groups = "unit") + public void testStream() { + { + Stream s = Optional.empty().stream(); + assertFalse(s.isParallel()); + + Object[] es = s.toArray(); + assertEquals(es.length, 0); + } + + { + Stream s = Optional.of("Duke").stream(); + assertFalse(s.isParallel()); + + String[] es = s.toArray(String[]::new); + assertEquals(es.length, 1); + assertEquals(es[0], "Duke"); + } + } + private static class ObscureException extends RuntimeException { } diff --git a/jdk/test/java/util/Optional/BasicDouble.java b/jdk/test/java/util/Optional/BasicDouble.java index 841dd459e78..df8ae9e0431 100644 --- a/jdk/test/java/util/Optional/BasicDouble.java +++ b/jdk/test/java/util/Optional/BasicDouble.java @@ -29,6 +29,7 @@ import java.util.NoSuchElementException; import java.util.OptionalDouble; +import java.util.stream.DoubleStream; import static org.testng.Assert.*; import org.testng.annotations.Test; @@ -109,6 +110,26 @@ public class BasicDouble { assertEquals(1.0, present.orElseThrow(ObscureException::new)); } + @Test(groups = "unit") + public void testStream() { + { + DoubleStream s = OptionalDouble.empty().stream(); + assertFalse(s.isParallel()); + + double[] es = s.toArray(); + assertEquals(es.length, 0); + } + + { + DoubleStream s = OptionalDouble.of(42.0).stream(); + assertFalse(s.isParallel()); + + double[] es = s.toArray(); + assertEquals(es.length, 1); + assertEquals(es[0], 42.0); + } + } + private static class ObscureException extends RuntimeException { } diff --git a/jdk/test/java/util/Optional/BasicInt.java b/jdk/test/java/util/Optional/BasicInt.java index fa29f95208a..8f3b2d5d82c 100644 --- a/jdk/test/java/util/Optional/BasicInt.java +++ b/jdk/test/java/util/Optional/BasicInt.java @@ -29,6 +29,7 @@ import java.util.NoSuchElementException; import java.util.OptionalInt; +import java.util.stream.IntStream; import static org.testng.Assert.*; import org.testng.annotations.Test; @@ -53,36 +54,36 @@ public class BasicInt { assertEquals(2, empty.orElseGet(()-> 2)); } - @Test(expectedExceptions=NoSuchElementException.class) - public void testEmptyGet() { - OptionalInt empty = OptionalInt.empty(); + @Test(expectedExceptions=NoSuchElementException.class) + public void testEmptyGet() { + OptionalInt empty = OptionalInt.empty(); - int got = empty.getAsInt(); - } + int got = empty.getAsInt(); + } - @Test(expectedExceptions=NullPointerException.class) - public void testEmptyOrElseGetNull() { - OptionalInt empty = OptionalInt.empty(); + @Test(expectedExceptions=NullPointerException.class) + public void testEmptyOrElseGetNull() { + OptionalInt empty = OptionalInt.empty(); - int got = empty.orElseGet(null); - } + int got = empty.orElseGet(null); + } - @Test(expectedExceptions=NullPointerException.class) - public void testEmptyOrElseThrowNull() throws Throwable { - OptionalInt empty = OptionalInt.empty(); + @Test(expectedExceptions=NullPointerException.class) + public void testEmptyOrElseThrowNull() throws Throwable { + OptionalInt empty = OptionalInt.empty(); - int got = empty.orElseThrow(null); - } + int got = empty.orElseThrow(null); + } - @Test(expectedExceptions=ObscureException.class) - public void testEmptyOrElseThrow() throws Exception { - OptionalInt empty = OptionalInt.empty(); + @Test(expectedExceptions=ObscureException.class) + public void testEmptyOrElseThrow() throws Exception { + OptionalInt empty = OptionalInt.empty(); - int got = empty.orElseThrow(ObscureException::new); - } + int got = empty.orElseThrow(ObscureException::new); + } - @Test(groups = "unit") - public void testPresent() { + @Test(groups = "unit") + public void testPresent() { OptionalInt empty = OptionalInt.empty(); OptionalInt present = OptionalInt.of(1); @@ -109,6 +110,26 @@ public class BasicInt { assertEquals(1, present.orElseThrow(ObscureException::new)); } + @Test(groups = "unit") + public void testStream() { + { + IntStream s = OptionalInt.empty().stream(); + assertFalse(s.isParallel()); + + int[] es = s.toArray(); + assertEquals(es.length, 0); + } + + { + IntStream s = OptionalInt.of(42).stream(); + assertFalse(s.isParallel()); + + int[] es = OptionalInt.of(42).stream().toArray(); + assertEquals(es.length, 1); + assertEquals(es[0], 42); + } + } + private static class ObscureException extends RuntimeException { } diff --git a/jdk/test/java/util/Optional/BasicLong.java b/jdk/test/java/util/Optional/BasicLong.java index 85bf689ad46..39b29375cac 100644 --- a/jdk/test/java/util/Optional/BasicLong.java +++ b/jdk/test/java/util/Optional/BasicLong.java @@ -29,6 +29,7 @@ import java.util.NoSuchElementException; import java.util.OptionalLong; +import java.util.stream.LongStream; import static org.testng.Assert.*; import org.testng.annotations.Test; @@ -109,6 +110,24 @@ public class BasicLong { assertEquals(1, present.orElseThrow(ObscureException::new)); } + @Test(groups = "unit") + public void testStream() { + { + LongStream s = OptionalLong.empty().stream(); + + long[] es = s.toArray(); + assertEquals(es.length, 0); + } + + { + LongStream s = OptionalLong.of(42L).stream(); + + long[] es = s.toArray(); + assertEquals(es.length, 1); + assertEquals(es[0], 42L); + } + } + private static class ObscureException extends RuntimeException { } diff --git a/jdk/test/java/util/concurrent/CompletableFuture/ThenComposeExceptionTest.java b/jdk/test/java/util/concurrent/CompletableFuture/ThenComposeExceptionTest.java index ad77c863d9f..877bbb9fd4d 100644 --- a/jdk/test/java/util/concurrent/CompletableFuture/ThenComposeExceptionTest.java +++ b/jdk/test/java/util/concurrent/CompletableFuture/ThenComposeExceptionTest.java @@ -36,7 +36,7 @@ import java.util.function.Consumer; /** * @test - * @bug 8068432 + * @bug 8068432 8072030 * @run testng ThenComposeExceptionTest * @summary Test that CompletableFuture.thenCompose works correctly if the * composing future completes exceptionally @@ -92,7 +92,8 @@ public class ThenComposeExceptionTest { Assert.assertNotSame(f_thenCompose, fe, "Composed CompletableFuture returned directly"); AtomicReference eOnWhenComplete = new AtomicReference<>(); - f_thenCompose.whenComplete((r, e) -> eOnWhenComplete.set(e)); + CompletableFuture f_whenComplete = f_thenCompose. + whenComplete((r, e) -> eOnWhenComplete.set(e)); afterAction.accept(fe); @@ -103,10 +104,20 @@ public class ThenComposeExceptionTest { catch (Throwable t) { eOnJoined = t; } - - Assert.assertTrue(eOnWhenComplete.get() instanceof CompletionException, - "Incorrect exception reported on whenComplete"); Assert.assertTrue(eOnJoined instanceof CompletionException, - "Incorrect exception reported when joined"); + "Incorrect exception reported when joined on thenCompose: " + eOnJoined); + + // Need to wait for f_whenComplete to complete to avoid + // race condition when updating eOnWhenComplete + eOnJoined = null; + try { + f_whenComplete.join(); + } catch (Throwable t) { + eOnJoined = t; + } + Assert.assertTrue(eOnJoined instanceof CompletionException, + "Incorrect exception reported when joined on whenComplete: " + eOnJoined); + Assert.assertTrue(eOnWhenComplete.get() instanceof CompletionException, + "Incorrect exception passed to whenComplete: " + eOnWhenComplete.get()); } -} +} \ No newline at end of file diff --git a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java index ac0911a52ca..0f2978f9b71 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java +++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java @@ -145,13 +145,7 @@ public class CustomLauncherTest { ProcessBuilder client = ProcessTools.createJavaProcessBuilder( "-cp", - TEST_CLASSPATH + - File.pathSeparator + - TEST_JDK + - File.separator + - "lib" + - File.separator + - "tools.jar", + TEST_CLASSPATH, "TestManager", String.valueOf(serverPrc.getPid()), port.get(), diff --git a/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java b/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java index 87ab6a9245e..1306f4e31a6 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java +++ b/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java @@ -132,13 +132,7 @@ public class LocalManagementTest { ProcessBuilder client = ProcessTools.createJavaProcessBuilder( "-cp", - TEST_CLASSPATH + - File.pathSeparator + - TEST_JDK + - File.separator + - "lib" + - File.separator + - "tools.jar", + TEST_CLASSPATH, "TestManager", String.valueOf(serverPrc.getPid()), port.get(), diff --git a/jdk/test/sun/misc/VM/GetNanoTimeAdjustment.java b/jdk/test/sun/misc/VM/GetNanoTimeAdjustment.java new file mode 100644 index 00000000000..bfeb8c0c7f3 --- /dev/null +++ b/jdk/test/sun/misc/VM/GetNanoTimeAdjustment.java @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2015, 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. + */ +import java.util.Objects; +import sun.misc.VM; + +/** + * @test + * @bug 8068730 + * @summary tests that VM.getgetNanoTimeAdjustment() works as expected. + * @run main GetNanoTimeAdjustment + * @author danielfuchs + */ +public class GetNanoTimeAdjustment { + + static final int MILLIS_IN_SECOND = 1000; + static final int NANOS_IN_MILLI = 1000_000; + static final int NANOS_IN_MICRO = 1000; + static final int NANOS_IN_SECOND = 1000_000_000; + + static final boolean verbose = true; + + static final class TestAssertException extends RuntimeException { + TestAssertException(String msg) { super(msg); } + } + + private static void assertEquals(long expected, long received, String msg) { + if (expected != received) { + throw new TestAssertException("Unexpected result for " + msg + + ".\n\texpected: " + expected + + "\n\tactual: " + received); + } else if (verbose) { + System.out.println("Got expected " + msg + ": " + received); + } + } + + private static void assertEquals(Object expected, Object received, String msg) { + if (!Objects.equals(expected, received)) { + throw new TestAssertException("Unexpected result for " + msg + + ".\n\texpected: " + expected + + "\n\tactual: " + received); + } else if (verbose) { + System.out.println("Got expected " + msg + ": " + received); + } + } + + static final long MAX_OFFSET = 0x0100000000L; + static final long MIN_OFFSET = -MAX_OFFSET; + static enum Answer { + YES, // isOffLimit = YES: we must get -1 + NO, // isOffLimit = NO: we must not not get -1 + MAYBE // isOffLimit = MAYBE: we might get -1 or a valid adjustment. + }; + static long distance(long one, long two) { + return one > two ? Math.subtractExact(one, two) + : Math.subtractExact(two, one); + } + + + static Answer isOffLimits(long before, long after, long offset) { + long relativeDistanceBefore = distance(before, offset); + long relativeDistanceAfter = distance(after, offset); + if (relativeDistanceBefore >= MAX_OFFSET && relativeDistanceAfter >= MAX_OFFSET) { + return Answer.YES; + } + if (relativeDistanceBefore < MAX_OFFSET && relativeDistanceAfter < MAX_OFFSET) { + if (relativeDistanceBefore == 0 || relativeDistanceAfter == 0) { + return Answer.MAYBE; // unlucky case where + } + return Answer.NO; + } + return Answer.MAYBE; + } + + static void testWithOffset(String name, long offset) { + System.out.println("Testing with offset: " + name); + long beforeMillis = System.currentTimeMillis(); + long adjustment = VM.getNanoTimeAdjustment(offset); + long afterMillis = System.currentTimeMillis(); + + if (offset >= beforeMillis/MILLIS_IN_SECOND + && offset <= afterMillis/MILLIS_IN_SECOND) { + if (adjustment == -1) { + // it's possible that we have fallen in the unlucky case + // where -1 was the genuine result. let's go backward a bit. + offset = offset - 10; + beforeMillis = System.currentTimeMillis(); + adjustment = VM.getNanoTimeAdjustment(offset); + afterMillis = System.currentTimeMillis(); + if (adjustment == -1) { + throw new RuntimeException(name + ": VM says " + offset + + " secs is too far off, " + + " when time in seconds is in [" + + beforeMillis/MILLIS_IN_SECOND + ", " + + afterMillis/MILLIS_IN_SECOND + + "]"); + } + } + } + + Answer isOffLimit = isOffLimits(beforeMillis/MILLIS_IN_SECOND, + afterMillis/MILLIS_IN_SECOND, offset); + switch (isOffLimit) { + case YES: + if (adjustment != -1) { + throw new RuntimeException(name + + ": VM should have returned -1 for " + + offset + + " when time in seconds is in [" + + beforeMillis/MILLIS_IN_SECOND + ", " + + afterMillis/MILLIS_IN_SECOND + "]"); + } + System.out.println("Got expected exception value: " + adjustment); + break; + case NO: + if (adjustment == -1) { + throw new RuntimeException(name + + "VM says " + offset + + " secs is too far off, " + + " when time in seconds is in [" + + beforeMillis/MILLIS_IN_SECOND + ", " + + afterMillis/MILLIS_IN_SECOND + + "]"); + } + break; + case MAYBE: + System.out.println("Adjustment: " + adjustment); + System.out.println("Can't assert for -1 with offset " + + offset + "(" + name + ")" + + " when time in seconds is in [" + + beforeMillis/MILLIS_IN_SECOND + ", " + + afterMillis/MILLIS_IN_SECOND + + "]"); + // not conclusive + } + + if (isOffLimit == Answer.NO || adjustment != -1) { + System.out.println("Validating adjustment: " + adjustment); + long expectedMax = distance(offset, beforeMillis/MILLIS_IN_SECOND) + * NANOS_IN_SECOND + + (beforeMillis % MILLIS_IN_SECOND) * NANOS_IN_MILLI + + (afterMillis - beforeMillis + 1) * NANOS_IN_MILLI; + long absoluteAdjustment = distance(0, adjustment); + if (absoluteAdjustment > expectedMax) { + long adjSec = absoluteAdjustment / NANOS_IN_SECOND; + long adjMil = (absoluteAdjustment % NANOS_IN_SECOND) / NANOS_IN_MILLI; + long adjMic = (absoluteAdjustment % NANOS_IN_MILLI) / NANOS_IN_MICRO; + long adjNan = (absoluteAdjustment % NANOS_IN_MICRO); + long expSec = expectedMax / NANOS_IN_SECOND; + long expMil = (expectedMax % NANOS_IN_SECOND) / NANOS_IN_MILLI; + long expMic = (expectedMax % NANOS_IN_MILLI) / NANOS_IN_MICRO; + long expNan = (expectedMax % NANOS_IN_MICRO); + System.err.println("Excessive adjustment: " + adjSec + "s, " + + adjMil + "ms, " + adjMic + "mics, " + adjNan + "ns"); + System.err.println("Epected max: " + expSec + "s, " + + expMil + "ms, " + expMic + "mics, " + expNan + "ns"); + + throw new RuntimeException(name + + ": Excessive adjustment: " + adjustment + + " when time in millis is in [" + + beforeMillis + ", " + afterMillis + + "] and offset in seconds is " + offset); + } + } + + } + + static void regular() { + System.out.println("*** Testing regular cases ***"); + final long start = System.currentTimeMillis(); + long offset = start/1000; + long adjustment = VM.getNanoTimeAdjustment(offset); + if (start != offset*1000) { + if (adjustment == -1) { + throw new RuntimeException("VM says " + offset + + " secs is too far off, but time millis is " + + System.currentTimeMillis()); + } + } + if (adjustment == -1) { + offset = System.currentTimeMillis()/1000 - 1024; + adjustment = VM.getNanoTimeAdjustment(offset); + if (adjustment == -1) { + throw new RuntimeException("VM says " + offset + + " secs is too far off, but time millis is " + + System.currentTimeMillis()); + } + } + if (adjustment > (start/1000 - offset + 20)*NANOS_IN_SECOND) { + throw new RuntimeException("Excessive adjustment: " + adjustment); + } + testWithOffset("System.currentTimeMillis()/1000", + System.currentTimeMillis()/1000); + testWithOffset("System.currentTimeMillis()/1000 - 1024", + System.currentTimeMillis()/1000 - 1024); + testWithOffset("System.currentTimeMillis()/1000 + 1024", + System.currentTimeMillis()/1000 + 1024); + } + + static void testLimits() { + System.out.println("*** Testing limits ***"); + testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET + 1", + System.currentTimeMillis()/1000 - MAX_OFFSET + 1); + testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET - 1", + System.currentTimeMillis()/1000 + MAX_OFFSET - 1); + testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET", + System.currentTimeMillis()/1000 - MAX_OFFSET); + testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET", + System.currentTimeMillis()/1000 + MAX_OFFSET); + testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET - 1024", + System.currentTimeMillis()/1000 - MAX_OFFSET - 1024); + testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET + 1024", + System.currentTimeMillis()/1000 + MAX_OFFSET + 1024); + testWithOffset("0", 0); + testWithOffset("-1", -1); + testWithOffset("Integer.MAX_VALUE + System.currentTimeMillis()/1000", + ((long)Integer.MAX_VALUE) + System.currentTimeMillis()/1000); + testWithOffset("System.currentTimeMillis()/1000 - Integer.MIN_VALUE", + System.currentTimeMillis()/1000 - Integer.MIN_VALUE); + testWithOffset("Long.MAX_VALUE", Long.MAX_VALUE); + testWithOffset("System.currentTimeMillis()/1000 - Long.MIN_VALUE", + (Long.MIN_VALUE + System.currentTimeMillis()/1000)*-1); + } + + public static void main(String[] args) throws Exception { + regular(); + testLimits(); + } + +} diff --git a/jdk/test/sun/util/calendar/zi/tzdata/VERSION b/jdk/test/sun/util/calendar/zi/tzdata/VERSION index 9987fde6dcb..034114ae6ca 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/VERSION +++ b/jdk/test/sun/util/calendar/zi/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2014j +tzdata2015a diff --git a/jdk/test/sun/util/calendar/zi/tzdata/antarctica b/jdk/test/sun/util/calendar/zi/tzdata/antarctica index 0cdac270861..1f3e4347b21 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/antarctica +++ b/jdk/test/sun/util/calendar/zi/tzdata/antarctica @@ -70,8 +70,8 @@ Rule ChileAQ 2009 only - Mar Sun>=9 3:00u 0 - Rule ChileAQ 2010 only - Apr Sun>=1 3:00u 0 - Rule ChileAQ 2011 only - May Sun>=2 3:00u 0 - Rule ChileAQ 2011 only - Aug Sun>=16 4:00u 1:00 S -Rule ChileAQ 2012 max - Apr Sun>=23 3:00u 0 - -Rule ChileAQ 2012 max - Sep Sun>=2 4:00u 1:00 S +Rule ChileAQ 2012 2015 - Apr Sun>=23 3:00u 0 - +Rule ChileAQ 2012 2014 - Sep Sun>=2 4:00u 1:00 S # Argentina - year-round bases # Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05 @@ -377,9 +377,10 @@ Zone Antarctica/Rothera 0 - zzz 1976 Dec 1 # # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Antarctica/Palmer 0 - zzz 1965 - -4:00 ArgAQ AR%sT 1969 Oct 5 + -4:00 ArgAQ AR%sT 1969 Oct 5 -3:00 ArgAQ AR%sT 1982 May - -4:00 ChileAQ CL%sT + -4:00 ChileAQ CL%sT 2015 Apr 26 3:00u + -3:00 - CLT # # # McMurdo Station, Ross Island, since 1955-12 diff --git a/jdk/test/sun/util/calendar/zi/tzdata/asia b/jdk/test/sun/util/calendar/zi/tzdata/asia index 960cab5062e..bff837c48d8 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/asia +++ b/jdk/test/sun/util/calendar/zi/tzdata/asia @@ -168,10 +168,7 @@ Zone Asia/Baku 3:19:24 - LMT 1924 May 2 4:00 Azer AZ%sT # Bahrain -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Bahrain 3:22:20 - LMT 1920 # Manamah - 4:00 - GST 1972 Jun - 3:00 - AST +# See Asia/Qatar. # Bangladesh # From Alexander Krivenyshev (2009-05-13): @@ -1754,9 +1751,7 @@ Zone Asia/Pyongyang 8:23:00 - LMT 1908 Apr 1 ############################################################################### # Kuwait -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Kuwait 3:11:56 - LMT 1950 - 3:00 - AST +# See Asia/Riyadh. # Laos # See Asia/Bangkok. @@ -1977,12 +1972,7 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920 5:45 - NPT # Nepal Time # Oman - -# Milne says 3:54:24 was the meridian of the Muscat Tidal Observatory. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Muscat 3:54:24 - LMT 1920 - 4:00 - GST +# See Asia/Dubai. # Pakistan @@ -2476,6 +2466,7 @@ Zone Asia/Manila -15:56:00 - LMT 1844 Dec 31 Zone Asia/Qatar 3:26:08 - LMT 1920 # Al Dawhah / Doha 4:00 - GST 1972 Jun 3:00 - AST +Link Asia/Qatar Asia/Bahrain # Saudi Arabia # @@ -2502,6 +2493,8 @@ Zone Asia/Qatar 3:26:08 - LMT 1920 # Al Dawhah / Doha # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Riyadh 3:06:52 - LMT 1947 Mar 14 3:00 - AST +Link Asia/Riyadh Asia/Aden # Yemen +Link Asia/Riyadh Asia/Kuwait # Singapore # taken from Mok Ly Yng (2003-10-30) @@ -2790,6 +2783,7 @@ Zone Asia/Ashgabat 3:53:32 - LMT 1924 May 2 # or Ashkhabad # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Dubai 3:41:12 - LMT 1920 4:00 - GST +Link Asia/Dubai Asia/Muscat # Oman # Uzbekistan # Byalokoz 1919 says Uzbekistan was 4:27:53. @@ -2874,10 +2868,4 @@ Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jul 1 7:00 - ICT # Yemen - -# Milne says 2:59:54 was the meridian of the saluting battery at Aden, -# and that Yemen was at 1:55:56, the meridian of the Hagia Sophia. - -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Asia/Aden 2:59:54 - LMT 1950 - 3:00 - AST +# See Asia/Riyadh. diff --git a/jdk/test/sun/util/calendar/zi/tzdata/backward b/jdk/test/sun/util/calendar/zi/tzdata/backward index ba012f45733..95266a6f16c 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/backward +++ b/jdk/test/sun/util/calendar/zi/tzdata/backward @@ -28,7 +28,7 @@ # and their old names. Many names changed in late 1993. # Link TARGET LINK-NAME -Link Africa/Asmara Africa/Asmera +Link Africa/Nairobi Africa/Asmera Link Africa/Abidjan Africa/Timbuktu Link America/Argentina/Catamarca America/Argentina/ComodRivadavia Link America/Adak America/Atka diff --git a/jdk/test/sun/util/calendar/zi/tzdata/europe b/jdk/test/sun/util/calendar/zi/tzdata/europe index 2ed6ad36b5d..89790f06c17 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/europe +++ b/jdk/test/sun/util/calendar/zi/tzdata/europe @@ -1430,35 +1430,32 @@ Zone Europe/Budapest 1:16:20 - LMT 1890 Oct # might be a reference to the Julian calendar as opposed to Gregorian, or it # might mean something else (???). # -# From Paul Eggert (2006-03-22): -# The Iceland Almanak, Shanks & Pottenger, and Whitman disagree on many points. -# We go with the Almanak, except for one claim from Shanks & Pottenger, namely -# that Reykavik was 21W57 from 1837 to 1908, local mean time before that. +# From Paul Eggert (2014-11-22): +# The information below is taken from the 1988 Almanak; see +# http://www.almanak.hi.is/klukkan.html # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Iceland 1917 1918 - Feb 19 23:00 1:00 S +Rule Iceland 1917 1919 - Feb 19 23:00 1:00 S Rule Iceland 1917 only - Oct 21 1:00 0 - -Rule Iceland 1918 only - Nov 16 1:00 0 - +Rule Iceland 1918 1919 - Nov 16 1:00 0 - +Rule Iceland 1921 only - Mar 19 23:00 1:00 S +Rule Iceland 1921 only - Jun 23 1:00 0 - Rule Iceland 1939 only - Apr 29 23:00 1:00 S -Rule Iceland 1939 only - Nov 29 2:00 0 - +Rule Iceland 1939 only - Oct 29 2:00 0 - Rule Iceland 1940 only - Feb 25 2:00 1:00 S -Rule Iceland 1940 only - Nov 3 2:00 0 - -Rule Iceland 1941 only - Mar 2 1:00s 1:00 S -Rule Iceland 1941 only - Nov 2 1:00s 0 - -Rule Iceland 1942 only - Mar 8 1:00s 1:00 S -Rule Iceland 1942 only - Oct 25 1:00s 0 - +Rule Iceland 1940 1941 - Nov Sun>=2 1:00s 0 - +Rule Iceland 1941 1942 - Mar Sun>=2 1:00s 1:00 S # 1943-1946 - first Sunday in March until first Sunday in winter Rule Iceland 1943 1946 - Mar Sun>=1 1:00s 1:00 S -Rule Iceland 1943 1948 - Oct Sun>=22 1:00s 0 - +Rule Iceland 1942 1948 - Oct Sun>=22 1:00s 0 - # 1947-1967 - first Sunday in April until first Sunday in winter Rule Iceland 1947 1967 - Apr Sun>=1 1:00s 1:00 S -# 1949 Oct transition delayed by 1 week +# 1949 and 1967 Oct transitions delayed by 1 week Rule Iceland 1949 only - Oct 30 1:00s 0 - Rule Iceland 1950 1966 - Oct Sun>=22 1:00s 0 - Rule Iceland 1967 only - Oct 29 1:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Atlantic/Reykjavik -1:27:24 - LMT 1837 - -1:27:48 - RMT 1908 # Reykjavik Mean Time? +Zone Atlantic/Reykjavik -1:28 - LMT 1908 -1:00 Iceland IS%sT 1968 Apr 7 1:00s 0:00 - GMT diff --git a/jdk/test/sun/util/calendar/zi/tzdata/leapseconds b/jdk/test/sun/util/calendar/zi/tzdata/leapseconds index 7612f2bc9b7..9b0a2278433 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/leapseconds +++ b/jdk/test/sun/util/calendar/zi/tzdata/leapseconds @@ -77,3 +77,7 @@ Leap 1998 Dec 31 23:59:60 + S Leap 2005 Dec 31 23:59:60 + S Leap 2008 Dec 31 23:59:60 + S Leap 2012 Jun 30 23:59:60 + S +Leap 2015 Jun 30 23:59:60 + S + +# Updated through IERS Bulletin C49 +# File expires on: 28 December 2015 diff --git a/jdk/test/sun/util/calendar/zi/tzdata/northamerica b/jdk/test/sun/util/calendar/zi/tzdata/northamerica index 86c9503a4eb..5943cfeec4b 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/northamerica +++ b/jdk/test/sun/util/calendar/zi/tzdata/northamerica @@ -147,7 +147,7 @@ Rule US 1918 1919 - Mar lastSun 2:00 1:00 D Rule US 1918 1919 - Oct lastSun 2:00 0 S Rule US 1942 only - Feb 9 2:00 1:00 W # War Rule US 1945 only - Aug 14 23:00u 1:00 P # Peace -Rule US 1945 only - Sep 30 2:00 0 S +Rule US 1945 only - Sep lastSun 2:00 0 S Rule US 1967 2006 - Oct lastSun 2:00 0 S Rule US 1967 1973 - Apr lastSun 2:00 1:00 D Rule US 1974 only - Jan 6 2:00 1:00 D @@ -2147,11 +2147,11 @@ Zone America/Dawson -9:17:40 - LMT 1900 Aug 20 # Mexico -# From Paul Eggert (2001-03-05): +# From Paul Eggert (2014-12-07): # The Investigation and Analysis Service of the # Mexican Library of Congress (MLoC) has published a # history of Mexican local time (in Spanish) -# http://www.cddhcu.gob.mx/bibliot/publica/inveyana/polisoc/horver/ +# http://www.diputados.gob.mx/bibliot/publica/inveyana/polisoc/horver/index.htm # # Here are the discrepancies between Shanks & Pottenger (S&P) and the MLoC. # (In all cases we go with the MLoC.) @@ -2320,6 +2320,24 @@ Zone America/Dawson -9:17:40 - LMT 1900 Aug 20 # efecto desde las dos horas del segundo domingo de marzo y concluirá a # las dos horas del primer domingo de noviembre. +# From Steffen Thorsen (2014-12-08), translated by Gwillim Law: +# The Mexican state of Quintana Roo will likely change to EST in 2015. +# +# http://www.unioncancun.mx/articulo/2014/12/04/medio-ambiente/congreso-aprueba-una-hora-mas-de-sol-en-qroo +# "With this change, the time conflict that has existed between the municipios +# of Quintana Roo and the municipio of Felipe Carrillo Puerto may come to an +# end. The latter declared itself in rebellion 15 years ago when a time change +# was initiated in Mexico, and since then it has refused to change its time +# zone along with the rest of the country." +# +# From Steffen Thorsen (2015-01-14), translated by Gwillim Law: +# http://sipse.com/novedades/confirman-aplicacion-de-nueva-zona-horaria-para-quintana-roo-132331.html +# "...the new time zone will come into effect at two o'clock on the first Sunday +# of February, when we will have to advance the clock one hour from its current +# time..." +# +# Also, the new zone will not use DST. + # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Mexico 1939 only - Feb 5 0:00 1:00 D Rule Mexico 1939 only - Jun 25 0:00 0 S @@ -2340,7 +2358,8 @@ Rule Mexico 2002 max - Oct lastSun 2:00 0 S Zone America/Cancun -5:47:04 - LMT 1922 Jan 1 0:12:56 -6:00 - CST 1981 Dec 23 -5:00 Mexico E%sT 1998 Aug 2 2:00 - -6:00 Mexico C%sT + -6:00 Mexico C%sT 2015 Feb 1 2:00 + -5:00 - EST # Campeche, Yucatán; represented by Mérida Zone America/Merida -5:58:28 - LMT 1922 Jan 1 0:01:32 -6:00 - CST 1981 Dec 23 diff --git a/jdk/test/sun/util/calendar/zi/tzdata/southamerica b/jdk/test/sun/util/calendar/zi/tzdata/southamerica index 0b70dea5616..02cf12113a0 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/southamerica +++ b/jdk/test/sun/util/calendar/zi/tzdata/southamerica @@ -1229,6 +1229,11 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC) # http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf +# From Juan Correa (2015-01-28): +# ... today the Ministry of Energy announced that Chile will drop DST, will keep +# "summer time" (UTC -3 / UTC -5) all year round.... +# http://www.minenergia.cl/ministerio/noticias/generales/ministerio-de-energia-anuncia.html + # NOTE: ChileAQ rules for Antarctic bases are stored separately in the # 'antarctica' file. @@ -1270,8 +1275,8 @@ Rule Chile 2009 only - Mar Sun>=9 3:00u 0 - Rule Chile 2010 only - Apr Sun>=1 3:00u 0 - Rule Chile 2011 only - May Sun>=2 3:00u 0 - Rule Chile 2011 only - Aug Sun>=16 4:00u 1:00 S -Rule Chile 2012 max - Apr Sun>=23 3:00u 0 - -Rule Chile 2012 max - Sep Sun>=2 4:00u 1:00 S +Rule Chile 2012 2015 - Apr Sun>=23 3:00u 0 - +Rule Chile 2012 2014 - Sep Sun>=2 4:00u 1:00 S # IATA SSIM anomalies: (1992-02) says 1992-03-14; # (1996-09) says 1998-03-08. Ignore these. # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -1282,11 +1287,13 @@ Zone America/Santiago -4:42:46 - LMT 1890 -4:00 - CLT 1919 Jul 1 # Chile Time -4:42:46 - SMT 1927 Sep 1 # Santiago Mean Time -5:00 Chile CL%sT 1947 May 22 # Chile Time - -4:00 Chile CL%sT + -4:00 Chile CL%sT 2015 Apr 26 3:00u + -3:00 - CLT Zone Pacific/Easter -7:17:44 - LMT 1890 -7:17:28 - EMT 1932 Sep # Easter Mean Time - -7:00 Chile EAS%sT 1982 Mar 13 21:00 # Easter Time - -6:00 Chile EAS%sT + -7:00 Chile EAS%sT 1982 Mar 13 3:00u # Easter Time + -6:00 Chile EAS%sT 2015 Apr 26 3:00u + -5:00 - EAST # # Salas y Gómez Island is uninhabited. # Other Chilean locations, including Juan Fernández Is, Desventuradas Is, diff --git a/jdk/test/sun/util/calendar/zi/tzdata/zone.tab b/jdk/test/sun/util/calendar/zi/tzdata/zone.tab index 0ef9ba869ea..ffb6469676e 100644 --- a/jdk/test/sun/util/calendar/zi/tzdata/zone.tab +++ b/jdk/test/sun/util/calendar/zi/tzdata/zone.tab @@ -297,7 +297,7 @@ MU -2010+05730 Indian/Mauritius MV +0410+07330 Indian/Maldives MW -1547+03500 Africa/Blantyre MX +1924-09909 America/Mexico_City Central Time - most locations -MX +2105-08646 America/Cancun Central Time - Quintana Roo +MX +2105-08646 America/Cancun Eastern Standard Time - Quintana Roo MX +2058-08937 America/Merida Central Time - Campeche, Yucatan MX +2540-10019 America/Monterrey Mexican Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas away from US border MX +2550-09730 America/Matamoros US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas near US border