--- a/jdk/make/GenerateData.gmk Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/make/GenerateData.gmk Fri Jun 27 14:21:31 2014 -0700
@@ -62,7 +62,7 @@
##########################################################################################
-GENDATA_CURDATA := $(JDK_OUTPUTDIR)/lib/currency.data
+GENDATA_CURDATA := $(JDK_OUTPUTDIR)/classes/java/util/currency.data
$(GENDATA_CURDATA): $(JDK_TOPDIR)/make/data/currency/CurrencyData.properties $(BUILD_TOOLS)
$(MKDIR) -p $(@D)
--- a/jdk/make/Setup.gmk Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/make/Setup.gmk Fri Jun 27 14:21:31 2014 -0700
@@ -27,7 +27,7 @@
# To build with all warnings enabled, do the following:
# make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
-JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,-overrides,auxiliaryclass,cast,classfile,dep-ann,divzero,empty,fallthrough,finally,overloads,serial,static,try,varargs -Werror
+JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,auxiliaryclass,cast,classfile,dep-ann,divzero,empty,fallthrough,finally,overloads,overrides,serial,static,try,varargs -Werror
# Any java code executed during a JDK build to build other parts of the JDK must be
# executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this
--- a/jdk/make/profile-includes.txt Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/make/profile-includes.txt Fri Jun 27 14:21:31 2014 -0700
@@ -56,7 +56,6 @@
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
calendars.properties \
classlist \
- currency.data \
ext/localedata.jar \
ext/meta-index \
ext/sunec.jar \
--- a/jdk/make/src/classes/build/tools/tzdb/ChronoField.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package build.tools.tzdb;
-
-/**
- * A standard set of date/time fields.
- *
- * @since 1.8
- */
-enum ChronoField {
-
- /**
- * The second-of-minute.
- * <p>
- * This counts the second within the minute, from 0 to 59.
- * This field has the same meaning for all calendar systems.
- */
- SECOND_OF_MINUTE("SecondOfMinute", 0, 59),
-
- /**
- * The second-of-day.
- * <p>
- * This counts the second within the day, from 0 to (24 * 60 * 60) - 1.
- * This field has the same meaning for all calendar systems.
- */
- SECOND_OF_DAY("SecondOfDay", 0, 86400 - 1),
-
- /**
- * The minute-of-hour.
- * <p>
- * This counts the minute within the hour, from 0 to 59.
- * This field has the same meaning for all calendar systems.
- */
- MINUTE_OF_HOUR("MinuteOfHour", 0, 59),
-
- /**
- * The hour-of-day.
- * <p>
- * This counts the hour within the day, from 0 to 23.
- * This is the hour that would be observed on a standard 24-hour digital clock.
- * This field has the same meaning for all calendar systems.
- */
- HOUR_OF_DAY("HourOfDay", 0, 23),
-
-
- /**
- * The day-of-month.
- * <p>
- * This represents the concept of the day within the month.
- * In the default ISO calendar system, this has values from 1 to 31 in most months.
- * April, June, September, November have days from 1 to 30, while February has days
- * from 1 to 28, or 29 in a leap year.
- * <p>
- * Non-ISO calendar systems should implement this field using the most recognized
- * day-of-month values for users of the calendar system.
- * Normally, this is a count of days from 1 to the length of the month.
- */
- DAY_OF_MONTH("DayOfMonth", 1, 31),
-
- /**
- * The month-of-year, such as March.
- * <p>
- * This represents the concept of the month within the year.
- * In the default ISO calendar system, this has values from January (1) to December (12).
- * <p>
- * Non-ISO calendar systems should implement this field using the most recognized
- * month-of-year values for users of the calendar system.
- * Normally, this is a count of months starting from 1.
- */
- MONTH_OF_YEAR("MonthOfYear", 1, 12),
-
- /**
- * The proleptic year, such as 2012.
- * <p>
- * This represents the concept of the year, counting sequentially and using negative numbers.
- * The proleptic year is not interpreted in terms of the era.
- * See {@link #YEAR_OF_ERA} for an example showing the mapping from proleptic year to year-of-era.
- * <p>
- * The standard mental model for a date is based on three concepts - year, month and day.
- * These map onto the {@code YEAR}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields.
- * Note that there is no reference to eras.
- * The full model for a date requires four concepts - era, year, month and day. These map onto
- * the {@code ERA}, {@code YEAR_OF_ERA}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} fields.
- * Whether this field or {@code YEAR_OF_ERA} is used depends on which mental model is being used.
- * See {@link ChronoLocalDate} for more discussion on this topic.
- * <p>
- * Non-ISO calendar systems should implement this field as follows.
- * If the calendar system has only two eras, before and after a fixed date, then the
- * proleptic-year value must be the same as the year-of-era value for the later era,
- * and increasingly negative for the earlier era.
- * If the calendar system has more than two eras, then the proleptic-year value may be
- * defined with any appropriate value, although defining it to be the same as ISO may be
- * the best option.
- */
- YEAR("Year", -999_999_999, 999_999_999);
-
- private final String name;
- private final int min;
- private final int max;
-
- private ChronoField(String name, int min, int max) {
- this.name = name;
- this.min= min;
- this.max= max;
- }
-
- /**
- * Checks that the specified value is valid for this field.
- * <p>
- *
- * @param value the value to check
- * @return the value that was passed in
- */
- public int checkValidValue(int value) {
- if (value >= min && value <= max) {
- return value;
- }
- throw new DateTimeException("Invalid value for " + name + " value: " + value);
- }
-
- public String toString() {
- return name;
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/DateTimeException.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-/**
- * Exception used to indicate a problem while calculating a date-time.
- * <p>
- * This exception is used to indicate problems with creating, querying
- * and manipulating date-time objects.
- *
- * @since 1.8
- */
-class DateTimeException extends RuntimeException {
-
- /**
- * Serialization version.
- */
- private static final long serialVersionUID = -1632418723876261839L;
-
- /**
- * Constructs a new date-time exception with the specified message.
- *
- * @param message the message to use for this exception, may be null
- */
- public DateTimeException(String message) {
- super(message);
- }
-
- /**
- * Constructs a new date-time exception with the specified message and cause.
- *
- * @param message the message to use for this exception, may be null
- * @param cause the cause of the exception, may be null
- */
- public DateTimeException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/LocalDate.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,363 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-import static build.tools.tzdb.Utils.*;
-import static build.tools.tzdb.LocalTime.SECONDS_PER_DAY;
-import static build.tools.tzdb.ChronoField.DAY_OF_MONTH;
-import static build.tools.tzdb.ChronoField.MONTH_OF_YEAR;
-import static build.tools.tzdb.ChronoField.YEAR;
-
-import java.util.Objects;
-
-/**
- * A date without a time-zone in the ISO-8601 calendar system,
- * such as {@code 2007-12-03}.
- *
- * @since 1.8
- */
-final class LocalDate {
-
- /**
- * The minimum supported {@code LocalDate}, '-999999999-01-01'.
- * This could be used by an application as a "far past" date.
- */
- public static final LocalDate MIN = new LocalDate(YEAR_MIN_VALUE, 1, 1);
- /**
- * The maximum supported {@code LocalDate}, '+999999999-12-31'.
- * This could be used by an application as a "far future" date.
- */
- public static final LocalDate MAX = new LocalDate(YEAR_MAX_VALUE, 12, 31);
-
- /**
- * The number of days in a 400 year cycle.
- */
- private static final int DAYS_PER_CYCLE = 146097;
- /**
- * The number of days from year zero to year 1970.
- * There are five 400 year cycles from year zero to 2000.
- * There are 7 leap years from 1970 to 2000.
- */
- static final long DAYS_0000_TO_1970 = (DAYS_PER_CYCLE * 5L) - (30L * 365L + 7L);
-
- /**
- * The year.
- */
- private final int year;
- /**
- * The month-of-year.
- */
- private final short month;
- /**
- * The day-of-month.
- */
- private final short day;
-
- /**
- * Obtains an instance of {@code LocalDate} from a year, month and day.
- * <p>
- * The day must be valid for the year and month, otherwise an exception will be thrown.
- *
- * @param year the year to represent, from MIN_YEAR to MAX_YEAR
- * @param month the month-of-year to represent, from 1 (January) to 12 (December)
- * @param dayOfMonth the day-of-month to represent, from 1 to 31
- * @return the local date, not null
- * @throws DateTimeException if the value of any field is out of range
- * @throws DateTimeException if the day-of-month is invalid for the month-year
- */
- public static LocalDate of(int year, int month, int dayOfMonth) {
- YEAR.checkValidValue(year);
- MONTH_OF_YEAR.checkValidValue(month);
- DAY_OF_MONTH.checkValidValue(dayOfMonth);
- if (dayOfMonth > 28 && dayOfMonth > lengthOfMonth(month, isLeapYear(year))) {
- if (dayOfMonth == 29) {
- throw new DateTimeException("Invalid date 'February 29' as '" + year + "' is not a leap year");
- } else {
- throw new DateTimeException("Invalid date '" + month + " " + dayOfMonth + "'");
- }
- }
- return new LocalDate(year, month, dayOfMonth);
- }
-
- /**
- * Constructor, previously validated.
- *
- * @param year the year to represent, from MIN_YEAR to MAX_YEAR
- * @param month the month-of-year to represent, not null
- * @param dayOfMonth the day-of-month to represent, valid for year-month, from 1 to 31
- */
- private LocalDate(int year, int month, int dayOfMonth) {
- this.year = year;
- this.month = (short) month;
- this.day = (short) dayOfMonth;
- }
-
- /**
- * Gets the year field.
- * <p>
- * This method returns the primitive {@code int} value for the year.
- * <p>
- * The year returned by this method is proleptic as per {@code get(YEAR)}.
- * To obtain the year-of-era, use {@code get(YEAR_OF_ERA}.
- *
- * @return the year, from MIN_YEAR to MAX_YEAR
- */
- public int getYear() {
- return year;
- }
-
- /**
- * Gets the month-of-year field as an int from 1 to 12.
- *
- * @return the month-of-year
- */
- public int getMonth() {
- return month;
- }
-
- /**
- * Gets the day-of-month field.
- * <p>
- * This method returns the primitive {@code int} value for the day-of-month.
- *
- * @return the day-of-month, from 1 to 31
- */
- public int getDayOfMonth() {
- return day;
- }
-
- /**
- * Gets the day-of-week field, which is an int from 1 to 7.
- *
- * @return the day-of-week
- */
- public int getDayOfWeek() {
- return (int)floorMod(toEpochDay() + 3, 7) + 1;
- }
-
- /**
- * Returns a copy of this {@code LocalDate} with the specified number of days added.
- * <p>
- * This method adds the specified amount to the days field incrementing the
- * month and year fields as necessary to ensure the result remains valid.
- * The result is only invalid if the maximum/minimum year is exceeded.
- * <p>
- * For example, 2008-12-31 plus one day would result in 2009-01-01.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param daysToAdd the days to add, may be negative
- * @return a {@code LocalDate} based on this date with the days added, not null
- * @throws DateTimeException if the result exceeds the supported date range
- */
- public LocalDate plusDays(long daysToAdd) {
- if (daysToAdd == 0) {
- return this;
- }
- long mjDay = addExact(toEpochDay(), daysToAdd);
- return LocalDate.ofEpochDay(mjDay);
- }
-
- /**
- * Returns a copy of this {@code LocalDate} with the specified number of days subtracted.
- * <p>
- * This method subtracts the specified amount from the days field decrementing the
- * month and year fields as necessary to ensure the result remains valid.
- * The result is only invalid if the maximum/minimum year is exceeded.
- * <p>
- * For example, 2009-01-01 minus one day would result in 2008-12-31.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param daysToSubtract the days to subtract, may be negative
- * @return a {@code LocalDate} based on this date with the days subtracted, not null
- * @throws DateTimeException if the result exceeds the supported date range
- */
- public LocalDate minusDays(long daysToSubtract) {
- return (daysToSubtract == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1) : plusDays(-daysToSubtract));
- }
-
- /**
- * Obtains an instance of {@code LocalDate} from the epoch day count.
- * <p>
- * The Epoch Day count is a simple incrementing count of days
- * where day 0 is 1970-01-01. Negative numbers represent earlier days.
- *
- * @param epochDay the Epoch Day to convert, based on the epoch 1970-01-01
- * @return the local date, not null
- * @throws DateTimeException if the epoch days exceeds the supported date range
- */
- public static LocalDate ofEpochDay(long epochDay) {
- long zeroDay = epochDay + DAYS_0000_TO_1970;
- // find the march-based year
- zeroDay -= 60; // adjust to 0000-03-01 so leap day is at end of four year cycle
- long adjust = 0;
- if (zeroDay < 0) {
- // adjust negative years to positive for calculation
- long adjustCycles = (zeroDay + 1) / DAYS_PER_CYCLE - 1;
- adjust = adjustCycles * 400;
- zeroDay += -adjustCycles * DAYS_PER_CYCLE;
- }
- long yearEst = (400 * zeroDay + 591) / DAYS_PER_CYCLE;
- long doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400);
- if (doyEst < 0) {
- // fix estimate
- yearEst--;
- doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400);
- }
- yearEst += adjust; // reset any negative year
- int marchDoy0 = (int) doyEst;
-
- // convert march-based values back to january-based
- int marchMonth0 = (marchDoy0 * 5 + 2) / 153;
- int month = (marchMonth0 + 2) % 12 + 1;
- int dom = marchDoy0 - (marchMonth0 * 306 + 5) / 10 + 1;
- yearEst += marchMonth0 / 10;
-
- // check year now we are certain it is correct
- int year = YEAR.checkValidValue((int)yearEst);
- return new LocalDate(year, month, dom);
- }
-
- public long toEpochDay() {
- long y = year;
- long m = month;
- long total = 0;
- total += 365 * y;
- if (y >= 0) {
- total += (y + 3) / 4 - (y + 99) / 100 + (y + 399) / 400;
- } else {
- total -= y / -4 - y / -100 + y / -400;
- }
- total += ((367 * m - 362) / 12);
- total += day - 1;
- if (m > 2) {
- total--;
- if (isLeapYear(year) == false) {
- total--;
- }
- }
- return total - DAYS_0000_TO_1970;
- }
-
- /**
- * Compares this date to another date.
- * <p>
- * The comparison is primarily based on the date, from earliest to latest.
- * It is "consistent with equals", as defined by {@link Comparable}.
- * <p>
- * If all the dates being compared are instances of {@code LocalDate},
- * then the comparison will be entirely based on the date.
- * If some dates being compared are in different chronologies, then the
- * chronology is also considered, see {@link java.time.temporal.ChronoLocalDate#compareTo}.
- *
- * @param other the other date to compare to, not null
- * @return the comparator value, negative if less, positive if greater
- */
- public int compareTo(LocalDate otherDate) {
- int cmp = (year - otherDate.year);
- if (cmp == 0) {
- cmp = (month - otherDate.month);
- if (cmp == 0) {
- cmp = (day - otherDate.day);
- }
- }
- return cmp;
- }
-
- /**
- * Checks if this date is equal to another date.
- * <p>
- * Compares this {@code LocalDate} with another ensuring that the date is the same.
- * <p>
- * Only objects of type {@code LocalDate} are compared, other types return false.
- * To compare the dates of two {@code TemporalAccessor} instances, including dates
- * in two different chronologies, use {@link ChronoField#EPOCH_DAY} as a comparator.
- *
- * @param obj the object to check, null returns false
- * @return true if this is equal to the other date
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LocalDate) {
- return compareTo((LocalDate) obj) == 0;
- }
- return false;
- }
-
- /**
- * A hash code for this date.
- *
- * @return a suitable hash code
- */
- @Override
- public int hashCode() {
- int yearValue = year;
- int monthValue = month;
- int dayValue = day;
- return (yearValue & 0xFFFFF800) ^ ((yearValue << 11) + (monthValue << 6) + (dayValue));
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/LocalDateTime.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,427 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-import static build.tools.tzdb.Utils.*;
-import static build.tools.tzdb.LocalTime.HOURS_PER_DAY;
-import static build.tools.tzdb.LocalTime.MICROS_PER_DAY;
-import static build.tools.tzdb.LocalTime.MILLIS_PER_DAY;
-import static build.tools.tzdb.LocalTime.MINUTES_PER_DAY;
-import static build.tools.tzdb.LocalTime.SECONDS_PER_DAY;
-import static build.tools.tzdb.LocalTime.SECONDS_PER_MINUTE;
-import static build.tools.tzdb.LocalTime.SECONDS_PER_HOUR;
-
-import java.util.Objects;
-
-/**
- * A date-time without a time-zone in the ISO-8601 calendar system,
- * such as {@code 2007-12-03T10:15:30}.
- *
- * @since 1.8
- */
-final class LocalDateTime {
-
- /**
- * The minimum supported {@code LocalDateTime}, '-999999999-01-01T00:00:00'.
- * This is the local date-time of midnight at the start of the minimum date.
- * This combines {@link LocalDate#MIN} and {@link LocalTime#MIN}.
- * This could be used by an application as a "far past" date-time.
- */
- public static final LocalDateTime MIN = LocalDateTime.of(LocalDate.MIN, LocalTime.MIN);
- /**
- * The maximum supported {@code LocalDateTime}, '+999999999-12-31T23:59:59.999999999'.
- * This is the local date-time just before midnight at the end of the maximum date.
- * This combines {@link LocalDate#MAX} and {@link LocalTime#MAX}.
- * This could be used by an application as a "far future" date-time.
- */
- public static final LocalDateTime MAX = LocalDateTime.of(LocalDate.MAX, LocalTime.MAX);
-
- /**
- * The date part.
- */
- private final LocalDate date;
- /**
- * The time part.
- */
- private final LocalTime time;
-
- /**
- * Obtains an instance of {@code LocalDateTime} from year, month,
- * day, hour and minute, setting the second and nanosecond to zero.
- * <p>
- * The day must be valid for the year and month, otherwise an exception will be thrown.
- * The second and nanosecond fields will be set to zero.
- *
- * @param year the year to represent, from MIN_YEAR to MAX_YEAR
- * @param month the month-of-year to represent, from 1 (January) to 12 (December)
- * @param dayOfMonth the day-of-month to represent, from 1 to 31
- * @param hour the hour-of-day to represent, from 0 to 23
- * @param minute the minute-of-hour to represent, from 0 to 59
- * @return the local date-time, not null
- * @throws DateTimeException if the value of any field is out of range
- * @throws DateTimeException if the day-of-month is invalid for the month-year
- */
- public static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute) {
- LocalDate date = LocalDate.of(year, month, dayOfMonth);
- LocalTime time = LocalTime.of(hour, minute);
- return new LocalDateTime(date, time);
- }
-
- /**
- * Obtains an instance of {@code LocalDateTime} from a date and time.
- *
- * @param date the local date, not null
- * @param time the local time, not null
- * @return the local date-time, not null
- */
- public static LocalDateTime of(LocalDate date, LocalTime time) {
- Objects.requireNonNull(date, "date");
- Objects.requireNonNull(time, "time");
- return new LocalDateTime(date, time);
- }
-
- /**
- * Obtains an instance of {@code LocalDateTime} using seconds from the
- * epoch of 1970-01-01T00:00:00Z.
- * <p>
- * This allows the {@link ChronoField#INSTANT_SECONDS epoch-second} field
- * to be converted to a local date-time. This is primarily intended for
- * low-level conversions rather than general application usage.
- *
- * @param epochSecond the number of seconds from the epoch of 1970-01-01T00:00:00Z
- * @param nanoOfSecond the nanosecond within the second, from 0 to 999,999,999
- * @param offset the zone offset, not null
- * @return the local date-time, not null
- * @throws DateTimeException if the result exceeds the supported range
- */
- public static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset) {
- Objects.requireNonNull(offset, "offset");
- long localSecond = epochSecond + offset.getTotalSeconds(); // overflow caught later
- long localEpochDay = floorDiv(localSecond, SECONDS_PER_DAY);
- int secsOfDay = (int)floorMod(localSecond, SECONDS_PER_DAY);
- LocalDate date = LocalDate.ofEpochDay(localEpochDay);
- LocalTime time = LocalTime.ofSecondOfDay(secsOfDay); // ignore nano
- return new LocalDateTime(date, time);
- }
-
- /**
- * Constructor.
- *
- * @param date the date part of the date-time, validated not null
- * @param time the time part of the date-time, validated not null
- */
- private LocalDateTime(LocalDate date, LocalTime time) {
- this.date = date;
- this.time = time;
- }
-
- /**
- * Returns a copy of this date-time with the new date and time, checking
- * to see if a new object is in fact required.
- *
- * @param newDate the date of the new date-time, not null
- * @param newTime the time of the new date-time, not null
- * @return the date-time, not null
- */
- private LocalDateTime with(LocalDate newDate, LocalTime newTime) {
- if (date == newDate && time == newTime) {
- return this;
- }
- return new LocalDateTime(newDate, newTime);
- }
-
- /**
- * Gets the {@code LocalDate} part of this date-time.
- * <p>
- * This returns a {@code LocalDate} with the same year, month and day
- * as this date-time.
- *
- * @return the date part of this date-time, not null
- */
- public LocalDate getDate() {
- return date;
- }
-
- /**
- * Gets the year field.
- * <p>
- * This method returns the primitive {@code int} value for the year.
- * <p>
- * The year returned by this method is proleptic as per {@code get(YEAR)}.
- * To obtain the year-of-era, use {@code get(YEAR_OF_ERA}.
- *
- * @return the year, from MIN_YEAR to MAX_YEAR
- */
- public int getYear() {
- return date.getYear();
- }
-
- /**
- * Gets the month-of-year field as an int from 1 to 12.
- *
- * @return the month-of-year
- */
- public int getMonth() {
- return date.getMonth();
- }
-
- /**
- * Gets the day-of-month field.
- * <p>
- * This method returns the primitive {@code int} value for the day-of-month.
- *
- * @return the day-of-month, from 1 to 31
- */
- public int getDayOfMonth() {
- return date.getDayOfMonth();
- }
-
- /**
- * Gets the day-of-week field, which is an integer from 1 to 7.
- *
- * @return the day-of-week, from 1 to 7
- */
- public int getDayOfWeek() {
- return date.getDayOfWeek();
- }
-
- /**
- * Gets the {@code LocalTime} part of this date-time.
- * <p>
- * This returns a {@code LocalTime} with the same hour, minute, second and
- * nanosecond as this date-time.
- *
- * @return the time part of this date-time, not null
- */
- public LocalTime getTime() {
- return time;
- }
-
- /**
- * Gets the hour-of-day field.
- *
- * @return the hour-of-day, from 0 to 23
- */
- public int getHour() {
- return time.getHour();
- }
-
- /**
- * Gets the minute-of-hour field.
- *
- * @return the minute-of-hour, from 0 to 59
- */
- public int getMinute() {
- return time.getMinute();
- }
-
- /**
- * Gets the second-of-minute field.
- *
- * @return the second-of-minute, from 0 to 59
- */
- public int getSecond() {
- return time.getSecond();
- }
-
- /**
- * Converts this date-time to the number of seconds from the epoch
- * of 1970-01-01T00:00:00Z.
- * <p>
- * This combines this local date-time and the specified offset to calculate the
- * epoch-second value, which is the number of elapsed seconds from 1970-01-01T00:00:00Z.
- * Instants on the time-line after the epoch are positive, earlier are negative.
- * <p>
- * This default implementation calculates from the epoch-day of the date and the
- * second-of-day of the time.
- *
- * @param offset the offset to use for the conversion, not null
- * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z
- */
- public long toEpochSecond(ZoneOffset offset) {
- Objects.requireNonNull(offset, "offset");
- long epochDay = getDate().toEpochDay();
- long secs = epochDay * 86400 + getTime().toSecondOfDay();
- secs -= offset.getTotalSeconds();
- return secs;
- }
-
- /**
- * Returns a copy of this {@code LocalDateTime} with the specified period in days added.
- * <p>
- * This method adds the specified amount to the days field incrementing the
- * month and year fields as necessary to ensure the result remains valid.
- * The result is only invalid if the maximum/minimum year is exceeded.
- * <p>
- * For example, 2008-12-31 plus one day would result in 2009-01-01.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param days the days to add, may be negative
- * @return a {@code LocalDateTime} based on this date-time with the days added, not null
- * @throws DateTimeException if the result exceeds the supported date range
- */
- public LocalDateTime plusDays(long days) {
- LocalDate newDate = date.plusDays(days);
- return with(newDate, time);
- }
-
- /**
- * Returns a copy of this {@code LocalDateTime} with the specified period in seconds added.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param seconds the seconds to add, may be negative
- * @return a {@code LocalDateTime} based on this date-time with the seconds added, not null
- * @throws DateTimeException if the result exceeds the supported date range
- */
- public LocalDateTime plusSeconds(long seconds) {
- return plusWithOverflow(date, 0, 0, seconds, 1);
- }
-
- /**
- * Returns a copy of this {@code LocalDateTime} with the specified period added.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param newDate the new date to base the calculation on, not null
- * @param hours the hours to add, may be negative
- * @param minutes the minutes to add, may be negative
- * @param seconds the seconds to add, may be negative
- * @param nanos the nanos to add, may be negative
- * @param sign the sign to determine add or subtract
- * @return the combined result, not null
- */
- private LocalDateTime plusWithOverflow(LocalDate newDate, long hours, long minutes, long seconds, int sign) {
- if ((hours | minutes | seconds) == 0) {
- return with(newDate, time);
- }
- long totDays = seconds / SECONDS_PER_DAY + // max/24*60*60
- minutes / MINUTES_PER_DAY + // max/24*60
- hours / HOURS_PER_DAY; // max/24
- totDays *= sign; // total max*0.4237...
- long totSecs = (seconds % SECONDS_PER_DAY) +
- (minutes % MINUTES_PER_DAY) * SECONDS_PER_MINUTE +
- (hours % HOURS_PER_DAY) * SECONDS_PER_HOUR;
- long curSoD = time.toSecondOfDay();
- totSecs = totSecs * sign + curSoD; // total 432000000000000
- totDays += floorDiv(totSecs, SECONDS_PER_DAY);
-
- int newSoD = (int)floorMod(totSecs, SECONDS_PER_DAY);
- LocalTime newTime = (newSoD == curSoD ? time : LocalTime.ofSecondOfDay(newSoD));
- return with(newDate.plusDays(totDays), newTime);
- }
-
- /**
- * Compares this date-time to another date-time.
- * <p>
- * The comparison is primarily based on the date-time, from earliest to latest.
- * It is "consistent with equals", as defined by {@link Comparable}.
- * <p>
- * If all the date-times being compared are instances of {@code LocalDateTime},
- * then the comparison will be entirely based on the date-time.
- * If some dates being compared are in different chronologies, then the
- * chronology is also considered, see {@link ChronoLocalDateTime#compareTo}.
- *
- * @param other the other date-time to compare to, not null
- * @return the comparator value, negative if less, positive if greater
- */
- public int compareTo(LocalDateTime other) {
- int cmp = date.compareTo(other.getDate());
- if (cmp == 0) {
- cmp = time.compareTo(other.getTime());
- }
- return cmp;
- }
-
- /**
- * Checks if this date-time is equal to another date-time.
- * <p>
- * Compares this {@code LocalDateTime} with another ensuring that the date-time is the same.
- * Only objects of type {@code LocalDateTime} are compared, other types return false.
- *
- * @param obj the object to check, null returns false
- * @return true if this is equal to the other date-time
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LocalDateTime) {
- LocalDateTime other = (LocalDateTime) obj;
- return date.equals(other.date) && time.equals(other.time);
- }
- return false;
- }
-
- /**
- * A hash code for this date-time.
- *
- * @return a suitable hash code
- */
- @Override
- public int hashCode() {
- return date.hashCode() ^ time.hashCode();
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/LocalTime.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,388 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-import static build.tools.tzdb.ChronoField.HOUR_OF_DAY;
-import static build.tools.tzdb.ChronoField.MINUTE_OF_HOUR;
-import static build.tools.tzdb.ChronoField.SECOND_OF_MINUTE;
-import static build.tools.tzdb.ChronoField.SECOND_OF_DAY;
-
-import java.util.Objects;
-
-/**
- * A time without time-zone in the ISO-8601 calendar system,
- * such as {@code 10:15:30}.
- *
- */
-final class LocalTime {
-
- /**
- * The minimum supported {@code LocalTime}, '00:00'.
- * This is the time of midnight at the start of the day.
- */
- public static final LocalTime MIN;
- /**
- * The minimum supported {@code LocalTime}, '23:59:59.999999999'.
- * This is the time just before midnight at the end of the day.
- */
- public static final LocalTime MAX;
- /**
- * The time of midnight at the start of the day, '00:00'.
- */
- public static final LocalTime MIDNIGHT;
- /**
- * The time of noon in the middle of the day, '12:00'.
- */
- public static final LocalTime NOON;
- /**
- * Constants for the local time of each hour.
- */
- private static final LocalTime[] HOURS = new LocalTime[24];
- static {
- for (int i = 0; i < HOURS.length; i++) {
- HOURS[i] = new LocalTime(i, 0, 0);
- }
- MIDNIGHT = HOURS[0];
- NOON = HOURS[12];
- MIN = HOURS[0];
- MAX = new LocalTime(23, 59, 59);
- }
-
- /**
- * Hours per day.
- */
- static final int HOURS_PER_DAY = 24;
- /**
- * Minutes per hour.
- */
- static final int MINUTES_PER_HOUR = 60;
- /**
- * Minutes per day.
- */
- static final int MINUTES_PER_DAY = MINUTES_PER_HOUR * HOURS_PER_DAY;
- /**
- * Seconds per minute.
- */
- static final int SECONDS_PER_MINUTE = 60;
- /**
- * Seconds per hour.
- */
- static final int SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
- /**
- * Seconds per day.
- */
- static final int SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY;
- /**
- * Milliseconds per day.
- */
- static final long MILLIS_PER_DAY = SECONDS_PER_DAY * 1000L;
- /**
- * Microseconds per day.
- */
- static final long MICROS_PER_DAY = SECONDS_PER_DAY * 1000_000L;
-
- /**
- * The hour.
- */
- private final byte hour;
- /**
- * The minute.
- */
- private final byte minute;
- /**
- * The second.
- */
- private final byte second;
-
- /**
- * Obtains an instance of {@code LocalTime} from an hour and minute.
- * <p>
- * The second and nanosecond fields will be set to zero by this factory method.
- * <p>
- * This factory may return a cached value, but applications must not rely on this.
- *
- * @param hour the hour-of-day to represent, from 0 to 23
- * @param minute the minute-of-hour to represent, from 0 to 59
- * @return the local time, not null
- * @throws DateTimeException if the value of any field is out of range
- */
- public static LocalTime of(int hour, int minute) {
- HOUR_OF_DAY.checkValidValue(hour);
- if (minute == 0) {
- return HOURS[hour]; // for performance
- }
- MINUTE_OF_HOUR.checkValidValue(minute);
- return new LocalTime(hour, minute, 0);
- }
-
- /**
- * Obtains an instance of {@code LocalTime} from an hour, minute and second.
- * <p>
- * The nanosecond field will be set to zero by this factory method.
- * <p>
- * This factory may return a cached value, but applications must not rely on this.
- *
- * @param hour the hour-of-day to represent, from 0 to 23
- * @param minute the minute-of-hour to represent, from 0 to 59
- * @param second the second-of-minute to represent, from 0 to 59
- * @return the local time, not null
- * @throws DateTimeException if the value of any field is out of range
- */
- public static LocalTime of(int hour, int minute, int second) {
- HOUR_OF_DAY.checkValidValue(hour);
- if ((minute | second) == 0) {
- return HOURS[hour]; // for performance
- }
- MINUTE_OF_HOUR.checkValidValue(minute);
- SECOND_OF_MINUTE.checkValidValue(second);
- return new LocalTime(hour, minute, second);
- }
-
- /**
- * Obtains an instance of {@code LocalTime} from a second-of-day value.
- * <p>
- * This factory may return a cached value, but applications must not rely on this.
- *
- * @param secondOfDay the second-of-day, from {@code 0} to {@code 24 * 60 * 60 - 1}
- * @return the local time, not null
- * @throws DateTimeException if the second-of-day value is invalid
- */
- public static LocalTime ofSecondOfDay(int secondOfDay) {
- SECOND_OF_DAY.checkValidValue(secondOfDay);
- int hours = secondOfDay / SECONDS_PER_HOUR;
- secondOfDay -= hours * SECONDS_PER_HOUR;
- int minutes = secondOfDay / SECONDS_PER_MINUTE;
- secondOfDay -= minutes * SECONDS_PER_MINUTE;
- return create(hours, minutes, secondOfDay);
- }
-
-
- /**
- * Creates a local time from the hour, minute, second and nanosecond fields.
- * <p>
- * This factory may return a cached value, but applications must not rely on this.
- *
- * @param hour the hour-of-day to represent, validated from 0 to 23
- * @param minute the minute-of-hour to represent, validated from 0 to 59
- * @param second the second-of-minute to represent, validated from 0 to 59
- * @return the local time, not null
- */
- private static LocalTime create(int hour, int minute, int second) {
- if ((minute | second) == 0) {
- return HOURS[hour];
- }
- return new LocalTime(hour, minute, second);
- }
-
- /**
- * Constructor, previously validated.
- *
- * @param hour the hour-of-day to represent, validated from 0 to 23
- * @param minute the minute-of-hour to represent, validated from 0 to 59
- * @param second the second-of-minute to represent, validated from 0 to 59
- */
- private LocalTime(int hour, int minute, int second) {
- this.hour = (byte) hour;
- this.minute = (byte) minute;
- this.second = (byte) second;
- }
-
- /**
- * Gets the hour-of-day field.
- *
- * @return the hour-of-day, from 0 to 23
- */
- public int getHour() {
- return hour;
- }
-
- /**
- * Gets the minute-of-hour field.
- *
- * @return the minute-of-hour, from 0 to 59
- */
- public int getMinute() {
- return minute;
- }
-
- /**
- * Gets the second-of-minute field.
- *
- * @return the second-of-minute, from 0 to 59
- */
- public int getSecond() {
- return second;
- }
-
- /**
- * Returns a copy of this {@code LocalTime} with the specified period in seconds added.
- * <p>
- * This adds the specified number of seconds to this time, returning a new time.
- * The calculation wraps around midnight.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param secondstoAdd the seconds to add, may be negative
- * @return a {@code LocalTime} based on this time with the seconds added, not null
- */
- public LocalTime plusSeconds(long secondstoAdd) {
- if (secondstoAdd == 0) {
- return this;
- }
- int sofd = hour * SECONDS_PER_HOUR +
- minute * SECONDS_PER_MINUTE + second;
- int newSofd = ((int) (secondstoAdd % SECONDS_PER_DAY) + sofd + SECONDS_PER_DAY) % SECONDS_PER_DAY;
- if (sofd == newSofd) {
- return this;
- }
- int newHour = newSofd / SECONDS_PER_HOUR;
- int newMinute = (newSofd / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
- int newSecond = newSofd % SECONDS_PER_MINUTE;
- return create(newHour, newMinute, newSecond);
- }
-
- /**
- * Returns a copy of this {@code LocalTime} with the specified period in seconds subtracted.
- * <p>
- * This subtracts the specified number of seconds from this time, returning a new time.
- * The calculation wraps around midnight.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param secondsToSubtract the seconds to subtract, may be negative
- * @return a {@code LocalTime} based on this time with the seconds subtracted, not null
- */
- public LocalTime minusSeconds(long secondsToSubtract) {
- return plusSeconds(-(secondsToSubtract % SECONDS_PER_DAY));
- }
-
- /**
- * Extracts the time as seconds of day,
- * from {@code 0} to {@code 24 * 60 * 60 - 1}.
- *
- * @return the second-of-day equivalent to this time
- */
- public int toSecondOfDay() {
- int total = hour * SECONDS_PER_HOUR;
- total += minute * SECONDS_PER_MINUTE;
- total += second;
- return total;
- }
-
- /**
- * Compares this {@code LocalTime} to another time.
- * <p>
- * 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}.
- *
- * @param other the other time to compare to, not null
- * @return the comparator value, negative if less, positive if greater
- * @throws NullPointerException if {@code other} is null
- */
- public int compareTo(LocalTime other) {
- int cmp = Integer.compare(hour, other.hour);
- if (cmp == 0) {
- cmp = Integer.compare(minute, other.minute);
- if (cmp == 0) {
- cmp = Integer.compare(second, other.second);
- }
- }
- return cmp;
- }
-
- /**
- * Checks if this time is equal to another time.
- * <p>
- * The comparison is based on the time-line position of the time within a day.
- * <p>
- * Only objects of type {@code LocalTime} are compared, other types return false.
- * To compare the date of two {@code TemporalAccessor} instances, use
- * {@link ChronoField#NANO_OF_DAY} as a comparator.
- *
- * @param obj the object to check, null returns false
- * @return true if this is equal to the other time
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LocalTime) {
- LocalTime other = (LocalTime) obj;
- return hour == other.hour && minute == other.minute &&
- second == other.second;
- }
- return false;
- }
-
- /**
- * A hash code for this time.
- *
- * @return a suitable hash code
- */
- @Override
- public int hashCode() {
- long sod = toSecondOfDay();
- return (int) (sod ^ (sod >>> 32));
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/TimeDefinition.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-import java.util.Objects;
-
-/**
- * A definition of the way a local time can be converted to the actual
- * transition date-time.
- * <p>
- * Time zone rules are expressed in one of three ways:
- * <p><ul>
- * <li>Relative to UTC</li>
- * <li>Relative to the standard offset in force</li>
- * <li>Relative to the wall offset (what you would see on a clock on the wall)</li>
- * </ul><p>
- */
-public enum TimeDefinition {
- /** The local date-time is expressed in terms of the UTC offset. */
- UTC,
- /** The local date-time is expressed in terms of the wall offset. */
- WALL,
- /** The local date-time is expressed in terms of the standard offset. */
- STANDARD;
-
- /**
- * Converts the specified local date-time to the local date-time actually
- * seen on a wall clock.
- * <p>
- * This method converts using the type of this enum.
- * The output is defined relative to the 'before' offset of the transition.
- * <p>
- * The UTC type uses the UTC offset.
- * The STANDARD type uses the standard offset.
- * The WALL type returns the input date-time.
- * The result is intended for use with the wall-offset.
- *
- * @param dateTime the local date-time, not null
- * @param standardOffset the standard offset, not null
- * @param wallOffset the wall offset, not null
- * @return the date-time relative to the wall/before offset, not null
- */
- public LocalDateTime createDateTime(LocalDateTime dateTime, ZoneOffset standardOffset, ZoneOffset wallOffset) {
- switch (this) {
- case UTC: {
- int difference = wallOffset.getTotalSeconds() - ZoneOffset.UTC.getTotalSeconds();
- return dateTime.plusSeconds(difference);
- }
- case STANDARD: {
- int difference = wallOffset.getTotalSeconds() - standardOffset.getTotalSeconds();
- return dateTime.plusSeconds(difference);
- }
- default: // WALL
- return dateTime;
- }
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesCompiler.java Fri Jun 27 14:21:31 2014 -0700
@@ -56,8 +56,6 @@
*/
package build.tools.tzdb;
-import static build.tools.tzdb.Utils.*;
-
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.nio.charset.StandardCharsets;
@@ -179,15 +177,41 @@
System.exit(1);
System.err.println("Source directory does not contain file: VERSION");
}
+
+ // load source files
printVerbose("Compiling TZDB version " + version);
- // parse source files
- for (Path file : srcFiles) {
- printVerbose("Parsing file: " + file);
- parseFile(file);
- }
+ TzdbZoneRulesProvider provider = new TzdbZoneRulesProvider(srcFiles);
+
// build zone rules
printVerbose("Building rules");
- buildZoneRules();
+
+ // Build the rules, zones and links into real zones.
+ SortedMap<String, ZoneRules> builtZones = new TreeMap<>();
+
+ // build zones
+ for (String zoneId : provider.getZoneIds()) {
+ printVerbose("Building zone " + zoneId);
+ builtZones.put(zoneId, provider.getZoneRules(zoneId));
+ }
+
+ // build aliases
+ Map<String, String> links = provider.getAliasMap();
+ for (String aliasId : links.keySet()) {
+ String realId = links.get(aliasId);
+ printVerbose("Linking alias " + aliasId + " to " + realId);
+ ZoneRules realRules = builtZones.get(realId);
+ if (realRules == null) {
+ realId = links.get(realId); // try again (handle alias liked to alias)
+ printVerbose("Relinking alias " + aliasId + " to " + realId);
+ realRules = builtZones.get(realId);
+ if (realRules == null) {
+ throw new IllegalArgumentException("Alias '" + aliasId + "' links to invalid zone '" + realId);
+ }
+ links.put(aliasId, realId);
+ }
+ builtZones.put(aliasId, realRules);
+ }
+
// output to file
printVerbose("Outputting tzdb file: " + dstFile);
outputFile(dstFile, version, builtZones, links);
@@ -269,361 +293,13 @@
}
}
- private static final Pattern YEAR = Pattern.compile("(?i)(?<min>min)|(?<max>max)|(?<only>only)|(?<year>[0-9]+)");
- private static final Pattern MONTH = Pattern.compile("(?i)(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)");
- private static final Matcher DOW = Pattern.compile("(?i)(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)").matcher("");
- private static final Matcher TIME = Pattern.compile("(?<neg>-)?+(?<hour>[0-9]{1,2})(:(?<minute>[0-5][0-9]))?+(:(?<second>[0-5][0-9]))?+").matcher("");
-
- /** The TZDB rules. */
- private final Map<String, List<TZDBRule>> rules = new HashMap<>();
-
- /** The TZDB zones. */
- private final Map<String, List<TZDBZone>> zones = new HashMap<>();
-
- /** The TZDB links. */
- private final Map<String, String> links = new HashMap<>();
-
- /** The built zones. */
- private final SortedMap<String, ZoneRules> builtZones = new TreeMap<>();
-
/** Whether to output verbose messages. */
private boolean verbose;
/**
* private contructor
*/
- private TzdbZoneRulesCompiler() {
- }
-
- /**
- * Parses a source file.
- *
- * @param file the file being read, not null
- * @throws Exception if an error occurs
- */
- private void parseFile(Path file) throws Exception {
- int lineNumber = 1;
- String line = null;
- try {
- List<String> lines = Files.readAllLines(file, StandardCharsets.ISO_8859_1);
- List<TZDBZone> openZone = null;
- for (; lineNumber < lines.size(); lineNumber++) {
- line = lines.get(lineNumber);
- int index = line.indexOf('#'); // remove comments (doesn't handle # in quotes)
- if (index >= 0) {
- line = line.substring(0, index);
- }
- if (line.trim().length() == 0) { // ignore blank lines
- continue;
- }
- Scanner s = new Scanner(line);
- if (openZone != null && Character.isWhitespace(line.charAt(0)) && s.hasNext()) {
- if (parseZoneLine(s, openZone)) {
- openZone = null;
- }
- } else {
- if (s.hasNext()) {
- String first = s.next();
- if (first.equals("Zone")) {
- openZone = new ArrayList<>();
- try {
- zones.put(s.next(), openZone);
- if (parseZoneLine(s, openZone)) {
- openZone = null;
- }
- } catch (NoSuchElementException x) {
- printVerbose("Invalid Zone line in file: " + file + ", line: " + line);
- throw new IllegalArgumentException("Invalid Zone line");
- }
- } else {
- openZone = null;
- if (first.equals("Rule")) {
- try {
- parseRuleLine(s);
- } catch (NoSuchElementException x) {
- printVerbose("Invalid Rule line in file: " + file + ", line: " + line);
- throw new IllegalArgumentException("Invalid Rule line");
- }
- } else if (first.equals("Link")) {
- try {
- String realId = s.next();
- String aliasId = s.next();
- links.put(aliasId, realId);
- } catch (NoSuchElementException x) {
- printVerbose("Invalid Link line in file: " + file + ", line: " + line);
- throw new IllegalArgumentException("Invalid Link line");
- }
-
- } else {
- throw new IllegalArgumentException("Unknown line");
- }
- }
- }
- }
- }
- } catch (Exception ex) {
- throw new Exception("Failed while parsing file '" + file + "' on line " + lineNumber + " '" + line + "'", ex);
- }
- }
-
- /**
- * Parses a Rule line.
- *
- * @param s the line scanner, not null
- */
- private void parseRuleLine(Scanner s) {
- TZDBRule rule = new TZDBRule();
- String name = s.next();
- if (rules.containsKey(name) == false) {
- rules.put(name, new ArrayList<TZDBRule>());
- }
- rules.get(name).add(rule);
- rule.startYear = parseYear(s, 0);
- rule.endYear = parseYear(s, rule.startYear);
- if (rule.startYear > rule.endYear) {
- throw new IllegalArgumentException("Year order invalid: " + rule.startYear + " > " + rule.endYear);
- }
- parseOptional(s.next()); // type is unused
- parseMonthDayTime(s, rule);
- rule.savingsAmount = parsePeriod(s.next());
- rule.text = parseOptional(s.next());
- }
-
- /**
- * Parses a Zone line.
- *
- * @param s the line scanner, not null
- * @return true if the zone is complete
- */
- private boolean parseZoneLine(Scanner s, List<TZDBZone> zoneList) {
- TZDBZone zone = new TZDBZone();
- zoneList.add(zone);
- zone.standardOffset = parseOffset(s.next());
- String savingsRule = parseOptional(s.next());
- if (savingsRule == null) {
- zone.fixedSavingsSecs = 0;
- zone.savingsRule = null;
- } else {
- try {
- zone.fixedSavingsSecs = parsePeriod(savingsRule);
- zone.savingsRule = null;
- } catch (Exception ex) {
- zone.fixedSavingsSecs = null;
- zone.savingsRule = savingsRule;
- }
- }
- zone.text = s.next();
- if (s.hasNext()) {
- zone.year = Integer.parseInt(s.next());
- if (s.hasNext()) {
- parseMonthDayTime(s, zone);
- }
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Parses a Rule line.
- *
- * @param s the line scanner, not null
- * @param mdt the object to parse into, not null
- */
- private void parseMonthDayTime(Scanner s, TZDBMonthDayTime mdt) {
- mdt.month = parseMonth(s);
- if (s.hasNext()) {
- String dayRule = s.next();
- if (dayRule.startsWith("last")) {
- mdt.dayOfMonth = -1;
- mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(4));
- mdt.adjustForwards = false;
- } else {
- int index = dayRule.indexOf(">=");
- if (index > 0) {
- mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
- dayRule = dayRule.substring(index + 2);
- } else {
- index = dayRule.indexOf("<=");
- if (index > 0) {
- mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
- mdt.adjustForwards = false;
- dayRule = dayRule.substring(index + 2);
- }
- }
- mdt.dayOfMonth = Integer.parseInt(dayRule);
- }
- if (s.hasNext()) {
- String timeStr = s.next();
- int secsOfDay = parseSecs(timeStr);
- if (secsOfDay == 86400) {
- mdt.endOfDay = true;
- secsOfDay = 0;
- }
- LocalTime time = LocalTime.ofSecondOfDay(secsOfDay);
- mdt.time = time;
- mdt.timeDefinition = parseTimeDefinition(timeStr.charAt(timeStr.length() - 1));
- }
- }
- }
-
- private int parseYear(Scanner s, int defaultYear) {
- if (s.hasNext(YEAR)) {
- s.next(YEAR);
- MatchResult mr = s.match();
- if (mr.group(1) != null) {
- return 1900; // systemv has min
- } else if (mr.group(2) != null) {
- return YEAR_MAX_VALUE;
- } else if (mr.group(3) != null) {
- return defaultYear;
- }
- return Integer.parseInt(mr.group(4));
- /*
- if (mr.group("min") != null) {
- //return YEAR_MIN_VALUE;
- return 1900; // systemv has min
- } else if (mr.group("max") != null) {
- return YEAR_MAX_VALUE;
- } else if (mr.group("only") != null) {
- return defaultYear;
- }
- return Integer.parseInt(mr.group("year"));
- */
- }
- throw new IllegalArgumentException("Unknown year: " + s.next());
- }
-
- private int parseMonth(Scanner s) {
- if (s.hasNext(MONTH)) {
- s.next(MONTH);
- for (int moy = 1; moy < 13; moy++) {
- if (s.match().group(moy) != null) {
- return moy;
- }
- }
- }
- throw new IllegalArgumentException("Unknown month: " + s.next());
- }
-
- private int parseDayOfWeek(String str) {
- if (DOW.reset(str).matches()) {
- for (int dow = 1; dow < 8; dow++) {
- if (DOW.group(dow) != null) {
- return dow;
- }
- }
- }
- throw new IllegalArgumentException("Unknown day-of-week: " + str);
- }
-
- private String parseOptional(String str) {
- return str.equals("-") ? null : str;
- }
-
- private int parseSecs(String str) {
- if (str.equals("-")) {
- return 0;
- }
- try {
- if (TIME.reset(str).find()) {
- int secs = Integer.parseInt(TIME.group("hour")) * 60 * 60;
- if (TIME.group("minute") != null) {
- secs += Integer.parseInt(TIME.group("minute")) * 60;
- }
- if (TIME.group("second") != null) {
- secs += Integer.parseInt(TIME.group("second"));
- }
- if (TIME.group("neg") != null) {
- secs = -secs;
- }
- return secs;
- }
- } catch (NumberFormatException x) {}
- throw new IllegalArgumentException(str);
- }
-
- private ZoneOffset parseOffset(String str) {
- int secs = parseSecs(str);
- return ZoneOffset.ofTotalSeconds(secs);
- }
-
- private int parsePeriod(String str) {
- return parseSecs(str);
- }
-
- private TimeDefinition parseTimeDefinition(char c) {
- switch (c) {
- case 's':
- case 'S':
- // standard time
- return TimeDefinition.STANDARD;
- case 'u':
- case 'U':
- case 'g':
- case 'G':
- case 'z':
- case 'Z':
- // UTC
- return TimeDefinition.UTC;
- case 'w':
- case 'W':
- default:
- // wall time
- return TimeDefinition.WALL;
- }
- }
-
- /**
- * Build the rules, zones and links into real zones.
- *
- * @throws Exception if an error occurs
- */
- private void buildZoneRules() throws Exception {
- // build zones
- for (String zoneId : zones.keySet()) {
- printVerbose("Building zone " + zoneId);
- List<TZDBZone> tzdbZones = zones.get(zoneId);
- ZoneRulesBuilder bld = new ZoneRulesBuilder();
- for (TZDBZone tzdbZone : tzdbZones) {
- bld = tzdbZone.addToBuilder(bld, rules);
- }
- builtZones.put(zoneId, bld.toRules(zoneId));
- }
-
- // build aliases
- for (String aliasId : links.keySet()) {
- String realId = links.get(aliasId);
- printVerbose("Linking alias " + aliasId + " to " + realId);
- ZoneRules realRules = builtZones.get(realId);
- if (realRules == null) {
- realId = links.get(realId); // try again (handle alias liked to alias)
- printVerbose("Relinking alias " + aliasId + " to " + realId);
- realRules = builtZones.get(realId);
- if (realRules == null) {
- throw new IllegalArgumentException("Alias '" + aliasId + "' links to invalid zone '" + realId);
- }
- links.put(aliasId, realId);
- }
- builtZones.put(aliasId, realRules);
- }
- // remove UTC and GMT
- // builtZones.remove("UTC");
- // builtZones.remove("GMT");
- // builtZones.remove("GMT0");
- builtZones.remove("GMT+0");
- builtZones.remove("GMT-0");
- links.remove("GMT+0");
- links.remove("GMT-0");
- // remove ROC, which is not supported in j.u.tz
- builtZones.remove("ROC");
- links.remove("ROC");
- // remove EST, HST and MST. They are supported via
- // the short-id mapping
- builtZones.remove("EST");
- builtZones.remove("HST");
- builtZones.remove("MST");
- }
+ private TzdbZoneRulesCompiler() {}
/**
* Prints a verbose message.
@@ -635,109 +311,4 @@
System.out.println(message);
}
}
-
- /**
- * Class representing a month-day-time in the TZDB file.
- */
- abstract class TZDBMonthDayTime {
- /** The month of the cutover. */
- int month = 1;
- /** The day-of-month of the cutover. */
- int dayOfMonth = 1;
- /** Whether to adjust forwards. */
- boolean adjustForwards = true;
- /** The day-of-week of the cutover. */
- int dayOfWeek = -1;
- /** The time of the cutover. */
- LocalTime time = LocalTime.MIDNIGHT;
- /** Whether this is midnight end of day. */
- boolean endOfDay;
- /** The time of the cutover. */
- TimeDefinition timeDefinition = TimeDefinition.WALL;
- void adjustToFowards(int year) {
- if (adjustForwards == false && dayOfMonth > 0) {
- LocalDate adjustedDate = LocalDate.of(year, month, dayOfMonth).minusDays(6);
- dayOfMonth = adjustedDate.getDayOfMonth();
- month = adjustedDate.getMonth();
- adjustForwards = true;
- }
- }
- }
-
- /**
- * Class representing a rule line in the TZDB file.
- */
- final class TZDBRule extends TZDBMonthDayTime {
- /** The start year. */
- int startYear;
- /** The end year. */
- int endYear;
- /** The amount of savings. */
- int savingsAmount;
- /** The text name of the zone. */
- String text;
-
- void addToBuilder(ZoneRulesBuilder bld) {
- adjustToFowards(2004); // irrelevant, treat as leap year
- bld.addRuleToWindow(startYear, endYear, month, dayOfMonth, dayOfWeek, time, endOfDay, timeDefinition, savingsAmount);
- }
- }
-
- /**
- * Class representing a linked set of zone lines in the TZDB file.
- */
- final class TZDBZone extends TZDBMonthDayTime {
- /** The standard offset. */
- ZoneOffset standardOffset;
- /** The fixed savings amount. */
- Integer fixedSavingsSecs;
- /** The savings rule. */
- String savingsRule;
- /** The text name of the zone. */
- String text;
- /** The year of the cutover. */
- int year = YEAR_MAX_VALUE;
-
- ZoneRulesBuilder addToBuilder(ZoneRulesBuilder bld, Map<String, List<TZDBRule>> rules) {
- if (year != YEAR_MAX_VALUE) {
- bld.addWindow(standardOffset, toDateTime(year), timeDefinition);
- } else {
- bld.addWindowForever(standardOffset);
- }
- if (fixedSavingsSecs != null) {
- bld.setFixedSavingsToWindow(fixedSavingsSecs);
- } else {
- List<TZDBRule> tzdbRules = rules.get(savingsRule);
- if (tzdbRules == null) {
- throw new IllegalArgumentException("Rule not found: " + savingsRule);
- }
- for (TZDBRule tzdbRule : tzdbRules) {
- tzdbRule.addToBuilder(bld);
- }
- }
- return bld;
- }
-
- private LocalDateTime toDateTime(int year) {
- adjustToFowards(year);
- LocalDate date;
- if (dayOfMonth == -1) {
- dayOfMonth = lengthOfMonth(month, isLeapYear(year));
- date = LocalDate.of(year, month, dayOfMonth);
- if (dayOfWeek != -1) {
- date = previousOrSame(date, dayOfWeek);
- }
- } else {
- date = LocalDate.of(year, month, dayOfMonth);
- if (dayOfWeek != -1) {
- date = nextOrSame(date, dayOfWeek);
- }
- }
- LocalDateTime ldt = LocalDateTime.of(date, time);
- if (endOfDay) {
- ldt = ldt.plusDays(1);
- }
- return ldt;
- }
- }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java Fri Jun 27 14:21:31 2014 -0700
@@ -0,0 +1,843 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+package build.tools.tzdb;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.NavigableMap;
+import java.util.Objects;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.time.*;
+import java.time.Year;
+import java.time.chrono.IsoChronology;
+import java.time.temporal.TemporalAdjusters;
+import java.time.zone.ZoneOffsetTransition;
+import java.time.zone.ZoneOffsetTransitionRule;
+import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition;
+import java.time.zone.ZoneRulesException;
+
+/**
+ * Compile and build time-zone rules from IANA timezone data
+ *
+ * @author Xueming Shen
+ * @author Stephen Colebourne
+ * @author Michael Nascimento Santos
+ *
+ * @since 1.9
+ */
+
+class TzdbZoneRulesProvider {
+
+ /**
+ * Creates an instance.
+ *
+ * @throws ZoneRulesException if unable to load
+ */
+ public TzdbZoneRulesProvider(List<Path> files) {
+ try {
+ load(files);
+ } catch (Exception ex) {
+ throw new ZoneRulesException("Unable to load TZDB time-zone rules", ex);
+ }
+ }
+
+ public Set<String> getZoneIds() {
+ return new TreeSet(regionIds);
+ }
+
+ public Map<String, String> getAliasMap() {
+ return links;
+ }
+
+ public ZoneRules getZoneRules(String zoneId) {
+ Object obj = zones.get(zoneId);
+ if (obj == null) {
+ String zoneId0 = zoneId;
+ if (links.containsKey(zoneId)) {
+ zoneId = links.get(zoneId);
+ obj = zones.get(zoneId);
+ }
+ if (obj == null) {
+ throw new ZoneRulesException("Unknown time-zone ID: " + zoneId0);
+ }
+ }
+ if (obj instanceof ZoneRules) {
+ return (ZoneRules)obj;
+ }
+ try {
+ ZoneRules zrules = buildRules(zoneId, (List<ZoneLine>)obj);
+ zones.put(zoneId, zrules);
+ return zrules;
+ } catch (Exception ex) {
+ throw new ZoneRulesException(
+ "Invalid binary time-zone data: TZDB:" + zoneId, ex);
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+
+ /**
+ * All the regions that are available.
+ */
+ private List<String> regionIds = new ArrayList<>(600);
+
+ /**
+ * Zone region to rules mapping
+ */
+ private final Map<String, Object> zones = new ConcurrentHashMap<>();
+
+ /**
+ * compatibility list
+ */
+ private static HashSet<String> excludedZones;
+ static {
+ // (1) exclude EST, HST and MST. They are supported
+ // via the short-id mapping
+ // (2) remove UTC and GMT
+ // (3) remove ROC, which is not supported in j.u.tz
+ excludedZones = new HashSet<>(10);
+ excludedZones.add("EST");
+ excludedZones.add("HST");
+ excludedZones.add("MST");
+ excludedZones.add("GMT+0");
+ excludedZones.add("GMT-0");
+ excludedZones.add("ROC");
+ }
+
+ private Map<String, String> links = new HashMap<>(150);
+ private Map<String, List<RuleLine>> rules = new HashMap<>(500);
+
+ private void load(List<Path> files) throws IOException {
+
+ for (Path file : files) {
+ List<ZoneLine> openZone = null;
+ try {
+ for (String line : Files.readAllLines(file, StandardCharsets.ISO_8859_1)) {
+ if (line.length() == 0 || line.charAt(0) == '#') {
+ continue;
+ }
+ //StringIterator itr = new StringIterator(line);
+ String[] tokens = split(line);
+ if (openZone != null && // continuing zone line
+ Character.isWhitespace(line.charAt(0)) &&
+ tokens.length > 0) {
+ ZoneLine zLine = new ZoneLine();
+ openZone.add(zLine);
+ if (zLine.parse(tokens, 0)) {
+ openZone = null;
+ }
+ continue;
+ }
+ if (line.startsWith("Zone")) { // parse Zone line
+ String name = tokens[1];
+ if (excludedZones.contains(name)){
+ continue;
+ }
+ if (zones.containsKey(name)) {
+ throw new IllegalArgumentException(
+ "Duplicated zone name in file: " + name +
+ ", line: [" + line + "]");
+ }
+ openZone = new ArrayList<>(10);
+ zones.put(name, openZone);
+ regionIds.add(name);
+ ZoneLine zLine = new ZoneLine();
+ openZone.add(zLine);
+ if (zLine.parse(tokens, 2)) {
+ openZone = null;
+ }
+ } else if (line.startsWith("Rule")) { // parse Rule line
+ String name = tokens[1];
+ if (!rules.containsKey(name)) {
+ rules.put(name, new ArrayList<RuleLine>(10));
+ }
+ rules.get(name).add(new RuleLine().parse(tokens));
+ } else if (line.startsWith("Link")) { // parse link line
+ if (tokens.length >= 3) {
+ String realId = tokens[1];
+ String aliasId = tokens[2];
+ if (excludedZones.contains(aliasId)){
+ continue;
+ }
+ links.put(aliasId, realId);
+ regionIds.add(aliasId);
+ } else {
+ throw new IllegalArgumentException(
+ "Invalid Link line in file" +
+ file + ", line: [" + line + "]");
+ }
+ } else {
+ // skip unknown line
+ }
+ }
+
+ } catch (Exception ex) {
+ throw new RuntimeException("Failed while processing file [" + file +
+ "]", ex);
+ }
+ }
+ }
+
+ private String[] split(String str) {
+ int off = 0;
+ int end = str.length();
+ ArrayList<String> list = new ArrayList<>(10);
+ while (off < end) {
+ char c = str.charAt(off);
+ if (c == '\t' || c == ' ') {
+ off++;
+ continue;
+ }
+ if (c == '#') { // comment
+ break;
+ }
+ int start = off;
+ while (off < end) {
+ c = str.charAt(off);
+ if (c == ' ' || c == '\t') {
+ break;
+ }
+ off++;
+ }
+ if (start != off) {
+ list.add(str.substring(start, off));
+ }
+ }
+ return list.toArray(new String[list.size()]);
+ }
+
+ /**
+ * Class representing a month-day-time in the TZDB file.
+ */
+ private static abstract class MonthDayTime {
+ /** The month of the cutover. */
+ Month month = Month.JANUARY;
+
+ /** The day-of-month of the cutover. */
+ int dayOfMonth = 1;
+
+ /** Whether to adjust forwards. */
+ boolean adjustForwards = true;
+
+ /** The day-of-week of the cutover. */
+ DayOfWeek dayOfWeek;
+
+ /** The time of the cutover, in second of day */
+ int secsOfDay = 0;
+
+ /** Whether this is midnight end of day. */
+ boolean endOfDay;
+ /** The time of the cutover. */
+
+ TimeDefinition timeDefinition = TimeDefinition.WALL;
+
+ void adjustToForwards(int year) {
+ if (adjustForwards == false && dayOfMonth > 0) {
+ // weekDay<=monthDay case, don't have it in tzdb data for now
+ LocalDate adjustedDate = LocalDate.of(year, month, dayOfMonth).minusDays(6);
+ dayOfMonth = adjustedDate.getDayOfMonth();
+ month = adjustedDate.getMonth();
+ adjustForwards = true;
+ }
+ }
+
+ LocalDateTime toDateTime(int year) {
+ LocalDate date;
+ if (dayOfMonth < 0) {
+ int monthLen = month.length(IsoChronology.INSTANCE.isLeapYear(year));
+ date = LocalDate.of(year, month, monthLen + 1 + dayOfMonth);
+ if (dayOfWeek != null) {
+ date = date.with(TemporalAdjusters.previousOrSame(dayOfWeek));
+ }
+ } else {
+ date = LocalDate.of(year, month, dayOfMonth);
+ if (dayOfWeek != null) {
+ date = date.with(TemporalAdjusters.nextOrSame(dayOfWeek));
+ }
+ }
+ if (endOfDay) {
+ date = date.plusDays(1);
+ }
+ return LocalDateTime.of(date, LocalTime.ofSecondOfDay(secsOfDay));
+ }
+
+ /**
+ * Parses the MonthDaytime segment of a tzdb line.
+ */
+ private void parse(String[] tokens, int off) {
+ month = parseMonth(tokens[off++]);
+ if (off < tokens.length) {
+ String dayRule = tokens[off++];
+ if (dayRule.startsWith("last")) {
+ dayOfMonth = -1;
+ dayOfWeek = parseDayOfWeek(dayRule.substring(4));
+ adjustForwards = false;
+ } else {
+ int index = dayRule.indexOf(">=");
+ if (index > 0) {
+ dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
+ dayRule = dayRule.substring(index + 2);
+ } else {
+ index = dayRule.indexOf("<=");
+ if (index > 0) {
+ dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
+ adjustForwards = false;
+ dayRule = dayRule.substring(index + 2);
+ }
+ }
+ dayOfMonth = Integer.parseInt(dayRule);
+ if (dayOfMonth < -28 || dayOfMonth > 31 || dayOfMonth == 0) {
+ throw new IllegalArgumentException(
+ "Day of month indicator must be between -28 and 31 inclusive excluding zero");
+ }
+ }
+ if (off < tokens.length) {
+ String timeStr = tokens[off++];
+ secsOfDay = parseSecs(timeStr);
+ if (secsOfDay == 86400) {
+ // time must be midnight when end of day flag is true
+ endOfDay = true;
+ secsOfDay = 0;
+ }
+ timeDefinition = parseTimeDefinition(timeStr.charAt(timeStr.length() - 1));
+ }
+ }
+ }
+
+ int parseYear(String year, int defaultYear) {
+ switch (year.toLowerCase()) {
+ case "min": return 1900;
+ case "max": return Year.MAX_VALUE;
+ case "only": return defaultYear;
+ }
+ return Integer.parseInt(year);
+ }
+
+ Month parseMonth(String mon) {
+ switch (mon) {
+ case "Jan": return Month.JANUARY;
+ case "Feb": return Month.FEBRUARY;
+ case "Mar": return Month.MARCH;
+ case "Apr": return Month.APRIL;
+ case "May": return Month.MAY;
+ case "Jun": return Month.JUNE;
+ case "Jul": return Month.JULY;
+ case "Aug": return Month.AUGUST;
+ case "Sep": return Month.SEPTEMBER;
+ case "Oct": return Month.OCTOBER;
+ case "Nov": return Month.NOVEMBER;
+ case "Dec": return Month.DECEMBER;
+ }
+ throw new IllegalArgumentException("Unknown month: " + mon);
+ }
+
+ DayOfWeek parseDayOfWeek(String dow) {
+ switch (dow) {
+ case "Mon": return DayOfWeek.MONDAY;
+ case "Tue": return DayOfWeek.TUESDAY;
+ case "Wed": return DayOfWeek.WEDNESDAY;
+ case "Thu": return DayOfWeek.THURSDAY;
+ case "Fri": return DayOfWeek.FRIDAY;
+ case "Sat": return DayOfWeek.SATURDAY;
+ case "Sun": return DayOfWeek.SUNDAY;
+ }
+ throw new IllegalArgumentException("Unknown day-of-week: " + dow);
+ }
+
+ String parseOptional(String str) {
+ return str.equals("-") ? null : str;
+ }
+
+ static final boolean isDigit(char c) {
+ return c >= '0' && c <= '9';
+ }
+
+ private int parseSecs(String time) {
+ if (time.equals("-")) {
+ return 0;
+ }
+ // faster hack
+ int secs = 0;
+ int sign = 1;
+ int off = 0;
+ int len = time.length();
+ if (off < len && time.charAt(off) == '-') {
+ sign = -1;
+ off++;
+ }
+ char c0, c1;
+ if (off < len && isDigit(c0 = time.charAt(off++))) {
+ int hour = c0 - '0';
+ if (off < len && isDigit(c1 = time.charAt(off))) {
+ hour = hour * 10 + c1 - '0';
+ off++;
+ }
+ secs = hour * 60 * 60;
+ if (off < len && time.charAt(off++) == ':') {
+ if (off + 1 < len &&
+ isDigit(c0 = time.charAt(off++)) &&
+ isDigit(c1 = time.charAt(off++))) {
+ // minutes
+ secs += ((c0 - '0') * 10 + c1 - '0') * 60;
+ if (off < len && time.charAt(off++) == ':') {
+ if (off + 1 < len &&
+ isDigit(c0 = time.charAt(off++)) &&
+ isDigit(c1 = time.charAt(off++))) {
+ // seconds
+ secs += ((c0 - '0') * 10 + c1 - '0');
+ }
+ }
+ }
+
+ }
+ return secs * sign;
+ }
+ throw new IllegalArgumentException("[" + time + "]");
+ }
+
+ int parseOffset(String str) {
+ int secs = parseSecs(str);
+ if (Math.abs(secs) > 18 * 60 * 60) {
+ throw new IllegalArgumentException(
+ "Zone offset not in valid range: -18:00 to +18:00");
+ }
+ return secs;
+ }
+
+ int parsePeriod(String str) {
+ return parseSecs(str);
+ }
+
+ TimeDefinition parseTimeDefinition(char c) {
+ switch (c) {
+ case 's':
+ case 'S':
+ // standard time
+ return TimeDefinition.STANDARD;
+ case 'u':
+ case 'U':
+ case 'g':
+ case 'G':
+ case 'z':
+ case 'Z':
+ // UTC
+ return TimeDefinition.UTC;
+ case 'w':
+ case 'W':
+ default:
+ // wall time
+ return TimeDefinition.WALL;
+ }
+ }
+ }
+
+ /**
+ * Class representing a rule line in the TZDB file.
+ */
+ private static class RuleLine extends MonthDayTime {
+ /** The start year. */
+ int startYear;
+
+ /** The end year. */
+ int endYear;
+
+ /** The amount of savings, in seconds. */
+ int savingsAmount;
+
+ /** The text name of the zone. */
+ String text;
+
+ /**
+ * Converts this to a transition rule.
+ *
+ * @param standardOffset the active standard offset, not null
+ * @param savingsBeforeSecs the active savings before the transition in seconds
+ * @return the transition, not null
+ */
+ ZoneOffsetTransitionRule toTransitionRule(ZoneOffset stdOffset, int savingsBefore) {
+ // rule shared by different zones, so don't change it
+ Month month = this.month;
+ int dayOfMonth = this.dayOfMonth;
+ DayOfWeek dayOfWeek = this.dayOfWeek;
+ boolean endOfDay = this.endOfDay;
+
+ // optimize stored format
+ if (dayOfMonth < 0) {
+ if (month != Month.FEBRUARY) { // not Month.FEBRUARY
+ dayOfMonth = month.maxLength() - 6;
+ }
+ }
+ if (endOfDay && dayOfMonth > 0 &&
+ (dayOfMonth == 28 && month == Month.FEBRUARY) == false) {
+ LocalDate date = LocalDate.of(2004, month, dayOfMonth).plusDays(1); // leap-year
+ month = date.getMonth();
+ dayOfMonth = date.getDayOfMonth();
+ if (dayOfWeek != null) {
+ dayOfWeek = dayOfWeek.plus(1);
+ }
+ endOfDay = false;
+ }
+ // build rule
+ return ZoneOffsetTransitionRule.of(
+ //month, dayOfMonth, dayOfWeek, time, endOfDay, timeDefinition,
+ month, dayOfMonth, dayOfWeek,
+ LocalTime.ofSecondOfDay(secsOfDay), endOfDay, timeDefinition,
+ stdOffset,
+ ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savingsBefore),
+ ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savingsAmount));
+ }
+
+ RuleLine parse(String[] tokens) {
+ startYear = parseYear(tokens[2], 0);
+ endYear = parseYear(tokens[3], startYear);
+ if (startYear > endYear) {
+ throw new IllegalArgumentException(
+ "Invalid <Rule> line/Year order invalid:" + startYear + " > " + endYear);
+ }
+ //parseOptional(s.next()); // type is unused
+ super.parse(tokens, 5); // monthdaytime parsing
+ savingsAmount = parsePeriod(tokens[8]);
+ //rule.text = parseOptional(s.next());
+ return this;
+ }
+ }
+
+ /**
+ * Class representing a linked set of zone lines in the TZDB file.
+ */
+ private static class ZoneLine extends MonthDayTime {
+ /** The standard offset. */
+ int stdOffsetSecs;
+
+ /** The fixed savings amount. */
+ int fixedSavingsSecs = 0;
+
+ /** The savings rule. */
+ String savingsRule;
+
+ /** The text name of the zone. */
+ String text;
+
+ /** The cutover year */
+ int year = Year.MAX_VALUE;
+
+ /** The cutover date time */
+ LocalDateTime ldt;
+
+ /** The cutover date/time in epoch seconds/UTC */
+ long ldtSecs = Long.MIN_VALUE;
+
+ LocalDateTime toDateTime() {
+ if (ldt == null) {
+ ldt = toDateTime(year);
+ }
+ return ldt;
+ }
+
+ /**
+ * Creates the date-time epoch second in the wall offset for the local
+ * date-time at the end of the window.
+ *
+ * @param savingsSecs the amount of savings in use in seconds
+ * @return the created date-time epoch second in the wall offset, not null
+ */
+ long toDateTimeEpochSecond(int savingsSecs) {
+ if (ldtSecs == Long.MIN_VALUE) {
+ ldtSecs = toDateTime().toEpochSecond(ZoneOffset.UTC);
+ }
+ switch(timeDefinition) {
+ case UTC: return ldtSecs;
+ case STANDARD: return ldtSecs - stdOffsetSecs;
+ default: return ldtSecs - (stdOffsetSecs + savingsSecs); // WALL
+ }
+ }
+
+ boolean parse(String[] tokens, int off) {
+ stdOffsetSecs = parseOffset(tokens[off++]);
+ savingsRule = parseOptional(tokens[off++]);
+ if (savingsRule != null && savingsRule.length() > 0 &&
+ (savingsRule.charAt(0) == '-' || isDigit(savingsRule.charAt(0)))) {
+ try {
+ fixedSavingsSecs = parsePeriod(savingsRule);
+ savingsRule = null;
+ } catch (Exception ex) {
+ fixedSavingsSecs = 0;
+ }
+ }
+ text = tokens[off++];
+ if (off < tokens.length) {
+ year = Integer.parseInt(tokens[off++]);
+ if (off < tokens.length) {
+ super.parse(tokens, off); // MonthDayTime
+ }
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+ /**
+ * Class representing a rule line in the TZDB file for a particular year.
+ */
+ private static class TransRule implements Comparable<TransRule>
+ {
+ private int year;
+ private RuleLine rule;
+
+ /** The trans date/time */
+ private LocalDateTime ldt;
+
+ /** The trans date/time in epoch seconds (assume UTC) */
+ long ldtSecs;
+
+ TransRule(int year, RuleLine rule) {
+ this.year = year;
+ this.rule = rule;
+ this.ldt = rule.toDateTime(year);
+ this.ldtSecs = ldt.toEpochSecond(ZoneOffset.UTC);
+ }
+
+ ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs) {
+ // copy of code in ZoneOffsetTransitionRule to avoid infinite loop
+ ZoneOffset wallOffset = ZoneOffset.ofTotalSeconds(
+ standardOffset.getTotalSeconds() + savingsBeforeSecs);
+ ZoneOffset offsetAfter = ZoneOffset.ofTotalSeconds(
+ standardOffset.getTotalSeconds() + rule.savingsAmount);
+ LocalDateTime dt = rule.timeDefinition
+ .createDateTime(ldt, standardOffset, wallOffset);
+ return ZoneOffsetTransition.of(dt, wallOffset, offsetAfter);
+ }
+
+ long toEpochSecond(ZoneOffset stdOffset, int savingsBeforeSecs) {
+ switch(rule.timeDefinition) {
+ case UTC: return ldtSecs;
+ case STANDARD: return ldtSecs - stdOffset.getTotalSeconds();
+ default: return ldtSecs - (stdOffset.getTotalSeconds() + savingsBeforeSecs); // WALL
+ }
+ }
+
+ /**
+ * Tests if this a real transition with the active savings in seconds
+ *
+ * @param savingsBefore the active savings in seconds
+ * @return true, if savings changes
+ */
+ boolean isTransition(int savingsBefore) {
+ return rule.savingsAmount != savingsBefore;
+ }
+
+ public int compareTo(TransRule other) {
+ return (ldtSecs < other.ldtSecs)? -1 : ((ldtSecs == other.ldtSecs) ? 0 : 1);
+ }
+ }
+
+ private ZoneRules buildRules(String zoneId, List<ZoneLine> zones) {
+ if (zones.isEmpty()) {
+ throw new IllegalStateException("No available zone window");
+ }
+ final List<ZoneOffsetTransition> standardTransitionList = new ArrayList<>(4);
+ final List<ZoneOffsetTransition> transitionList = new ArrayList<>(256);
+ final List<ZoneOffsetTransitionRule> lastTransitionRuleList = new ArrayList<>(2);
+
+ final ZoneLine zone0 = zones.get(0);
+ // initialize the standard offset, wallOffset and savings for loop
+
+ //ZoneOffset stdOffset = zone0.standardOffset;
+ ZoneOffset stdOffset = ZoneOffset.ofTotalSeconds(zone0.stdOffsetSecs);
+
+ int savings = zone0.fixedSavingsSecs;
+ ZoneOffset wallOffset = ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savings);
+
+ // start ldt of each zone window
+ LocalDateTime zoneStart = LocalDateTime.MIN;
+
+ // first stanard offset
+ ZoneOffset firstStdOffset = stdOffset;
+ // first wall offset
+ ZoneOffset firstWallOffset = wallOffset;
+
+ for (ZoneLine zone : zones) {
+ // check if standard offset changed, update it if yes
+ ZoneOffset stdOffsetPrev = stdOffset; // for effectiveSavings check
+ if (zone.stdOffsetSecs != stdOffset.getTotalSeconds()) {
+ ZoneOffset stdOffsetNew = ZoneOffset.ofTotalSeconds(zone.stdOffsetSecs);
+ standardTransitionList.add(
+ ZoneOffsetTransition.of(
+ LocalDateTime.ofEpochSecond(zoneStart.toEpochSecond(wallOffset),
+ 0,
+ stdOffset),
+ stdOffset,
+ stdOffsetNew));
+ stdOffset = stdOffsetNew;
+ }
+
+ LocalDateTime zoneEnd;
+ if (zone.year == Year.MAX_VALUE) {
+ zoneEnd = LocalDateTime.MAX;
+ } else {
+ zoneEnd = zone.toDateTime();
+ }
+ if (zoneEnd.compareTo(zoneStart) < 0) {
+ throw new IllegalStateException("Windows must be in date-time order: " +
+ zoneEnd + " < " + zoneStart);
+ }
+ // calculate effective savings at the start of the window
+ List<TransRule> trules = null;
+ List<TransRule> lastRules = null;
+
+ int effectiveSavings = zone.fixedSavingsSecs;
+ if (zone.savingsRule != null) {
+ List<RuleLine> tzdbRules = rules.get(zone.savingsRule);
+ if (tzdbRules == null) {
+ throw new IllegalArgumentException("<Rule> not found: " +
+ zone.savingsRule);
+ }
+ trules = new ArrayList<>(256);
+ lastRules = new ArrayList<>(2);
+ int lastRulesStartYear = Year.MIN_VALUE;
+
+ // merge the rules to transitions
+ for (RuleLine rule : tzdbRules) {
+ if (rule.startYear > zoneEnd.getYear()) {
+ // rules will not be used for this zone entry
+ continue;
+ }
+ rule.adjustToForwards(2004); // irrelevant, treat as leap year
+
+ int startYear = rule.startYear;
+ int endYear = rule.endYear;
+ if (zoneEnd.equals(LocalDateTime.MAX)) {
+ if (endYear == Year.MAX_VALUE) {
+ endYear = startYear;
+ lastRules.add(new TransRule(endYear, rule));
+ lastRulesStartYear = Math.max(startYear, lastRulesStartYear);
+ }
+ } else {
+ if (endYear == Year.MAX_VALUE) {
+ //endYear = zoneEnd.getYear();
+ endYear = zone.year;
+ }
+ }
+ int year = startYear;
+ while (year <= endYear) {
+ trules.add(new TransRule(year, rule));
+ year++;
+ }
+ }
+
+ // last rules, fill the gap years between different last rules
+ if (zoneEnd.equals(LocalDateTime.MAX)) {
+ lastRulesStartYear = Math.max(lastRulesStartYear, zoneStart.getYear()) + 1;
+ for (TransRule rule : lastRules) {
+ if (rule.year <= lastRulesStartYear) {
+ int year = rule.year;
+ while (year <= lastRulesStartYear) {
+ trules.add(new TransRule(year, rule.rule));
+ year++;
+ }
+ rule.year = lastRulesStartYear;
+ rule.ldt = rule.rule.toDateTime(year);
+ rule.ldtSecs = rule.ldt.toEpochSecond(ZoneOffset.UTC);
+ }
+ }
+ Collections.sort(lastRules);
+ }
+ // sort the merged rules
+ Collections.sort(trules);
+
+ effectiveSavings = 0;
+ for (TransRule rule : trules) {
+ if (rule.toEpochSecond(stdOffsetPrev, savings) >
+ zoneStart.toEpochSecond(wallOffset)) {
+ // previous savings amount found, which could be the
+ // savings amount at the instant that the window starts
+ // (hence isAfter)
+ break;
+ }
+ effectiveSavings = rule.rule.savingsAmount;
+ }
+ }
+ // check if the start of the window represents a transition
+ ZoneOffset effectiveWallOffset =
+ ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + effectiveSavings);
+
+ if (!wallOffset.equals(effectiveWallOffset)) {
+ transitionList.add(ZoneOffsetTransition.of(zoneStart,
+ wallOffset,
+ effectiveWallOffset));
+ }
+ savings = effectiveSavings;
+ // apply rules within the window
+ if (trules != null) {
+ long zoneStartEpochSecs = zoneStart.toEpochSecond(wallOffset);
+ for (TransRule trule : trules) {
+ if (trule.isTransition(savings)) {
+ long epochSecs = trule.toEpochSecond(stdOffset, savings);
+ if (epochSecs < zoneStartEpochSecs ||
+ epochSecs >= zone.toDateTimeEpochSecond(savings)) {
+ continue;
+ }
+ transitionList.add(trule.toTransition(stdOffset, savings));
+ savings = trule.rule.savingsAmount;
+ }
+ }
+ }
+ if (lastRules != null) {
+ for (TransRule trule : lastRules) {
+ lastTransitionRuleList.add(trule.rule.toTransitionRule(stdOffset, savings));
+ savings = trule.rule.savingsAmount;
+ }
+ }
+
+ // finally we can calculate the true end of the window, passing it to the next window
+ wallOffset = ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savings);
+ zoneStart = LocalDateTime.ofEpochSecond(zone.toDateTimeEpochSecond(savings),
+ 0,
+ wallOffset);
+ }
+ return new ZoneRules(firstStdOffset,
+ firstWallOffset,
+ standardTransitionList,
+ transitionList,
+ lastTransitionRuleList);
+ }
+
+}
--- a/jdk/make/src/classes/build/tools/tzdb/Utils.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-import java.util.Objects;
-
-class Utils {
-
- // Returns the largest (closest to positive infinity)
- public static long floorDiv(long x, long y) {
- long r = x / y;
- // if the signs are different and modulo not zero, round down
- if ((x ^ y) < 0 && (r * y != x)) {
- r--;
- }
- return r;
- }
-
- // Returns the floor modulus of the {@code long} arguments.
- public static long floorMod(long x, long y) {
- return x - floorDiv(x, y) * y;
- }
-
- // Returns the sum of its arguments,
- public static long addExact(long x, long y) {
- long r = x + y;
- // HD 2-12 Overflow iff both arguments have the opposite sign of the result
- if (((x ^ r) & (y ^ r)) < 0) {
- throw new ArithmeticException("long overflow");
- }
- return r;
- }
-
- // Year
-
- // Returns true if the specified year is a leap year.
- public static boolean isLeapYear(int year) {
- return ((year & 3) == 0) && ((year % 100) != 0 || (year % 400) == 0);
- }
-
- // The minimum supported year, '-999,999,999'.
- public static final int YEAR_MIN_VALUE = -999_999_999;
-
- // The maximum supported year, '+999,999,999'.
- public static final int YEAR_MAX_VALUE = 999_999_999;
-
-
- // Gets the length of the specified month in days.
- public static int lengthOfMonth(int month, boolean leapYear) {
- switch (month) {
- case 2: //FEBRUARY:
- return (leapYear ? 29 : 28);
- case 4: //APRIL:
- case 6: //JUNE:
- case 9: //SEPTEMBER:
- case 11: //NOVEMBER:
- return 30;
- default:
- return 31;
- }
- }
-
- // Gets the maximum length of the specified month in days.
- public static int maxLengthOfMonth(int month) {
- switch (month) {
- case 2: //FEBRUARY:
- return 29;
- case 4: //APRIL:
- case 6: //JUNE:
- case 9: //SEPTEMBER:
- case 11: //NOVEMBER:
- return 30;
- default:
- return 31;
- }
- }
-
- // DayOfWeek
-
- // Returns the day-of-week that is the specified number of days after
- // this one, from 1 to 7 for Monday to Sunday.
- public static int plusDayOfWeek(int dow, long days) {
- int amount = (int) (days % 7);
- return (dow - 1 + (amount + 7)) % 7 + 1;
- }
-
- // Returns the day-of-week that is the specified number of days before
- // this one, from 1 to 7 for Monday to Sunday.
- public static int minusDayOfWeek(int dow, long days) {
- return plusDayOfWeek(dow, -(days % 7));
- }
-
- // Adjusts the date to the first occurrence of the specified day-of-week
- // before the date being adjusted unless it is already on that day in
- // which case the same object is returned.
- public static LocalDate previousOrSame(LocalDate date, int dayOfWeek) {
- return adjust(date, dayOfWeek, 1);
- }
-
- // Adjusts the date to the first occurrence of the specified day-of-week
- // after the date being adjusted unless it is already on that day in
- // which case the same object is returned.
- public static LocalDate nextOrSame(LocalDate date, int dayOfWeek) {
- return adjust(date, dayOfWeek, 0);
- }
-
- // Implementation of next, previous or current day-of-week.
- // @param relative whether the current date is a valid answer
- private static final LocalDate adjust(LocalDate date, int dow, int relative) {
- int calDow = date.getDayOfWeek();
- if (relative < 2 && calDow == dow) {
- return date;
- }
- if ((relative & 1) == 0) {
- int daysDiff = calDow - dow;
- return date.plusDays(daysDiff >= 0 ? 7 - daysDiff : -daysDiff);
- } else {
- int daysDiff = dow - calDow;
- return date.minusDays(daysDiff >= 0 ? 7 - daysDiff : -daysDiff);
- }
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/ZoneOffset.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,474 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * A time-zone offset from Greenwich/UTC, such as {@code +02:00}.
- * <p>
- * A time-zone offset is the period of time that a time-zone differs from Greenwich/UTC.
- * This is usually a fixed number of hours and minutes.
- *
- * @since 1.8
- */
-final class ZoneOffset implements Comparable<ZoneOffset> {
-
- /** Cache of time-zone offset by offset in seconds. */
- private static final ConcurrentMap<Integer, ZoneOffset> SECONDS_CACHE = new ConcurrentHashMap<>(16, 0.75f, 4);
- /** Cache of time-zone offset by ID. */
- private static final ConcurrentMap<String, ZoneOffset> ID_CACHE = new ConcurrentHashMap<>(16, 0.75f, 4);
-
- /**
- * The number of seconds per hour.
- */
- private static final int SECONDS_PER_HOUR = 60 * 60;
- /**
- * The number of seconds per minute.
- */
- private static final int SECONDS_PER_MINUTE = 60;
- /**
- * The number of minutes per hour.
- */
- private static final int MINUTES_PER_HOUR = 60;
- /**
- * The abs maximum seconds.
- */
- private static final int MAX_SECONDS = 18 * SECONDS_PER_HOUR;
- /**
- * Serialization version.
- */
- private static final long serialVersionUID = 2357656521762053153L;
-
- /**
- * The time-zone offset for UTC, with an ID of 'Z'.
- */
- public static final ZoneOffset UTC = ZoneOffset.ofTotalSeconds(0);
- /**
- * Constant for the maximum supported offset.
- */
- public static final ZoneOffset MIN = ZoneOffset.ofTotalSeconds(-MAX_SECONDS);
- /**
- * Constant for the maximum supported offset.
- */
- public static final ZoneOffset MAX = ZoneOffset.ofTotalSeconds(MAX_SECONDS);
-
- /**
- * The total offset in seconds.
- */
- private final int totalSeconds;
- /**
- * The string form of the time-zone offset.
- */
- private final transient String id;
-
- //-----------------------------------------------------------------------
- /**
- * Obtains an instance of {@code ZoneOffset} using the ID.
- * <p>
- * This method parses the string ID of a {@code ZoneOffset} to
- * return an instance. The parsing accepts all the formats generated by
- * {@link #getId()}, plus some additional formats:
- * <p><ul>
- * <li>{@code Z} - for UTC
- * <li>{@code +h}
- * <li>{@code +hh}
- * <li>{@code +hh:mm}
- * <li>{@code -hh:mm}
- * <li>{@code +hhmm}
- * <li>{@code -hhmm}
- * <li>{@code +hh:mm:ss}
- * <li>{@code -hh:mm:ss}
- * <li>{@code +hhmmss}
- * <li>{@code -hhmmss}
- * </ul><p>
- * Note that ± means either the plus or minus symbol.
- * <p>
- * The ID of the returned offset will be normalized to one of the formats
- * described by {@link #getId()}.
- * <p>
- * The maximum supported range is from +18:00 to -18:00 inclusive.
- *
- * @param offsetId the offset ID, not null
- * @return the zone-offset, not null
- * @throws DateTimeException if the offset ID is invalid
- */
- @SuppressWarnings("fallthrough")
- public static ZoneOffset of(String offsetId) {
- Objects.requireNonNull(offsetId, "offsetId");
- // "Z" is always in the cache
- ZoneOffset offset = ID_CACHE.get(offsetId);
- if (offset != null) {
- return offset;
- }
-
- // parse - +h, +hh, +hhmm, +hh:mm, +hhmmss, +hh:mm:ss
- final int hours, minutes, seconds;
- switch (offsetId.length()) {
- case 2:
- offsetId = offsetId.charAt(0) + "0" + offsetId.charAt(1); // fallthru
- case 3:
- hours = parseNumber(offsetId, 1, false);
- minutes = 0;
- seconds = 0;
- break;
- case 5:
- hours = parseNumber(offsetId, 1, false);
- minutes = parseNumber(offsetId, 3, false);
- seconds = 0;
- break;
- case 6:
- hours = parseNumber(offsetId, 1, false);
- minutes = parseNumber(offsetId, 4, true);
- seconds = 0;
- break;
- case 7:
- hours = parseNumber(offsetId, 1, false);
- minutes = parseNumber(offsetId, 3, false);
- seconds = parseNumber(offsetId, 5, false);
- break;
- case 9:
- hours = parseNumber(offsetId, 1, false);
- minutes = parseNumber(offsetId, 4, true);
- seconds = parseNumber(offsetId, 7, true);
- break;
- default:
- throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid");
- }
- char first = offsetId.charAt(0);
- if (first != '+' && first != '-') {
- throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid: Plus/minus not found when expected");
- }
- if (first == '-') {
- return ofHoursMinutesSeconds(-hours, -minutes, -seconds);
- } else {
- return ofHoursMinutesSeconds(hours, minutes, seconds);
- }
- }
-
- /**
- * Parse a two digit zero-prefixed number.
- *
- * @param offsetId the offset ID, not null
- * @param pos the position to parse, valid
- * @param precededByColon should this number be prefixed by a precededByColon
- * @return the parsed number, from 0 to 99
- */
- private static int parseNumber(CharSequence offsetId, int pos, boolean precededByColon) {
- if (precededByColon && offsetId.charAt(pos - 1) != ':') {
- throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid: Colon not found when expected");
- }
- char ch1 = offsetId.charAt(pos);
- char ch2 = offsetId.charAt(pos + 1);
- if (ch1 < '0' || ch1 > '9' || ch2 < '0' || ch2 > '9') {
- throw new DateTimeException("Zone offset ID '" + offsetId + "' is invalid: Non numeric characters found");
- }
- return (ch1 - 48) * 10 + (ch2 - 48);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Obtains an instance of {@code ZoneOffset} using an offset in hours.
- *
- * @param hours the time-zone offset in hours, from -18 to +18
- * @return the zone-offset, not null
- * @throws DateTimeException if the offset is not in the required range
- */
- public static ZoneOffset ofHours(int hours) {
- return ofHoursMinutesSeconds(hours, 0, 0);
- }
-
- /**
- * Obtains an instance of {@code ZoneOffset} using an offset in
- * hours and minutes.
- * <p>
- * The sign of the hours and minutes components must match.
- * Thus, if the hours is negative, the minutes must be negative or zero.
- * If the hours is zero, the minutes may be positive, negative or zero.
- *
- * @param hours the time-zone offset in hours, from -18 to +18
- * @param minutes the time-zone offset in minutes, from 0 to ±59, sign matches hours
- * @return the zone-offset, not null
- * @throws DateTimeException if the offset is not in the required range
- */
- public static ZoneOffset ofHoursMinutes(int hours, int minutes) {
- return ofHoursMinutesSeconds(hours, minutes, 0);
- }
-
- /**
- * Obtains an instance of {@code ZoneOffset} using an offset in
- * hours, minutes and seconds.
- * <p>
- * The sign of the hours, minutes and seconds components must match.
- * Thus, if the hours is negative, the minutes and seconds must be negative or zero.
- *
- * @param hours the time-zone offset in hours, from -18 to +18
- * @param minutes the time-zone offset in minutes, from 0 to ±59, sign matches hours and seconds
- * @param seconds the time-zone offset in seconds, from 0 to ±59, sign matches hours and minutes
- * @return the zone-offset, not null
- * @throws DateTimeException if the offset is not in the required range
- */
- public static ZoneOffset ofHoursMinutesSeconds(int hours, int minutes, int seconds) {
- validate(hours, minutes, seconds);
- int totalSeconds = totalSeconds(hours, minutes, seconds);
- return ofTotalSeconds(totalSeconds);
- }
-
- /**
- * Validates the offset fields.
- *
- * @param hours the time-zone offset in hours, from -18 to +18
- * @param minutes the time-zone offset in minutes, from 0 to ±59
- * @param seconds the time-zone offset in seconds, from 0 to ±59
- * @throws DateTimeException if the offset is not in the required range
- */
- private static void validate(int hours, int minutes, int seconds) {
- if (hours < -18 || hours > 18) {
- throw new DateTimeException("Zone offset hours not in valid range: value " + hours +
- " is not in the range -18 to 18");
- }
- if (hours > 0) {
- if (minutes < 0 || seconds < 0) {
- throw new DateTimeException("Zone offset minutes and seconds must be positive because hours is positive");
- }
- } else if (hours < 0) {
- if (minutes > 0 || seconds > 0) {
- throw new DateTimeException("Zone offset minutes and seconds must be negative because hours is negative");
- }
- } else if ((minutes > 0 && seconds < 0) || (minutes < 0 && seconds > 0)) {
- throw new DateTimeException("Zone offset minutes and seconds must have the same sign");
- }
- if (Math.abs(minutes) > 59) {
- throw new DateTimeException("Zone offset minutes not in valid range: abs(value) " +
- Math.abs(minutes) + " is not in the range 0 to 59");
- }
- if (Math.abs(seconds) > 59) {
- throw new DateTimeException("Zone offset seconds not in valid range: abs(value) " +
- Math.abs(seconds) + " is not in the range 0 to 59");
- }
- if (Math.abs(hours) == 18 && (Math.abs(minutes) > 0 || Math.abs(seconds) > 0)) {
- throw new DateTimeException("Zone offset not in valid range: -18:00 to +18:00");
- }
- }
-
- /**
- * Calculates the total offset in seconds.
- *
- * @param hours the time-zone offset in hours, from -18 to +18
- * @param minutes the time-zone offset in minutes, from 0 to ±59, sign matches hours and seconds
- * @param seconds the time-zone offset in seconds, from 0 to ±59, sign matches hours and minutes
- * @return the total in seconds
- */
- private static int totalSeconds(int hours, int minutes, int seconds) {
- return hours * SECONDS_PER_HOUR + minutes * SECONDS_PER_MINUTE + seconds;
- }
-
- //-----------------------------------------------------------------------
- /**
- * Obtains an instance of {@code ZoneOffset} specifying the total offset in seconds
- * <p>
- * The offset must be in the range {@code -18:00} to {@code +18:00}, which corresponds to -64800 to +64800.
- *
- * @param totalSeconds the total time-zone offset in seconds, from -64800 to +64800
- * @return the ZoneOffset, not null
- * @throws DateTimeException if the offset is not in the required range
- */
- public static ZoneOffset ofTotalSeconds(int totalSeconds) {
- if (Math.abs(totalSeconds) > MAX_SECONDS) {
- throw new DateTimeException("Zone offset not in valid range: -18:00 to +18:00");
- }
- if (totalSeconds % (15 * SECONDS_PER_MINUTE) == 0) {
- Integer totalSecs = totalSeconds;
- ZoneOffset result = SECONDS_CACHE.get(totalSecs);
- if (result == null) {
- result = new ZoneOffset(totalSeconds);
- SECONDS_CACHE.putIfAbsent(totalSecs, result);
- result = SECONDS_CACHE.get(totalSecs);
- ID_CACHE.putIfAbsent(result.getId(), result);
- }
- return result;
- } else {
- return new ZoneOffset(totalSeconds);
- }
- }
-
- /**
- * Constructor.
- *
- * @param totalSeconds the total time-zone offset in seconds, from -64800 to +64800
- */
- private ZoneOffset(int totalSeconds) {
- super();
- this.totalSeconds = totalSeconds;
- id = buildId(totalSeconds);
- }
-
- private static String buildId(int totalSeconds) {
- if (totalSeconds == 0) {
- return "Z";
- } else {
- int absTotalSeconds = Math.abs(totalSeconds);
- StringBuilder buf = new StringBuilder();
- int absHours = absTotalSeconds / SECONDS_PER_HOUR;
- int absMinutes = (absTotalSeconds / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
- buf.append(totalSeconds < 0 ? "-" : "+")
- .append(absHours < 10 ? "0" : "").append(absHours)
- .append(absMinutes < 10 ? ":0" : ":").append(absMinutes);
- int absSeconds = absTotalSeconds % SECONDS_PER_MINUTE;
- if (absSeconds != 0) {
- buf.append(absSeconds < 10 ? ":0" : ":").append(absSeconds);
- }
- return buf.toString();
- }
- }
-
- /**
- * Gets the total zone offset in seconds.
- * <p>
- * This is the primary way to access the offset amount.
- * It returns the total of the hours, minutes and seconds fields as a
- * single offset that can be added to a time.
- *
- * @return the total zone offset amount in seconds
- */
- public int getTotalSeconds() {
- return totalSeconds;
- }
-
- /**
- * Gets the normalized zone offset ID.
- * <p>
- * The ID is minor variation to the standard ISO-8601 formatted string
- * for the offset. There are three formats:
- * <p><ul>
- * <li>{@code Z} - for UTC (ISO-8601)
- * <li>{@code +hh:mm} or {@code -hh:mm} - if the seconds are zero (ISO-8601)
- * <li>{@code +hh:mm:ss} or {@code -hh:mm:ss} - if the seconds are non-zero (not ISO-8601)
- * </ul><p>
- *
- * @return the zone offset ID, not null
- */
- public String getId() {
- return id;
- }
-
- /**
- * Compares this offset to another offset in descending order.
- * <p>
- * The offsets are compared in the order that they occur for the same time
- * of day around the world. Thus, an offset of {@code +10:00} comes before an
- * offset of {@code +09:00} and so on down to {@code -18:00}.
- * <p>
- * The comparison is "consistent with equals", as defined by {@link Comparable}.
- *
- * @param other the other date to compare to, not null
- * @return the comparator value, negative if less, postive if greater
- * @throws NullPointerException if {@code other} is null
- */
- @Override
- public int compareTo(ZoneOffset other) {
- return other.totalSeconds - totalSeconds;
- }
-
- /**
- * Checks if this offset is equal to another offset.
- * <p>
- * The comparison is based on the amount of the offset in seconds.
- * This is equivalent to a comparison by ID.
- *
- * @param obj the object to check, null returns false
- * @return true if this is equal to the other offset
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof ZoneOffset) {
- return totalSeconds == ((ZoneOffset) obj).totalSeconds;
- }
- return false;
- }
-
- /**
- * A hash code for this offset.
- *
- * @return a suitable hash code
- */
- @Override
- public int hashCode() {
- return totalSeconds;
- }
-
- /**
- * Outputs this offset as a {@code String}, using the normalized ID.
- *
- * @return a string representation of this offset, not null
- */
- @Override
- public String toString() {
- return id;
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/ZoneOffsetTransition.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,290 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * A transition between two offsets caused by a discontinuity in the local time-line.
- *
- * @since 1.8
- */
-final class ZoneOffsetTransition implements Comparable<ZoneOffsetTransition> {
-
- /**
- * The local transition date-time at the transition.
- */
- private final LocalDateTime transition;
- /**
- * The offset before transition.
- */
- private final ZoneOffset offsetBefore;
- /**
- * The offset after transition.
- */
- private final ZoneOffset offsetAfter;
-
- /**
- * Creates an instance defining a transition between two offsets.
- *
- * @param transition the transition date-time with the offset before the transition, not null
- * @param offsetBefore the offset before the transition, not null
- * @param offsetAfter the offset at and after the transition, not null
- */
- ZoneOffsetTransition(LocalDateTime transition, ZoneOffset offsetBefore, ZoneOffset offsetAfter) {
- Objects.requireNonNull(transition, "transition");
- Objects.requireNonNull(offsetBefore, "offsetBefore");
- Objects.requireNonNull(offsetAfter, "offsetAfter");
- if (offsetBefore.equals(offsetAfter)) {
- throw new IllegalArgumentException("Offsets must not be equal");
- }
- this.transition = transition;
- this.offsetBefore = offsetBefore;
- this.offsetAfter = offsetAfter;
- }
-
- /**
- * Creates an instance from epoch-second and offsets.
- *
- * @param epochSecond the transition epoch-second
- * @param offsetBefore the offset before the transition, not null
- * @param offsetAfter the offset at and after the transition, not null
- */
- ZoneOffsetTransition(long epochSecond, ZoneOffset offsetBefore, ZoneOffset offsetAfter) {
- this.transition = LocalDateTime.ofEpochSecond(epochSecond, 0, offsetBefore);
- this.offsetBefore = offsetBefore;
- this.offsetAfter = offsetAfter;
- }
-
- /**
- * Gets the transition instant as an epoch second.
- *
- * @return the transition epoch second
- */
- public long toEpochSecond() {
- return transition.toEpochSecond(offsetBefore);
- }
-
- /**
- * Gets the local transition date-time, as would be expressed with the 'before' offset.
- * <p>
- * This is the date-time where the discontinuity begins expressed with the 'before' offset.
- * At this instant, the 'after' offset is actually used, therefore the combination of this
- * date-time and the 'before' offset will never occur.
- * <p>
- * The combination of the 'before' date-time and offset represents the same instant
- * as the 'after' date-time and offset.
- *
- * @return the transition date-time expressed with the before offset, not null
- */
- public LocalDateTime getDateTimeBefore() {
- return transition;
- }
-
- /**
- * Gets the local transition date-time, as would be expressed with the 'after' offset.
- * <p>
- * This is the first date-time after the discontinuity, when the new offset applies.
- * <p>
- * The combination of the 'before' date-time and offset represents the same instant
- * as the 'after' date-time and offset.
- *
- * @return the transition date-time expressed with the after offset, not null
- */
- public LocalDateTime getDateTimeAfter() {
- return transition.plusSeconds(getDurationSeconds());
- }
-
- /**
- * Gets the offset before the transition.
- * <p>
- * This is the offset in use before the instant of the transition.
- *
- * @return the offset before the transition, not null
- */
- public ZoneOffset getOffsetBefore() {
- return offsetBefore;
- }
-
- /**
- * Gets the offset after the transition.
- * <p>
- * This is the offset in use on and after the instant of the transition.
- *
- * @return the offset after the transition, not null
- */
- public ZoneOffset getOffsetAfter() {
- return offsetAfter;
- }
-
- /**
- * Gets the duration of the transition in seconds.
- *
- * @return the duration in seconds
- */
- private int getDurationSeconds() {
- return getOffsetAfter().getTotalSeconds() - getOffsetBefore().getTotalSeconds();
- }
-
- /**
- * Does this transition represent a gap in the local time-line.
- * <p>
- * Gaps occur where there are local date-times that simply do not not exist.
- * An example would be when the offset changes from {@code +01:00} to {@code +02:00}.
- * This might be described as 'the clocks will move forward one hour tonight at 1am'.
- *
- * @return true if this transition is a gap, false if it is an overlap
- */
- public boolean isGap() {
- return getOffsetAfter().getTotalSeconds() > getOffsetBefore().getTotalSeconds();
- }
-
- /**
- * Does this transition represent a gap in the local time-line.
- * <p>
- * Overlaps occur where there are local date-times that exist twice.
- * An example would be when the offset changes from {@code +02:00} to {@code +01:00}.
- * This might be described as 'the clocks will move back one hour tonight at 2am'.
- *
- * @return true if this transition is an overlap, false if it is a gap
- */
- public boolean isOverlap() {
- return getOffsetAfter().getTotalSeconds() < getOffsetBefore().getTotalSeconds();
- }
-
- /**
- * Checks if the specified offset is valid during this transition.
- * <p>
- * This checks to see if the given offset will be valid at some point in the transition.
- * A gap will always return false.
- * An overlap will return true if the offset is either the before or after offset.
- *
- * @param offset the offset to check, null returns false
- * @return true if the offset is valid during the transition
- */
- public boolean isValidOffset(ZoneOffset offset) {
- return isGap() ? false : (getOffsetBefore().equals(offset) || getOffsetAfter().equals(offset));
- }
-
- /**
- * Gets the valid offsets during this transition.
- * <p>
- * A gap will return an empty list, while an overlap will return both offsets.
- *
- * @return the list of valid offsets
- */
- List<ZoneOffset> getValidOffsets() {
- if (isGap()) {
- return Collections.emptyList();
- }
- return Arrays.asList(getOffsetBefore(), getOffsetAfter());
- }
-
- /**
- * Compares this transition to another based on the transition instant.
- * <p>
- * This compares the instants of each transition.
- * The offsets are ignored, making this order inconsistent with equals.
- *
- * @param transition the transition to compare to, not null
- * @return the comparator value, negative if less, positive if greater
- */
- @Override
- public int compareTo(ZoneOffsetTransition transition) {
- return Long.compare(this.toEpochSecond(), transition.toEpochSecond());
- }
-
- /**
- * Checks if this object equals another.
- * <p>
- * The entire state of the object is compared.
- *
- * @param other the other object to compare to, null returns false
- * @return true if equal
- */
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
- if (other instanceof ZoneOffsetTransition) {
- ZoneOffsetTransition d = (ZoneOffsetTransition) other;
- return transition.equals(d.transition) &&
- offsetBefore.equals(d.offsetBefore) && offsetAfter.equals(d.offsetAfter);
- }
- return false;
- }
-
- /**
- * Returns a suitable hash code.
- *
- * @return the hash code
- */
- @Override
- public int hashCode() {
- return transition.hashCode() ^ offsetBefore.hashCode() ^ Integer.rotateLeft(offsetAfter.hashCode(), 16);
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/ZoneOffsetTransitionRule.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-import static build.tools.tzdb.Utils.*;
-import java.util.Objects;
-
-/**
- * A rule expressing how to create a transition.
- * <p>
- * This class allows rules for identifying future transitions to be expressed.
- * A rule might be written in many forms:
- * <p><ul>
- * <li>the 16th March
- * <li>the Sunday on or after the 16th March
- * <li>the Sunday on or before the 16th March
- * <li>the last Sunday in February
- * </ul><p>
- * These different rule types can be expressed and queried.
- *
- * <h3>Specification for implementors</h3>
- * This class is immutable and thread-safe.
- *
- * @since 1.8
- */
-final class ZoneOffsetTransitionRule {
-
- /**
- * The month of the month-day of the first day of the cutover week.
- * The actual date will be adjusted by the dowChange field.
- */
- final int month;
- /**
- * The day-of-month of the month-day of the cutover week.
- * If positive, it is the start of the week where the cutover can occur.
- * If negative, it represents the end of the week where cutover can occur.
- * The value is the number of days from the end of the month, such that
- * {@code -1} is the last day of the month, {@code -2} is the second
- * to last day, and so on.
- */
- final byte dom;
- /**
- * The cutover day-of-week, -1 to retain the day-of-month.
- */
- final int dow;
- /**
- * The cutover time in the 'before' offset.
- */
- final LocalTime time;
- /**
- * Whether the cutover time is midnight at the end of day.
- */
- final boolean timeEndOfDay;
- /**
- * The definition of how the local time should be interpreted.
- */
- final TimeDefinition timeDefinition;
- /**
- * The standard offset at the cutover.
- */
- final ZoneOffset standardOffset;
- /**
- * The offset before the cutover.
- */
- final ZoneOffset offsetBefore;
- /**
- * The offset after the cutover.
- */
- final ZoneOffset offsetAfter;
-
- /**
- * Creates an instance defining the yearly rule to create transitions between two offsets.
- *
- * @param month the month of the month-day of the first day of the cutover week, from 1 to 12
- * @param dayOfMonthIndicator the day of the month-day of the cutover week, positive if the week is that
- * day or later, negative if the week is that day or earlier, counting from the last day of the month,
- * from -28 to 31 excluding 0
- * @param dayOfWeek the required day-of-week, -1 if the month-day should not be changed
- * @param time the cutover time in the 'before' offset, not null
- * @param timeEndOfDay whether the time is midnight at the end of day
- * @param timeDefnition how to interpret the cutover
- * @param standardOffset the standard offset in force at the cutover, not null
- * @param offsetBefore the offset before the cutover, not null
- * @param offsetAfter the offset after the cutover, not null
- * @throws IllegalArgumentException if the day of month indicator is invalid
- * @throws IllegalArgumentException if the end of day flag is true when the time is not midnight
- */
- ZoneOffsetTransitionRule(
- int month,
- int dayOfMonthIndicator,
- int dayOfWeek,
- LocalTime time,
- boolean timeEndOfDay,
- TimeDefinition timeDefnition,
- ZoneOffset standardOffset,
- ZoneOffset offsetBefore,
- ZoneOffset offsetAfter) {
- Objects.requireNonNull(time, "time");
- Objects.requireNonNull(timeDefnition, "timeDefnition");
- Objects.requireNonNull(standardOffset, "standardOffset");
- Objects.requireNonNull(offsetBefore, "offsetBefore");
- Objects.requireNonNull(offsetAfter, "offsetAfter");
- if (month < 1 || month > 12) {
- throw new IllegalArgumentException("month must be between 1 and 12");
- }
- if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) {
- throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
- }
- if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) {
- throw new IllegalArgumentException("Time must be midnight when end of day flag is true");
- }
- this.month = month;
- this.dom = (byte) dayOfMonthIndicator;
- this.dow = dayOfWeek;
- this.time = time;
- this.timeEndOfDay = timeEndOfDay;
- this.timeDefinition = timeDefnition;
- this.standardOffset = standardOffset;
- this.offsetBefore = offsetBefore;
- this.offsetAfter = offsetAfter;
- }
-
- //-----------------------------------------------------------------------
- /**
- * Checks if this object equals another.
- * <p>
- * The entire state of the object is compared.
- *
- * @param otherRule the other object to compare to, null returns false
- * @return true if equal
- */
- @Override
- public boolean equals(Object otherRule) {
- if (otherRule == this) {
- return true;
- }
- if (otherRule instanceof ZoneOffsetTransitionRule) {
- ZoneOffsetTransitionRule other = (ZoneOffsetTransitionRule) otherRule;
- return month == other.month && dom == other.dom && dow == other.dow &&
- timeDefinition == other.timeDefinition &&
- time.equals(other.time) &&
- timeEndOfDay == other.timeEndOfDay &&
- standardOffset.equals(other.standardOffset) &&
- offsetBefore.equals(other.offsetBefore) &&
- offsetAfter.equals(other.offsetAfter);
- }
- return false;
- }
-
- /**
- * Returns a suitable hash code.
- *
- * @return the hash code
- */
- @Override
- public int hashCode() {
- int hash = ((time.toSecondOfDay() + (timeEndOfDay ? 1 : 0)) << 15) +
- (month << 11) + ((dom + 32) << 5) +
- ((dow == -1 ? 8 : dow) << 2) + (timeDefinition.ordinal());
- return hash ^ standardOffset.hashCode() ^
- offsetBefore.hashCode() ^ offsetAfter.hashCode();
- }
-
-}
--- a/jdk/make/src/classes/build/tools/tzdb/ZoneRules.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/make/src/classes/build/tools/tzdb/ZoneRules.java Fri Jun 27 14:21:31 2014 -0700
@@ -64,6 +64,12 @@
import java.io.DataOutput;
import java.io.IOException;
import java.io.ObjectOutput;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneOffset;
+import java.time.zone.ZoneOffsetTransition;
+import java.time.zone.ZoneOffsetTransitionRule;
+import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
@@ -224,15 +230,15 @@
* @throws IOException if an error occurs
*/
static void writeRule(ZoneOffsetTransitionRule rule, DataOutput out) throws IOException {
- int month = rule.month;
- byte dom = rule.dom;
- int dow = rule.dow;
- LocalTime time = rule.time;
- boolean timeEndOfDay = rule.timeEndOfDay;
- TimeDefinition timeDefinition = rule.timeDefinition;
- ZoneOffset standardOffset = rule.standardOffset;
- ZoneOffset offsetBefore = rule.offsetBefore;
- ZoneOffset offsetAfter = rule.offsetAfter;
+ int month = rule.getMonth().getValue();
+ byte dom = (byte)rule.getDayOfMonthIndicator();
+ int dow = rule.getDayOfWeek().getValue();
+ LocalTime time = rule.getLocalTime();
+ boolean timeEndOfDay = rule.isMidnightEndOfDay();
+ TimeDefinition timeDefinition = rule.getTimeDefinition();
+ ZoneOffset standardOffset = rule.getStandardOffset();
+ ZoneOffset offsetBefore = rule.getOffsetBefore();
+ ZoneOffset offsetAfter = rule.getOffsetAfter();
int timeSecs = (timeEndOfDay ? 86400 : time.toSecondOfDay());
int stdOffset = standardOffset.getTotalSeconds();
--- a/jdk/make/src/classes/build/tools/tzdb/ZoneRulesBuilder.java Thu Jun 26 03:26:20 2014 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,743 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package build.tools.tzdb;
-
-import static build.tools.tzdb.Utils.*;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * A mutable builder used to create all the rules for a historic time-zone.
- * <p>
- * The rules of a time-zone describe how the offset changes over time.
- * The rules are created by building windows on the time-line within which
- * the different rules apply. The rules may be one of two kinds:
- * <p><ul>
- * <li>Fixed savings - A single fixed amount of savings from the standard offset will apply.</li>
- * <li>Rules - A set of one or more rules describe how daylight savings changes during the window.</li>
- * </ul><p>
- *
- * <h4>Implementation notes</h4>
- * This class is a mutable builder used to create zone instances.
- * It must only be used from a single thread.
- * The created instances are immutable and thread-safe.
- *
- * @since 1.8
- */
-public class ZoneRulesBuilder {
-
- /**
- * The list of windows.
- */
- private List<TZWindow> windowList = new ArrayList<>();
-
- //-----------------------------------------------------------------------
- /**
- * Constructs an instance of the builder that can be used to create zone rules.
- * <p>
- * The builder is used by adding one or more windows representing portions
- * of the time-line. The standard offset from UTC/Greenwich will be constant
- * within a window, although two adjacent windows can have the same standard offset.
- * <p>
- * Within each window, there can either be a
- * {@link #setFixedSavingsToWindow fixed savings amount} or a
- * {@link #addRuleToWindow list of rules}.
- */
- public ZoneRulesBuilder() {
- }
-
- //-----------------------------------------------------------------------
- /**
- * Adds a window to the builder that can be used to filter a set of rules.
- * <p>
- * This method defines and adds a window to the zone where the standard offset is specified.
- * The window limits the effect of subsequent additions of transition rules
- * or fixed savings. If neither rules or fixed savings are added to the window
- * then the window will default to no savings.
- * <p>
- * Each window must be added sequentially, as the start instant of the window
- * is derived from the until instant of the previous window.
- *
- * @param standardOffset the standard offset, not null
- * @param until the date-time that the offset applies until, not null
- * @param untilDefinition the time type for the until date-time, not null
- * @return this, for chaining
- * @throws IllegalStateException if the window order is invalid
- */
- public ZoneRulesBuilder addWindow(
- ZoneOffset standardOffset,
- LocalDateTime until,
- TimeDefinition untilDefinition) {
- Objects.requireNonNull(standardOffset, "standardOffset");
- Objects.requireNonNull(until, "until");
- Objects.requireNonNull(untilDefinition, "untilDefinition");
- TZWindow window = new TZWindow(standardOffset, until, untilDefinition);
- if (windowList.size() > 0) {
- TZWindow previous = windowList.get(windowList.size() - 1);
- window.validateWindowOrder(previous);
- }
- windowList.add(window);
- return this;
- }
-
- /**
- * Adds a window that applies until the end of time to the builder that can be
- * used to filter a set of rules.
- * <p>
- * This method defines and adds a window to the zone where the standard offset is specified.
- * The window limits the effect of subsequent additions of transition rules
- * or fixed savings. If neither rules or fixed savings are added to the window
- * then the window will default to no savings.
- * <p>
- * This must be added after all other windows.
- * No more windows can be added after this one.
- *
- * @param standardOffset the standard offset, not null
- * @return this, for chaining
- * @throws IllegalStateException if a forever window has already been added
- */
- public ZoneRulesBuilder addWindowForever(ZoneOffset standardOffset) {
- return addWindow(standardOffset, LocalDateTime.MAX, TimeDefinition.WALL);
- }
-
- //-----------------------------------------------------------------------
- /**
- * Sets the previously added window to have fixed savings.
- * <p>
- * Setting a window to have fixed savings simply means that a single daylight
- * savings amount applies throughout the window. The window could be small,
- * such as a single summer, or large, such as a multi-year daylight savings.
- * <p>
- * A window can either have fixed savings or rules but not both.
- *
- * @param fixedSavingAmountSecs the amount of saving to use for the whole window, not null
- * @return this, for chaining
- * @throws IllegalStateException if no window has yet been added
- * @throws IllegalStateException if the window already has rules
- */
- public ZoneRulesBuilder setFixedSavingsToWindow(int fixedSavingAmountSecs) {
- if (windowList.isEmpty()) {
- throw new IllegalStateException("Must add a window before setting the fixed savings");
- }
- TZWindow window = windowList.get(windowList.size() - 1);
- window.setFixedSavings(fixedSavingAmountSecs);
- return this;
- }
-
- //-----------------------------------------------------------------------
- /**
- * Adds a single transition rule to the current window.
- * <p>
- * This adds a rule such that the offset, expressed as a daylight savings amount,
- * changes at the specified date-time.
- *
- * @param transitionDateTime the date-time that the transition occurs as defined by timeDefintion, not null
- * @param timeDefinition the definition of how to convert local to actual time, not null
- * @param savingAmountSecs the amount of saving from the standard offset after the transition in seconds
- * @return this, for chaining
- * @throws IllegalStateException if no window has yet been added
- * @throws IllegalStateException if the window already has fixed savings
- * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules
- */
- public ZoneRulesBuilder addRuleToWindow(
- LocalDateTime transitionDateTime,
- TimeDefinition timeDefinition,
- int savingAmountSecs) {
- Objects.requireNonNull(transitionDateTime, "transitionDateTime");
- return addRuleToWindow(
- transitionDateTime.getYear(), transitionDateTime.getYear(),
- transitionDateTime.getMonth(), transitionDateTime.getDayOfMonth(),
- -1, transitionDateTime.getTime(), false, timeDefinition, savingAmountSecs);
- }
-
- /**
- * Adds a single transition rule to the current window.
- * <p>
- * This adds a rule such that the offset, expressed as a daylight savings amount,
- * changes at the specified date-time.
- *
- * @param year the year of the transition, from MIN_YEAR to MAX_YEAR
- * @param month the month of the transition, not null
- * @param dayOfMonthIndicator the day-of-month of the transition, adjusted by dayOfWeek,
- * from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month
- * @param time the time that the transition occurs as defined by timeDefintion, not null
- * @param timeEndOfDay whether midnight is at the end of day
- * @param timeDefinition the definition of how to convert local to actual time, not null
- * @param savingAmountSecs the amount of saving from the standard offset after the transition in seconds
- * @return this, for chaining
- * @throws DateTimeException if a date-time field is out of range
- * @throws IllegalStateException if no window has yet been added
- * @throws IllegalStateException if the window already has fixed savings
- * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules
- */
- public ZoneRulesBuilder addRuleToWindow(
- int year,
- int month,
- int dayOfMonthIndicator,
- LocalTime time,
- boolean timeEndOfDay,
- TimeDefinition timeDefinition,
- int savingAmountSecs) {
- return addRuleToWindow(year, year, month, dayOfMonthIndicator, -1, time, timeEndOfDay, timeDefinition, savingAmountSecs);
- }
-
- /**
- * Adds a multi-year transition rule to the current window.
- * <p>
- * This adds a rule such that the offset, expressed as a daylight savings amount,
- * changes at the specified date-time for each year in the range.
- *
- * @param startYear the start year of the rule, from MIN_YEAR to MAX_YEAR
- * @param endYear the end year of the rule, from MIN_YEAR to MAX_YEAR
- * @param month the month of the transition, from 1 to 12
- * @param dayOfMonthIndicator the day-of-month of the transition, adjusted by dayOfWeek,
- * from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month
- * @param dayOfWeek the day-of-week to adjust to, -1 if day-of-month should not be adjusted
- * @param time the time that the transition occurs as defined by timeDefintion, not null
- * @param timeEndOfDay whether midnight is at the end of day
- * @param timeDefinition the definition of how to convert local to actual time, not null
- * @param savingAmountSecs the amount of saving from the standard offset after the transition in seconds
- * @return this, for chaining
- * @throws DateTimeException if a date-time field is out of range
- * @throws IllegalArgumentException if the day of month indicator is invalid
- * @throws IllegalArgumentException if the end of day midnight flag does not match the time
- * @throws IllegalStateException if no window has yet been added
- * @throws IllegalStateException if the window already has fixed savings
- * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules
- */
- public ZoneRulesBuilder addRuleToWindow(
- int startYear,
- int endYear,
- int month,
- int dayOfMonthIndicator,
- int dayOfWeek,
- LocalTime time,
- boolean timeEndOfDay,
- TimeDefinition timeDefinition,
- int savingAmountSecs) {
- Objects.requireNonNull(time, "time");
- Objects.requireNonNull(timeDefinition, "timeDefinition");
- if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0) {
- throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
- }
- if (timeEndOfDay && time.equals(LocalTime.MIDNIGHT) == false) {
- throw new IllegalArgumentException("Time must be midnight when end of day flag is true");
- }
- if (windowList.isEmpty()) {
- throw new IllegalStateException("Must add a window before adding a rule");
- }
- TZWindow window = windowList.get(windowList.size() - 1);
- window.addRule(startYear, endYear, month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefinition, savingAmountSecs);
- return this;
- }
-
- //-----------------------------------------------------------------------
- /**
- * Completes the build converting the builder to a set of time-zone rules.
- * <p>
- * Calling this method alters the state of the builder.
- * Further rules should not be added to this builder once this method is called.
- *
- * @param zoneId the time-zone ID, not null
- * @return the zone rules, not null
- * @throws IllegalStateException if no windows have been added
- * @throws IllegalStateException if there is only one rule defined as being forever for any given window
- */
- public ZoneRules toRules(String zoneId) {
- Objects.requireNonNull(zoneId, "zoneId");
- if (windowList.isEmpty()) {
- throw new IllegalStateException("No windows have been added to the builder");
- }
-
- final List<ZoneOffsetTransition> standardTransitionList = new ArrayList<>(4);
- final List<ZoneOffsetTransition> transitionList = new ArrayList<>(256);
- final List<ZoneOffsetTransitionRule> lastTransitionRuleList = new ArrayList<>(2);
-
- // initialize the standard offset calculation
- final TZWindow firstWindow = windowList.get(0);
- ZoneOffset loopStandardOffset = firstWindow.standardOffset;
- int loopSavings = 0;
- if (firstWindow.fixedSavingAmountSecs != null) {
- loopSavings = firstWindow.fixedSavingAmountSecs;
- }
- final ZoneOffset firstWallOffset = ZoneOffset.ofTotalSeconds(loopStandardOffset.getTotalSeconds() + loopSavings);
- LocalDateTime loopWindowStart = LocalDateTime.of(YEAR_MIN_VALUE, 1, 1, 0, 0);
- ZoneOffset loopWindowOffset = firstWallOffset;
-
- // build the windows and rules to interesting data
- for (TZWindow window : windowList) {
- // tidy the state
- window.tidy(loopWindowStart.getYear());
-
- // calculate effective savings at the start of the window
- Integer effectiveSavings = window.fixedSavingAmountSecs;
- if (effectiveSavings == null) {
- // apply rules from this window together with the standard offset and
- // savings from the last window to find the savings amount applicable
- // at start of this window
- effectiveSavings = 0;
- for (TZRule rule : window.ruleList) {
- if (rule.toEpochSecond(loopStandardOffset, loopSavings) > loopWindowStart.toEpochSecond(loopWindowOffset)) {
- // previous savings amount found, which could be the savings amount at
- // the instant that the window starts (hence isAfter)
- break;
- }
- effectiveSavings = rule.savingAmountSecs;
- }
- }
-
- // check if standard offset changed, and update it
- if (loopStandardOffset.equals(window.standardOffset) == false) {
- standardTransitionList.add(
- new ZoneOffsetTransition(
- LocalDateTime.ofEpochSecond(loopWindowStart.toEpochSecond(loopWindowOffset), 0, loopStandardOffset),
- loopStandardOffset, window.standardOffset));
- loopStandardOffset = window.standardOffset;
- }
-
- // check if the start of the window represents a transition
- ZoneOffset effectiveWallOffset = ZoneOffset.ofTotalSeconds(loopStandardOffset.getTotalSeconds() + effectiveSavings);
- if (loopWindowOffset.equals(effectiveWallOffset) == false) {
- transitionList.add(new ZoneOffsetTransition(loopWindowStart, loopWindowOffset, effectiveWallOffset));
- }
- loopSavings = effectiveSavings;
-
- // apply rules within the window
- for (TZRule rule : window.ruleList) {
- if (rule.isTransition(loopSavings)) {
- ZoneOffsetTransition trans = rule.toTransition(loopStandardOffset, loopSavings);
- if (trans.toEpochSecond() < loopWindowStart.toEpochSecond(loopWindowOffset) == false &&
- trans.toEpochSecond() < window.createDateTimeEpochSecond(loopSavings)) {
- transitionList.add(trans);
- loopSavings = rule.savingAmountSecs;
- }
- }
- }
-
- // calculate last rules
- for (TZRule lastRule : window.lastRuleList) {
- lastTransitionRuleList.add(lastRule.toTransitionRule(loopStandardOffset, loopSavings));
- loopSavings = lastRule.savingAmountSecs;
- }
-
- // finally we can calculate the true end of the window, passing it to the next window
- loopWindowOffset = window.createWallOffset(loopSavings);
- loopWindowStart = LocalDateTime.ofEpochSecond(
- window.createDateTimeEpochSecond(loopSavings), 0, loopWindowOffset);
- }
-
- return new ZoneRules(
- firstWindow.standardOffset, firstWallOffset, standardTransitionList,
- transitionList, lastTransitionRuleList);
- }
-
- //-----------------------------------------------------------------------
- /**
- * A definition of a window in the time-line.
- * The window will have one standard offset and will either have a
- * fixed DST savings or a set of rules.
- */
- class TZWindow {
- /** The standard offset during the window, not null. */
- private final ZoneOffset standardOffset;
- /** The end local time, not null. */
- private final LocalDateTime windowEnd;
- /** The type of the end time, not null. */
- private final TimeDefinition timeDefinition;
-
- /** The fixed amount of the saving to be applied during this window. */
- private Integer fixedSavingAmountSecs;
- /** The rules for the current window. */
- private List<TZRule> ruleList = new ArrayList<>();
- /** The latest year that the last year starts at. */
- private int maxLastRuleStartYear = YEAR_MIN_VALUE;
- /** The last rules. */
- private List<TZRule> lastRuleList = new ArrayList<>();
-
- /**
- * Constructor.
- *
- * @param standardOffset the standard offset applicable during the window, not null
- * @param windowEnd the end of the window, relative to the time definition, null if forever
- * @param timeDefinition the time definition for calculating the true end, not null
- */
- TZWindow(
- ZoneOffset standardOffset,
- LocalDateTime windowEnd,
- TimeDefinition timeDefinition) {
- super();
- this.windowEnd = windowEnd;
- this.timeDefinition = timeDefinition;
- this.standardOffset = standardOffset;
- }
-
- /**
- * Sets the fixed savings amount for the window.
- *
- * @param fixedSavingAmount the amount of daylight saving to apply throughout the window, may be null
- * @throws IllegalStateException if the window already has rules
- */
- void setFixedSavings(int fixedSavingAmount) {
- if (ruleList.size() > 0 || lastRuleList.size() > 0) {
- throw new IllegalStateException("Window has DST rules, so cannot have fixed savings");
- }
- this.fixedSavingAmountSecs = fixedSavingAmount;
- }
-
- /**
- * Adds a rule to the current window.
- *
- * @param startYear the start year of the rule, from MIN_YEAR to MAX_YEAR
- * @param endYear the end year of the rule, from MIN_YEAR to MAX_YEAR
- * @param month the month of the transition, not null
- * @param dayOfMonthIndicator the day-of-month of the transition, adjusted by dayOfWeek,
- * from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month
- * @param dayOfWeek the day-of-week to adjust to, null if day-of-month should not be adjusted
- * @param time the time that the transition occurs as defined by timeDefintion, not null
- * @param timeEndOfDay whether midnight is at the end of day
- * @param timeDefinition the definition of how to convert local to actual time, not null
- * @param savingAmountSecs the amount of saving from the standard offset in seconds
- * @throws IllegalStateException if the window already has fixed savings
- * @throws IllegalStateException if the window has reached the maximum capacity of 2000 rules
- */
- void addRule(
- int startYear,
- int endYear,
- int month,
- int dayOfMonthIndicator,
- int dayOfWeek,
- LocalTime time,
- boolean timeEndOfDay,
- TimeDefinition timeDefinition,
- int savingAmountSecs) {
-
- if (fixedSavingAmountSecs != null) {
- throw new IllegalStateException("Window has a fixed DST saving, so cannot have DST rules");
- }
- if (ruleList.size() >= 2000) {
- throw new IllegalStateException("Window has reached the maximum number of allowed rules");
- }
- boolean lastRule = false;
- if (endYear == YEAR_MAX_VALUE) {
- lastRule = true;
- endYear = startYear;
- }
- int year = startYear;
- while (year <= endYear) {
- TZRule rule = new TZRule(year, month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefinition, savingAmountSecs);
- if (lastRule) {
- lastRuleList.add(rule);
- maxLastRuleStartYear = Math.max(startYear, maxLastRuleStartYear);
- } else {
- ruleList.add(rule);
- }
- year++;
- }
- }
-
- /**
- * Validates that this window is after the previous one.
- *
- * @param previous the previous window, not null
- * @throws IllegalStateException if the window order is invalid
- */
- void validateWindowOrder(TZWindow previous) {
- if (windowEnd.compareTo(previous.windowEnd) < 0) {
- throw new IllegalStateException("Windows must be added in date-time order: " +
- windowEnd + " < " + previous.windowEnd);
- }
- }
-
- /**
- * Adds rules to make the last rules all start from the same year.
- * Also add one more year to avoid weird case where penultimate year has odd offset.
- *
- * @param windowStartYear the window start year
- * @throws IllegalStateException if there is only one rule defined as being forever
- */
- void tidy(int windowStartYear) {
- if (lastRuleList.size() == 1) {
- throw new IllegalStateException("Cannot have only one rule defined as being forever");
- }
-
- // handle last rules
- if (windowEnd.equals(LocalDateTime.MAX)) {
- // setup at least one real rule, which closes off other windows nicely
- maxLastRuleStartYear = Math.max(maxLastRuleStartYear, windowStartYear) + 1;
- for (TZRule lastRule : lastRuleList) {
- addRule(lastRule.year, maxLastRuleStartYear, lastRule.month, lastRule.dayOfMonthIndicator,
- lastRule.dayOfWeek, lastRule.time, lastRule.timeEndOfDay, lastRule.timeDefinition, lastRule.savingAmountSecs);
- lastRule.year = maxLastRuleStartYear + 1;
- }
- if (maxLastRuleStartYear == YEAR_MAX_VALUE) {
- lastRuleList.clear();
- } else {
- maxLastRuleStartYear++;
- }
- } else {
- // convert all within the endYear limit
- int endYear = windowEnd.getYear();
- for (TZRule lastRule : lastRuleList) {
- addRule(lastRule.year, endYear + 1, lastRule.month, lastRule.dayOfMonthIndicator,
- lastRule.dayOfWeek, lastRule.time, lastRule.timeEndOfDay, lastRule.timeDefinition, lastRule.savingAmountSecs);
- }
- lastRuleList.clear();
- maxLastRuleStartYear = YEAR_MAX_VALUE;
- }
-
- // ensure lists are sorted
- Collections.sort(ruleList);
- Collections.sort(lastRuleList);
-
- // default fixed savings to zero
- if (ruleList.size() == 0 && fixedSavingAmountSecs == null) {
- fixedSavingAmountSecs = 0;
- }
- }
-
- /**
- * Checks if the window is empty.
- *
- * @return true if the window is only a standard offset
- */
- boolean isSingleWindowStandardOffset() {
- return windowEnd.equals(LocalDateTime.MAX) && timeDefinition == TimeDefinition.WALL &&
- fixedSavingAmountSecs == null && lastRuleList.isEmpty() && ruleList.isEmpty();
- }
-
- /**
- * Creates the wall offset for the local date-time at the end of the window.
- *
- * @param savingsSecs the amount of savings in use in seconds
- * @return the created date-time epoch second in the wall offset, not null
- */
- ZoneOffset createWallOffset(int savingsSecs) {
- return ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsSecs);
- }
-
- /**
- * Creates the offset date-time for the local date-time at the end of the window.
- *
- * @param savingsSecs the amount of savings in use in seconds
- * @return the created date-time epoch second in the wall offset, not null
- */
- long createDateTimeEpochSecond(int savingsSecs) {
- ZoneOffset wallOffset = createWallOffset(savingsSecs);
- LocalDateTime ldt = timeDefinition.createDateTime(windowEnd, standardOffset, wallOffset);
- return ldt.toEpochSecond(wallOffset);
- }
- }
-
- //-----------------------------------------------------------------------
- /**
- * A definition of the way a local time can be converted to an offset time.
- */
- class TZRule implements Comparable<TZRule> {
- private int year;
- private int month;
- private int dayOfMonthIndicator;
- private int dayOfWeek;
- private LocalTime time;
- private boolean timeEndOfDay; // Whether the local time is end of day.
- private TimeDefinition timeDefinition; // The type of the time.
- private int savingAmountSecs; // The amount of the saving to be applied after this point.
-
- /**
- * Constructor.
- *
- * @param year the year
- * @param month the month, value from 1 to 12
- * @param dayOfMonthIndicator the day-of-month of the transition, adjusted by dayOfWeek,
- * from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month
- * @param dayOfWeek the day-of-week, -1 if day-of-month is exact
- * @param time the time, not null
- * @param timeEndOfDay whether midnight is at the end of day
- * @param timeDefinition the time definition, not null
- * @param savingAfterSecs the savings amount in seconds
- */
- TZRule(int year, int month, int dayOfMonthIndicator,
- int dayOfWeek, LocalTime time, boolean timeEndOfDay,
- TimeDefinition timeDefinition, int savingAfterSecs) {
- this.year = year;
- this.month = month;
- this.dayOfMonthIndicator = dayOfMonthIndicator;
- this.dayOfWeek = dayOfWeek;
- this.time = time;
- this.timeEndOfDay = timeEndOfDay;
- this.timeDefinition = timeDefinition;
- this.savingAmountSecs = savingAfterSecs;
- }
-
- /**
- * Converts this to a transition.
- *
- * @param standardOffset the active standard offset, not null
- * @param savingsBeforeSecs the active savings in seconds
- * @return the transition, not null
- */
- ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs) {
- // copy of code in ZoneOffsetTransitionRule to avoid infinite loop
- LocalDate date = toLocalDate();
- LocalDateTime ldt = LocalDateTime.of(date, time);
- ZoneOffset wallOffset = ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs);
- LocalDateTime dt = timeDefinition.createDateTime(ldt, standardOffset, wallOffset);
- ZoneOffset offsetAfter = ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingAmountSecs);
- return new ZoneOffsetTransition(dt, wallOffset, offsetAfter);
- }
-
- /**
- * Returns the apoch second of this rules with the specified
- * active standard offset and active savings
- *
- * @param standardOffset the active standard offset, not null
- * @param savingsBeforeSecs the active savings in seconds
- * @return the transition epoch second
- */
- long toEpochSecond(ZoneOffset standardOffset, int savingsBeforeSecs) {
- LocalDateTime ldt = LocalDateTime.of(toLocalDate(), time);
- ZoneOffset wallOffset = ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs);
- return timeDefinition.createDateTime(ldt, standardOffset, wallOffset)
- .toEpochSecond(wallOffset);
- }
-
- /**
- * Tests if this a real transition with the active savings in seconds
- *
- * @param savingsBeforeSecs the active savings in seconds
- * @return true, if savings in seconds changes
- */
- boolean isTransition(int savingsBeforeSecs) {
- return savingAmountSecs != savingsBeforeSecs;
- }
-
- /**
- * Converts this to a transition rule.
- *
- * @param standardOffset the active standard offset, not null
- * @param savingsBeforeSecs the active savings before the transition in seconds
- * @return the transition, not null
- */
- ZoneOffsetTransitionRule toTransitionRule(ZoneOffset standardOffset, int savingsBeforeSecs) {
- // optimize stored format
- if (dayOfMonthIndicator < 0) {
- if (month != 2) { // not Month.FEBRUARY
- dayOfMonthIndicator = maxLengthOfMonth(month) - 6;
- }
- }
- if (timeEndOfDay && dayOfMonthIndicator > 0 &&
- (dayOfMonthIndicator == 28 && month == 2) == false) {
- LocalDate date = LocalDate.of(2004, month, dayOfMonthIndicator).plusDays(1); // leap-year
- month = date.getMonth();
- dayOfMonthIndicator = date.getDayOfMonth();
- if (dayOfWeek != -1) {
- dayOfWeek = plusDayOfWeek(dayOfWeek, 1);
- }
- timeEndOfDay = false;
- }
- // build rule
- return new ZoneOffsetTransitionRule(
- month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefinition,
- standardOffset,
- ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs),
- ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingAmountSecs));
- }
-
- public int compareTo(TZRule other) {
- int cmp = year - other.year;
- cmp = (cmp == 0 ? month - other.month : cmp);
- if (cmp == 0) {
- // convert to date to handle dow/domIndicator/timeEndOfDay
- LocalDate thisDate = toLocalDate();
- LocalDate otherDate = other.toLocalDate();
- cmp = thisDate.compareTo(otherDate);
- }
- cmp = (cmp == 0 ? time.compareTo(other.time) : cmp);
- return cmp;
- }
-
- private LocalDate toLocalDate() {
- LocalDate date;
- if (dayOfMonthIndicator < 0) {
- int monthLen = lengthOfMonth(month, isLeapYear(year));
- date = LocalDate.of(year, month, monthLen + 1 + dayOfMonthIndicator);
- if (dayOfWeek != -1) {
- date = previousOrSame(date, dayOfWeek);
- }
- } else {
- date = LocalDate.of(year, month, dayOfMonthIndicator);
- if (dayOfWeek != -1) {
- date = nextOrSame(date, dayOfWeek);
- }
- }
- if (timeEndOfDay) {
- date = date.plusDays(1);
- }
- return date;
- }
- }
-
-}
--- a/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c Fri Jun 27 14:21:31 2014 -0700
@@ -110,6 +110,7 @@
emit_inet("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IP, IP_MULTICAST_LOOP);
#ifdef AF_INET6
+ emit_inet6("StandardSocketOptions.IP_TOS", IPPROTO_IPV6, IPV6_TCLASS);
emit_inet6("StandardSocketOptions.IP_MULTICAST_IF", IPPROTO_IPV6, IPV6_MULTICAST_IF);
emit_inet6("StandardSocketOptions.IP_MULTICAST_TTL", IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
emit_inet6("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
--- a/jdk/src/share/classes/java/awt/AWTEvent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/AWTEvent.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -388,6 +388,8 @@
/**
* Returns the event type.
+ *
+ * @return the event's type id
*/
public int getID() {
return id;
@@ -446,6 +448,9 @@
/**
* Returns whether this event has been consumed.
+ *
+ * @return {@code true} if this event has been consumed;
+ * otherwise {@code false}
*/
protected boolean isConsumed() {
return consumed;
--- a/jdk/src/share/classes/java/awt/AWTEventMulticaster.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/AWTEventMulticaster.java Fri Jun 27 14:21:31 2014 -0700
@@ -110,7 +110,15 @@
TextListener, InputMethodListener, HierarchyListener,
HierarchyBoundsListener, MouseWheelListener {
- protected final EventListener a, b;
+ /**
+ * A variable in the event chain (listener-a)
+ */
+ protected final EventListener a;
+
+ /**
+ * A variable in the event chain (listener-b)
+ */
+ protected final EventListener b;
/**
* Creates an event multicaster instance which chains listener-a
@@ -537,6 +545,7 @@
* returns the resulting multicast listener.
* @param a component-listener-a
* @param b component-listener-b
+ * @return the resulting listener
*/
public static ComponentListener add(ComponentListener a, ComponentListener b) {
return (ComponentListener)addInternal(a, b);
@@ -547,6 +556,7 @@
* returns the resulting multicast listener.
* @param a container-listener-a
* @param b container-listener-b
+ * @return the resulting listener
*/
public static ContainerListener add(ContainerListener a, ContainerListener b) {
return (ContainerListener)addInternal(a, b);
@@ -557,6 +567,7 @@
* returns the resulting multicast listener.
* @param a focus-listener-a
* @param b focus-listener-b
+ * @return the resulting listener
*/
public static FocusListener add(FocusListener a, FocusListener b) {
return (FocusListener)addInternal(a, b);
@@ -567,6 +578,7 @@
* returns the resulting multicast listener.
* @param a key-listener-a
* @param b key-listener-b
+ * @return the resulting listener
*/
public static KeyListener add(KeyListener a, KeyListener b) {
return (KeyListener)addInternal(a, b);
@@ -577,6 +589,7 @@
* returns the resulting multicast listener.
* @param a mouse-listener-a
* @param b mouse-listener-b
+ * @return the resulting listener
*/
public static MouseListener add(MouseListener a, MouseListener b) {
return (MouseListener)addInternal(a, b);
@@ -587,6 +600,7 @@
* returns the resulting multicast listener.
* @param a mouse-motion-listener-a
* @param b mouse-motion-listener-b
+ * @return the resulting listener
*/
public static MouseMotionListener add(MouseMotionListener a, MouseMotionListener b) {
return (MouseMotionListener)addInternal(a, b);
@@ -597,6 +611,7 @@
* returns the resulting multicast listener.
* @param a window-listener-a
* @param b window-listener-b
+ * @return the resulting listener
*/
public static WindowListener add(WindowListener a, WindowListener b) {
return (WindowListener)addInternal(a, b);
@@ -607,6 +622,7 @@
* and returns the resulting multicast listener.
* @param a window-state-listener-a
* @param b window-state-listener-b
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
@@ -620,6 +636,7 @@
* and returns the resulting multicast listener.
* @param a window-focus-listener-a
* @param b window-focus-listener-b
+ * @return the resulting listener
* @since 1.4
*/
public static WindowFocusListener add(WindowFocusListener a,
@@ -632,6 +649,7 @@
* returns the resulting multicast listener.
* @param a action-listener-a
* @param b action-listener-b
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ActionListener add(ActionListener a, ActionListener b) {
@@ -643,6 +661,7 @@
* returns the resulting multicast listener.
* @param a item-listener-a
* @param b item-listener-b
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ItemListener add(ItemListener a, ItemListener b) {
@@ -654,11 +673,21 @@
* returns the resulting multicast listener.
* @param a adjustment-listener-a
* @param b adjustment-listener-b
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static AdjustmentListener add(AdjustmentListener a, AdjustmentListener b) {
return (AdjustmentListener)addInternal(a, b);
}
+
+ /**
+ * Adds text-listener-a with text-listener-b and
+ * returns the resulting multicast listener.
+ *
+ * @param a text-listener-a
+ * @param b text-listener-b
+ * @return the resulting listener
+ */
@SuppressWarnings("overloads")
public static TextListener add(TextListener a, TextListener b) {
return (TextListener)addInternal(a, b);
@@ -669,6 +698,7 @@
* returns the resulting multicast listener.
* @param a input-method-listener-a
* @param b input-method-listener-b
+ * @return the resulting listener
*/
public static InputMethodListener add(InputMethodListener a, InputMethodListener b) {
return (InputMethodListener)addInternal(a, b);
@@ -679,6 +709,7 @@
* returns the resulting multicast listener.
* @param a hierarchy-listener-a
* @param b hierarchy-listener-b
+ * @return the resulting listener
* @since 1.3
*/
@SuppressWarnings("overloads")
@@ -691,6 +722,7 @@
* returns the resulting multicast listener.
* @param a hierarchy-bounds-listener-a
* @param b hierarchy-bounds-listener-b
+ * @return the resulting listener
* @since 1.3
*/
public static HierarchyBoundsListener add(HierarchyBoundsListener a, HierarchyBoundsListener b) {
@@ -702,6 +734,7 @@
* returns the resulting multicast listener.
* @param a mouse-wheel-listener-a
* @param b mouse-wheel-listener-b
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
@@ -715,6 +748,7 @@
* returns the resulting multicast listener.
* @param l component-listener-l
* @param oldl the component-listener being removed
+ * @return the resulting listener
*/
public static ComponentListener remove(ComponentListener l, ComponentListener oldl) {
return (ComponentListener) removeInternal(l, oldl);
@@ -725,6 +759,7 @@
* returns the resulting multicast listener.
* @param l container-listener-l
* @param oldl the container-listener being removed
+ * @return the resulting listener
*/
public static ContainerListener remove(ContainerListener l, ContainerListener oldl) {
return (ContainerListener) removeInternal(l, oldl);
@@ -735,6 +770,7 @@
* returns the resulting multicast listener.
* @param l focus-listener-l
* @param oldl the focus-listener being removed
+ * @return the resulting listener
*/
public static FocusListener remove(FocusListener l, FocusListener oldl) {
return (FocusListener) removeInternal(l, oldl);
@@ -745,6 +781,7 @@
* returns the resulting multicast listener.
* @param l key-listener-l
* @param oldl the key-listener being removed
+ * @return the resulting listener
*/
public static KeyListener remove(KeyListener l, KeyListener oldl) {
return (KeyListener) removeInternal(l, oldl);
@@ -755,6 +792,7 @@
* returns the resulting multicast listener.
* @param l mouse-listener-l
* @param oldl the mouse-listener being removed
+ * @return the resulting listener
*/
public static MouseListener remove(MouseListener l, MouseListener oldl) {
return (MouseListener) removeInternal(l, oldl);
@@ -765,6 +803,7 @@
* and returns the resulting multicast listener.
* @param l mouse-motion-listener-l
* @param oldl the mouse-motion-listener being removed
+ * @return the resulting listener
*/
public static MouseMotionListener remove(MouseMotionListener l, MouseMotionListener oldl) {
return (MouseMotionListener) removeInternal(l, oldl);
@@ -775,6 +814,7 @@
* returns the resulting multicast listener.
* @param l window-listener-l
* @param oldl the window-listener being removed
+ * @return the resulting listener
*/
public static WindowListener remove(WindowListener l, WindowListener oldl) {
return (WindowListener) removeInternal(l, oldl);
@@ -785,6 +825,7 @@
* and returns the resulting multicast listener.
* @param l window-state-listener-l
* @param oldl the window-state-listener being removed
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
@@ -798,6 +839,7 @@
* and returns the resulting multicast listener.
* @param l window-focus-listener-l
* @param oldl the window-focus-listener being removed
+ * @return the resulting listener
* @since 1.4
*/
public static WindowFocusListener remove(WindowFocusListener l,
@@ -810,6 +852,7 @@
* returns the resulting multicast listener.
* @param l action-listener-l
* @param oldl the action-listener being removed
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ActionListener remove(ActionListener l, ActionListener oldl) {
@@ -821,6 +864,7 @@
* returns the resulting multicast listener.
* @param l item-listener-l
* @param oldl the item-listener being removed
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ItemListener remove(ItemListener l, ItemListener oldl) {
@@ -832,11 +876,21 @@
* returns the resulting multicast listener.
* @param l adjustment-listener-l
* @param oldl the adjustment-listener being removed
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static AdjustmentListener remove(AdjustmentListener l, AdjustmentListener oldl) {
return (AdjustmentListener) removeInternal(l, oldl);
}
+
+ /**
+ * Removes the old text-listener from text-listener-l and
+ * returns the resulting multicast listener.
+ *
+ * @param l text-listener-l
+ * @param oldl the text-listener being removed
+ * @return the resulting listener
+ */
@SuppressWarnings("overloads")
public static TextListener remove(TextListener l, TextListener oldl) {
return (TextListener) removeInternal(l, oldl);
@@ -847,6 +901,7 @@
* returns the resulting multicast listener.
* @param l input-method-listener-l
* @param oldl the input-method-listener being removed
+ * @return the resulting listener
*/
public static InputMethodListener remove(InputMethodListener l, InputMethodListener oldl) {
return (InputMethodListener) removeInternal(l, oldl);
@@ -857,6 +912,7 @@
* returns the resulting multicast listener.
* @param l hierarchy-listener-l
* @param oldl the hierarchy-listener being removed
+ * @return the resulting listener
* @since 1.3
*/
@SuppressWarnings("overloads")
@@ -870,6 +926,7 @@
* listener.
* @param l hierarchy-bounds-listener-l
* @param oldl the hierarchy-bounds-listener being removed
+ * @return the resulting listener
* @since 1.3
*/
public static HierarchyBoundsListener remove(HierarchyBoundsListener l, HierarchyBoundsListener oldl) {
@@ -881,6 +938,7 @@
* and returns the resulting multicast listener.
* @param l mouse-wheel-listener-l
* @param oldl the mouse-wheel-listener being removed
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
@@ -898,6 +956,7 @@
* a new AWTEventMulticaster instance which chains a with b.
* @param a event listener-a
* @param b event listener-b
+ * @return the resulting listener
*/
protected static EventListener addInternal(EventListener a, EventListener b) {
if (a == null) return b;
@@ -915,6 +974,7 @@
* Else, returns listener l.
* @param l the listener being removed from
* @param oldl the listener being removed
+ * @return the resulting listener
*/
protected static EventListener removeInternal(EventListener l, EventListener oldl) {
if (l == oldl || l == null) {
@@ -927,9 +987,14 @@
}
- /* Serialization support.
- */
-
+ /**
+ * Serialization support. Saves all Serializable listeners
+ * to a serialization stream.
+ *
+ * @param s the stream to save to
+ * @param k a prefix stream to put before each serializable listener
+ * @throws IOException if serialization fails
+ */
protected void saveInternal(ObjectOutputStream s, String k) throws IOException {
if (a instanceof AWTEventMulticaster) {
((AWTEventMulticaster)a).saveInternal(s, k);
@@ -948,6 +1013,14 @@
}
}
+ /**
+ * Saves a Serializable listener chain to a serialization stream.
+ *
+ * @param s the stream to save to
+ * @param k a prefix stream to put before each serializable listener
+ * @param l the listener chain to save
+ * @throws IOException if serialization fails
+ */
protected static void save(ObjectOutputStream s, String k, EventListener l) throws IOException {
if (l == null) {
return;
--- a/jdk/src/share/classes/java/awt/AWTKeyStroke.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/AWTKeyStroke.java Fri Jun 27 14:21:31 2014 -0700
@@ -802,6 +802,7 @@
* <code>AWTKeyStroke</code>) which is equal to this instance.
*
* @return a cached instance which is equal to this instance
+ * @throws java.io.ObjectStreamException if a serialization problem occurs
*/
protected Object readResolve() throws java.io.ObjectStreamException {
synchronized (AWTKeyStroke.class) {
--- a/jdk/src/share/classes/java/awt/AlphaComposite.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/AlphaComposite.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -621,7 +621,9 @@
/**
* Creates an <code>AlphaComposite</code> object with the specified rule.
+ *
* @param rule the compositing rule
+ * @return the {@code AlphaComposite} object created
* @throws IllegalArgumentException if <code>rule</code> is not one of
* the following: {@link #CLEAR}, {@link #SRC}, {@link #DST},
* {@link #SRC_OVER}, {@link #DST_OVER}, {@link #SRC_IN},
@@ -664,10 +666,12 @@
* the constant alpha to multiply with the alpha of the source.
* The source is multiplied with the specified alpha before being composited
* with the destination.
+ *
* @param rule the compositing rule
* @param alpha the constant alpha to be multiplied with the alpha of
* the source. <code>alpha</code> must be a floating point number in the
* inclusive range [0.0, 1.0].
+ * @return the {@code AlphaComposite} object created
* @throws IllegalArgumentException if
* <code>alpha</code> is less than 0.0 or greater than 1.0, or if
* <code>rule</code> is not one of
--- a/jdk/src/share/classes/java/awt/BorderLayout.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/BorderLayout.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -367,6 +367,8 @@
/**
* Returns the horizontal gap between components.
+ *
+ * @return the horizontal gap between components
* @since 1.1
*/
public int getHgap() {
@@ -375,6 +377,7 @@
/**
* Sets the horizontal gap between components.
+ *
* @param hgap the horizontal gap between components
* @since 1.1
*/
@@ -384,6 +387,8 @@
/**
* Returns the vertical gap between components.
+ *
+ * @return the vertical gap between components
* @since 1.1
*/
public int getVgap() {
@@ -392,6 +397,7 @@
/**
* Sets the vertical gap between components.
+ *
* @param vgap the vertical gap between components
* @since 1.1
*/
--- a/jdk/src/share/classes/java/awt/Button.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Button.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -238,6 +238,8 @@
* Returns the command name of the action event fired by this button.
* If the command name is <code>null</code> (default) then this method
* returns the label of the button.
+ *
+ * @return the action command name (or label) for this button
*/
public String getActionCommand() {
return (actionCommand == null? label : actionCommand);
--- a/jdk/src/share/classes/java/awt/Checkbox.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Checkbox.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -713,6 +713,9 @@
*/
private static final long serialVersionUID = 7881579233144754107L;
+ /**
+ * Constructor for {@code AccessibleAWTCheckbox}
+ */
public AccessibleAWTCheckbox() {
super();
Checkbox.this.addItemListener(this);
--- a/jdk/src/share/classes/java/awt/CheckboxGroup.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/CheckboxGroup.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -91,6 +91,10 @@
}
/**
+ * Returns the current choice from this check box group
+ * or {@code null} if none of checkboxes are selected.
+ *
+ * @return the selected checkbox
* @deprecated As of JDK version 1.1,
* replaced by <code>getSelectedCheckbox()</code>.
*/
@@ -120,6 +124,11 @@
}
/**
+ * Sets the currently selected check box in this group
+ * to be the specified check box and unsets all others.
+ *
+ * @param box the {@code Checkbox} to set as the
+ * current selection.
* @deprecated As of JDK version 1.1,
* replaced by <code>setSelectedCheckbox(Checkbox)</code>.
*/
--- a/jdk/src/share/classes/java/awt/Choice.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Choice.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -156,6 +156,7 @@
/**
* Returns the number of items in this <code>Choice</code> menu.
+ *
* @return the number of items in this <code>Choice</code> menu
* @see #getItem
* @since 1.1
@@ -165,6 +166,9 @@
}
/**
+ * Returns the number of items in this {@code Choice} menu.
+ *
+ * @return the number of items in this {@code Choice} menu
* @deprecated As of JDK version 1.1,
* replaced by <code>getItemCount()</code>.
*/
@@ -176,8 +180,10 @@
/**
* Gets the string at the specified index in this
* <code>Choice</code> menu.
- * @param index the index at which to begin
- * @see #getItemCount
+ *
+ * @param index the index at which to begin
+ * @return the item at the specified index
+ * @see #getItemCount
*/
public String getItem(int index) {
return getItemImpl(index);
@@ -759,6 +765,9 @@
*/
private static final long serialVersionUID = 7175603582428509322L;
+ /**
+ * Constructor for {@code AccessibleAWTChoice}
+ */
public AccessibleAWTChoice() {
super();
}
--- a/jdk/src/share/classes/java/awt/Component.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Component.java Fri Jun 27 14:21:31 2014 -0700
@@ -1075,6 +1075,7 @@
* @deprecated As of JDK version 1.1,
* programs should not directly manipulate peers;
* replaced by <code>boolean isDisplayable()</code>.
+ * @return the peer for this component
*/
@Deprecated
public ComponentPeer getPeer() {
@@ -1132,6 +1133,8 @@
/**
* Gets the <code>DropTarget</code> associated with this
* <code>Component</code>.
+ *
+ * @return the drop target
*/
public synchronized DropTarget getDropTarget() { return dropTarget; }
@@ -1498,6 +1501,11 @@
}
/**
+ * Enables or disables this component.
+ *
+ * @param b {@code true} to enable this component;
+ * otherwise {@code false}
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setEnabled(boolean)</code>.
*/
@@ -1656,6 +1664,11 @@
}
/**
+ * Makes this component visible or invisible.
+ *
+ * @param b {@code true} to make this component visible;
+ * otherwise {@code false}
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setVisible(boolean)</code>.
*/
@@ -2068,6 +2081,9 @@
/**
+ * Returns the location of this component's top left corner.
+ *
+ * @return the location of this component's top left corner
* @deprecated As of JDK version 1.1,
* replaced by <code>getLocation()</code>.
*/
@@ -2102,6 +2118,13 @@
}
/**
+ * Moves this component to a new location.
+ *
+ * @param x the <i>x</i>-coordinate of the new location's
+ * top-left corner in the parent's coordinate space
+ * @param y the <i>y</i>-coordinate of the new location's
+ * top-left corner in the parent's coordinate space
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setLocation(int, int)</code>.
*/
@@ -2150,6 +2173,11 @@
}
/**
+ * Returns the size of this component in the form of a
+ * {@code Dimension} object.
+ *
+ * @return the {@code Dimension} object that indicates the
+ * size of this component
* @deprecated As of JDK version 1.1,
* replaced by <code>getSize()</code>.
*/
@@ -2177,6 +2205,10 @@
}
/**
+ * Resizes this component.
+ *
+ * @param width the new width of the component
+ * @param height the new height of the component
* @deprecated As of JDK version 1.1,
* replaced by <code>setSize(int, int)</code>.
*/
@@ -2208,6 +2240,10 @@
}
/**
+ * Resizes this component so that it has width {@code d.width}
+ * and height {@code d.height}.
+ *
+ * @param d the new size of this component
* @deprecated As of JDK version 1.1,
* replaced by <code>setSize(Dimension)</code>.
*/
@@ -2231,6 +2267,9 @@
}
/**
+ * Returns the bounding rectangle of this component.
+ *
+ * @return the bounding rectangle for this component
* @deprecated As of JDK version 1.1,
* replaced by <code>getBounds()</code>.
*/
@@ -2265,6 +2304,13 @@
}
/**
+ * Reshapes the bounding rectangle for this component.
+ *
+ * @param x the <i>x</i> coordinate of the upper left corner of the rectangle
+ * @param y the <i>y</i> coordinate of the upper left corner of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setBounds(int, int, int, int)</code>.
*/
@@ -2631,6 +2677,9 @@
/**
+ * Returns the component's preferred size.
+ *
+ * @return the component's preferred size
* @deprecated As of JDK version 1.1,
* replaced by <code>getPreferredSize()</code>.
*/
@@ -2701,6 +2750,9 @@
}
/**
+ * Returns the minimum size of this component.
+ *
+ * @return the minimum size of this component
* @deprecated As of JDK version 1.1,
* replaced by <code>getMinimumSize()</code>.
*/
@@ -2781,6 +2833,8 @@
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
+ *
+ * @return the horizontal alignment of this component
*/
public float getAlignmentX() {
return CENTER_ALIGNMENT;
@@ -2792,6 +2846,8 @@
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
+ *
+ * @return the vertical alignment of this component
*/
public float getAlignmentY() {
return CENTER_ALIGNMENT;
@@ -3157,8 +3213,10 @@
* not have a cursor set, the cursor of its parent is returned.
* If no cursor is set in the entire hierarchy,
* <code>Cursor.DEFAULT_CURSOR</code> is returned.
+ *
+ * @return the cursor for this component
* @see #setCursor
- * @since 1.1
+ * @since 1.1
*/
public Cursor getCursor() {
return getCursor_NoClientCode();
@@ -3942,6 +4000,7 @@
* a lost state.
*/
protected boolean validatedContents; // = false
+
/**
* Size of the back buffers. (Note: these fields were added in 6.0
* but kept package-private to avoid exposing them in the spec.
@@ -3949,7 +4008,15 @@
* protected when they were introduced in 1.4, but now we just have
* to live with that decision.)
*/
+
+ /**
+ * The width of the back buffers
+ */
int width;
+
+ /**
+ * The height of the back buffers
+ */
int height;
/**
@@ -4304,6 +4371,8 @@
/**
* Creates the back buffers
+ *
+ * @param numBuffers the number of buffers to create
*/
protected void createBackBuffers(int numBuffers) {
if (numBuffers == 0) {
@@ -4593,6 +4662,9 @@
* better performance is desired, or if page-flipping is used as the
* buffer strategy.
*
+ * @param ignoreRepaint {@code true} if the paint messages from the OS
+ * should be ignored; otherwise {@code false}
+ *
* @since 1.4
* @see #getIgnoreRepaint
* @see Canvas#createBufferStrategy
@@ -4619,8 +4691,11 @@
* Checks whether this component "contains" the specified point,
* where <code>x</code> and <code>y</code> are defined to be
* relative to the coordinate system of this component.
+ *
* @param x the <i>x</i> coordinate of the point
* @param y the <i>y</i> coordinate of the point
+ * @return {@code true} if the point is within the component;
+ * otherwise {@code false}
* @see #getComponentAt(int, int)
* @since 1.1
*/
@@ -4629,6 +4704,12 @@
}
/**
+ * Checks whether the point is inside of this component.
+ *
+ * @param x the <i>x</i> coordinate of the point
+ * @param y the <i>y</i> coordinate of the point
+ * @return {@code true} if the point is within the component;
+ * otherwise {@code false}
* @deprecated As of JDK version 1.1,
* replaced by contains(int, int).
*/
@@ -4641,7 +4722,10 @@
* Checks whether this component "contains" the specified point,
* where the point's <i>x</i> and <i>y</i> coordinates are defined
* to be relative to the coordinate system of this component.
+ *
* @param p the point
+ * @return {@code true} if the point is within the component;
+ * otherwise {@code false}
* @throws NullPointerException if {@code p} is {@code null}
* @see #getComponentAt(Point)
* @since 1.1
@@ -4676,6 +4760,13 @@
}
/**
+ * Returns the component occupying the position specified (this component,
+ * or immediate child component, or null if neither
+ * of the first two occupies the location).
+ *
+ * @param x the <i>x</i> coordinate to search for components at
+ * @param y the <i>y</i> coordinate to search for components at
+ * @return the component at the specified location or {@code null}
* @deprecated As of JDK version 1.1,
* replaced by getComponentAt(int, int).
*/
@@ -4687,15 +4778,17 @@
/**
* Returns the component or subcomponent that contains the
* specified point.
- * @param p the point
- * @see java.awt.Component#contains
- * @since 1.1
+ * @param p the point
+ * @return the component at the specified location or {@code null}
+ * @see java.awt.Component#contains
+ * @since 1.1
*/
public Component getComponentAt(Point p) {
return getComponentAt(p.x, p.y);
}
/**
+ * @param e the event to deliver
* @deprecated As of JDK version 1.1,
* replaced by <code>dispatchEvent(AWTEvent e)</code>.
*/
@@ -6746,6 +6839,8 @@
}
/**
+ * @param evt the event to handle
+ * @return {@code true} if the event was handled, {@code false} otherwise
* @deprecated As of JDK version 1.1
* replaced by processEvent(AWTEvent).
*/
@@ -6789,6 +6884,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseEvent(MouseEvent).
*/
@@ -6798,6 +6897,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseMotionEvent(MouseEvent).
*/
@@ -6807,6 +6910,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseEvent(MouseEvent).
*/
@@ -6816,6 +6923,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseMotionEvent(MouseEvent).
*/
@@ -6825,6 +6936,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseEvent(MouseEvent).
*/
@@ -6834,6 +6949,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseEvent(MouseEvent).
*/
@@ -6843,6 +6962,9 @@
}
/**
+ * @param evt the event to handle
+ * @param key the key pressed
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processKeyEvent(KeyEvent).
*/
@@ -6852,6 +6974,9 @@
}
/**
+ * @param evt the event to handle
+ * @param key the key pressed
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processKeyEvent(KeyEvent).
*/
@@ -6861,6 +6986,9 @@
}
/**
+ * @param evt the event to handle
+ * @param what the object acted on
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* should register this component as ActionListener on component
* which fires action events.
@@ -7070,6 +7198,9 @@
}
/**
+ * @param evt the event to handle
+ * @param what the object focused
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processFocusEvent(FocusEvent).
*/
@@ -7079,6 +7210,9 @@
}
/**
+ * @param evt the event to handle
+ * @param what the object focused
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processFocusEvent(FocusEvent).
*/
@@ -8390,6 +8524,7 @@
* Returns an array of all the listeners which have been associated
* with the named property.
*
+ * @param propertyName the property name
* @return all of the <code>PropertyChangeListener</code>s associated with
* the named property; if no such listeners have been added or
* if <code>propertyName</code> is <code>null</code>, an empty
@@ -8400,8 +8535,7 @@
* @see #getPropertyChangeListeners
* @since 1.4
*/
- public PropertyChangeListener[] getPropertyChangeListeners(
- String propertyName) {
+ public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
synchronized (getObjectLock()) {
if (changeSupport == null) {
return new PropertyChangeListener[0];
@@ -8879,6 +9013,7 @@
* This method changes layout-related information, and therefore,
* invalidates the component hierarchy.
*
+ * @param o the orientation to be set
*
* @see ComponentOrientation
* @see #invalidate
@@ -8906,6 +9041,7 @@
* subclasses that wish to respect orientation should call this method to
* get the component's orientation before performing layout or drawing.
*
+ * @return the orientation to order the elements or text
* @see ComponentOrientation
*
* @author Laura Werner, IBM
@@ -9063,7 +9199,16 @@
*/
private volatile transient int propertyListenersCount = 0;
+ /**
+ * A component listener to track show/hide/resize events
+ * and convert them to PropertyChange events.
+ */
protected ComponentListener accessibleAWTComponentHandler = null;
+
+ /**
+ * A listener to track focus events
+ * and convert them to PropertyChange events.
+ */
protected FocusListener accessibleAWTFocusHandler = null;
/**
--- a/jdk/src/share/classes/java/awt/ComponentOrientation.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/ComponentOrientation.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -126,6 +126,8 @@
* Are lines horizontal?
* This will return true for horizontal, left-to-right writing
* systems such as Roman.
+ *
+ * @return {@code true} if this orientation has horizontal lines
*/
public boolean isHorizontal() {
return (orientation & HORIZ_BIT) != 0;
@@ -136,6 +138,8 @@
* Vertical Lines: Do lines run left-to-right?<br>
* This will return true for horizontal, left-to-right writing
* systems such as Roman.
+ *
+ * @return {@code true} if this orientation is left-to-right
*/
public boolean isLeftToRight() {
return (orientation & LTR_BIT) != 0;
@@ -143,7 +147,9 @@
/**
* Returns the orientation that is appropriate for the given locale.
+ *
* @param locale the specified locale
+ * @return the orientation for the locale
*/
public static ComponentOrientation getOrientation(Locale locale) {
// A more flexible implementation would consult a ResourceBundle
@@ -171,6 +177,8 @@
* <li>Return the default locale's orientation.
* </ol>
*
+ * @param bdl the bundle to use
+ * @return the orientation
* @deprecated As of J2SE 1.4, use {@link #getOrientation(java.util.Locale)}.
*/
@Deprecated
--- a/jdk/src/share/classes/java/awt/Container.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Container.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -310,6 +310,9 @@
}
/**
+ * Returns the number of components in this container.
+ *
+ * @return the number of components in this container
* @deprecated As of JDK version 1.1,
* replaced by getComponentCount().
*/
@@ -391,8 +394,11 @@
}
/**
+ * Returns the insets for this container.
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>getInsets()</code>.
+ * @return the insets for this container
*/
@Deprecated
public Insets insets() {
@@ -438,6 +444,9 @@
* displayed, the hierarchy must be validated thereafter in order to
* display the added component.
*
+ * @param name the name of the component to be added
+ * @param comp the component to be added
+ * @return the component added
* @exception NullPointerException if {@code comp} is {@code null}
* @see #add(Component, Object)
* @see #invalidate
@@ -1471,8 +1480,10 @@
/**
* Gets the layout manager for this container.
+ *
* @see #doLayout
* @see #setLayout
+ * @return the current layout manager for this container
*/
public LayoutManager getLayout() {
return layoutMgr;
@@ -3854,6 +3865,10 @@
*/
private volatile transient int propertyListenersCount = 0;
+ /**
+ * The handler to fire {@code PropertyChange}
+ * when children are added or removed
+ */
protected ContainerListener accessibleContainerHandler = null;
/**
--- a/jdk/src/share/classes/java/awt/Cursor.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Cursor.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -294,6 +294,7 @@
* @return the system specific custom cursor named
* @exception HeadlessException if
* <code>GraphicsEnvironment.isHeadless</code> returns true
+ * @exception AWTException in case of erroneous retrieving of the cursor
*/
static public Cursor getSystemCustomCursor(final String name)
throws AWTException, HeadlessException {
@@ -378,6 +379,8 @@
/**
* Return the system default cursor.
+ *
+ * @return the default cursor
*/
static public Cursor getDefaultCursor() {
return getPredefinedCursor(Cursor.DEFAULT_CURSOR);
@@ -416,6 +419,8 @@
/**
* Returns the type for this cursor.
+ *
+ * @return the cursor type
*/
public int getType() {
return type;
--- a/jdk/src/share/classes/java/awt/DisplayMode.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/DisplayMode.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -125,6 +125,8 @@
/**
* Returns whether the two display modes are equal.
+ *
+ * @param dm the display mode to compare to
* @return whether the two display modes are equal
*/
public boolean equals(DisplayMode dm) {
--- a/jdk/src/share/classes/java/awt/EventQueue.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/EventQueue.java Fri Jun 27 14:21:31 2014 -0700
@@ -222,6 +222,9 @@
});
}
+ /**
+ * Initializes a new instance of {@code EventQueue}.
+ */
public EventQueue() {
for (int i = 0; i < NUM_PRIORITIES; i++) {
queues[i] = new Queue();
--- a/jdk/src/share/classes/java/awt/Frame.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Frame.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1089,6 +1089,9 @@
}
/**
+ * Sets the cursor for this frame to the specified type.
+ *
+ * @param cursorType the cursor type
* @deprecated As of JDK version 1.1,
* replaced by <code>Component.setCursor(Cursor)</code>.
*/
@@ -1103,6 +1106,7 @@
/**
* @deprecated As of JDK version 1.1,
* replaced by <code>Component.getCursor()</code>.
+ * @return the cursor type for this frame
*/
@Deprecated
public int getCursorType() {
@@ -1124,6 +1128,8 @@
* ownerless {@code Dialog}s (introduced in release 1.6), use {@link
* Window#getOwnerlessWindows Window.getOwnerlessWindows}.
*
+ * @return the array of all {@code Frame}s created by this application
+ *
* @see Window#getWindows()
* @see Window#getOwnerlessWindows
*
--- a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java Fri Jun 27 14:21:31 2014 -0700
@@ -357,6 +357,8 @@
* <p>Notice that an application can supersede the registration
* of an earlier created font with a new one.
* </ul>
+ *
+ * @param font the font to be registered
* @return true if the <code>font</code> is successfully
* registered in this <code>GraphicsEnvironment</code>.
* @throws NullPointerException if <code>font</code> is null
--- a/jdk/src/share/classes/java/awt/GridBagLayout.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/GridBagLayout.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -981,9 +981,15 @@
* This method is obsolete and supplied for backwards
* compatibility only; new code should call {@link
* #getLayoutInfo(java.awt.Container, int) getLayoutInfo} instead.
- * This method is the same as <code>getLayoutInfo</code>;
- * refer to <code>getLayoutInfo</code> for details on parameters
- * and return value.
+ *
+ * Fills in an instance of {@code GridBagLayoutInfo} for the
+ * current set of managed children. This method is the same
+ * as {@code getLayoutInfo}; refer to {@code getLayoutInfo}
+ * description for details.
+ *
+ * @param parent the layout container
+ * @param sizeflag either {@code PREFERREDSIZE} or {@code MINSIZE}
+ * @return the {@code GridBagLayoutInfo} for the set of children
*/
protected GridBagLayoutInfo GetLayoutInfo(Container parent, int sizeflag) {
synchronized (parent.getTreeLock()) {
@@ -1611,13 +1617,17 @@
}
/**
+ * Adjusts the x, y, width, and height fields to the correct
+ * values depending on the constraint geometry and pads.
+ * <p>
* This method is obsolete and supplied for backwards
* compatibility only; new code should call {@link
* #adjustForGravity(java.awt.GridBagConstraints, java.awt.Rectangle)
* adjustForGravity} instead.
- * This method is the same as <code>adjustForGravity</code>;
- * refer to <code>adjustForGravity</code> for details
- * on parameters.
+ * This method is the same as <code>adjustForGravity</code>
+ *
+ * @param constraints the constraints to be applied
+ * @param r the {@code Rectangle} to be adjusted
*/
protected void AdjustForGravity(GridBagConstraints constraints,
Rectangle r) {
@@ -1995,9 +2005,12 @@
* This method is obsolete and supplied for backwards
* compatibility only; new code should call {@link
* #getMinSize(java.awt.Container, GridBagLayoutInfo) getMinSize} instead.
- * This method is the same as <code>getMinSize</code>;
- * refer to <code>getMinSize</code> for details on parameters
- * and return value.
+ * This method is the same as <code>getMinSize</code>
+ *
+ * @param parent the layout container
+ * @param info the layout info for this parent
+ * @return a <code>Dimension</code> object containing the
+ * minimum size
*/
protected Dimension GetMinSize(Container parent, GridBagLayoutInfo info) {
Dimension d = new Dimension();
@@ -2035,9 +2048,9 @@
* This method is obsolete and supplied for backwards
* compatibility only; new code should call {@link
* #arrangeGrid(Container) arrangeGrid} instead.
- * This method is the same as <code>arrangeGrid</code>;
- * refer to <code>arrangeGrid</code> for details on the
- * parameter.
+ * This method is the same as <code>arrangeGrid</code>
+ *
+ * @param parent the layout container
*/
protected void ArrangeGrid(Container parent) {
Component comp;
--- a/jdk/src/share/classes/java/awt/HeadlessException.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/HeadlessException.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,10 +38,24 @@
* JDK 1.4 serialVersionUID
*/
private static final long serialVersionUID = 167183644944358563L;
+
+ /**
+ * Constructs new {@code HeadlessException}
+ */
public HeadlessException() {}
+
+ /**
+ * Create a new instance with the specified detailed error message.
+ *
+ * @param msg the error message
+ */
public HeadlessException(String msg) {
super(msg);
}
+
+ /**
+ * {@inheritDoc}
+ */
public String getMessage() {
String superMessage = super.getMessage();
String headlessMessage = GraphicsEnvironment.getHeadlessMessage();
--- a/jdk/src/share/classes/java/awt/ItemSelectable.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/ItemSelectable.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,8 @@
/**
* Returns the selected items or <code>null</code> if no
* items are selected.
+ *
+ * @return the list of selected objects, or {@code null}
*/
public Object[] getSelectedObjects();
--- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Fri Jun 27 14:21:31 2014 -0700
@@ -1459,6 +1459,7 @@
* Returns an array of all the <code>PropertyChangeListener</code>s
* associated with the named property.
*
+ * @param propertyName the property name
* @return all of the <code>PropertyChangeListener</code>s associated with
* the named property or an empty array if no such listeners have
* been added.
@@ -1628,6 +1629,7 @@
* Returns an array of all the <code>VetoableChangeListener</code>s
* associated with the named property.
*
+ * @param propertyName the property name
* @return all of the <code>VetoableChangeListener</code>s associated with
* the named property or an empty array if no such listeners have
* been added.
--- a/jdk/src/share/classes/java/awt/Label.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Label.java Fri Jun 27 14:21:31 2014 -0700
@@ -193,7 +193,8 @@
* Gets the current alignment of this label. Possible values are
* <code>Label.LEFT</code>, <code>Label.RIGHT</code>, and
* <code>Label.CENTER</code>.
- * @see java.awt.Label#setAlignment
+ * @return the alignment of this label
+ * @see java.awt.Label#setAlignment
*/
public int getAlignment() {
return alignment;
@@ -321,6 +322,9 @@
*/
private static final long serialVersionUID = -3568967560160480438L;
+ /**
+ * Constructor for the accessible label.
+ */
public AccessibleAWTLabel() {
super();
}
--- a/jdk/src/share/classes/java/awt/LayoutManager.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/LayoutManager.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,9 @@
/**
* Calculates the preferred size dimensions for the specified
* container, given the components it contains.
- * @param parent the container to be laid out
+ *
+ * @param parent the container to be laid out
+ * @return the preferred dimension for the container
*
* @see #minimumLayoutSize
*/
@@ -70,7 +72,10 @@
/**
* Calculates the minimum size dimensions for the specified
* container, given the components it contains.
- * @param parent the component to be laid out
+ *
+ * @param parent the component to be laid out
+ * @return the minimum dimension for the container
+ *
* @see #preferredLayoutSize
*/
Dimension minimumLayoutSize(Container parent);
--- a/jdk/src/share/classes/java/awt/LayoutManager2.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/LayoutManager2.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,8 +55,11 @@
/**
* Calculates the maximum size dimensions for the specified container,
* given the components it contains.
+ *
* @see java.awt.Component#getMaximumSize
* @see LayoutManager
+ * @param target the target container
+ * @return the maximum size of the container
*/
public Dimension maximumLayoutSize(Container target);
@@ -66,6 +69,9 @@
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
+ *
+ * @param target the target container
+ * @return the x-axis alignment preference
*/
public float getLayoutAlignmentX(Container target);
@@ -75,12 +81,16 @@
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
+ *
+ * @param target the target container
+ * @return the y-axis alignment preference
*/
public float getLayoutAlignmentY(Container target);
/**
* Invalidates the layout, indicating that if the layout manager
* has cached information it should be discarded.
+ * @param target the target container
*/
public void invalidateLayout(Container target);
--- a/jdk/src/share/classes/java/awt/List.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/List.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -282,6 +282,9 @@
}
/**
+ * Returns the number of items in the list.
+ *
+ * @return the number of items in the list
* @deprecated As of JDK version 1.1,
* replaced by <code>getItemCount()</code>.
*/
@@ -333,7 +336,10 @@
}
/**
- * @deprecated replaced by <code>add(String)</code>.
+ * Adds the specified item to the end of the list.
+ *
+ * @param item the item to be added
+ * @deprecated replaced by <code>add(String)</code>.
*/
@Deprecated
public void addItem(String item) {
@@ -358,7 +364,12 @@
}
/**
- * @deprecated replaced by <code>add(String, int)</code>.
+ * Adds the specified item to the the list
+ * at the position indicated by the index.
+ *
+ * @param item the item to be added
+ * @param index the position at which to add the item
+ * @deprecated replaced by <code>add(String, int)</code>.
*/
@Deprecated
public synchronized void addItem(String item, int index) {
@@ -455,8 +466,11 @@
}
/**
- * @deprecated replaced by <code>remove(String)</code>
- * and <code>remove(int)</code>.
+ * Removes the item at the specified position.
+ *
+ * @param position the index of the item to delete
+ * @deprecated replaced by <code>remove(String)</code>
+ * and <code>remove(int)</code>.
*/
@Deprecated
public void delItem(int position) {
@@ -646,6 +660,10 @@
}
/**
+ * Determines if the specified item in the list is selected.
+ *
+ * @param index specifies the item to be checked
+ * @return {@code true} if the item is selected; otherwise {@code false}
* @deprecated As of JDK version 1.1,
* replaced by <code>isIndexSelected(int)</code>.
*/
@@ -672,6 +690,7 @@
/**
* Determines whether this list allows multiple selections.
+ *
* @return <code>true</code> if this list allows multiple
* selections; otherwise, <code>false</code>
* @see #setMultipleMode
@@ -682,6 +701,10 @@
}
/**
+ * Determines whether this list allows multiple selections.
+ *
+ * @return {@code true} if this list allows multiple
+ * selections; otherwise {@code false}
* @deprecated As of JDK version 1.1,
* replaced by <code>isMultipleMode()</code>.
*/
@@ -709,6 +732,9 @@
}
/**
+ * Enables or disables multiple selection mode for this list.
+ *
+ * @param b {@code true} to enable multiple mode, {@code false} otherwise
* @deprecated As of JDK version 1.1,
* replaced by <code>setMultipleMode(boolean)</code>.
*/
@@ -760,6 +786,11 @@
}
/**
+ * Returns the preferred size of this component
+ * assuming it has the specified number of rows.
+ *
+ * @param rows the number of rows
+ * @return the preferred dimensions for displaying this list
* @deprecated As of JDK version 1.1,
* replaced by <code>getPreferredSize(int)</code>.
*/
@@ -810,6 +841,11 @@
}
/**
+ * Returns the minimum dimensions for the list
+ * with the specified number of rows.
+ *
+ * @param rows the number of rows in the list
+ * @return the minimum dimensions for displaying this list
* @deprecated As of JDK version 1.1,
* replaced by <code>getMinimumSize(int)</code>.
*/
@@ -1146,6 +1182,10 @@
}
/**
+ * Deletes the list items in the specified index range.
+ *
+ * @param start the beginning index of the range to delete
+ * @param end the ending index of the range to delete
* @deprecated As of JDK version 1.1,
* Not for public use in the future.
* This method is expected to be retained only as a package
@@ -1290,6 +1330,9 @@
*/
private static final long serialVersionUID = 7924617370136012829L;
+ /**
+ * Constructs new {@code AccessibleAWTList}
+ */
public AccessibleAWTList() {
super();
List.this.addActionListener(this);
@@ -1491,6 +1534,13 @@
private List parent;
private int indexInParent;
+ /**
+ * Constructs new {@code AccessibleAWTListChild} with the given
+ * parent {@code List} and 0-based index of this object in the parent.
+ *
+ * @param parent the parent {@code List}
+ * @param indexInParent the index in the parent
+ */
public AccessibleAWTListChild(List parent, int indexInParent) {
this.parent = parent;
this.setAccessibleParent(parent);
--- a/jdk/src/share/classes/java/awt/MediaTracker.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/MediaTracker.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -643,9 +643,11 @@
* image is considered to have finished loading. Use the
* <code>statusID</code>, <code>isErrorID</code>, and
* <code>isErrorAny</code> methods to check for errors.
- * @param id the identifier of the images to check
- * @param ms the length of time, in milliseconds, to wait
- * for the loading to complete
+ * @param id the identifier of the images to check
+ * @param ms the length of time, in milliseconds, to wait
+ * for the loading to complete
+ * @return {@code true} if the loading completed in time;
+ * otherwise {@code false}
* @see java.awt.MediaTracker#waitForAll
* @see java.awt.MediaTracker#waitForID(int)
* @see java.awt.MediaTracker#statusID
--- a/jdk/src/share/classes/java/awt/Menu.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Menu.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -213,7 +213,7 @@
/**
* Get the number of items in this menu.
- * @return the number of items in this menu.
+ * @return the number of items in this menu
* @since 1.1
*/
public int getItemCount() {
@@ -221,6 +221,9 @@
}
/**
+ * Returns the number of items in this menu.
+ *
+ * @return the number of items in this menu
* @deprecated As of JDK version 1.1,
* replaced by <code>getItemCount()</code>.
*/
--- a/jdk/src/share/classes/java/awt/MenuBar.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/MenuBar.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -279,6 +279,9 @@
}
/**
+ * Gets the number of menus on the menu bar.
+ *
+ * @return the number of menus on the menu bar.
* @deprecated As of JDK version 1.1,
* replaced by <code>getMenuCount()</code>.
*/
@@ -338,10 +341,11 @@
* or <code>null</code> if none of the menu items being managed
* by this menu bar is associated with the specified menu
* shortcut.
- * @param s the specified menu shortcut.
- * @see java.awt.MenuItem
- * @see java.awt.MenuShortcut
- * @since 1.1
+ * @param s the specified menu shortcut.
+ * @return the menu item for the specified shortcut.
+ * @see java.awt.MenuItem
+ * @see java.awt.MenuShortcut
+ * @since 1.1
*/
public MenuItem getShortcutMenuItem(MenuShortcut s) {
int nmenus = getMenuCount();
--- a/jdk/src/share/classes/java/awt/MenuComponent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/MenuComponent.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -220,6 +220,7 @@
/**
* @deprecated As of JDK version 1.1,
* programs should not directly manipulate peers.
+ * @return the peer for this component
*/
@Deprecated
public MenuComponentPeer getPeer() {
--- a/jdk/src/share/classes/java/awt/MenuContainer.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/MenuContainer.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,10 +31,25 @@
*/
public interface MenuContainer {
+
+ /**
+ * Returns the font in use by this container.
+ *
+ * @return the menu font
+ */
Font getFont();
+
+ /**
+ * Removes the specified menu component from the menu.
+ *
+ * @param comp the menu component to remove
+ */
void remove(MenuComponent comp);
/**
+ * Posts an event to the listeners.
+ *
+ * @param evt the event to dispatch
* @deprecated As of JDK version 1.1
* replaced by dispatchEvent(AWTEvent).
*/
--- a/jdk/src/share/classes/java/awt/MenuItem.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/MenuItem.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -264,6 +264,9 @@
/**
* Checks whether this menu item is enabled.
+ *
+ * @return {@code true} if the item is enabled;
+ * otherwise {@code false}
* @see java.awt.MenuItem#setEnabled
* @since 1.0
*/
@@ -296,6 +299,10 @@
}
/**
+ * Sets whether or not this menu item can be chosen.
+ *
+ * @param b if {@code true}, enables this menu item;
+ * otherwise disables
* @deprecated As of JDK version 1.1,
* replaced by <code>setEnabled(boolean)</code>.
*/
@@ -494,8 +501,10 @@
/**
* Gets the command name of the action event that is fired
* by this menu item.
- * @see java.awt.MenuItem#setActionCommand
- * @since 1.1
+ *
+ * @return the action command name
+ * @see java.awt.MenuItem#setActionCommand
+ * @since 1.1
*/
public String getActionCommand() {
return getActionCommandImpl();
--- a/jdk/src/share/classes/java/awt/PrintGraphics.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/PrintGraphics.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 1997, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,8 @@
/**
* Returns the PrintJob object from which this PrintGraphics
* object originated.
+ *
+ * @return the print job for this object
*/
public PrintJob getPrintJob();
--- a/jdk/src/share/classes/java/awt/PrintJob.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/PrintJob.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,7 @@
* object is disposed. This graphics object will also implement
* the PrintGraphics interface.
* @see PrintGraphics
+ * @return the graphics context for printing the next page
*/
public abstract Graphics getGraphics();
@@ -49,6 +50,8 @@
* Returns the dimensions of the page in pixels.
* The resolution of the page is chosen so that it
* is similar to the screen resolution.
+ *
+ * @return the page dimension
*/
public abstract Dimension getPageDimension();
@@ -56,11 +59,16 @@
* Returns the resolution of the page in pixels per inch.
* Note that this doesn't have to correspond to the physical
* resolution of the printer.
+ *
+ * @return the page resolution
*/
public abstract int getPageResolution();
/**
* Returns true if the last page will be printed first.
+ *
+ * @return {@code true} if the last page will be printed first;
+ * otherwise {@code false}
*/
public abstract boolean lastPageFirst();
--- a/jdk/src/share/classes/java/awt/Robot.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Robot.java Fri Jun 27 14:21:31 2014 -0700
@@ -498,6 +498,8 @@
/**
* Returns the number of milliseconds this Robot sleeps after generating an event.
+ *
+ * @return the delay duration in milliseconds
*/
public synchronized int getAutoDelay() {
return autoDelay;
@@ -505,7 +507,10 @@
/**
* Sets the number of milliseconds this Robot sleeps after generating an event.
- * @throws IllegalArgumentException If <code>ms</code> is not between 0 and 60,000 milliseconds inclusive
+ *
+ * @param ms the delay duration in milliseconds
+ * @throws IllegalArgumentException If {@code ms}
+ * is not between 0 and 60,000 milliseconds inclusive
*/
public synchronized void setAutoDelay(int ms) {
checkDelayArgument(ms);
@@ -523,9 +528,11 @@
* Sleeps for the specified time.
* To catch any <code>InterruptedException</code>s that occur,
* <code>Thread.sleep()</code> may be used instead.
- * @param ms time to sleep in milliseconds
- * @throws IllegalArgumentException if <code>ms</code> is not between 0 and 60,000 milliseconds inclusive
- * @see java.lang.Thread#sleep
+ *
+ * @param ms time to sleep in milliseconds
+ * @throws IllegalArgumentException if {@code ms}
+ * is not between 0 and 60,000 milliseconds inclusive
+ * @see java.lang.Thread#sleep
*/
public synchronized void delay(int ms) {
checkDelayArgument(ms);
--- a/jdk/src/share/classes/java/awt/ScrollPane.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/ScrollPane.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -323,7 +323,9 @@
* represents the state of the vertical scrollbar.
* The declared return type of this method is
* <code>Adjustable</code> to maintain backward compatibility.
+ *
* @see java.awt.ScrollPaneAdjustable
+ * @return the vertical scrollbar state
*/
public Adjustable getVAdjustable() {
return vAdjustable;
@@ -334,7 +336,9 @@
* represents the state of the horizontal scrollbar.
* The declared return type of this method is
* <code>Adjustable</code> to maintain backward compatibility.
+ *
* @see java.awt.ScrollPaneAdjustable
+ * @return the horizontal scrollbar state
*/
public Adjustable getHAdjustable() {
return hAdjustable;
@@ -657,6 +661,9 @@
* Indicates whether or not scrolling will take place in response to
* the mouse wheel. Wheel scrolling is enabled by default.
*
+ * @return {@code true} if the wheel scrolling enabled;
+ * otherwise {@code false}
+ *
* @see #setWheelScrollingEnabled(boolean)
* @since 1.4
*/
--- a/jdk/src/share/classes/java/awt/Scrollbar.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Scrollbar.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -656,6 +656,9 @@
}
/**
+ * Returns the visible amount of this scroll bar.
+ *
+ * @return the visible amount of this scroll bar
* @deprecated As of JDK version 1.1,
* replaced by <code>getVisibleAmount()</code>.
*/
@@ -729,6 +732,10 @@
}
/**
+ * Sets the unit increment for this scroll bar.
+ *
+ * @param v the increment value
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setUnitIncrement(int)</code>.
*/
@@ -768,6 +775,9 @@
}
/**
+ * Returns the unit increment for this scrollbar.
+ *
+ * @return the unit increment for this scrollbar
* @deprecated As of JDK version 1.1,
* replaced by <code>getUnitIncrement()</code>.
*/
@@ -797,6 +807,9 @@
}
/**
+ * Sets the block increment for this scroll bar.
+ *
+ * @param v the block increment
* @deprecated As of JDK version 1.1,
* replaced by <code>setBlockIncrement()</code>.
*/
@@ -833,6 +846,10 @@
}
/**
+ * Returns the block increment of this scroll bar.
+ *
+ * @return the block increment of this scroll bar
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>getBlockIncrement()</code>.
*/
--- a/jdk/src/share/classes/java/awt/TextArea.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/TextArea.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -314,6 +314,11 @@
}
/**
+ * Inserts the specified text at the specified position
+ * in this text area.
+ *
+ * @param str the non-{@code null} text to insert
+ * @param pos the position at which to insert
* @deprecated As of JDK version 1.1,
* replaced by <code>insert(String, int)</code>.
*/
@@ -342,6 +347,9 @@
}
/**
+ * Appends the given text to the text area's current text.
+ *
+ * @param str the text to append
* @deprecated As of JDK version 1.1,
* replaced by <code>append(String)</code>.
*/
@@ -378,6 +386,15 @@
}
/**
+ * Replaces a range of characters between
+ * the indicated start and end positions
+ * with the specified replacement text (the text at the end
+ * position will not be replaced).
+ *
+ * @param str the non-{@code null} text to use as
+ * the replacement
+ * @param start the start position
+ * @param end the end position
* @deprecated As of JDK version 1.1,
* replaced by <code>replaceRange(String, int, int)</code>.
*/
@@ -492,6 +509,12 @@
}
/**
+ * Determines the preferred size of the text area with the specified
+ * number of rows and columns.
+ *
+ * @param rows the number of rows
+ * @param columns the number of columns
+ * @return the preferred dimensions needed for the text area
* @deprecated As of JDK version 1.1,
* replaced by <code>getPreferredSize(int, int)</code>.
*/
@@ -544,6 +567,12 @@
}
/**
+ * Determines the minimum size of the text area with the specified
+ * number of rows and columns.
+ *
+ * @param rows the number of rows
+ * @param columns the number of columns
+ * @return the minimum size for the text area
* @deprecated As of JDK version 1.1,
* replaced by <code>getMinimumSize(int, int)</code>.
*/
--- a/jdk/src/share/classes/java/awt/TextComponent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/TextComponent.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -107,6 +107,9 @@
// the background color of non-editable TextComponents.
boolean backgroundSetByClientCode = false;
+ /**
+ * A list of listeners that will receive events from this object.
+ */
transient protected TextListener textListener;
/*
--- a/jdk/src/share/classes/java/awt/TextField.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/TextField.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -272,6 +272,10 @@
}
/**
+ * Sets the character to be echoed when protected input is displayed.
+ *
+ * @param c the echo character for this text field
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setEchoChar(char)</code>.
*/
@@ -368,6 +372,12 @@
}
/**
+ * Returns the preferred size for this text field
+ * with the specified number of columns.
+ *
+ * @param columns the number of columns
+ * @return the preferred size for the text field
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>getPreferredSize(int)</code>.
*/
@@ -407,8 +417,9 @@
/**
* Gets the minimum dimensions for a text field with
* the specified number of columns.
- * @param columns the number of columns in
- * this text field.
+ * @param columns the number of columns in
+ * this text field.
+ * @return the minimum size for this text field
* @since 1.1
*/
public Dimension getMinimumSize(int columns) {
@@ -416,6 +427,11 @@
}
/**
+ * Returns the minimum dimensions for a text field with
+ * the specified number of columns.
+ *
+ * @param columns the number of columns
+ * @return the minimum size for this text field
* @deprecated As of JDK version 1.1,
* replaced by <code>getMinimumSize(int)</code>.
*/
--- a/jdk/src/share/classes/java/awt/Toolkit.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Toolkit.java Fri Jun 27 14:21:31 2014 -0700
@@ -422,7 +422,8 @@
* and allows the Component and Container classes to be extended directly
* to create windowless components that are defined entirely in java.
*
- * @param target The Component to be created.
+ * @param target The Component to be created.
+ * @return the peer for the specified component
*/
protected LightweightPeer createComponent(Component target) {
if (lightweightMarker == null) {
@@ -1370,6 +1371,9 @@
* {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and
* {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.
*
+ * @param keyCode the key code
+ * @return {@code true} if the given key is currently in its "on" state;
+ * otherwise {@code false}
* @exception java.lang.IllegalArgumentException if <code>keyCode</code>
* is not one of the valid key codes
* @exception java.lang.UnsupportedOperationException if the host system doesn't
@@ -1404,6 +1408,8 @@
* involve event processing and therefore may not be immediately
* observable through getLockingKeyState.
*
+ * @param keyCode the key code
+ * @param on the state of the key
* @exception java.lang.IllegalArgumentException if <code>keyCode</code>
* is not one of the valid key codes
* @exception java.lang.UnsupportedOperationException if the host system doesn't
@@ -1429,6 +1435,9 @@
/**
* Give native peers the ability to query the native container
* given a native component (eg the direct parent may be lightweight).
+ *
+ * @param c the component to fetch the container for
+ * @return the native container object for the component
*/
protected static Container getNativeContainer(Component c) {
return c.getNativeContainer();
@@ -1449,6 +1458,7 @@
* @param name a localized description of the cursor, for Java Accessibility use
* @exception IndexOutOfBoundsException if the hotSpot values are outside
* the bounds of the cursor
+ * @return the cursor created
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
@@ -1675,6 +1685,11 @@
/**
* Gets a property with the specified key and default.
* This method returns defaultValue if the property is not found.
+ *
+ * @param key the key
+ * @param defaultValue the default value
+ * @return the value of the property or the default value
+ * if the property was not found
*/
public static String getProperty(String key, String defaultValue) {
// first try platform specific bundle
@@ -1738,6 +1753,9 @@
* Creates the peer for a DragSourceContext.
* Always throws InvalidDndOperationException if
* GraphicsEnvironment.isHeadless() returns true.
+ *
+ * @param dge the {@code DragGestureEvent}
+ * @return the peer created
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException;
@@ -1775,6 +1793,9 @@
* representation for an underlying platform dependent desktop setting.
* For more information on desktop properties supported by the AWT see
* <a href="doc-files/DesktopProperties.html">AWT Desktop Properties</a>.
+ *
+ * @param propertyName the property name
+ * @return the value for the specified desktop property
*/
public final synchronized Object getDesktopProperty(String propertyName) {
// This is a workaround for headless toolkits. It would be
@@ -1818,6 +1839,9 @@
/**
* Sets the named desktop property to the specified value and fires a
* property change event to notify any listeners that the value has changed.
+ *
+ * @param name the property name
+ * @param newValue the new property value
*/
protected final void setDesktopProperty(String name, Object newValue) {
// This is a workaround for headless toolkits. It would be
--- a/jdk/src/share/classes/java/awt/Window.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Window.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1452,6 +1452,8 @@
/**
* Returns the owner of this window.
+ *
+ * @return the owner of this window
* @since 1.2
*/
public Window getOwner() {
@@ -1464,6 +1466,8 @@
/**
* Return an array containing all the windows this
* window currently owns.
+ *
+ * @return the array of all the owned windows
* @since 1.2
*/
public Window[] getOwnedWindows() {
@@ -1586,6 +1590,7 @@
* dialogs such as component positions, {@code LayoutManager}s
* or serialization.
*
+ * @return the array of all the {@code Window}s created by the application
* @see Frame#getFrames
* @see Window#getOwnerlessWindows
*
@@ -1608,6 +1613,8 @@
* dialogs such as component positions, {@code LayoutManager}s
* or serialization.
*
+ * @return the array of all the ownerless {@code Window}s
+ * created by this application
* @see Frame#getFrames
* @see Window#getWindows()
*
@@ -2849,6 +2856,7 @@
*
* This method can only be called while the window is not displayable.
*
+ * @param type the window type
* @throws IllegalComponentStateException if the window
* is displayable.
* @throws IllegalArgumentException if the type is {@code null}
@@ -2874,6 +2882,7 @@
/**
* Returns the type of the window.
*
+ * @return the type of the window
* @see #setType
* @since 1.7
*/
--- a/jdk/src/share/classes/java/lang/ClassLoader.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java Fri Jun 27 14:21:31 2014 -0700
@@ -1859,18 +1859,17 @@
String name = NativeLibrary.findBuiltinLib(file.getName());
boolean isBuiltin = (name != null);
if (!isBuiltin) {
- boolean exists = AccessController.doPrivileged(
- new PrivilegedAction<Object>() {
- public Object run() {
- return file.exists() ? Boolean.TRUE : null;
- }})
- != null;
- if (!exists) {
- return false;
- }
- try {
- name = file.getCanonicalPath();
- } catch (IOException e) {
+ name = AccessController.doPrivileged(
+ new PrivilegedAction<String>() {
+ public String run() {
+ try {
+ return file.exists() ? file.getCanonicalPath() : null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+ });
+ if (name == null) {
return false;
}
}
--- a/jdk/src/share/classes/java/lang/Package.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/lang/Package.java Fri Jun 27 14:21:31 2014 -0700
@@ -107,6 +107,7 @@
* loader to be found.
*
* @see ClassLoader#definePackage
+ * @since 1.2
*/
public class Package implements java.lang.reflect.AnnotatedElement {
/**
--- a/jdk/src/share/classes/java/lang/SafeVarargs.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/lang/SafeVarargs.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
* <li> the declaration is a fixed arity method or constructor
*
* <li> the declaration is a variable arity method that is neither
- * {@code static} nor {@code final}.
+ * {@code static} nor {@code final} nor {@code private}.
*
* </ul>
*
--- a/jdk/src/share/classes/java/util/Collections.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/util/Collections.java Fri Jun 27 14:21:31 2014 -0700
@@ -3031,9 +3031,11 @@
final Collection<E> c;
final Class<E> type;
- void typeCheck(Object o) {
+ @SuppressWarnings("unchecked")
+ E typeCheck(Object o) {
if (o != null && !type.isInstance(o))
throw new ClassCastException(badElementMsg(o));
+ return (E) o;
}
private String badElementMsg(Object o) {
@@ -3042,10 +3044,8 @@
}
CheckedCollection(Collection<E> c, Class<E> type) {
- if (c==null || type == null)
- throw new NullPointerException();
- this.c = c;
- this.type = type;
+ this.c = Objects.requireNonNull(c, "c");
+ this.type = Objects.requireNonNull(type, "type");
}
public int size() { return c.size(); }
@@ -3091,7 +3091,7 @@
@SuppressWarnings("unchecked")
Collection<E> checkedCopyOf(Collection<? extends E> coll) {
- Object[] a = null;
+ Object[] a;
try {
E[] z = zeroLengthElementArray();
a = coll.toArray(z);
@@ -3487,10 +3487,19 @@
return new CheckedList<>(list.subList(fromIndex, toIndex), type);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @throws ClassCastException if the class of an element returned by the
+ * operator prevents it from being added to this collection. The
+ * exception may be thrown after some elements of the list have
+ * already been replaced.
+ */
@Override
public void replaceAll(UnaryOperator<E> operator) {
- list.replaceAll(operator);
- }
+ list.replaceAll(e -> typeCheck(operator.apply(e)));
+ }
+
@Override
public void sort(Comparator<? super E> c) {
list.sort(c);
--- a/jdk/src/share/classes/java/util/Currency.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/java/util/Currency.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -212,13 +212,9 @@
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
- String homeDir = System.getProperty("java.home");
try {
- String dataFile = homeDir + File.separator +
- "lib" + File.separator + "currency.data";
try (DataInputStream dis = new DataInputStream(
- new BufferedInputStream(
- new FileInputStream(dataFile)))) {
+ new BufferedInputStream(getClass().getResourceAsStream("/java/util/currency.data")))) {
if (dis.readInt() != MAGIC_NUMBER) {
throw new InternalError("Currency data is possibly corrupted");
}
@@ -248,7 +244,7 @@
// look for the properties file for overrides
String propsFile = System.getProperty("java.util.currency.data");
if (propsFile == null) {
- propsFile = homeDir + File.separator + "lib" +
+ propsFile = System.getProperty("java.home") + File.separator + "lib" +
File.separator + "currency.properties";
}
try {
--- a/jdk/src/share/classes/javax/crypto/CipherInputStream.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/crypto/CipherInputStream.java Fri Jun 27 14:21:31 2014 -0700
@@ -170,7 +170,6 @@
* @return the next byte of data, or <code>-1</code> if the end of the
* stream is reached.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public int read() throws IOException {
if (ostart >= ofinish) {
@@ -196,7 +195,6 @@
* the stream has been reached.
* @exception IOException if an I/O error occurs.
* @see java.io.InputStream#read(byte[], int, int)
- * @since JCE1.2
*/
public int read(byte b[]) throws IOException {
return read(b, 0, b.length);
@@ -217,7 +215,6 @@
* the stream has been reached.
* @exception IOException if an I/O error occurs.
* @see java.io.InputStream#read()
- * @since JCE1.2
*/
public int read(byte b[], int off, int len) throws IOException {
if (ostart >= ofinish) {
@@ -254,7 +251,6 @@
* @param n the number of bytes to be skipped.
* @return the actual number of bytes skipped.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public long skip(long n) throws IOException {
int available = ofinish - ostart;
@@ -277,7 +273,6 @@
* @return the number of bytes that can be read from this input stream
* without blocking.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public int available() throws IOException {
return (ofinish - ostart);
@@ -292,7 +287,6 @@
* stream.
*
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void close() throws IOException {
if (closed) {
@@ -321,7 +315,6 @@
* <code>mark</code> and <code>reset</code> methods.
* @see java.io.InputStream#mark(int)
* @see java.io.InputStream#reset()
- * @since JCE1.2
*/
public boolean markSupported() {
return false;
--- a/jdk/src/share/classes/javax/crypto/CipherOutputStream.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/crypto/CipherOutputStream.java Fri Jun 27 14:21:31 2014 -0700
@@ -114,7 +114,6 @@
*
* @param b the <code>byte</code>.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void write(int b) throws IOException {
ibuffer[0] = (byte) b;
@@ -138,7 +137,6 @@
* @exception NullPointerException if <code>b</code> is null.
* @exception IOException if an I/O error occurs.
* @see javax.crypto.CipherOutputStream#write(byte[], int, int)
- * @since JCE1.2
*/
public void write(byte b[]) throws IOException {
write(b, 0, b.length);
@@ -152,7 +150,6 @@
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void write(byte b[], int off, int len) throws IOException {
obuffer = cipher.update(b, off, len);
@@ -174,7 +171,6 @@
* the cipher's block size, no bytes will be written out.
*
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void flush() throws IOException {
if (obuffer != null) {
@@ -198,7 +194,6 @@
* stream.
*
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void close() throws IOException {
if (closed) {
--- a/jdk/src/share/classes/javax/naming/InitialContext.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/naming/InitialContext.java Fri Jun 27 14:21:31 2014 -0700
@@ -125,7 +125,7 @@
* @see Context
* @see NamingManager#setInitialContextFactoryBuilder
* NamingManager.setInitialContextFactoryBuilder
- * @since JNDI 1.1 / Java 2 Platform, Standard Edition, v 1.3
+ * @since 1.3, JNDI 1.1
*/
public class InitialContext implements Context {
--- a/jdk/src/share/classes/javax/swing/event/AncestorEvent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/AncestorEvent.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -81,6 +81,8 @@
/**
* Returns the ancestor that the event actually occurred on.
+ *
+ * @return the {@code Container} object specifying the ancestor component
*/
public Container getAncestor() {
return ancestor;
@@ -90,6 +92,8 @@
* Returns the parent of the ancestor the event actually occurred on.
* This is most interesting in an ANCESTOR_REMOVED event, as
* the ancestor may no longer be in the component hierarchy.
+ *
+ * @return the {@code Container} object specifying the ancestor's parent
*/
public Container getAncestorParent() {
return ancestorParent;
@@ -97,6 +101,8 @@
/**
* Returns the component that the listener was added to.
+ *
+ * @return the {@code JComponent} on which the event occurred
*/
public JComponent getComponent() {
return (JComponent)getSource();
--- a/jdk/src/share/classes/javax/swing/event/AncestorListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/AncestorListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,9 @@
* if the source has actually become visible. For this to be true
* all its parents must be visible and it must be in a hierarchy
* rooted at a Window
+ *
+ * @param event an {@code AncestorEvent} signifying a change in an
+ * ancestor-component's display-status
*/
public void ancestorAdded(AncestorEvent event);
@@ -58,11 +61,17 @@
* if the source has actually become invisible. For this to be true
* at least one of its parents must by invisible or it is not in
* a hierarchy rooted at a Window
+ *
+ * @param event an {@code AncestorEvent} signifying a change in an
+ * ancestor-component's display-status
*/
public void ancestorRemoved(AncestorEvent event);
/**
* Called when either the source or one of its ancestors is moved.
+ *
+ * @param event an {@code AncestorEvent} signifying a change in an
+ * ancestor-component's display-status
*/
public void ancestorMoved(AncestorEvent event);
--- a/jdk/src/share/classes/javax/swing/event/CellEditorListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/CellEditorListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,9 +37,17 @@
public interface CellEditorListener extends java.util.EventListener {
- /** This tells the listeners the editor has ended editing */
+ /**
+ * This tells the listeners the editor has ended editing
+ *
+ * @param e the {@code ChangeEvent} containing the source of the event
+ */
public void editingStopped(ChangeEvent e);
- /** This tells the listeners the editor has canceled editing */
+ /**
+ * This tells the listeners the editor has canceled editing
+ *
+ * @param e the {@code ChangeEvent} containing the source of the event
+ */
public void editingCanceled(ChangeEvent e);
}
--- a/jdk/src/share/classes/javax/swing/event/EventListenerList.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/EventListenerList.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -120,6 +120,8 @@
* any such manipulation is necessary, it should be done
* on a copy of the array returned rather than the array
* itself.
+ *
+ * @return array of ListenerType-listener pairs
*/
public Object[] getListenerList() {
return listenerList;
@@ -127,6 +129,9 @@
/**
* Return an array of all the listeners of the given type.
+ *
+ * @param <T> the type of {@code EventListener} to search for
+ * @param t the type of {@code EventListener} classes to be returned
* @return all of the listeners of the specified type.
* @exception ClassCastException if the supplied class
* is not assignable to EventListener
@@ -148,6 +153,8 @@
/**
* Returns the total number of listeners for this listener list.
+ *
+ * @return an integer count of total number of listeners
*/
public int getListenerCount() {
return listenerList.length/2;
@@ -156,6 +163,9 @@
/**
* Returns the total number of listeners of the supplied type
* for this listener list.
+ *
+ * @param t the type of listeners to count
+ * @return the number of listeners of type {@code t}
*/
public int getListenerCount(Class<?> t) {
Object[] lList = listenerList;
@@ -173,7 +183,9 @@
/**
* Adds the listener as a listener of the specified type.
- * @param t the type of the listener to be added
+ *
+ * @param <T> the type of {@code EventListener} to add
+ * @param t the type of the {@code EventListener} class to add
* @param l the listener to be added
*/
public synchronized <T extends EventListener> void add(Class<T> t, T l) {
@@ -206,6 +218,8 @@
/**
* Removes the listener as a listener of the specified type.
+ *
+ * @param <T> the type of {@code EventListener}
* @param t the type of the listener to be removed
* @param l the listener to be removed
*/
--- a/jdk/src/share/classes/javax/swing/event/HyperlinkEvent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/HyperlinkEvent.java Fri Jun 27 14:21:31 2014 -0700
@@ -142,6 +142,8 @@
* This may be useful if a URL can't be formed
* from the description, in which case the associated
* URL would be null.
+ *
+ * @return the description of this link as a {@code String}
*/
public String getDescription() {
return desc;
--- a/jdk/src/share/classes/javax/swing/event/InternalFrameListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/InternalFrameListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,9 @@
public interface InternalFrameListener extends EventListener {
/**
* Invoked when a internal frame has been opened.
+ *
+ * @param e an {@code InternalFrameEvent} with information about the
+ * {@code JInteralFrame} that originated the event
* @see javax.swing.JInternalFrame#show
*/
public void internalFrameOpened(InternalFrameEvent e);
@@ -49,36 +52,54 @@
/**
* Invoked when an internal frame is in the process of being closed.
* The close operation can be overridden at this point.
+ *
+ * @param e an {@code InternalFrameEvent} with information about the
+ * {@code JInteralFrame} that originated the event
* @see javax.swing.JInternalFrame#setDefaultCloseOperation
*/
public void internalFrameClosing(InternalFrameEvent e);
/**
* Invoked when an internal frame has been closed.
+ *
+ * @param e an {@code InternalFrameEvent} with information about the
+ * {@code JInteralFrame} that originated the event
* @see javax.swing.JInternalFrame#setClosed
*/
public void internalFrameClosed(InternalFrameEvent e);
/**
* Invoked when an internal frame is iconified.
+ *
+ * @param e an {@code InternalFrameEvent} with information about the
+ * {@code JInteralFrame} that originated the event
* @see javax.swing.JInternalFrame#setIcon
*/
public void internalFrameIconified(InternalFrameEvent e);
/**
* Invoked when an internal frame is de-iconified.
+ *
+ * @param e an {@code InternalFrameEvent} with information about the
+ * {@code JInteralFrame} that originated the event
* @see javax.swing.JInternalFrame#setIcon
*/
public void internalFrameDeiconified(InternalFrameEvent e);
/**
* Invoked when an internal frame is activated.
+ *
+ * @param e an {@code InternalFrameEvent} with information about the
+ * {@code JInteralFrame} that originated the event
* @see javax.swing.JInternalFrame#setSelected
*/
public void internalFrameActivated(InternalFrameEvent e);
/**
* Invoked when an internal frame is de-activated.
+ *
+ * @param e an {@code InternalFrameEvent} with information about the
+ * {@code JInteralFrame} that originated the event
* @see javax.swing.JInternalFrame#setSelected
*/
public void internalFrameDeactivated(InternalFrameEvent e);
--- a/jdk/src/share/classes/javax/swing/event/ListSelectionEvent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/ListSelectionEvent.java Fri Jun 27 14:21:31 2014 -0700
@@ -63,6 +63,7 @@
* {@code lastIndex}. The selection of at least one index within the range will
* have changed.
*
+ * @param source the {@code Object} on which the event initially occurred
* @param firstIndex the first index in the range, <= lastIndex
* @param lastIndex the last index in the range, >= firstIndex
* @param isAdjusting whether or not this is one in a series of
--- a/jdk/src/share/classes/javax/swing/event/MenuKeyListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/MenuKeyListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,16 +37,22 @@
/**
* Invoked when a key has been typed.
* This event occurs when a key press is followed by a key release.
+ *
+ * @param e a {@code MenuKeyEvent}
*/
void menuKeyTyped(MenuKeyEvent e);
/**
* Invoked when a key has been pressed.
+ *
+ * @param e a {@code MenuKeyEvent}
*/
void menuKeyPressed(MenuKeyEvent e);
/**
* Invoked when a key has been released.
+ *
+ * @param e a {@code MenuKeyEvent}
*/
void menuKeyReleased(MenuKeyEvent e);
}
--- a/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/PopupMenuEvent.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
import java.util.EventObject;
/**
- * PopupMenuEvent only contains the source of the event which is the JPoupMenu
+ * PopupMenuEvent only contains the source of the event which is the JPopupMenu
* sending the event
* <p>
* <strong>Warning:</strong>
--- a/jdk/src/share/classes/javax/swing/event/PopupMenuListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/PopupMenuListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,17 +35,23 @@
/**
* This method is called before the popup menu becomes visible
+ *
+ * @param e a {@code PopupMenuEvent} containing the source of the event
*/
void popupMenuWillBecomeVisible(PopupMenuEvent e);
/**
* This method is called before the popup menu becomes invisible
* Note that a JPopupMenu can become invisible any time
+ *
+ * @param e a {@code PopupMenuEvent} containing the source of the event
*/
void popupMenuWillBecomeInvisible(PopupMenuEvent e);
/**
* This method is called when the popup menu is canceled
+ *
+ * @param e a {@code PopupMenuEvent} containing the source of the event
*/
void popupMenuCanceled(PopupMenuEvent e);
}
--- a/jdk/src/share/classes/javax/swing/event/TableColumnModelEvent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/TableColumnModelEvent.java Fri Jun 27 14:21:31 2014 -0700
@@ -83,9 +83,17 @@
// Querying Methods
//
- /** Returns the fromIndex. Valid for removed or moved events */
+ /**
+ * Returns the fromIndex. Valid for removed or moved events
+ *
+ * @return int value for index from which the column was moved or removed
+ */
public int getFromIndex() { return fromIndex; };
- /** Returns the toIndex. Valid for add and moved events */
+ /**
+ * Returns the toIndex. Valid for add and moved events
+ *
+ * @return int value of column's new index
+ */
public int getToIndex() { return toIndex; };
}
--- a/jdk/src/share/classes/javax/swing/event/TableColumnModelListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/TableColumnModelListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,21 +39,39 @@
public interface TableColumnModelListener extends java.util.EventListener
{
- /** Tells listeners that a column was added to the model. */
+ /**
+ * Tells listeners that a column was added to the model.
+ *
+ * @param e a {@code TableColumnModelEvent}
+ */
public void columnAdded(TableColumnModelEvent e);
- /** Tells listeners that a column was removed from the model. */
+ /**
+ * Tells listeners that a column was removed from the model.
+ *
+ * @param e a {@code TableColumnModelEvent}
+ */
public void columnRemoved(TableColumnModelEvent e);
- /** Tells listeners that a column was repositioned. */
+ /**
+ * Tells listeners that a column was repositioned.
+ *
+ * @param e a {@code TableColumnModelEvent}
+ */
public void columnMoved(TableColumnModelEvent e);
- /** Tells listeners that a column was moved due to a margin change. */
+ /**
+ * Tells listeners that a column was moved due to a margin change.
+ *
+ * @param e a {@code ChangeEvent}
+ */
public void columnMarginChanged(ChangeEvent e);
/**
* Tells listeners that the selection model of the
* TableColumnModel changed.
+ *
+ * @param e a {@code ListSelectionEvent}
*/
public void columnSelectionChanged(ListSelectionEvent e);
}
--- a/jdk/src/share/classes/javax/swing/event/TableModelEvent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/TableModelEvent.java Fri Jun 27 14:21:31 2014 -0700
@@ -95,13 +95,15 @@
//
/**
- * All row data in the table has changed, listeners should discard any state
- * that was based on the rows and requery the <code>TableModel</code>
- * to get the new row count and all the appropriate values.
- * The <code>JTable</code> will repaint the entire visible region on
- * receiving this event, querying the model for the cell values that are visible.
- * The structure of the table ie, the column names, types and order
- * have not changed.
+ * All row data in the table has changed, listeners should discard any state
+ * that was based on the rows and requery the <code>TableModel</code>
+ * to get the new row count and all the appropriate values.
+ * The <code>JTable</code> will repaint the entire visible region on
+ * receiving this event, querying the model for the cell values that are visible.
+ * The structure of the table ie, the column names, types and order
+ * have not changed.
+ *
+ * @param source the {@code TableModel} affected by this event
*/
public TableModelEvent(TableModel source) {
// Use Integer.MAX_VALUE instead of getRowCount() in case rows were deleted.
@@ -109,21 +111,28 @@
}
/**
- * This row of data has been updated.
- * To denote the arrival of a completely new table with a different structure
- * use <code>HEADER_ROW</code> as the value for the <code>row</code>.
- * When the <code>JTable</code> receives this event and its
- * <code>autoCreateColumnsFromModel</code>
- * flag is set it discards any TableColumns that it had and reallocates
- * default ones in the order they appear in the model. This is the
- * same as calling <code>setModel(TableModel)</code> on the <code>JTable</code>.
+ * This row of data has been updated.
+ * To denote the arrival of a completely new table with a different structure
+ * use <code>HEADER_ROW</code> as the value for the <code>row</code>.
+ * When the <code>JTable</code> receives this event and its
+ * <code>autoCreateColumnsFromModel</code>
+ * flag is set it discards any TableColumns that it had and reallocates
+ * default ones in the order they appear in the model. This is the
+ * same as calling <code>setModel(TableModel)</code> on the <code>JTable</code>.
+ *
+ * @param source the {@code TableModel} affected by this event
+ * @param row the row which has been updated
*/
public TableModelEvent(TableModel source, int row) {
this(source, row, row, ALL_COLUMNS, UPDATE);
}
/**
- * The data in rows [<I>firstRow</I>, <I>lastRow</I>] have been updated.
+ * The data in rows [<I>firstRow</I>, <I>lastRow</I>] have been updated.
+ *
+ * @param source the {@code TableModel} affected by this event
+ * @param firstRow the first row affected by this event
+ * @param lastRow the last row affected by this event
*/
public TableModelEvent(TableModel source, int firstRow, int lastRow) {
this(source, firstRow, lastRow, ALL_COLUMNS, UPDATE);
@@ -132,18 +141,32 @@
/**
* The cells in column <I>column</I> in the range
* [<I>firstRow</I>, <I>lastRow</I>] have been updated.
+ *
+ * @param source the {@code TableModel} affected by this event
+ * @param firstRow the first row affected by this event
+ * @param lastRow the last row affected by this event
+ * @param column the column index of cells changed; {@code ALL_COLUMNS}
+ * signifies all cells in the specified range of rows are changed.
*/
public TableModelEvent(TableModel source, int firstRow, int lastRow, int column) {
this(source, firstRow, lastRow, column, UPDATE);
}
/**
- * The cells from (firstRow, column) to (lastRow, column) have been changed.
- * The <I>column</I> refers to the column index of the cell in the model's
- * co-ordinate system. When <I>column</I> is ALL_COLUMNS, all cells in the
- * specified range of rows are considered changed.
- * <p>
- * The <I>type</I> should be one of: INSERT, UPDATE and DELETE.
+ * The cells from (firstRow, column) to (lastRow, column) have been changed.
+ * The <I>column</I> refers to the column index of the cell in the model's
+ * co-ordinate system. When <I>column</I> is ALL_COLUMNS, all cells in the
+ * specified range of rows are considered changed.
+ * <p>
+ * The <I>type</I> should be one of: INSERT, UPDATE and DELETE.
+ *
+ * @param source the {@code TableModel} affected by this event
+ * @param firstRow the first row affected by this event
+ * @param lastRow the last row affected by this event
+ * @param column the column index of cells changed; {@code ALL_COLUMNS}
+ * signifies all cells in the specified range of rows are changed.
+ * @param type the type of change signified by this even, @code INSERT},
+ * {@code DELETE } or {@code UPDATE}
*/
public TableModelEvent(TableModel source, int firstRow, int lastRow, int column, int type) {
super(source);
@@ -157,23 +180,36 @@
// Querying Methods
//
- /** Returns the first row that changed. HEADER_ROW means the meta data,
+ /**
+ * Returns the first row that changed. HEADER_ROW means the meta data,
* ie. names, types and order of the columns.
+ *
+ * @return an integer signifying the first row changed
*/
public int getFirstRow() { return firstRow; };
- /** Returns the last row that changed. */
+ /**
+ * Returns the last row that changed.
+ *
+ * @return an integer signifying the last row changed
+ */
public int getLastRow() { return lastRow; };
/**
* Returns the column for the event. If the return
* value is ALL_COLUMNS; it means every column in the specified
* rows changed.
+ *
+ * @return an integer signifying which column is affected by this event
*/
public int getColumn() { return column; };
/**
* Returns the type of event - one of: INSERT, UPDATE and DELETE.
+ *
+ * @return the type of change to a table model, an {@code INSERT} or
+ * {@code DELETE } of row(s) or column(s) or {@code UPDATE}
+ * to data
*/
public int getType() { return type; }
}
--- a/jdk/src/share/classes/javax/swing/event/TableModelListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/TableModelListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,9 @@
/**
* This fine grain notification tells listeners the exact range
* of cells, rows, or columns that changed.
+ *
+ * @param e a {@code TableModelEvent} to notify listener that a table model
+ * has changed
*/
public void tableChanged(TableModelEvent e);
}
--- a/jdk/src/share/classes/javax/swing/event/TreeExpansionEvent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/TreeExpansionEvent.java Fri Jun 27 14:21:31 2014 -0700
@@ -54,7 +54,7 @@
/**
* Path to the value this event represents.
*/
- protected TreePath path;
+ protected TreePath path;
/**
* Constructs a TreeExpansionEvent object.
@@ -71,6 +71,8 @@
/**
* Returns the path to the value that has been expanded/collapsed.
+ *
+ * @return this event's {@code TreePath} object
*/
public TreePath getPath() { return path; }
}
--- a/jdk/src/share/classes/javax/swing/event/TreeExpansionListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/TreeExpansionListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,12 +41,18 @@
public interface TreeExpansionListener extends EventListener
{
/**
- * Called whenever an item in the tree has been expanded.
- */
+ * Called whenever an item in the tree has been expanded.
+ *
+ * @param event a {@code TreeExpansionEvent} containing a {@code TreePath}
+ * object for the expanded node
+ */
public void treeExpanded(TreeExpansionEvent event);
/**
- * Called whenever an item in the tree has been collapsed.
- */
+ * Called whenever an item in the tree has been collapsed.
+ *
+ * @param event a {@code TreeExpansionEvent} containing a {@code TreePath}
+ * object for the collapsed node
+ */
public void treeCollapsed(TreeExpansionEvent event);
}
--- a/jdk/src/share/classes/javax/swing/event/TreeModelListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/TreeModelListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,25 +46,26 @@
* altered their children arrays, but other attributes have
* changed and may affect presentation. Example: the name of a
* file has changed, but it is in the same location in the file
- * system.</p>
+ * system.
+ *
* <p>To indicate the root has changed, childIndices and children
- * will be null. </p>
+ * will be null.
*
- * <p>Use <code>e.getPath()</code>
- * to get the parent of the changed node(s).
- * <code>e.getChildIndices()</code>
- * returns the index(es) of the changed node(s).</p>
+ * <p>Use {@code e.getPath()} to get the parent of the changed node(s).
+ * {@code e.getChildIndices()} returns the index(es) of the changed node(s).
+ *
+ * @param e a {@code TreeModelEvent} describing changes to a tree model
*/
void treeNodesChanged(TreeModelEvent e);
/**
* <p>Invoked after nodes have been inserted into the tree.</p>
*
- * <p>Use <code>e.getPath()</code>
- * to get the parent of the new node(s).
- * <code>e.getChildIndices()</code>
- * returns the index(es) of the new node(s)
- * in ascending order.</p>
+ * <p>Use {@code e.getPath()} to get the parent of the new node(s).
+ * {@code e.getChildIndices()} returns the index(es) of the new node(s)
+ * in ascending order.
+ *
+ * @param e a {@code TreeModelEvent} describing changes to a tree model
*/
void treeNodesInserted(TreeModelEvent e);
@@ -74,11 +75,11 @@
* invoked once for the root of the removed subtree, not once for
* each individual set of siblings removed.</p>
*
- * <p>Use <code>e.getPath()</code>
- * to get the former parent of the deleted node(s).
- * <code>e.getChildIndices()</code>
- * returns, in ascending order, the index(es)
- * the node(s) had before being deleted.</p>
+ * <p>Use {@code e.getPath()} to get the former parent of the deleted
+ * node(s). {@code e.getChildIndices()} returns, in ascending order, the
+ * index(es) the node(s) had before being deleted.
+ *
+ * @param e a {@code TreeModelEvent} describing changes to a tree model
*/
void treeNodesRemoved(TreeModelEvent e);
@@ -88,10 +89,10 @@
* one and the first element does not identify the current root node
* the first element should become the new root of the tree.
*
- * <p>Use <code>e.getPath()</code>
- * to get the path to the node.
- * <code>e.getChildIndices()</code>
- * returns null.</p>
+ * <p>Use {@code e.getPath()} to get the path to the node.
+ * {@code e.getChildIndices()} returns null.
+ *
+ * @param e a {@code TreeModelEvent} describing changes to a tree model
*/
void treeStructureChanged(TreeModelEvent e);
--- a/jdk/src/share/classes/javax/swing/event/TreeSelectionEvent.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/TreeSelectionEvent.java Fri Jun 27 14:21:31 2014 -0700
@@ -62,12 +62,16 @@
protected TreePath newLeadSelectionPath;
/**
- * Represents a change in the selection of a TreeSelectionModel.
- * paths identifies the paths that have been either added or
+ * Represents a change in the selection of a {@code TreeSelectionModel}.
+ * {@code paths} identifies the paths that have been either added or
* removed from the selection.
*
* @param source source of event
* @param paths the paths that have changed in the selection
+ * @param areNew a {@code boolean} array indicating whether the paths in
+ * {@code paths} are new to the selection
+ * @param oldLeadSelectionPath the previous lead selection path
+ * @param newLeadSelectionPath the new lead selection path
*/
public TreeSelectionEvent(Object source, TreePath[] paths,
boolean[] areNew, TreePath oldLeadSelectionPath,
@@ -81,14 +85,16 @@
}
/**
- * Represents a change in the selection of a TreeSelectionModel.
- * path identifies the path that have been either added or
+ * Represents a change in the selection of a {@code TreeSelectionModel}.
+ * {@code path} identifies the path that has been either added or
* removed from the selection.
*
* @param source source of event
* @param path the path that has changed in the selection
* @param isNew whether or not the path is new to the selection, false
- * means path was removed from the selection.
+ * means path was removed from the selection.
+ * @param oldLeadSelectionPath the previous lead selection path
+ * @param newLeadSelectionPath the new lead selection path
*/
public TreeSelectionEvent(Object source, TreePath path, boolean isNew,
TreePath oldLeadSelectionPath,
@@ -104,8 +110,9 @@
}
/**
- * Returns the paths that have been added or removed from the
- * selection.
+ * Returns the paths that have been added or removed from the selection.
+ *
+ * @return copy of the array of {@code TreePath} obects for this event.
*/
public TreePath[] getPaths()
{
@@ -120,6 +127,8 @@
/**
* Returns the first path element.
+ *
+ * @return the first {@code TreePath} element represented by this event
*/
public TreePath getPath()
{
@@ -187,6 +196,8 @@
/**
* Returns the path that was previously the lead path.
+ *
+ * @return a {@code TreePath} containing the old lead selection path
*/
public TreePath getOldLeadSelectionPath() {
return oldLeadSelectionPath;
@@ -194,6 +205,8 @@
/**
* Returns the current lead path.
+ *
+ * @return a {@code TreePath} containing the new lead selection path
*/
public TreePath getNewLeadSelectionPath() {
return newLeadSelectionPath;
@@ -201,10 +214,14 @@
/**
* Returns a copy of the receiver, but with the source being newSource.
+ *
+ * @param newSource source of event
+ * @return an {@code Object} which is a copy of this event with the source
+ * being the {@code newSource} provided
*/
public Object cloneWithSource(Object newSource) {
// Fix for IE bug - crashing
- return new TreeSelectionEvent(newSource, paths,areNew,
+ return new TreeSelectionEvent(newSource, paths, areNew,
oldLeadSelectionPath,
newLeadSelectionPath);
}
--- a/jdk/src/share/classes/javax/swing/event/TreeWillExpandListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/TreeWillExpandListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,11 +41,19 @@
public interface TreeWillExpandListener extends EventListener {
/**
* Invoked whenever a node in the tree is about to be expanded.
+ *
+ * @param event a {@code TreeExpansionEvent} containing a {@code TreePath}
+ * object for the node
+ * @throws ExpandVetoException to signify expansion has been canceled
*/
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException;
/**
* Invoked whenever a node in the tree is about to be collapsed.
+ *
+ * @param event a {@code TreeExpansionEvent} containing a {@code TreePath}
+ * object for the node
+ * @throws ExpandVetoException to signify collapse has been canceled
*/
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException;
}
--- a/jdk/src/share/classes/javax/swing/event/UndoableEditListener.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/event/UndoableEditListener.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,8 @@
/**
* An undoable edit happened
+ *
+ * @param e an {@code UndoableEditEvent} object
*/
void undoableEditHappened(UndoableEditEvent e);
}
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -421,6 +421,13 @@
* @param property The name of a bean style property or client property
* @param defaultColor The color to return if no color was obtained from
* the component.
+ * @param saturationOffset additively modifies the HSB saturation component
+ * of the color returned (ignored if default color is returned).
+ * @param brightnessOffset additively modifies the HSB brightness component
+ * of the color returned (ignored if default color is returned).
+ * @param alphaOffset additively modifies the ARGB alpha component of the
+ * color returned (ignored if default color is returned).
+ *
* @return The color that was obtained from the component or defaultColor
*/
protected final Color getComponentColor(JComponent c, String property,
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -513,6 +513,13 @@
/**
* Returns the Icon used in calculating the
* preferred/minimum/maximum size.
+ *
+ * @param b specifies the {@code AbstractButton}
+ * used when calculating the preferred/minimum/maximum
+ * size.
+ *
+ * @return the Icon used in calculating the
+ * preferred/minimum/maximum size.
*/
protected Icon getSizingIcon(AbstractButton b) {
Icon icon = getEnabledIcon(b, b.getIcon());
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -137,6 +137,9 @@
* @param iconR Rectangle to place icon bounds in
* @param textR Rectangle to place text in
* @param iconTextGap gap between icon and text
+ *
+ * @return by reference, the location to
+ * place the icon and text.
*/
public String layoutText(SynthContext ss, FontMetrics fm,
String text, Icon icon, int hAlign,
@@ -166,6 +169,8 @@
* @param font Font to use
* @param metrics FontMetrics, may be ignored
* @param text Text to get size of.
+ *
+ * @return the size of the passed in string.
*/
public int computeStringWidth(SynthContext ss, Font font,
FontMetrics metrics, String text) {
@@ -187,6 +192,8 @@
* @param iconTextGap gap between icon and text
* @param mnemonicIndex Index into text to render the mnemonic at, -1
* indicates no mnemonic.
+ *
+ * @return the minimum size needed to properly render an icon and text.
*/
public Dimension getMinimumSize(SynthContext ss, Font font, String text,
Icon icon, int hAlign, int vAlign, int hTextPosition,
@@ -218,6 +225,8 @@
* @param iconTextGap gap between icon and text
* @param mnemonicIndex Index into text to render the mnemonic at, -1
* indicates no mnemonic.
+ *
+ * @return the maximum size needed to properly render an icon and text.
*/
public Dimension getMaximumSize(SynthContext ss, Font font, String text,
Icon icon, int hAlign, int vAlign, int hTextPosition,
@@ -263,6 +272,8 @@
* @param iconTextGap gap between icon and text
* @param mnemonicIndex Index into text to render the mnemonic at, -1
* indicates no mnemonic.
+ *
+ * @return the preferred size needed to properly render an icon and text.
*/
public Dimension getPreferredSize(SynthContext ss, Font font, String text,
Icon icon, int hAlign, int vAlign, int hTextPosition,
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -78,6 +78,9 @@
/**
* Installs default setting. This method is called when a
* {@code LookAndFeel} is installed.
+ *
+ * @param c specifies the {@code JSeparator} for the installed
+ * {@code LookAndFeel}.
*/
public void installDefaults(JSeparator c) {
updateStyle(c);
@@ -109,6 +112,9 @@
/**
* Uninstalls default setting. This method is called when a
* {@code LookAndFeel} is uninstalled.
+ *
+ * @param c specifies the {@code JSeparator} for the (un)installed
+ * {@code LookAndFeel}.
*/
public void uninstallDefaults(JSeparator c) {
SynthContext context = getContext(c, ENABLED);
@@ -121,6 +127,9 @@
/**
* Installs listeners. This method is called when a
* {@code LookAndFeel} is installed.
+ *
+ * @param c specifies the {@code JSeparator} for the installed
+ * {@code LookAndFeel}.
*/
public void installListeners(JSeparator c) {
c.addPropertyChangeListener(this);
@@ -129,6 +138,9 @@
/**
* Uninstalls listeners. This method is called when a
* {@code LookAndFeel} is uninstalled.
+ *
+ * @param c specifies the {@code JSeparator} for the (un)installed
+ * {@code LookAndFeel}.
*/
public void uninstallListeners(JSeparator c) {
c.removePropertyChangeListener(this);
--- a/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java Fri Jun 27 14:21:31 2014 -0700
@@ -716,6 +716,8 @@
/**
* Creates a new default list selection model.
+ *
+ * @return a newly created default list selection model.
*/
protected ListSelectionModel createSelectionModel() {
return new DefaultListSelectionModel();
--- a/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java Fri Jun 27 14:21:31 2014 -0700
@@ -335,6 +335,8 @@
*
* @see #setColumnCount
* @since 1.3
+ *
+ * @param rowCount number of rows in the model
*/
public void setRowCount(int rowCount) {
setNumRows(rowCount);
@@ -577,6 +579,9 @@
* element going to row 0, etc. This method will send a
* <code>tableChanged</code> notification message to all the listeners.
*
+ * @param columnName identifier of the newly created column
+ * @param columnData new data to be added to the column
+ *
* @see #addColumn(Object, Vector)
*/
public void addColumn(Object columnName, Object[] columnData) {
--- a/jdk/src/share/classes/javax/swing/table/JTableHeader.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/table/JTableHeader.java Fri Jun 27 14:21:31 2014 -0700
@@ -336,6 +336,10 @@
* Returns the index of the column that <code>point</code> lies in, or -1 if it
* lies out of bounds.
*
+ * @param point if this <code>point</code> lies within a column, the index of
+ * that column will be returned; otherwise it is out of bounds
+ * and -1 is returned
+ *
* @return the index of the column that <code>point</code> lies in, or -1 if it
* lies out of bounds
*/
@@ -352,6 +356,8 @@
* When the <code>column</code> parameter is out of bounds this method uses the
* same conventions as the <code>JTable</code> method <code>getCellRect</code>.
*
+ * @param column index of the column
+ *
* @return the rectangle containing the header tile at <code>column</code>
* @see JTable#getCellRect
*/
@@ -883,6 +889,10 @@
/**
* Constructs an AccessiblJTableHeaaderEntry
* @since 1.4
+ *
+ * @param c the column index
+ * @param p the parent <code>JTableHeader</code>
+ * @param t the table <code>JTable</code>
*/
public AccessibleJTableHeaderEntry(int c, JTableHeader p, JTable t) {
parent = p;
--- a/jdk/src/share/classes/javax/swing/table/TableCellRenderer.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/table/TableCellRenderer.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -86,6 +86,9 @@
* drawing the header, the value of
* <code>row</code> is -1
* @param column the column index of the cell being drawn
+ *
+ * @return the component used for drawing the cell.
+ *
* @see javax.swing.JComponent#isPaintingForPrint()
*/
Component getTableCellRendererComponent(JTable table, Object value,
--- a/jdk/src/share/classes/javax/swing/table/TableColumn.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/table/TableColumn.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -201,6 +201,11 @@
* Cover method, using a default width of 75, a <code>null</code>
* renderer and a <code>null</code> editor.
* @see #TableColumn(int, int, TableCellRenderer, TableCellEditor)
+ *
+ * @param modelIndex the index of the column in the model
+ * that supplies the data for this column in the table;
+ * the model index remains the same even when columns
+ * are reordered in the view
*/
public TableColumn(int modelIndex) {
this(modelIndex, 75, null, null);
@@ -210,6 +215,12 @@
* Cover method, using a <code>null</code> renderer and a
* <code>null</code> editor.
* @see #TableColumn(int, int, TableCellRenderer, TableCellEditor)
+ *
+ * @param modelIndex the index of the column in the model
+ * that supplies the data for this column in the table;
+ * the model index remains the same even when columns
+ * are reordered in the view
+ * @param width this column's preferred width and initial width
*/
public TableColumn(int modelIndex, int width) {
this(modelIndex, width, null, null);
--- a/jdk/src/share/classes/javax/swing/table/TableColumnModel.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/table/TableColumnModel.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -162,6 +162,9 @@
* model. If the column index for a given X coordinate in 2D space is
* required, <code>JTable.columnAtPoint</code> can be used instead.
*
+ * @param xPosition width from the start of the first column in
+ * the model.
+ *
* @return the index of the column; or -1 if no column is found
* @see javax.swing.JTable#columnAtPoint
*/
--- a/jdk/src/share/classes/javax/swing/tree/ExpandVetoException.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/javax/swing/tree/ExpandVetoException.java Fri Jun 27 14:21:31 2014 -0700
@@ -28,7 +28,7 @@
import javax.swing.event.TreeExpansionEvent;
/**
- * Exception used to stop and expand/collapse from happening.
+ * Exception used to stop an expand/collapse from happening.
* See <a
href="http://docs.oracle.com/javase/tutorial/uiswing/events/treewillexpandlistener.html">How to Write a Tree-Will-Expand Listener</a>
* in <em>The Java Tutorial</em>
--- a/jdk/src/share/classes/sun/misc/Launcher.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/sun/misc/Launcher.java Fri Jun 27 14:21:31 2014 -0700
@@ -207,7 +207,7 @@
* look in the extension directory itself.
*/
public String findLibrary(String name) {
- name = System.mapLibraryName(name);
+ final String libname = System.mapLibraryName(name);
URL[] urls = super.getURLs();
File prevDir = null;
for (int i = 0; i < urls.length; i++) {
@@ -216,17 +216,26 @@
if (dir != null && !dir.equals(prevDir)) {
// Look in architecture-specific subdirectory first
// Read from the saved system properties to avoid deadlock
- String arch = VM.getSavedProperty("os.arch");
- if (arch != null) {
- File file = new File(new File(dir, arch), name);
- if (file.exists()) {
- return file.getAbsolutePath();
- }
- }
- // Then check the extension directory
- File file = new File(dir, name);
- if (file.exists()) {
- return file.getAbsolutePath();
+ final String arch = VM.getSavedProperty("os.arch");
+ String pathname = AccessController.doPrivileged(
+ new PrivilegedAction<String>() {
+ public String run() {
+ if (arch != null) {
+ File file = new File(new File(dir, arch), libname);
+ if (file.exists()) {
+ return file.getAbsolutePath();
+ }
+ }
+ // Then check the extension directory
+ File file = new File(dir, libname);
+ if (file.exists()) {
+ return file.getAbsolutePath();
+ }
+ return null;
+ }
+ });
+ if (pathname != null) {
+ return pathname;
}
}
prevDir = dir;
--- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Fri Jun 27 14:21:31 2014 -0700
@@ -195,15 +195,8 @@
synchronized (stateLock) {
ensureOpen();
- if (name == StandardSocketOptions.IP_TOS) {
- // IPv4 only; no-op for IPv6
- if (family == StandardProtocolFamily.INET) {
- Net.setSocketOption(fd, family, name, value);
- }
- return this;
- }
-
- if (name == StandardSocketOptions.IP_MULTICAST_TTL ||
+ if (name == StandardSocketOptions.IP_TOS ||
+ name == StandardSocketOptions.IP_MULTICAST_TTL ||
name == StandardSocketOptions.IP_MULTICAST_LOOP)
{
// options are protocol dependent
@@ -256,16 +249,8 @@
synchronized (stateLock) {
ensureOpen();
- if (name == StandardSocketOptions.IP_TOS) {
- // IPv4 only; always return 0 on IPv6
- if (family == StandardProtocolFamily.INET) {
- return (T) Net.getSocketOption(fd, family, name);
- } else {
- return (T) Integer.valueOf(0);
- }
- }
-
- if (name == StandardSocketOptions.IP_MULTICAST_TTL ||
+ if (name == StandardSocketOptions.IP_TOS ||
+ name == StandardSocketOptions.IP_MULTICAST_TTL ||
name == StandardSocketOptions.IP_MULTICAST_LOOP)
{
return (T) Net.getSocketOption(fd, family, name);
--- a/jdk/src/share/classes/sun/nio/ch/Net.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/Net.java Fri Jun 27 14:21:31 2014 -0700
@@ -352,7 +352,8 @@
}
boolean mayNeedConversion = (family == UNSPEC);
- setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg);
+ boolean isIPv6 = (family == StandardProtocolFamily.INET6);
+ setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg, isIPv6);
}
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
@@ -499,7 +500,7 @@
throws IOException;
private static native void setIntOption0(FileDescriptor fd, boolean mayNeedConversion,
- int level, int opt, int arg)
+ int level, int opt, int arg, boolean isIPv6)
throws IOException;
static native int poll(FileDescriptor fd, int events, long timeout)
--- a/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Fri Jun 27 14:21:31 2014 -0700
@@ -133,6 +133,14 @@
synchronized (stateLock) {
if (!isOpen())
throw new ClosedChannelException();
+
+ if (name == StandardSocketOptions.IP_TOS) {
+ ProtocolFamily family = Net.isIPv6Available() ?
+ StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
+ Net.setSocketOption(fd, family, name, value);
+ return this;
+ }
+
if (name == StandardSocketOptions.SO_REUSEADDR &&
Net.useExclusiveBind())
{
@@ -177,6 +185,7 @@
HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(2);
set.add(StandardSocketOptions.SO_RCVBUF);
set.add(StandardSocketOptions.SO_REUSEADDR);
+ set.add(StandardSocketOptions.IP_TOS);
return Collections.unmodifiableSet(set);
}
}
--- a/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java Fri Jun 27 14:21:31 2014 -0700
@@ -173,14 +173,14 @@
if (!isOpen())
throw new ClosedChannelException();
- // special handling for IP_TOS: no-op when IPv6
if (name == StandardSocketOptions.IP_TOS) {
- if (!Net.isIPv6Available())
- Net.setSocketOption(fd, StandardProtocolFamily.INET, name, value);
+ ProtocolFamily family = Net.isIPv6Available() ?
+ StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
+ Net.setSocketOption(fd, family, name, value);
return this;
- } else if (name == StandardSocketOptions.SO_REUSEADDR &&
- Net.useExclusiveBind())
- {
+ }
+
+ if (name == StandardSocketOptions.SO_REUSEADDR && Net.useExclusiveBind()) {
// SO_REUSEADDR emulated when using exclusive bind
isReuseAddress = (Boolean)value;
return this;
@@ -215,8 +215,9 @@
// special handling for IP_TOS: always return 0 when IPv6
if (name == StandardSocketOptions.IP_TOS) {
- return (Net.isIPv6Available()) ? (T) Integer.valueOf(0) :
- (T) Net.getSocketOption(fd, StandardProtocolFamily.INET, name);
+ ProtocolFamily family = Net.isIPv6Available() ?
+ StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
+ return (T) Net.getSocketOption(fd, family, name);
}
// no options that require special handling
--- a/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java Fri Jun 27 14:21:31 2014 -0700
@@ -334,15 +334,29 @@
* returns null.
*/
Credentials readCred(int version) throws IOException,RealmException, KrbApErrException, Asn1Exception {
- PrincipalName cpname = readPrincipal(version);
- if (DEBUG)
+ PrincipalName cpname = null;
+ try {
+ cpname = readPrincipal(version);
+ } catch (Exception e) {
+ // Do not return here. All data for this cred should be fully
+ // consumed so that we can read the next one.
+ }
+ if (DEBUG) {
System.out.println(">>>DEBUG <CCacheInputStream> client principal is " + cpname);
- PrincipalName spname = readPrincipal(version);
- if (DEBUG)
+ }
+ PrincipalName spname = null;
+ try {
+ spname = readPrincipal(version);
+ } catch (Exception e) {
+ // same as above
+ }
+ if (DEBUG) {
System.out.println(">>>DEBUG <CCacheInputStream> server principal is " + spname);
+ }
EncryptionKey key = readKey(version);
- if (DEBUG)
+ if (DEBUG) {
System.out.println(">>>DEBUG <CCacheInputStream> key type: " + key.getEType());
+ }
long times[] = readTimes();
KerberosTime authtime = new KerberosTime(times[0]);
KerberosTime starttime =
@@ -375,6 +389,11 @@
byte[] ticketData = readData();
byte[] ticketData2 = readData();
+ // Skip this cred if either cpname or spname isn't created.
+ if (cpname == null || spname == null) {
+ return null;
+ }
+
try {
return new Credentials(cpname, spname, key, authtime, starttime,
endtime, renewTill, skey, tFlags,
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp Fri Jun 27 14:21:31 2014 -0700
@@ -435,7 +435,7 @@
struct tm* s = gmtime_r(&t, &sbuf);
if (s == NULL) {
fprintf(u->errstrm, "Error: gmtime failure, invalid input archive\n");
- exit(2);
+ exit(-1);
}
modtime_cache = modtime;
dostime_cache = dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday,
--- a/jdk/src/solaris/native/java/net/net_util_md.c Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/solaris/native/java/net/net_util_md.c Fri Jun 27 14:21:31 2014 -0700
@@ -1317,7 +1317,7 @@
* or sending UDP packet.
* 2. IPv6 on Linux: By default Linux ignores flowinfo
* field so enable IPV6_FLOWINFO_SEND so that flowinfo
- * will be examined.
+ * will be examined. We also set the IPv4 TOS option in this case.
* 3. IPv4: set socket option based on ToS and Precedence
* fields (otherwise get invalid argument)
*/
@@ -1333,8 +1333,10 @@
#if defined(AF_INET6) && defined(__linux__)
if (ipv6_available()) {
int optval = 1;
- return setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND,
- (void *)&optval, sizeof(optval));
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND,
+ (void *)&optval, sizeof(optval)) < 0) {
+ return -1;
+ }
}
#endif
--- a/jdk/src/solaris/native/sun/nio/ch/Net.c Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/solaris/native/sun/nio/ch/Net.c Fri Jun 27 14:21:31 2014 -0700
@@ -435,7 +435,8 @@
JNIEXPORT void JNICALL
Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo,
- jboolean mayNeedConversion, jint level, jint opt, jint arg)
+ jboolean mayNeedConversion, jint level,
+ jint opt, jint arg, jboolean isIPv6)
{
int result;
struct linger linger;
@@ -478,6 +479,12 @@
JNU_JAVANETPKG "SocketException",
"sun.nio.ch.Net.setIntOption");
}
+#ifdef __linux__
+ if (level == IPPROTO_IPV6 && opt == IPV6_TCLASS && isIPv6) {
+ // set the V4 option also
+ setsockopt(fdval(env, fdo), IPPROTO_IP, IP_TOS, parg, arglen);
+ }
+#endif
}
JNIEXPORT jint JNICALL
--- a/jdk/src/solaris/native/sun/security/smartcardio/MUSCLE/pcsclite.h Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/solaris/native/sun/security/smartcardio/MUSCLE/pcsclite.h Fri Jun 27 14:21:31 2014 -0700
@@ -75,6 +75,13 @@
}
SCARD_READERSTATE_A;
+typedef struct _SCARD_IO_REQUEST
+{
+ unsigned long dwProtocol; /* Protocol identifier */
+ unsigned long cbPciLength; /* Protocol Control Inf Length */
+}
+SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
+
#else // __APPLE__
#pragma pack(1)
@@ -88,6 +95,13 @@
unsigned char rgbAtr[MAX_ATR_SIZE];
}
SCARD_READERSTATE_A;
+
+typedef struct _SCARD_IO_REQUEST
+{
+ uint32_t dwProtocol; /* Protocol identifier */
+ uint32_t cbPciLength; /* Protocol Control Inf Length */
+}
+SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
#pragma pack()
#endif // __APPLE__
@@ -95,13 +109,6 @@
typedef SCARD_READERSTATE_A SCARD_READERSTATE, *PSCARD_READERSTATE_A,
*LPSCARD_READERSTATE_A;
-typedef struct _SCARD_IO_REQUEST
-{
- unsigned long dwProtocol; /* Protocol identifier */
- unsigned long cbPciLength; /* Protocol Control Inf Length */
-}
-SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
-
typedef const SCARD_IO_REQUEST *LPCSCARD_IO_REQUEST;
extern SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci,
--- a/jdk/src/windows/native/sun/nio/ch/Net.c Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/src/windows/native/sun/nio/ch/Net.c Fri Jun 27 14:21:31 2014 -0700
@@ -319,7 +319,7 @@
JNIEXPORT void JNICALL
Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo,
- jboolean mayNeedConversion, jint level, jint opt, jint arg)
+ jboolean mayNeedConversion, jint level, jint opt, jint arg, jboolean ipv6)
{
struct linger linger;
char *parg;
--- a/jdk/test/ProblemList.txt Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/ProblemList.txt Fri Jun 27 14:21:31 2014 -0700
@@ -298,7 +298,4 @@
# 8046355
sun/tools/jstatd/TestJstatdExternalRegistry.java generic-all
-# 8046352
-com/sun/tools/attach/TempDirTest.java generic-all
-
############################################################################
--- a/jdk/test/com/sun/tools/attach/RunnerUtil.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/com/sun/tools/attach/RunnerUtil.java Fri Jun 27 14:21:31 2014 -0700
@@ -139,12 +139,19 @@
String content = null;
// Read file or wait for it to be created.
+ long startTime = System.currentTimeMillis();
+ long lastWarningTime = 0;
while (true) {
content = readFile(file);
if (content != null && content.indexOf("done") >= 0) {
break;
}
Thread.sleep(100);
+ long elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
+ if (elapsedTime > lastWarningTime) {
+ lastWarningTime = elapsedTime;
+ System.out.println("Waited " + elapsedTime + " seconds for file.");
+ }
}
ProcessInfo info = new ProcessInfo();
--- a/jdk/test/com/sun/tools/attach/TempDirTest.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/com/sun/tools/attach/TempDirTest.java Fri Jun 27 14:21:31 2014 -0700
@@ -39,13 +39,22 @@
* @summary Test to make sure attach and jvmstat works correctly when java.io.tmpdir is set
* @library /lib/testlibrary
* @run build jdk.testlibrary.* Application Shutdown RunnerUtil
- * @run main TempDirTest
+ * @run main/timeout=200 TempDirTest
+ */
+
+/*
+ * This test runs with an extra long timeout since it takes a really long time with -Xcomp
+ * when starting many processes.
*/
public class TempDirTest {
+ private static long startTime;
+
public static void main(String args[]) throws Throwable {
+ startTime = System.currentTimeMillis();
+
Path clientTmpDir = Files.createTempDirectory("TempDirTest-client");
clientTmpDir.toFile().deleteOnExit();
Path targetTmpDir = Files.createTempDirectory("TempDirTest-target");
@@ -76,6 +85,9 @@
System.out.print(" target: " + (targetTmpDir == null ? "no" : "yes"));
System.out.println(" ###");
+ long elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
+ System.out.println("Started after " + elapsedTime + "s");
+
final String pidFile = "TempDirTest.Application.pid-" + counter++;
ProcessThread processThread = null;
RunnerUtil.ProcessInfo info = null;
@@ -95,6 +107,10 @@
// Make sure the Application process is stopped.
RunnerUtil.stopApplication(info.shutdownPort, processThread);
}
+
+ elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
+ System.out.println("Completed after " + elapsedTime + "s");
+
}
/**
--- a/jdk/test/java/net/URLPermission/nstest/lookup.sh Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh Fri Jun 27 14:21:31 2014 -0700
@@ -24,9 +24,9 @@
# @test
# @library /lib/testlibrary
+# @build jdk.testlibrary.*
# @compile -XDignore.symbol.file=true SimpleNameService.java
# LookupTest.java SimpleNameServiceDescriptor.java
-# @build jdk.testlibrary.*
# @run shell/timeout=50 lookup.sh
#
@@ -42,8 +42,7 @@
;;
esac
-
-port=`${TESTJAVA}/bin/java -cp ${TESTCLASSES} LookupTest -getport`
+port=`${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} LookupTest -getport`
cat << POLICY > policy
grant {
@@ -60,4 +59,4 @@
${TESTJAVA}/bin/java ${TESTVMOPTS} \
-Djava.security.policy=file:./policy \
-Dsun.net.spi.nameservice.provider.1=simple,sun \
- -cp ${TESTCLASSES}${PS}${TESTSRC} LookupTest -runtest ${port}
+ -cp ${TESTCLASSPATH}${PS}${TESTSRC} LookupTest -runtest ${port}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Collections/CheckedListReplaceAll.java Fri Jun 27 14:21:31 2014 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8047795
+ * @summary Ensure that replaceAll operator cannot add bad elements
+ * @author Mike Duigou
+ */
+
+import java.util.*;
+import java.util.function.UnaryOperator;
+
+public class CheckedListReplaceAll {
+ public static void main(String[] args) {
+ List unwrapped = Arrays.asList(new Object[]{1, 2, 3});
+ List<Object> wrapped = Collections.checkedList(unwrapped, Integer.class);
+
+ UnaryOperator evil = e -> (((int) e) % 2 != 0) ? e : "evil";
+
+ try {
+ wrapped.replaceAll(evil);
+ System.out.printf("Bwahaha! I have defeated you! %s\n", wrapped);
+ throw new RuntimeException("String added to checked List<Integer>");
+ } catch (ClassCastException thwarted) {
+ thwarted.printStackTrace(System.out);
+ System.out.println("Curses! Foiled again!");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Collections/CheckedMapReplaceAll.java Fri Jun 27 14:21:31 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8047795
+ * @summary Ensure that replaceAll operator cannot add bad elements
+ * @author Mike Duigou
+ */
+
+import java.util.*;
+import java.util.function.BiFunction;
+
+public class CheckedMapReplaceAll {
+ public static void main(String[] args) {
+ Map<Integer,Double> unwrapped = new HashMap<>();
+ unwrapped.put(1, 1.0);
+ unwrapped.put(2, 2.0);
+ unwrapped.put(3, 3.0);
+
+ Map<Integer,Double> wrapped = Collections.checkedMap(unwrapped, Integer.class, Double.class);
+
+ BiFunction evil = (k, v) -> (((int)k) % 2 != 0) ? v : "evil";
+
+ try {
+ wrapped.replaceAll(evil);
+ System.out.printf("Bwahaha! I have defeated you! %s\n", wrapped);
+ throw new RuntimeException("String added to checked Map<Integer,Double>");
+ } catch (ClassCastException thwarted) {
+ thwarted.printStackTrace(System.out);
+ System.out.println("Curses! Foiled again!");
+ }
+ }
+}
--- a/jdk/test/java/util/Currency/CheckDataVersion.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/java/util/Currency/CheckDataVersion.java Fri Jun 27 14:21:31 2014 -0700
@@ -64,7 +64,8 @@
public Object run() {
try {
String sep = File.separator;
- DataInputStream dis = new DataInputStream(new FileInputStream(System.getProperty("java.home")+sep+"lib"+sep+"currency.data"));
+ DataInputStream dis = new DataInputStream(
+ new BufferedInputStream(getClass().getResourceAsStream("/java/util/currency.data")));
int magic = dis.readInt();
if (magic != 0x43757244) {
throw new RuntimeException("The magic number in the JRE's currency data is incorrect. Expected: 0x43757244, Got: 0x"+magic);
--- a/jdk/test/java/util/Currency/CurrencyTest.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/java/util/Currency/CurrencyTest.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
* @bug 4290801 4692419 4693631 5101540 5104960 6296410 6336600 6371531
- * 6488442 7036905
+ * 6488442 7036905 8039317
* @summary Basic tests for Currency class.
*/
--- a/jdk/test/java/util/Currency/ValidateISO4217.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/java/util/Currency/ValidateISO4217.java Fri Jun 27 14:21:31 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/*
* @test
* @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759
+ * 8039317
* @summary Validate ISO 4217 data for Currency class.
*/
--- a/jdk/test/javax/management/MBeanServer/MBeanFallbackTest.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/javax/management/MBeanServer/MBeanFallbackTest.java Fri Jun 27 14:21:31 2014 -0700
@@ -35,7 +35,7 @@
* @author Jaroslav Bachorik
* @run clean MBeanFallbackTest
* @run build MBeanFallbackTest
- * @run main MBeanFallbackTest
+ * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true MBeanFallbackTest
*/
public class MBeanFallbackTest {
private static interface PrivateMBean {
@@ -51,7 +51,6 @@
private static int failures = 0;
public static void main(String[] args) throws Exception {
- System.setProperty("jdk.jmx.mbeans.allowNonPublic", "true");
testPrivate(PrivateMBean.class, new Private());
if (failures == 0)
--- a/jdk/test/javax/management/ObjectName/SerialCompatTest.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/javax/management/ObjectName/SerialCompatTest.java Fri Jun 27 14:21:31 2014 -0700
@@ -28,7 +28,7 @@
* @author Eamonn McManus, Daniel Fuchs
* @run clean SerialCompatTest
* @run build SerialCompatTest
- * @run main/othervm SerialCompatTest
+ * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true -Djmx.serial.form=1.0 SerialCompatTest
*/
import java.io.*;
@@ -223,8 +223,6 @@
}
public static void main(String[] args) throws Exception {
- System.setProperty("jmx.serial.form", "1.0");
-
/* Check that we really are in jmx.serial.form=1.0 mode.
The property is frozen the first time the ObjectName class
is referenced so checking that it is set to the correct
--- a/jdk/test/javax/management/mxbean/MXBeanFallbackTest.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/javax/management/mxbean/MXBeanFallbackTest.java Fri Jun 27 14:21:31 2014 -0700
@@ -30,7 +30,7 @@
* @author Jaroslav Bachorik
* @run clean MXBeanFallbackTest
* @run build MXBeanFallbackTest
- * @run main MXBeanFallbackTest
+ * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true MXBeanFallbackTest
*/
import javax.management.MBeanServer;
@@ -40,7 +40,6 @@
public class MXBeanFallbackTest {
public static void main(String[] args) throws Exception {
- System.setProperty("jdk.jmx.mbeans.allowNonPublic", "true");
testPrivateMXBean("Private", new Private());
if (failures == 0)
--- a/jdk/test/javax/management/proxy/JMXProxyFallbackTest.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/javax/management/proxy/JMXProxyFallbackTest.java Fri Jun 27 14:21:31 2014 -0700
@@ -36,7 +36,7 @@
* @author Jaroslav Bachorik
* @run clean JMXProxyFallbackTest
* @run build JMXProxyFallbackTest
- * @run main JMXProxyFallbackTest
+ * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true JMXProxyFallbackTest
*/
public class JMXProxyFallbackTest {
private static interface PrivateMBean {
@@ -56,7 +56,6 @@
private static int failures = 0;
public static void main(String[] args) throws Exception {
- System.setProperty("jdk.jmx.mbeans.allowNonPublic", "true");
testPrivate(PrivateMBean.class);
testPrivate(PrivateMXBean.class);
--- a/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java Fri Jun 27 14:21:31 2014 -0700
@@ -38,7 +38,7 @@
public class RMIConnector_NPETest {
public static void main(String argv[]) throws Exception {
RMID rmid = RMID.createRMID();
- rmid.start();
+ rmid.start(Long.MAX_VALUE);
int rmidPort = rmid.getPort();
Exception failureCause = null;
RMIConnector agent = null;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/jaxp/datatype/5077522/DurationComparison.java Fri Jun 27 14:21:31 2014 -0700
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2013, 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 5077522
+ * @summary test INDETERMINATE relations
+ * @run main DurationComparison
+ */
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+
+/**
+ *
+ * This is a JCK failure. The implementation fails with a list of
+ * INDETERMINATE comparisons
+ *
+ *
+ * @author Joe Wang <huizhe.wang@oracle.com>
+ */
+public class DurationComparison {
+ static String errMsg;
+ int passed = 0, failed = 0;
+
+ public static void main(String[] args) {
+ DurationComparison test = new DurationComparison();
+ test.testCompareWithInderterminateRelation();
+ test.testVerifyOtherRelations();
+ test.tearDown();
+ }
+
+ /**
+ * See JDK-5077522, Duration.compare returns equal for INDETERMINATE
+ * comparisons
+ */
+ public void testCompareWithInderterminateRelation() {
+
+ final String [][] partialOrder = { // partialOrder
+ {"P1Y", "<>", "P365D"},
+ {"P1Y", "<>", "P366D"},
+ {"P1M", "<>", "P28D"},
+ {"P1M", "<>", "P29D"},
+ {"P1M", "<>", "P30D"},
+ {"P1M", "<>", "P31D"},
+ {"P5M", "<>", "P150D"},
+ {"P5M", "<>", "P151D"},
+ {"P5M", "<>", "P152D"},
+ {"P5M", "<>", "P153D"},
+ {"PT2419200S", "<>", "P1M"},
+ {"PT2678400S", "<>", "P1M"},
+ {"PT31536000S", "<>", "P1Y"},
+ {"PT31622400S", "<>", "P1Y"},
+ {"PT525600M", "<>", "P1Y"},
+ {"PT527040M", "<>", "P1Y"},
+ {"PT8760H", "<>", "P1Y"},
+ {"PT8784H", "<>", "P1Y"},
+ {"P365D", "<>", "P1Y"},
+ };
+
+ DatatypeFactory df = null;
+ try {
+ df = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException ex) {
+ ex.printStackTrace();
+ fail(ex.toString());
+ }
+
+ for (int valueIndex = 0; valueIndex < partialOrder.length; ++valueIndex) {
+ Duration duration1 = df.newDuration(partialOrder[valueIndex][0]);
+ Duration duration2 = df.newDuration(partialOrder[valueIndex][2]);
+ int cmp = duration1.compare(duration2);
+ int expected = ">".equals(partialOrder[valueIndex][1])
+ ? DatatypeConstants.GREATER
+ : "<".equals(partialOrder[valueIndex][1])
+ ? DatatypeConstants.LESSER
+ : "==".equals(partialOrder[valueIndex][1])
+ ? DatatypeConstants.EQUAL
+ : DatatypeConstants.INDETERMINATE;
+
+ if (expected != cmp) {
+ fail("returned " + cmp2str(cmp)
+ + " for durations \'" + duration1 + "\' and "
+ + duration2 + "\', but expected " + cmp2str(expected));
+ } else {
+ success("Comparing " + duration1 + " and " + duration2 +
+ ": INDETERMINATE");
+ }
+ }
+ }
+
+ /**
+ * Verify cases around the INDETERMINATE relations
+ */
+ public void testVerifyOtherRelations() {
+
+ final String [][] partialOrder = { // partialOrder
+ {"P1Y", ">", "P364D"},
+ {"P1Y", "<", "P367D"},
+ {"P1Y2D", ">", "P366D"},
+ {"P1M", ">", "P27D"},
+ {"P1M", "<", "P32D"},
+ {"P1M", "<", "P31DT1H"},
+ {"P5M", ">", "P149D"},
+ {"P5M", "<", "P154D"},
+ {"P5M", "<", "P153DT1H"},
+ {"PT2419199S", "<", "P1M"}, //PT2419200S -> P28D
+ {"PT2678401S", ">", "P1M"}, //PT2678400S -> P31D
+ {"PT31535999S", "<", "P1Y"}, //PT31536000S -> P365D
+ {"PT31622401S", ">", "P1Y"}, //PT31622400S -> P366D
+ {"PT525599M59S", "<", "P1Y"}, //PT525600M -> P365D
+ {"PT527040M1S", ">", "P1Y"}, //PT527040M -> P366D
+ {"PT8759H59M59S", "<", "P1Y"}, //PT8760H -> P365D
+ {"PT8784H1S", ">", "P1Y"}, //PT8784H -> P366D
+ };
+
+ DatatypeFactory df = null;
+ try {
+ df = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException ex) {
+ ex.printStackTrace();
+ fail(ex.toString());
+ }
+
+ for (int valueIndex = 0; valueIndex < partialOrder.length; ++valueIndex) {
+ Duration duration1 = df.newDuration(partialOrder[valueIndex][0]);
+ Duration duration2 = df.newDuration(partialOrder[valueIndex][2]);
+ int cmp = duration1.compare(duration2);
+ int expected = ">".equals(partialOrder[valueIndex][1])
+ ? DatatypeConstants.GREATER
+ : "<".equals(partialOrder[valueIndex][1])
+ ? DatatypeConstants.LESSER
+ : "==".equals(partialOrder[valueIndex][1])
+ ? DatatypeConstants.EQUAL
+ : DatatypeConstants.INDETERMINATE;
+
+ if (expected != cmp) {
+ fail("returned " + cmp2str(cmp)
+ + " for durations \'" + duration1 + "\' and "
+ + duration2 + "\', but expected " + cmp2str(expected));
+ } else {
+ success("Comparing " + duration1 + " and " + duration2 +
+ ": expected: " + cmp2str(expected) +
+ " actual: " + cmp2str(cmp));
+ }
+ }
+ }
+ public static String cmp2str(int cmp) {
+ return cmp == DatatypeConstants.LESSER ? "LESSER"
+ : cmp == DatatypeConstants.GREATER ? "GREATER"
+ : cmp == DatatypeConstants.EQUAL ? "EQUAL"
+ : cmp == DatatypeConstants.INDETERMINATE ? "INDETERMINATE"
+ : "UNDEFINED";
+ }
+
+ public void tearDown() {
+
+ System.out.println("\nNumber of tests passed: " + passed);
+ System.out.println("Number of tests failed: " + failed + "\n");
+
+ if (errMsg != null ) {
+ throw new RuntimeException(errMsg);
+ }
+ }
+ void fail(String msg) {
+ if (errMsg == null) {
+ errMsg = msg;
+ } else {
+ errMsg = errMsg + "\n" + msg;
+ }
+ failed++;
+ }
+
+ void success(String msg) {
+ passed++;
+ System.out.println(msg);
+ }
+
+}
--- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java Fri Jun 27 14:21:31 2014 -0700
@@ -38,7 +38,9 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
+import java.util.function.IntUnaryOperator;
import javax.management.*;
import javax.management.remote.*;
@@ -290,11 +292,14 @@
public static void main(String args[]) throws Exception {
for (Method m : JMXStartStopTest.class.getDeclaredMethods()) {
if (m.getName().startsWith("test_")) {
+ long t1 = System.currentTimeMillis();
try {
m.invoke(null);
- System.out.println("=== PASSED\n");
+ System.out.println("=== PASSED");
} catch (Throwable e) {
failures.add(new Failure(e, m.getName() + " failed"));
+ } finally {
+ System.out.println("(took " + (System.currentTimeMillis() - t1) + "ms)\n");
}
}
}
@@ -585,11 +590,11 @@
testConnect(pa.getPort1(), pa.getPort2());
- final boolean[] checks = new boolean[3];
+ final AtomicInteger checks = new AtomicInteger();
jcmd(
line -> {
if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
- checks[0] = true;
+ checks.getAndUpdate((op) -> op | 1);
}
},
CMD_START,
@@ -600,7 +605,7 @@
jcmd(
line -> {
if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
- checks[1] = true;
+ checks.getAndUpdate((op) -> op | 2);
}
},
CMD_START,
@@ -611,12 +616,14 @@
jcmd(CMD_STOP);
jcmd(CMD_STOP);
+ int busyPort;
try (ServerSocket ss = new ServerSocket(0))
{
+ busyPort = ss.getLocalPort();
jcmd(
line -> {
- if (line.contains("Port already in use: " + ss.getLocalPort())) {
- checks[2] = true;
+ if (line.contains("Port already in use: " + busyPort)) {
+ checks.getAndUpdate((op) -> op | 4);
}
},
CMD_START,
@@ -624,19 +631,18 @@
"jmxremote.rmi.port=" + pa.getPort2(),
"jmxremote.authenticate=false",
"jmxremote.ssl=false");
-
- if (!checks[0]) {
- throw new Exception("Starting agent on port " + pa.getPort1() + " should " +
- "report an invalid agent state");
- }
- if (!checks[1]) {
- throw new Exception("Starting agent on poprt " + pa.getPort2() + " should " +
- "report an invalid agent state");
- }
- if (!checks[2]) {
- throw new Exception("Starting agent on port " + ss.getLocalPort() + " should " +
- "report port in use");
- }
+ }
+ if ((checks.get() & 1) == 0) {
+ throw new Exception("Starting agent on port " + pa.getPort1() + " should " +
+ "report an invalid agent state");
+ }
+ if ((checks.get() & 2) == 0) {
+ throw new Exception("Starting agent on poprt " + pa.getPort2() + " should " +
+ "report an invalid agent state");
+ }
+ if ((checks.get() & 4) == 0) {
+ throw new Exception("Starting agent on port " + busyPort + " should " +
+ "report port in use");
}
} finally {
s.stop();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/ccache/EmptyRealmCC.java Fri Jun 27 14:21:31 2014 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8048073
+ * @summary Cannot read ccache entry with a realm-less service name
+ * @compile -XDignore.symbol.file EmptyRealmCC.java
+ * @run main EmptyRealmCC
+ */
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import sun.security.krb5.internal.ccache.CredentialsCache;
+
+public class EmptyRealmCC {
+ public static void main(String[] args) throws Exception {
+ byte[] ccache = TimeInCCache.ccache;
+
+ // The service name starts at 0x52:
+ //
+ // 0050: 00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
+ // ----------- -----------
+ // 0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
+ // ----------- -----
+ // 0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
+ // -----
+ //
+ // which contains 2 (the length of names), a 10-byte realm, a 6-byte
+ // name[0], and a 10-byte name[1].
+
+ // We will empty the realm, and pack the realm string to another
+ // name (6-byte ".LOCAL"). Finally "krbtgt/MAXI.LOCAL@MAXI.LOCAL"
+ // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".
+
+ // length of names is now 3
+ ccache[0x55] = 3;
+ // The empty realm
+ System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
+ // Length of inserted name is 6
+ System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);
+
+ Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
+ if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
+ throw new Exception("Nothing should be there");
+ }
+ }
+}
--- a/jdk/test/sun/security/krb5/ccache/TimeInCCache.java Thu Jun 26 03:26:20 2014 -0700
+++ b/jdk/test/sun/security/krb5/ccache/TimeInCCache.java Fri Jun 27 14:21:31 2014 -0700
@@ -28,16 +28,14 @@
*/
import java.io.ByteArrayInputStream;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import sun.security.krb5.internal.ccache.CCacheInputStream;
import sun.security.krb5.internal.ccache.Credentials;
public class TimeInCCache {
- // Attention: this field is also used by CorruptedCC.java test
+ // Attention: this field is also used by 2 other tests:
+ // CorruptedCC.java and EmptyRealmCC.java
public static byte[] ccache;
static {