diff --git a/make/lib/CoreLibraries.gmk b/make/lib/CoreLibraries.gmk index a36bf90b93ed1db71c82c5506c21112b656e37cd..758fa8e59b5e300676e333204247705a7d34c732 100644 --- a/make/lib/CoreLibraries.gmk +++ b/make/lib/CoreLibraries.gmk @@ -207,7 +207,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \ LDFLAGS_SUFFIX_windows := -export:winFileHandleOpen -export:handleLseek \ jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \ shell32.lib delayimp.lib -DELAYLOAD:shell32.dll \ - advapi32.lib, \ + advapi32.lib version.lib, \ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ RC_FLAGS := $(RC_FLAGS) \ -D "JDK_FNAME=java.dll" \ diff --git a/src/share/classes/com/sun/jndi/ldap/LdapURL.java b/src/share/classes/com/sun/jndi/ldap/LdapURL.java index ada02f6f3bcc4281ceaa291e41e5bbe520641535..96365a1394506323d3eaffac63d577c438e939d5 100644 --- a/src/share/classes/com/sun/jndi/ldap/LdapURL.java +++ b/src/share/classes/com/sun/jndi/ldap/LdapURL.java @@ -26,9 +26,6 @@ package com.sun.jndi.ldap; import javax.naming.*; -import javax.naming.directory.*; -import javax.naming.spi.*; -import java.net.URL; import java.net.MalformedURLException; import java.io.UnsupportedEncodingException; import java.util.StringTokenizer; @@ -211,44 +208,53 @@ final public class LdapURL extends Uri { // query begins with a '?' or is null - if (query == null) { + if (query == null || query.length() < 2) { return; } - int qmark2 = query.indexOf('?', 1); + int currentIndex = 1; + int nextQmark; + int endIndex; - if (qmark2 < 0) { - attributes = query.substring(1); + // attributes: + nextQmark = query.indexOf('?', currentIndex); + endIndex = nextQmark == -1 ? query.length() : nextQmark; + if (endIndex - currentIndex > 0) { + attributes = query.substring(currentIndex, endIndex); + } + currentIndex = endIndex + 1; + if (currentIndex >= query.length()) { return; - } else if (qmark2 != 1) { - attributes = query.substring(1, qmark2); } - int qmark3 = query.indexOf('?', qmark2 + 1); - - if (qmark3 < 0) { - scope = query.substring(qmark2 + 1); + // scope: + nextQmark = query.indexOf('?', currentIndex); + endIndex = nextQmark == -1 ? query.length() : nextQmark; + if (endIndex - currentIndex > 0) { + scope = query.substring(currentIndex, endIndex); + } + currentIndex = endIndex + 1; + if (currentIndex >= query.length()) { return; - } else if (qmark3 != qmark2 + 1) { - scope = query.substring(qmark2 + 1, qmark3); } - int qmark4 = query.indexOf('?', qmark3 + 1); - - if (qmark4 < 0) { - filter = query.substring(qmark3 + 1); - } else { - if (qmark4 != qmark3 + 1) { - filter = query.substring(qmark3 + 1, qmark4); - } - extensions = query.substring(qmark4 + 1); - if (extensions.length() > 0) { - extensions = UrlUtil.decode(extensions, "UTF8"); - } - } - if (filter != null && filter.length() > 0) { + // filter: + nextQmark = query.indexOf('?', currentIndex); + endIndex = nextQmark == -1 ? query.length() : nextQmark; + if (endIndex - currentIndex > 0) { + filter = query.substring(currentIndex, endIndex); filter = UrlUtil.decode(filter, "UTF8"); } + currentIndex = endIndex + 1; + if (currentIndex >= query.length()) { + return; + } + + // extensions: + if (query.length() - currentIndex > 0) { + extensions = query.substring(currentIndex); + extensions = UrlUtil.decode(extensions, "UTF8"); + } } /* diff --git a/src/share/classes/java/time/DayOfWeek.java b/src/share/classes/java/time/DayOfWeek.java index ecd03f2803d7100ef4de07ca0d262230f471119a..ee49f8ac3786cd7085f64875a0d4fa75420ff511 100644 --- a/src/share/classes/java/time/DayOfWeek.java +++ b/src/share/classes/java/time/DayOfWeek.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 @@ -201,7 +201,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { * Gets the day-of-week {@code int} value. *

* The values are numbered following the ISO-8601 standard, from 1 (Monday) to 7 (Sunday). - * See {@link WeekFields#dayOfWeek} for localized week-numbering. + * See {@link java.time.temporal.WeekFields#dayOfWeek()} for localized week-numbering. * * @return the day-of-week, from 1 (Monday) to 7 (Sunday) */ @@ -288,7 +288,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { /** * Gets the value of the specified field from this day-of-week as an {@code int}. *

- * This queries this day-of-week for the value for the specified field. + * This queries this day-of-week for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -321,7 +321,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { /** * Gets the value of the specified field from this day-of-week as a {@code long}. *

- * This queries this day-of-week for the value for the specified field. + * This queries this day-of-week for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

@@ -419,7 +419,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)} * passing {@link ChronoField#DAY_OF_WEEK} as the field. * Note that this adjusts forwards or backwards within a Monday to Sunday week. - * See {@link WeekFields#dayOfWeek} for localized week start days. + * See {@link java.time.temporal.WeekFields#dayOfWeek()} for localized week start days. * See {@code TemporalAdjuster} for other adjusters with more control, * such as {@code next(MONDAY)}. *

diff --git a/src/share/classes/java/time/Duration.java b/src/share/classes/java/time/Duration.java index c53afe3ebcb466a91e2c6d5ba7b1eb1618b52be1..1e19945c83bf837526d6a06492be2fc8720c86d2 100644 --- a/src/share/classes/java/time/Duration.java +++ b/src/share/classes/java/time/Duration.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 @@ -546,7 +546,7 @@ public final class Duration * They are returned in the order seconds, nanos. *

* This set can be used in conjunction with {@link #get(TemporalUnit)} - * to access the entire state of the period. + * to access the entire state of the duration. * * @return a list containing the seconds and nanos units, not null */ @@ -686,8 +686,8 @@ public final class Duration *

* This instance is immutable and unaffected by this method call. * - * @param amountToAdd the amount of the period, measured in terms of the unit, positive or negative - * @param unit the unit that the period is measured in, must have an exact duration, not null + * @param amountToAdd the amount to add, measured in terms of the unit, positive or negative + * @param unit the unit that the amount is measured in, must have an exact duration, not null * @return a {@code Duration} based on this duration with the specified duration added, not null * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs @@ -848,8 +848,8 @@ public final class Duration *

* This instance is immutable and unaffected by this method call. * - * @param amountToSubtract the amount of the period, measured in terms of the unit, positive or negative - * @param unit the unit that the period is measured in, must have an exact duration, not null + * @param amountToSubtract the amount to subtract, measured in terms of the unit, positive or negative + * @param unit the unit that the amount is measured in, must have an exact duration, not null * @return a {@code Duration} based on this duration with the specified duration subtracted, not null * @throws ArithmeticException if numeric overflow occurs */ diff --git a/src/share/classes/java/time/Instant.java b/src/share/classes/java/time/Instant.java index 42e1b8df9662f0f8587f5e6d2c77e5a62195a3ef..91a177c9a7b8c4ff614b165994e34dd568f51cd7 100644 --- a/src/share/classes/java/time/Instant.java +++ b/src/share/classes/java/time/Instant.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 @@ -530,7 +530,7 @@ public final class Instant /** * Gets the value of the specified field from this instant as an {@code int}. *

- * This queries this instant for the value for the specified field. + * This queries this instant for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -571,7 +571,7 @@ public final class Instant /** * Gets the value of the specified field from this instant as a {@code long}. *

- * This queries this instant for the value for the specified field. + * This queries this instant for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

diff --git a/src/share/classes/java/time/LocalDate.java b/src/share/classes/java/time/LocalDate.java index 17b3b24c0ea7255c248fb47492602e5452205c47..9c060e5be079201d7f2cf610ffaf9c267cac8e49 100644 --- a/src/share/classes/java/time/LocalDate.java +++ b/src/share/classes/java/time/LocalDate.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 @@ -280,7 +280,7 @@ public final class LocalDate * @param dayOfYear the day-of-year to represent, from 1 to 366 * @return the local date, not null * @throws DateTimeException if the value of any field is out of range, - * or if the day-of-year is invalid for the month-year + * or if the day-of-year is invalid for the year */ public static LocalDate ofYearDay(int year, int dayOfYear) { YEAR.checkValidValue(year); @@ -308,7 +308,7 @@ public final class LocalDate * * @param epochDay the Epoch Day to convert, based on the epoch 1970-01-01 * @return the local date, not null - * @throws DateTimeException if the epoch days exceeds the supported date range + * @throws DateTimeException if the epoch day exceeds the supported date range */ public static LocalDate ofEpochDay(long epochDay) { long zeroDay = epochDay + DAYS_0000_TO_1970; @@ -515,7 +515,7 @@ public final class LocalDate /** * Checks if the specified unit is supported. *

- * This checks if the specified unit can be added to, or subtracted from, this date-time. + * This checks if the specified unit can be added to, or subtracted from, this date. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. *

@@ -592,7 +592,7 @@ public final class LocalDate /** * Gets the value of the specified field from this date as an {@code int}. *

- * This queries this date for the value for the specified field. + * This queries this date for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -627,7 +627,7 @@ public final class LocalDate /** * Gets the value of the specified field from this date as a {@code long}. *

- * This queries this date for the value for the specified field. + * This queries this date for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

@@ -875,7 +875,9 @@ public final class LocalDate *

* A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link TemporalAdjuster}. + *

+ * A selection of common adjustments is provided in + * {@link java.time.temporal.TemporalAdjusters TemporalAdjusters}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -885,7 +887,7 @@ public final class LocalDate * For example this code returns a date on the last day of July: *

      *  import static java.time.Month.*;
-     *  import static java.time.temporal.Adjusters.*;
+     *  import static java.time.temporal.TemporalAdjusters.*;
      *
      *  result = localDate.with(JULY).with(lastDayOfMonth());
      * 
@@ -1041,7 +1043,8 @@ public final class LocalDate //----------------------------------------------------------------------- /** - * Returns a copy of this date with the year altered. + * Returns a copy of this {@code LocalDate} with the year altered. + *

* If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. *

* This instance is immutable and unaffected by this method call. @@ -1059,7 +1062,8 @@ public final class LocalDate } /** - * Returns a copy of this date with the month-of-year altered. + * Returns a copy of this {@code LocalDate} with the month-of-year altered. + *

* If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. *

* This instance is immutable and unaffected by this method call. @@ -1077,7 +1081,8 @@ public final class LocalDate } /** - * Returns a copy of this date with the day-of-month altered. + * Returns a copy of this {@code LocalDate} with the day-of-month altered. + *

* If the resulting date is invalid, an exception is thrown. *

* This instance is immutable and unaffected by this method call. @@ -1095,7 +1100,8 @@ public final class LocalDate } /** - * Returns a copy of this date with the day-of-year altered. + * Returns a copy of this {@code LocalDate} with the day-of-year altered. + *

* If the resulting date is invalid, an exception is thrown. *

* This instance is immutable and unaffected by this method call. @@ -1245,7 +1251,7 @@ public final class LocalDate //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalDate} with the specified period in years added. + * Returns a copy of this {@code LocalDate} with the specified number of years added. *

* This method adds the specified amount to the years field in three steps: *

    @@ -1273,7 +1279,7 @@ public final class LocalDate } /** - * Returns a copy of this {@code LocalDate} with the specified period in months added. + * Returns a copy of this {@code LocalDate} with the specified number of months added. *

    * This method adds the specified amount to the months field in three steps: *

      @@ -1304,7 +1310,7 @@ public final class LocalDate } /** - * Returns a copy of this {@code LocalDate} with the specified period in weeks added. + * Returns a copy of this {@code LocalDate} with the specified number of weeks added. *

      * This method adds the specified amount in weeks to the days field incrementing * the month and year fields as necessary to ensure the result remains valid. @@ -1402,11 +1408,11 @@ public final class LocalDate //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalDate} with the specified period in years subtracted. + * Returns a copy of this {@code LocalDate} with the specified number of years subtracted. *

      * This method subtracts the specified amount from the years field in three steps: *

        - *
      1. Subtract the input years to the year field
      2. + *
      3. Subtract the input years from the year field
      4. *
      5. Check if the resulting date would be invalid
      6. *
      7. Adjust the day-of-month to the last valid day if necessary
      8. *
      @@ -1426,11 +1432,11 @@ public final class LocalDate } /** - * Returns a copy of this {@code LocalDate} with the specified period in months subtracted. + * Returns a copy of this {@code LocalDate} with the specified number of months subtracted. *

      * This method subtracts the specified amount from the months field in three steps: *

        - *
      1. Subtract the input months to the month-of-year field
      2. + *
      3. Subtract the input months from the month-of-year field
      4. *
      5. Check if the resulting date would be invalid
      6. *
      7. Adjust the day-of-month to the last valid day if necessary
      8. *
      @@ -1450,7 +1456,7 @@ public final class LocalDate } /** - * Returns a copy of this {@code LocalDate} with the specified period in weeks subtracted. + * Returns a copy of this {@code LocalDate} with the specified number of weeks subtracted. *

      * This method subtracts the specified amount in weeks from the days field decrementing * the month and year fields as necessary to ensure the result remains valid. diff --git a/src/share/classes/java/time/LocalDateTime.java b/src/share/classes/java/time/LocalDateTime.java index 86633b8416541c98e6edbabff17f0c1a46f7d363..940aafde923187e54cdc0ebd525f125801c960b1 100644 --- a/src/share/classes/java/time/LocalDateTime.java +++ b/src/share/classes/java/time/LocalDateTime.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 @@ -428,7 +428,7 @@ public final class LocalDateTime /** * Obtains an instance of {@code LocalDateTime} from a temporal object. *

      - * This obtains an offset time based on the specified temporal. + * This obtains a local date-time based on the specified temporal. * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code LocalDateTime}. *

      @@ -656,7 +656,7 @@ public final class LocalDateTime /** * Gets the value of the specified field from this date-time as an {@code int}. *

      - * This queries this date-time for the value for the specified field. + * This queries this date-time for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -693,7 +693,7 @@ public final class LocalDateTime /** * Gets the value of the specified field from this date-time as a {@code long}. *

      - * This queries this date-time for the value for the specified field. + * This queries this date-time for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

      @@ -878,7 +878,9 @@ public final class LocalDateTime *

      * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link TemporalAdjuster}. + *

      + * A selection of common adjustments is provided in + * {@link java.time.temporal.TemporalAdjusters TemporalAdjusters}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -888,7 +890,7 @@ public final class LocalDateTime * For example this code returns a date on the last day of July: *

            *  import static java.time.Month.*;
      -     *  import static java.time.temporal.Adjusters.*;
      +     *  import static java.time.temporal.TemporalAdjusters.*;
            *
            *  result = localDateTime.with(JULY).with(lastDayOfMonth());
            * 
      @@ -974,6 +976,7 @@ public final class LocalDateTime //----------------------------------------------------------------------- /** * Returns a copy of this {@code LocalDateTime} with the year altered. + *

      * The time does not affect the calculation and will be the same in the result. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. *

      @@ -989,6 +992,7 @@ public final class LocalDateTime /** * Returns a copy of this {@code LocalDateTime} with the month-of-year altered. + *

      * The time does not affect the calculation and will be the same in the result. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. *

      @@ -1004,7 +1008,8 @@ public final class LocalDateTime /** * Returns a copy of this {@code LocalDateTime} with the day-of-month altered. - * If the resulting {@code LocalDateTime} is invalid, an exception is thrown. + *

      + * If the resulting date-time is invalid, an exception is thrown. * The time does not affect the calculation and will be the same in the result. *

      * This instance is immutable and unaffected by this method call. @@ -1020,7 +1025,8 @@ public final class LocalDateTime /** * Returns a copy of this {@code LocalDateTime} with the day-of-year altered. - * If the resulting {@code LocalDateTime} is invalid, an exception is thrown. + *

      + * If the resulting date-time is invalid, an exception is thrown. *

      * This instance is immutable and unaffected by this method call. * @@ -1035,7 +1041,7 @@ public final class LocalDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalDateTime} with the hour-of-day value altered. + * Returns a copy of this {@code LocalDateTime} with the hour-of-day altered. *

      * This instance is immutable and unaffected by this method call. * @@ -1049,7 +1055,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the minute-of-hour value altered. + * Returns a copy of this {@code LocalDateTime} with the minute-of-hour altered. *

      * This instance is immutable and unaffected by this method call. * @@ -1063,7 +1069,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the second-of-minute value altered. + * Returns a copy of this {@code LocalDateTime} with the second-of-minute altered. *

      * This instance is immutable and unaffected by this method call. * @@ -1077,7 +1083,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the nano-of-second value altered. + * Returns a copy of this {@code LocalDateTime} with the nano-of-second altered. *

      * This instance is immutable and unaffected by this method call. * @@ -1109,7 +1115,7 @@ public final class LocalDateTime * @param unit the unit to truncate to, not null * @return a {@code LocalDateTime} based on this date-time with the time truncated, not null * @throws DateTimeException if unable to truncate - * @throws UnsupportedTemporalTypeException if the field is not supported + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public LocalDateTime truncatedTo(TemporalUnit unit) { return with(date, time.truncatedTo(unit)); @@ -1192,7 +1198,7 @@ public final class LocalDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalDateTime} with the specified period in years added. + * Returns a copy of this {@code LocalDateTime} with the specified number of years added. *

      * This method adds the specified amount to the years field in three steps: *

        @@ -1217,7 +1223,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in months added. + * Returns a copy of this {@code LocalDateTime} with the specified number of months added. *

        * This method adds the specified amount to the months field in three steps: *

          @@ -1242,7 +1248,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in weeks added. + * Returns a copy of this {@code LocalDateTime} with the specified number of weeks added. *

          * This method adds the specified amount in weeks to the days field incrementing * the month and year fields as necessary to ensure the result remains valid. @@ -1262,7 +1268,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in days added. + * Returns a copy of this {@code LocalDateTime} with the specified number of days added. *

          * This method adds the specified amount to the days field incrementing the * month and year fields as necessary to ensure the result remains valid. @@ -1283,7 +1289,7 @@ public final class LocalDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalDateTime} with the specified period in hours added. + * Returns a copy of this {@code LocalDateTime} with the specified number of hours added. *

          * This instance is immutable and unaffected by this method call. * @@ -1296,7 +1302,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in minutes added. + * Returns a copy of this {@code LocalDateTime} with the specified number of minutes added. *

          * This instance is immutable and unaffected by this method call. * @@ -1309,7 +1315,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in seconds added. + * Returns a copy of this {@code LocalDateTime} with the specified number of seconds added. *

          * This instance is immutable and unaffected by this method call. * @@ -1322,7 +1328,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in nanoseconds added. + * Returns a copy of this {@code LocalDateTime} with the specified number of nanoseconds added. *

          * This instance is immutable and unaffected by this method call. * @@ -1391,7 +1397,7 @@ public final class LocalDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalDateTime} with the specified period in years subtracted. + * Returns a copy of this {@code LocalDateTime} with the specified number of years subtracted. *

          * This method subtracts the specified amount from the years field in three steps: *

            @@ -1415,7 +1421,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in months subtracted. + * Returns a copy of this {@code LocalDateTime} with the specified number of months subtracted. *

            * This method subtracts the specified amount from the months field in three steps: *

              @@ -1439,7 +1445,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in weeks subtracted. + * Returns a copy of this {@code LocalDateTime} with the specified number of weeks subtracted. *

              * This method subtracts the specified amount in weeks from the days field decrementing * the month and year fields as necessary to ensure the result remains valid. @@ -1458,9 +1464,9 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in days subtracted. + * Returns a copy of this {@code LocalDateTime} with the specified number of days subtracted. *

              - * This method subtracts the specified amount from the days field incrementing the + * This method subtracts the specified amount from the days field decrementing the * month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. *

              @@ -1478,7 +1484,7 @@ public final class LocalDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalDateTime} with the specified period in hours subtracted. + * Returns a copy of this {@code LocalDateTime} with the specified number of hours subtracted. *

              * This instance is immutable and unaffected by this method call. * @@ -1491,7 +1497,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in minutes subtracted. + * Returns a copy of this {@code LocalDateTime} with the specified number of minutes subtracted. *

              * This instance is immutable and unaffected by this method call. * @@ -1504,7 +1510,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in seconds subtracted. + * Returns a copy of this {@code LocalDateTime} with the specified number of seconds subtracted. *

              * This instance is immutable and unaffected by this method call. * @@ -1517,7 +1523,7 @@ public final class LocalDateTime } /** - * Returns a copy of this {@code LocalDateTime} with the specified period in nanoseconds subtracted. + * Returns a copy of this {@code LocalDateTime} with the specified number of nanoseconds subtracted. *

              * This instance is immutable and unaffected by this method call. * @@ -1575,7 +1581,7 @@ public final class LocalDateTime * what the result of this method will be. *

              * The result of this method is obtained by invoking the - * {@link java.time.temporal.TemporalQuery#queryFrom(TemporalAccessor)} method on the + * {@link TemporalQuery#queryFrom(TemporalAccessor)} method on the * specified query passing {@code this} as the argument. * * @param the type of the result diff --git a/src/share/classes/java/time/LocalTime.java b/src/share/classes/java/time/LocalTime.java index 0fcf89d26a34691747b9e61470add329bcfb4742..c6299f4c9c770d3ed9e8cb615478e6bfd7253ca5 100644 --- a/src/share/classes/java/time/LocalTime.java +++ b/src/share/classes/java/time/LocalTime.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 @@ -93,7 +93,7 @@ import java.time.temporal.ValueRange; import java.util.Objects; /** - * A time without time-zone in the ISO-8601 calendar system, + * A time without a time-zone in the ISO-8601 calendar system, * such as {@code 10:15:30}. *

              * {@code LocalTime} is an immutable date-time object that represents a time, @@ -101,7 +101,7 @@ import java.util.Objects; * Time is represented to nanosecond precision. * For example, the value "13:45.30.123456789" can be stored in a {@code LocalTime}. *

              - * It does not store or represent a date or time-zone. + * This class does not store or represent a date or time-zone. * Instead, it is a description of the local time as seen on a wall clock. * It cannot represent an instant on the time-line without additional information * such as an offset or time-zone. @@ -280,7 +280,7 @@ public final class LocalTime return ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + now.getNano()); } - //------------------------get----------------------------------------------- + //----------------------------------------------------------------------- /** * Obtains an instance of {@code LocalTime} from an hour and minute. *

              @@ -395,7 +395,7 @@ public final class LocalTime * on extracting the {@link ChronoField#NANO_OF_DAY NANO_OF_DAY} field. *

              * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code LocalTime::from}. + * allowing it to be used as a query via method reference, {@code LocalTime::from}. * * @param temporal the temporal object to convert, not null * @return the local time, not null @@ -418,7 +418,7 @@ public final class LocalTime * The string must represent a valid time and is parsed using * {@link java.time.format.DateTimeFormatter#ISO_LOCAL_TIME}. * - * @param text the text to parse such as "10:15:30", not null + * @param text the text to parse such as "10:15:30", not null * @return the parsed local time, not null * @throws DateTimeParseException if the text cannot be parsed */ @@ -524,7 +524,7 @@ public final class LocalTime /** * Checks if the specified unit is supported. *

              - * This checks if the specified unit can be added to, or subtracted from, this date-time. + * This checks if the specified unit can be added to, or subtracted from, this time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. *

              @@ -589,7 +589,7 @@ public final class LocalTime /** * Gets the value of the specified field from this time as an {@code int}. *

              - * This queries this time for the value for the specified field. + * This queries this time for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -624,7 +624,7 @@ public final class LocalTime /** * Gets the value of the specified field from this time as a {@code long}. *

              - * This queries this time for the value for the specified field. + * This queries this time for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

              @@ -858,7 +858,7 @@ public final class LocalTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalTime} with the hour-of-day value altered. + * Returns a copy of this {@code LocalTime} with the hour-of-day altered. *

              * This instance is immutable and unaffected by this method call. * @@ -875,7 +875,7 @@ public final class LocalTime } /** - * Returns a copy of this {@code LocalTime} with the minute-of-hour value altered. + * Returns a copy of this {@code LocalTime} with the minute-of-hour altered. *

              * This instance is immutable and unaffected by this method call. * @@ -892,7 +892,7 @@ public final class LocalTime } /** - * Returns a copy of this {@code LocalTime} with the second-of-minute value altered. + * Returns a copy of this {@code LocalTime} with the second-of-minute altered. *

              * This instance is immutable and unaffected by this method call. * @@ -909,7 +909,7 @@ public final class LocalTime } /** - * Returns a copy of this {@code LocalTime} with the nano-of-second value altered. + * Returns a copy of this {@code LocalTime} with the nano-of-second altered. *

              * This instance is immutable and unaffected by this method call. * @@ -929,7 +929,7 @@ public final class LocalTime /** * Returns a copy of this {@code LocalTime} with the time truncated. *

              - * Truncating the time returns a copy of the original time with fields + * Truncation returns a copy of the original time with fields * smaller than the specified unit set to zero. * For example, truncating with the {@link ChronoUnit#MINUTES minutes} unit * will set the second-of-minute and nano-of-second field to zero. @@ -1059,7 +1059,7 @@ public final class LocalTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalTime} with the specified period in hours added. + * Returns a copy of this {@code LocalTime} with the specified number of hours added. *

              * This adds the specified number of hours to this time, returning a new time. * The calculation wraps around midnight. @@ -1078,7 +1078,7 @@ public final class LocalTime } /** - * Returns a copy of this {@code LocalTime} with the specified period in minutes added. + * Returns a copy of this {@code LocalTime} with the specified number of minutes added. *

              * This adds the specified number of minutes to this time, returning a new time. * The calculation wraps around midnight. @@ -1103,7 +1103,7 @@ public final class LocalTime } /** - * Returns a copy of this {@code LocalTime} with the specified period in seconds added. + * Returns a copy of this {@code LocalTime} with the specified number of seconds added. *

              * This adds the specified number of seconds to this time, returning a new time. * The calculation wraps around midnight. @@ -1130,7 +1130,7 @@ public final class LocalTime } /** - * Returns a copy of this {@code LocalTime} with the specified period in nanoseconds added. + * Returns a copy of this {@code LocalTime} with the specified number of nanoseconds added. *

              * This adds the specified number of nanoseconds to this time, returning a new time. * The calculation wraps around midnight. @@ -1208,7 +1208,7 @@ public final class LocalTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code LocalTime} with the specified period in hours subtracted. + * Returns a copy of this {@code LocalTime} with the specified number of hours subtracted. *

              * This subtracts the specified number of hours from this time, returning a new time. * The calculation wraps around midnight. @@ -1223,7 +1223,7 @@ public final class LocalTime } /** - * Returns a copy of this {@code LocalTime} with the specified period in minutes subtracted. + * Returns a copy of this {@code LocalTime} with the specified number of minutes subtracted. *

              * This subtracts the specified number of minutes from this time, returning a new time. * The calculation wraps around midnight. @@ -1238,7 +1238,7 @@ public final class LocalTime } /** - * Returns a copy of this {@code LocalTime} with the specified period in seconds subtracted. + * Returns a copy of this {@code LocalTime} with the specified number of seconds subtracted. *

              * This subtracts the specified number of seconds from this time, returning a new time. * The calculation wraps around midnight. @@ -1253,7 +1253,7 @@ public final class LocalTime } /** - * Returns a copy of this {@code LocalTime} with the specified period in nanoseconds subtracted. + * Returns a copy of this {@code LocalTime} with the specified number of nanoseconds subtracted. *

              * This subtracts the specified number of nanoseconds from this time, returning a new time. * The calculation wraps around midnight. @@ -1470,7 +1470,7 @@ public final class LocalTime //----------------------------------------------------------------------- /** - * Compares this {@code LocalTime} to another time. + * Compares this time to another time. *

              * The comparison is based on the time-line position of the local times within a day. * It is "consistent with equals", as defined by {@link Comparable}. @@ -1495,7 +1495,7 @@ public final class LocalTime } /** - * Checks if this {@code LocalTime} is after the specified time. + * Checks if this time is after the specified time. *

              * The comparison is based on the time-line position of the time within a day. * @@ -1508,7 +1508,7 @@ public final class LocalTime } /** - * Checks if this {@code LocalTime} is before the specified time. + * Checks if this time is before the specified time. *

              * The comparison is based on the time-line position of the time within a day. * diff --git a/src/share/classes/java/time/Month.java b/src/share/classes/java/time/Month.java index 2e85b6cf601035af38881547594b2583cd87c9ed..57382cd9845b292cb69d444b6a4571ac9a9c2cc4 100644 --- a/src/share/classes/java/time/Month.java +++ b/src/share/classes/java/time/Month.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 @@ -202,7 +202,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { * chronology, or can be converted to a {@code LocalDate}. *

              * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code Month::from}. + * allowing it to be used as a query via method reference, {@code Month::from}. * * @param temporal the temporal object to convert, not null * @return the month-of-year, not null @@ -315,7 +315,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { /** * Gets the value of the specified field from this month-of-year as an {@code int}. *

              - * This queries this month for the value for the specified field. + * This queries this month for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -348,7 +348,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { /** * Gets the value of the specified field from this month-of-year as a {@code long}. *

              - * This queries this month for the value for the specified field. + * This queries this month for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

              diff --git a/src/share/classes/java/time/MonthDay.java b/src/share/classes/java/time/MonthDay.java index 5b7844fd468008c381da3146069194d4f4d02d9e..87f753039df1a155361175ed8c018ec7c4ef1a46 100644 --- a/src/share/classes/java/time/MonthDay.java +++ b/src/share/classes/java/time/MonthDay.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 @@ -90,8 +90,8 @@ import java.util.Objects; * A month-day in the ISO-8601 calendar system, such as {@code --12-03}. *

              * {@code MonthDay} is an immutable date-time object that represents the combination - * of a year and month. Any field that can be derived from a month and day, such as - * quarter-of-year, can be obtained. + * of a month and day-of-month. Any field that can be derived from a month and day, + * such as quarter-of-year, can be obtained. *

              * This class does not store or represent a year, time or time-zone. * For example, the value "December 3rd" can be stored in a {@code MonthDay}. @@ -154,7 +154,7 @@ public final class MonthDay /** * Obtains the current month-day from the system clock in the default time-zone. *

              - * This will query the {@link java.time.Clock#systemDefaultZone() system clock} in the default + * This will query the {@link Clock#systemDefaultZone() system clock} in the default * time-zone to obtain the current month-day. *

              * Using this method will prevent the ability to use an alternate clock for testing @@ -169,7 +169,7 @@ public final class MonthDay /** * Obtains the current month-day from the system clock in the specified time-zone. *

              - * This will query the {@link Clock#system(java.time.ZoneId) system clock} to obtain the current month-day. + * This will query the {@link Clock#system(ZoneId) system clock} to obtain the current month-day. * Specifying the time-zone avoids dependence on the default time-zone. *

              * Using this method will prevent the ability to use an alternate clock for testing @@ -258,7 +258,7 @@ public final class MonthDay * chronology, or can be converted to a {@code LocalDate}. *

              * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code MonthDay::from}. + * allowing it to be used as a query via method reference, {@code MonthDay::from}. * * @param temporal the temporal object to convert, not null * @return the month-day, not null @@ -389,7 +389,7 @@ public final class MonthDay /** * Gets the value of the specified field from this month-day as an {@code int}. *

              - * This queries this month-day for the value for the specified field. + * This queries this month-day for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -420,7 +420,7 @@ public final class MonthDay /** * Gets the value of the specified field from this month-day as a {@code long}. *

              - * This queries this month-day for the value for the specified field. + * This queries this month-day for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

              @@ -501,7 +501,7 @@ public final class MonthDay * This method checks whether this month and day and the input year form * a valid date. This can only return false for February 29th. * - * @param year the year to validate, an out of range value returns false + * @param year the year to validate * @return true if the year is valid for this month-day * @see Year#isValidMonthDay(MonthDay) */ @@ -685,7 +685,7 @@ public final class MonthDay } /** - * Is this month-day after the specified month-day. + * Checks if this month-day is after the specified month-day. * * @param other the other month-day to compare to, not null * @return true if this is after the specified month-day @@ -695,7 +695,7 @@ public final class MonthDay } /** - * Is this month-day before the specified month-day. + * Checks if this month-day is before the specified month-day. * * @param other the other month-day to compare to, not null * @return true if this point is before the specified month-day diff --git a/src/share/classes/java/time/OffsetDateTime.java b/src/share/classes/java/time/OffsetDateTime.java index 4e505fcaafa92f5b0a59503566449676dec5b186..16bd360f36151ce013658ae69155584ce73663be 100644 --- a/src/share/classes/java/time/OffsetDateTime.java +++ b/src/share/classes/java/time/OffsetDateTime.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 @@ -199,7 +199,7 @@ public final class OffsetDateTime /** * Obtains the current date-time from the system clock in the default time-zone. *

              - * This will query the {@link java.time.Clock#systemDefaultZone() system clock} in the default + * This will query the {@link Clock#systemDefaultZone() system clock} in the default * time-zone to obtain the current date-time. * The offset will be calculated from the time-zone in the clock. *

              @@ -215,7 +215,7 @@ public final class OffsetDateTime /** * Obtains the current date-time from the system clock in the specified time-zone. *

              - * This will query the {@link Clock#system(java.time.ZoneId) system clock} to obtain the current date-time. + * This will query the {@link Clock#system(ZoneId) system clock} to obtain the current date-time. * Specifying the time-zone avoids dependence on the default time-zone. * The offset will be calculated from the specified time-zone. *

              @@ -345,7 +345,7 @@ public final class OffsetDateTime * those fields that are equivalent to the relevant objects. *

              * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code OffsetDateTime::from}. + * allowing it to be used as a query via method reference, {@code OffsetDateTime::from}. * * @param temporal the temporal object to convert, not null * @return the offset date-time, not null @@ -567,7 +567,7 @@ public final class OffsetDateTime /** * Gets the value of the specified field from this date-time as an {@code int}. *

              - * This queries this date-time for the value for the specified field. + * This queries this date-time for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -609,7 +609,7 @@ public final class OffsetDateTime /** * Gets the value of the specified field from this date-time as a {@code long}. *

              - * This queries this date-time for the value for the specified field. + * This queries this date-time for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

              @@ -704,7 +704,7 @@ public final class OffsetDateTime //----------------------------------------------------------------------- /** - * Gets the {@code LocalDateTime} part of this offset date-time. + * Gets the {@code LocalDateTime} part of this date-time. *

              * This returns a {@code LocalDateTime} with the same year, month, day and time * as this date-time. @@ -796,10 +796,10 @@ public final class OffsetDateTime /** * Gets the day-of-week field, which is an enum {@code DayOfWeek}. *

              - * This method returns the enum {@link java.time.DayOfWeek} for the day-of-week. + * This method returns the enum {@link DayOfWeek} for the day-of-week. * This avoids confusion as to what {@code int} values mean. * If you need access to the primitive {@code int} value then the enum - * provides the {@link java.time.DayOfWeek#getValue() int value}. + * provides the {@link DayOfWeek#getValue() int value}. *

              * Additional information can be obtained from the {@code DayOfWeek}. * This includes textual names of the values. @@ -869,7 +869,8 @@ public final class OffsetDateTime *

              * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link TemporalAdjuster}. + * A selection of common adjustments is provided in + * {@link java.time.temporal.TemporalAdjusters TemporalAdjusters}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -879,7 +880,7 @@ public final class OffsetDateTime * For example this code returns a date on the last day of July: *

                    *  import static java.time.Month.*;
              -     *  import static java.time.temporal.Adjusters.*;
              +     *  import static java.time.temporal.TemporalAdjusters.*;
                    *
                    *  result = offsetDateTime.with(JULY).with(lastDayOfMonth());
                    * 
              @@ -921,7 +922,7 @@ public final class OffsetDateTime /** * Returns a copy of this date-time with the specified field set to a new value. *

              - * TThis returns an {@code OffsetDateTime}, based on this one, with the value + * This returns an {@code OffsetDateTime}, based on this one, with the value * for the specified field changed. * This can be used to change any supported field, such as the year, month or day-of-month. * If it is not possible to set the value, because the field is not supported or for @@ -980,7 +981,8 @@ public final class OffsetDateTime //----------------------------------------------------------------------- /** * Returns a copy of this {@code OffsetDateTime} with the year altered. - * The offset does not affect the calculation and will be the same in the result. + *

              + * The time and offset do not affect the calculation and will be the same in the result. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. *

              * This instance is immutable and unaffected by this method call. @@ -995,7 +997,8 @@ public final class OffsetDateTime /** * Returns a copy of this {@code OffsetDateTime} with the month-of-year altered. - * The offset does not affect the calculation and will be the same in the result. + *

              + * The time and offset do not affect the calculation and will be the same in the result. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. *

              * This instance is immutable and unaffected by this method call. @@ -1010,8 +1013,9 @@ public final class OffsetDateTime /** * Returns a copy of this {@code OffsetDateTime} with the day-of-month altered. + *

              * If the resulting {@code OffsetDateTime} is invalid, an exception is thrown. - * The offset does not affect the calculation and will be the same in the result. + * The time and offset do not affect the calculation and will be the same in the result. *

              * This instance is immutable and unaffected by this method call. * @@ -1026,6 +1030,8 @@ public final class OffsetDateTime /** * Returns a copy of this {@code OffsetDateTime} with the day-of-year altered. + *

              + * The time and offset do not affect the calculation and will be the same in the result. * If the resulting {@code OffsetDateTime} is invalid, an exception is thrown. *

              * This instance is immutable and unaffected by this method call. @@ -1041,9 +1047,9 @@ public final class OffsetDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code OffsetDateTime} with the hour-of-day value altered. + * Returns a copy of this {@code OffsetDateTime} with the hour-of-day altered. *

              - * The offset does not affect the calculation and will be the same in the result. + * The date and offset do not affect the calculation and will be the same in the result. *

              * This instance is immutable and unaffected by this method call. * @@ -1056,9 +1062,9 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the minute-of-hour value altered. + * Returns a copy of this {@code OffsetDateTime} with the minute-of-hour altered. *

              - * The offset does not affect the calculation and will be the same in the result. + * The date and offset do not affect the calculation and will be the same in the result. *

              * This instance is immutable and unaffected by this method call. * @@ -1071,9 +1077,9 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the second-of-minute value altered. + * Returns a copy of this {@code OffsetDateTime} with the second-of-minute altered. *

              - * The offset does not affect the calculation and will be the same in the result. + * The date and offset do not affect the calculation and will be the same in the result. *

              * This instance is immutable and unaffected by this method call. * @@ -1086,15 +1092,15 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the nano-of-second value altered. + * Returns a copy of this {@code OffsetDateTime} with the nano-of-second altered. *

              - * The offset does not affect the calculation and will be the same in the result. + * The date and offset do not affect the calculation and will be the same in the result. *

              * This instance is immutable and unaffected by this method call. * * @param nanoOfSecond the nano-of-second to set in the result, from 0 to 999,999,999 * @return an {@code OffsetDateTime} based on this date-time with the requested nanosecond, not null - * @throws DateTimeException if the nanos value is invalid + * @throws DateTimeException if the nano value is invalid */ public OffsetDateTime withNano(int nanoOfSecond) { return with(dateTime.withNano(nanoOfSecond), offset); @@ -1188,7 +1194,7 @@ public final class OffsetDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in years added. + * Returns a copy of this {@code OffsetDateTime} with the specified number of years added. *

              * This method adds the specified amount to the years field in three steps: *

                @@ -1212,7 +1218,7 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in months added. + * Returns a copy of this {@code OffsetDateTime} with the specified number of months added. *

                * This method adds the specified amount to the months field in three steps: *

                  @@ -1236,13 +1242,13 @@ public final class OffsetDateTime } /** - * Returns a copy of this OffsetDateTime with the specified period in weeks added. + * Returns a copy of this OffsetDateTime with the specified number of weeks added. *

                  * This method adds the specified amount in weeks to the days field incrementing * the month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. *

                  - * For example, 2008-12-31 plus one week would result in the 2009-01-07. + * For example, 2008-12-31 plus one week would result in 2009-01-07. *

                  * This instance is immutable and unaffected by this method call. * @@ -1255,13 +1261,13 @@ public final class OffsetDateTime } /** - * Returns a copy of this OffsetDateTime with the specified period in days added. + * Returns a copy of this OffsetDateTime with the specified number of days added. *

                  * This method adds the specified amount to the days field incrementing the * month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. *

                  - * For example, 2008-12-31 plus one day would result in the 2009-01-01. + * For example, 2008-12-31 plus one day would result in 2009-01-01. *

                  * This instance is immutable and unaffected by this method call. * @@ -1274,7 +1280,7 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in hours added. + * Returns a copy of this {@code OffsetDateTime} with the specified number of hours added. *

                  * This instance is immutable and unaffected by this method call. * @@ -1287,7 +1293,7 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in minutes added. + * Returns a copy of this {@code OffsetDateTime} with the specified number of minutes added. *

                  * This instance is immutable and unaffected by this method call. * @@ -1300,7 +1306,7 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in seconds added. + * Returns a copy of this {@code OffsetDateTime} with the specified number of seconds added. *

                  * This instance is immutable and unaffected by this method call. * @@ -1313,7 +1319,7 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in nanoseconds added. + * Returns a copy of this {@code OffsetDateTime} with the specified number of nanoseconds added. *

                  * This instance is immutable and unaffected by this method call. * @@ -1377,11 +1383,11 @@ public final class OffsetDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in years subtracted. + * Returns a copy of this {@code OffsetDateTime} with the specified number of years subtracted. *

                  * This method subtracts the specified amount from the years field in three steps: *

                    - *
                  1. Subtract the input years to the year field
                  2. + *
                  3. Subtract the input years from the year field
                  4. *
                  5. Check if the resulting date would be invalid
                  6. *
                  7. Adjust the day-of-month to the last valid day if necessary
                  8. *
                  @@ -1401,11 +1407,11 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in months subtracted. + * Returns a copy of this {@code OffsetDateTime} with the specified number of months subtracted. *

                  * This method subtracts the specified amount from the months field in three steps: *

                    - *
                  1. Subtract the input months to the month-of-year field
                  2. + *
                  3. Subtract the input months from the month-of-year field
                  4. *
                  5. Check if the resulting date would be invalid
                  6. *
                  7. Adjust the day-of-month to the last valid day if necessary
                  8. *
                  @@ -1425,13 +1431,13 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in weeks subtracted. + * Returns a copy of this {@code OffsetDateTime} with the specified number of weeks subtracted. *

                  * This method subtracts the specified amount in weeks from the days field decrementing * the month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. *

                  - * For example, 2008-12-31 minus one week would result in the 2009-01-07. + * For example, 2008-12-31 minus one week would result in 2009-01-07. *

                  * This instance is immutable and unaffected by this method call. * @@ -1444,13 +1450,13 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in days subtracted. + * Returns a copy of this {@code OffsetDateTime} with the specified number of days subtracted. *

                  - * This method subtracts the specified amount from the days field incrementing the + * This method subtracts the specified amount from the days field decrementing the * month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. *

                  - * For example, 2008-12-31 minus one day would result in the 2009-01-01. + * For example, 2008-12-31 minus one day would result in 2009-01-01. *

                  * This instance is immutable and unaffected by this method call. * @@ -1463,7 +1469,7 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in hours subtracted. + * Returns a copy of this {@code OffsetDateTime} with the specified number of hours subtracted. *

                  * This instance is immutable and unaffected by this method call. * @@ -1476,7 +1482,7 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in minutes subtracted. + * Returns a copy of this {@code OffsetDateTime} with the specified number of minutes subtracted. *

                  * This instance is immutable and unaffected by this method call. * @@ -1489,7 +1495,7 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in seconds subtracted. + * Returns a copy of this {@code OffsetDateTime} with the specified number of seconds subtracted. *

                  * This instance is immutable and unaffected by this method call. * @@ -1502,7 +1508,7 @@ public final class OffsetDateTime } /** - * Returns a copy of this {@code OffsetDateTime} with the specified period in nanoseconds subtracted. + * Returns a copy of this {@code OffsetDateTime} with the specified number of nanoseconds subtracted. *

                  * This instance is immutable and unaffected by this method call. * @@ -1599,7 +1605,7 @@ public final class OffsetDateTime * objects in terms of a single {@code TemporalUnit}. * The start and end points are {@code this} and the specified date-time. * The result will be negative if the end is before the start. - * For example, the period in days between two date-times can be calculated + * For example, the amount in days between two date-times can be calculated * using {@code startDateTime.until(endDateTime, DAYS)}. *

                  * The {@code Temporal} passed to this method is converted to a @@ -1609,7 +1615,7 @@ public final class OffsetDateTime *

                  * The calculation returns a whole number, representing the number of * complete units between the two date-times. - * For example, the period in months between 2012-06-15T00:00Z and 2012-08-14T23:59Z + * For example, the amount in months between 2012-06-15T00:00Z and 2012-08-14T23:59Z * will only be one month as it is one minute short of two months. *

                  * There are two equivalent ways of using this method. @@ -1770,7 +1776,7 @@ public final class OffsetDateTime //----------------------------------------------------------------------- /** - * Compares this {@code OffsetDateTime} to another date-time. + * Compares this date-time to another date-time. *

                  * The comparison is based on the instant then on the local date-time. * It is "consistent with equals", as defined by {@link Comparable}. diff --git a/src/share/classes/java/time/OffsetTime.java b/src/share/classes/java/time/OffsetTime.java index 32a7187d0f50a6c8b87f08b9317fbdf2cc289796..d142c8b0a288eebbafb4a2ba4828b098f97df01c 100644 --- a/src/share/classes/java/time/OffsetTime.java +++ b/src/share/classes/java/time/OffsetTime.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 @@ -153,14 +153,14 @@ public final class OffsetTime /** * Obtains the current time from the system clock in the default time-zone. *

                  - * This will query the {@link java.time.Clock#systemDefaultZone() system clock} in the default + * This will query the {@link Clock#systemDefaultZone() system clock} in the default * time-zone to obtain the current time. * The offset will be calculated from the time-zone in the clock. *

                  * Using this method will prevent the ability to use an alternate clock for testing * because the clock is hard-coded. * - * @return the current time using the system clock, not null + * @return the current time using the system clock and default time-zone, not null */ public static OffsetTime now() { return now(Clock.systemDefaultZone()); @@ -169,7 +169,7 @@ public final class OffsetTime /** * Obtains the current time from the system clock in the specified time-zone. *

                  - * This will query the {@link Clock#system(java.time.ZoneId) system clock} to obtain the current time. + * This will query the {@link Clock#system(ZoneId) system clock} to obtain the current time. * Specifying the time-zone avoids dependence on the default time-zone. * The offset will be calculated from the specified time-zone. *

                  @@ -277,7 +277,7 @@ public final class OffsetTime * those fields that are equivalent to the relevant objects. *

                  * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code OffsetTime::from}. + * allowing it to be used as a query via method reference, {@code OffsetTime::from}. * * @param temporal the temporal object to convert, not null * @return the offset time, not null @@ -402,7 +402,7 @@ public final class OffsetTime /** * Checks if the specified unit is supported. *

                  - * This checks if the specified unit can be added to, or subtracted from, this date-time. + * This checks if the specified unit can be added to, or subtracted from, this offset-time. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. *

                  @@ -473,7 +473,7 @@ public final class OffsetTime /** * Gets the value of the specified field from this time as an {@code int}. *

                  - * This queries this time for the value for the specified field. + * This queries this time for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -505,7 +505,7 @@ public final class OffsetTime /** * Gets the value of the specified field from this time as a {@code long}. *

                  - * This queries this time for the value for the specified field. + * This queries this time for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

                  @@ -575,7 +575,7 @@ public final class OffsetTime *

                  * This method returns an object with the specified {@code ZoneOffset} and a {@code LocalTime} * adjusted by the difference between the two offsets. - * This will result in the old and new objects representing the same instant an an implied day. + * This will result in the old and new objects representing the same instant on an implied day. * This is useful for finding the local time in a different offset. * For example, if this time represents {@code 10:30+02:00} and the offset specified is * {@code +03:00}, then this method will return {@code 11:30+03:00}. @@ -737,7 +737,7 @@ public final class OffsetTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code OffsetTime} with the hour-of-day value altered. + * Returns a copy of this {@code OffsetTime} with the hour-of-day altered. *

                  * The offset does not affect the calculation and will be the same in the result. *

                  @@ -752,7 +752,7 @@ public final class OffsetTime } /** - * Returns a copy of this {@code OffsetTime} with the minute-of-hour value altered. + * Returns a copy of this {@code OffsetTime} with the minute-of-hour altered. *

                  * The offset does not affect the calculation and will be the same in the result. *

                  @@ -767,7 +767,7 @@ public final class OffsetTime } /** - * Returns a copy of this {@code OffsetTime} with the second-of-minute value altered. + * Returns a copy of this {@code OffsetTime} with the second-of-minute altered. *

                  * The offset does not affect the calculation and will be the same in the result. *

                  @@ -782,7 +782,7 @@ public final class OffsetTime } /** - * Returns a copy of this {@code OffsetTime} with the nano-of-second value altered. + * Returns a copy of this {@code OffsetTime} with the nano-of-second altered. *

                  * The offset does not affect the calculation and will be the same in the result. *

                  @@ -884,7 +884,7 @@ public final class OffsetTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code OffsetTime} with the specified period in hours added. + * Returns a copy of this {@code OffsetTime} with the specified number of hours added. *

                  * This adds the specified number of hours to this time, returning a new time. * The calculation wraps around midnight. @@ -899,7 +899,7 @@ public final class OffsetTime } /** - * Returns a copy of this {@code OffsetTime} with the specified period in minutes added. + * Returns a copy of this {@code OffsetTime} with the specified number of minutes added. *

                  * This adds the specified number of minutes to this time, returning a new time. * The calculation wraps around midnight. @@ -914,7 +914,7 @@ public final class OffsetTime } /** - * Returns a copy of this {@code OffsetTime} with the specified period in seconds added. + * Returns a copy of this {@code OffsetTime} with the specified number of seconds added. *

                  * This adds the specified number of seconds to this time, returning a new time. * The calculation wraps around midnight. @@ -929,7 +929,7 @@ public final class OffsetTime } /** - * Returns a copy of this {@code OffsetTime} with the specified period in nanoseconds added. + * Returns a copy of this {@code OffsetTime} with the specified number of nanoseconds added. *

                  * This adds the specified number of nanoseconds to this time, returning a new time. * The calculation wraps around midnight. @@ -995,7 +995,7 @@ public final class OffsetTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code OffsetTime} with the specified period in hours subtracted. + * Returns a copy of this {@code OffsetTime} with the specified number of hours subtracted. *

                  * This subtracts the specified number of hours from this time, returning a new time. * The calculation wraps around midnight. @@ -1010,7 +1010,7 @@ public final class OffsetTime } /** - * Returns a copy of this {@code OffsetTime} with the specified period in minutes subtracted. + * Returns a copy of this {@code OffsetTime} with the specified number of minutes subtracted. *

                  * This subtracts the specified number of minutes from this time, returning a new time. * The calculation wraps around midnight. @@ -1025,7 +1025,7 @@ public final class OffsetTime } /** - * Returns a copy of this {@code OffsetTime} with the specified period in seconds subtracted. + * Returns a copy of this {@code OffsetTime} with the specified number of seconds subtracted. *

                  * This subtracts the specified number of seconds from this time, returning a new time. * The calculation wraps around midnight. @@ -1040,7 +1040,7 @@ public final class OffsetTime } /** - * Returns a copy of this {@code OffsetTime} with the specified period in nanoseconds subtracted. + * Returns a copy of this {@code OffsetTime} with the specified number of nanoseconds subtracted. *

                  * This subtracts the specified number of nanoseconds from this time, returning a new time. * The calculation wraps around midnight. @@ -1130,7 +1130,7 @@ public final class OffsetTime * objects in terms of a single {@code TemporalUnit}. * The start and end points are {@code this} and the specified time. * The result will be negative if the end is before the start. - * For example, the period in hours between two times can be calculated + * For example, the amount in hours between two times can be calculated * using {@code startTime.until(endTime, HOURS)}. *

                  * The {@code Temporal} passed to this method is converted to a @@ -1140,7 +1140,7 @@ public final class OffsetTime *

                  * The calculation returns a whole number, representing the number of * complete units between the two times. - * For example, the period in hours between 11:30Z and 13:29Z will only + * For example, the amount in hours between 11:30Z and 13:29Z will only * be one hour as it is one minute short of two hours. *

                  * There are two equivalent ways of using this method. @@ -1165,7 +1165,7 @@ public final class OffsetTime *

                  * This instance is immutable and unaffected by this method call. * - * @param endExclusive the end date, exclusive, which is converted to an {@code OffsetTime}, not null + * @param endExclusive the end time, exclusive, which is converted to an {@code OffsetTime}, not null * @param unit the unit to measure the amount in, not null * @return the amount of time between this time and the end time * @throws DateTimeException if the amount cannot be calculated, or the end diff --git a/src/share/classes/java/time/Period.java b/src/share/classes/java/time/Period.java index 6087618ef9c2698c5e8e7f08e5e271001a2221d7..7f3b717272f1456d1058281ca7d8c5c0f61a1f56 100644 --- a/src/share/classes/java/time/Period.java +++ b/src/share/classes/java/time/Period.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 @@ -616,7 +616,7 @@ public final class Period *

                  * This instance is immutable and unaffected by this method call. * - * @param amountToAdd the period to add, not null + * @param amountToAdd the amount to add, not null * @return a {@code Period} based on this period with the requested period added, not null * @throws DateTimeException if the specified amount has a non-ISO chronology or * contains an invalid unit @@ -705,7 +705,7 @@ public final class Period *

                  * This instance is immutable and unaffected by this method call. * - * @param amountToSubtract the period to subtract, not null + * @param amountToSubtract the amount to subtract, not null * @return a {@code Period} based on this period with the requested period subtracted, not null * @throws DateTimeException if the specified amount has a non-ISO chronology or * contains an invalid unit diff --git a/src/share/classes/java/time/Year.java b/src/share/classes/java/time/Year.java index ff8528aef8f48ea9ae43fc980d6e009870fa4258..b910c3aa304d083303662004de74f4c9c50f57e8 100644 --- a/src/share/classes/java/time/Year.java +++ b/src/share/classes/java/time/Year.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 @@ -164,7 +164,7 @@ public final class Year /** * Obtains the current year from the system clock in the default time-zone. *

                  - * This will query the {@link java.time.Clock#systemDefaultZone() system clock} in the default + * This will query the {@link Clock#systemDefaultZone() system clock} in the default * time-zone to obtain the current year. *

                  * Using this method will prevent the ability to use an alternate clock for testing @@ -179,7 +179,7 @@ public final class Year /** * Obtains the current year from the system clock in the specified time-zone. *

                  - * This will query the {@link Clock#system(java.time.ZoneId) system clock} to obtain the current year. + * This will query the {@link Clock#system(ZoneId) system clock} to obtain the current year. * Specifying the time-zone avoids dependence on the default time-zone. *

                  * Using this method will prevent the ability to use an alternate clock for testing @@ -240,7 +240,7 @@ public final class Year * chronology, or can be converted to a {@code LocalDate}. *

                  * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code Year::from}. + * allowing it to be used as a query via method reference, {@code Year::from}. * * @param temporal the temporal object to convert, not null * @return the year, not null @@ -375,7 +375,7 @@ public final class Year /** * Checks if the specified unit is supported. *

                  - * This checks if the specified unit can be added to, or subtracted from, this date-time. + * This checks if the specified unit can be added to, or subtracted from, this year. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. *

                  @@ -441,7 +441,7 @@ public final class Year /** * Gets the value of the specified field from this year as an {@code int}. *

                  - * This queries this year for the value for the specified field. + * This queries this year for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -472,7 +472,7 @@ public final class Year /** * Gets the value of the specified field from this year as a {@code long}. *

                  - * This queries this year for the value for the specified field. + * This queries this year for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

                  @@ -720,13 +720,13 @@ public final class Year } /** - * Returns a copy of this year with the specified number of years added. + * Returns a copy of this {@code Year} with the specified number of years added. *

                  * This instance is immutable and unaffected by this method call. * * @param yearsToAdd the years to add, may be negative - * @return a {@code Year} based on this year with the period added, not null - * @throws DateTimeException if the result exceeds the supported year range + * @return a {@code Year} based on this year with the years added, not null + * @throws DateTimeException if the result exceeds the supported range */ public Year plusYears(long yearsToAdd) { if (yearsToAdd == 0) { @@ -786,13 +786,13 @@ public final class Year } /** - * Returns a copy of this year with the specified number of years subtracted. + * Returns a copy of this {@code Year} with the specified number of years subtracted. *

                  * This instance is immutable and unaffected by this method call. * * @param yearsToSubtract the years to subtract, may be negative - * @return a {@code Year} based on this year with the period subtracted, not null - * @throws DateTimeException if the result exceeds the supported year range + * @return a {@code Year} based on this year with the year subtracted, not null + * @throws DateTimeException if the result exceeds the supported range */ public Year minusYears(long yearsToSubtract) { return (yearsToSubtract == Long.MIN_VALUE ? plusYears(Long.MAX_VALUE).plusYears(1) : plusYears(-yearsToSubtract)); @@ -871,12 +871,12 @@ public final class Year * The result will be negative if the end is before the start. * The {@code Temporal} passed to this method is converted to a * {@code Year} using {@link #from(TemporalAccessor)}. - * For example, the period in decades between two year can be calculated + * For example, the amount in decades between two year can be calculated * using {@code startYear.until(endYear, DECADES)}. *

                  * The calculation returns a whole number, representing the number of * complete units between the two years. - * For example, the period in decades between 2012 and 2031 + * For example, the amount in decades between 2012 and 2031 * will only be one decade as it is one year short of two decades. *

                  * There are two equivalent ways of using this method. @@ -948,7 +948,7 @@ public final class Year *

                  * The day-of-year value 366 is only valid in a leap year. * - * @param dayOfYear the day-of-year to use, not null + * @param dayOfYear the day-of-year to use, from 1 to 365-366 * @return the local date formed from this year and the specified date of year, not null * @throws DateTimeException if the day of year is zero or less, 366 or greater or equal * to 366 and this is not a leap year @@ -1025,7 +1025,7 @@ public final class Year } /** - * Is this year after the specified year. + * Checks if this year is after the specified year. * * @param other the other year to compare to, not null * @return true if this is after the specified year @@ -1035,7 +1035,7 @@ public final class Year } /** - * Is this year before the specified year. + * Checks if this year is before the specified year. * * @param other the other year to compare to, not null * @return true if this point is before the specified year diff --git a/src/share/classes/java/time/YearMonth.java b/src/share/classes/java/time/YearMonth.java index 97f66de2903f1d228c8d61199e1b03817b85fda1..0f9b0f4df4be8ee578b202a1c05ce21991456163 100644 --- a/src/share/classes/java/time/YearMonth.java +++ b/src/share/classes/java/time/YearMonth.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 @@ -157,9 +157,8 @@ public final class YearMonth /** * Obtains the current year-month from the system clock in the default time-zone. *

                  - * This will query the {@link java.time.Clock#systemDefaultZone() system clock} in the default + * This will query the {@link Clock#systemDefaultZone() system clock} in the default * time-zone to obtain the current year-month. - * The zone and offset will be set based on the time-zone in the clock. *

                  * Using this method will prevent the ability to use an alternate clock for testing * because the clock is hard-coded. @@ -173,7 +172,7 @@ public final class YearMonth /** * Obtains the current year-month from the system clock in the specified time-zone. *

                  - * This will query the {@link Clock#system(java.time.ZoneId) system clock} to obtain the current year-month. + * This will query the {@link Clock#system(ZoneId) system clock} to obtain the current year-month. * Specifying the time-zone avoids dependence on the default time-zone. *

                  * Using this method will prevent the ability to use an alternate clock for testing @@ -243,7 +242,7 @@ public final class YearMonth * chronology, or can be converted to a {@code LocalDate}. *

                  * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code YearMonth::from}. + * allowing it to be used as a query via method reference, {@code YearMonth::from}. * * @param temporal the temporal object to convert, not null * @return the year-month, not null @@ -363,7 +362,7 @@ public final class YearMonth /** * Checks if the specified unit is supported. *

                  - * This checks if the specified unit can be added to, or subtracted from, this date-time. + * This checks if the specified unit can be added to, or subtracted from, this year-month. * If false, then calling the {@link #plus(long, TemporalUnit)} and * {@link #minus(long, TemporalUnit) minus} methods will throw an exception. *

                  @@ -430,7 +429,7 @@ public final class YearMonth /** * Gets the value of the specified field from this year-month as an {@code int}. *

                  - * This queries this year-month for the value for the specified field. + * This queries this year-month for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -462,7 +461,7 @@ public final class YearMonth /** * Gets the value of the specified field from this year-month as a {@code long}. *

                  - * This queries this year-month for the value for the specified field. + * This queries this year-month for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

                  @@ -819,7 +818,7 @@ public final class YearMonth } /** - * Returns a copy of this year-month with the specified period in years added. + * Returns a copy of this {@code YearMonth} with the specified number of years added. *

                  * This instance is immutable and unaffected by this method call. * @@ -836,7 +835,7 @@ public final class YearMonth } /** - * Returns a copy of this year-month with the specified period in months added. + * Returns a copy of this {@code YearMonth} with the specified number of months added. *

                  * This instance is immutable and unaffected by this method call. * @@ -906,7 +905,7 @@ public final class YearMonth } /** - * Returns a copy of this year-month with the specified period in years subtracted. + * Returns a copy of this {@code YearMonth} with the specified number of years subtracted. *

                  * This instance is immutable and unaffected by this method call. * @@ -919,7 +918,7 @@ public final class YearMonth } /** - * Returns a copy of this year-month with the specified period in months subtracted. + * Returns a copy of this {@code YearMonth} with the specified number of months subtracted. *

                  * This instance is immutable and unaffected by this method call. * @@ -1004,12 +1003,12 @@ public final class YearMonth * The result will be negative if the end is before the start. * The {@code Temporal} passed to this method is converted to a * {@code YearMonth} using {@link #from(TemporalAccessor)}. - * For example, the period in years between two year-months can be calculated + * For example, the amount in years between two year-months can be calculated * using {@code startYearMonth.until(endYearMonth, YEARS)}. *

                  * The calculation returns a whole number, representing the number of * complete units between the two year-months. - * For example, the period in decades between 2012-06 and 2032-05 + * For example, the amount in decades between 2012-06 and 2032-05 * will only be one decade as it is one month short of two decades. *

                  * There are two equivalent ways of using this method. @@ -1134,7 +1133,7 @@ public final class YearMonth } /** - * Is this year-month after the specified year-month. + * Checks if this year-month is after the specified year-month. * * @param other the other year-month to compare to, not null * @return true if this is after the specified year-month @@ -1144,7 +1143,7 @@ public final class YearMonth } /** - * Is this year-month before the specified year-month. + * Checks if this year-month is before the specified year-month. * * @param other the other year-month to compare to, not null * @return true if this point is before the specified year-month diff --git a/src/share/classes/java/time/ZoneId.java b/src/share/classes/java/time/ZoneId.java index 16f8bf210c6de8607995d0e70c2887ba4e861748..58967b7faf5128dad8d4559763b3c085aaad6705 100644 --- a/src/share/classes/java/time/ZoneId.java +++ b/src/share/classes/java/time/ZoneId.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 @@ -453,7 +453,7 @@ public abstract class ZoneId implements Serializable { * zones over offset-based zones using {@link TemporalQueries#zone()}. *

                  * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code ZoneId::from}. + * allowing it to be used as a query via method reference, {@code ZoneId::from}. * * @param temporal the temporal object to convert, not null * @return the zone ID, not null diff --git a/src/share/classes/java/time/ZoneOffset.java b/src/share/classes/java/time/ZoneOffset.java index 10bd5446e0b06cc320e9b03a7972720d5c4e0160..dc2562abdf1daf6ccb9a106fd93b759b470ddb22 100644 --- a/src/share/classes/java/time/ZoneOffset.java +++ b/src/share/classes/java/time/ZoneOffset.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 @@ -89,7 +89,7 @@ import java.util.concurrent.ConcurrentMap; /** * A time-zone offset from Greenwich/UTC, such as {@code +02:00}. *

                  - * A time-zone offset is the period of time that a time-zone differs from Greenwich/UTC. + * A time-zone offset is the amount of time that a time-zone differs from Greenwich/UTC. * This is usually a fixed number of hours and minutes. *

                  * Different parts of the world have different time-zone offsets. @@ -334,7 +334,7 @@ public final class ZoneOffset * on extracting the {@link ChronoField#OFFSET_SECONDS OFFSET_SECONDS} field. *

                  * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code ZoneOffset::from}. + * allowing it to be used as a query via method reference, {@code ZoneOffset::from}. * * @param temporal the temporal object to convert, not null * @return the zone-offset, not null @@ -564,7 +564,7 @@ public final class ZoneOffset /** * Gets the value of the specified field from this offset as an {@code int}. *

                  - * This queries this offset for the value for the specified field. + * This queries this offset for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -599,7 +599,7 @@ public final class ZoneOffset /** * Gets the value of the specified field from this offset as a {@code long}. *

                  - * This queries this offset for the value for the specified field. + * This queries this offset for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

                  diff --git a/src/share/classes/java/time/ZonedDateTime.java b/src/share/classes/java/time/ZonedDateTime.java index a23ac821d75e566fb58dabff788d0afadc4ef121..35a48901bc277e717cf569e3cf06232c6f8348ff 100644 --- a/src/share/classes/java/time/ZonedDateTime.java +++ b/src/share/classes/java/time/ZonedDateTime.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 @@ -419,7 +419,7 @@ public final class ZonedDateTime *

                  * Converting an instant to a zoned date-time is simple as there is only one valid * offset for each instant. If the valid offset is different to the offset specified, - * the the date-time and offset of the zoned date-time will differ from those specified. + * then the date-time and offset of the zoned date-time will differ from those specified. *

                  * If the {@code ZoneId} to be used is a {@code ZoneOffset}, this method is equivalent * to {@link #of(LocalDateTime, ZoneId)}. @@ -539,7 +539,7 @@ public final class ZonedDateTime * those fields that are equivalent to the relevant objects. *

                  * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code ZonedDateTime::from}. + * allowing it to be used as a query via method reference, {@code ZonedDateTime::from}. * * @param temporal the temporal object to convert, not null * @return the zoned date-time, not null @@ -783,7 +783,7 @@ public final class ZonedDateTime /** * Gets the value of the specified field from this date-time as an {@code int}. *

                  - * This queries this date-time for the value for the specified field. + * This queries this date-time for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -825,7 +825,7 @@ public final class ZonedDateTime /** * Gets the value of the specified field from this date-time as a {@code long}. *

                  - * This queries this date-time for the value for the specified field. + * This queries this date-time for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

                  @@ -1183,7 +1183,8 @@ public final class ZonedDateTime *

                  * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link TemporalAdjuster}. + * A selection of common adjustments is provided in + * {@link java.time.temporal.TemporalAdjusters TemporalAdjusters}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -1193,7 +1194,7 @@ public final class ZonedDateTime * For example this code returns a date on the last day of July: *

                        *  import static java.time.Month.*;
                  -     *  import static java.time.temporal.Adjusters.*;
                  +     *  import static java.time.temporal.TemporalAdjusters.*;
                        *
                        *  result = zonedDateTime.with(JULY).with(lastDayOfMonth());
                        * 
                  @@ -1314,7 +1315,7 @@ public final class ZonedDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code ZonedDateTime} with the year value altered. + * Returns a copy of this {@code ZonedDateTime} with the year altered. *

                  * This operates on the local time-line, * {@link LocalDateTime#withYear(int) changing the year} of the local date-time. @@ -1336,7 +1337,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the month-of-year value altered. + * Returns a copy of this {@code ZonedDateTime} with the month-of-year altered. *

                  * This operates on the local time-line, * {@link LocalDateTime#withMonth(int) changing the month} of the local date-time. @@ -1358,7 +1359,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the day-of-month value altered. + * Returns a copy of this {@code ZonedDateTime} with the day-of-month altered. *

                  * This operates on the local time-line, * {@link LocalDateTime#withDayOfMonth(int) changing the day-of-month} of the local date-time. @@ -1405,7 +1406,7 @@ public final class ZonedDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code ZonedDateTime} with the hour-of-day value altered. + * Returns a copy of this {@code ZonedDateTime} with the hour-of-day altered. *

                  * This operates on the local time-line, * {@linkplain LocalDateTime#withHour(int) changing the time} of the local date-time. @@ -1427,7 +1428,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the minute-of-hour value altered. + * Returns a copy of this {@code ZonedDateTime} with the minute-of-hour altered. *

                  * This operates on the local time-line, * {@linkplain LocalDateTime#withMinute(int) changing the time} of the local date-time. @@ -1449,7 +1450,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the second-of-minute value altered. + * Returns a copy of this {@code ZonedDateTime} with the second-of-minute altered. *

                  * This operates on the local time-line, * {@linkplain LocalDateTime#withSecond(int) changing the time} of the local date-time. @@ -1471,7 +1472,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the nano-of-second value altered. + * Returns a copy of this {@code ZonedDateTime} with the nano-of-second altered. *

                  * This operates on the local time-line, * {@linkplain LocalDateTime#withNano(int) changing the time} of the local date-time. @@ -1507,7 +1508,7 @@ public final class ZonedDateTime * {@link ChronoUnit#DAYS DAYS}. Other units throw an exception. *

                  * This operates on the local time-line, - * {@link LocalDateTime#truncatedTo(java.time.temporal.TemporalUnit) truncating} + * {@link LocalDateTime#truncatedTo(TemporalUnit) truncating} * the underlying local date-time. This is then converted back to a * {@code ZonedDateTime}, using the zone ID to obtain the offset. *

                  @@ -1608,7 +1609,7 @@ public final class ZonedDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in years added. + * Returns a copy of this {@code ZonedDateTime} with the specified number of years added. *

                  * This operates on the local time-line, * {@link LocalDateTime#plusYears(long) adding years} to the local date-time. @@ -1630,7 +1631,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in months added. + * Returns a copy of this {@code ZonedDateTime} with the specified number of months added. *

                  * This operates on the local time-line, * {@link LocalDateTime#plusMonths(long) adding months} to the local date-time. @@ -1652,7 +1653,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in weeks added. + * Returns a copy of this {@code ZonedDateTime} with the specified number of weeks added. *

                  * This operates on the local time-line, * {@link LocalDateTime#plusWeeks(long) adding weeks} to the local date-time. @@ -1674,7 +1675,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in days added. + * Returns a copy of this {@code ZonedDateTime} with the specified number of days added. *

                  * This operates on the local time-line, * {@link LocalDateTime#plusDays(long) adding days} to the local date-time. @@ -1697,7 +1698,7 @@ public final class ZonedDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in hours added. + * Returns a copy of this {@code ZonedDateTime} with the specified number of hours added. *

                  * This operates on the instant time-line, such that adding one hour will * always be a duration of one hour later. @@ -1725,7 +1726,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in minutes added. + * Returns a copy of this {@code ZonedDateTime} with the specified number of minutes added. *

                  * This operates on the instant time-line, such that adding one minute will * always be a duration of one minute later. @@ -1743,7 +1744,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in seconds added. + * Returns a copy of this {@code ZonedDateTime} with the specified number of seconds added. *

                  * This operates on the instant time-line, such that adding one second will * always be a duration of one second later. @@ -1761,7 +1762,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in nanoseconds added. + * Returns a copy of this {@code ZonedDateTime} with the specified number of nanoseconds added. *

                  * This operates on the instant time-line, such that adding one nano will * always be a duration of one nano later. @@ -1849,7 +1850,7 @@ public final class ZonedDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in years subtracted. + * Returns a copy of this {@code ZonedDateTime} with the specified number of years subtracted. *

                  * This operates on the local time-line, * {@link LocalDateTime#minusYears(long) subtracting years} to the local date-time. @@ -1871,7 +1872,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in months subtracted. + * Returns a copy of this {@code ZonedDateTime} with the specified number of months subtracted. *

                  * This operates on the local time-line, * {@link LocalDateTime#minusMonths(long) subtracting months} to the local date-time. @@ -1893,7 +1894,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in weeks subtracted. + * Returns a copy of this {@code ZonedDateTime} with the specified number of weeks subtracted. *

                  * This operates on the local time-line, * {@link LocalDateTime#minusWeeks(long) subtracting weeks} to the local date-time. @@ -1915,7 +1916,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in days subtracted. + * Returns a copy of this {@code ZonedDateTime} with the specified number of days subtracted. *

                  * This operates on the local time-line, * {@link LocalDateTime#minusDays(long) subtracting days} to the local date-time. @@ -1938,7 +1939,7 @@ public final class ZonedDateTime //----------------------------------------------------------------------- /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in hours subtracted. + * Returns a copy of this {@code ZonedDateTime} with the specified number of hours subtracted. *

                  * This operates on the instant time-line, such that subtracting one hour will * always be a duration of one hour earlier. @@ -1966,7 +1967,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in minutes subtracted. + * Returns a copy of this {@code ZonedDateTime} with the specified number of minutes subtracted. *

                  * This operates on the instant time-line, such that subtracting one minute will * always be a duration of one minute earlier. @@ -1984,7 +1985,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in seconds subtracted. + * Returns a copy of this {@code ZonedDateTime} with the specified number of seconds subtracted. *

                  * This operates on the instant time-line, such that subtracting one second will * always be a duration of one second earlier. @@ -2002,7 +2003,7 @@ public final class ZonedDateTime } /** - * Returns a copy of this {@code ZonedDateTime} with the specified period in nanoseconds subtracted. + * Returns a copy of this {@code ZonedDateTime} with the specified number of nanoseconds subtracted. *

                  * This operates on the instant time-line, such that subtracting one nano will * always be a duration of one nano earlier. @@ -2029,7 +2030,7 @@ public final class ZonedDateTime * what the result of this method will be. *

                  * The result of this method is obtained by invoking the - * {@link java.time.temporal.TemporalQuery#queryFrom(TemporalAccessor)} method on the + * {@link TemporalQuery#queryFrom(TemporalAccessor)} method on the * specified query passing {@code this} as the argument. * * @param the type of the result @@ -2054,7 +2055,7 @@ public final class ZonedDateTime * objects in terms of a single {@code TemporalUnit}. * The start and end points are {@code this} and the specified date-time. * The result will be negative if the end is before the start. - * For example, the period in days between two date-times can be calculated + * For example, the amount in days between two date-times can be calculated * using {@code startDateTime.until(endDateTime, DAYS)}. *

                  * The {@code Temporal} passed to this method is converted to a @@ -2064,7 +2065,7 @@ public final class ZonedDateTime *

                  * The calculation returns a whole number, representing the number of * complete units between the two date-times. - * For example, the period in months between 2012-06-15T00:00Z and 2012-08-14T23:59Z + * For example, the amount in months between 2012-06-15T00:00Z and 2012-08-14T23:59Z * will only be one month as it is one minute short of two months. *

                  * There are two equivalent ways of using this method. diff --git a/src/share/classes/java/time/chrono/ChronoLocalDate.java b/src/share/classes/java/time/chrono/ChronoLocalDate.java index 6fe6a4578a9fec840e178538ed3b15ebea8d2c61..676421ab5d64768d7b227aa5a51c743cd2118abd 100644 --- a/src/share/classes/java/time/chrono/ChronoLocalDate.java +++ b/src/share/classes/java/time/chrono/ChronoLocalDate.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 @@ -249,8 +249,8 @@ public interface ChronoLocalDate * This allows dates in different calendar systems to be compared based * on the position of the date on the local time-line. * The underlying comparison is equivalent to comparing the epoch-day. - * @return a comparator that compares in time-line order ignoring the chronology * + * @return a comparator that compares in time-line order ignoring the chronology * @see #isAfter * @see #isBefore * @see #isEqual diff --git a/src/share/classes/java/time/chrono/ChronoLocalDateImpl.java b/src/share/classes/java/time/chrono/ChronoLocalDateImpl.java index 6cb115d393ed9c5401a1e5086dd31dccc3348d97..8fe8d1932bba235a0285d0d246a5556292c7408e 100644 --- a/src/share/classes/java/time/chrono/ChronoLocalDateImpl.java +++ b/src/share/classes/java/time/chrono/ChronoLocalDateImpl.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 @@ -227,7 +227,7 @@ abstract class ChronoLocalDateImpl //----------------------------------------------------------------------- /** - * Returns a copy of this date with the specified period in years added. + * Returns a copy of this date with the specified number of years added. *

                  * This adds the specified period in years to the date. * In some cases, adding years can cause the resulting date to become invalid. @@ -243,7 +243,7 @@ abstract class ChronoLocalDateImpl abstract D plusYears(long yearsToAdd); /** - * Returns a copy of this date with the specified period in months added. + * Returns a copy of this date with the specified number of months added. *

                  * This adds the specified period in months to the date. * In some cases, adding months can cause the resulting date to become invalid. @@ -259,7 +259,7 @@ abstract class ChronoLocalDateImpl abstract D plusMonths(long monthsToAdd); /** - * Returns a copy of this date with the specified period in weeks added. + * Returns a copy of this date with the specified number of weeks added. *

                  * This adds the specified period in weeks to the date. * In some cases, adding weeks can cause the resulting date to become invalid. @@ -292,7 +292,7 @@ abstract class ChronoLocalDateImpl //----------------------------------------------------------------------- /** - * Returns a copy of this date with the specified period in years subtracted. + * Returns a copy of this date with the specified number of years subtracted. *

                  * This subtracts the specified period in years to the date. * In some cases, subtracting years can cause the resulting date to become invalid. @@ -313,7 +313,7 @@ abstract class ChronoLocalDateImpl } /** - * Returns a copy of this date with the specified period in months subtracted. + * Returns a copy of this date with the specified number of months subtracted. *

                  * This subtracts the specified period in months to the date. * In some cases, subtracting months can cause the resulting date to become invalid. @@ -334,7 +334,7 @@ abstract class ChronoLocalDateImpl } /** - * Returns a copy of this date with the specified period in weeks subtracted. + * Returns a copy of this date with the specified number of weeks subtracted. *

                  * This subtracts the specified period in weeks to the date. * In some cases, subtracting weeks can cause the resulting date to become invalid. diff --git a/src/share/classes/java/time/chrono/ChronoLocalDateTime.java b/src/share/classes/java/time/chrono/ChronoLocalDateTime.java index 0607932084fcc7a862cfa84098887942c41c6cda..ce77f4d2ac7912f89cc7f9fd3052bbca631fbd71 100644 --- a/src/share/classes/java/time/chrono/ChronoLocalDateTime.java +++ b/src/share/classes/java/time/chrono/ChronoLocalDateTime.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 @@ -131,7 +131,6 @@ public interface ChronoLocalDateTime * The underlying comparison is equivalent to comparing the epoch-day and nano-of-day. * * @return a comparator that compares in time-line order ignoring the chronology - * * @see #isAfter * @see #isBefore * @see #isEqual @@ -323,7 +322,7 @@ public interface ChronoLocalDateTime * what the result of this method will be. *

                  * The result of this method is obtained by invoking the - * {@link java.time.temporal.TemporalQuery#queryFrom(TemporalAccessor)} method on the + * {@link TemporalQuery#queryFrom(TemporalAccessor)} method on the * specified query passing {@code this} as the argument. * * @param the type of the result diff --git a/src/share/classes/java/time/chrono/ChronoZonedDateTime.java b/src/share/classes/java/time/chrono/ChronoZonedDateTime.java index e98f422bb3aa9a20216576637bb63a7c164dc3ad..cae9adce696e763f0b67695cd0aad6c848216166 100644 --- a/src/share/classes/java/time/chrono/ChronoZonedDateTime.java +++ b/src/share/classes/java/time/chrono/ChronoZonedDateTime.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 @@ -132,7 +132,6 @@ public interface ChronoZonedDateTime * The underlying comparison is equivalent to comparing the epoch-second and nano-of-second. * * @return a comparator that compares in time-line order ignoring the chronology - * * @see #isAfter * @see #isBefore * @see #isEqual @@ -292,7 +291,7 @@ public interface ChronoZonedDateTime *

                  * This instance is immutable and unaffected by this method call. * - * @return a {@code ZoneChronoDateTime} based on this date-time with the earlier offset, not null + * @return a {@code ChronoZonedDateTime} based on this date-time with the earlier offset, not null * @throws DateTimeException if no rules can be found for the zone * @throws DateTimeException if no rules are valid for this date-time */ @@ -319,7 +318,7 @@ public interface ChronoZonedDateTime ChronoZonedDateTime withLaterOffsetAtOverlap(); /** - * Returns a copy of this ZonedDateTime with a different time-zone, + * Returns a copy of this date-time with a different time-zone, * retaining the local date-time if possible. *

                  * This method changes the time-zone and retains the local date-time. @@ -470,7 +469,7 @@ public interface ChronoZonedDateTime * what the result of this method will be. *

                  * The result of this method is obtained by invoking the - * {@link java.time.temporal.TemporalQuery#queryFrom(TemporalAccessor)} method on the + * {@link TemporalQuery#queryFrom(TemporalAccessor)} method on the * specified query passing {@code this} as the argument. * * @param the type of the result diff --git a/src/share/classes/java/time/chrono/Chronology.java b/src/share/classes/java/time/chrono/Chronology.java index 7c17da1ea5b5088e93f5bedae011f61b61d67db4..0b2d2e1994300b23f3551ac24115f5b96bc51b13 100644 --- a/src/share/classes/java/time/chrono/Chronology.java +++ b/src/share/classes/java/time/chrono/Chronology.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 @@ -132,8 +132,9 @@ import java.util.Set; * The set of available chronologies can be extended by applications. * Adding a new calendar system requires the writing of an implementation of * {@code Chronology}, {@code ChronoLocalDate} and {@code Era}. - * The majority of the logic specific to the calendar system will be in - * {@code ChronoLocalDate}. The {@code Chronology} subclass acts as a factory. + * The majority of the logic specific to the calendar system will be in the + * {@code ChronoLocalDate} implementation. + * The {@code Chronology} implementation acts as a factory. *

                  * To permit the discovery of additional chronologies, the {@link java.util.ServiceLoader ServiceLoader} * is used. A file must be added to the {@code META-INF/services} directory with the @@ -167,7 +168,7 @@ public interface Chronology extends Comparable { * If the specified temporal object does not have a chronology, {@link IsoChronology} is returned. *

                  * This method matches the signature of the functional interface {@link TemporalQuery} - * allowing it to be used in queries via method reference, {@code Chronology::from}. + * allowing it to be used as a query via method reference, {@code Chronology::from}. * * @param temporal the temporal to convert, not null * @return the chronology, not null @@ -413,7 +414,7 @@ public interface Chronology extends Comparable { * The alternate clock may be introduced using {@link Clock dependency injection}. * * @implSpec - * The default implementation invokes {@link #date(TemporalAccessor)} )}. + * The default implementation invokes {@link #date(TemporalAccessor)}. * * @param clock the clock to use, not null * @return the current local date, not null @@ -622,7 +623,7 @@ public interface Chronology extends Comparable { * The parameters control the style of the returned text and the locale. * * @implSpec - * The default implementation behaves as the the formatter was used to + * The default implementation behaves as though the formatter was used to * format the chronology textual name. * * @param style the style of the text required, not null diff --git a/src/share/classes/java/time/chrono/Era.java b/src/share/classes/java/time/chrono/Era.java index ec65e3f7531518977fa3259e7bb097b8505498d8..0e3c5332dbf05132243d98198deec7b61225c9b1 100644 --- a/src/share/classes/java/time/chrono/Era.java +++ b/src/share/classes/java/time/chrono/Era.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 @@ -182,7 +182,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { /** * Gets the value of the specified field from this era as an {@code int}. *

                  - * This queries this era for the value for the specified field. + * This queries this era for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. @@ -215,7 +215,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { /** * Gets the value of the specified field from this era as a {@code long}. *

                  - * This queries this era for the value for the specified field. + * This queries this era for the value of the specified field. * If it is not possible to return the value, because the field is not supported * or for some other reason, an exception is thrown. *

                  diff --git a/src/share/classes/java/time/chrono/HijrahChronology.java b/src/share/classes/java/time/chrono/HijrahChronology.java index 3be442cecb7b624aff5d436251baa0d11a701a52..6291b9ce5108ec09040c7d8cac84220765fb4517 100644 --- a/src/share/classes/java/time/chrono/HijrahChronology.java +++ b/src/share/classes/java/time/chrono/HijrahChronology.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 @@ -394,7 +394,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial * Gets the ID of the chronology. *

                  * The ID uniquely identifies the {@code Chronology}. It can be used to - * lookup the {@code Chronology} using {@link #of(String)}. + * lookup the {@code Chronology} using {@link Chronology#of(String)}. * * @return the chronology ID, non-null * @see #getCalendarType() @@ -409,7 +409,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial *

                  * The calendar type is an identifier defined by the * Unicode Locale Data Markup Language (LDML) specification. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}. * * @return the calendar system type; non-null if the calendar has * a standard type, otherwise null diff --git a/src/share/classes/java/time/chrono/IsoChronology.java b/src/share/classes/java/time/chrono/IsoChronology.java index f84c1c87671f0a4a814a048cc06609ed637b08b5..a9c79ff80cb548bd8c98ad0ed4911022ccd84464 100644 --- a/src/share/classes/java/time/chrono/IsoChronology.java +++ b/src/share/classes/java/time/chrono/IsoChronology.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 @@ -143,7 +143,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa * Gets the ID of the chronology - 'ISO'. *

                  * The ID uniquely identifies the {@code Chronology}. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}. * * @return the chronology ID - 'ISO' * @see #getCalendarType() @@ -158,7 +158,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa *

                  * The calendar type is an identifier defined by the * Unicode Locale Data Markup Language (LDML) specification. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}. * It can also be used as part of a locale, accessible via * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * diff --git a/src/share/classes/java/time/chrono/JapaneseChronology.java b/src/share/classes/java/time/chrono/JapaneseChronology.java index 7845088eb7eb392a5a65a5e384ddd80240d6f61c..93b47ca484d9cbe2896b965a6277995d6975fb7b 100644 --- a/src/share/classes/java/time/chrono/JapaneseChronology.java +++ b/src/share/classes/java/time/chrono/JapaneseChronology.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 @@ -150,7 +150,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri * Gets the ID of the chronology - 'Japanese'. *

                  * The ID uniquely identifies the {@code Chronology}. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}. * * @return the chronology ID - 'Japanese' * @see #getCalendarType() @@ -165,7 +165,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri *

                  * The calendar type is an identifier defined by the * Unicode Locale Data Markup Language (LDML) specification. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}. * It can also be used as part of a locale, accessible via * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * diff --git a/src/share/classes/java/time/chrono/MinguoChronology.java b/src/share/classes/java/time/chrono/MinguoChronology.java index 1fda0e415d4cbbb27c847ad5564cdc4ff1105edd..841884c4a9e1157cc8d786149cc502bc2d6d808d 100644 --- a/src/share/classes/java/time/chrono/MinguoChronology.java +++ b/src/share/classes/java/time/chrono/MinguoChronology.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 @@ -132,7 +132,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial * Gets the ID of the chronology - 'Minguo'. *

                  * The ID uniquely identifies the {@code Chronology}. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}. * * @return the chronology ID - 'Minguo' * @see #getCalendarType() @@ -147,7 +147,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial *

                  * The calendar type is an identifier defined by the * Unicode Locale Data Markup Language (LDML) specification. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}. * It can also be used as part of a locale, accessible via * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * diff --git a/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java b/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java index 87bc10047ecec66b1ee98163f332b7017941067b..5b96c85e905494dba9af78e2c104d53a5c0383f6 100644 --- a/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java +++ b/src/share/classes/java/time/chrono/ThaiBuddhistChronology.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 @@ -168,7 +168,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements * Gets the ID of the chronology - 'ThaiBuddhist'. *

                  * The ID uniquely identifies the {@code Chronology}. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}. * * @return the chronology ID - 'ThaiBuddhist' * @see #getCalendarType() @@ -183,7 +183,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements *

                  * The calendar type is an identifier defined by the * Unicode Locale Data Markup Language (LDML) specification. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}. * It can also be used as part of a locale, accessible via * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * diff --git a/src/share/classes/java/time/format/DateTimeFormatter.java b/src/share/classes/java/time/format/DateTimeFormatter.java index 3e1a2bdd2c90564f06c2727a82a29039f50655d6..57a0bf89781c71b723c8b8c318f34bccac73f7b0 100644 --- a/src/share/classes/java/time/format/DateTimeFormatter.java +++ b/src/share/classes/java/time/format/DateTimeFormatter.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 @@ -117,8 +117,9 @@ import java.util.Set; * {@code parse(CharSequence text, DateTimeFormatter formatter)}. *

                  For example: *

                  - *  String text = date.toString(formatter);
                  - *  LocalDate date = LocalDate.parse(text, formatter);
                  + *  LocalDate date = LocalDate.now();
                  + *  String text = date.format(formatter);
                  + *  LocalDate parsedDate = LocalDate.parse(text, formatter);
                    * 
                  *

                  * In addition to the format, formatters can be created with desired Locale, @@ -265,9 +266,10 @@ import java.util.Set; *

                  * For example: *

                  + *  LocalDate date = LocalDate.now();
                    *  DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd");
                  - *  String text = date.toString(formatter);
                  - *  LocalDate date = LocalDate.parse(text, formatter);
                  + *  String text = date.format(formatter);
                  + *  LocalDate parsedDate = LocalDate.parse(text, formatter);
                    * 
                  *

                  * All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The @@ -1331,8 +1333,8 @@ public final class DateTimeFormatter { * If the time '23:59:60' is received, then a simple conversion is applied, * replacing the second-of-minute of 60 with 59. This query can be used * on the parse result to determine if the leap-second adjustment was made. - * The query will return one second of excess if it did adjust to remove - * the leap-second, and zero if not. Note that applying a leap-second + * The query will return {@code true} if it did adjust to remove the + * leap-second, and {@code false} if not. Note that applying a leap-second * smoothing mechanism, such as UTC-SLS, is the responsibility of the * application, as follows: *

                  @@ -1976,7 +1978,7 @@ public final class DateTimeFormatter {
                        * Errors are returned using the error index field of the {@code ParsePosition}
                        * instead of {@code DateTimeParseException}.
                        * The returned error index will be set to an index indicative of the error.
                  -     * Callers must check for errors before using the context.
                  +     * Callers must check for errors before using the result.
                        * 

                  * If the formatter parses the same field more than once with different values, * the result will be an error. diff --git a/src/share/classes/java/time/format/DateTimeFormatterBuilder.java b/src/share/classes/java/time/format/DateTimeFormatterBuilder.java index d0db09f070208dd2178ce844c4dc86490e01b253..933afcb3f71b358ebfaaa048bb2b6602e38697fd 100644 --- a/src/share/classes/java/time/format/DateTimeFormatterBuilder.java +++ b/src/share/classes/java/time/format/DateTimeFormatterBuilder.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 @@ -31,7 +31,7 @@ * * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos * - * All rights reserved. + * All rights hg qreserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -137,7 +137,6 @@ import sun.util.locale.provider.TimeZoneNameUtility; *

                1. ChronologyText - the name of the chronology
                2. *
                3. Literal - a text literal
                4. *
                5. Nested and Optional - formats can be nested or made optional
                6. - *
                7. Other - the printer and parser interfaces can be used to add user supplied formatting
                8. * * In addition, any of the elements may be decorated by padding, either with spaces or any other character. *

                  @@ -194,8 +193,8 @@ public final class DateTimeFormatterBuilder { * The locale and chronology are used to lookup the locale specific format * for the requested dateStyle and/or timeStyle. * - * @param dateStyle the FormatStyle for the date - * @param timeStyle the FormatStyle for the time + * @param dateStyle the FormatStyle for the date, null for time-only pattern + * @param timeStyle the FormatStyle for the time, null for date-only pattern * @param chrono the Chronology, non-null * @param locale the locale, non-null * @return the locale and Chronology specific formatting pattern @@ -747,9 +746,9 @@ public final class DateTimeFormatterBuilder { * defines the connection between each value and the text: *

                        * Map<Long, String> map = new HashMap<>();
                  -     * map.put(1, "JNY");
                  -     * map.put(2, "FBY");
                  -     * map.put(3, "MCH");
                  +     * map.put(1L, "JNY");
                  +     * map.put(2L, "FBY");
                  +     * map.put(3L, "MCH");
                        * ...
                        * builder.appendText(MONTH_OF_YEAR, map);
                        * 
                  @@ -841,7 +840,7 @@ public final class DateTimeFormatterBuilder { *

                  * The {@linkplain ResolverStyle resolver style} has no effect on instant parsing. * The end-of-day time of '24:00' is handled as midnight at the start of the following day. - * The leap-second time of '23:59:59' is handled to some degree, see + * The leap-second time of '23:59:60' is handled to some degree, see * {@link DateTimeFormatter#parsedLeapSecond()} for full details. *

                  * An alternative to this method is to format/parse the instant as a single @@ -864,7 +863,7 @@ public final class DateTimeFormatterBuilder { * Appends the zone offset, such as '+01:00', to the formatter. *

                  * This appends an instruction to format/parse the offset ID to the builder. - * This is equivalent to calling {@code appendOffset("HH:MM:ss", "Z")}. + * This is equivalent to calling {@code appendOffset("+HH:MM:ss", "Z")}. * * @return this, for chaining, not null */ @@ -1049,7 +1048,7 @@ public final class DateTimeFormatterBuilder { * "GMT+01:30" -- ZoneOffset.of("+01:30") *

                  *

                  - * Note that this method is is identical to {@code appendZoneId()} except + * Note that this method is identical to {@code appendZoneId()} except * in the mechanism used to obtain the zone. * Note also that parsing accepts offsets, whereas formatting will never * produce one. @@ -1107,7 +1106,7 @@ public final class DateTimeFormatterBuilder { * "GMT+01:30" -- ZoneOffset.of("GMT+01:30") * *

                  - * Note that this method is is identical to {@code appendZoneId()} except + * Note that this method is identical to {@code appendZoneId()} except * in the mechanism used to obtain the zone. * * @return this, for chaining, not null @@ -1132,7 +1131,7 @@ public final class DateTimeFormatterBuilder { * for the locale set in the {@link DateTimeFormatter}. * If the temporal object being printed represents an instant, then the text * will be the summer or winter time text as appropriate. - * If the lookup for text does not find any suitable reuslt, then the + * If the lookup for text does not find any suitable result, then the * {@link ZoneId#getId() ID} will be printed instead. * If the zone cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -1168,7 +1167,7 @@ public final class DateTimeFormatterBuilder { * for the locale set in the {@link DateTimeFormatter}. * If the temporal object being printed represents an instant, then the text * will be the summer or winter time text as appropriate. - * If the lookup for text does not find any suitable reuslt, then the + * If the lookup for text does not find any suitable result, then the * {@link ZoneId#getId() ID} will be printed instead. * If the zone cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -1182,7 +1181,7 @@ public final class DateTimeFormatterBuilder { * zone. This method also allows a set of preferred {@link ZoneId} to be * specified for parsing. The matched preferred zone id will be used if the * textural zone name being parsed is not unique. - * + *

                  * If the zone cannot be parsed then an exception is thrown unless the * section of the formatter is optional. * @@ -1227,7 +1226,6 @@ public final class DateTimeFormatterBuilder { *

                  * The calendar system name will be output during a format. * If the chronology cannot be obtained then an exception will be thrown. - * The calendar system name is obtained from the Chronology. * * @param textStyle the text style to use, not null * @return this, for chaining, not null @@ -1453,7 +1451,7 @@ public final class DateTimeFormatterBuilder { * LLLLL 5 appendText(ChronoField.MONTH_OF_YEAR, TextStyle.NARROW_STANDALONE) * * w 1 append special localized WeekFields element for numeric week-of-year - * ww 1 append special localized WeekFields element for numeric week-of-year, zero-padded + * ww 2 append special localized WeekFields element for numeric week-of-year, zero-padded * W 1 append special localized WeekFields element for numeric week-of-month * d 1 appendValue(ChronoField.DAY_OF_MONTH) * dd 2 appendValue(ChronoField.DAY_OF_MONTH, 2) @@ -1880,7 +1878,6 @@ public final class DateTimeFormatterBuilder { *

                  * During parsing, the padding and decorated element are parsed. * If parsing is lenient, then the pad width is treated as a maximum. - * If parsing is case insensitive, then the pad character is matched ignoring case. * The padding is parsed greedily. Thus, if the decorated element starts with * the pad character, it will not be parsed. * diff --git a/src/share/classes/java/time/format/DecimalStyle.java b/src/share/classes/java/time/format/DecimalStyle.java index 8143037feff5c1d00ff0a60c28aaaa82a58bf153..484f2f215923b6ac826a7f3da65a93c169845b9a 100644 --- a/src/share/classes/java/time/format/DecimalStyle.java +++ b/src/share/classes/java/time/format/DecimalStyle.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,6 @@ package java.time.format; import java.text.DecimalFormatSymbols; -import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Locale; @@ -138,7 +137,7 @@ public final class DecimalStyle { * of(Locale.getDefault(Locale.Category.FORMAT))}. * * @see java.util.Locale.Category#FORMAT - * @return the info, not null + * @return the decimal style, not null */ public static DecimalStyle ofDefaultLocale() { return of(Locale.getDefault(Locale.Category.FORMAT)); @@ -150,7 +149,7 @@ public final class DecimalStyle { * This method provides access to locale sensitive decimal style symbols. * * @param locale the locale, not null - * @return the info, not null + * @return the decimal style, not null */ public static DecimalStyle of(Locale locale) { Objects.requireNonNull(locale, "locale"); @@ -340,7 +339,7 @@ public final class DecimalStyle { //----------------------------------------------------------------------- /** - * Checks if this DecimalStyle is equal another DecimalStyle. + * Checks if this DecimalStyle is equal to another DecimalStyle. * * @param obj the object to check, null returns false * @return true if this is equal to the other date diff --git a/src/share/classes/java/time/package-info.java b/src/share/classes/java/time/package-info.java index 5bc428319d15a4015cec0c7f390b4e44523d9fa0..ea160ffffc33e629aab7f5832949147b23cfbaaf 100644 --- a/src/share/classes/java/time/package-info.java +++ b/src/share/classes/java/time/package-info.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 @@ -65,7 +65,7 @@ * The main API for dates, times, instants, and durations. *

                  *

                  - * The classes defined here represent the principal date-time concepts, + * The classes defined here represent the principle date-time concepts, * including instants, durations, dates, times, time-zones and periods. * They are based on the ISO calendar system, which is the de facto world * calendar following the proleptic Gregorian rules. @@ -120,9 +120,10 @@ * *

                  Duration and Period

                  *

                  - * Beyond dates and times, the API also allows the storage of period and durations of time. + * Beyond dates and times, the API also allows the storage of periods and durations of time. * A {@link java.time.Duration} is a simple measure of time along the time-line in nanoseconds. - * A {@link java.time.Period} expresses an amount of time in units meaningful to humans, such as years or hours. + * A {@link java.time.Period} expresses an amount of time in units meaningful + * to humans, such as years or days. *

                  * *

                  Additional value types

                  @@ -247,8 +248,8 @@ * *

                  * 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/src/share/classes/java/time/temporal/IsoFields.java b/src/share/classes/java/time/temporal/IsoFields.java index 70c3ffb39b7d1ac3de7a0645a02466def8e65e3a..d9f5101e39f16af15598362e6dd823e14393461d 100644 --- a/src/share/classes/java/time/temporal/IsoFields.java +++ b/src/share/classes/java/time/temporal/IsoFields.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 @@ -638,7 +638,7 @@ public final class IsoFields { //----------------------------------------------------------------------- /** - * Implementation of the period unit. + * Implementation of the unit. */ private static enum Unit implements TemporalUnit { diff --git a/src/share/classes/java/time/temporal/Temporal.java b/src/share/classes/java/time/temporal/Temporal.java index 937a37e704f46dba457aa48882011e803c6a990d..f7064aa68edd9b47fb58100411aefac66746c195 100644 --- a/src/share/classes/java/time/temporal/Temporal.java +++ b/src/share/classes/java/time/temporal/Temporal.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 @@ -157,7 +157,8 @@ public interface Temporal extends TemporalAccessor { * This adjusts this date-time according to the rules of the specified adjuster. * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link TemporalAdjuster}. + * A selection of common adjustments is provided in + * {@link java.time.temporal.TemporalAdjusters TemporalAdjusters}. * These include finding the "last day of the month" and "next Wednesday". * The adjuster is responsible for handling special cases, such as the varying * lengths of month and leap years. @@ -287,7 +288,7 @@ public interface Temporal extends TemporalAccessor { * This provides equivalent, safe behavior for immutable and mutable implementations. * * @param amountToAdd the amount of the specified unit to add, may be negative - * @param unit the unit of the period to add, not null + * @param unit the unit of the amount to add, not null * @return an object of the same type with the specified period added, not null * @throws DateTimeException if the unit cannot be added * @throws UnsupportedTemporalTypeException if the unit is not supported @@ -359,7 +360,7 @@ public interface Temporal extends TemporalAccessor { * * * @param amountToSubtract the amount of the specified unit to subtract, may be negative - * @param unit the unit of the period to subtract, not null + * @param unit the unit of the amount to subtract, not null * @return an object of the same type with the specified period subtracted, not null * @throws DateTimeException if the unit cannot be subtracted * @throws UnsupportedTemporalTypeException if the unit is not supported @@ -378,12 +379,12 @@ public interface Temporal extends TemporalAccessor { * The start and end points are {@code this} and the specified temporal. * The end point is converted to be of the same type as the start point if different. * The result will be negative if the end is before the start. - * For example, the period in hours between two temporal objects can be + * For example, the amount in hours between two temporal objects can be * calculated using {@code startTime.until(endTime, HOURS)}. *

                  * The calculation returns a whole number, representing the number of * complete units between the two temporals. - * For example, the period in hours between the times 11:30 and 13:29 + * For example, the amount in hours between the times 11:30 and 13:29 * will only be one hour as it is one minute short of two hours. *

                  * There are two equivalent ways of using this method. diff --git a/src/share/classes/java/time/temporal/TemporalAccessor.java b/src/share/classes/java/time/temporal/TemporalAccessor.java index a6133e18837cb56a33b40de786648b63f3b66404..5e8b61ef71032150da0a02829457df52b32fc325 100644 --- a/src/share/classes/java/time/temporal/TemporalAccessor.java +++ b/src/share/classes/java/time/temporal/TemporalAccessor.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 @@ -180,7 +180,7 @@ public interface TemporalAccessor { /** * Gets the value of the specified field as an {@code int}. *

                  - * This queries the date-time for the value for the specified field. + * This queries the date-time for the value of the specified field. * The returned value will always be within the valid range of values for the field. * If the date-time cannot return the value, because the field is unsupported or for * some other reason, an exception will be thrown. @@ -229,7 +229,7 @@ public interface TemporalAccessor { /** * Gets the value of the specified field as a {@code long}. *

                  - * This queries the date-time for the value for the specified field. + * This queries the date-time for the value of the specified field. * The returned value may be outside the valid range of values for the field. * If the date-time cannot return the value, because the field is unsupported or for * some other reason, an exception will be thrown. diff --git a/src/share/classes/java/time/temporal/TemporalField.java b/src/share/classes/java/time/temporal/TemporalField.java index 51903ede30f9e57826e0ab90a875065f1dcdc95c..a82255a41c7231e81d945ad85c144e7d3148478d 100644 --- a/src/share/classes/java/time/temporal/TemporalField.java +++ b/src/share/classes/java/time/temporal/TemporalField.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 @@ -116,7 +116,7 @@ public interface TemporalField { * For example, in the field 'MonthOfYear', the unit is 'Months'. * See also {@link #getRangeUnit()}. * - * @return the period unit defining the base unit of the field, not null + * @return the unit defining the base unit of the field, not null */ TemporalUnit getBaseUnit(); @@ -130,7 +130,7 @@ public interface TemporalField { * The range is never null. For example, the 'Year' field is shorthand for * 'YearOfForever'. It therefore has a unit of 'Years' and a range of 'Forever'. * - * @return the period unit defining the range of the field, not null + * @return the unit defining the range of the field, not null */ TemporalUnit getRangeUnit(); @@ -179,7 +179,7 @@ public interface TemporalField { * Checks if this field is supported by the temporal object. *

                  * This determines whether the temporal accessor supports this field. - * If this returns false, the the temporal cannot be queried for this field. + * If this returns false, then the temporal cannot be queried for this field. *

                  * There are two equivalent ways of using this method. * The first is to invoke this method directly. diff --git a/src/share/classes/java/time/temporal/TemporalUnit.java b/src/share/classes/java/time/temporal/TemporalUnit.java index 1c41afa0593f090751d778bdff8d3ccaea5690d5..949104dfce23edbad45fc31678b64fd24caa6104 100644 --- a/src/share/classes/java/time/temporal/TemporalUnit.java +++ b/src/share/classes/java/time/temporal/TemporalUnit.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 @@ -221,7 +221,7 @@ public interface TemporalUnit { * @param temporal the temporal object to adjust, not null * @param amount the amount of this unit to add, positive or negative * @return the adjusted temporal object, not null - * @throws DateTimeException if the period cannot be added + * @throws DateTimeException if the amount cannot be added * @throws UnsupportedTemporalTypeException if the unit is not supported by the temporal */ R addTo(R temporal, long amount); diff --git a/src/share/classes/java/time/zone/ZoneOffsetTransition.java b/src/share/classes/java/time/zone/ZoneOffsetTransition.java index 1df7c850b26105325b1d625e99e4cca7f28a1aff..bc9cafe003b7025fbd7bbfce742a42215442f4e6 100644 --- a/src/share/classes/java/time/zone/ZoneOffsetTransition.java +++ b/src/share/classes/java/time/zone/ZoneOffsetTransition.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 @@ -83,7 +83,7 @@ import java.util.Objects; * The discontinuity is normally a gap in spring and an overlap in autumn. * {@code ZoneOffsetTransition} models the transition between the two offsets. *

                  - * Gaps occur where there are local date-times that simply do not not exist. + * Gaps occur where there are local date-times that simply do not exist. * An example would be when the offset changes from {@code +03:00} to {@code +04:00}. * This might be described as 'the clocks will move forward one hour tonight at 1am'. *

                  @@ -334,7 +334,7 @@ public final class ZoneOffsetTransition /** * Does this transition represent a gap in the local time-line. *

                  - * Gaps occur where there are local date-times that simply do not not exist. + * Gaps occur where there are local date-times that simply do not exist. * An example would be when the offset changes from {@code +01:00} to {@code +02:00}. * This might be described as 'the clocks will move forward one hour tonight at 1am'. * diff --git a/src/share/classes/java/util/concurrent/LinkedTransferQueue.java b/src/share/classes/java/util/concurrent/LinkedTransferQueue.java index 5ebd04923d4c5d453816240081a052dbee289e29..b59042653e70c995482a256c6a866b236101b628 100644 --- a/src/share/classes/java/util/concurrent/LinkedTransferQueue.java +++ b/src/share/classes/java/util/concurrent/LinkedTransferQueue.java @@ -780,7 +780,9 @@ public class LinkedTransferQueue extends AbstractQueue } /** - * Version of firstOfMode used by Spliterator + * Version of firstOfMode used by Spliterator. Callers must + * recheck if the returned node's item field is null or + * self-linked before using. */ final Node firstDataNode() { for (Node p = head; p != null;) { @@ -953,11 +955,12 @@ public class LinkedTransferQueue extends AbstractQueue Object[] a = new Object[n]; int i = 0; do { - if ((a[i] = p.item) != null) + Object e = p.item; + if (e != p && (a[i] = e) != null) ++i; if (p == (p = p.next)) p = q.firstDataNode(); - } while (p != null && i < n); + } while (p != null && i < n && p.isData); if ((current = p) == null) exhausted = true; if (i > 0) { @@ -980,11 +983,11 @@ public class LinkedTransferQueue extends AbstractQueue exhausted = true; do { Object e = p.item; + if (e != null && e != p) + action.accept((E)e); if (p == (p = p.next)) p = q.firstDataNode(); - if (e != null) - action.accept((E)e); - } while (p != null); + } while (p != null && p.isData); } } @@ -997,10 +1000,11 @@ public class LinkedTransferQueue extends AbstractQueue ((p = current) != null || (p = q.firstDataNode()) != null)) { Object e; do { - e = p.item; + if ((e = p.item) == p) + e = null; if (p == (p = p.next)) p = q.firstDataNode(); - } while (e == null && p != null); + } while (e == null && p != null && p.isData); if ((current = p) == null) exhausted = true; if (e != null) { diff --git a/src/share/classes/sun/awt/SunToolkit.java b/src/share/classes/sun/awt/SunToolkit.java index 737c8c6eed63dd63c2be307274a756e2de4474ec..62696453ad7f73731de0712b81218134c4a1334a 100644 --- a/src/share/classes/sun/awt/SunToolkit.java +++ b/src/share/classes/sun/awt/SunToolkit.java @@ -715,16 +715,19 @@ public abstract class SunToolkit extends Toolkit } - static final SoftCache imgCache = new SoftCache(); + static final SoftCache fileImgCache = new SoftCache(); + + static final SoftCache urlImgCache = new SoftCache(); static Image getImageFromHash(Toolkit tk, URL url) { checkPermissions(url); - synchronized (imgCache) { - Image img = (Image)imgCache.get(url); + synchronized (urlImgCache) { + String key = url.toString(); + Image img = (Image)urlImgCache.get(key); if (img == null) { try { img = tk.createImage(new URLImageSource(url)); - imgCache.put(url, img); + urlImgCache.put(key, img); } catch (Exception e) { } } @@ -735,12 +738,12 @@ public abstract class SunToolkit extends Toolkit static Image getImageFromHash(Toolkit tk, String filename) { checkPermissions(filename); - synchronized (imgCache) { - Image img = (Image)imgCache.get(filename); + synchronized (fileImgCache) { + Image img = (Image)fileImgCache.get(filename); if (img == null) { try { img = tk.createImage(new FileImageSource(filename)); - imgCache.put(filename, img); + fileImgCache.put(filename, img); } catch (Exception e) { } } @@ -758,28 +761,29 @@ public abstract class SunToolkit extends Toolkit protected Image getImageWithResolutionVariant(String fileName, String resolutionVariantName) { - synchronized (imgCache) { + synchronized (fileImgCache) { Image image = getImageFromHash(this, fileName); if (image instanceof MultiResolutionImage) { return image; } Image resolutionVariant = getImageFromHash(this, resolutionVariantName); image = createImageWithResolutionVariant(image, resolutionVariant); - imgCache.put(fileName, image); + fileImgCache.put(fileName, image); return image; } } protected Image getImageWithResolutionVariant(URL url, URL resolutionVariantURL) { - synchronized (imgCache) { + synchronized (urlImgCache) { Image image = getImageFromHash(this, url); if (image instanceof MultiResolutionImage) { return image; } Image resolutionVariant = getImageFromHash(this, resolutionVariantURL); image = createImageWithResolutionVariant(image, resolutionVariant); - imgCache.put(url, image); + String key = url.toString(); + urlImgCache.put(key, image); return image; } } @@ -884,8 +888,13 @@ public abstract class SunToolkit extends Toolkit return null; } - protected static boolean imageCached(Object key) { - return imgCache.containsKey(key); + protected static boolean imageCached(String fileName) { + return fileImgCache.containsKey(fileName); + } + + protected static boolean imageCached(URL url) { + String key = url.toString(); + return urlImgCache.containsKey(key); } protected static boolean imageExists(String filename) { diff --git a/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java b/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java index b974c3ca86cc4b505e04efd6c2ebd98436c9a00f..552a15d82e5ea0d7b26e870086b74e5ec524ef57 100644 --- a/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java +++ b/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java @@ -69,7 +69,7 @@ public final class ECPrivateKeyImpl extends PKCS8Key implements ECPrivateKey { /** * Construct a key from its encoding. Called by the ECKeyFactory. */ - ECPrivateKeyImpl(byte[] encoded) throws InvalidKeyException { + public ECPrivateKeyImpl(byte[] encoded) throws InvalidKeyException { decode(encoded); } @@ -77,7 +77,7 @@ public final class ECPrivateKeyImpl extends PKCS8Key implements ECPrivateKey { * Construct a key from its components. Used by the * KeyFactory. */ - ECPrivateKeyImpl(BigInteger s, ECParameterSpec params) + public ECPrivateKeyImpl(BigInteger s, ECParameterSpec params) throws InvalidKeyException { this.s = s; this.params = params; diff --git a/src/share/classes/sun/security/ec/ECPublicKeyImpl.java b/src/share/classes/sun/security/ec/ECPublicKeyImpl.java index 0e82e734e4aed479d8f6a8f692f85c177749b06e..8bc51f4b5e25085bf23f0ce74bf4bf590bbc418b 100644 --- a/src/share/classes/sun/security/ec/ECPublicKeyImpl.java +++ b/src/share/classes/sun/security/ec/ECPublicKeyImpl.java @@ -52,7 +52,7 @@ public final class ECPublicKeyImpl extends X509Key implements ECPublicKey { * ECKeyFactory. */ @SuppressWarnings("deprecation") - ECPublicKeyImpl(ECPoint w, ECParameterSpec params) + public ECPublicKeyImpl(ECPoint w, ECParameterSpec params) throws InvalidKeyException { this.w = w; this.params = params; @@ -65,7 +65,7 @@ public final class ECPublicKeyImpl extends X509Key implements ECPublicKey { /** * Construct a key from its encoding. */ - ECPublicKeyImpl(byte[] encoded) throws InvalidKeyException { + public ECPublicKeyImpl(byte[] encoded) throws InvalidKeyException { decode(encoded); } diff --git a/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java b/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java index 257164ab60f18a5e7f831e8e3ba8f88977c1a96d..494ab00f0d5ece874fb5ee5123ead763d233bf3b 100644 --- a/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java +++ b/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java @@ -116,7 +116,7 @@ final class P11ECKeyFactory extends P11KeyFactory { byte[] encoded = key.getEncoded(); try { - key = ECUtil.decodeX509ECPublicKey(encoded); + key = P11ECUtil.decodeX509ECPublicKey(encoded); } catch (InvalidKeySpecException ikse) { throw new InvalidKeyException(ikse); } @@ -145,7 +145,7 @@ final class P11ECKeyFactory extends P11KeyFactory { byte[] encoded = key.getEncoded(); try { - key = ECUtil.decodePKCS8ECPrivateKey(encoded); + key = P11ECUtil.decodePKCS8ECPrivateKey(encoded); } catch (InvalidKeySpecException ikse) { throw new InvalidKeyException(ikse); } @@ -167,7 +167,7 @@ final class P11ECKeyFactory extends P11KeyFactory { if (keySpec instanceof X509EncodedKeySpec) { try { byte[] encoded = ((X509EncodedKeySpec)keySpec).getEncoded(); - PublicKey key = ECUtil.decodeX509ECPublicKey(encoded); + PublicKey key = P11ECUtil.decodeX509ECPublicKey(encoded); return implTranslatePublicKey(key); } catch (InvalidKeyException e) { throw new InvalidKeySpecException @@ -197,7 +197,7 @@ final class P11ECKeyFactory extends P11KeyFactory { if (keySpec instanceof PKCS8EncodedKeySpec) { try { byte[] encoded = ((PKCS8EncodedKeySpec)keySpec).getEncoded(); - PrivateKey key = ECUtil.decodePKCS8ECPrivateKey(encoded); + PrivateKey key = P11ECUtil.decodePKCS8ECPrivateKey(encoded); return implTranslatePrivateKey(key); } catch (GeneralSecurityException e) { throw new InvalidKeySpecException diff --git a/src/share/classes/sun/security/pkcs11/P11ECUtil.java b/src/share/classes/sun/security/pkcs11/P11ECUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..35ff32611a2f97e4f8fdfeb40bbac21067ad63c0 --- /dev/null +++ b/src/share/classes/sun/security/pkcs11/P11ECUtil.java @@ -0,0 +1,114 @@ +/* + * 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.security.pkcs11; + +import java.io.IOException; +import java.math.BigInteger; +import java.security.*; +import java.security.interfaces.*; +import java.security.spec.*; + +import sun.security.ec.ECPublicKeyImpl; +import sun.security.ec.ECPrivateKeyImpl; +import sun.security.x509.X509Key; + +final class P11ECUtil { + + static ECPublicKey decodeX509ECPublicKey(byte[] encoded) + throws InvalidKeySpecException { + X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encoded); + + return (ECPublicKey)ECGeneratePublic(keySpec); + } + + static byte[] x509EncodeECPublicKey(ECPoint w, + ECParameterSpec params) throws InvalidKeySpecException { + ECPublicKeySpec keySpec = new ECPublicKeySpec(w, params); + X509Key key = (X509Key)ECGeneratePublic(keySpec); + + return key.getEncoded(); + } + + static ECPrivateKey decodePKCS8ECPrivateKey(byte[] encoded) + throws InvalidKeySpecException { + PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded); + + return (ECPrivateKey)ECGeneratePrivate(keySpec); + } + + static ECPrivateKey generateECPrivateKey(BigInteger s, + ECParameterSpec params) throws InvalidKeySpecException { + ECPrivateKeySpec keySpec = new ECPrivateKeySpec(s, params); + + return (ECPrivateKey)ECGeneratePrivate(keySpec); + } + + private static PublicKey ECGeneratePublic(KeySpec keySpec) + throws InvalidKeySpecException { + try { + if (keySpec instanceof X509EncodedKeySpec) { + X509EncodedKeySpec x509Spec = (X509EncodedKeySpec)keySpec; + return new ECPublicKeyImpl(x509Spec.getEncoded()); + } else if (keySpec instanceof ECPublicKeySpec) { + ECPublicKeySpec ecSpec = (ECPublicKeySpec)keySpec; + return new ECPublicKeyImpl( + ecSpec.getW(), + ecSpec.getParams() + ); + } else { + throw new InvalidKeySpecException("Only ECPublicKeySpec " + + "and X509EncodedKeySpec supported for EC public keys"); + } + } catch (InvalidKeySpecException e) { + throw e; + } catch (GeneralSecurityException e) { + throw new InvalidKeySpecException(e); + } + } + + private static PrivateKey ECGeneratePrivate(KeySpec keySpec) + throws InvalidKeySpecException { + try { + if (keySpec instanceof PKCS8EncodedKeySpec) { + PKCS8EncodedKeySpec pkcsSpec = (PKCS8EncodedKeySpec)keySpec; + return new ECPrivateKeyImpl(pkcsSpec.getEncoded()); + } else if (keySpec instanceof ECPrivateKeySpec) { + ECPrivateKeySpec ecSpec = (ECPrivateKeySpec)keySpec; + return new ECPrivateKeyImpl(ecSpec.getS(), ecSpec.getParams()); + } else { + throw new InvalidKeySpecException("Only ECPrivateKeySpec " + + "and PKCS8EncodedKeySpec supported for EC private keys"); + } + } catch (InvalidKeySpecException e) { + throw e; + } catch (GeneralSecurityException e) { + throw new InvalidKeySpecException(e); + } + } + + private P11ECUtil() {} + +} diff --git a/src/share/classes/sun/security/pkcs11/P11Key.java b/src/share/classes/sun/security/pkcs11/P11Key.java index 235c1488a4457ff5eeddee2c4b13b07680c90ce1..bfca0fdcb61d5cf55171ec5d669c630d63b385e9 100644 --- a/src/share/classes/sun/security/pkcs11/P11Key.java +++ b/src/share/classes/sun/security/pkcs11/P11Key.java @@ -47,7 +47,6 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*; import sun.security.util.DerValue; import sun.security.util.Length; -import sun.security.util.ECUtil; /** * Key implementation classes. @@ -993,7 +992,7 @@ abstract class P11Key implements Key, Length { if (encoded == null) { fetchValues(); try { - Key key = ECUtil.generateECPrivateKey(s, params); + Key key = P11ECUtil.generateECPrivateKey(s, params); encoded = key.getEncoded(); } catch (InvalidKeySpecException e) { throw new ProviderException(e); @@ -1067,7 +1066,7 @@ abstract class P11Key implements Key, Length { if (encoded == null) { fetchValues(); try { - return ECUtil.x509EncodeECPublicKey(w, params); + return P11ECUtil.x509EncodeECPublicKey(w, params); } catch (InvalidKeySpecException e) { throw new ProviderException(e); } diff --git a/src/share/classes/sun/security/util/ECUtil.java b/src/share/classes/sun/security/util/ECUtil.java index dc6b02be611a3c09d1b712df639151db5ba10c60..8bdc575fbb6a497a6ec6efc3b3fd6bcf048c53bf 100644 --- a/src/share/classes/sun/security/util/ECUtil.java +++ b/src/share/classes/sun/security/util/ECUtil.java @@ -89,47 +89,6 @@ public class ECUtil { return Arrays.copyOfRange(b, i, b.length); } - private static KeyFactory getKeyFactory() { - try { - return KeyFactory.getInstance("EC", "SunEC"); - } catch (NoSuchAlgorithmException | NoSuchProviderException e) { - throw new RuntimeException(e); - } - } - - public static ECPublicKey decodeX509ECPublicKey(byte[] encoded) - throws InvalidKeySpecException { - KeyFactory keyFactory = getKeyFactory(); - X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encoded); - - return (ECPublicKey)keyFactory.generatePublic(keySpec); - } - - public static byte[] x509EncodeECPublicKey(ECPoint w, - ECParameterSpec params) throws InvalidKeySpecException { - KeyFactory keyFactory = getKeyFactory(); - ECPublicKeySpec keySpec = new ECPublicKeySpec(w, params); - X509Key key = (X509Key)keyFactory.generatePublic(keySpec); - - return key.getEncoded(); - } - - public static ECPrivateKey decodePKCS8ECPrivateKey(byte[] encoded) - throws InvalidKeySpecException { - KeyFactory keyFactory = getKeyFactory(); - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded); - - return (ECPrivateKey)keyFactory.generatePrivate(keySpec); - } - - public static ECPrivateKey generateECPrivateKey(BigInteger s, - ECParameterSpec params) throws InvalidKeySpecException { - KeyFactory keyFactory = getKeyFactory(); - ECPrivateKeySpec keySpec = new ECPrivateKeySpec(s, params); - - return (ECPrivateKey)keyFactory.generatePrivate(keySpec); - } - private static AlgorithmParameters getECParameters(Provider p) { try { if (p != null) { diff --git a/src/share/demo/jfc/Font2DTest/FontPanel.java b/src/share/demo/jfc/Font2DTest/FontPanel.java index a53d56cfd25a92609535a51d203325f76634ad5a..01a956e2968e65c5cff89b79b3c0afd535d2c5d4 100644 --- a/src/share/demo/jfc/Font2DTest/FontPanel.java +++ b/src/share/demo/jfc/Font2DTest/FontPanel.java @@ -515,7 +515,6 @@ public final class FontPanel extends JPanel implements AdjustmentListener { /// Sets the font, hints, according to the set parameters private void setParams( Graphics2D g2 ) { -System.out.println("USING FONT " + testFont + " "+testFont.getPSName()); g2.setFont( testFont ); g2.setRenderingHint(KEY_TEXT_ANTIALIASING, antiAliasType); g2.setRenderingHint(KEY_FRACTIONALMETRICS, fractionalMetricsType); diff --git a/src/share/native/sun/awt/splashscreen/splashscreen_gif.c b/src/share/native/sun/awt/splashscreen/splashscreen_gif.c index f1954b5fa02a7dda07d98271dacba3799479e225..3654c677493fa28b9a377b01a48407e544f389a5 100644 --- a/src/share/native/sun/awt/splashscreen/splashscreen_gif.c +++ b/src/share/native/sun/awt/splashscreen/splashscreen_gif.c @@ -82,8 +82,8 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) int i, j; int imageIndex; int cx, cy, cw, ch; /* clamped coordinates */ - int numLines; - int numPassLines; + const int interlacedOffset[] = { 0, 4, 2, 1, 0 }; /* The way Interlaced image should. */ + const int interlacedJumps[] = { 8, 8, 4, 2, 1 }; /* be read - offsets and jumps... */ if (DGifSlurp(gif) == GIF_ERROR) { return 0; @@ -213,6 +213,16 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) byte_t *pSrc = image->RasterBits; ImageFormat srcFormat; ImageRect srcRect, dstRect; + int pass = 4, npass = 5; + +#if GIFLIB_MAJOR < 5 + /* Interlaced gif support is broken in giflib < 5 + so we need to work around this */ + if (desc->Interlace) { + pass = 0; + npass = 4; + } +#endif srcFormat.colorMap = colorMapBuf; srcFormat.depthBytes = 1; @@ -221,22 +231,26 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) srcFormat.fixedBits = QUAD_ALPHA_MASK; // fixed 100% alpha srcFormat.premultiplied = 0; - /* Number of source lines for current pass */ - numPassLines = desc->Height; - /* Number of lines that fits to dest buffer */ - numLines = ch; + for (; pass < npass; ++pass) { + int jump = interlacedJumps[pass]; + int ofs = interlacedOffset[pass]; + /* Number of source lines for current pass */ + int numPassLines = (desc->Height + jump - ofs - 1) / jump; + /* Number of lines that fits to dest buffer */ + int numLines = (ch + jump - ofs - 1) / jump; - initRect(&srcRect, 0, 0, desc->Width, numLines, 1, - desc->Width, pSrc, &srcFormat); + initRect(&srcRect, 0, 0, desc->Width, numLines, 1, + desc->Width, pSrc, &srcFormat); - if (numLines > 0) { - initRect(&dstRect, cx, cy, cw, - numLines , 1, stride, pBitmapBits, &splash->imageFormat); + if (numLines > 0) { + initRect(&dstRect, cx, cy + ofs, cw, + numLines , jump, stride, pBitmapBits, &splash->imageFormat); - pSrc += convertRect(&srcRect, &dstRect, CVT_ALPHATEST); + pSrc += convertRect(&srcRect, &dstRect, CVT_ALPHATEST); + } + // skip extra source data + pSrc += (numPassLines - numLines) * srcRect.stride; } - // skip extra source data - pSrc += (numPassLines - numLines) * srcRect.stride; } // now dispose of the previous frame correctly @@ -296,7 +310,13 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) free(pBitmapBits); free(pOldBitmapBits); - DGifCloseFile(gif, NULL); +#if GIFLIB_MAJOR > 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1) + if (DGifCloseFile(gif, NULL) == GIF_ERROR) { + return 0; + } +#else + DGifCloseFile(gif); +#endif return 1; } @@ -304,7 +324,11 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) int SplashDecodeGifStream(Splash * splash, SplashStream * stream) { +#if GIFLIB_MAJOR >= 5 GifFileType *gif = DGifOpen((void *) stream, SplashStreamGifInputFunc, NULL); +#else + GifFileType *gif = DGifOpen((void *) stream, SplashStreamGifInputFunc); +#endif if (!gif) return 0; diff --git a/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/src/solaris/classes/sun/awt/X11/XWindowPeer.java index 8dcd15bc975a144b82f7cb179c49887f236bb09b..093029387cd34285d8bff898137f88a9888bf066 100644 --- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java +++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java @@ -679,28 +679,33 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, GraphicsConfiguration newGC = null; Rectangle screenBounds; - for (int i = 0; i < gds.length; i++) { - screenBounds = gds[i].getDefaultConfiguration().getBounds(); - if (newBounds.intersects(screenBounds)) { - horizAmt = Math.min(newBounds.x + newBounds.width, - screenBounds.x + screenBounds.width) - - Math.max(newBounds.x, screenBounds.x); - vertAmt = Math.min(newBounds.y + newBounds.height, - screenBounds.y + screenBounds.height)- - Math.max(newBounds.y, screenBounds.y); - intAmt = horizAmt * vertAmt; - if (intAmt == area) { - // Completely on this screen - done! - newScreenNum = i; - newGC = gds[i].getDefaultConfiguration(); - break; - } - if (intAmt > largestAmt) { - largestAmt = intAmt; - newScreenNum = i; - newGC = gds[i].getDefaultConfiguration(); + XToolkit.awtUnlock(); + try { + for (int i = 0; i < gds.length; i++) { + screenBounds = gds[i].getDefaultConfiguration().getBounds(); + if (newBounds.intersects(screenBounds)) { + horizAmt = Math.min(newBounds.x + newBounds.width, + screenBounds.x + screenBounds.width) - + Math.max(newBounds.x, screenBounds.x); + vertAmt = Math.min(newBounds.y + newBounds.height, + screenBounds.y + screenBounds.height)- + Math.max(newBounds.y, screenBounds.y); + intAmt = horizAmt * vertAmt; + if (intAmt == area) { + // Completely on this screen - done! + newScreenNum = i; + newGC = gds[i].getDefaultConfiguration(); + break; + } + if (intAmt > largestAmt) { + largestAmt = intAmt; + newScreenNum = i; + newGC = gds[i].getDefaultConfiguration(); + } } } + } finally { + XToolkit.awtLock(); } if (newScreenNum != curScreenNum) { if (log.isLoggable(PlatformLogger.Level.FINEST)) { diff --git a/src/solaris/classes/sun/awt/X11GraphicsDevice.java b/src/solaris/classes/sun/awt/X11GraphicsDevice.java index 7ffa13286653dce185f4c57e08225d71364f6c36..3749b8242dfdd19ee48609e4cb26e2b463b98df9 100644 --- a/src/solaris/classes/sun/awt/X11GraphicsDevice.java +++ b/src/solaris/classes/sun/awt/X11GraphicsDevice.java @@ -286,7 +286,6 @@ public class X11GraphicsDevice * Returns true only if: * - the Xrandr extension is present * - the necessary Xrandr functions were loaded successfully - * - XINERAMA is not enabled */ private static synchronized boolean isXrandrExtensionSupported() { if (xrandrExtSupported == null) { @@ -318,7 +317,9 @@ public class X11GraphicsDevice @Override public boolean isDisplayChangeSupported() { - return (isFullScreenSupported() && (getFullScreenWindow() != null)); + return (isFullScreenSupported() + && !((X11GraphicsEnvironment) GraphicsEnvironment + .getLocalGraphicsEnvironment()).runningXinerama()); } private static void enterFullScreenExclusive(Window w) { @@ -348,7 +349,9 @@ public class X11GraphicsDevice if (fsSupported && old != null) { // enter windowed mode (and restore original display mode) exitFullScreenExclusive(old); - setDisplayMode(origDisplayMode); + if (isDisplayChangeSupported()) { + setDisplayMode(origDisplayMode); + } } super.setFullScreenWindow(w); @@ -431,7 +434,9 @@ public class X11GraphicsDevice Window old = getFullScreenWindow(); if (old != null) { exitFullScreenExclusive(old); - setDisplayMode(origDisplayMode); + if (isDisplayChangeSupported()) { + setDisplayMode(origDisplayMode); + } } }; Thread t = new Thread(rootTG, r,"Display-Change-Shutdown-Thread-"+screen); diff --git a/src/windows/classes/sun/security/mscapi/KeyStore.java b/src/windows/classes/sun/security/mscapi/KeyStore.java index 05db5dbd7a6ee8b70f7af357ceab1302664fe56c..69298f5fc606a16443c7ee8ad1b2a7040a7d9901 100644 --- a/src/windows/classes/sun/security/mscapi/KeyStore.java +++ b/src/windows/classes/sun/security/mscapi/KeyStore.java @@ -41,12 +41,7 @@ import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.interfaces.RSAPrivateCrtKey; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.UUID; +import java.util.*; import sun.security.action.GetPropertyAction; @@ -142,7 +137,7 @@ abstract class KeyStore extends KeyStoreSpi { key.getPrimeExponentQ().toByteArray(), key.getCrtCoefficient().toByteArray()); - privateKey = storePrivateKey(keyBlob, + privateKey = storePrivateKey(Objects.requireNonNull(keyBlob), "{" + UUID.randomUUID().toString() + "}", keyBitLength); } diff --git a/src/windows/native/java/lang/java_props_md.c b/src/windows/native/java/lang/java_props_md.c index 382e9dfc41e4b264ad9685f953b82eb39c716076..8bf371854d4a6293826af5d8f874ec026ab54b90 100644 --- a/src/windows/native/java/lang/java_props_md.c +++ b/src/windows/native/java/lang/java_props_md.c @@ -348,8 +348,8 @@ java_props_t * GetJavaProperties(JNIEnv* env) { static java_props_t sprops = {0}; - - OSVERSIONINFOEX ver; + int majorVersion; + int minorVersion; if (sprops.line_separator) { return &sprops; @@ -380,21 +380,67 @@ GetJavaProperties(JNIEnv* env) /* OS properties */ { char buf[100]; - SYSTEM_INFO si; - PGNSI pGNSI; - - ver.dwOSVersionInfoSize = sizeof(ver); - GetVersionEx((OSVERSIONINFO *) &ver); - - ZeroMemory(&si, sizeof(SYSTEM_INFO)); - // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. - pGNSI = (PGNSI) GetProcAddress( - GetModuleHandle(TEXT("kernel32.dll")), - "GetNativeSystemInfo"); - if(NULL != pGNSI) - pGNSI(&si); - else - GetSystemInfo(&si); + boolean is_workstation; + boolean is_64bit; + DWORD platformId; + { + OSVERSIONINFOEX ver; + ver.dwOSVersionInfoSize = sizeof(ver); + GetVersionEx((OSVERSIONINFO *) &ver); + majorVersion = ver.dwMajorVersion; + minorVersion = ver.dwMinorVersion; + is_workstation = (ver.wProductType == VER_NT_WORKSTATION); + platformId = ver.dwPlatformId; + sprops.patch_level = _strdup(ver.szCSDVersion); + } + + { + SYSTEM_INFO si; + ZeroMemory(&si, sizeof(SYSTEM_INFO)); + GetNativeSystemInfo(&si); + + is_64bit = (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64); + } + do { + // Read the major and minor version number from kernel32.dll + VS_FIXEDFILEINFO *file_info; + WCHAR kernel32_path[MAX_PATH]; + DWORD version_size; + LPTSTR version_info; + UINT len, ret; + + // Get the full path to \Windows\System32\kernel32.dll and use that for + // determining what version of Windows we're running on. + len = MAX_PATH - (UINT)strlen("\\kernel32.dll") - 1; + ret = GetSystemDirectoryW(kernel32_path, len); + if (ret == 0 || ret > len) { + break; + } + wcsncat(kernel32_path, L"\\kernel32.dll", MAX_PATH - ret); + + version_size = GetFileVersionInfoSizeW(kernel32_path, NULL); + if (version_size == 0) { + break; + } + + version_info = (LPTSTR)malloc(version_size); + if (version_info == NULL) { + break; + } + + if (!GetFileVersionInfoW(kernel32_path, 0, version_size, version_info)) { + free(version_info); + break; + } + + if (!VerQueryValueW(version_info, L"\\", (LPVOID*)&file_info, &len)) { + free(version_info); + break; + } + majorVersion = HIWORD(file_info->dwProductVersionMS); + minorVersion = LOWORD(file_info->dwProductVersionMS); + free(version_info); + } while (0); /* * From msdn page on OSVERSIONINFOEX, current as of this @@ -420,17 +466,15 @@ GetJavaProperties(JNIEnv* env) * Windows Server 2008 R2 6 1 (!VER_NT_WORKSTATION) * Windows 8 6 2 (VER_NT_WORKSTATION) * Windows Server 2012 6 2 (!VER_NT_WORKSTATION) + * Windows 10 10 0 (VER_NT_WORKSTATION) * * This mapping will presumably be augmented as new Windows * versions are released. */ - switch (ver.dwPlatformId) { - case VER_PLATFORM_WIN32s: - sprops.os_name = "Windows 3.1"; - break; + switch (platformId) { case VER_PLATFORM_WIN32_WINDOWS: - if (ver.dwMajorVersion == 4) { - switch (ver.dwMinorVersion) { + if (majorVersion == 4) { + switch (minorVersion) { case 0: sprops.os_name = "Windows 95"; break; case 10: sprops.os_name = "Windows 98"; break; case 90: sprops.os_name = "Windows Me"; break; @@ -441,10 +485,10 @@ GetJavaProperties(JNIEnv* env) } break; case VER_PLATFORM_WIN32_NT: - if (ver.dwMajorVersion <= 4) { + if (majorVersion <= 4) { sprops.os_name = "Windows NT"; - } else if (ver.dwMajorVersion == 5) { - switch (ver.dwMinorVersion) { + } else if (majorVersion == 5) { + switch (minorVersion) { case 0: sprops.os_name = "Windows 2000"; break; case 1: sprops.os_name = "Windows XP"; break; case 2: @@ -459,8 +503,7 @@ GetJavaProperties(JNIEnv* env) * If it is, the operating system is Windows XP 64 bit; * otherwise, it is Windows Server 2003." */ - if(ver.wProductType == VER_NT_WORKSTATION && - si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { + if (is_workstation && is_64bit) { sprops.os_name = "Windows XP"; /* 64 bit */ } else { sprops.os_name = "Windows 2003"; @@ -468,12 +511,12 @@ GetJavaProperties(JNIEnv* env) break; default: sprops.os_name = "Windows NT (unknown)"; break; } - } else if (ver.dwMajorVersion == 6) { + } else if (majorVersion == 6) { /* * See table in MSDN OSVERSIONINFOEX documentation. */ - if (ver.wProductType == VER_NT_WORKSTATION) { - switch (ver.dwMinorVersion) { + if (is_workstation) { + switch (minorVersion) { case 0: sprops.os_name = "Windows Vista"; break; case 1: sprops.os_name = "Windows 7"; break; case 2: sprops.os_name = "Windows 8"; break; @@ -481,7 +524,7 @@ GetJavaProperties(JNIEnv* env) default: sprops.os_name = "Windows NT (unknown)"; } } else { - switch (ver.dwMinorVersion) { + switch (minorVersion) { case 0: sprops.os_name = "Windows Server 2008"; break; case 1: sprops.os_name = "Windows Server 2008 R2"; break; case 2: sprops.os_name = "Windows Server 2012"; break; @@ -489,6 +532,17 @@ GetJavaProperties(JNIEnv* env) default: sprops.os_name = "Windows NT (unknown)"; } } + } else if (majorVersion == 10) { + if (is_workstation) { + switch (minorVersion) { + case 0: sprops.os_name = "Windows 10"; break; + default: sprops.os_name = "Windows NT (unknown)"; + } + } else { + switch (minorVersion) { + default: sprops.os_name = "Windows NT (unknown)"; + } + } } else { sprops.os_name = "Windows NT (unknown)"; } @@ -497,7 +551,7 @@ GetJavaProperties(JNIEnv* env) sprops.os_name = "Windows (unknown)"; break; } - sprintf(buf, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion); + sprintf(buf, "%d.%d", majorVersion, minorVersion); sprops.os_version = _strdup(buf); #if _M_IA64 sprops.os_arch = "ia64"; @@ -508,9 +562,6 @@ GetJavaProperties(JNIEnv* env) #else sprops.os_arch = "unknown"; #endif - - sprops.patch_level = _strdup(ver.szCSDVersion); - sprops.desktop = "windows"; } @@ -621,7 +672,7 @@ GetJavaProperties(JNIEnv* env) &display_encoding); sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID); - if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && ver.dwMajorVersion == 6) { + if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && majorVersion == 6) { // MS claims "Vista has built-in support for HKSCS-2004. // All of the HKSCS-2004 characters have Unicode 4.1. // PUA code point assignments". But what it really means diff --git a/src/windows/native/sun/security/mscapi/security.cpp b/src/windows/native/sun/security/mscapi/security.cpp index 8b5d8aeb8a9442a65e46169404cef5917eb31f06..83613e8c15bc163b561b9d4bd9f8671cbc2f17c5 100644 --- a/src/windows/native/sun/security/mscapi/security.cpp +++ b/src/windows/native/sun/security/mscapi/security.cpp @@ -1659,29 +1659,36 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getModulus int convertToLittleEndian(JNIEnv *env, jbyteArray source, jbyte* destination, int destinationLength) { - int count = 0; int sourceLength = env->GetArrayLength(source); - if (sourceLength < destinationLength) { - return -1; - } - jbyte* sourceBytes = env->GetByteArrayElements(source, 0); if (sourceBytes == NULL) { return -1; } + int copyLen = sourceLength; + if (sourceLength > destinationLength) { + // source might include an extra sign byte + if (sourceLength == destinationLength + 1 && sourceBytes[0] == 0) { + copyLen--; + } else { + return -1; + } + } + // Copy bytes from the end of the source array to the beginning of the // destination array (until the destination array is full). // This ensures that the sign byte from the source array will be excluded. - for (int i = 0; i < destinationLength; i++) { - destination[i] = sourceBytes[sourceLength - i - 1]; - count++; + for (int i = 0; i < copyLen; i++) { + destination[i] = sourceBytes[sourceLength - 1 - i]; } - if (sourceBytes) - env->ReleaseByteArrayElements(source, sourceBytes, JNI_ABORT); + if (copyLen < destinationLength) { + memset(destination + copyLen, 0, destinationLength - copyLen); + } + + env->ReleaseByteArrayElements(source, sourceBytes, JNI_ABORT); - return count; + return destinationLength; } /* diff --git a/src/windows/resource/java.manifest b/src/windows/resource/java.manifest index 52f997e8b396a8ec2f5d735b55f6dbfaafd91ff1..f971a78ebb7efbaebbc0524f94cf25ea90e67574 100644 --- a/src/windows/resource/java.manifest +++ b/src/windows/resource/java.manifest @@ -52,6 +52,8 @@ + + diff --git a/test/TEST.groups b/test/TEST.groups index be800ee054bf8cc0a4cc6fe472b71c26ed6692d7..d1b858f0dbdefc58e44e70b1f398e1eb92da01e6 100644 --- a/test/TEST.groups +++ b/test/TEST.groups @@ -489,6 +489,7 @@ needs_compact3 = \ java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java \ java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java \ java/lang/System/MacEncoding/TestFileEncoding.java \ + java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java \ java/nio/channels/AsynchronousSocketChannel/Leaky.java \ java/security/PermissionCollection/Concurrent.java \ java/security/Principal/Implies.java \ diff --git a/test/com/sun/jndi/ldap/LdapURLOptionalFields.java b/test/com/sun/jndi/ldap/LdapURLOptionalFields.java new file mode 100644 index 0000000000000000000000000000000000000000..86b5c1a442be6be22957e0996f47edcc70793ab4 --- /dev/null +++ b/test/com/sun/jndi/ldap/LdapURLOptionalFields.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015, Red Hat, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8074761 + * @summary RFC-2255 allows attribute, scope and filter to be empty. + */ + +import com.sun.jndi.ldap.LdapURL; + +public class LdapURLOptionalFields { + + private static final String[] TEST_URLS = { + "ldap://localhost:10389/ou=RefPeople,dc=example,dc=com", + "ldap://localhost:10389/ou=RefPeople,dc=example,dc=com?", + "ldap://localhost:10389/ou=RefPeople,dc=example,dc=com??", + "ldap://localhost:10389/ou=RefPeople,dc=example,dc=com???", + "ldap://localhost:10389/ou=RefPeople,dc=example,dc=com????" + }; + + public static void main(String[] args) throws Exception { + for (int i = 0; i < TEST_URLS.length; i++) { + String url = TEST_URLS[i]; + checkEmptyAttributes(url); + } + } + + private static void checkEmptyAttributes(String urlString) throws Exception { + LdapURL url = new LdapURL(urlString); + if (url.getAttributes() != null) { + throw new Exception("Expected null attributes for url: '" + urlString + "'"); + } + if (url.getScope() != null) { + throw new Exception("Expected null scope for url: '" + urlString + "'"); + } + if (url.getFilter() != null) { + throw new Exception("Expected null filter for url: '" + urlString + "'"); + } + } + +} diff --git a/test/java/awt/FullScreen/MultimonFullscreenTest/MultimonDeadlockTest.java b/test/java/awt/FullScreen/MultimonFullscreenTest/MultimonDeadlockTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c457245c3f15b6dc6040d0dfac0a8ae653f473ea --- /dev/null +++ b/test/java/awt/FullScreen/MultimonFullscreenTest/MultimonDeadlockTest.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +/* + @test + @bug 8129116 + @summary Deadlock with multimonitor fullscreen windows. + @run main/timeout=20 MultimonDeadlockTest + */ +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.lang.reflect.InvocationTargetException; + +public class MultimonDeadlockTest { + + public static void main(String argv[]) { + final GraphicsDevice[] devices = GraphicsEnvironment + .getLocalGraphicsEnvironment() + .getScreenDevices(); + if (devices.length < 2) { + System.out.println("It's a multiscreen test... skipping!"); + return; + } + + Frame frames[] = new Frame[devices.length]; + try { + EventQueue.invokeAndWait(() -> { + for (int i = 0; i < devices.length; i++) { + frames[i] = new Frame(); + frames[i].setSize(100, 100); + frames[i].setBackground(Color.BLUE); + devices[i].setFullScreenWindow(frames[i]); + } + }); + Thread.sleep(5000); + } catch (InterruptedException | InvocationTargetException ex) { + } finally { + for (int i = 0; i < devices.length; i++) { + devices[i].setFullScreenWindow(null); + frames[i].dispose(); + } + } + + } +} diff --git a/test/java/lang/invoke/8022701/InvokeSeveralWays.java b/test/java/lang/invoke/8022701/InvokeSeveralWays.java index a5099dd60c5eee9937aef9b2e324858e9e651bd3..5c1f64bf9b0cf8fb413ba8394656bef48e35fb3c 100644 --- a/test/java/lang/invoke/8022701/InvokeSeveralWays.java +++ b/test/java/lang/invoke/8022701/InvokeSeveralWays.java @@ -38,12 +38,19 @@ public class InvokeSeveralWays { failures++; } catch (InvocationTargetException e) { Throwable c = e.getCause(); - if (expected.isInstance(c)) - System.out.println("EXPECTED: " + expected.getName() + ", "+ c); - else { - failures++; - System.out.println("FAIL: Unexpected wrapped exception " + c); - e.printStackTrace(System.out); + if (BootstrapMethodError.class.isInstance(c)) { + c = c.getCause(); + if (expected.isInstance(c)) + System.out.println("EXPECTED: " + expected.getName() + ", "+ c); + else { + failures++; + System.out.println("FAIL: Unexpected wrapped exception " + c); + e.printStackTrace(System.out); + } + } else { + failures++; + System.out.println("FAIL: Exception from MethodHandle invocation not wrapped in BootstrapMethodError " + c); + e.printStackTrace(System.out); } } catch (Throwable e) { failures++; @@ -74,14 +81,19 @@ public class InvokeSeveralWays { Invoker.invoke(); System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier"); failures++; - } catch (Throwable e) { - if (expected.isInstance(e)) - System.out.println("EXPECTED: " + expected.getName() + ", "+ e); + } catch (BootstrapMethodError e) { + Throwable c = e.getCause(); + if (expected.isInstance(c)) + System.out.println("EXPECTED: " + expected.getName() + ", "+ c); else { + failures++; + System.out.println("FAIL: Unexpected exception has been caught " + c); + e.printStackTrace(System.out); + } + } catch (Throwable e) { failures++; - System.out.println("FAIL: Unexpected exception has been caught " + e); + System.out.println("FAIL: Exception from MethodHandle invocation not wrapped in BootstrapMethodError " + e); e.printStackTrace(System.out); - } } System.out.println(); try { diff --git a/test/java/lang/invoke/LFCaching/LFCachingTestCase.java b/test/java/lang/invoke/LFCaching/LFCachingTestCase.java index 50a57e40c673a35efcc8f345f1aad9d569d9bc5f..b5f99bd00182d2c711b93ce45df21194c189c08e 100644 --- a/test/java/lang/invoke/LFCaching/LFCachingTestCase.java +++ b/test/java/lang/invoke/LFCaching/LFCachingTestCase.java @@ -77,7 +77,7 @@ public abstract class LFCachingTestCase extends LambdaFormTestCase { } } catch (IllegalAccessException | IllegalArgumentException | SecurityException | InvocationTargetException ex) { - throw new Error("Unexpected exception: ", ex); + throw new Error("Unexpected exception", ex); } } } diff --git a/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java b/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java index a60d46044066b8ea0ba1aaa2dfdcc72bc8d6dddc..347fabbb45a02ff5019553dce833be9061db0b09 100644 --- a/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java +++ b/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java @@ -59,10 +59,10 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase { super(testMethod); } - PhantomReference ph; - ReferenceQueue rq = new ReferenceQueue(); - MethodType mtype; - Map data; + PhantomReference ph; + ReferenceQueue rq = new ReferenceQueue(); + MethodType mtype; + Map data; @Override public void doTest() { @@ -73,7 +73,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase { try { adapter = testCase.getTestCaseMH(data, TestMethods.Kind.ONE); } catch (NoSuchMethodException ex) { - throw new Error("Unexpected exception: ", ex); + throw new Error("Unexpected exception", ex); } mtype = adapter.type(); Object lambdaForm = INTERNAL_FORM.invoke(adapter); @@ -94,12 +94,12 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase { collectLambdaForm(); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { - throw new Error("Unexpected exception: ", ex); + throw new Error("Unexpected exception", ex); } } private void collectLambdaForm() throws IllegalAccessException { - // Usually, 2 System.GCs are necessary to enqueue a SoftReference. + // Usually, 2 System.GCs are necessary to enqueue a SoftReference. System.gc(); System.gc(); @@ -129,7 +129,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase { }; } - private void dumpTestData() { + private void dumpTestData() { System.err.println("Test case: " + getTestMethod()); for (String s : data.keySet()) { System.err.printf("\t%20s => %s\n", s, data.get(s)); diff --git a/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java b/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java index 35c2f97d1910f1d972afce1d5434174d7663061b..95150f70a6a449f34f2de1bfc408a34f0ad94b41 100644 --- a/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java +++ b/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -35,18 +35,23 @@ */ import java.lang.invoke.MethodHandle; +import java.util.Collections; import java.util.EnumSet; +import java.util.HashMap; import java.util.Map; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; +import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor; /** * Multiple threaded lambda forms caching test class. */ public final class LFMultiThreadCachingTest extends LFCachingTestCase { + private static final TestMethods.Kind[] KINDS; + static { EnumSet set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT)); KINDS = set.toArray(new TestMethods.Kind[set.size()]); @@ -72,21 +77,50 @@ public final class LFMultiThreadCachingTest extends LFCachingTestCase { ConcurrentLinkedQueue adapters = new ConcurrentLinkedQueue<>(); CyclicBarrier begin = new CyclicBarrier(CORES); CountDownLatch end = new CountDownLatch(CORES); + final Map threadUncaughtExceptions + = Collections.synchronizedMap(new HashMap(CORES)); for (int i = 0; i < CORES; ++i) { TestMethods.Kind kind = KINDS[i % KINDS.length]; - new Thread(() -> { + Thread t = new Thread(() -> { try { begin.await(); adapters.add(getTestMethod().getTestCaseMH(data, kind)); - } catch (InterruptedException | BrokenBarrierException | IllegalAccessException | NoSuchMethodException ex) { - throw new Error("Unexpected exception: ", ex); + } catch (Throwable ex) { + threadUncaughtExceptions.put(Thread.currentThread(), ex); } finally { end.countDown(); } - }).start(); + }); + t.start(); } try { end.await(); + boolean vmeThrown = false; + boolean nonVmeThrown = false; + Throwable vme = null; + for (Map.Entry entry : threadUncaughtExceptions.entrySet()) { + Thread t = entry.getKey(); + Throwable e = entry.getValue(); + System.err.printf("%nA thread with name \"%s\" of %d threads" + + " has thrown exception:%n", t.getName(), CORES); + e.printStackTrace(); + if (CodeCacheOverflowProcessor.isThrowableCausedByVME(e)) { + vmeThrown = true; + vme = e; + } else { + nonVmeThrown = true; + } + if (nonVmeThrown) { + throw new Error("One ore more threads have" + + " thrown unexpected exceptions. See log."); + } + if (vmeThrown) { + throw new Error("One ore more threads have" + + " thrown VirtualMachineError caused by" + + " code cache overflow. See log.", vme); + } + } } catch (InterruptedException ex) { throw new Error("Unexpected exception: ", ex); } diff --git a/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java b/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java index 6a44e44d8b6b391303323f7eed76152ef8ad541d..3d468a4833c4301127b96e32c717f7628259065b 100644 --- a/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java +++ b/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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,7 @@ public final class LFSingleThreadCachingTest extends LFCachingTestCase { adapter1 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE); adapter2 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.TWO); } catch (NoSuchMethodException | IllegalAccessException ex) { - throw new Error("Unexpected exception: ", ex); + throw new Error("Unexpected exception", ex); } checkLFCaching(adapter1, adapter2); } diff --git a/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java b/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java index 5d037cabcf2cf47024d417cb321f92faaeb98d7b..f945883807aa6827265f02fac48f9db3dbc00d15 100644 --- a/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java +++ b/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -22,8 +22,7 @@ */ import com.oracle.testlibrary.jsr292.Helper; -import com.sun.management.HotSpotDiagnosticMXBean; - +import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor; import java.lang.invoke.MethodHandle; import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; @@ -45,8 +44,6 @@ import jdk.testlibrary.TimeLimitedRunner; */ public abstract class LambdaFormTestCase { - private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO - = 45 / (128.0 * 1024 * 1024); private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9); /** @@ -73,23 +70,89 @@ public abstract class LambdaFormTestCase { REF_FIELD = Reference.class.getDeclaredField("referent"); REF_FIELD.setAccessible(true); } catch (Exception ex) { - throw new Error("Unexpected exception: ", ex); + throw new Error("Unexpected exception", ex); } gcInfo = ManagementFactory.getGarbageCollectorMXBeans(); - if (gcInfo.size() == 0) { + if (gcInfo.size() == 0) { throw new Error("No GarbageCollectorMXBeans found."); } } private final TestMethods testMethod; - private static long totalIterations = 0L; - private static long doneIterations = 0L; - private static boolean passed = true; - private static int testCounter = 0; - private static int failCounter = 0; private long gcCountAtStart; + private static class TestRun { + + final Function ctor; + final Collection testMethods; + final long totalIterations; + long doneIterations; + long testCounter; + long failCounter; + boolean passed; + + TestRun(Function ctor, Collection testMethods) { + this.ctor = ctor; + this.testMethods = testMethods; + long testCaseNum = testMethods.size(); + long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum); + System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n", + iterations, iterations * testCaseNum); + System.out.printf("Number of iterations is set to %d (%d cases)%n", + iterations, iterations * testCaseNum); + System.out.flush(); + totalIterations = iterations; + doneIterations = 0L; + testCounter = 0L; + failCounter = 0L; + passed = true; + } + + Boolean doIteration() { + if (doneIterations >= totalIterations) { + return false; + } + System.err.println(String.format("Iteration %d:", doneIterations)); + for (TestMethods testMethod : testMethods) { + LambdaFormTestCase testCase = ctor.apply(testMethod); + try { + System.err.printf("Tested LF caching feature" + + " with MethodHandles.%s method.%n", + testCase.getTestMethod().name); + Throwable t = CodeCacheOverflowProcessor + .runMHTest(testCase::doTest); + if (t != null) { + return false; + } + System.err.println("PASSED"); + } catch (OutOfMemoryError oome) { + // Don't swallow OOME so a heap dump can be created. + System.err.println("FAILED"); + throw oome; + } catch (Throwable t) { + t.printStackTrace(); + System.err.printf("FAILED. Caused by %s%n", t.getMessage()); + passed = false; + failCounter++; + } + testCounter++; + } + doneIterations++; + return true; + } + + void checkPassed() { + if (!passed) { + throw new Error(String.format("%d of %d test cases FAILED! %n" + + "Rerun the test with the same \"-Dseed=\" option as in the log file!", + failCounter, testCounter)); + } else { + System.err.printf("All %d test cases PASSED!%n", testCounter); + } + } + } + /** * Test case constructor. Generates test cases with random method types for * given methods form {@code j.l.i.MethodHandles} class. @@ -123,65 +186,15 @@ public abstract class LambdaFormTestCase { * @param testMethods list of test methods */ public static void runTests(Function ctor, Collection testMethods) { - long testCaseNum = testMethods.size(); - totalIterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum); - System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n", - totalIterations, totalIterations * testCaseNum); - HotSpotDiagnosticMXBean hsDiagBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class); - long codeCacheSize = Long.parseLong( - hsDiagBean.getVMOption("ReservedCodeCacheSize").getValue()); - System.out.printf("Code Cache Size is %d bytes%n", codeCacheSize); - long iterationsByCodeCacheSize = (long) (codeCacheSize - * ITERATIONS_TO_CODE_CACHE_SIZE_RATIO); - System.out.printf("Number of iterations limited by code cache size is %d (%d cases)%n", - iterationsByCodeCacheSize, iterationsByCodeCacheSize * testCaseNum); - if (totalIterations > iterationsByCodeCacheSize) { - totalIterations = iterationsByCodeCacheSize; - } - System.out.printf("Number of iterations is set to %d (%d cases)%n", - totalIterations, totalIterations * testCaseNum); - System.out.flush(); - TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, - () -> { - if (doneIterations >= totalIterations) { - return false; - } - System.err.println(String.format("Iteration %d:", doneIterations)); - for (TestMethods testMethod : testMethods) { - LambdaFormTestCase testCase = ctor.apply(testMethod); - try { - System.err.printf("Tested LF caching feature with MethodHandles.%s method.%n", - testCase.getTestMethod().name); - testCase.doTest(); - System.err.println("PASSED"); - } catch (OutOfMemoryError e) { - // Don't swallow OOME so a heap dump can be created. - System.err.println("FAILED"); - throw e; - } catch (Throwable t) { - t.printStackTrace(); - System.err.println("FAILED"); - passed = false; - failCounter++; - } - testCounter++; - } - doneIterations++; - return true; - }); + LambdaFormTestCase.TestRun run + = new LambdaFormTestCase.TestRun(ctor, testMethods); + TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration); try { runner.call(); - } catch (Throwable t) { - t.printStackTrace(); + } catch (Exception ex) { System.err.println("FAILED"); - throw new Error("Unexpected error!"); - } - if (!passed) { - throw new Error(String.format("%d of %d test cases FAILED! %n" - + "Rerun the test with the same \"-Dseed=\" option as in the log file!", - failCounter, testCounter)); - } else { - System.err.println(String.format("All %d test cases PASSED!", testCounter)); + throw new Error("Unexpected error!", ex); } + run.checkPassed(); } } diff --git a/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java b/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java index 7202f2f84c95687a67c20a4d3fc6d837a69b7a81..ecfca10edd6ee41b85634fd68e4349f0253e0936 100644 --- a/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java +++ b/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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,10 @@ package test.java.lang.invoke.MethodHandles; import com.oracle.testlibrary.jsr292.Helper; +import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor; import jdk.testlibrary.Asserts; +import jdk.testlibrary.TimeLimitedRunner; +import jdk.testlibrary.Utils; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -37,10 +40,10 @@ import java.util.function.Supplier; /* @test * @library /lib/testlibrary/jsr292 /lib/testlibrary/ * @compile CatchExceptionTest.java - * @build jdk.testlibrary.* * @run main/othervm -esa test.java.lang.invoke.MethodHandles.CatchExceptionTest */ public class CatchExceptionTest { + private static final List> ARGS_CLASSES; protected static final int MAX_ARITY = Helper.MAX_ARITY - 1; @@ -69,12 +72,6 @@ public class CatchExceptionTest { final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; - if (Helper.IS_VERBOSE) { - System.out.printf("CatchException::CatchException(%s, isVararg=%b " + - "argsCount=%d catchDrops=%d)%n", - testCase, isVararg, argsCount, catchDrops - ); - } MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List> classes; @@ -94,21 +91,34 @@ public class CatchExceptionTest { } public static void main(String[] args) throws Throwable { - for (CatchExceptionTest test : TestFactory.MANDATORY_TEST_CASES) { - test.runTest(); - } + CodeCacheOverflowProcessor.runMHTest(CatchExceptionTest::test); + } + + public static void test() throws Throwable { + System.out.println("classes = " + ARGS_CLASSES); TestFactory factory = new TestFactory(); - CatchExceptionTest test; - while ((test = factory.nextTest()) != null ) { + long timeout = Helper.IS_THOROUGH ? 0L : Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT); + // subtract vm init time and reserve time for vm exit + timeout *= 0.9; + TimeLimitedRunner runner = new TimeLimitedRunner(timeout, 2.0d, + () -> { + CatchExceptionTest test = factory.nextTest(); + if (test != null) { + test.runTest(); + return true; + } + return false; + }); + for (CatchExceptionTest test : TestFactory.MANDATORY_TEST_CASES) { test.runTest(); } + runner.call(); } private List> getThrowerParams(boolean isVararg, int argsCount) { return Helper.getParams(ARGS_CLASSES, isVararg, argsCount); } - private List> getCatcherParams() { int catchArgc = 1 + this.argsCount - dropped; List> result = new ArrayList<>( @@ -119,6 +129,13 @@ public class CatchExceptionTest { } private void runTest() { + if (Helper.IS_VERBOSE) { + System.out.printf("CatchException(%s, isVararg=%b argsCount=%d " + + "dropped=%d)%n", + testCase, thrower.isVarargsCollector(), + argsCount, dropped); + } + Helper.clear(); Object[] args = Helper.randomArgs( @@ -172,7 +189,7 @@ class TestFactory { {CatchExceptionTest.MAX_ARITY, 0}, {CatchExceptionTest.MAX_ARITY, CatchExceptionTest.MAX_ARITY}, }) { - MANDATORY_TEST_CASES.addAll(createTests(args[0], args[1])); + MANDATORY_TEST_CASES.addAll(createTests(args[0], args[1])); } } @@ -200,10 +217,7 @@ class TestFactory { args = 1; } - if (Helper.IS_VERBOSE) { - System.out.printf("maxArgs = %d%nmaxDrops = %d%n", - maxArgs, maxDrops); - } + System.out.printf("maxArgs = %d%nmaxDrops = %d%n", maxArgs, maxDrops); constructorSize = TestCase.CONSTRUCTORS.size(); } @@ -230,8 +244,9 @@ class TestFactory { } /** - * @return next test from test matrix: - * {varArgs, noVarArgs} x TestCase.rtypes x TestCase.THROWABLES x {1, .., maxArgs } x {1, .., maxDrops} + * @return next test from test matrix: {varArgs, noVarArgs} x + * TestCase.rtypes x TestCase.THROWABLES x {1, .., maxArgs } x + * {0, .., maxDrops} */ public CatchExceptionTest nextTest() { if (constructor < constructorSize) { @@ -244,7 +259,7 @@ class TestFactory { return null; } if (dropArgs <= currentMaxDrops) { - if (dropArgs == 1) { + if (dropArgs == 0) { if (Helper.IS_THOROUGH || Helper.RNG.nextBoolean()) { ++dropArgs; return createTest(); @@ -259,8 +274,8 @@ class TestFactory { } } - if (args <= maxArgs) { - dropArgs = 1; + if (args < maxArgs) { + dropArgs = 0; currentMaxDrops = Math.min(args, maxDrops); ++args; return createTest(); @@ -274,17 +289,17 @@ class TestFactory { TestCase.CONSTRUCTORS.get(constructor++).get(), Helper.RNG.nextBoolean(), args, dropArgs); } else { - if (isVararg) { - isVararg = false; - return new CatchExceptionTest( - TestCase.CONSTRUCTORS.get(constructor++).get(), - isVararg, args, dropArgs); - } else { - isVararg = true; - return new CatchExceptionTest( - TestCase.CONSTRUCTORS.get(constructor).get(), - isVararg, args, dropArgs); - } + if (isVararg) { + isVararg = false; + return new CatchExceptionTest( + TestCase.CONSTRUCTORS.get(constructor++).get(), + isVararg, args, dropArgs); + } else { + isVararg = true; + return new CatchExceptionTest( + TestCase.CONSTRUCTORS.get(constructor).get(), + isVararg, args, dropArgs); + } } } } @@ -412,7 +427,7 @@ class TestCase { } private static - Object throwOrReturn(Object normal, T exception) throws T { + Object throwOrReturn(Object normal, T exception) throws T { if (exception != null) { Helper.called("throwOrReturn/throw", normal, exception); throw exception; @@ -421,8 +436,7 @@ class TestCase { return normal; } - private static - Object catcher(Object o) { + private static Object catcher(Object o) { Helper.called("catcher", o); return o; } @@ -433,7 +447,7 @@ class TestCase { public MethodHandle getCatcher(List> classes) { return MethodHandles.filterReturnValue(Helper.AS_LIST.asType( - MethodType.methodType(Object.class, classes)), + MethodType.methodType(Object.class, classes)), CATCHER ); } diff --git a/test/java/lang/invoke/MethodHandlesTest.java b/test/java/lang/invoke/MethodHandlesTest.java index 993eaefef0f1c5af17172dfe74a6f0c933ebd4e2..48aad9112eb4dd80fed16a3054eb77be6ace9b1d 100644 --- a/test/java/lang/invoke/MethodHandlesTest.java +++ b/test/java/lang/invoke/MethodHandlesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, 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 @@ -23,6 +23,7 @@ /* @test * @summary unit tests for java.lang.invoke.MethodHandles + * @library /lib/testlibrary /lib/testlibrary/jsr292 * @compile MethodHandlesTest.java remote/RemoteExample.java * @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa test.java.lang.invoke.MethodHandlesTest */ @@ -36,6 +37,7 @@ import java.lang.reflect.*; import java.util.*; import org.junit.*; import static org.junit.Assert.*; +import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor; /** @@ -499,6 +501,10 @@ public class MethodHandlesTest { @Test public void testFindStatic() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFindStatic0); + } + + public void testFindStatic0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("findStatic"); testFindStatic(PubExample.class, void.class, "s0"); @@ -586,6 +592,10 @@ public class MethodHandlesTest { @Test public void testFindVirtual() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFindVirtual0); + } + + public void testFindVirtual0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("findVirtual"); testFindVirtual(Example.class, void.class, "v0"); @@ -616,6 +626,10 @@ public class MethodHandlesTest { @Test public void testFindVirtualClone() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFindVirtualClone0); + } + + public void testFindVirtualClone0() throws Throwable { // test some ad hoc system methods testFindVirtual(false, PUBLIC, Object.class, Object.class, "clone"); testFindVirtual(true, PUBLIC, Object[].class, Object.class, "clone"); @@ -699,6 +713,10 @@ public class MethodHandlesTest { @Test public void testFindSpecial() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFindSpecial0); + } + + public void testFindSpecial0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("findSpecial"); testFindSpecial(SubExample.class, Example.class, void.class, "v0"); @@ -775,6 +793,10 @@ public class MethodHandlesTest { @Test public void testFindConstructor() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFindConstructor0); + } + + public void testFindConstructor0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("findConstructor"); testFindConstructor(true, EXAMPLE, Example.class); @@ -818,6 +840,10 @@ public class MethodHandlesTest { @Test public void testBind() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testBind0); + } + + public void testBind0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("bind"); testBind(Example.class, void.class, "v0"); @@ -879,6 +905,10 @@ public class MethodHandlesTest { @Test public void testUnreflect() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testUnreflect0); + } + + public void testUnreflect0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("unreflect"); testUnreflect(Example.class, true, void.class, "s0"); @@ -985,6 +1015,10 @@ public class MethodHandlesTest { @Test public void testUnreflectSpecial() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testUnreflectSpecial0); + } + + public void testUnreflectSpecial0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("unreflectSpecial"); testUnreflectSpecial(Example.class, Example.class, void.class, "v0"); @@ -1077,23 +1111,38 @@ public class MethodHandlesTest { @Test public void testUnreflectGetter() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testUnreflectGetter0); + } + + public void testUnreflectGetter0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("unreflectGetter"); testGetter(TEST_UNREFLECT); } + @Test public void testFindGetter() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFindGetter0); + } + + public void testFindGetter0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("findGetter"); testGetter(TEST_FIND_FIELD); testGetter(TEST_FIND_FIELD | TEST_BOUND); } + @Test public void testFindStaticGetter() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFindStaticGetter0); + } + + public void testFindStaticGetter0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("findStaticGetter"); testGetter(TEST_FIND_STATIC); } + public void testGetter(int testMode) throws Throwable { Lookup lookup = PRIVATE; // FIXME: test more lookups than this one for (Object[] c : HasFields.CASES) { @@ -1287,26 +1336,40 @@ public class MethodHandlesTest { } } - @Test public void testUnreflectSetter() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testUnreflectSetter0); + } + + public void testUnreflectSetter0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("unreflectSetter"); testSetter(TEST_UNREFLECT); } + @Test public void testFindSetter() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFindSetter0); + } + + public void testFindSetter0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("findSetter"); testSetter(TEST_FIND_FIELD); testSetter(TEST_FIND_FIELD | TEST_BOUND); } + @Test public void testFindStaticSetter() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFindStaticSetter0); + } + + public void testFindStaticSetter0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("findStaticSetter"); testSetter(TEST_FIND_STATIC); } + public void testSetter(int testMode) throws Throwable { Lookup lookup = PRIVATE; // FIXME: test more lookups than this one startTest("unreflectSetter"); @@ -1329,6 +1392,10 @@ public class MethodHandlesTest { @Test public void testArrayElementGetter() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testArrayElementGetter0); + } + + public void testArrayElementGetter0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("arrayElementGetter"); testArrayElementGetterSetter(false); @@ -1336,6 +1403,10 @@ public class MethodHandlesTest { @Test public void testArrayElementSetter() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testArrayElementSetter0); + } + + public void testArrayElementSetter0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("arrayElementSetter"); testArrayElementGetterSetter(true); @@ -1349,6 +1420,10 @@ public class MethodHandlesTest { @Test public void testArrayElementErrors() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testArrayElementErrors0); + } + + public void testArrayElementErrors0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("arrayElementErrors"); testArrayElementGetterSetter(false, TEST_ARRAY_NPE); @@ -1528,6 +1603,10 @@ public class MethodHandlesTest { @Test public void testConvertArguments() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testConvertArguments0); + } + + public void testConvertArguments0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("convertArguments"); testConvert(Callee.ofType(1), null, "id", int.class); @@ -1591,6 +1670,10 @@ public class MethodHandlesTest { @Test public void testVarargsCollector() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testVarargsCollector0); + } + + public void testVarargsCollector0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("varargsCollector"); MethodHandle vac0 = PRIVATE.findStatic(MethodHandlesTest.class, "called", @@ -1605,8 +1688,12 @@ public class MethodHandlesTest { } } - @Test // SLOW + @Test // SLOW public void testPermuteArguments() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testPermuteArguments0); + } + + public void testPermuteArguments0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("permuteArguments"); testPermuteArguments(4, Integer.class, 2, long.class, 6); @@ -1744,8 +1831,12 @@ public class MethodHandlesTest { } - @Test // SLOW + @Test // SLOW public void testSpreadArguments() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testSpreadArguments0); + } + + public void testSpreadArguments0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("spreadArguments"); for (Class argType : new Class[]{Object.class, Integer.class, int.class}) { @@ -1838,8 +1929,12 @@ public class MethodHandlesTest { } } - @Test // SLOW + @Test // SLOW public void testAsCollector() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testAsCollector0); + } + + public void testAsCollector0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("asCollector"); for (Class argType : new Class[]{Object.class, Integer.class, int.class}) { @@ -1880,8 +1975,12 @@ public class MethodHandlesTest { assertArrayEquals(collectedArgs, returnValue); } - @Test // SLOW + @Test // SLOW public void testInsertArguments() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testInsertArguments0); + } + + public void testInsertArguments0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("insertArguments"); for (int nargs = 0; nargs < 50; nargs++) { @@ -1923,6 +2022,10 @@ public class MethodHandlesTest { @Test public void testFilterReturnValue() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFilterReturnValue0); + } + + public void testFilterReturnValue0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("filterReturnValue"); Class classOfVCList = varargsList(1).invokeWithArguments(0).getClass(); @@ -1972,6 +2075,10 @@ public class MethodHandlesTest { @Test public void testFilterArguments() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFilterArguments0); + } + + public void testFilterArguments0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("filterArguments"); for (int nargs = 1; nargs <= 6; nargs++) { @@ -2004,6 +2111,10 @@ public class MethodHandlesTest { @Test public void testCollectArguments() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testCollectArguments0); + } + + public void testCollectArguments0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("collectArguments"); testFoldOrCollectArguments(true); @@ -2011,6 +2122,10 @@ public class MethodHandlesTest { @Test public void testFoldArguments() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testFoldArguments0); + } + + public void testFoldArguments0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("foldArguments"); testFoldOrCollectArguments(false); @@ -2112,6 +2227,10 @@ public class MethodHandlesTest { @Test public void testDropArguments() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testDropArguments0); + } + + public void testDropArguments0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("dropArguments"); for (int nargs = 0; nargs <= 4; nargs++) { @@ -2143,6 +2262,10 @@ public class MethodHandlesTest { @Test // SLOW public void testInvokers() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testInvokers0); + } + + public void testInvokers0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("exactInvoker, genericInvoker, varargsInvoker, dynamicInvoker"); // exactInvoker, genericInvoker, varargsInvoker[0..N], dynamicInvoker @@ -2344,6 +2467,10 @@ public class MethodHandlesTest { @Test public void testGuardWithTest() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testGuardWithTest0); + } + + public void testGuardWithTest0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("guardWithTest"); for (int nargs = 0; nargs <= 50; nargs++) { @@ -2415,6 +2542,10 @@ public class MethodHandlesTest { @Test public void testThrowException() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testThrowException0); + } + + public void testThrowException0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("throwException"); testThrowException(int.class, new ClassCastException("testing")); @@ -2446,6 +2577,10 @@ public class MethodHandlesTest { @Test public void testInterfaceCast() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testInterfaceCast0); + } + + public void testInterfaceCast0() throws Throwable { //if (CAN_SKIP_WORKING) return; startTest("interfaceCast"); assert( (((Object)"foo") instanceof CharSequence)); @@ -2543,6 +2678,10 @@ public class MethodHandlesTest { @Test // SLOW public void testCastFailure() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testCastFailure0); + } + + public void testCastFailure0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("testCastFailure"); testCastFailure("cast/argument", 11000); @@ -2655,6 +2794,10 @@ public class MethodHandlesTest { @Test public void testUserClassInSignature() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testUserClassInSignature0); + } + + public void testUserClassInSignature0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("testUserClassInSignature"); Lookup lookup = MethodHandles.lookup(); @@ -2706,6 +2849,10 @@ public class MethodHandlesTest { @Test public void testAsInterfaceInstance() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testAsInterfaceInstance0); + } + + public void testAsInterfaceInstance0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("asInterfaceInstance"); Lookup lookup = MethodHandles.lookup(); @@ -2869,6 +3016,10 @@ public class MethodHandlesTest { @Test public void testRunnableProxy() throws Throwable { + CodeCacheOverflowProcessor.runMHTest(this::testRunnableProxy0); + } + + public void testRunnableProxy0() throws Throwable { if (CAN_SKIP_WORKING) return; startTest("testRunnableProxy"); MethodHandles.Lookup lookup = MethodHandles.lookup(); diff --git a/test/java/lang/invoke/TestCatchExceptionWithVarargs.java b/test/java/lang/invoke/TestCatchExceptionWithVarargs.java index d5d6c102b42475ca0a0707c43cc2a6269ba3c419..160c04a65d2dc157e214d8c1d80254d768557a87 100644 --- a/test/java/lang/invoke/TestCatchExceptionWithVarargs.java +++ b/test/java/lang/invoke/TestCatchExceptionWithVarargs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,9 +24,12 @@ /* * @test * @bug 8019184 + * @library /lib/testlibrary /lib/testlibrary/jsr292 * @summary MethodHandles.catchException() fails when methods have 8 args + varargs + * @run main TestCatchExceptionWithVarargs */ +import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor; import java.util.*; import java.lang.invoke.*; @@ -68,6 +71,11 @@ public class TestCatchExceptionWithVarargs { } public static void main(String[] args) throws Throwable { + CodeCacheOverflowProcessor + .runMHTest(TestCatchExceptionWithVarargs::test); + } + + public static void test() throws Throwable { List> ptypes = new LinkedList<>(); ptypes.add(Object[].class); diff --git a/test/java/lang/invoke/VarargsArrayTest.java b/test/java/lang/invoke/VarargsArrayTest.java index 91bf36485f2998f878dd77da2a2e772e7c70f76f..a247fa5b43414e7bedc4bd73fbc2f825baa4c178 100644 --- a/test/java/lang/invoke/VarargsArrayTest.java +++ b/test/java/lang/invoke/VarargsArrayTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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,14 +24,14 @@ package java.lang.invoke; import sun.invoke.util.Wrapper; - import java.util.Arrays; import java.util.Collections; +import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor; /* @test * @summary unit tests for varargs array methods: MethodHandleInfo.varargsArray(int), * MethodHandleInfo.varargsArray(Class,int) & MethodHandleInfo.varargsList(int) - * + * @library /lib/testlibrary /lib/testlibrary/jsr292 * @run main/bootclasspath java.lang.invoke.VarargsArrayTest * @run main/bootclasspath -DVarargsArrayTest.MAX_ARITY=255 -DVarargsArrayTest.START_ARITY=250 * java.lang.invoke.VarargsArrayTest @@ -47,6 +47,10 @@ public class VarargsArrayTest { private static final boolean EXHAUSTIVE = Boolean.getBoolean(CLASS.getSimpleName()+".EXHAUSTIVE"); public static void main(String[] args) throws Throwable { + CodeCacheOverflowProcessor.runMHTest(VarargsArrayTest::test); + } + + public static void test() throws Throwable { testVarargsArray(); testVarargsReferenceArray(); testVarargsPrimitiveArray(); diff --git a/test/java/util/concurrent/LinkedTransferQueue/SpliteratorTraverseAddRemoveTest.java b/test/java/util/concurrent/LinkedTransferQueue/SpliteratorTraverseAddRemoveTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4d288a27845573a1b0fd0a64ed70768abcaef5ff --- /dev/null +++ b/test/java/util/concurrent/LinkedTransferQueue/SpliteratorTraverseAddRemoveTest.java @@ -0,0 +1,114 @@ +/* + * 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. + */ + +/* + * @test + * @run testng SpliteratorTraverseAddRemoveTest + * @bug 8085978 + * @summary repeatedly traverse the queue using the spliterator while + * concurrently adding and removing an element to test that self-linked + * nodes are never erroneously reported on traversal + */ + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Queue; +import java.util.Spliterator; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.LinkedTransferQueue; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; + +@Test +public class SpliteratorTraverseAddRemoveTest { + + static Object[] of(String desc, Consumer> c) { + return new Object[]{desc, c}; + } + + static void assertIsString(Object e) { + Assert.assertTrue(e instanceof String, + String.format("Object instanceof %s (actual: instanceof %s)", + String.class.getName(), + e.getClass().getName())); + } + + @DataProvider() + public static Object[][] spliteratorTraversers() { + return new Object[][]{ + of("forEachRemaining", q -> { + q.spliterator().forEachRemaining(SpliteratorTraverseAddRemoveTest::assertIsString); + }), + of("tryAdvance", q -> { + Spliterator s = q.spliterator(); + while (s.tryAdvance(SpliteratorTraverseAddRemoveTest::assertIsString)) + ; + }), + of("trySplit then forEachRemaining", q -> { + Spliterator r = q.spliterator(); + + List> ss = new ArrayList<>(); + Spliterator l; + while ((l = r.trySplit()) != null) { + ss.add(l); + } + ss.add(r); + + ss.forEach(s -> s.forEachRemaining(SpliteratorTraverseAddRemoveTest::assertIsString)); + }), + }; + } + + @Test(dataProvider = "spliteratorTraversers") + public void testQueue(String desc, Consumer> c) + throws InterruptedException { + AtomicBoolean done = new AtomicBoolean(false); + Queue msgs = new LinkedTransferQueue<>(); + + CompletableFuture traversalTask = CompletableFuture.runAsync(() -> { + while (!done.get()) { + // Traversal will fail if self-linked nodes of + // LinkedTransferQueue are erroneously reported + c.accept(msgs); + } + }); + CompletableFuture addAndRemoveTask = CompletableFuture.runAsync(() -> { + while (!traversalTask.isDone()) { + msgs.add("msg"); + msgs.remove("msg"); + } + }); + + Thread.sleep(TimeUnit.SECONDS.toMillis(1)); + done.set(true); + + addAndRemoveTask.join(); + Assert.assertTrue(traversalTask.isDone()); + traversalTask.join(); + } +} diff --git a/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java b/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java index cd6894d0543cc6965d4c0d0109194dba80454c27..f686cf70d3a7c750406147d5c31826652c7b01cb 100644 --- a/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java +++ b/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java @@ -104,6 +104,8 @@ public class DisabledAlgorithms { default: throw new RuntimeException("Wrong parameter: " + args[0]); } + + System.out.println("Test passed"); } /* @@ -128,7 +130,6 @@ public class DisabledAlgorithms { } } - server.stop(); while (server.isRunning()) { sleep(); } @@ -224,11 +225,19 @@ public class DisabledAlgorithms { } catch (SSLHandshakeException e) { System.out.println("Server: run: " + e); sslError = true; + stopped = true; } catch (IOException e) { if (!stopped) { - System.out.println("Server: run: " + e); + System.out.println("Server: run: unexpected exception: " + + e); e.printStackTrace(); otherError = true; + stopped = true; + } else { + System.out.println("Server: run: " + e); + System.out.println("The exception above occurred " + + "because socket was closed, " + + "please ignore it"); } } } @@ -261,6 +270,7 @@ public class DisabledAlgorithms { stopped = true; if (!ssocket.isClosed()) { try { + System.out.println("Server: close socket"); ssocket.close(); } catch (IOException e) { System.out.println("Server: close: " + e); diff --git a/test/lib/testlibrary/jdk/testlibrary/Utils.java b/test/lib/testlibrary/jdk/testlibrary/Utils.java index afcf6325bfb37f9c4bbf530ab356abeabfbc0bd4..c769e705c4464323dea38a429aa1116e231aeb88 100644 --- a/test/lib/testlibrary/jdk/testlibrary/Utils.java +++ b/test/lib/testlibrary/jdk/testlibrary/Utils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.regex.Pattern; import java.util.regex.Matcher; import java.util.concurrent.TimeUnit; +import java.util.function.Function; /** * Common library for various test helper functions. @@ -276,4 +277,38 @@ public final class Utils { public static long adjustTimeout(long tOut) { return Math.round(tOut * Utils.TIMEOUT_FACTOR); } + + /** + * Interface same as java.lang.Runnable but with + * method {@code run()} able to throw any Throwable. + */ + public static interface ThrowingRunnable { + void run() throws Throwable; + } + + /** + * Filters out an exception that may be thrown by the given + * test according to the given filter. + * + * @param test - method that is invoked and checked for exception. + * @param filter - function that checks if the thrown exception matches + * criteria given in the filter's implementation. + * @return - exception that matches the filter if it has been thrown or + * {@code null} otherwise. + * @throws Throwable - if test has thrown an exception that does not + * match the filter. + */ + public static Throwable filterException(ThrowingRunnable test, + Function filter) throws Throwable { + try { + test.run(); + } catch (Throwable t) { + if (filter.apply(t)) { + return t; + } else { + throw t; + } + } + return null; + } } diff --git a/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java b/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java new file mode 100644 index 0000000000000000000000000000000000000000..d5d6b1c34f3cefe255ecbf762932fdeb3f700ffe --- /dev/null +++ b/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java @@ -0,0 +1,79 @@ +/* + * 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. + */ +package com.oracle.testlibrary.jsr292; + +import jdk.testlibrary.Utils; + +/** + * Helper class used to catch and process VirtualMachineError with message "Out + * of space in CodeCache". Some JSR292 tests run out of code cache size, so code + * cache overflows and VME is thrown. This VME is considered as non-critical in + * some JSR292 tests, so it should be processed to prevent test failure. + */ +public class CodeCacheOverflowProcessor { + + /** + * Checks if an instance of Throwable is caused by VirtualMachineError with + * message "Out of space in CodeCache". May be used as filter in method + * {@code jdk.testlibrary.Utils.filterException}. + * + * @param t - Throwable to check. + * @return true if Throwable is caused by VME, false otherwise. + */ + public static Boolean isThrowableCausedByVME(Throwable t) { + Throwable causeOfT = t; + do { + if (causeOfT instanceof VirtualMachineError + && causeOfT.getMessage().matches(".*[Oo]ut of space" + + " in CodeCache.*")) { + return true; + } + causeOfT = causeOfT != null ? causeOfT.getCause() : null; + } while (causeOfT != null && causeOfT != t); + return false; + } + + /** + * Checks if the given test throws an exception caused by + * VirtualMachineError with message "Out of space in CodeCache", and, if VME + * takes place, processes it so that no exception is thrown, and prints its + * stack trace. If test throws exception not caused by VME, this method just + * re-throws this exception. + * + * @param test - test to check for and process VirtualMachineError. + * @return - an exception caused by VME or null + * if test has thrown no exception. + * @throws Throwable - if test has thrown an exception + * that is not caused by VME. + */ + public static Throwable runMHTest(Utils.ThrowingRunnable test) throws Throwable { + Throwable t = Utils.filterException(test::run, + CodeCacheOverflowProcessor::isThrowableCausedByVME); + if (t != null) { + System.err.printf("%nNon-critical exception caught becuse of" + + " code cache size is not enough to run all test cases.%n%n"); + t.printStackTrace(); + } + return t; + } +} diff --git a/test/sun/security/mscapi/SmallPrimeExponentP.java b/test/sun/security/mscapi/SmallPrimeExponentP.java new file mode 100644 index 0000000000000000000000000000000000000000..88c3bbeda8d9887c9387d793cc8ec4e348f1716c --- /dev/null +++ b/test/sun/security/mscapi/SmallPrimeExponentP.java @@ -0,0 +1,75 @@ +/* + * 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 sun.security.tools.keytool.CertAndKeyGen; +import sun.security.x509.X500Name; + +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; +import java.security.interfaces.RSAPrivateCrtKey; +import java.util.HashSet; +import java.util.Set; + +/* + * @test + * @bug 8023546 + * @summary sun/security/mscapi/ShortRSAKey1024.sh fails intermittently + */ +public class SmallPrimeExponentP { + + public static void main(String argv[]) throws Exception { + + String osName = System.getProperty("os.name"); + if (!osName.startsWith("Windows")) { + System.out.println("Not windows"); + return; + } + KeyStore ks = KeyStore.getInstance("Windows-MY"); + ks.load(null, null); + CertAndKeyGen ckg = new CertAndKeyGen("RSA", "SHA1withRSA"); + ckg.setRandom(new SecureRandom()); + boolean see63 = false, see65 = false; + while (!see63 || !see65) { + ckg.generate(1024); + RSAPrivateCrtKey k = (RSAPrivateCrtKey) ckg.getPrivateKey(); + int len = k.getPrimeExponentP().toByteArray().length; + if (len == 63 || len == 65) { + if (len == 63) { + if (see63) continue; + else see63 = true; + } + if (len == 65) { + if (see65) continue; + else see65 = true; + } + System.err.print(len); + ks.setKeyEntry("anything", k, null, new X509Certificate[]{ + ckg.getSelfCertificate(new X500Name("CN=Me"), 1000) + }); + } + System.err.print('.'); + } + ks.store(null, null); + } +} diff --git a/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java b/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java index d6d788a31799bd765b0f38d1730ae1158f30987d..9af80e5bbd3b176f9f07359577f6301c4237cedd 100644 --- a/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java +++ b/test/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java @@ -28,7 +28,7 @@ /* * @test - * @bug 6405536 + * @bug 6405536 8080102 * @summary Verify that all ciphersuites work (incl. ECC using NSS crypto) * @author Andreas Sterbenz * @library .. @@ -49,13 +49,29 @@ public class ClientJSSEServerJSSE extends PKCS11Test { cmdArgs = args; main(new ClientJSSEServerJSSE()); + // now test without SunEC Provider + System.setProperty("testWithoutSunEC", "true"); + main(new ClientJSSEServerJSSE()); + } public void main(Provider p) throws Exception { + String testWithoutSunEC = System.getProperty("testWithoutSunEC"); if (p.getService("KeyFactory", "EC") == null) { System.out.println("Provider does not support EC, skipping"); return; } + + + if (testWithoutSunEC != null) { + Provider sunec = Security.getProvider("SunEC"); + if (sunec == null) { + System.out.println("SunEC provider not present. Skipping test"); + return; + } + Security.removeProvider(sunec.getName()); + } + Providers.setAt(p, 1); CipherTest.main(new JSSEFactory(), cmdArgs); Security.removeProvider(p.getName());