提交 497e78cf 编写于 作者: M mfang

Merge

...@@ -207,7 +207,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \ ...@@ -207,7 +207,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \
LDFLAGS_SUFFIX_windows := -export:winFileHandleOpen -export:handleLseek \ LDFLAGS_SUFFIX_windows := -export:winFileHandleOpen -export:handleLseek \
jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \ jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
shell32.lib delayimp.lib -DELAYLOAD:shell32.dll \ shell32.lib delayimp.lib -DELAYLOAD:shell32.dll \
advapi32.lib, \ advapi32.lib version.lib, \
VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
RC_FLAGS := $(RC_FLAGS) \ RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=java.dll" \ -D "JDK_FNAME=java.dll" \
......
...@@ -26,9 +26,6 @@ ...@@ -26,9 +26,6 @@
package com.sun.jndi.ldap; package com.sun.jndi.ldap;
import javax.naming.*; import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.spi.*;
import java.net.URL;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
...@@ -211,43 +208,52 @@ final public class LdapURL extends Uri { ...@@ -211,43 +208,52 @@ final public class LdapURL extends Uri {
// query begins with a '?' or is null // query begins with a '?' or is null
if (query == null) { if (query == null || query.length() < 2) {
return; return;
} }
int qmark2 = query.indexOf('?', 1); int currentIndex = 1;
int nextQmark;
int endIndex;
if (qmark2 < 0) { // attributes:
attributes = query.substring(1); 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; return;
} else if (qmark2 != 1) {
attributes = query.substring(1, qmark2);
} }
int qmark3 = query.indexOf('?', qmark2 + 1); // scope:
nextQmark = query.indexOf('?', currentIndex);
if (qmark3 < 0) { endIndex = nextQmark == -1 ? query.length() : nextQmark;
scope = query.substring(qmark2 + 1); if (endIndex - currentIndex > 0) {
scope = query.substring(currentIndex, endIndex);
}
currentIndex = endIndex + 1;
if (currentIndex >= query.length()) {
return; return;
} else if (qmark3 != qmark2 + 1) {
scope = query.substring(qmark2 + 1, qmark3);
} }
int qmark4 = query.indexOf('?', qmark3 + 1); // filter:
nextQmark = query.indexOf('?', currentIndex);
if (qmark4 < 0) { endIndex = nextQmark == -1 ? query.length() : nextQmark;
filter = query.substring(qmark3 + 1); if (endIndex - currentIndex > 0) {
} else { filter = query.substring(currentIndex, endIndex);
if (qmark4 != qmark3 + 1) { filter = UrlUtil.decode(filter, "UTF8");
filter = query.substring(qmark3 + 1, qmark4);
}
extensions = query.substring(qmark4 + 1);
if (extensions.length() > 0) {
extensions = UrlUtil.decode(extensions, "UTF8");
} }
currentIndex = endIndex + 1;
if (currentIndex >= query.length()) {
return;
} }
if (filter != null && filter.length() > 0) {
filter = UrlUtil.decode(filter, "UTF8"); // extensions:
if (query.length() - currentIndex > 0) {
extensions = query.substring(currentIndex);
extensions = UrlUtil.decode(extensions, "UTF8");
} }
} }
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -201,7 +201,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { ...@@ -201,7 +201,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
* Gets the day-of-week {@code int} value. * Gets the day-of-week {@code int} value.
* <p> * <p>
* The values are numbered following the ISO-8601 standard, from 1 (Monday) to 7 (Sunday). * 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) * @return the day-of-week, from 1 (Monday) to 7 (Sunday)
*/ */
...@@ -288,7 +288,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { ...@@ -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}. * Gets the value of the specified field from this day-of-week as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -321,7 +321,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { ...@@ -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}. * Gets the value of the specified field from this day-of-week as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -419,7 +419,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { ...@@ -419,7 +419,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
* The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)} * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)}
* passing {@link ChronoField#DAY_OF_WEEK} as the field. * passing {@link ChronoField#DAY_OF_WEEK} as the field.
* Note that this adjusts forwards or backwards within a Monday to Sunday week. * 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, * See {@code TemporalAdjuster} for other adjusters with more control,
* such as {@code next(MONDAY)}. * such as {@code next(MONDAY)}.
* <p> * <p>
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -546,7 +546,7 @@ public final class Duration ...@@ -546,7 +546,7 @@ public final class Duration
* They are returned in the order seconds, nanos. * They are returned in the order seconds, nanos.
* <p> * <p>
* This set can be used in conjunction with {@link #get(TemporalUnit)} * 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 * @return a list containing the seconds and nanos units, not null
*/ */
...@@ -686,8 +686,8 @@ public final class Duration ...@@ -686,8 +686,8 @@ public final class Duration
* <p> * <p>
* This instance is immutable and unaffected by this method call. * 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 amountToAdd the amount to add, 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 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 * @return a {@code Duration} based on this duration with the specified duration added, not null
* @throws UnsupportedTemporalTypeException if the unit is not supported * @throws UnsupportedTemporalTypeException if the unit is not supported
* @throws ArithmeticException if numeric overflow occurs * @throws ArithmeticException if numeric overflow occurs
...@@ -848,8 +848,8 @@ public final class Duration ...@@ -848,8 +848,8 @@ public final class Duration
* <p> * <p>
* This instance is immutable and unaffected by this method call. * 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 amountToSubtract the amount to subtract, 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 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 * @return a {@code Duration} based on this duration with the specified duration subtracted, not null
* @throws ArithmeticException if numeric overflow occurs * @throws ArithmeticException if numeric overflow occurs
*/ */
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -530,7 +530,7 @@ public final class Instant ...@@ -530,7 +530,7 @@ public final class Instant
/** /**
* Gets the value of the specified field from this instant as an {@code int}. * Gets the value of the specified field from this instant as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -571,7 +571,7 @@ public final class Instant ...@@ -571,7 +571,7 @@ public final class Instant
/** /**
* Gets the value of the specified field from this instant as a {@code long}. * Gets the value of the specified field from this instant as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -280,7 +280,7 @@ public final class LocalDate ...@@ -280,7 +280,7 @@ public final class LocalDate
* @param dayOfYear the day-of-year to represent, from 1 to 366 * @param dayOfYear the day-of-year to represent, from 1 to 366
* @return the local date, not null * @return the local date, not null
* @throws DateTimeException if the value of any field is out of range, * @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) { public static LocalDate ofYearDay(int year, int dayOfYear) {
YEAR.checkValidValue(year); YEAR.checkValidValue(year);
...@@ -308,7 +308,7 @@ public final class LocalDate ...@@ -308,7 +308,7 @@ public final class LocalDate
* *
* @param epochDay the Epoch Day to convert, based on the epoch 1970-01-01 * @param epochDay the Epoch Day to convert, based on the epoch 1970-01-01
* @return the local date, not null * @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) { public static LocalDate ofEpochDay(long epochDay) {
long zeroDay = epochDay + DAYS_0000_TO_1970; long zeroDay = epochDay + DAYS_0000_TO_1970;
...@@ -515,7 +515,7 @@ public final class LocalDate ...@@ -515,7 +515,7 @@ public final class LocalDate
/** /**
* Checks if the specified unit is supported. * Checks if the specified unit is supported.
* <p> * <p>
* 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 * If false, then calling the {@link #plus(long, TemporalUnit)} and
* {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * {@link #minus(long, TemporalUnit) minus} methods will throw an exception.
* <p> * <p>
...@@ -592,7 +592,7 @@ public final class LocalDate ...@@ -592,7 +592,7 @@ public final class LocalDate
/** /**
* Gets the value of the specified field from this date as an {@code int}. * Gets the value of the specified field from this date as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -627,7 +627,7 @@ public final class LocalDate ...@@ -627,7 +627,7 @@ public final class LocalDate
/** /**
* Gets the value of the specified field from this date as a {@code long}. * Gets the value of the specified field from this date as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -875,7 +875,9 @@ public final class LocalDate ...@@ -875,7 +875,9 @@ public final class LocalDate
* <p> * <p>
* A simple adjuster might simply set the one of the fields, such as the year field. * 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 more complex adjuster might set the date to the last day of the month.
* A selection of common adjustments is provided in {@link TemporalAdjuster}. * <p>
* 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". * These include finding the "last day of the month" and "next Wednesday".
* Key date-time classes also implement the {@code TemporalAdjuster} interface, * Key date-time classes also implement the {@code TemporalAdjuster} interface,
* such as {@link Month} and {@link java.time.MonthDay MonthDay}. * such as {@link Month} and {@link java.time.MonthDay MonthDay}.
...@@ -885,7 +887,7 @@ public final class LocalDate ...@@ -885,7 +887,7 @@ public final class LocalDate
* For example this code returns a date on the last day of July: * For example this code returns a date on the last day of July:
* <pre> * <pre>
* import static java.time.Month.*; * import static java.time.Month.*;
* import static java.time.temporal.Adjusters.*; * import static java.time.temporal.TemporalAdjusters.*;
* *
* result = localDate.with(JULY).with(lastDayOfMonth()); * result = localDate.with(JULY).with(lastDayOfMonth());
* </pre> * </pre>
...@@ -1041,7 +1043,8 @@ public final class LocalDate ...@@ -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.
* <p>
* If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
...@@ -1059,7 +1062,8 @@ public final class LocalDate ...@@ -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.
* <p>
* If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
...@@ -1077,7 +1081,8 @@ public final class LocalDate ...@@ -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.
* <p>
* If the resulting date is invalid, an exception is thrown. * If the resulting date is invalid, an exception is thrown.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
...@@ -1095,7 +1100,8 @@ public final class LocalDate ...@@ -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.
* <p>
* If the resulting date is invalid, an exception is thrown. * If the resulting date is invalid, an exception is thrown.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
...@@ -1245,7 +1251,7 @@ public final class LocalDate ...@@ -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.
* <p> * <p>
* This method adds the specified amount to the years field in three steps: * This method adds the specified amount to the years field in three steps:
* <ol> * <ol>
...@@ -1273,7 +1279,7 @@ public final class LocalDate ...@@ -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.
* <p> * <p>
* This method adds the specified amount to the months field in three steps: * This method adds the specified amount to the months field in three steps:
* <ol> * <ol>
...@@ -1304,7 +1310,7 @@ public final class LocalDate ...@@ -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.
* <p> * <p>
* This method adds the specified amount in weeks to the days field incrementing * 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 month and year fields as necessary to ensure the result remains valid.
...@@ -1402,11 +1408,11 @@ public final class LocalDate ...@@ -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.
* <p> * <p>
* This method subtracts the specified amount from the years field in three steps: * This method subtracts the specified amount from the years field in three steps:
* <ol> * <ol>
* <li>Subtract the input years to the year field</li> * <li>Subtract the input years from the year field</li>
* <li>Check if the resulting date would be invalid</li> * <li>Check if the resulting date would be invalid</li>
* <li>Adjust the day-of-month to the last valid day if necessary</li> * <li>Adjust the day-of-month to the last valid day if necessary</li>
* </ol> * </ol>
...@@ -1426,11 +1432,11 @@ public final class LocalDate ...@@ -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.
* <p> * <p>
* This method subtracts the specified amount from the months field in three steps: * This method subtracts the specified amount from the months field in three steps:
* <ol> * <ol>
* <li>Subtract the input months to the month-of-year field</li> * <li>Subtract the input months from the month-of-year field</li>
* <li>Check if the resulting date would be invalid</li> * <li>Check if the resulting date would be invalid</li>
* <li>Adjust the day-of-month to the last valid day if necessary</li> * <li>Adjust the day-of-month to the last valid day if necessary</li>
* </ol> * </ol>
...@@ -1450,7 +1456,7 @@ public final class LocalDate ...@@ -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.
* <p> * <p>
* This method subtracts the specified amount in weeks from the days field decrementing * 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 month and year fields as necessary to ensure the result remains valid.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -428,7 +428,7 @@ public final class LocalDateTime ...@@ -428,7 +428,7 @@ public final class LocalDateTime
/** /**
* Obtains an instance of {@code LocalDateTime} from a temporal object. * Obtains an instance of {@code LocalDateTime} from a temporal object.
* <p> * <p>
* 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, * A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code LocalDateTime}. * which this factory converts to an instance of {@code LocalDateTime}.
* <p> * <p>
...@@ -656,7 +656,7 @@ public final class LocalDateTime ...@@ -656,7 +656,7 @@ public final class LocalDateTime
/** /**
* Gets the value of the specified field from this date-time as an {@code int}. * Gets the value of the specified field from this date-time as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -693,7 +693,7 @@ public final class LocalDateTime ...@@ -693,7 +693,7 @@ public final class LocalDateTime
/** /**
* Gets the value of the specified field from this date-time as a {@code long}. * Gets the value of the specified field from this date-time as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -878,7 +878,9 @@ public final class LocalDateTime ...@@ -878,7 +878,9 @@ public final class LocalDateTime
* <p> * <p>
* A simple adjuster might simply set the one of the fields, such as the year field. * 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 more complex adjuster might set the date to the last day of the month.
* A selection of common adjustments is provided in {@link TemporalAdjuster}. * <p>
* 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". * These include finding the "last day of the month" and "next Wednesday".
* Key date-time classes also implement the {@code TemporalAdjuster} interface, * Key date-time classes also implement the {@code TemporalAdjuster} interface,
* such as {@link Month} and {@link java.time.MonthDay MonthDay}. * such as {@link Month} and {@link java.time.MonthDay MonthDay}.
...@@ -888,7 +890,7 @@ public final class LocalDateTime ...@@ -888,7 +890,7 @@ public final class LocalDateTime
* For example this code returns a date on the last day of July: * For example this code returns a date on the last day of July:
* <pre> * <pre>
* import static java.time.Month.*; * import static java.time.Month.*;
* import static java.time.temporal.Adjusters.*; * import static java.time.temporal.TemporalAdjusters.*;
* *
* result = localDateTime.with(JULY).with(lastDayOfMonth()); * result = localDateTime.with(JULY).with(lastDayOfMonth());
* </pre> * </pre>
...@@ -974,6 +976,7 @@ public final class LocalDateTime ...@@ -974,6 +976,7 @@ public final class LocalDateTime
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Returns a copy of this {@code LocalDateTime} with the year altered. * Returns a copy of this {@code LocalDateTime} with the year altered.
* <p>
* The time does not affect the calculation and will be the same in the result. * 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. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month.
* <p> * <p>
...@@ -989,6 +992,7 @@ public final class LocalDateTime ...@@ -989,6 +992,7 @@ public final class LocalDateTime
/** /**
* Returns a copy of this {@code LocalDateTime} with the month-of-year altered. * Returns a copy of this {@code LocalDateTime} with the month-of-year altered.
* <p>
* The time does not affect the calculation and will be the same in the result. * 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. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month.
* <p> * <p>
...@@ -1004,7 +1008,8 @@ public final class LocalDateTime ...@@ -1004,7 +1008,8 @@ public final class LocalDateTime
/** /**
* Returns a copy of this {@code LocalDateTime} with the day-of-month altered. * Returns a copy of this {@code LocalDateTime} with the day-of-month altered.
* If the resulting {@code LocalDateTime} is invalid, an exception is thrown. * <p>
* 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. * The time does not affect the calculation and will be the same in the result.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
...@@ -1020,7 +1025,8 @@ public final class LocalDateTime ...@@ -1020,7 +1025,8 @@ public final class LocalDateTime
/** /**
* Returns a copy of this {@code LocalDateTime} with the day-of-year altered. * Returns a copy of this {@code LocalDateTime} with the day-of-year altered.
* If the resulting {@code LocalDateTime} is invalid, an exception is thrown. * <p>
* If the resulting date-time is invalid, an exception is thrown.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1035,7 +1041,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1049,7 +1055,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1063,7 +1069,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1077,7 +1083,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1109,7 +1115,7 @@ public final class LocalDateTime ...@@ -1109,7 +1115,7 @@ public final class LocalDateTime
* @param unit the unit to truncate to, not null * @param unit the unit to truncate to, not null
* @return a {@code LocalDateTime} based on this date-time with the time truncated, not null * @return a {@code LocalDateTime} based on this date-time with the time truncated, not null
* @throws DateTimeException if unable to truncate * @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) { public LocalDateTime truncatedTo(TemporalUnit unit) {
return with(date, time.truncatedTo(unit)); return with(date, time.truncatedTo(unit));
...@@ -1192,7 +1198,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This method adds the specified amount to the years field in three steps: * This method adds the specified amount to the years field in three steps:
* <ol> * <ol>
...@@ -1217,7 +1223,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This method adds the specified amount to the months field in three steps: * This method adds the specified amount to the months field in three steps:
* <ol> * <ol>
...@@ -1242,7 +1248,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This method adds the specified amount in weeks to the days field incrementing * 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 month and year fields as necessary to ensure the result remains valid.
...@@ -1262,7 +1268,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This method adds the specified amount to the days field incrementing the * This method adds the specified amount to the days field incrementing the
* month and year fields as necessary to ensure the result remains valid. * month and year fields as necessary to ensure the result remains valid.
...@@ -1283,7 +1289,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1296,7 +1302,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1309,7 +1315,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1322,7 +1328,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1391,7 +1397,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This method subtracts the specified amount from the years field in three steps: * This method subtracts the specified amount from the years field in three steps:
* <ol> * <ol>
...@@ -1415,7 +1421,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This method subtracts the specified amount from the months field in three steps: * This method subtracts the specified amount from the months field in three steps:
* <ol> * <ol>
...@@ -1439,7 +1445,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This method subtracts the specified amount in weeks from the days field decrementing * 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 month and year fields as necessary to ensure the result remains valid.
...@@ -1458,9 +1464,9 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* 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. * month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded. * The result is only invalid if the maximum/minimum year is exceeded.
* <p> * <p>
...@@ -1478,7 +1484,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1491,7 +1497,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1504,7 +1510,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1517,7 +1523,7 @@ public final class LocalDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1575,7 +1581,7 @@ public final class LocalDateTime ...@@ -1575,7 +1581,7 @@ public final class LocalDateTime
* what the result of this method will be. * what the result of this method will be.
* <p> * <p>
* The result of this method is obtained by invoking the * 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. * specified query passing {@code this} as the argument.
* *
* @param <R> the type of the result * @param <R> the type of the result
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -93,7 +93,7 @@ import java.time.temporal.ValueRange; ...@@ -93,7 +93,7 @@ import java.time.temporal.ValueRange;
import java.util.Objects; 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}. * such as {@code 10:15:30}.
* <p> * <p>
* {@code LocalTime} is an immutable date-time object that represents a time, * {@code LocalTime} is an immutable date-time object that represents a time,
...@@ -101,7 +101,7 @@ import java.util.Objects; ...@@ -101,7 +101,7 @@ import java.util.Objects;
* Time is represented to nanosecond precision. * Time is represented to nanosecond precision.
* For example, the value "13:45.30.123456789" can be stored in a {@code LocalTime}. * For example, the value "13:45.30.123456789" can be stored in a {@code LocalTime}.
* <p> * <p>
* 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. * 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 * It cannot represent an instant on the time-line without additional information
* such as an offset or time-zone. * such as an offset or time-zone.
...@@ -280,7 +280,7 @@ public final class LocalTime ...@@ -280,7 +280,7 @@ public final class LocalTime
return ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + now.getNano()); return ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + now.getNano());
} }
//------------------------get----------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Obtains an instance of {@code LocalTime} from an hour and minute. * Obtains an instance of {@code LocalTime} from an hour and minute.
* <p> * <p>
...@@ -395,7 +395,7 @@ public final class LocalTime ...@@ -395,7 +395,7 @@ public final class LocalTime
* on extracting the {@link ChronoField#NANO_OF_DAY NANO_OF_DAY} field. * on extracting the {@link ChronoField#NANO_OF_DAY NANO_OF_DAY} field.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the local time, not null * @return the local time, not null
...@@ -524,7 +524,7 @@ public final class LocalTime ...@@ -524,7 +524,7 @@ public final class LocalTime
/** /**
* Checks if the specified unit is supported. * Checks if the specified unit is supported.
* <p> * <p>
* 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 * If false, then calling the {@link #plus(long, TemporalUnit)} and
* {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * {@link #minus(long, TemporalUnit) minus} methods will throw an exception.
* <p> * <p>
...@@ -589,7 +589,7 @@ public final class LocalTime ...@@ -589,7 +589,7 @@ public final class LocalTime
/** /**
* Gets the value of the specified field from this time as an {@code int}. * Gets the value of the specified field from this time as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -624,7 +624,7 @@ public final class LocalTime ...@@ -624,7 +624,7 @@ public final class LocalTime
/** /**
* Gets the value of the specified field from this time as a {@code long}. * Gets the value of the specified field from this time as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -858,7 +858,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -875,7 +875,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -892,7 +892,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -909,7 +909,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -929,7 +929,7 @@ public final class LocalTime ...@@ -929,7 +929,7 @@ public final class LocalTime
/** /**
* Returns a copy of this {@code LocalTime} with the time truncated. * Returns a copy of this {@code LocalTime} with the time truncated.
* <p> * <p>
* 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. * smaller than the specified unit set to zero.
* For example, truncating with the {@link ChronoUnit#MINUTES minutes} unit * For example, truncating with the {@link ChronoUnit#MINUTES minutes} unit
* will set the second-of-minute and nano-of-second field to zero. * will set the second-of-minute and nano-of-second field to zero.
...@@ -1059,7 +1059,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This adds the specified number of hours to this time, returning a new time. * This adds the specified number of hours to this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1078,7 +1078,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This adds the specified number of minutes to this time, returning a new time. * This adds the specified number of minutes to this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1103,7 +1103,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This adds the specified number of seconds to this time, returning a new time. * This adds the specified number of seconds to this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1130,7 +1130,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This adds the specified number of nanoseconds to this time, returning a new time. * This adds the specified number of nanoseconds to this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1208,7 +1208,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This subtracts the specified number of hours from this time, returning a new time. * This subtracts the specified number of hours from this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1223,7 +1223,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This subtracts the specified number of minutes from this time, returning a new time. * This subtracts the specified number of minutes from this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1238,7 +1238,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This subtracts the specified number of seconds from this time, returning a new time. * This subtracts the specified number of seconds from this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1253,7 +1253,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* This subtracts the specified number of nanoseconds from this time, returning a new time. * This subtracts the specified number of nanoseconds from this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1470,7 +1470,7 @@ public final class LocalTime ...@@ -1470,7 +1470,7 @@ public final class LocalTime
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Compares this {@code LocalTime} to another time. * Compares this time to another time.
* <p> * <p>
* The comparison is based on the time-line position of the local times within a day. * 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}. * It is "consistent with equals", as defined by {@link Comparable}.
...@@ -1495,7 +1495,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* The comparison is based on the time-line position of the time within a day. * The comparison is based on the time-line position of the time within a day.
* *
...@@ -1508,7 +1508,7 @@ public final class LocalTime ...@@ -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.
* <p> * <p>
* The comparison is based on the time-line position of the time within a day. * The comparison is based on the time-line position of the time within a day.
* *
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -202,7 +202,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { ...@@ -202,7 +202,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
* chronology, or can be converted to a {@code LocalDate}. * chronology, or can be converted to a {@code LocalDate}.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the month-of-year, not null * @return the month-of-year, not null
...@@ -315,7 +315,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { ...@@ -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}. * Gets the value of the specified field from this month-of-year as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -348,7 +348,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { ...@@ -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}. * Gets the value of the specified field from this month-of-year as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -90,8 +90,8 @@ import java.util.Objects; ...@@ -90,8 +90,8 @@ import java.util.Objects;
* A month-day in the ISO-8601 calendar system, such as {@code --12-03}. * A month-day in the ISO-8601 calendar system, such as {@code --12-03}.
* <p> * <p>
* {@code MonthDay} is an immutable date-time object that represents the combination * {@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 * of a month and day-of-month. Any field that can be derived from a month and day,
* quarter-of-year, can be obtained. * such as quarter-of-year, can be obtained.
* <p> * <p>
* This class does not store or represent a year, time or time-zone. * 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}. * For example, the value "December 3rd" can be stored in a {@code MonthDay}.
...@@ -154,7 +154,7 @@ public final class MonthDay ...@@ -154,7 +154,7 @@ public final class MonthDay
/** /**
* Obtains the current month-day from the system clock in the default time-zone. * Obtains the current month-day from the system clock in the default time-zone.
* <p> * <p>
* 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. * time-zone to obtain the current month-day.
* <p> * <p>
* Using this method will prevent the ability to use an alternate clock for testing * Using this method will prevent the ability to use an alternate clock for testing
...@@ -169,7 +169,7 @@ public final class MonthDay ...@@ -169,7 +169,7 @@ public final class MonthDay
/** /**
* Obtains the current month-day from the system clock in the specified time-zone. * Obtains the current month-day from the system clock in the specified time-zone.
* <p> * <p>
* 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. * Specifying the time-zone avoids dependence on the default time-zone.
* <p> * <p>
* Using this method will prevent the ability to use an alternate clock for testing * Using this method will prevent the ability to use an alternate clock for testing
...@@ -258,7 +258,7 @@ public final class MonthDay ...@@ -258,7 +258,7 @@ public final class MonthDay
* chronology, or can be converted to a {@code LocalDate}. * chronology, or can be converted to a {@code LocalDate}.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the month-day, not null * @return the month-day, not null
...@@ -389,7 +389,7 @@ public final class MonthDay ...@@ -389,7 +389,7 @@ public final class MonthDay
/** /**
* Gets the value of the specified field from this month-day as an {@code int}. * Gets the value of the specified field from this month-day as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -420,7 +420,7 @@ public final class MonthDay ...@@ -420,7 +420,7 @@ public final class MonthDay
/** /**
* Gets the value of the specified field from this month-day as a {@code long}. * Gets the value of the specified field from this month-day as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -501,7 +501,7 @@ public final class MonthDay ...@@ -501,7 +501,7 @@ public final class MonthDay
* This method checks whether this month and day and the input year form * This method checks whether this month and day and the input year form
* a valid date. This can only return false for February 29th. * 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 * @return true if the year is valid for this month-day
* @see Year#isValidMonthDay(MonthDay) * @see Year#isValidMonthDay(MonthDay)
*/ */
...@@ -685,7 +685,7 @@ public final class 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 * @param other the other month-day to compare to, not null
* @return true if this is after the specified month-day * @return true if this is after the specified month-day
...@@ -695,7 +695,7 @@ public final class MonthDay ...@@ -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 * @param other the other month-day to compare to, not null
* @return true if this point is before the specified month-day * @return true if this point is before the specified month-day
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -199,7 +199,7 @@ public final class OffsetDateTime ...@@ -199,7 +199,7 @@ public final class OffsetDateTime
/** /**
* Obtains the current date-time from the system clock in the default time-zone. * Obtains the current date-time from the system clock in the default time-zone.
* <p> * <p>
* 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. * time-zone to obtain the current date-time.
* The offset will be calculated from the time-zone in the clock. * The offset will be calculated from the time-zone in the clock.
* <p> * <p>
...@@ -215,7 +215,7 @@ public final class OffsetDateTime ...@@ -215,7 +215,7 @@ public final class OffsetDateTime
/** /**
* Obtains the current date-time from the system clock in the specified time-zone. * Obtains the current date-time from the system clock in the specified time-zone.
* <p> * <p>
* 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. * Specifying the time-zone avoids dependence on the default time-zone.
* The offset will be calculated from the specified time-zone. * The offset will be calculated from the specified time-zone.
* <p> * <p>
...@@ -345,7 +345,7 @@ public final class OffsetDateTime ...@@ -345,7 +345,7 @@ public final class OffsetDateTime
* those fields that are equivalent to the relevant objects. * those fields that are equivalent to the relevant objects.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the offset date-time, not null * @return the offset date-time, not null
...@@ -567,7 +567,7 @@ public final class OffsetDateTime ...@@ -567,7 +567,7 @@ public final class OffsetDateTime
/** /**
* Gets the value of the specified field from this date-time as an {@code int}. * Gets the value of the specified field from this date-time as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -609,7 +609,7 @@ public final class OffsetDateTime ...@@ -609,7 +609,7 @@ public final class OffsetDateTime
/** /**
* Gets the value of the specified field from this date-time as a {@code long}. * Gets the value of the specified field from this date-time as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -704,7 +704,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This returns a {@code LocalDateTime} with the same year, month, day and time * This returns a {@code LocalDateTime} with the same year, month, day and time
* as this date-time. * as this date-time.
...@@ -796,10 +796,10 @@ public final class OffsetDateTime ...@@ -796,10 +796,10 @@ public final class OffsetDateTime
/** /**
* Gets the day-of-week field, which is an enum {@code DayOfWeek}. * Gets the day-of-week field, which is an enum {@code DayOfWeek}.
* <p> * <p>
* 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. * This avoids confusion as to what {@code int} values mean.
* If you need access to the primitive {@code int} value then the enum * 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}.
* <p> * <p>
* Additional information can be obtained from the {@code DayOfWeek}. * Additional information can be obtained from the {@code DayOfWeek}.
* This includes textual names of the values. * This includes textual names of the values.
...@@ -869,7 +869,8 @@ public final class OffsetDateTime ...@@ -869,7 +869,8 @@ public final class OffsetDateTime
* <p> * <p>
* A simple adjuster might simply set the one of the fields, such as the year field. * 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 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". * These include finding the "last day of the month" and "next Wednesday".
* Key date-time classes also implement the {@code TemporalAdjuster} interface, * Key date-time classes also implement the {@code TemporalAdjuster} interface,
* such as {@link Month} and {@link java.time.MonthDay MonthDay}. * such as {@link Month} and {@link java.time.MonthDay MonthDay}.
...@@ -879,7 +880,7 @@ public final class OffsetDateTime ...@@ -879,7 +880,7 @@ public final class OffsetDateTime
* For example this code returns a date on the last day of July: * For example this code returns a date on the last day of July:
* <pre> * <pre>
* import static java.time.Month.*; * import static java.time.Month.*;
* import static java.time.temporal.Adjusters.*; * import static java.time.temporal.TemporalAdjusters.*;
* *
* result = offsetDateTime.with(JULY).with(lastDayOfMonth()); * result = offsetDateTime.with(JULY).with(lastDayOfMonth());
* </pre> * </pre>
...@@ -921,7 +922,7 @@ public final class OffsetDateTime ...@@ -921,7 +922,7 @@ public final class OffsetDateTime
/** /**
* Returns a copy of this date-time with the specified field set to a new value. * Returns a copy of this date-time with the specified field set to a new value.
* <p> * <p>
* 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. * for the specified field changed.
* This can be used to change any supported field, such as the year, month or day-of-month. * 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 * 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 ...@@ -980,7 +981,8 @@ public final class OffsetDateTime
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Returns a copy of this {@code OffsetDateTime} with the year altered. * 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. * <p>
* 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. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
...@@ -995,7 +997,8 @@ public final class OffsetDateTime ...@@ -995,7 +997,8 @@ public final class OffsetDateTime
/** /**
* Returns a copy of this {@code OffsetDateTime} with the month-of-year altered. * 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. * <p>
* 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. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
...@@ -1010,8 +1013,9 @@ public final class OffsetDateTime ...@@ -1010,8 +1013,9 @@ public final class OffsetDateTime
/** /**
* Returns a copy of this {@code OffsetDateTime} with the day-of-month altered. * Returns a copy of this {@code OffsetDateTime} with the day-of-month altered.
* <p>
* If the resulting {@code OffsetDateTime} is invalid, an exception is thrown. * 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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1026,6 +1030,8 @@ public final class OffsetDateTime ...@@ -1026,6 +1030,8 @@ public final class OffsetDateTime
/** /**
* Returns a copy of this {@code OffsetDateTime} with the day-of-year altered. * Returns a copy of this {@code OffsetDateTime} with the day-of-year altered.
* <p>
* 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. * If the resulting {@code OffsetDateTime} is invalid, an exception is thrown.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
...@@ -1041,9 +1047,9 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* 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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1056,9 +1062,9 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* 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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1071,9 +1077,9 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* 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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1086,15 +1092,15 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* 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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * 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 * @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 * @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) { public OffsetDateTime withNano(int nanoOfSecond) {
return with(dateTime.withNano(nanoOfSecond), offset); return with(dateTime.withNano(nanoOfSecond), offset);
...@@ -1188,7 +1194,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This method adds the specified amount to the years field in three steps: * This method adds the specified amount to the years field in three steps:
* <ol> * <ol>
...@@ -1212,7 +1218,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This method adds the specified amount to the months field in three steps: * This method adds the specified amount to the months field in three steps:
* <ol> * <ol>
...@@ -1236,13 +1242,13 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This method adds the specified amount in weeks to the days field incrementing * 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 month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded. * The result is only invalid if the maximum/minimum year is exceeded.
* <p> * <p>
* 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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1255,13 +1261,13 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This method adds the specified amount to the days field incrementing the * This method adds the specified amount to the days field incrementing the
* month and year fields as necessary to ensure the result remains valid. * month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded. * The result is only invalid if the maximum/minimum year is exceeded.
* <p> * <p>
* 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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1274,7 +1280,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1287,7 +1293,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1300,7 +1306,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1313,7 +1319,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1377,11 +1383,11 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This method subtracts the specified amount from the years field in three steps: * This method subtracts the specified amount from the years field in three steps:
* <ol> * <ol>
* <li>Subtract the input years to the year field</li> * <li>Subtract the input years from the year field</li>
* <li>Check if the resulting date would be invalid</li> * <li>Check if the resulting date would be invalid</li>
* <li>Adjust the day-of-month to the last valid day if necessary</li> * <li>Adjust the day-of-month to the last valid day if necessary</li>
* </ol> * </ol>
...@@ -1401,11 +1407,11 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This method subtracts the specified amount from the months field in three steps: * This method subtracts the specified amount from the months field in three steps:
* <ol> * <ol>
* <li>Subtract the input months to the month-of-year field</li> * <li>Subtract the input months from the month-of-year field</li>
* <li>Check if the resulting date would be invalid</li> * <li>Check if the resulting date would be invalid</li>
* <li>Adjust the day-of-month to the last valid day if necessary</li> * <li>Adjust the day-of-month to the last valid day if necessary</li>
* </ol> * </ol>
...@@ -1425,13 +1431,13 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This method subtracts the specified amount in weeks from the days field decrementing * 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 month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded. * The result is only invalid if the maximum/minimum year is exceeded.
* <p> * <p>
* 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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1444,13 +1450,13 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* 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. * month and year fields as necessary to ensure the result remains valid.
* The result is only invalid if the maximum/minimum year is exceeded. * The result is only invalid if the maximum/minimum year is exceeded.
* <p> * <p>
* 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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1463,7 +1469,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1476,7 +1482,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1489,7 +1495,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1502,7 +1508,7 @@ public final class OffsetDateTime ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1599,7 +1605,7 @@ public final class OffsetDateTime ...@@ -1599,7 +1605,7 @@ public final class OffsetDateTime
* objects in terms of a single {@code TemporalUnit}. * objects in terms of a single {@code TemporalUnit}.
* The start and end points are {@code this} and the specified date-time. * 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. * 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)}. * using {@code startDateTime.until(endDateTime, DAYS)}.
* <p> * <p>
* The {@code Temporal} passed to this method is converted to a * The {@code Temporal} passed to this method is converted to a
...@@ -1609,7 +1615,7 @@ public final class OffsetDateTime ...@@ -1609,7 +1615,7 @@ public final class OffsetDateTime
* <p> * <p>
* The calculation returns a whole number, representing the number of * The calculation returns a whole number, representing the number of
* complete units between the two date-times. * 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. * will only be one month as it is one minute short of two months.
* <p> * <p>
* There are two equivalent ways of using this method. * There are two equivalent ways of using this method.
...@@ -1770,7 +1776,7 @@ public final class OffsetDateTime ...@@ -1770,7 +1776,7 @@ public final class OffsetDateTime
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Compares this {@code OffsetDateTime} to another date-time. * Compares this date-time to another date-time.
* <p> * <p>
* The comparison is based on the instant then on the local 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}. * It is "consistent with equals", as defined by {@link Comparable}.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -153,14 +153,14 @@ public final class OffsetTime ...@@ -153,14 +153,14 @@ public final class OffsetTime
/** /**
* Obtains the current time from the system clock in the default time-zone. * Obtains the current time from the system clock in the default time-zone.
* <p> * <p>
* 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. * time-zone to obtain the current time.
* The offset will be calculated from the time-zone in the clock. * The offset will be calculated from the time-zone in the clock.
* <p> * <p>
* Using this method will prevent the ability to use an alternate clock for testing * Using this method will prevent the ability to use an alternate clock for testing
* because the clock is hard-coded. * 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() { public static OffsetTime now() {
return now(Clock.systemDefaultZone()); return now(Clock.systemDefaultZone());
...@@ -169,7 +169,7 @@ public final class OffsetTime ...@@ -169,7 +169,7 @@ public final class OffsetTime
/** /**
* Obtains the current time from the system clock in the specified time-zone. * Obtains the current time from the system clock in the specified time-zone.
* <p> * <p>
* 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. * Specifying the time-zone avoids dependence on the default time-zone.
* The offset will be calculated from the specified time-zone. * The offset will be calculated from the specified time-zone.
* <p> * <p>
...@@ -277,7 +277,7 @@ public final class OffsetTime ...@@ -277,7 +277,7 @@ public final class OffsetTime
* those fields that are equivalent to the relevant objects. * those fields that are equivalent to the relevant objects.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the offset time, not null * @return the offset time, not null
...@@ -402,7 +402,7 @@ public final class OffsetTime ...@@ -402,7 +402,7 @@ public final class OffsetTime
/** /**
* Checks if the specified unit is supported. * Checks if the specified unit is supported.
* <p> * <p>
* 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 * If false, then calling the {@link #plus(long, TemporalUnit)} and
* {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * {@link #minus(long, TemporalUnit) minus} methods will throw an exception.
* <p> * <p>
...@@ -473,7 +473,7 @@ public final class OffsetTime ...@@ -473,7 +473,7 @@ public final class OffsetTime
/** /**
* Gets the value of the specified field from this time as an {@code int}. * Gets the value of the specified field from this time as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -505,7 +505,7 @@ public final class OffsetTime ...@@ -505,7 +505,7 @@ public final class OffsetTime
/** /**
* Gets the value of the specified field from this time as a {@code long}. * Gets the value of the specified field from this time as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -575,7 +575,7 @@ public final class OffsetTime ...@@ -575,7 +575,7 @@ public final class OffsetTime
* <p> * <p>
* This method returns an object with the specified {@code ZoneOffset} and a {@code LocalTime} * This method returns an object with the specified {@code ZoneOffset} and a {@code LocalTime}
* adjusted by the difference between the two offsets. * 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. * 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 * 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}. * {@code +03:00}, then this method will return {@code 11:30+03:00}.
...@@ -737,7 +737,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* The offset does not affect the calculation and will be the same in the result. * The offset does not affect the calculation and will be the same in the result.
* <p> * <p>
...@@ -752,7 +752,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* The offset does not affect the calculation and will be the same in the result. * The offset does not affect the calculation and will be the same in the result.
* <p> * <p>
...@@ -767,7 +767,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* The offset does not affect the calculation and will be the same in the result. * The offset does not affect the calculation and will be the same in the result.
* <p> * <p>
...@@ -782,7 +782,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* The offset does not affect the calculation and will be the same in the result. * The offset does not affect the calculation and will be the same in the result.
* <p> * <p>
...@@ -884,7 +884,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* This adds the specified number of hours to this time, returning a new time. * This adds the specified number of hours to this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -899,7 +899,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* This adds the specified number of minutes to this time, returning a new time. * This adds the specified number of minutes to this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -914,7 +914,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* This adds the specified number of seconds to this time, returning a new time. * This adds the specified number of seconds to this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -929,7 +929,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* This adds the specified number of nanoseconds to this time, returning a new time. * This adds the specified number of nanoseconds to this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -995,7 +995,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* This subtracts the specified number of hours from this time, returning a new time. * This subtracts the specified number of hours from this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1010,7 +1010,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* This subtracts the specified number of minutes from this time, returning a new time. * This subtracts the specified number of minutes from this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1025,7 +1025,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* This subtracts the specified number of seconds from this time, returning a new time. * This subtracts the specified number of seconds from this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1040,7 +1040,7 @@ public final class OffsetTime ...@@ -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.
* <p> * <p>
* This subtracts the specified number of nanoseconds from this time, returning a new time. * This subtracts the specified number of nanoseconds from this time, returning a new time.
* The calculation wraps around midnight. * The calculation wraps around midnight.
...@@ -1130,7 +1130,7 @@ public final class OffsetTime ...@@ -1130,7 +1130,7 @@ public final class OffsetTime
* objects in terms of a single {@code TemporalUnit}. * objects in terms of a single {@code TemporalUnit}.
* The start and end points are {@code this} and the specified time. * The start and end points are {@code this} and the specified time.
* The result will be negative if the end is before the start. * 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)}. * using {@code startTime.until(endTime, HOURS)}.
* <p> * <p>
* The {@code Temporal} passed to this method is converted to a * The {@code Temporal} passed to this method is converted to a
...@@ -1140,7 +1140,7 @@ public final class OffsetTime ...@@ -1140,7 +1140,7 @@ public final class OffsetTime
* <p> * <p>
* The calculation returns a whole number, representing the number of * The calculation returns a whole number, representing the number of
* complete units between the two times. * 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. * be one hour as it is one minute short of two hours.
* <p> * <p>
* There are two equivalent ways of using this method. * There are two equivalent ways of using this method.
...@@ -1165,7 +1165,7 @@ public final class OffsetTime ...@@ -1165,7 +1165,7 @@ public final class OffsetTime
* <p> * <p>
* This instance is immutable and unaffected by this method call. * 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 * @param unit the unit to measure the amount in, not null
* @return the amount of time between this time and the end time * @return the amount of time between this time and the end time
* @throws DateTimeException if the amount cannot be calculated, or the end * @throws DateTimeException if the amount cannot be calculated, or the end
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -616,7 +616,7 @@ public final class Period ...@@ -616,7 +616,7 @@ public final class Period
* <p> * <p>
* This instance is immutable and unaffected by this method call. * 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 * @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 * @throws DateTimeException if the specified amount has a non-ISO chronology or
* contains an invalid unit * contains an invalid unit
...@@ -705,7 +705,7 @@ public final class Period ...@@ -705,7 +705,7 @@ public final class Period
* <p> * <p>
* This instance is immutable and unaffected by this method call. * 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 * @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 * @throws DateTimeException if the specified amount has a non-ISO chronology or
* contains an invalid unit * contains an invalid unit
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -164,7 +164,7 @@ public final class Year ...@@ -164,7 +164,7 @@ public final class Year
/** /**
* Obtains the current year from the system clock in the default time-zone. * Obtains the current year from the system clock in the default time-zone.
* <p> * <p>
* 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. * time-zone to obtain the current year.
* <p> * <p>
* Using this method will prevent the ability to use an alternate clock for testing * Using this method will prevent the ability to use an alternate clock for testing
...@@ -179,7 +179,7 @@ public final class Year ...@@ -179,7 +179,7 @@ public final class Year
/** /**
* Obtains the current year from the system clock in the specified time-zone. * Obtains the current year from the system clock in the specified time-zone.
* <p> * <p>
* 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. * Specifying the time-zone avoids dependence on the default time-zone.
* <p> * <p>
* Using this method will prevent the ability to use an alternate clock for testing * Using this method will prevent the ability to use an alternate clock for testing
...@@ -240,7 +240,7 @@ public final class Year ...@@ -240,7 +240,7 @@ public final class Year
* chronology, or can be converted to a {@code LocalDate}. * chronology, or can be converted to a {@code LocalDate}.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the year, not null * @return the year, not null
...@@ -375,7 +375,7 @@ public final class Year ...@@ -375,7 +375,7 @@ public final class Year
/** /**
* Checks if the specified unit is supported. * Checks if the specified unit is supported.
* <p> * <p>
* 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 * If false, then calling the {@link #plus(long, TemporalUnit)} and
* {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * {@link #minus(long, TemporalUnit) minus} methods will throw an exception.
* <p> * <p>
...@@ -441,7 +441,7 @@ public final class Year ...@@ -441,7 +441,7 @@ public final class Year
/** /**
* Gets the value of the specified field from this year as an {@code int}. * Gets the value of the specified field from this year as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -472,7 +472,7 @@ public final class Year ...@@ -472,7 +472,7 @@ public final class Year
/** /**
* Gets the value of the specified field from this year as a {@code long}. * Gets the value of the specified field from this year as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -720,13 +720,13 @@ public final class Year ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
* @param yearsToAdd the years to add, may be negative * @param yearsToAdd the years to add, may be negative
* @return a {@code Year} based on this year with the period added, not null * @return a {@code Year} based on this year with the years added, not null
* @throws DateTimeException if the result exceeds the supported year range * @throws DateTimeException if the result exceeds the supported range
*/ */
public Year plusYears(long yearsToAdd) { public Year plusYears(long yearsToAdd) {
if (yearsToAdd == 0) { if (yearsToAdd == 0) {
...@@ -786,13 +786,13 @@ public final class Year ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
* @param yearsToSubtract the years to subtract, may be negative * @param yearsToSubtract the years to subtract, may be negative
* @return a {@code Year} based on this year with the period subtracted, not null * @return a {@code Year} based on this year with the year subtracted, not null
* @throws DateTimeException if the result exceeds the supported year range * @throws DateTimeException if the result exceeds the supported range
*/ */
public Year minusYears(long yearsToSubtract) { public Year minusYears(long yearsToSubtract) {
return (yearsToSubtract == Long.MIN_VALUE ? plusYears(Long.MAX_VALUE).plusYears(1) : plusYears(-yearsToSubtract)); return (yearsToSubtract == Long.MIN_VALUE ? plusYears(Long.MAX_VALUE).plusYears(1) : plusYears(-yearsToSubtract));
...@@ -871,12 +871,12 @@ public final class Year ...@@ -871,12 +871,12 @@ public final class Year
* The result will be negative if the end is before the start. * The result will be negative if the end is before the start.
* The {@code Temporal} passed to this method is converted to a * The {@code Temporal} passed to this method is converted to a
* {@code Year} using {@link #from(TemporalAccessor)}. * {@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)}. * using {@code startYear.until(endYear, DECADES)}.
* <p> * <p>
* The calculation returns a whole number, representing the number of * The calculation returns a whole number, representing the number of
* complete units between the two years. * 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. * will only be one decade as it is one year short of two decades.
* <p> * <p>
* There are two equivalent ways of using this method. * There are two equivalent ways of using this method.
...@@ -948,7 +948,7 @@ public final class Year ...@@ -948,7 +948,7 @@ public final class Year
* <p> * <p>
* The day-of-year value 366 is only valid in a leap 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 * @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 * @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 * to 366 and this is not a leap year
...@@ -1025,7 +1025,7 @@ public final class 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 * @param other the other year to compare to, not null
* @return true if this is after the specified year * @return true if this is after the specified year
...@@ -1035,7 +1035,7 @@ public final class 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 * @param other the other year to compare to, not null
* @return true if this point is before the specified year * @return true if this point is before the specified year
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -157,9 +157,8 @@ public final class YearMonth ...@@ -157,9 +157,8 @@ public final class YearMonth
/** /**
* Obtains the current year-month from the system clock in the default time-zone. * Obtains the current year-month from the system clock in the default time-zone.
* <p> * <p>
* 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. * time-zone to obtain the current year-month.
* The zone and offset will be set based on the time-zone in the clock.
* <p> * <p>
* Using this method will prevent the ability to use an alternate clock for testing * Using this method will prevent the ability to use an alternate clock for testing
* because the clock is hard-coded. * because the clock is hard-coded.
...@@ -173,7 +172,7 @@ public final class YearMonth ...@@ -173,7 +172,7 @@ public final class YearMonth
/** /**
* Obtains the current year-month from the system clock in the specified time-zone. * Obtains the current year-month from the system clock in the specified time-zone.
* <p> * <p>
* 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. * Specifying the time-zone avoids dependence on the default time-zone.
* <p> * <p>
* Using this method will prevent the ability to use an alternate clock for testing * Using this method will prevent the ability to use an alternate clock for testing
...@@ -243,7 +242,7 @@ public final class YearMonth ...@@ -243,7 +242,7 @@ public final class YearMonth
* chronology, or can be converted to a {@code LocalDate}. * chronology, or can be converted to a {@code LocalDate}.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the year-month, not null * @return the year-month, not null
...@@ -363,7 +362,7 @@ public final class YearMonth ...@@ -363,7 +362,7 @@ public final class YearMonth
/** /**
* Checks if the specified unit is supported. * Checks if the specified unit is supported.
* <p> * <p>
* 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 * If false, then calling the {@link #plus(long, TemporalUnit)} and
* {@link #minus(long, TemporalUnit) minus} methods will throw an exception. * {@link #minus(long, TemporalUnit) minus} methods will throw an exception.
* <p> * <p>
...@@ -430,7 +429,7 @@ public final class YearMonth ...@@ -430,7 +429,7 @@ public final class YearMonth
/** /**
* Gets the value of the specified field from this year-month as an {@code int}. * Gets the value of the specified field from this year-month as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -462,7 +461,7 @@ public final class YearMonth ...@@ -462,7 +461,7 @@ public final class YearMonth
/** /**
* Gets the value of the specified field from this year-month as a {@code long}. * Gets the value of the specified field from this year-month as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -819,7 +818,7 @@ public final class YearMonth ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -836,7 +835,7 @@ public final class YearMonth ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -906,7 +905,7 @@ public final class YearMonth ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -919,7 +918,7 @@ public final class YearMonth ...@@ -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.
* <p> * <p>
* This instance is immutable and unaffected by this method call. * This instance is immutable and unaffected by this method call.
* *
...@@ -1004,12 +1003,12 @@ public final class YearMonth ...@@ -1004,12 +1003,12 @@ public final class YearMonth
* The result will be negative if the end is before the start. * The result will be negative if the end is before the start.
* The {@code Temporal} passed to this method is converted to a * The {@code Temporal} passed to this method is converted to a
* {@code YearMonth} using {@link #from(TemporalAccessor)}. * {@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)}. * using {@code startYearMonth.until(endYearMonth, YEARS)}.
* <p> * <p>
* The calculation returns a whole number, representing the number of * The calculation returns a whole number, representing the number of
* complete units between the two year-months. * 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. * will only be one decade as it is one month short of two decades.
* <p> * <p>
* There are two equivalent ways of using this method. * There are two equivalent ways of using this method.
...@@ -1134,7 +1133,7 @@ public final class YearMonth ...@@ -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 * @param other the other year-month to compare to, not null
* @return true if this is after the specified year-month * @return true if this is after the specified year-month
...@@ -1144,7 +1143,7 @@ public final class YearMonth ...@@ -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 * @param other the other year-month to compare to, not null
* @return true if this point is before the specified year-month * @return true if this point is before the specified year-month
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -453,7 +453,7 @@ public abstract class ZoneId implements Serializable { ...@@ -453,7 +453,7 @@ public abstract class ZoneId implements Serializable {
* zones over offset-based zones using {@link TemporalQueries#zone()}. * zones over offset-based zones using {@link TemporalQueries#zone()}.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the zone ID, not null * @return the zone ID, not null
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -89,7 +89,7 @@ import java.util.concurrent.ConcurrentMap; ...@@ -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 from Greenwich/UTC, such as {@code +02:00}.
* <p> * <p>
* 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. * This is usually a fixed number of hours and minutes.
* <p> * <p>
* Different parts of the world have different time-zone offsets. * Different parts of the world have different time-zone offsets.
...@@ -334,7 +334,7 @@ public final class ZoneOffset ...@@ -334,7 +334,7 @@ public final class ZoneOffset
* on extracting the {@link ChronoField#OFFSET_SECONDS OFFSET_SECONDS} field. * on extracting the {@link ChronoField#OFFSET_SECONDS OFFSET_SECONDS} field.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the zone-offset, not null * @return the zone-offset, not null
...@@ -564,7 +564,7 @@ public final class ZoneOffset ...@@ -564,7 +564,7 @@ public final class ZoneOffset
/** /**
* Gets the value of the specified field from this offset as an {@code int}. * Gets the value of the specified field from this offset as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -599,7 +599,7 @@ public final class ZoneOffset ...@@ -599,7 +599,7 @@ public final class ZoneOffset
/** /**
* Gets the value of the specified field from this offset as a {@code long}. * Gets the value of the specified field from this offset as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -419,7 +419,7 @@ public final class ZonedDateTime ...@@ -419,7 +419,7 @@ public final class ZonedDateTime
* <p> * <p>
* Converting an instant to a zoned date-time is simple as there is only one valid * 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, * 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.
* <p> * <p>
* If the {@code ZoneId} to be used is a {@code ZoneOffset}, this method is equivalent * If the {@code ZoneId} to be used is a {@code ZoneOffset}, this method is equivalent
* to {@link #of(LocalDateTime, ZoneId)}. * to {@link #of(LocalDateTime, ZoneId)}.
...@@ -539,7 +539,7 @@ public final class ZonedDateTime ...@@ -539,7 +539,7 @@ public final class ZonedDateTime
* those fields that are equivalent to the relevant objects. * those fields that are equivalent to the relevant objects.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal object to convert, not null
* @return the zoned date-time, not null * @return the zoned date-time, not null
...@@ -783,7 +783,7 @@ public final class ZonedDateTime ...@@ -783,7 +783,7 @@ public final class ZonedDateTime
/** /**
* Gets the value of the specified field from this date-time as an {@code int}. * Gets the value of the specified field from this date-time as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -825,7 +825,7 @@ public final class ZonedDateTime ...@@ -825,7 +825,7 @@ public final class ZonedDateTime
/** /**
* Gets the value of the specified field from this date-time as a {@code long}. * Gets the value of the specified field from this date-time as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
...@@ -1183,7 +1183,8 @@ public final class ZonedDateTime ...@@ -1183,7 +1183,8 @@ public final class ZonedDateTime
* <p> * <p>
* A simple adjuster might simply set the one of the fields, such as the year field. * 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 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". * These include finding the "last day of the month" and "next Wednesday".
* Key date-time classes also implement the {@code TemporalAdjuster} interface, * Key date-time classes also implement the {@code TemporalAdjuster} interface,
* such as {@link Month} and {@link java.time.MonthDay MonthDay}. * such as {@link Month} and {@link java.time.MonthDay MonthDay}.
...@@ -1193,7 +1194,7 @@ public final class ZonedDateTime ...@@ -1193,7 +1194,7 @@ public final class ZonedDateTime
* For example this code returns a date on the last day of July: * For example this code returns a date on the last day of July:
* <pre> * <pre>
* import static java.time.Month.*; * import static java.time.Month.*;
* import static java.time.temporal.Adjusters.*; * import static java.time.temporal.TemporalAdjusters.*;
* *
* result = zonedDateTime.with(JULY).with(lastDayOfMonth()); * result = zonedDateTime.with(JULY).with(lastDayOfMonth());
* </pre> * </pre>
...@@ -1314,7 +1315,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#withYear(int) changing the year} of the local date-time. * {@link LocalDateTime#withYear(int) changing the year} of the local date-time.
...@@ -1336,7 +1337,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#withMonth(int) changing the month} of the local date-time. * {@link LocalDateTime#withMonth(int) changing the month} of the local date-time.
...@@ -1358,7 +1359,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#withDayOfMonth(int) changing the day-of-month} of the local date-time. * {@link LocalDateTime#withDayOfMonth(int) changing the day-of-month} of the local date-time.
...@@ -1405,7 +1406,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@linkplain LocalDateTime#withHour(int) changing the time} of the local date-time. * {@linkplain LocalDateTime#withHour(int) changing the time} of the local date-time.
...@@ -1427,7 +1428,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@linkplain LocalDateTime#withMinute(int) changing the time} of the local date-time. * {@linkplain LocalDateTime#withMinute(int) changing the time} of the local date-time.
...@@ -1449,7 +1450,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@linkplain LocalDateTime#withSecond(int) changing the time} of the local date-time. * {@linkplain LocalDateTime#withSecond(int) changing the time} of the local date-time.
...@@ -1471,7 +1472,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@linkplain LocalDateTime#withNano(int) changing the time} of the local date-time. * {@linkplain LocalDateTime#withNano(int) changing the time} of the local date-time.
...@@ -1507,7 +1508,7 @@ public final class ZonedDateTime ...@@ -1507,7 +1508,7 @@ public final class ZonedDateTime
* {@link ChronoUnit#DAYS DAYS}. Other units throw an exception. * {@link ChronoUnit#DAYS DAYS}. Other units throw an exception.
* <p> * <p>
* This operates on the local time-line, * 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 * the underlying local date-time. This is then converted back to a
* {@code ZonedDateTime}, using the zone ID to obtain the offset. * {@code ZonedDateTime}, using the zone ID to obtain the offset.
* <p> * <p>
...@@ -1608,7 +1609,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#plusYears(long) adding years} to the local date-time. * {@link LocalDateTime#plusYears(long) adding years} to the local date-time.
...@@ -1630,7 +1631,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#plusMonths(long) adding months} to the local date-time. * {@link LocalDateTime#plusMonths(long) adding months} to the local date-time.
...@@ -1652,7 +1653,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#plusWeeks(long) adding weeks} to the local date-time. * {@link LocalDateTime#plusWeeks(long) adding weeks} to the local date-time.
...@@ -1674,7 +1675,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#plusDays(long) adding days} to the local date-time. * {@link LocalDateTime#plusDays(long) adding days} to the local date-time.
...@@ -1697,7 +1698,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the instant time-line, such that adding one hour will * This operates on the instant time-line, such that adding one hour will
* always be a duration of one hour later. * always be a duration of one hour later.
...@@ -1725,7 +1726,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the instant time-line, such that adding one minute will * This operates on the instant time-line, such that adding one minute will
* always be a duration of one minute later. * always be a duration of one minute later.
...@@ -1743,7 +1744,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the instant time-line, such that adding one second will * This operates on the instant time-line, such that adding one second will
* always be a duration of one second later. * always be a duration of one second later.
...@@ -1761,7 +1762,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the instant time-line, such that adding one nano will * This operates on the instant time-line, such that adding one nano will
* always be a duration of one nano later. * always be a duration of one nano later.
...@@ -1849,7 +1850,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#minusYears(long) subtracting years} to the local date-time. * {@link LocalDateTime#minusYears(long) subtracting years} to the local date-time.
...@@ -1871,7 +1872,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#minusMonths(long) subtracting months} to the local date-time. * {@link LocalDateTime#minusMonths(long) subtracting months} to the local date-time.
...@@ -1893,7 +1894,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#minusWeeks(long) subtracting weeks} to the local date-time. * {@link LocalDateTime#minusWeeks(long) subtracting weeks} to the local date-time.
...@@ -1915,7 +1916,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the local time-line, * This operates on the local time-line,
* {@link LocalDateTime#minusDays(long) subtracting days} to the local date-time. * {@link LocalDateTime#minusDays(long) subtracting days} to the local date-time.
...@@ -1938,7 +1939,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the instant time-line, such that subtracting one hour will * This operates on the instant time-line, such that subtracting one hour will
* always be a duration of one hour earlier. * always be a duration of one hour earlier.
...@@ -1966,7 +1967,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the instant time-line, such that subtracting one minute will * This operates on the instant time-line, such that subtracting one minute will
* always be a duration of one minute earlier. * always be a duration of one minute earlier.
...@@ -1984,7 +1985,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the instant time-line, such that subtracting one second will * This operates on the instant time-line, such that subtracting one second will
* always be a duration of one second earlier. * always be a duration of one second earlier.
...@@ -2002,7 +2003,7 @@ public final class ZonedDateTime ...@@ -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.
* <p> * <p>
* This operates on the instant time-line, such that subtracting one nano will * This operates on the instant time-line, such that subtracting one nano will
* always be a duration of one nano earlier. * always be a duration of one nano earlier.
...@@ -2029,7 +2030,7 @@ public final class ZonedDateTime ...@@ -2029,7 +2030,7 @@ public final class ZonedDateTime
* what the result of this method will be. * what the result of this method will be.
* <p> * <p>
* The result of this method is obtained by invoking the * 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. * specified query passing {@code this} as the argument.
* *
* @param <R> the type of the result * @param <R> the type of the result
...@@ -2054,7 +2055,7 @@ public final class ZonedDateTime ...@@ -2054,7 +2055,7 @@ public final class ZonedDateTime
* objects in terms of a single {@code TemporalUnit}. * objects in terms of a single {@code TemporalUnit}.
* The start and end points are {@code this} and the specified date-time. * 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. * 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)}. * using {@code startDateTime.until(endDateTime, DAYS)}.
* <p> * <p>
* The {@code Temporal} passed to this method is converted to a * The {@code Temporal} passed to this method is converted to a
...@@ -2064,7 +2065,7 @@ public final class ZonedDateTime ...@@ -2064,7 +2065,7 @@ public final class ZonedDateTime
* <p> * <p>
* The calculation returns a whole number, representing the number of * The calculation returns a whole number, representing the number of
* complete units between the two date-times. * 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. * will only be one month as it is one minute short of two months.
* <p> * <p>
* There are two equivalent ways of using this method. * There are two equivalent ways of using this method.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -249,8 +249,8 @@ public interface ChronoLocalDate ...@@ -249,8 +249,8 @@ public interface ChronoLocalDate
* This allows dates in different calendar systems to be compared based * This allows dates in different calendar systems to be compared based
* on the position of the date on the local time-line. * on the position of the date on the local time-line.
* The underlying comparison is equivalent to comparing the epoch-day. * 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 #isAfter
* @see #isBefore * @see #isBefore
* @see #isEqual * @see #isEqual
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -227,7 +227,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate> ...@@ -227,7 +227,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* 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.
* <p> * <p>
* This adds the specified period in years to the date. * This adds the specified period in years to the date.
* In some cases, adding years can cause the resulting date to become invalid. * In some cases, adding years can cause the resulting date to become invalid.
...@@ -243,7 +243,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate> ...@@ -243,7 +243,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
abstract D plusYears(long yearsToAdd); 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.
* <p> * <p>
* This adds the specified period in months to the date. * This adds the specified period in months to the date.
* In some cases, adding months can cause the resulting date to become invalid. * In some cases, adding months can cause the resulting date to become invalid.
...@@ -259,7 +259,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate> ...@@ -259,7 +259,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
abstract D plusMonths(long monthsToAdd); 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.
* <p> * <p>
* This adds the specified period in weeks to the date. * This adds the specified period in weeks to the date.
* In some cases, adding weeks can cause the resulting date to become invalid. * In some cases, adding weeks can cause the resulting date to become invalid.
...@@ -292,7 +292,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate> ...@@ -292,7 +292,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* 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.
* <p> * <p>
* This subtracts the specified period in years to the date. * This subtracts the specified period in years to the date.
* In some cases, subtracting years can cause the resulting date to become invalid. * In some cases, subtracting years can cause the resulting date to become invalid.
...@@ -313,7 +313,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate> ...@@ -313,7 +313,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
} }
/** /**
* 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.
* <p> * <p>
* This subtracts the specified period in months to the date. * This subtracts the specified period in months to the date.
* In some cases, subtracting months can cause the resulting date to become invalid. * In some cases, subtracting months can cause the resulting date to become invalid.
...@@ -334,7 +334,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate> ...@@ -334,7 +334,7 @@ abstract class ChronoLocalDateImpl<D extends ChronoLocalDate>
} }
/** /**
* 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.
* <p> * <p>
* This subtracts the specified period in weeks to the date. * This subtracts the specified period in weeks to the date.
* In some cases, subtracting weeks can cause the resulting date to become invalid. * In some cases, subtracting weeks can cause the resulting date to become invalid.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -131,7 +131,6 @@ public interface ChronoLocalDateTime<D extends ChronoLocalDate> ...@@ -131,7 +131,6 @@ public interface ChronoLocalDateTime<D extends ChronoLocalDate>
* The underlying comparison is equivalent to comparing the epoch-day and nano-of-day. * 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 * @return a comparator that compares in time-line order ignoring the chronology
*
* @see #isAfter * @see #isAfter
* @see #isBefore * @see #isBefore
* @see #isEqual * @see #isEqual
...@@ -323,7 +322,7 @@ public interface ChronoLocalDateTime<D extends ChronoLocalDate> ...@@ -323,7 +322,7 @@ public interface ChronoLocalDateTime<D extends ChronoLocalDate>
* what the result of this method will be. * what the result of this method will be.
* <p> * <p>
* The result of this method is obtained by invoking the * 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. * specified query passing {@code this} as the argument.
* *
* @param <R> the type of the result * @param <R> the type of the result
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -132,7 +132,6 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate> ...@@ -132,7 +132,6 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate>
* The underlying comparison is equivalent to comparing the epoch-second and nano-of-second. * 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 * @return a comparator that compares in time-line order ignoring the chronology
*
* @see #isAfter * @see #isAfter
* @see #isBefore * @see #isBefore
* @see #isEqual * @see #isEqual
...@@ -292,7 +291,7 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate> ...@@ -292,7 +291,7 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate>
* <p> * <p>
* This instance is immutable and unaffected by this method call. * 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 can be found for the zone
* @throws DateTimeException if no rules are valid for this date-time * @throws DateTimeException if no rules are valid for this date-time
*/ */
...@@ -319,7 +318,7 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate> ...@@ -319,7 +318,7 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate>
ChronoZonedDateTime<D> withLaterOffsetAtOverlap(); ChronoZonedDateTime<D> 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. * retaining the local date-time if possible.
* <p> * <p>
* This method changes the time-zone and retains the local date-time. * This method changes the time-zone and retains the local date-time.
...@@ -470,7 +469,7 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate> ...@@ -470,7 +469,7 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate>
* what the result of this method will be. * what the result of this method will be.
* <p> * <p>
* The result of this method is obtained by invoking the * 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. * specified query passing {@code this} as the argument.
* *
* @param <R> the type of the result * @param <R> the type of the result
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -132,8 +132,9 @@ import java.util.Set; ...@@ -132,8 +132,9 @@ import java.util.Set;
* The set of available chronologies can be extended by applications. * The set of available chronologies can be extended by applications.
* Adding a new calendar system requires the writing of an implementation of * Adding a new calendar system requires the writing of an implementation of
* {@code Chronology}, {@code ChronoLocalDate} and {@code Era}. * {@code Chronology}, {@code ChronoLocalDate} and {@code Era}.
* The majority of the logic specific to the calendar system will be in * The majority of the logic specific to the calendar system will be in the
* {@code ChronoLocalDate}. The {@code Chronology} subclass acts as a factory. * {@code ChronoLocalDate} implementation.
* The {@code Chronology} implementation acts as a factory.
* <p> * <p>
* To permit the discovery of additional chronologies, the {@link java.util.ServiceLoader ServiceLoader} * 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 * 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<Chronology> { ...@@ -167,7 +168,7 @@ public interface Chronology extends Comparable<Chronology> {
* If the specified temporal object does not have a chronology, {@link IsoChronology} is returned. * If the specified temporal object does not have a chronology, {@link IsoChronology} is returned.
* <p> * <p>
* This method matches the signature of the functional interface {@link TemporalQuery} * 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 * @param temporal the temporal to convert, not null
* @return the chronology, not null * @return the chronology, not null
...@@ -413,7 +414,7 @@ public interface Chronology extends Comparable<Chronology> { ...@@ -413,7 +414,7 @@ public interface Chronology extends Comparable<Chronology> {
* The alternate clock may be introduced using {@link Clock dependency injection}. * The alternate clock may be introduced using {@link Clock dependency injection}.
* *
* @implSpec * @implSpec
* The default implementation invokes {@link #date(TemporalAccessor)} )}. * The default implementation invokes {@link #date(TemporalAccessor)}.
* *
* @param clock the clock to use, not null * @param clock the clock to use, not null
* @return the current local date, not null * @return the current local date, not null
...@@ -622,7 +623,7 @@ public interface Chronology extends Comparable<Chronology> { ...@@ -622,7 +623,7 @@ public interface Chronology extends Comparable<Chronology> {
* The parameters control the style of the returned text and the locale. * The parameters control the style of the returned text and the locale.
* *
* @implSpec * @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. * format the chronology textual name.
* *
* @param style the style of the text required, not null * @param style the style of the text required, not null
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -182,7 +182,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { ...@@ -182,7 +182,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster {
/** /**
* Gets the value of the specified field from this era as an {@code int}. * Gets the value of the specified field from this era as an {@code int}.
* <p> * <p>
* 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. * 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
...@@ -215,7 +215,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { ...@@ -215,7 +215,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster {
/** /**
* Gets the value of the specified field from this era as a {@code long}. * Gets the value of the specified field from this era as a {@code long}.
* <p> * <p>
* 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 * If it is not possible to return the value, because the field is not supported
* or for some other reason, an exception is thrown. * or for some other reason, an exception is thrown.
* <p> * <p>
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 ...@@ -394,7 +394,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial
* Gets the ID of the chronology. * Gets the ID of the chronology.
* <p> * <p>
* The ID uniquely identifies the {@code Chronology}. It can be used to * 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 * @return the chronology ID, non-null
* @see #getCalendarType() * @see #getCalendarType()
...@@ -409,7 +409,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial ...@@ -409,7 +409,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial
* <p> * <p>
* The calendar type is an identifier defined by the * The calendar type is an identifier defined by the
* <em>Unicode Locale Data Markup Language (LDML)</em> specification. * <em>Unicode Locale Data Markup Language (LDML)</em> 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 * @return the calendar system type; non-null if the calendar has
* a standard type, otherwise null * a standard type, otherwise null
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 ...@@ -143,7 +143,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa
* Gets the ID of the chronology - 'ISO'. * Gets the ID of the chronology - 'ISO'.
* <p> * <p>
* The ID uniquely identifies the {@code Chronology}. * 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' * @return the chronology ID - 'ISO'
* @see #getCalendarType() * @see #getCalendarType()
...@@ -158,7 +158,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa ...@@ -158,7 +158,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa
* <p> * <p>
* The calendar type is an identifier defined by the * The calendar type is an identifier defined by the
* <em>Unicode Locale Data Markup Language (LDML)</em> specification. * <em>Unicode Locale Data Markup Language (LDML)</em> 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 * It can also be used as part of a locale, accessible via
* {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'.
* *
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 ...@@ -150,7 +150,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
* Gets the ID of the chronology - 'Japanese'. * Gets the ID of the chronology - 'Japanese'.
* <p> * <p>
* The ID uniquely identifies the {@code Chronology}. * 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' * @return the chronology ID - 'Japanese'
* @see #getCalendarType() * @see #getCalendarType()
...@@ -165,7 +165,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri ...@@ -165,7 +165,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
* <p> * <p>
* The calendar type is an identifier defined by the * The calendar type is an identifier defined by the
* <em>Unicode Locale Data Markup Language (LDML)</em> specification. * <em>Unicode Locale Data Markup Language (LDML)</em> 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 * It can also be used as part of a locale, accessible via
* {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'.
* *
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 ...@@ -132,7 +132,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial
* Gets the ID of the chronology - 'Minguo'. * Gets the ID of the chronology - 'Minguo'.
* <p> * <p>
* The ID uniquely identifies the {@code Chronology}. * 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' * @return the chronology ID - 'Minguo'
* @see #getCalendarType() * @see #getCalendarType()
...@@ -147,7 +147,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial ...@@ -147,7 +147,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial
* <p> * <p>
* The calendar type is an identifier defined by the * The calendar type is an identifier defined by the
* <em>Unicode Locale Data Markup Language (LDML)</em> specification. * <em>Unicode Locale Data Markup Language (LDML)</em> 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 * It can also be used as part of a locale, accessible via
* {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'.
* *
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -168,7 +168,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements ...@@ -168,7 +168,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements
* Gets the ID of the chronology - 'ThaiBuddhist'. * Gets the ID of the chronology - 'ThaiBuddhist'.
* <p> * <p>
* The ID uniquely identifies the {@code Chronology}. * 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' * @return the chronology ID - 'ThaiBuddhist'
* @see #getCalendarType() * @see #getCalendarType()
...@@ -183,7 +183,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements ...@@ -183,7 +183,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements
* <p> * <p>
* The calendar type is an identifier defined by the * The calendar type is an identifier defined by the
* <em>Unicode Locale Data Markup Language (LDML)</em> specification. * <em>Unicode Locale Data Markup Language (LDML)</em> 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 * It can also be used as part of a locale, accessible via
* {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'.
* *
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -117,8 +117,9 @@ import java.util.Set; ...@@ -117,8 +117,9 @@ import java.util.Set;
* {@code parse(CharSequence text, DateTimeFormatter formatter)}. * {@code parse(CharSequence text, DateTimeFormatter formatter)}.
* <p>For example: * <p>For example:
* <blockquote><pre> * <blockquote><pre>
* String text = date.toString(formatter); * LocalDate date = LocalDate.now();
* LocalDate date = LocalDate.parse(text, formatter); * String text = date.format(formatter);
* LocalDate parsedDate = LocalDate.parse(text, formatter);
* </pre></blockquote> * </pre></blockquote>
* <p> * <p>
* In addition to the format, formatters can be created with desired Locale, * In addition to the format, formatters can be created with desired Locale,
...@@ -265,9 +266,10 @@ import java.util.Set; ...@@ -265,9 +266,10 @@ import java.util.Set;
* <p> * <p>
* For example: * For example:
* <blockquote><pre> * <blockquote><pre>
* LocalDate date = LocalDate.now();
* DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd"); * DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd");
* String text = date.toString(formatter); * String text = date.format(formatter);
* LocalDate date = LocalDate.parse(text, formatter); * LocalDate parsedDate = LocalDate.parse(text, formatter);
* </pre></blockquote> * </pre></blockquote>
* <p> * <p>
* All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The * All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The
...@@ -1331,8 +1333,8 @@ public final class DateTimeFormatter { ...@@ -1331,8 +1333,8 @@ public final class DateTimeFormatter {
* If the time '23:59:60' is received, then a simple conversion is applied, * 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 * 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. * 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 query will return {@code true} if it did adjust to remove the
* the leap-second, and zero if not. Note that applying a leap-second * leap-second, and {@code false} if not. Note that applying a leap-second
* smoothing mechanism, such as UTC-SLS, is the responsibility of the * smoothing mechanism, such as UTC-SLS, is the responsibility of the
* application, as follows: * application, as follows:
* <pre> * <pre>
...@@ -1976,7 +1978,7 @@ public final class DateTimeFormatter { ...@@ -1976,7 +1978,7 @@ public final class DateTimeFormatter {
* Errors are returned using the error index field of the {@code ParsePosition} * Errors are returned using the error index field of the {@code ParsePosition}
* instead of {@code DateTimeParseException}. * instead of {@code DateTimeParseException}.
* The returned error index will be set to an index indicative of the error. * 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.
* <p> * <p>
* If the formatter parses the same field more than once with different values, * If the formatter parses the same field more than once with different values,
* the result will be an error. * the result will be an error.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* *
* Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos * 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -137,7 +137,6 @@ import sun.util.locale.provider.TimeZoneNameUtility; ...@@ -137,7 +137,6 @@ import sun.util.locale.provider.TimeZoneNameUtility;
* <li>ChronologyText - the name of the chronology</li> * <li>ChronologyText - the name of the chronology</li>
* <li>Literal - a text literal</li> * <li>Literal - a text literal</li>
* <li>Nested and Optional - formats can be nested or made optional</li> * <li>Nested and Optional - formats can be nested or made optional</li>
* <li>Other - the printer and parser interfaces can be used to add user supplied formatting</li>
* </ul> * </ul>
* In addition, any of the elements may be decorated by padding, either with spaces or any other character. * In addition, any of the elements may be decorated by padding, either with spaces or any other character.
* <p> * <p>
...@@ -194,8 +193,8 @@ public final class DateTimeFormatterBuilder { ...@@ -194,8 +193,8 @@ public final class DateTimeFormatterBuilder {
* The locale and chronology are used to lookup the locale specific format * The locale and chronology are used to lookup the locale specific format
* for the requested dateStyle and/or timeStyle. * for the requested dateStyle and/or timeStyle.
* *
* @param dateStyle the FormatStyle for the date * @param dateStyle the FormatStyle for the date, null for time-only pattern
* @param timeStyle the FormatStyle for the time * @param timeStyle the FormatStyle for the time, null for date-only pattern
* @param chrono the Chronology, non-null * @param chrono the Chronology, non-null
* @param locale the locale, non-null * @param locale the locale, non-null
* @return the locale and Chronology specific formatting pattern * @return the locale and Chronology specific formatting pattern
...@@ -747,9 +746,9 @@ public final class DateTimeFormatterBuilder { ...@@ -747,9 +746,9 @@ public final class DateTimeFormatterBuilder {
* defines the connection between each value and the text: * defines the connection between each value and the text:
* <pre> * <pre>
* Map&lt;Long, String&gt; map = new HashMap&lt;&gt;(); * Map&lt;Long, String&gt; map = new HashMap&lt;&gt;();
* map.put(1, "JNY"); * map.put(1L, "JNY");
* map.put(2, "FBY"); * map.put(2L, "FBY");
* map.put(3, "MCH"); * map.put(3L, "MCH");
* ... * ...
* builder.appendText(MONTH_OF_YEAR, map); * builder.appendText(MONTH_OF_YEAR, map);
* </pre> * </pre>
...@@ -841,7 +840,7 @@ public final class DateTimeFormatterBuilder { ...@@ -841,7 +840,7 @@ public final class DateTimeFormatterBuilder {
* <p> * <p>
* The {@linkplain ResolverStyle resolver style} has no effect on instant parsing. * 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 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. * {@link DateTimeFormatter#parsedLeapSecond()} for full details.
* <p> * <p>
* An alternative to this method is to format/parse the instant as a single * An alternative to this method is to format/parse the instant as a single
...@@ -864,7 +863,7 @@ public final class DateTimeFormatterBuilder { ...@@ -864,7 +863,7 @@ public final class DateTimeFormatterBuilder {
* Appends the zone offset, such as '+01:00', to the formatter. * Appends the zone offset, such as '+01:00', to the formatter.
* <p> * <p>
* This appends an instruction to format/parse the offset ID to the builder. * 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 * @return this, for chaining, not null
*/ */
...@@ -1049,7 +1048,7 @@ public final class DateTimeFormatterBuilder { ...@@ -1049,7 +1048,7 @@ public final class DateTimeFormatterBuilder {
* "GMT+01:30" -- ZoneOffset.of("+01:30") * "GMT+01:30" -- ZoneOffset.of("+01:30")
* </pre> * </pre>
* <p> * <p>
* 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. * in the mechanism used to obtain the zone.
* Note also that parsing accepts offsets, whereas formatting will never * Note also that parsing accepts offsets, whereas formatting will never
* produce one. * produce one.
...@@ -1107,7 +1106,7 @@ public final class DateTimeFormatterBuilder { ...@@ -1107,7 +1106,7 @@ public final class DateTimeFormatterBuilder {
* "GMT+01:30" -- ZoneOffset.of("GMT+01:30") * "GMT+01:30" -- ZoneOffset.of("GMT+01:30")
* </pre> * </pre>
* <p> * <p>
* 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. * in the mechanism used to obtain the zone.
* *
* @return this, for chaining, not null * @return this, for chaining, not null
...@@ -1132,7 +1131,7 @@ public final class DateTimeFormatterBuilder { ...@@ -1132,7 +1131,7 @@ public final class DateTimeFormatterBuilder {
* for the locale set in the {@link DateTimeFormatter}. * for the locale set in the {@link DateTimeFormatter}.
* If the temporal object being printed represents an instant, then the text * If the temporal object being printed represents an instant, then the text
* will be the summer or winter time text as appropriate. * 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. * {@link ZoneId#getId() ID} will be printed instead.
* If the zone cannot be obtained then an exception is thrown unless the * If the zone cannot be obtained then an exception is thrown unless the
* section of the formatter is optional. * section of the formatter is optional.
...@@ -1168,7 +1167,7 @@ public final class DateTimeFormatterBuilder { ...@@ -1168,7 +1167,7 @@ public final class DateTimeFormatterBuilder {
* for the locale set in the {@link DateTimeFormatter}. * for the locale set in the {@link DateTimeFormatter}.
* If the temporal object being printed represents an instant, then the text * If the temporal object being printed represents an instant, then the text
* will be the summer or winter time text as appropriate. * 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. * {@link ZoneId#getId() ID} will be printed instead.
* If the zone cannot be obtained then an exception is thrown unless the * If the zone cannot be obtained then an exception is thrown unless the
* section of the formatter is optional. * section of the formatter is optional.
...@@ -1182,7 +1181,7 @@ public final class DateTimeFormatterBuilder { ...@@ -1182,7 +1181,7 @@ public final class DateTimeFormatterBuilder {
* zone. This method also allows a set of preferred {@link ZoneId} to be * 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 * specified for parsing. The matched preferred zone id will be used if the
* textural zone name being parsed is not unique. * textural zone name being parsed is not unique.
* * <p>
* If the zone cannot be parsed then an exception is thrown unless the * If the zone cannot be parsed then an exception is thrown unless the
* section of the formatter is optional. * section of the formatter is optional.
* *
...@@ -1227,7 +1226,6 @@ public final class DateTimeFormatterBuilder { ...@@ -1227,7 +1226,6 @@ public final class DateTimeFormatterBuilder {
* <p> * <p>
* The calendar system name will be output during a format. * The calendar system name will be output during a format.
* If the chronology cannot be obtained then an exception will be thrown. * 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 * @param textStyle the text style to use, not null
* @return this, for chaining, not null * @return this, for chaining, not null
...@@ -1453,7 +1451,7 @@ public final class DateTimeFormatterBuilder { ...@@ -1453,7 +1451,7 @@ public final class DateTimeFormatterBuilder {
* LLLLL 5 appendText(ChronoField.MONTH_OF_YEAR, TextStyle.NARROW_STANDALONE) * LLLLL 5 appendText(ChronoField.MONTH_OF_YEAR, TextStyle.NARROW_STANDALONE)
* *
* w 1 append special localized WeekFields element for numeric week-of-year * 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 * W 1 append special localized WeekFields element for numeric week-of-month
* d 1 appendValue(ChronoField.DAY_OF_MONTH) * d 1 appendValue(ChronoField.DAY_OF_MONTH)
* dd 2 appendValue(ChronoField.DAY_OF_MONTH, 2) * dd 2 appendValue(ChronoField.DAY_OF_MONTH, 2)
...@@ -1880,7 +1878,6 @@ public final class DateTimeFormatterBuilder { ...@@ -1880,7 +1878,6 @@ public final class DateTimeFormatterBuilder {
* <p> * <p>
* During parsing, the padding and decorated element are parsed. * 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 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 padding is parsed greedily. Thus, if the decorated element starts with
* the pad character, it will not be parsed. * the pad character, it will not be parsed.
* *
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
package java.time.format; package java.time.format;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
...@@ -138,7 +137,7 @@ public final class DecimalStyle { ...@@ -138,7 +137,7 @@ public final class DecimalStyle {
* of(Locale.getDefault(Locale.Category.FORMAT))}. * of(Locale.getDefault(Locale.Category.FORMAT))}.
* *
* @see java.util.Locale.Category#FORMAT * @see java.util.Locale.Category#FORMAT
* @return the info, not null * @return the decimal style, not null
*/ */
public static DecimalStyle ofDefaultLocale() { public static DecimalStyle ofDefaultLocale() {
return of(Locale.getDefault(Locale.Category.FORMAT)); return of(Locale.getDefault(Locale.Category.FORMAT));
...@@ -150,7 +149,7 @@ public final class DecimalStyle { ...@@ -150,7 +149,7 @@ public final class DecimalStyle {
* This method provides access to locale sensitive decimal style symbols. * This method provides access to locale sensitive decimal style symbols.
* *
* @param locale the locale, not null * @param locale the locale, not null
* @return the info, not null * @return the decimal style, not null
*/ */
public static DecimalStyle of(Locale locale) { public static DecimalStyle of(Locale locale) {
Objects.requireNonNull(locale, "locale"); Objects.requireNonNull(locale, "locale");
...@@ -340,7 +339,7 @@ public final class DecimalStyle { ...@@ -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 * @param obj the object to check, null returns false
* @return true if this is equal to the other date * @return true if this is equal to the other date
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
* The main API for dates, times, instants, and durations. * The main API for dates, times, instants, and durations.
* </p> * </p>
* <p> * <p>
* 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. * including instants, durations, dates, times, time-zones and periods.
* They are based on the ISO calendar system, which is the <i>de facto</i> world * They are based on the ISO calendar system, which is the <i>de facto</i> world
* calendar following the proleptic Gregorian rules. * calendar following the proleptic Gregorian rules.
...@@ -120,9 +120,10 @@ ...@@ -120,9 +120,10 @@
* *
* <h3>Duration and Period</h3> * <h3>Duration and Period</h3>
* <p> * <p>
* 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.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.
* </p> * </p>
* *
* <h3>Additional value types</h3> * <h3>Additional value types</h3>
...@@ -247,8 +248,8 @@ ...@@ -247,8 +248,8 @@
* </ul> * </ul>
* <p> * <p>
* Multiple calendar systems is an awkward addition to the design challenges. * Multiple calendar systems is an awkward addition to the design challenges.
* The first principal is that most users want the standard ISO calendar system. * The first principle 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 * 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. * 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 * 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. * storage, only being converted to and from a local calendar for display.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -638,7 +638,7 @@ public final class IsoFields { ...@@ -638,7 +638,7 @@ public final class IsoFields {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Implementation of the period unit. * Implementation of the unit.
*/ */
private static enum Unit implements TemporalUnit { private static enum Unit implements TemporalUnit {
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -157,7 +157,8 @@ public interface Temporal extends TemporalAccessor { ...@@ -157,7 +157,8 @@ public interface Temporal extends TemporalAccessor {
* This adjusts this date-time according to the rules of the specified adjuster. * 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 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 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". * These include finding the "last day of the month" and "next Wednesday".
* The adjuster is responsible for handling special cases, such as the varying * The adjuster is responsible for handling special cases, such as the varying
* lengths of month and leap years. * lengths of month and leap years.
...@@ -287,7 +288,7 @@ public interface Temporal extends TemporalAccessor { ...@@ -287,7 +288,7 @@ public interface Temporal extends TemporalAccessor {
* This provides equivalent, safe behavior for immutable and mutable implementations. * This provides equivalent, safe behavior for immutable and mutable implementations.
* *
* @param amountToAdd the amount of the specified unit to add, may be negative * @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 * @return an object of the same type with the specified period added, not null
* @throws DateTimeException if the unit cannot be added * @throws DateTimeException if the unit cannot be added
* @throws UnsupportedTemporalTypeException if the unit is not supported * @throws UnsupportedTemporalTypeException if the unit is not supported
...@@ -359,7 +360,7 @@ public interface Temporal extends TemporalAccessor { ...@@ -359,7 +360,7 @@ public interface Temporal extends TemporalAccessor {
* </pre> * </pre>
* *
* @param amountToSubtract the amount of the specified unit to subtract, may be negative * @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 * @return an object of the same type with the specified period subtracted, not null
* @throws DateTimeException if the unit cannot be subtracted * @throws DateTimeException if the unit cannot be subtracted
* @throws UnsupportedTemporalTypeException if the unit is not supported * @throws UnsupportedTemporalTypeException if the unit is not supported
...@@ -378,12 +379,12 @@ public interface Temporal extends TemporalAccessor { ...@@ -378,12 +379,12 @@ public interface Temporal extends TemporalAccessor {
* The start and end points are {@code this} and the specified temporal. * 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 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. * 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)}. * calculated using {@code startTime.until(endTime, HOURS)}.
* <p> * <p>
* The calculation returns a whole number, representing the number of * The calculation returns a whole number, representing the number of
* complete units between the two temporals. * 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. * will only be one hour as it is one minute short of two hours.
* <p> * <p>
* There are two equivalent ways of using this method. * There are two equivalent ways of using this method.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -180,7 +180,7 @@ public interface TemporalAccessor { ...@@ -180,7 +180,7 @@ public interface TemporalAccessor {
/** /**
* Gets the value of the specified field as an {@code int}. * Gets the value of the specified field as an {@code int}.
* <p> * <p>
* 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. * 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 * If the date-time cannot return the value, because the field is unsupported or for
* some other reason, an exception will be thrown. * some other reason, an exception will be thrown.
...@@ -229,7 +229,7 @@ public interface TemporalAccessor { ...@@ -229,7 +229,7 @@ public interface TemporalAccessor {
/** /**
* Gets the value of the specified field as a {@code long}. * Gets the value of the specified field as a {@code long}.
* <p> * <p>
* 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. * 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 * If the date-time cannot return the value, because the field is unsupported or for
* some other reason, an exception will be thrown. * some other reason, an exception will be thrown.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -116,7 +116,7 @@ public interface TemporalField { ...@@ -116,7 +116,7 @@ public interface TemporalField {
* For example, in the field 'MonthOfYear', the unit is 'Months'. * For example, in the field 'MonthOfYear', the unit is 'Months'.
* See also {@link #getRangeUnit()}. * 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(); TemporalUnit getBaseUnit();
...@@ -130,7 +130,7 @@ public interface TemporalField { ...@@ -130,7 +130,7 @@ public interface TemporalField {
* The range is never null. For example, the 'Year' field is shorthand for * 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'. * '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(); TemporalUnit getRangeUnit();
...@@ -179,7 +179,7 @@ public interface TemporalField { ...@@ -179,7 +179,7 @@ public interface TemporalField {
* Checks if this field is supported by the temporal object. * Checks if this field is supported by the temporal object.
* <p> * <p>
* This determines whether the temporal accessor supports this field. * 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.
* <p> * <p>
* There are two equivalent ways of using this method. * There are two equivalent ways of using this method.
* The first is to invoke this method directly. * The first is to invoke this method directly.
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -221,7 +221,7 @@ public interface TemporalUnit { ...@@ -221,7 +221,7 @@ public interface TemporalUnit {
* @param temporal the temporal object to adjust, not null * @param temporal the temporal object to adjust, not null
* @param amount the amount of this unit to add, positive or negative * @param amount the amount of this unit to add, positive or negative
* @return the adjusted temporal object, not null * @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 * @throws UnsupportedTemporalTypeException if the unit is not supported by the temporal
*/ */
<R extends Temporal> R addTo(R temporal, long amount); <R extends Temporal> R addTo(R temporal, long amount);
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -83,7 +83,7 @@ import java.util.Objects; ...@@ -83,7 +83,7 @@ import java.util.Objects;
* The discontinuity is normally a gap in spring and an overlap in autumn. * The discontinuity is normally a gap in spring and an overlap in autumn.
* {@code ZoneOffsetTransition} models the transition between the two offsets. * {@code ZoneOffsetTransition} models the transition between the two offsets.
* <p> * <p>
* 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}. * 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'. * This might be described as 'the clocks will move forward one hour tonight at 1am'.
* <p> * <p>
...@@ -334,7 +334,7 @@ public final class ZoneOffsetTransition ...@@ -334,7 +334,7 @@ public final class ZoneOffsetTransition
/** /**
* Does this transition represent a gap in the local time-line. * Does this transition represent a gap in the local time-line.
* <p> * <p>
* 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}. * 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'. * This might be described as 'the clocks will move forward one hour tonight at 1am'.
* *
......
...@@ -780,7 +780,9 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> ...@@ -780,7 +780,9 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
} }
/** /**
* 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() { final Node firstDataNode() {
for (Node p = head; p != null;) { for (Node p = head; p != null;) {
...@@ -953,11 +955,12 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> ...@@ -953,11 +955,12 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
Object[] a = new Object[n]; Object[] a = new Object[n];
int i = 0; int i = 0;
do { do {
if ((a[i] = p.item) != null) Object e = p.item;
if (e != p && (a[i] = e) != null)
++i; ++i;
if (p == (p = p.next)) if (p == (p = p.next))
p = q.firstDataNode(); p = q.firstDataNode();
} while (p != null && i < n); } while (p != null && i < n && p.isData);
if ((current = p) == null) if ((current = p) == null)
exhausted = true; exhausted = true;
if (i > 0) { if (i > 0) {
...@@ -980,11 +983,11 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> ...@@ -980,11 +983,11 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
exhausted = true; exhausted = true;
do { do {
Object e = p.item; Object e = p.item;
if (e != null && e != p)
action.accept((E)e);
if (p == (p = p.next)) if (p == (p = p.next))
p = q.firstDataNode(); p = q.firstDataNode();
if (e != null) } while (p != null && p.isData);
action.accept((E)e);
} while (p != null);
} }
} }
...@@ -997,10 +1000,11 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E> ...@@ -997,10 +1000,11 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
((p = current) != null || (p = q.firstDataNode()) != null)) { ((p = current) != null || (p = q.firstDataNode()) != null)) {
Object e; Object e;
do { do {
e = p.item; if ((e = p.item) == p)
e = null;
if (p == (p = p.next)) if (p == (p = p.next))
p = q.firstDataNode(); p = q.firstDataNode();
} while (e == null && p != null); } while (e == null && p != null && p.isData);
if ((current = p) == null) if ((current = p) == null)
exhausted = true; exhausted = true;
if (e != null) { if (e != null) {
......
...@@ -715,16 +715,19 @@ public abstract class SunToolkit extends Toolkit ...@@ -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) { static Image getImageFromHash(Toolkit tk, URL url) {
checkPermissions(url); checkPermissions(url);
synchronized (imgCache) { synchronized (urlImgCache) {
Image img = (Image)imgCache.get(url); String key = url.toString();
Image img = (Image)urlImgCache.get(key);
if (img == null) { if (img == null) {
try { try {
img = tk.createImage(new URLImageSource(url)); img = tk.createImage(new URLImageSource(url));
imgCache.put(url, img); urlImgCache.put(key, img);
} catch (Exception e) { } catch (Exception e) {
} }
} }
...@@ -735,12 +738,12 @@ public abstract class SunToolkit extends Toolkit ...@@ -735,12 +738,12 @@ public abstract class SunToolkit extends Toolkit
static Image getImageFromHash(Toolkit tk, static Image getImageFromHash(Toolkit tk,
String filename) { String filename) {
checkPermissions(filename); checkPermissions(filename);
synchronized (imgCache) { synchronized (fileImgCache) {
Image img = (Image)imgCache.get(filename); Image img = (Image)fileImgCache.get(filename);
if (img == null) { if (img == null) {
try { try {
img = tk.createImage(new FileImageSource(filename)); img = tk.createImage(new FileImageSource(filename));
imgCache.put(filename, img); fileImgCache.put(filename, img);
} catch (Exception e) { } catch (Exception e) {
} }
} }
...@@ -758,28 +761,29 @@ public abstract class SunToolkit extends Toolkit ...@@ -758,28 +761,29 @@ public abstract class SunToolkit extends Toolkit
protected Image getImageWithResolutionVariant(String fileName, protected Image getImageWithResolutionVariant(String fileName,
String resolutionVariantName) { String resolutionVariantName) {
synchronized (imgCache) { synchronized (fileImgCache) {
Image image = getImageFromHash(this, fileName); Image image = getImageFromHash(this, fileName);
if (image instanceof MultiResolutionImage) { if (image instanceof MultiResolutionImage) {
return image; return image;
} }
Image resolutionVariant = getImageFromHash(this, resolutionVariantName); Image resolutionVariant = getImageFromHash(this, resolutionVariantName);
image = createImageWithResolutionVariant(image, resolutionVariant); image = createImageWithResolutionVariant(image, resolutionVariant);
imgCache.put(fileName, image); fileImgCache.put(fileName, image);
return image; return image;
} }
} }
protected Image getImageWithResolutionVariant(URL url, protected Image getImageWithResolutionVariant(URL url,
URL resolutionVariantURL) { URL resolutionVariantURL) {
synchronized (imgCache) { synchronized (urlImgCache) {
Image image = getImageFromHash(this, url); Image image = getImageFromHash(this, url);
if (image instanceof MultiResolutionImage) { if (image instanceof MultiResolutionImage) {
return image; return image;
} }
Image resolutionVariant = getImageFromHash(this, resolutionVariantURL); Image resolutionVariant = getImageFromHash(this, resolutionVariantURL);
image = createImageWithResolutionVariant(image, resolutionVariant); image = createImageWithResolutionVariant(image, resolutionVariant);
imgCache.put(url, image); String key = url.toString();
urlImgCache.put(key, image);
return image; return image;
} }
} }
...@@ -884,8 +888,13 @@ public abstract class SunToolkit extends Toolkit ...@@ -884,8 +888,13 @@ public abstract class SunToolkit extends Toolkit
return null; return null;
} }
protected static boolean imageCached(Object key) { protected static boolean imageCached(String fileName) {
return imgCache.containsKey(key); return fileImgCache.containsKey(fileName);
}
protected static boolean imageCached(URL url) {
String key = url.toString();
return urlImgCache.containsKey(key);
} }
protected static boolean imageExists(String filename) { protected static boolean imageExists(String filename) {
......
...@@ -69,7 +69,7 @@ public final class ECPrivateKeyImpl extends PKCS8Key implements ECPrivateKey { ...@@ -69,7 +69,7 @@ public final class ECPrivateKeyImpl extends PKCS8Key implements ECPrivateKey {
/** /**
* Construct a key from its encoding. Called by the ECKeyFactory. * Construct a key from its encoding. Called by the ECKeyFactory.
*/ */
ECPrivateKeyImpl(byte[] encoded) throws InvalidKeyException { public ECPrivateKeyImpl(byte[] encoded) throws InvalidKeyException {
decode(encoded); decode(encoded);
} }
...@@ -77,7 +77,7 @@ public final class ECPrivateKeyImpl extends PKCS8Key implements ECPrivateKey { ...@@ -77,7 +77,7 @@ public final class ECPrivateKeyImpl extends PKCS8Key implements ECPrivateKey {
* Construct a key from its components. Used by the * Construct a key from its components. Used by the
* KeyFactory. * KeyFactory.
*/ */
ECPrivateKeyImpl(BigInteger s, ECParameterSpec params) public ECPrivateKeyImpl(BigInteger s, ECParameterSpec params)
throws InvalidKeyException { throws InvalidKeyException {
this.s = s; this.s = s;
this.params = params; this.params = params;
......
...@@ -52,7 +52,7 @@ public final class ECPublicKeyImpl extends X509Key implements ECPublicKey { ...@@ -52,7 +52,7 @@ public final class ECPublicKeyImpl extends X509Key implements ECPublicKey {
* ECKeyFactory. * ECKeyFactory.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
ECPublicKeyImpl(ECPoint w, ECParameterSpec params) public ECPublicKeyImpl(ECPoint w, ECParameterSpec params)
throws InvalidKeyException { throws InvalidKeyException {
this.w = w; this.w = w;
this.params = params; this.params = params;
...@@ -65,7 +65,7 @@ public final class ECPublicKeyImpl extends X509Key implements ECPublicKey { ...@@ -65,7 +65,7 @@ public final class ECPublicKeyImpl extends X509Key implements ECPublicKey {
/** /**
* Construct a key from its encoding. * Construct a key from its encoding.
*/ */
ECPublicKeyImpl(byte[] encoded) throws InvalidKeyException { public ECPublicKeyImpl(byte[] encoded) throws InvalidKeyException {
decode(encoded); decode(encoded);
} }
......
...@@ -116,7 +116,7 @@ final class P11ECKeyFactory extends P11KeyFactory { ...@@ -116,7 +116,7 @@ final class P11ECKeyFactory extends P11KeyFactory {
byte[] encoded = key.getEncoded(); byte[] encoded = key.getEncoded();
try { try {
key = ECUtil.decodeX509ECPublicKey(encoded); key = P11ECUtil.decodeX509ECPublicKey(encoded);
} catch (InvalidKeySpecException ikse) { } catch (InvalidKeySpecException ikse) {
throw new InvalidKeyException(ikse); throw new InvalidKeyException(ikse);
} }
...@@ -145,7 +145,7 @@ final class P11ECKeyFactory extends P11KeyFactory { ...@@ -145,7 +145,7 @@ final class P11ECKeyFactory extends P11KeyFactory {
byte[] encoded = key.getEncoded(); byte[] encoded = key.getEncoded();
try { try {
key = ECUtil.decodePKCS8ECPrivateKey(encoded); key = P11ECUtil.decodePKCS8ECPrivateKey(encoded);
} catch (InvalidKeySpecException ikse) { } catch (InvalidKeySpecException ikse) {
throw new InvalidKeyException(ikse); throw new InvalidKeyException(ikse);
} }
...@@ -167,7 +167,7 @@ final class P11ECKeyFactory extends P11KeyFactory { ...@@ -167,7 +167,7 @@ final class P11ECKeyFactory extends P11KeyFactory {
if (keySpec instanceof X509EncodedKeySpec) { if (keySpec instanceof X509EncodedKeySpec) {
try { try {
byte[] encoded = ((X509EncodedKeySpec)keySpec).getEncoded(); byte[] encoded = ((X509EncodedKeySpec)keySpec).getEncoded();
PublicKey key = ECUtil.decodeX509ECPublicKey(encoded); PublicKey key = P11ECUtil.decodeX509ECPublicKey(encoded);
return implTranslatePublicKey(key); return implTranslatePublicKey(key);
} catch (InvalidKeyException e) { } catch (InvalidKeyException e) {
throw new InvalidKeySpecException throw new InvalidKeySpecException
...@@ -197,7 +197,7 @@ final class P11ECKeyFactory extends P11KeyFactory { ...@@ -197,7 +197,7 @@ final class P11ECKeyFactory extends P11KeyFactory {
if (keySpec instanceof PKCS8EncodedKeySpec) { if (keySpec instanceof PKCS8EncodedKeySpec) {
try { try {
byte[] encoded = ((PKCS8EncodedKeySpec)keySpec).getEncoded(); byte[] encoded = ((PKCS8EncodedKeySpec)keySpec).getEncoded();
PrivateKey key = ECUtil.decodePKCS8ECPrivateKey(encoded); PrivateKey key = P11ECUtil.decodePKCS8ECPrivateKey(encoded);
return implTranslatePrivateKey(key); return implTranslatePrivateKey(key);
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
throw new InvalidKeySpecException throw new InvalidKeySpecException
......
/*
* 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() {}
}
...@@ -47,7 +47,6 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*; ...@@ -47,7 +47,6 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
import sun.security.util.DerValue; import sun.security.util.DerValue;
import sun.security.util.Length; import sun.security.util.Length;
import sun.security.util.ECUtil;
/** /**
* Key implementation classes. * Key implementation classes.
...@@ -993,7 +992,7 @@ abstract class P11Key implements Key, Length { ...@@ -993,7 +992,7 @@ abstract class P11Key implements Key, Length {
if (encoded == null) { if (encoded == null) {
fetchValues(); fetchValues();
try { try {
Key key = ECUtil.generateECPrivateKey(s, params); Key key = P11ECUtil.generateECPrivateKey(s, params);
encoded = key.getEncoded(); encoded = key.getEncoded();
} catch (InvalidKeySpecException e) { } catch (InvalidKeySpecException e) {
throw new ProviderException(e); throw new ProviderException(e);
...@@ -1067,7 +1066,7 @@ abstract class P11Key implements Key, Length { ...@@ -1067,7 +1066,7 @@ abstract class P11Key implements Key, Length {
if (encoded == null) { if (encoded == null) {
fetchValues(); fetchValues();
try { try {
return ECUtil.x509EncodeECPublicKey(w, params); return P11ECUtil.x509EncodeECPublicKey(w, params);
} catch (InvalidKeySpecException e) { } catch (InvalidKeySpecException e) {
throw new ProviderException(e); throw new ProviderException(e);
} }
......
...@@ -89,47 +89,6 @@ public class ECUtil { ...@@ -89,47 +89,6 @@ public class ECUtil {
return Arrays.copyOfRange(b, i, b.length); 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) { private static AlgorithmParameters getECParameters(Provider p) {
try { try {
if (p != null) { if (p != null) {
......
...@@ -515,7 +515,6 @@ public final class FontPanel extends JPanel implements AdjustmentListener { ...@@ -515,7 +515,6 @@ public final class FontPanel extends JPanel implements AdjustmentListener {
/// Sets the font, hints, according to the set parameters /// Sets the font, hints, according to the set parameters
private void setParams( Graphics2D g2 ) { private void setParams( Graphics2D g2 ) {
System.out.println("USING FONT " + testFont + " "+testFont.getPSName());
g2.setFont( testFont ); g2.setFont( testFont );
g2.setRenderingHint(KEY_TEXT_ANTIALIASING, antiAliasType); g2.setRenderingHint(KEY_TEXT_ANTIALIASING, antiAliasType);
g2.setRenderingHint(KEY_FRACTIONALMETRICS, fractionalMetricsType); g2.setRenderingHint(KEY_FRACTIONALMETRICS, fractionalMetricsType);
......
...@@ -82,8 +82,8 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) ...@@ -82,8 +82,8 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
int i, j; int i, j;
int imageIndex; int imageIndex;
int cx, cy, cw, ch; /* clamped coordinates */ int cx, cy, cw, ch; /* clamped coordinates */
int numLines; const int interlacedOffset[] = { 0, 4, 2, 1, 0 }; /* The way Interlaced image should. */
int numPassLines; const int interlacedJumps[] = { 8, 8, 4, 2, 1 }; /* be read - offsets and jumps... */
if (DGifSlurp(gif) == GIF_ERROR) { if (DGifSlurp(gif) == GIF_ERROR) {
return 0; return 0;
...@@ -213,6 +213,16 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) ...@@ -213,6 +213,16 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
byte_t *pSrc = image->RasterBits; byte_t *pSrc = image->RasterBits;
ImageFormat srcFormat; ImageFormat srcFormat;
ImageRect srcRect, dstRect; 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.colorMap = colorMapBuf;
srcFormat.depthBytes = 1; srcFormat.depthBytes = 1;
...@@ -221,23 +231,27 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) ...@@ -221,23 +231,27 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
srcFormat.fixedBits = QUAD_ALPHA_MASK; // fixed 100% alpha srcFormat.fixedBits = QUAD_ALPHA_MASK; // fixed 100% alpha
srcFormat.premultiplied = 0; srcFormat.premultiplied = 0;
for (; pass < npass; ++pass) {
int jump = interlacedJumps[pass];
int ofs = interlacedOffset[pass];
/* Number of source lines for current pass */ /* Number of source lines for current pass */
numPassLines = desc->Height; int numPassLines = (desc->Height + jump - ofs - 1) / jump;
/* Number of lines that fits to dest buffer */ /* Number of lines that fits to dest buffer */
numLines = ch; int numLines = (ch + jump - ofs - 1) / jump;
initRect(&srcRect, 0, 0, desc->Width, numLines, 1, initRect(&srcRect, 0, 0, desc->Width, numLines, 1,
desc->Width, pSrc, &srcFormat); desc->Width, pSrc, &srcFormat);
if (numLines > 0) { if (numLines > 0) {
initRect(&dstRect, cx, cy, cw, initRect(&dstRect, cx, cy + ofs, cw,
numLines , 1, stride, pBitmapBits, &splash->imageFormat); numLines , jump, stride, pBitmapBits, &splash->imageFormat);
pSrc += convertRect(&srcRect, &dstRect, CVT_ALPHATEST); pSrc += convertRect(&srcRect, &dstRect, CVT_ALPHATEST);
} }
// skip extra source data // skip extra source data
pSrc += (numPassLines - numLines) * srcRect.stride; pSrc += (numPassLines - numLines) * srcRect.stride;
} }
}
// now dispose of the previous frame correctly // now dispose of the previous frame correctly
...@@ -296,7 +310,13 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) ...@@ -296,7 +310,13 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
free(pBitmapBits); free(pBitmapBits);
free(pOldBitmapBits); 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; return 1;
} }
...@@ -304,7 +324,11 @@ SplashDecodeGif(Splash * splash, GifFileType * gif) ...@@ -304,7 +324,11 @@ SplashDecodeGif(Splash * splash, GifFileType * gif)
int int
SplashDecodeGifStream(Splash * splash, SplashStream * stream) SplashDecodeGifStream(Splash * splash, SplashStream * stream)
{ {
#if GIFLIB_MAJOR >= 5
GifFileType *gif = DGifOpen((void *) stream, SplashStreamGifInputFunc, NULL); GifFileType *gif = DGifOpen((void *) stream, SplashStreamGifInputFunc, NULL);
#else
GifFileType *gif = DGifOpen((void *) stream, SplashStreamGifInputFunc);
#endif
if (!gif) if (!gif)
return 0; return 0;
......
...@@ -679,6 +679,8 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -679,6 +679,8 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
GraphicsConfiguration newGC = null; GraphicsConfiguration newGC = null;
Rectangle screenBounds; Rectangle screenBounds;
XToolkit.awtUnlock();
try {
for (int i = 0; i < gds.length; i++) { for (int i = 0; i < gds.length; i++) {
screenBounds = gds[i].getDefaultConfiguration().getBounds(); screenBounds = gds[i].getDefaultConfiguration().getBounds();
if (newBounds.intersects(screenBounds)) { if (newBounds.intersects(screenBounds)) {
...@@ -702,6 +704,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, ...@@ -702,6 +704,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
} }
} }
} }
} finally {
XToolkit.awtLock();
}
if (newScreenNum != curScreenNum) { if (newScreenNum != curScreenNum) {
if (log.isLoggable(PlatformLogger.Level.FINEST)) { if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("XWindowPeer: Moved to a new screen"); log.finest("XWindowPeer: Moved to a new screen");
......
...@@ -286,7 +286,6 @@ public class X11GraphicsDevice ...@@ -286,7 +286,6 @@ public class X11GraphicsDevice
* Returns true only if: * Returns true only if:
* - the Xrandr extension is present * - the Xrandr extension is present
* - the necessary Xrandr functions were loaded successfully * - the necessary Xrandr functions were loaded successfully
* - XINERAMA is not enabled
*/ */
private static synchronized boolean isXrandrExtensionSupported() { private static synchronized boolean isXrandrExtensionSupported() {
if (xrandrExtSupported == null) { if (xrandrExtSupported == null) {
...@@ -318,7 +317,9 @@ public class X11GraphicsDevice ...@@ -318,7 +317,9 @@ public class X11GraphicsDevice
@Override @Override
public boolean isDisplayChangeSupported() { public boolean isDisplayChangeSupported() {
return (isFullScreenSupported() && (getFullScreenWindow() != null)); return (isFullScreenSupported()
&& !((X11GraphicsEnvironment) GraphicsEnvironment
.getLocalGraphicsEnvironment()).runningXinerama());
} }
private static void enterFullScreenExclusive(Window w) { private static void enterFullScreenExclusive(Window w) {
...@@ -348,8 +349,10 @@ public class X11GraphicsDevice ...@@ -348,8 +349,10 @@ public class X11GraphicsDevice
if (fsSupported && old != null) { if (fsSupported && old != null) {
// enter windowed mode (and restore original display mode) // enter windowed mode (and restore original display mode)
exitFullScreenExclusive(old); exitFullScreenExclusive(old);
if (isDisplayChangeSupported()) {
setDisplayMode(origDisplayMode); setDisplayMode(origDisplayMode);
} }
}
super.setFullScreenWindow(w); super.setFullScreenWindow(w);
...@@ -431,8 +434,10 @@ public class X11GraphicsDevice ...@@ -431,8 +434,10 @@ public class X11GraphicsDevice
Window old = getFullScreenWindow(); Window old = getFullScreenWindow();
if (old != null) { if (old != null) {
exitFullScreenExclusive(old); exitFullScreenExclusive(old);
if (isDisplayChangeSupported()) {
setDisplayMode(origDisplayMode); setDisplayMode(origDisplayMode);
} }
}
}; };
Thread t = new Thread(rootTG, r,"Display-Change-Shutdown-Thread-"+screen); Thread t = new Thread(rootTG, r,"Display-Change-Shutdown-Thread-"+screen);
t.setContextClassLoader(null); t.setContextClassLoader(null);
......
...@@ -41,12 +41,7 @@ import java.security.cert.Certificate; ...@@ -41,12 +41,7 @@ import java.security.cert.Certificate;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory; import java.security.cert.CertificateFactory;
import java.security.interfaces.RSAPrivateCrtKey; import java.security.interfaces.RSAPrivateCrtKey;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.UUID;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
...@@ -142,7 +137,7 @@ abstract class KeyStore extends KeyStoreSpi { ...@@ -142,7 +137,7 @@ abstract class KeyStore extends KeyStoreSpi {
key.getPrimeExponentQ().toByteArray(), key.getPrimeExponentQ().toByteArray(),
key.getCrtCoefficient().toByteArray()); key.getCrtCoefficient().toByteArray());
privateKey = storePrivateKey(keyBlob, privateKey = storePrivateKey(Objects.requireNonNull(keyBlob),
"{" + UUID.randomUUID().toString() + "}", keyBitLength); "{" + UUID.randomUUID().toString() + "}", keyBitLength);
} }
......
...@@ -348,8 +348,8 @@ java_props_t * ...@@ -348,8 +348,8 @@ java_props_t *
GetJavaProperties(JNIEnv* env) GetJavaProperties(JNIEnv* env)
{ {
static java_props_t sprops = {0}; static java_props_t sprops = {0};
int majorVersion;
OSVERSIONINFOEX ver; int minorVersion;
if (sprops.line_separator) { if (sprops.line_separator) {
return &sprops; return &sprops;
...@@ -380,21 +380,67 @@ GetJavaProperties(JNIEnv* env) ...@@ -380,21 +380,67 @@ GetJavaProperties(JNIEnv* env)
/* OS properties */ /* OS properties */
{ {
char buf[100]; char buf[100];
SYSTEM_INFO si; boolean is_workstation;
PGNSI pGNSI; boolean is_64bit;
DWORD platformId;
{
OSVERSIONINFOEX ver;
ver.dwOSVersionInfoSize = sizeof(ver); ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx((OSVERSIONINFO *) &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)); ZeroMemory(&si, sizeof(SYSTEM_INFO));
// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. GetNativeSystemInfo(&si);
pGNSI = (PGNSI) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")), is_64bit = (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64);
"GetNativeSystemInfo"); }
if(NULL != pGNSI) do {
pGNSI(&si); // Read the major and minor version number from kernel32.dll
else VS_FIXEDFILEINFO *file_info;
GetSystemInfo(&si); 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 * From msdn page on OSVERSIONINFOEX, current as of this
...@@ -420,17 +466,15 @@ GetJavaProperties(JNIEnv* env) ...@@ -420,17 +466,15 @@ GetJavaProperties(JNIEnv* env)
* Windows Server 2008 R2 6 1 (!VER_NT_WORKSTATION) * Windows Server 2008 R2 6 1 (!VER_NT_WORKSTATION)
* Windows 8 6 2 (VER_NT_WORKSTATION) * Windows 8 6 2 (VER_NT_WORKSTATION)
* Windows Server 2012 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 * This mapping will presumably be augmented as new Windows
* versions are released. * versions are released.
*/ */
switch (ver.dwPlatformId) { switch (platformId) {
case VER_PLATFORM_WIN32s:
sprops.os_name = "Windows 3.1";
break;
case VER_PLATFORM_WIN32_WINDOWS: case VER_PLATFORM_WIN32_WINDOWS:
if (ver.dwMajorVersion == 4) { if (majorVersion == 4) {
switch (ver.dwMinorVersion) { switch (minorVersion) {
case 0: sprops.os_name = "Windows 95"; break; case 0: sprops.os_name = "Windows 95"; break;
case 10: sprops.os_name = "Windows 98"; break; case 10: sprops.os_name = "Windows 98"; break;
case 90: sprops.os_name = "Windows Me"; break; case 90: sprops.os_name = "Windows Me"; break;
...@@ -441,10 +485,10 @@ GetJavaProperties(JNIEnv* env) ...@@ -441,10 +485,10 @@ GetJavaProperties(JNIEnv* env)
} }
break; break;
case VER_PLATFORM_WIN32_NT: case VER_PLATFORM_WIN32_NT:
if (ver.dwMajorVersion <= 4) { if (majorVersion <= 4) {
sprops.os_name = "Windows NT"; sprops.os_name = "Windows NT";
} else if (ver.dwMajorVersion == 5) { } else if (majorVersion == 5) {
switch (ver.dwMinorVersion) { switch (minorVersion) {
case 0: sprops.os_name = "Windows 2000"; break; case 0: sprops.os_name = "Windows 2000"; break;
case 1: sprops.os_name = "Windows XP"; break; case 1: sprops.os_name = "Windows XP"; break;
case 2: case 2:
...@@ -459,8 +503,7 @@ GetJavaProperties(JNIEnv* env) ...@@ -459,8 +503,7 @@ GetJavaProperties(JNIEnv* env)
* If it is, the operating system is Windows XP 64 bit; * If it is, the operating system is Windows XP 64 bit;
* otherwise, it is Windows Server 2003." * otherwise, it is Windows Server 2003."
*/ */
if(ver.wProductType == VER_NT_WORKSTATION && if (is_workstation && is_64bit) {
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
sprops.os_name = "Windows XP"; /* 64 bit */ sprops.os_name = "Windows XP"; /* 64 bit */
} else { } else {
sprops.os_name = "Windows 2003"; sprops.os_name = "Windows 2003";
...@@ -468,12 +511,12 @@ GetJavaProperties(JNIEnv* env) ...@@ -468,12 +511,12 @@ GetJavaProperties(JNIEnv* env)
break; break;
default: sprops.os_name = "Windows NT (unknown)"; break; default: sprops.os_name = "Windows NT (unknown)"; break;
} }
} else if (ver.dwMajorVersion == 6) { } else if (majorVersion == 6) {
/* /*
* See table in MSDN OSVERSIONINFOEX documentation. * See table in MSDN OSVERSIONINFOEX documentation.
*/ */
if (ver.wProductType == VER_NT_WORKSTATION) { if (is_workstation) {
switch (ver.dwMinorVersion) { switch (minorVersion) {
case 0: sprops.os_name = "Windows Vista"; break; case 0: sprops.os_name = "Windows Vista"; break;
case 1: sprops.os_name = "Windows 7"; break; case 1: sprops.os_name = "Windows 7"; break;
case 2: sprops.os_name = "Windows 8"; break; case 2: sprops.os_name = "Windows 8"; break;
...@@ -481,7 +524,7 @@ GetJavaProperties(JNIEnv* env) ...@@ -481,7 +524,7 @@ GetJavaProperties(JNIEnv* env)
default: sprops.os_name = "Windows NT (unknown)"; default: sprops.os_name = "Windows NT (unknown)";
} }
} else { } else {
switch (ver.dwMinorVersion) { switch (minorVersion) {
case 0: sprops.os_name = "Windows Server 2008"; break; case 0: sprops.os_name = "Windows Server 2008"; break;
case 1: sprops.os_name = "Windows Server 2008 R2"; break; case 1: sprops.os_name = "Windows Server 2008 R2"; break;
case 2: sprops.os_name = "Windows Server 2012"; break; case 2: sprops.os_name = "Windows Server 2012"; break;
...@@ -489,6 +532,17 @@ GetJavaProperties(JNIEnv* env) ...@@ -489,6 +532,17 @@ GetJavaProperties(JNIEnv* env)
default: sprops.os_name = "Windows NT (unknown)"; 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 { } else {
sprops.os_name = "Windows NT (unknown)"; sprops.os_name = "Windows NT (unknown)";
} }
...@@ -497,7 +551,7 @@ GetJavaProperties(JNIEnv* env) ...@@ -497,7 +551,7 @@ GetJavaProperties(JNIEnv* env)
sprops.os_name = "Windows (unknown)"; sprops.os_name = "Windows (unknown)";
break; break;
} }
sprintf(buf, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion); sprintf(buf, "%d.%d", majorVersion, minorVersion);
sprops.os_version = _strdup(buf); sprops.os_version = _strdup(buf);
#if _M_IA64 #if _M_IA64
sprops.os_arch = "ia64"; sprops.os_arch = "ia64";
...@@ -508,9 +562,6 @@ GetJavaProperties(JNIEnv* env) ...@@ -508,9 +562,6 @@ GetJavaProperties(JNIEnv* env)
#else #else
sprops.os_arch = "unknown"; sprops.os_arch = "unknown";
#endif #endif
sprops.patch_level = _strdup(ver.szCSDVersion);
sprops.desktop = "windows"; sprops.desktop = "windows";
} }
...@@ -621,7 +672,7 @@ GetJavaProperties(JNIEnv* env) ...@@ -621,7 +672,7 @@ GetJavaProperties(JNIEnv* env)
&display_encoding); &display_encoding);
sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID); 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. // MS claims "Vista has built-in support for HKSCS-2004.
// All of the HKSCS-2004 characters have Unicode 4.1. // All of the HKSCS-2004 characters have Unicode 4.1.
// PUA code point assignments". But what it really means // PUA code point assignments". But what it really means
......
...@@ -1659,29 +1659,36 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getModulus ...@@ -1659,29 +1659,36 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getModulus
int convertToLittleEndian(JNIEnv *env, jbyteArray source, jbyte* destination, int convertToLittleEndian(JNIEnv *env, jbyteArray source, jbyte* destination,
int destinationLength) { int destinationLength) {
int count = 0;
int sourceLength = env->GetArrayLength(source); int sourceLength = env->GetArrayLength(source);
if (sourceLength < destinationLength) { jbyte* sourceBytes = env->GetByteArrayElements(source, 0);
if (sourceBytes == NULL) {
return -1; return -1;
} }
jbyte* sourceBytes = env->GetByteArrayElements(source, 0); int copyLen = sourceLength;
if (sourceBytes == NULL) { if (sourceLength > destinationLength) {
// source might include an extra sign byte
if (sourceLength == destinationLength + 1 && sourceBytes[0] == 0) {
copyLen--;
} else {
return -1; return -1;
} }
}
// Copy bytes from the end of the source array to the beginning of the // Copy bytes from the end of the source array to the beginning of the
// destination array (until the destination array is full). // destination array (until the destination array is full).
// This ensures that the sign byte from the source array will be excluded. // This ensures that the sign byte from the source array will be excluded.
for (int i = 0; i < destinationLength; i++) { for (int i = 0; i < copyLen; i++) {
destination[i] = sourceBytes[sourceLength - i - 1]; destination[i] = sourceBytes[sourceLength - 1 - i];
count++;
} }
if (sourceBytes) if (copyLen < destinationLength) {
memset(destination + copyLen, 0, destinationLength - copyLen);
}
env->ReleaseByteArrayElements(source, sourceBytes, JNI_ABORT); env->ReleaseByteArrayElements(source, sourceBytes, JNI_ABORT);
return count; return destinationLength;
} }
/* /*
......
...@@ -52,6 +52,8 @@ ...@@ -52,6 +52,8 @@
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 --> <!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application> </application>
</compatibility> </compatibility>
......
...@@ -489,6 +489,7 @@ needs_compact3 = \ ...@@ -489,6 +489,7 @@ needs_compact3 = \
java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java \ java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java \
java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java \ java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java \
java/lang/System/MacEncoding/TestFileEncoding.java \ java/lang/System/MacEncoding/TestFileEncoding.java \
java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java \
java/nio/channels/AsynchronousSocketChannel/Leaky.java \ java/nio/channels/AsynchronousSocketChannel/Leaky.java \
java/security/PermissionCollection/Concurrent.java \ java/security/PermissionCollection/Concurrent.java \
java/security/Principal/Implies.java \ java/security/Principal/Implies.java \
......
/*
* 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 + "'");
}
}
}
/*
* 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();
}
}
}
}
...@@ -38,6 +38,8 @@ public class InvokeSeveralWays { ...@@ -38,6 +38,8 @@ public class InvokeSeveralWays {
failures++; failures++;
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
Throwable c = e.getCause(); Throwable c = e.getCause();
if (BootstrapMethodError.class.isInstance(c)) {
c = c.getCause();
if (expected.isInstance(c)) if (expected.isInstance(c))
System.out.println("EXPECTED: " + expected.getName() + ", "+ c); System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
else { else {
...@@ -45,6 +47,11 @@ public class InvokeSeveralWays { ...@@ -45,6 +47,11 @@ public class InvokeSeveralWays {
System.out.println("FAIL: Unexpected wrapped exception " + c); System.out.println("FAIL: Unexpected wrapped exception " + c);
e.printStackTrace(System.out); 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) { } catch (Throwable e) {
failures++; failures++;
System.out.println("FAIL: Unexpected exception has been caught " + e); System.out.println("FAIL: Unexpected exception has been caught " + e);
...@@ -74,14 +81,19 @@ public class InvokeSeveralWays { ...@@ -74,14 +81,19 @@ public class InvokeSeveralWays {
Invoker.invoke(); Invoker.invoke();
System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier"); System.out.println("FAIL: No exception throw, probably failed to load modified bytecodes for MethodSupplier");
failures++; failures++;
} catch (Throwable e) { } catch (BootstrapMethodError e) {
if (expected.isInstance(e)) Throwable c = e.getCause();
System.out.println("EXPECTED: " + expected.getName() + ", "+ e); if (expected.isInstance(c))
System.out.println("EXPECTED: " + expected.getName() + ", "+ c);
else { else {
failures++; failures++;
System.out.println("FAIL: Unexpected exception has been caught " + e); System.out.println("FAIL: Unexpected exception has been caught " + c);
e.printStackTrace(System.out); e.printStackTrace(System.out);
} }
} catch (Throwable e) {
failures++;
System.out.println("FAIL: Exception from MethodHandle invocation not wrapped in BootstrapMethodError " + e);
e.printStackTrace(System.out);
} }
System.out.println(); System.out.println();
try { try {
......
...@@ -77,7 +77,7 @@ public abstract class LFCachingTestCase extends LambdaFormTestCase { ...@@ -77,7 +77,7 @@ public abstract class LFCachingTestCase extends LambdaFormTestCase {
} }
} catch (IllegalAccessException | IllegalArgumentException | } catch (IllegalAccessException | IllegalArgumentException |
SecurityException | InvocationTargetException ex) { SecurityException | InvocationTargetException ex) {
throw new Error("Unexpected exception: ", ex); throw new Error("Unexpected exception", ex);
} }
} }
} }
...@@ -73,7 +73,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase { ...@@ -73,7 +73,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase {
try { try {
adapter = testCase.getTestCaseMH(data, TestMethods.Kind.ONE); adapter = testCase.getTestCaseMH(data, TestMethods.Kind.ONE);
} catch (NoSuchMethodException ex) { } catch (NoSuchMethodException ex) {
throw new Error("Unexpected exception: ", ex); throw new Error("Unexpected exception", ex);
} }
mtype = adapter.type(); mtype = adapter.type();
Object lambdaForm = INTERNAL_FORM.invoke(adapter); Object lambdaForm = INTERNAL_FORM.invoke(adapter);
...@@ -94,7 +94,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase { ...@@ -94,7 +94,7 @@ public final class LFGarbageCollectedTest extends LambdaFormTestCase {
collectLambdaForm(); collectLambdaForm();
} catch (IllegalAccessException | IllegalArgumentException | } catch (IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) { InvocationTargetException ex) {
throw new Error("Unexpected exception: ", ex); throw new Error("Unexpected exception", ex);
} }
} }
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -35,18 +35,23 @@ ...@@ -35,18 +35,23 @@
*/ */
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier; import java.util.concurrent.CyclicBarrier;
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
/** /**
* Multiple threaded lambda forms caching test class. * Multiple threaded lambda forms caching test class.
*/ */
public final class LFMultiThreadCachingTest extends LFCachingTestCase { public final class LFMultiThreadCachingTest extends LFCachingTestCase {
private static final TestMethods.Kind[] KINDS; private static final TestMethods.Kind[] KINDS;
static { static {
EnumSet<TestMethods.Kind> set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT)); EnumSet<TestMethods.Kind> set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
KINDS = set.toArray(new TestMethods.Kind[set.size()]); KINDS = set.toArray(new TestMethods.Kind[set.size()]);
...@@ -72,21 +77,50 @@ public final class LFMultiThreadCachingTest extends LFCachingTestCase { ...@@ -72,21 +77,50 @@ public final class LFMultiThreadCachingTest extends LFCachingTestCase {
ConcurrentLinkedQueue<MethodHandle> adapters = new ConcurrentLinkedQueue<>(); ConcurrentLinkedQueue<MethodHandle> adapters = new ConcurrentLinkedQueue<>();
CyclicBarrier begin = new CyclicBarrier(CORES); CyclicBarrier begin = new CyclicBarrier(CORES);
CountDownLatch end = new CountDownLatch(CORES); CountDownLatch end = new CountDownLatch(CORES);
final Map<Thread, Throwable> threadUncaughtExceptions
= Collections.synchronizedMap(new HashMap<Thread, Throwable>(CORES));
for (int i = 0; i < CORES; ++i) { for (int i = 0; i < CORES; ++i) {
TestMethods.Kind kind = KINDS[i % KINDS.length]; TestMethods.Kind kind = KINDS[i % KINDS.length];
new Thread(() -> { Thread t = new Thread(() -> {
try { try {
begin.await(); begin.await();
adapters.add(getTestMethod().getTestCaseMH(data, kind)); adapters.add(getTestMethod().getTestCaseMH(data, kind));
} catch (InterruptedException | BrokenBarrierException | IllegalAccessException | NoSuchMethodException ex) { } catch (Throwable ex) {
throw new Error("Unexpected exception: ", ex); threadUncaughtExceptions.put(Thread.currentThread(), ex);
} finally { } finally {
end.countDown(); end.countDown();
} }
}).start(); });
t.start();
} }
try { try {
end.await(); end.await();
boolean vmeThrown = false;
boolean nonVmeThrown = false;
Throwable vme = null;
for (Map.Entry<Thread,
Throwable> 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) { } catch (InterruptedException ex) {
throw new Error("Unexpected exception: ", ex); throw new Error("Unexpected exception: ", ex);
} }
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -62,7 +62,7 @@ public final class LFSingleThreadCachingTest extends LFCachingTestCase { ...@@ -62,7 +62,7 @@ public final class LFSingleThreadCachingTest extends LFCachingTestCase {
adapter1 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE); adapter1 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE);
adapter2 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.TWO); adapter2 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.TWO);
} catch (NoSuchMethodException | IllegalAccessException ex) { } catch (NoSuchMethodException | IllegalAccessException ex) {
throw new Error("Unexpected exception: ", ex); throw new Error("Unexpected exception", ex);
} }
checkLFCaching(adapter1, adapter2); checkLFCaching(adapter1, adapter2);
} }
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
*/ */
import com.oracle.testlibrary.jsr292.Helper; 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.invoke.MethodHandle;
import java.lang.management.GarbageCollectorMXBean; import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
...@@ -45,8 +44,6 @@ import jdk.testlibrary.TimeLimitedRunner; ...@@ -45,8 +44,6 @@ import jdk.testlibrary.TimeLimitedRunner;
*/ */
public abstract class LambdaFormTestCase { 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); private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
/** /**
...@@ -73,7 +70,7 @@ public abstract class LambdaFormTestCase { ...@@ -73,7 +70,7 @@ public abstract class LambdaFormTestCase {
REF_FIELD = Reference.class.getDeclaredField("referent"); REF_FIELD = Reference.class.getDeclaredField("referent");
REF_FIELD.setAccessible(true); REF_FIELD.setAccessible(true);
} catch (Exception ex) { } catch (Exception ex) {
throw new Error("Unexpected exception: ", ex); throw new Error("Unexpected exception", ex);
} }
gcInfo = ManagementFactory.getGarbageCollectorMXBeans(); gcInfo = ManagementFactory.getGarbageCollectorMXBeans();
...@@ -83,13 +80,79 @@ public abstract class LambdaFormTestCase { ...@@ -83,13 +80,79 @@ public abstract class LambdaFormTestCase {
} }
private final TestMethods testMethod; 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 long gcCountAtStart;
private static class TestRun {
final Function<TestMethods, LambdaFormTestCase> ctor;
final Collection<TestMethods> testMethods;
final long totalIterations;
long doneIterations;
long testCounter;
long failCounter;
boolean passed;
TestRun(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> 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 * Test case constructor. Generates test cases with random method types for
* given methods form {@code j.l.i.MethodHandles} class. * given methods form {@code j.l.i.MethodHandles} class.
...@@ -123,65 +186,15 @@ public abstract class LambdaFormTestCase { ...@@ -123,65 +186,15 @@ public abstract class LambdaFormTestCase {
* @param testMethods list of test methods * @param testMethods list of test methods
*/ */
public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) { public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
long testCaseNum = testMethods.size(); LambdaFormTestCase.TestRun run
totalIterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum); = new LambdaFormTestCase.TestRun(ctor, testMethods);
System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n", TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration);
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;
});
try { try {
runner.call(); runner.call();
} catch (Throwable t) { } catch (Exception ex) {
t.printStackTrace();
System.err.println("FAILED"); System.err.println("FAILED");
throw new Error("Unexpected error!"); throw new Error("Unexpected error!", ex);
}
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));
} }
run.checkPassed();
} }
} }
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,7 +23,10 @@ ...@@ -23,7 +23,10 @@
package test.java.lang.invoke.MethodHandles; package test.java.lang.invoke.MethodHandles;
import com.oracle.testlibrary.jsr292.Helper; import com.oracle.testlibrary.jsr292.Helper;
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
import jdk.testlibrary.Asserts; import jdk.testlibrary.Asserts;
import jdk.testlibrary.TimeLimitedRunner;
import jdk.testlibrary.Utils;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
...@@ -37,10 +40,10 @@ import java.util.function.Supplier; ...@@ -37,10 +40,10 @@ import java.util.function.Supplier;
/* @test /* @test
* @library /lib/testlibrary/jsr292 /lib/testlibrary/ * @library /lib/testlibrary/jsr292 /lib/testlibrary/
* @compile CatchExceptionTest.java * @compile CatchExceptionTest.java
* @build jdk.testlibrary.*
* @run main/othervm -esa test.java.lang.invoke.MethodHandles.CatchExceptionTest * @run main/othervm -esa test.java.lang.invoke.MethodHandles.CatchExceptionTest
*/ */
public class CatchExceptionTest { public class CatchExceptionTest {
private static final List<Class<?>> ARGS_CLASSES; private static final List<Class<?>> ARGS_CLASSES;
protected static final int MAX_ARITY = Helper.MAX_ARITY - 1; protected static final int MAX_ARITY = Helper.MAX_ARITY - 1;
...@@ -69,12 +72,6 @@ public class CatchExceptionTest { ...@@ -69,12 +72,6 @@ public class CatchExceptionTest {
final int catchDrops) { final int catchDrops) {
this.testCase = testCase; this.testCase = testCase;
this.dropped = catchDrops; 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; MethodHandle thrower = testCase.thrower;
int throwerLen = thrower.type().parameterCount(); int throwerLen = thrower.type().parameterCount();
List<Class<?>> classes; List<Class<?>> classes;
...@@ -94,21 +91,34 @@ public class CatchExceptionTest { ...@@ -94,21 +91,34 @@ public class CatchExceptionTest {
} }
public static void main(String[] args) throws Throwable { public static void main(String[] args) throws Throwable {
for (CatchExceptionTest test : TestFactory.MANDATORY_TEST_CASES) { CodeCacheOverflowProcessor.runMHTest(CatchExceptionTest::test);
test.runTest();
} }
public static void test() throws Throwable {
System.out.println("classes = " + ARGS_CLASSES);
TestFactory factory = new TestFactory(); TestFactory factory = new TestFactory();
CatchExceptionTest test; long timeout = Helper.IS_THOROUGH ? 0L : Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT);
while ((test = factory.nextTest()) != null ) { // 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(); test.runTest();
return true;
} }
return false;
});
for (CatchExceptionTest test : TestFactory.MANDATORY_TEST_CASES) {
test.runTest();
}
runner.call();
} }
private List<Class<?>> getThrowerParams(boolean isVararg, int argsCount) { private List<Class<?>> getThrowerParams(boolean isVararg, int argsCount) {
return Helper.getParams(ARGS_CLASSES, isVararg, argsCount); return Helper.getParams(ARGS_CLASSES, isVararg, argsCount);
} }
private List<Class<?>> getCatcherParams() { private List<Class<?>> getCatcherParams() {
int catchArgc = 1 + this.argsCount - dropped; int catchArgc = 1 + this.argsCount - dropped;
List<Class<?>> result = new ArrayList<>( List<Class<?>> result = new ArrayList<>(
...@@ -119,6 +129,13 @@ public class CatchExceptionTest { ...@@ -119,6 +129,13 @@ public class CatchExceptionTest {
} }
private void runTest() { 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(); Helper.clear();
Object[] args = Helper.randomArgs( Object[] args = Helper.randomArgs(
...@@ -200,10 +217,7 @@ class TestFactory { ...@@ -200,10 +217,7 @@ class TestFactory {
args = 1; 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(); constructorSize = TestCase.CONSTRUCTORS.size();
} }
...@@ -230,8 +244,9 @@ class TestFactory { ...@@ -230,8 +244,9 @@ class TestFactory {
} }
/** /**
* @return next test from test matrix: * @return next test from test matrix: {varArgs, noVarArgs} x
* {varArgs, noVarArgs} x TestCase.rtypes x TestCase.THROWABLES x {1, .., maxArgs } x {1, .., maxDrops} * TestCase.rtypes x TestCase.THROWABLES x {1, .., maxArgs } x
* {0, .., maxDrops}
*/ */
public CatchExceptionTest nextTest() { public CatchExceptionTest nextTest() {
if (constructor < constructorSize) { if (constructor < constructorSize) {
...@@ -244,7 +259,7 @@ class TestFactory { ...@@ -244,7 +259,7 @@ class TestFactory {
return null; return null;
} }
if (dropArgs <= currentMaxDrops) { if (dropArgs <= currentMaxDrops) {
if (dropArgs == 1) { if (dropArgs == 0) {
if (Helper.IS_THOROUGH || Helper.RNG.nextBoolean()) { if (Helper.IS_THOROUGH || Helper.RNG.nextBoolean()) {
++dropArgs; ++dropArgs;
return createTest(); return createTest();
...@@ -259,8 +274,8 @@ class TestFactory { ...@@ -259,8 +274,8 @@ class TestFactory {
} }
} }
if (args <= maxArgs) { if (args < maxArgs) {
dropArgs = 1; dropArgs = 0;
currentMaxDrops = Math.min(args, maxDrops); currentMaxDrops = Math.min(args, maxDrops);
++args; ++args;
return createTest(); return createTest();
...@@ -421,8 +436,7 @@ class TestCase<T> { ...@@ -421,8 +436,7 @@ class TestCase<T> {
return normal; return normal;
} }
private static <T extends Throwable> private static <T extends Throwable> Object catcher(Object o) {
Object catcher(Object o) {
Helper.called("catcher", o); Helper.called("catcher", o);
return o; return o;
} }
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/* @test /* @test
* @summary unit tests for java.lang.invoke.MethodHandles * @summary unit tests for java.lang.invoke.MethodHandles
* @library /lib/testlibrary /lib/testlibrary/jsr292
* @compile MethodHandlesTest.java remote/RemoteExample.java * @compile MethodHandlesTest.java remote/RemoteExample.java
* @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa test.java.lang.invoke.MethodHandlesTest * @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa test.java.lang.invoke.MethodHandlesTest
*/ */
...@@ -36,6 +37,7 @@ import java.lang.reflect.*; ...@@ -36,6 +37,7 @@ import java.lang.reflect.*;
import java.util.*; import java.util.*;
import org.junit.*; import org.junit.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
/** /**
...@@ -499,6 +501,10 @@ public class MethodHandlesTest { ...@@ -499,6 +501,10 @@ public class MethodHandlesTest {
@Test @Test
public void testFindStatic() throws Throwable { public void testFindStatic() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFindStatic0);
}
public void testFindStatic0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("findStatic"); startTest("findStatic");
testFindStatic(PubExample.class, void.class, "s0"); testFindStatic(PubExample.class, void.class, "s0");
...@@ -586,6 +592,10 @@ public class MethodHandlesTest { ...@@ -586,6 +592,10 @@ public class MethodHandlesTest {
@Test @Test
public void testFindVirtual() throws Throwable { public void testFindVirtual() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFindVirtual0);
}
public void testFindVirtual0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("findVirtual"); startTest("findVirtual");
testFindVirtual(Example.class, void.class, "v0"); testFindVirtual(Example.class, void.class, "v0");
...@@ -616,6 +626,10 @@ public class MethodHandlesTest { ...@@ -616,6 +626,10 @@ public class MethodHandlesTest {
@Test @Test
public void testFindVirtualClone() throws Throwable { public void testFindVirtualClone() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFindVirtualClone0);
}
public void testFindVirtualClone0() throws Throwable {
// test some ad hoc system methods // test some ad hoc system methods
testFindVirtual(false, PUBLIC, Object.class, Object.class, "clone"); testFindVirtual(false, PUBLIC, Object.class, Object.class, "clone");
testFindVirtual(true, PUBLIC, Object[].class, Object.class, "clone"); testFindVirtual(true, PUBLIC, Object[].class, Object.class, "clone");
...@@ -699,6 +713,10 @@ public class MethodHandlesTest { ...@@ -699,6 +713,10 @@ public class MethodHandlesTest {
@Test @Test
public void testFindSpecial() throws Throwable { public void testFindSpecial() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFindSpecial0);
}
public void testFindSpecial0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("findSpecial"); startTest("findSpecial");
testFindSpecial(SubExample.class, Example.class, void.class, "v0"); testFindSpecial(SubExample.class, Example.class, void.class, "v0");
...@@ -775,6 +793,10 @@ public class MethodHandlesTest { ...@@ -775,6 +793,10 @@ public class MethodHandlesTest {
@Test @Test
public void testFindConstructor() throws Throwable { public void testFindConstructor() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFindConstructor0);
}
public void testFindConstructor0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("findConstructor"); startTest("findConstructor");
testFindConstructor(true, EXAMPLE, Example.class); testFindConstructor(true, EXAMPLE, Example.class);
...@@ -818,6 +840,10 @@ public class MethodHandlesTest { ...@@ -818,6 +840,10 @@ public class MethodHandlesTest {
@Test @Test
public void testBind() throws Throwable { public void testBind() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testBind0);
}
public void testBind0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("bind"); startTest("bind");
testBind(Example.class, void.class, "v0"); testBind(Example.class, void.class, "v0");
...@@ -879,6 +905,10 @@ public class MethodHandlesTest { ...@@ -879,6 +905,10 @@ public class MethodHandlesTest {
@Test @Test
public void testUnreflect() throws Throwable { public void testUnreflect() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testUnreflect0);
}
public void testUnreflect0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("unreflect"); startTest("unreflect");
testUnreflect(Example.class, true, void.class, "s0"); testUnreflect(Example.class, true, void.class, "s0");
...@@ -985,6 +1015,10 @@ public class MethodHandlesTest { ...@@ -985,6 +1015,10 @@ public class MethodHandlesTest {
@Test @Test
public void testUnreflectSpecial() throws Throwable { public void testUnreflectSpecial() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testUnreflectSpecial0);
}
public void testUnreflectSpecial0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("unreflectSpecial"); startTest("unreflectSpecial");
testUnreflectSpecial(Example.class, Example.class, void.class, "v0"); testUnreflectSpecial(Example.class, Example.class, void.class, "v0");
...@@ -1077,23 +1111,38 @@ public class MethodHandlesTest { ...@@ -1077,23 +1111,38 @@ public class MethodHandlesTest {
@Test @Test
public void testUnreflectGetter() throws Throwable { public void testUnreflectGetter() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testUnreflectGetter0);
}
public void testUnreflectGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("unreflectGetter"); startTest("unreflectGetter");
testGetter(TEST_UNREFLECT); testGetter(TEST_UNREFLECT);
} }
@Test @Test
public void testFindGetter() throws Throwable { public void testFindGetter() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFindGetter0);
}
public void testFindGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("findGetter"); startTest("findGetter");
testGetter(TEST_FIND_FIELD); testGetter(TEST_FIND_FIELD);
testGetter(TEST_FIND_FIELD | TEST_BOUND); testGetter(TEST_FIND_FIELD | TEST_BOUND);
} }
@Test @Test
public void testFindStaticGetter() throws Throwable { public void testFindStaticGetter() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFindStaticGetter0);
}
public void testFindStaticGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("findStaticGetter"); startTest("findStaticGetter");
testGetter(TEST_FIND_STATIC); testGetter(TEST_FIND_STATIC);
} }
public void testGetter(int testMode) throws Throwable { public void testGetter(int testMode) throws Throwable {
Lookup lookup = PRIVATE; // FIXME: test more lookups than this one Lookup lookup = PRIVATE; // FIXME: test more lookups than this one
for (Object[] c : HasFields.CASES) { for (Object[] c : HasFields.CASES) {
...@@ -1287,26 +1336,40 @@ public class MethodHandlesTest { ...@@ -1287,26 +1336,40 @@ public class MethodHandlesTest {
} }
} }
@Test @Test
public void testUnreflectSetter() throws Throwable { public void testUnreflectSetter() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testUnreflectSetter0);
}
public void testUnreflectSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("unreflectSetter"); startTest("unreflectSetter");
testSetter(TEST_UNREFLECT); testSetter(TEST_UNREFLECT);
} }
@Test @Test
public void testFindSetter() throws Throwable { public void testFindSetter() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFindSetter0);
}
public void testFindSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("findSetter"); startTest("findSetter");
testSetter(TEST_FIND_FIELD); testSetter(TEST_FIND_FIELD);
testSetter(TEST_FIND_FIELD | TEST_BOUND); testSetter(TEST_FIND_FIELD | TEST_BOUND);
} }
@Test @Test
public void testFindStaticSetter() throws Throwable { public void testFindStaticSetter() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFindStaticSetter0);
}
public void testFindStaticSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("findStaticSetter"); startTest("findStaticSetter");
testSetter(TEST_FIND_STATIC); testSetter(TEST_FIND_STATIC);
} }
public void testSetter(int testMode) throws Throwable { public void testSetter(int testMode) throws Throwable {
Lookup lookup = PRIVATE; // FIXME: test more lookups than this one Lookup lookup = PRIVATE; // FIXME: test more lookups than this one
startTest("unreflectSetter"); startTest("unreflectSetter");
...@@ -1329,6 +1392,10 @@ public class MethodHandlesTest { ...@@ -1329,6 +1392,10 @@ public class MethodHandlesTest {
@Test @Test
public void testArrayElementGetter() throws Throwable { public void testArrayElementGetter() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testArrayElementGetter0);
}
public void testArrayElementGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("arrayElementGetter"); startTest("arrayElementGetter");
testArrayElementGetterSetter(false); testArrayElementGetterSetter(false);
...@@ -1336,6 +1403,10 @@ public class MethodHandlesTest { ...@@ -1336,6 +1403,10 @@ public class MethodHandlesTest {
@Test @Test
public void testArrayElementSetter() throws Throwable { public void testArrayElementSetter() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testArrayElementSetter0);
}
public void testArrayElementSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("arrayElementSetter"); startTest("arrayElementSetter");
testArrayElementGetterSetter(true); testArrayElementGetterSetter(true);
...@@ -1349,6 +1420,10 @@ public class MethodHandlesTest { ...@@ -1349,6 +1420,10 @@ public class MethodHandlesTest {
@Test @Test
public void testArrayElementErrors() throws Throwable { public void testArrayElementErrors() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testArrayElementErrors0);
}
public void testArrayElementErrors0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("arrayElementErrors"); startTest("arrayElementErrors");
testArrayElementGetterSetter(false, TEST_ARRAY_NPE); testArrayElementGetterSetter(false, TEST_ARRAY_NPE);
...@@ -1528,6 +1603,10 @@ public class MethodHandlesTest { ...@@ -1528,6 +1603,10 @@ public class MethodHandlesTest {
@Test @Test
public void testConvertArguments() throws Throwable { public void testConvertArguments() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testConvertArguments0);
}
public void testConvertArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("convertArguments"); startTest("convertArguments");
testConvert(Callee.ofType(1), null, "id", int.class); testConvert(Callee.ofType(1), null, "id", int.class);
...@@ -1591,6 +1670,10 @@ public class MethodHandlesTest { ...@@ -1591,6 +1670,10 @@ public class MethodHandlesTest {
@Test @Test
public void testVarargsCollector() throws Throwable { public void testVarargsCollector() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testVarargsCollector0);
}
public void testVarargsCollector0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("varargsCollector"); startTest("varargsCollector");
MethodHandle vac0 = PRIVATE.findStatic(MethodHandlesTest.class, "called", MethodHandle vac0 = PRIVATE.findStatic(MethodHandlesTest.class, "called",
...@@ -1607,6 +1690,10 @@ public class MethodHandlesTest { ...@@ -1607,6 +1690,10 @@ public class MethodHandlesTest {
@Test // SLOW @Test // SLOW
public void testPermuteArguments() throws Throwable { public void testPermuteArguments() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testPermuteArguments0);
}
public void testPermuteArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("permuteArguments"); startTest("permuteArguments");
testPermuteArguments(4, Integer.class, 2, long.class, 6); testPermuteArguments(4, Integer.class, 2, long.class, 6);
...@@ -1746,6 +1833,10 @@ public class MethodHandlesTest { ...@@ -1746,6 +1833,10 @@ public class MethodHandlesTest {
@Test // SLOW @Test // SLOW
public void testSpreadArguments() throws Throwable { public void testSpreadArguments() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testSpreadArguments0);
}
public void testSpreadArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("spreadArguments"); startTest("spreadArguments");
for (Class<?> argType : new Class<?>[]{Object.class, Integer.class, int.class}) { for (Class<?> argType : new Class<?>[]{Object.class, Integer.class, int.class}) {
...@@ -1840,6 +1931,10 @@ public class MethodHandlesTest { ...@@ -1840,6 +1931,10 @@ public class MethodHandlesTest {
@Test // SLOW @Test // SLOW
public void testAsCollector() throws Throwable { public void testAsCollector() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testAsCollector0);
}
public void testAsCollector0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("asCollector"); startTest("asCollector");
for (Class<?> argType : new Class<?>[]{Object.class, Integer.class, int.class}) { for (Class<?> argType : new Class<?>[]{Object.class, Integer.class, int.class}) {
...@@ -1882,6 +1977,10 @@ public class MethodHandlesTest { ...@@ -1882,6 +1977,10 @@ public class MethodHandlesTest {
@Test // SLOW @Test // SLOW
public void testInsertArguments() throws Throwable { public void testInsertArguments() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testInsertArguments0);
}
public void testInsertArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("insertArguments"); startTest("insertArguments");
for (int nargs = 0; nargs < 50; nargs++) { for (int nargs = 0; nargs < 50; nargs++) {
...@@ -1923,6 +2022,10 @@ public class MethodHandlesTest { ...@@ -1923,6 +2022,10 @@ public class MethodHandlesTest {
@Test @Test
public void testFilterReturnValue() throws Throwable { public void testFilterReturnValue() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFilterReturnValue0);
}
public void testFilterReturnValue0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("filterReturnValue"); startTest("filterReturnValue");
Class<?> classOfVCList = varargsList(1).invokeWithArguments(0).getClass(); Class<?> classOfVCList = varargsList(1).invokeWithArguments(0).getClass();
...@@ -1972,6 +2075,10 @@ public class MethodHandlesTest { ...@@ -1972,6 +2075,10 @@ public class MethodHandlesTest {
@Test @Test
public void testFilterArguments() throws Throwable { public void testFilterArguments() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFilterArguments0);
}
public void testFilterArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("filterArguments"); startTest("filterArguments");
for (int nargs = 1; nargs <= 6; nargs++) { for (int nargs = 1; nargs <= 6; nargs++) {
...@@ -2004,6 +2111,10 @@ public class MethodHandlesTest { ...@@ -2004,6 +2111,10 @@ public class MethodHandlesTest {
@Test @Test
public void testCollectArguments() throws Throwable { public void testCollectArguments() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testCollectArguments0);
}
public void testCollectArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("collectArguments"); startTest("collectArguments");
testFoldOrCollectArguments(true); testFoldOrCollectArguments(true);
...@@ -2011,6 +2122,10 @@ public class MethodHandlesTest { ...@@ -2011,6 +2122,10 @@ public class MethodHandlesTest {
@Test @Test
public void testFoldArguments() throws Throwable { public void testFoldArguments() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testFoldArguments0);
}
public void testFoldArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("foldArguments"); startTest("foldArguments");
testFoldOrCollectArguments(false); testFoldOrCollectArguments(false);
...@@ -2112,6 +2227,10 @@ public class MethodHandlesTest { ...@@ -2112,6 +2227,10 @@ public class MethodHandlesTest {
@Test @Test
public void testDropArguments() throws Throwable { public void testDropArguments() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testDropArguments0);
}
public void testDropArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("dropArguments"); startTest("dropArguments");
for (int nargs = 0; nargs <= 4; nargs++) { for (int nargs = 0; nargs <= 4; nargs++) {
...@@ -2143,6 +2262,10 @@ public class MethodHandlesTest { ...@@ -2143,6 +2262,10 @@ public class MethodHandlesTest {
@Test // SLOW @Test // SLOW
public void testInvokers() throws Throwable { public void testInvokers() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testInvokers0);
}
public void testInvokers0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("exactInvoker, genericInvoker, varargsInvoker, dynamicInvoker"); startTest("exactInvoker, genericInvoker, varargsInvoker, dynamicInvoker");
// exactInvoker, genericInvoker, varargsInvoker[0..N], dynamicInvoker // exactInvoker, genericInvoker, varargsInvoker[0..N], dynamicInvoker
...@@ -2344,6 +2467,10 @@ public class MethodHandlesTest { ...@@ -2344,6 +2467,10 @@ public class MethodHandlesTest {
@Test @Test
public void testGuardWithTest() throws Throwable { public void testGuardWithTest() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testGuardWithTest0);
}
public void testGuardWithTest0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("guardWithTest"); startTest("guardWithTest");
for (int nargs = 0; nargs <= 50; nargs++) { for (int nargs = 0; nargs <= 50; nargs++) {
...@@ -2415,6 +2542,10 @@ public class MethodHandlesTest { ...@@ -2415,6 +2542,10 @@ public class MethodHandlesTest {
@Test @Test
public void testThrowException() throws Throwable { public void testThrowException() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testThrowException0);
}
public void testThrowException0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("throwException"); startTest("throwException");
testThrowException(int.class, new ClassCastException("testing")); testThrowException(int.class, new ClassCastException("testing"));
...@@ -2446,6 +2577,10 @@ public class MethodHandlesTest { ...@@ -2446,6 +2577,10 @@ public class MethodHandlesTest {
@Test @Test
public void testInterfaceCast() throws Throwable { public void testInterfaceCast() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testInterfaceCast0);
}
public void testInterfaceCast0() throws Throwable {
//if (CAN_SKIP_WORKING) return; //if (CAN_SKIP_WORKING) return;
startTest("interfaceCast"); startTest("interfaceCast");
assert( (((Object)"foo") instanceof CharSequence)); assert( (((Object)"foo") instanceof CharSequence));
...@@ -2543,6 +2678,10 @@ public class MethodHandlesTest { ...@@ -2543,6 +2678,10 @@ public class MethodHandlesTest {
@Test // SLOW @Test // SLOW
public void testCastFailure() throws Throwable { public void testCastFailure() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testCastFailure0);
}
public void testCastFailure0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("testCastFailure"); startTest("testCastFailure");
testCastFailure("cast/argument", 11000); testCastFailure("cast/argument", 11000);
...@@ -2655,6 +2794,10 @@ public class MethodHandlesTest { ...@@ -2655,6 +2794,10 @@ public class MethodHandlesTest {
@Test @Test
public void testUserClassInSignature() throws Throwable { public void testUserClassInSignature() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testUserClassInSignature0);
}
public void testUserClassInSignature0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("testUserClassInSignature"); startTest("testUserClassInSignature");
Lookup lookup = MethodHandles.lookup(); Lookup lookup = MethodHandles.lookup();
...@@ -2706,6 +2849,10 @@ public class MethodHandlesTest { ...@@ -2706,6 +2849,10 @@ public class MethodHandlesTest {
@Test @Test
public void testAsInterfaceInstance() throws Throwable { public void testAsInterfaceInstance() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testAsInterfaceInstance0);
}
public void testAsInterfaceInstance0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("asInterfaceInstance"); startTest("asInterfaceInstance");
Lookup lookup = MethodHandles.lookup(); Lookup lookup = MethodHandles.lookup();
...@@ -2869,6 +3016,10 @@ public class MethodHandlesTest { ...@@ -2869,6 +3016,10 @@ public class MethodHandlesTest {
@Test @Test
public void testRunnableProxy() throws Throwable { public void testRunnableProxy() throws Throwable {
CodeCacheOverflowProcessor.runMHTest(this::testRunnableProxy0);
}
public void testRunnableProxy0() throws Throwable {
if (CAN_SKIP_WORKING) return; if (CAN_SKIP_WORKING) return;
startTest("testRunnableProxy"); startTest("testRunnableProxy");
MethodHandles.Lookup lookup = MethodHandles.lookup(); MethodHandles.Lookup lookup = MethodHandles.lookup();
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,9 +24,12 @@ ...@@ -24,9 +24,12 @@
/* /*
* @test * @test
* @bug 8019184 * @bug 8019184
* @library /lib/testlibrary /lib/testlibrary/jsr292
* @summary MethodHandles.catchException() fails when methods have 8 args + varargs * @summary MethodHandles.catchException() fails when methods have 8 args + varargs
* @run main TestCatchExceptionWithVarargs
*/ */
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
import java.util.*; import java.util.*;
import java.lang.invoke.*; import java.lang.invoke.*;
...@@ -68,6 +71,11 @@ public class TestCatchExceptionWithVarargs { ...@@ -68,6 +71,11 @@ public class TestCatchExceptionWithVarargs {
} }
public static void main(String[] args) throws Throwable { public static void main(String[] args) throws Throwable {
CodeCacheOverflowProcessor
.runMHTest(TestCatchExceptionWithVarargs::test);
}
public static void test() throws Throwable {
List<Class<?>> ptypes = new LinkedList<>(); List<Class<?>> ptypes = new LinkedList<>();
ptypes.add(Object[].class); ptypes.add(Object[].class);
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
package java.lang.invoke; package java.lang.invoke;
import sun.invoke.util.Wrapper; import sun.invoke.util.Wrapper;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
/* @test /* @test
* @summary unit tests for varargs array methods: MethodHandleInfo.varargsArray(int), * @summary unit tests for varargs array methods: MethodHandleInfo.varargsArray(int),
* MethodHandleInfo.varargsArray(Class,int) & MethodHandleInfo.varargsList(int) * MethodHandleInfo.varargsArray(Class,int) & MethodHandleInfo.varargsList(int)
* * @library /lib/testlibrary /lib/testlibrary/jsr292
* @run main/bootclasspath java.lang.invoke.VarargsArrayTest * @run main/bootclasspath java.lang.invoke.VarargsArrayTest
* @run main/bootclasspath -DVarargsArrayTest.MAX_ARITY=255 -DVarargsArrayTest.START_ARITY=250 * @run main/bootclasspath -DVarargsArrayTest.MAX_ARITY=255 -DVarargsArrayTest.START_ARITY=250
* java.lang.invoke.VarargsArrayTest * java.lang.invoke.VarargsArrayTest
...@@ -47,6 +47,10 @@ public class VarargsArrayTest { ...@@ -47,6 +47,10 @@ public class VarargsArrayTest {
private static final boolean EXHAUSTIVE = Boolean.getBoolean(CLASS.getSimpleName()+".EXHAUSTIVE"); private static final boolean EXHAUSTIVE = Boolean.getBoolean(CLASS.getSimpleName()+".EXHAUSTIVE");
public static void main(String[] args) throws Throwable { public static void main(String[] args) throws Throwable {
CodeCacheOverflowProcessor.runMHTest(VarargsArrayTest::test);
}
public static void test() throws Throwable {
testVarargsArray(); testVarargsArray();
testVarargsReferenceArray(); testVarargsReferenceArray();
testVarargsPrimitiveArray(); testVarargsPrimitiveArray();
......
/*
* 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<Queue<?>> 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<Spliterator<?>> 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<Queue<String>> c)
throws InterruptedException {
AtomicBoolean done = new AtomicBoolean(false);
Queue<String> msgs = new LinkedTransferQueue<>();
CompletableFuture<Void> traversalTask = CompletableFuture.runAsync(() -> {
while (!done.get()) {
// Traversal will fail if self-linked nodes of
// LinkedTransferQueue are erroneously reported
c.accept(msgs);
}
});
CompletableFuture<Void> 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();
}
}
...@@ -104,6 +104,8 @@ public class DisabledAlgorithms { ...@@ -104,6 +104,8 @@ public class DisabledAlgorithms {
default: default:
throw new RuntimeException("Wrong parameter: " + args[0]); throw new RuntimeException("Wrong parameter: " + args[0]);
} }
System.out.println("Test passed");
} }
/* /*
...@@ -128,7 +130,6 @@ public class DisabledAlgorithms { ...@@ -128,7 +130,6 @@ public class DisabledAlgorithms {
} }
} }
server.stop();
while (server.isRunning()) { while (server.isRunning()) {
sleep(); sleep();
} }
...@@ -224,11 +225,19 @@ public class DisabledAlgorithms { ...@@ -224,11 +225,19 @@ public class DisabledAlgorithms {
} catch (SSLHandshakeException e) { } catch (SSLHandshakeException e) {
System.out.println("Server: run: " + e); System.out.println("Server: run: " + e);
sslError = true; sslError = true;
stopped = true;
} catch (IOException e) { } catch (IOException e) {
if (!stopped) { if (!stopped) {
System.out.println("Server: run: " + e); System.out.println("Server: run: unexpected exception: "
+ e);
e.printStackTrace(); e.printStackTrace();
otherError = true; 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 { ...@@ -261,6 +270,7 @@ public class DisabledAlgorithms {
stopped = true; stopped = true;
if (!ssocket.isClosed()) { if (!ssocket.isClosed()) {
try { try {
System.out.println("Server: close socket");
ssocket.close(); ssocket.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println("Server: close: " + e); System.out.println("Server: close: " + e);
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -36,6 +36,7 @@ import java.util.Collections; ...@@ -36,6 +36,7 @@ import java.util.Collections;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function;
/** /**
* Common library for various test helper functions. * Common library for various test helper functions.
...@@ -276,4 +277,38 @@ public final class Utils { ...@@ -276,4 +277,38 @@ public final class Utils {
public static long adjustTimeout(long tOut) { public static long adjustTimeout(long tOut) {
return Math.round(tOut * Utils.TIMEOUT_FACTOR); 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<Throwable, Boolean> filter) throws Throwable {
try {
test.run();
} catch (Throwable t) {
if (filter.apply(t)) {
return t;
} else {
throw t;
}
}
return null;
}
} }
/*
* 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;
}
}
/*
* 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);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册