提交 2eb59b22 编写于 作者: L lana

Merge

......@@ -198,3 +198,4 @@ a996b57e554198f4592a5f3c30f2f9f4075e545d jdk8-b70
57d5d954462831ac353a1f40d3bb05ddb4620952 jdk8-b74
4a67fdb752b7d6329d9be9c28d3f9d6cf7eb9a3c jdk8-b75
3a263052866137b645ab86498a43693ff5c19e69 jdk8-b76
b2fc8e31cecc35b76188e821d4c5dc0e0b74ac24 jdk8-b77
......@@ -128,9 +128,9 @@ CORE_PKGS = \
java.text \
java.text.spi \
java.time \
java.time.temporal \
java.time.calendar \
java.time.chrono \
java.time.format \
java.time.temporal \
java.time.zone \
java.util \
java.util.concurrent \
......
......@@ -255,7 +255,6 @@ JAVA_JAVA_java = \
java/util/SimpleTimeZone.java \
sun/util/calendar/ZoneInfo.java \
sun/util/calendar/ZoneInfoFile.java \
sun/util/calendar/TzIDOldMapping.java \
java/util/TooManyListenersException.java \
java/util/Comparator.java \
java/util/Collections.java \
......@@ -389,6 +388,7 @@ JAVA_JAVA_java = \
java/util/concurrent/locks/ReadWriteLock.java \
java/util/concurrent/locks/ReentrantLock.java \
java/util/concurrent/locks/ReentrantReadWriteLock.java \
java/util/concurrent/locks/StampedLock.java \
java/util/regex/Pattern.java \
java/util/regex/Matcher.java \
java/util/regex/MatchResult.java \
......
......@@ -63,6 +63,7 @@ jprt.vm.default.test.targets= \
${jprt.my.test.target.set:TESTNAME=jvm98}
# Default jdk test targets (testset=default)
# NOTE: This does not match test/Makefile :: jdk_default
jprt.make.rule.default.test.targets= \
${jprt.my.test.target.set:TESTNAME=jdk_lang}, \
${jprt.my.test.target.set:TESTNAME=jdk_math}
......@@ -72,6 +73,7 @@ jprt.vm.core.test.targets= \
${jprt.vm.default.test.targets}
# Core jdk test targets (testset=core)
# NOTE: please keep this in sync with test/Makefile :: jdk_core
jprt.make.rule.core.test.targets= \
${jprt.make.rule.default.test.targets}, \
${jprt.my.test.target.set:TESTNAME=jdk_util}, \
......@@ -97,6 +99,7 @@ jprt.vm.all.test.targets= \
${jprt.my.test.target.set:TESTNAME=jbb_default}
# All jdk test targets (testset=all)
# NOTE: This does not match test/Makefile :: jdk_all
jprt.make.rule.all.test.targets= \
${jprt.make.rule.core.test.targets}, \
${jprt.my.test.target.set:TESTNAME=jdk_awt}, \
......
......@@ -70,7 +70,7 @@ else
endif
# nio need to be compiled before awt to have all charsets ready
SUBDIRS = jar security javazic misc net nio text util launcher cldr tzdb
SUBDIRS = jar security misc net nio text util launcher cldr tzdb
ifdef BUILD_HEADLESS_ONLY
DISPLAY_LIBS = awt $(HEADLESS_SUBDIR)
......
......@@ -33,11 +33,11 @@ include $(BUILDDIR)/common/Defs.gmk
# Time zone data file creation
TZDATA = ./tzdata/
TZDATA_VER = `$(GREP) '^tzdata' $(TZDATA)VERSION`
TZDATA_VER := $(shell $(GREP) '^tzdata' $(TZDATA)VERSION)
TZFILE = \
africa antarctica asia australasia europe northamerica \
pacificnew southamerica backward \
etcetera solar87 solar88 solar89 systemv
etcetera systemv
JDKTZDATA = ./tzdata_jdk/
JDKTZFILES = gmt jdk11_backward
TZFILES = \
......
#
# Copyright (c) 2000, 2005, 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.
#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone GMT 0:00 - GMT
#
# Copyright (c) 2000, 2006, 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.
#
# JDK 1.1.x compatible time zone IDs
#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule SystemV min 1973 - Apr lastSun 2:00 1:00 D
Rule SystemV min 1973 - Oct lastSun 2:00 0 S
Rule SystemV 1974 only - Jan 6 2:00 1:00 D
Rule SystemV 1974 only - Nov lastSun 2:00 0 S
Rule SystemV 1975 only - Feb 23 2:00 1:00 D
Rule SystemV 1975 only - Oct lastSun 2:00 0 S
Rule SystemV 1976 max - Apr lastSun 2:00 1:00 D
Rule SystemV 1976 max - Oct lastSun 2:00 0 S
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
Zone SystemV/AST4ADT -4:00 SystemV A%sT
Zone SystemV/EST5EDT -5:00 SystemV E%sT
Zone SystemV/CST6CDT -6:00 SystemV C%sT
Zone SystemV/MST7MDT -7:00 SystemV M%sT
Zone SystemV/PST8PDT -8:00 SystemV P%sT
Zone SystemV/YST9YDT -9:00 SystemV Y%sT
Zone SystemV/AST4 -4:00 - AST
Zone SystemV/EST5 -5:00 - EST
Zone SystemV/CST6 -6:00 - CST
Zone SystemV/MST7 -7:00 - MST
Zone SystemV/PST8 -8:00 - PST
Zone SystemV/YST9 -9:00 - YST
Zone SystemV/HST10 -10:00 - HST
......@@ -43,9 +43,15 @@ BUILD_MANIFEST=true
#
TZDATA_DIR := ../javazic/tzdata
TZDATA_VER := $(subst tzdata,,$(shell $(GREP) '^tzdata' $(TZDATA_DIR)/VERSION))
TZFILE := africa antarctica asia australasia europe northamerica southamerica backward etcetera
TZFILE := \
africa antarctica asia australasia europe northamerica \
pacificnew southamerica backward etcetera \
gmt jdk11_backward
TZFILES := $(addprefix $(TZDATA_DIR)/,$(TZFILE))
TZDB_JAR = tzdb.jar
#
......@@ -61,7 +67,7 @@ build: $(LIBDIR)/$(TZDB_JAR)
$(LIBDIR)/$(TZDB_JAR): $(TZFILES)
$(prep-target)
echo build tzdb from version $(TZDATA_VER)
$(BOOT_JAVA_CMD) -jar $(BUILDTOOLJARDIR)/tzdb.jar -verbose \
$(BOOT_JAVA_CMD) -jar $(BUILDTOOLJARDIR)/tzdb.jar \
-version $(TZDATA_VER) -srcdir $(TZDATA_DIR) -dstdir $(LIBDIR) $(TZFILE)
clean clobber::
......
......@@ -48,7 +48,6 @@ SUBDIRS = \
hasher_classes \
jarreorder \
jarsplit \
javazic \
jdwpgen \
makeclasslist \
strip_properties \
......
......@@ -490,11 +490,16 @@ class Zoneinfo {
tz.addUsedRec(rrec);
usedZone = true;
}
} else {
} else { // fromTime == minTime
int save = rrec.getSave();
tz.addTransition(fromTime,
tz.addTransition(minTime,
tz.getOffsetIndex(gmtOffset),
tz.getDstOffsetIndex(0));
tz.addTransition(transition,
tz.getOffsetIndex(gmtOffset+save),
tz.getDstOffsetIndex(save));
tz.addUsedRec(rrec);
usedZone = true;
}
......
......@@ -227,6 +227,7 @@ public final class TzdbZoneRulesCompiler {
Map<String, SortedMap<String, ZoneRules>> allBuiltZones = new TreeMap<>();
Set<String> allRegionIds = new TreeSet<String>();
Set<ZoneRules> allRules = new HashSet<ZoneRules>();
Map<String, Map<String, String>> allLinks = new TreeMap<>();
for (File srcDir : srcDirs) {
// source files in this directory
......@@ -242,7 +243,8 @@ public final class TzdbZoneRulesCompiler {
}
// compile
String loopVersion = srcDir.getName();
String loopVersion = (srcDirs.size() == 1 && version != null)
? version : srcDir.getName();
TzdbZoneRulesCompiler compiler = new TzdbZoneRulesCompiler(loopVersion, srcFiles, verbose);
try {
// compile
......@@ -255,12 +257,13 @@ public final class TzdbZoneRulesCompiler {
if (verbose) {
System.out.println("Outputting file: " + dstFile);
}
outputFile(dstFile, loopVersion, builtZones);
outputFile(dstFile, loopVersion, builtZones, compiler.links);
// create totals
allBuiltZones.put(loopVersion, builtZones);
allRegionIds.addAll(builtZones.keySet());
allRules.addAll(builtZones.values());
allLinks.put(loopVersion, compiler.links);
} catch (Exception ex) {
System.out.println("Failed: " + ex.toString());
ex.printStackTrace();
......@@ -274,7 +277,7 @@ public final class TzdbZoneRulesCompiler {
if (verbose) {
System.out.println("Outputting combined file: " + dstFile);
}
outputFile(dstFile, allBuiltZones, allRegionIds, allRules);
outputFile(dstFile, allBuiltZones, allRegionIds, allRules, allLinks);
}
}
......@@ -283,12 +286,15 @@ public final class TzdbZoneRulesCompiler {
*/
private static void outputFile(File dstFile,
String version,
SortedMap<String, ZoneRules> builtZones) {
SortedMap<String, ZoneRules> builtZones,
Map<String, String> links) {
Map<String, SortedMap<String, ZoneRules>> loopAllBuiltZones = new TreeMap<>();
loopAllBuiltZones.put(version, builtZones);
Set<String> loopAllRegionIds = new TreeSet<String>(builtZones.keySet());
Set<ZoneRules> loopAllRules = new HashSet<ZoneRules>(builtZones.values());
outputFile(dstFile, loopAllBuiltZones, loopAllRegionIds, loopAllRules);
Map<String, Map<String, String>> loopAllLinks = new TreeMap<>();
loopAllLinks.put(version, links);
outputFile(dstFile, loopAllBuiltZones, loopAllRegionIds, loopAllRules, loopAllLinks);
}
/**
......@@ -297,10 +303,10 @@ public final class TzdbZoneRulesCompiler {
private static void outputFile(File dstFile,
Map<String, SortedMap<String, ZoneRules>> allBuiltZones,
Set<String> allRegionIds,
Set<ZoneRules> allRules)
{
Set<ZoneRules> allRules,
Map<String, Map<String, String>> allLinks) {
try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(dstFile))) {
outputTZEntry(jos, allBuiltZones, allRegionIds, allRules);
outputTZEntry(jos, allBuiltZones, allRegionIds, allRules, allLinks);
} catch (Exception ex) {
System.out.println("Failed: " + ex.toString());
ex.printStackTrace();
......@@ -314,7 +320,8 @@ public final class TzdbZoneRulesCompiler {
private static void outputTZEntry(JarOutputStream jos,
Map<String, SortedMap<String, ZoneRules>> allBuiltZones,
Set<String> allRegionIds,
Set<ZoneRules> allRules) {
Set<ZoneRules> allRules,
Map<String, Map<String, String>> allLinks) {
// this format is not publicly specified
try {
jos.putNextEntry(new ZipEntry("TZDB.dat"));
......@@ -359,6 +366,16 @@ public final class TzdbZoneRulesCompiler {
out.writeShort(rulesIndex);
}
}
// alias-region
for (String version : allLinks.keySet()) {
out.writeShort(allLinks.get(version).size());
for (Map.Entry<String, String> entry : allLinks.get(version).entrySet()) {
int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey());
int regionIndex = Arrays.binarySearch(regionArray, entry.getValue());
out.writeShort(aliasIndex);
out.writeShort(regionIndex);
}
}
out.flush();
jos.closeEntry();
} catch (Exception ex) {
......@@ -621,7 +638,8 @@ public final class TzdbZoneRulesCompiler {
private int parseYear(String str, int defaultYear) {
if (YEAR.reset(str).matches()) {
if (YEAR.group("min") != null) {
return YEAR_MIN_VALUE;
//return YEAR_MIN_VALUE;
return 1900; // systemv has min
} else if (YEAR.group("max") != null) {
return YEAR_MAX_VALUE;
} else if (YEAR.group("only") != null) {
......@@ -742,16 +760,20 @@ public final class TzdbZoneRulesCompiler {
if (realRules == null) {
throw new IllegalArgumentException("Alias '" + aliasId + "' links to invalid zone '" + realId + "' for '" + version + "'");
}
links.put(aliasId, realId);
}
builtZones.put(aliasId, realRules);
}
// remove UTC and GMT
builtZones.remove("UTC");
builtZones.remove("GMT");
builtZones.remove("GMT0");
//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");
}
//-----------------------------------------------------------------------
......@@ -785,7 +807,6 @@ public final class TzdbZoneRulesCompiler {
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);
......
......@@ -30,7 +30,7 @@ GENDATA_TZDB :=
#
TZDATA_DIR := $(JDK_TOPDIR)/make/sun/javazic/tzdata
TZDATA_VER := $(subst tzdata,,$(shell $(GREP) '^tzdata' $(TZDATA_DIR)/VERSION))
TZDATA_TZFILE := africa antarctica asia australasia europe northamerica southamerica backward etcetera
TZDATA_TZFILE := africa antarctica asia australasia europe northamerica pacificnew southamerica backward etcetera gmt jdk11_backward
TZDATA_TZFILES := $(addprefix $(TZDATA_DIR)/,$(TZDATA_TZFILE))
GENDATA_TZDB_DST := $(JDK_OUTPUTDIR)/lib
......@@ -39,6 +39,6 @@ GENDATA_TZDB_JAR := tzdb.jar
$(GENDATA_TZDB_DST)/$(GENDATA_TZDB_JAR) : $(TZDATA_TZFILES)
$(RM) $(GENDATA_TZDB_DST)/$(GENDATA_TZDB_JAR)
echo building tzdb from version $(TZDATA_VER)
$(TOOL_TZDB) -verbose -version $(TZDATA_VER) -srcdir $(TZDATA_DIR) -dstdir $(GENDATA_TZDB_DST) $(TZDATA_TZFILE)
$(TOOL_TZDB) -version $(TZDATA_VER) -srcdir $(TZDATA_DIR) -dstdir $(GENDATA_TZDB_DST) $(TZDATA_TZFILE)
GENDATA_TZDB += $(GENDATA_TZDB_DST)/$(GENDATA_TZDB_JAR)
......@@ -34,7 +34,7 @@ GENDATA_TIMEZONE_TMP := $(JDK_OUTPUTDIR)/gendata_timezone
TZFILE0 := \
africa antarctica asia australasia europe northamerica \
pacificnew southamerica backward \
etcetera solar87 solar88 solar89 systemv
etcetera systemv
TZFILE1 := \
gmt jdk11_backward
......
......@@ -44,9 +44,6 @@ GENDATA += $(BREAK_ITERATOR)
include GendataFontConfig.gmk
GENDATA += $(GENDATA_FONT_CONFIG)
include GendataTimeZone.gmk
GENDATA += $(GENDATA_TIMEZONE)
include GendataTZDB.gmk
GENDATA += $(GENDATA_TZDB)
......
......@@ -103,9 +103,6 @@ TOOL_HASHER=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
TOOL_JARSPLIT=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
build.tools.jarsplit.JarSplit
TOOL_JAVAZIC=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
build.tools.javazic.Main
TOOL_TZDB=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
build.tools.tzdb.TzdbZoneRulesCompiler
......
......@@ -34,7 +34,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_jobjc_SEL_getSelectorPtr
const char *selNameAsChars = (*env)->GetStringUTFChars(env, selName, JNI_FALSE);
const SEL sel = sel_registerName(selNameAsChars);
(*env)->ReleaseStringUTFChars(env, selName, selNameAsChars);
return ptr_to_jlong(sel);
return ptr_to_jlong((void*)sel);
}
JNIEXPORT jstring JNICALL Java_com_apple_jobjc_SEL_getSelectorName
......
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -106,8 +106,9 @@ inflate_file(int fd, zentry *entry, int *size_out)
*size_out = (int)entry->isize;
}
return (out);
} else
return (NULL);
}
free(in);
return (NULL);
}
static jboolean zip64_present = JNI_FALSE;
......@@ -563,7 +564,7 @@ JLI_ParseManifest(char *jarfile, manifest_info *info)
if ((fd = open(jarfile, O_RDONLY
#ifdef O_LARGEFILE
| O_LARGEFILE /* large file mode on solaris */
| O_LARGEFILE /* large file mode */
#endif
#ifdef O_BINARY
| O_BINARY /* use binary mode on windows */
......@@ -618,6 +619,9 @@ JLI_JarUnpackFile(const char *jarfile, const char *filename, int *size) {
void *data = NULL;
fd = open(jarfile, O_RDONLY
#ifdef O_LARGEFILE
| O_LARGEFILE /* large file mode */
#endif
#ifdef O_BINARY
| O_BINARY /* use binary mode on windows */
#endif
......@@ -661,6 +665,9 @@ JLI_ManifestIterate(const char *jarfile, attribute_closure ac, void *user_data)
int rc;
if ((fd = open(jarfile, O_RDONLY
#ifdef O_LARGEFILE
| O_LARGEFILE /* large file mode */
#endif
#ifdef O_BINARY
| O_BINARY /* use binary mode on windows */
#endif
......
......@@ -52,16 +52,19 @@ import sun.misc.HexDumpEncoder;
* principal set and private credentials set are updated only when
* <code>commit</code> is called.
* When <code>commit</code> is called, the <code>KerberosPrincipal</code>
* is added to the <code>Subject</code>'s
* principal set and <code>KerberosTicket</code> is
* is added to the <code>Subject</code>'s principal set (unless the
* <code>principal</code> is specified as "*"). If <code>isInitiator</code>
* is true, the <code>KerberosTicket</code> is
* added to the <code>Subject</code>'s private credentials.
*
* <p> If the configuration entry for <code>KerberosLoginModule</code>
* has the option <code>storeKey</code> set to true, then
* <code>KerberosKey</code> will also be added to the
* <code>KerberosKey</code> or <code>KeyTab</code> will also be added to the
* subject's private credentials. <code>KerberosKey</code>, the principal's
* key will be either obtained from the keytab or
* derived from user's password.
* key(s) will be derived from user's password, and <code>KeyTab</code> is
* the keytab used when <code>useKeyTab</code> is set to true. The
* <code>KeyTab</code> object is restricted to be used by the specified
* principal unless the principal value is "*".
*
* <p> This <code>LoginModule</code> recognizes the <code>doNotPrompt</code>
* option. If set to true the user will not be prompted for the password.
......@@ -75,8 +78,8 @@ import sun.misc.HexDumpEncoder;
*
* <p> The principal name can be specified in the configuration entry
* by using the option <code>principal</code>. The principal name
* can either be a simple user name or a service name such as
* <code>host/mission.eng.sun.com</code>. The principal can also
* can either be a simple user name, a service name such as
* <code>host/mission.eng.sun.com</code>, or "*". The principal can also
* be set using the system property <code>sun.security.krb5.principal</code>.
* This property is checked during login. If this property is not set, then
* the principal name from the configuration is used. In the
......@@ -87,11 +90,10 @@ import sun.misc.HexDumpEncoder;
*
* <p> The following is a list of configuration options supported
* for <code>Krb5LoginModule</code>:
* <dl>
* <blockquote><dt><b><code>refreshKrb5Config</code></b>:</dt>
* <blockquote><dl>
* <dt><b><code>refreshKrb5Config</code></b>:</dt>
* <dd> Set this to true, if you want the configuration
* to be refreshed before the <code>login</code> method is called.</dd>
* <P>
* <dt><b><code>useTicketCache</code></b>:</dt>
* <dd>Set this to true, if you want the
* TGT to be obtained
......@@ -112,19 +114,16 @@ import sun.misc.HexDumpEncoder;
* <code>ticketCache</code>.
* For Windows, if a ticket cannot be retrieved from the file ticket cache,
* it will use Local Security Authority (LSA) API to get the TGT.
* <P>
* <dt><b><code>ticketCache</code></b>:</dt>
* <dd>Set this to the name of the ticket
* cache that contains user's TGT.
* If this is set, <code>useTicketCache</code>
* must also be set to true; Otherwise a configuration error will
* be returned.</dd>
* <P>
* <dt><b><code>renewTGT</code></b>:</dt>
* <dd>Set this to true, if you want to renew
* the TGT. If this is set, <code>useTicketCache</code> must also be
* set to true; otherwise a configuration error will be returned.</dd>
* <p>
* <dt><b><code>doNotPrompt</code></b>:</dt>
* <dd>Set this to true if you do not want to be
* prompted for the password
......@@ -132,7 +131,6 @@ import sun.misc.HexDumpEncoder;
* or through shared state.(Default is false)
* If set to true, credential must be obtained through cache, keytab,
* or shared state. Otherwise, authentication will fail.</dd>
* <P>
* <dt><b><code>useKeyTab</code></b>:</dt>
* <dd>Set this to true if you
* want the module to get the principal's key from the
......@@ -144,15 +142,15 @@ import sun.misc.HexDumpEncoder;
* If it is not specified in the Kerberos configuration file
* then it will look for the file
* <code>{user.home}{file.separator}</code>krb5.keytab.</dd>
* <P>
* <dt><b><code>keyTab</code></b>:</dt>
* <dd>Set this to the file name of the
* keytab to get principal's secret key.</dd>
* <P>
* <dt><b><code>storeKey</code></b>:</dt>
* <dd>Set this to true to if you want the
* principal's key to be stored in the Subject's private credentials. </dd>
* <p>
* <dd>Set this to true to if you want the keytab or the
* principal's key to be stored in the Subject's private credentials.
* For <code>isInitiator</code> being false, if <code>principal</code>
* is "*", the {@link KeyTab} stored can be used by anyone, otherwise,
* it's restricted to be used by the specified principal only.</dd>
* <dt><b><code>principal</code></b>:</dt>
* <dd>The name of the principal that should
* be used. The principal can be a simple username such as
......@@ -165,8 +163,13 @@ import sun.misc.HexDumpEncoder;
* <code>sun.security.krb5.principal</code>. In addition, if this
* system property is defined, then it will be used. If this property
* is not set, then the principal name from the configuration will be
* used.</dd>
* <P>
* used.
* The principal name can be set to "*" when <code>isInitiator</code> is false.
* In this case, the acceptor is not bound to a single principal. It can
* act as any principal an initiator requests if keys for that principal
* can be found. When <code>isInitiator</code> is true, the principal name
* cannot be set to "*".
* </dd>
* <dt><b><code>isInitiator</code></b>:</dt>
* <dd>Set this to true, if initiator. Set this to false, if acceptor only.
* (Default is true).
......@@ -177,18 +180,20 @@ import sun.misc.HexDumpEncoder;
* <code>Configuration</code>
* options that enable you to share username and passwords across different
* authentication modules:
* <pre>
* <blockquote><dl>
*
* useFirstPass if, true, this LoginModule retrieves the
* <dt><b><code>useFirstPass</code></b>:</dt>
* <dd>if, true, this LoginModule retrieves the
* username and password from the module's shared state,
* using "javax.security.auth.login.name" and
* "javax.security.auth.login.password" as the respective
* keys. The retrieved values are used for authentication.
* If authentication fails, no attempt for a retry
* is made, and the failure is reported back to the
* calling application.
* calling application.</dd>
*
* tryFirstPass if, true, this LoginModule retrieves the
* <dt><b><code>tryFirstPass</code></b>:</dt>
* <dd>if, true, this LoginModule retrieves the
* the username and password from the module's shared
* state using "javax.security.auth.login.name" and
* "javax.security.auth.login.password" as the respective
......@@ -198,26 +203,28 @@ import sun.misc.HexDumpEncoder;
* CallbackHandler to retrieve a new username
* and password, and another attempt to authenticate
* is made. If the authentication fails,
* the failure is reported back to the calling application
* the failure is reported back to the calling application</dd>
*
* storePass if, true, this LoginModule stores the username and
* <dt><b><code>storePass</code></b>:</dt>
* <dd>if, true, this LoginModule stores the username and
* password obtained from the CallbackHandler in the
* modules shared state, using
* "javax.security.auth.login.name" and
* "javax.security.auth.login.password" as the respective
* keys. This is not performed if existing values already
* exist for the username and password in the shared
* state, or if authentication fails.
* state, or if authentication fails.</dd>
*
* clearPass if, true, this LoginModule clears the
* <dt><b><code>clearPass</code></b>:</dt>
* <dd>if, true, this LoginModule clears the
* username and password stored in the module's shared
* state after both phases of authentication
* (login and commit) have completed.
* </pre>
* (login and commit) have completed.</dd>
* </dl></blockquote>
* <p>If the principal system property or key is already provided, the value of
* "javax.security.auth.login.name" in the shared state is ignored.
* <p>When multiple mechanisms to retrieve a ticket or key is provided, the
* preference order looks like this:
* preference order is:
* <ol>
* <li>ticket cache
* <li>keytab
......@@ -225,7 +232,7 @@ import sun.misc.HexDumpEncoder;
* <li>user prompt
* </ol>
* <p>Note that if any step fails, it will fallback to the next step.
* There's only one exception, it the shared state step fails and
* There's only one exception, if the shared state step fails and
* <code>useFirstPass</code>=true, no user prompt is made.
* <p>Examples of some configuration values for Krb5LoginModule in
* JAAS config file and the results are:
......@@ -318,7 +325,7 @@ import sun.misc.HexDumpEncoder;
* <p> <code>useKeyTab</code> = true
* <code>keyTab</code>=&lt;keytabname&gt;
* <code>storeKey</code>=true
* <code>doNotPrompt</code>=true;
* <code>doNotPrompt</code>=false;
*</ul>
* <p>The user will be prompted for the service principal name.
* If the principal's
......@@ -328,6 +335,14 @@ import sun.misc.HexDumpEncoder;
* If successful the TGT will be added to the
* Subject's private credentials set. Otherwise the authentication will
* fail.
* <ul>
* <p> <code>isInitiator</code> = false <code>useKeyTab</code> = true
* <code>keyTab</code>=&lt;keytabname&gt;
* <code>storeKey</code>=true
* <code>principal</code>=*;
*</ul>
* <p>The acceptor will be an unbound acceptor and it can act as any principal
* as long that principal has keys in the keytab.
*<ul>
* <p>
* <code>useTicketCache</code>=true
......@@ -409,6 +424,7 @@ public class Krb5LoginModule implements LoginModule {
private KerberosTicket kerbTicket = null;
private KerberosKey[] kerbKeys = null;
private StringBuffer krb5PrincName = null;
private boolean unboundServer = false;
private char[] password = null;
private static final String NAME = "javax.security.auth.login.name";
......@@ -520,8 +536,6 @@ public class Krb5LoginModule implements LoginModule {
*/
public boolean login() throws LoginException {
int len;
validateConfiguration();
if (refreshKrb5Config) {
try {
if (debug) {
......@@ -544,6 +558,12 @@ public class Krb5LoginModule implements LoginModule {
}
}
validateConfiguration();
if (krb5PrincName != null && krb5PrincName.toString().equals("*")) {
unboundServer = true;
}
if (tryFirstPass) {
try {
attemptAuthentication(true);
......@@ -698,9 +718,17 @@ public class Krb5LoginModule implements LoginModule {
* (encKeys == null) to check.
*/
if (useKeyTab) {
ktab = (keyTabName == null)
? KeyTab.getInstance()
: KeyTab.getInstance(new File(keyTabName));
if (!unboundServer) {
KerberosPrincipal kp =
new KerberosPrincipal(principal.getName());
ktab = (keyTabName == null)
? KeyTab.getInstance(kp)
: KeyTab.getInstance(kp, new File(keyTabName));
} else {
ktab = (keyTabName == null)
? KeyTab.getUnboundInstance()
: KeyTab.getUnboundInstance(new File(keyTabName));
}
if (isInitiator) {
if (Krb5Util.keysFromJavaxKeyTab(ktab, principal).length
== 0) {
......@@ -939,6 +967,13 @@ public class Krb5LoginModule implements LoginModule {
("Configuration Error"
+ " - either useTicketCache should be "
+ " true or renewTGT should be false");
if (krb5PrincName != null && krb5PrincName.toString().equals("*")) {
if (isInitiator) {
throw new LoginException
("Configuration Error"
+ " - principal cannot be * when isInitiator is true");
}
}
}
private boolean isCurrent(Credentials creds)
......@@ -1052,7 +1087,10 @@ public class Krb5LoginModule implements LoginModule {
}
// Let us add the kerbClientPrinc,kerbTicket and KeyTab/KerbKey (if
// storeKey is true)
if (!princSet.contains(kerbClientPrinc)) {
// We won't add "*" as a KerberosPrincipal
if (!unboundServer &&
!princSet.contains(kerbClientPrinc)) {
princSet.add(kerbClientPrinc);
}
......
......@@ -138,8 +138,7 @@ public final class Client extends NTLM {
domain = domainFromServer;
}
if (domain == null) {
throw new NTLMException(NTLMException.NO_DOMAIN_INFO,
"No domain info");
domain = "";
}
int flags = 0x88200 | (inputFlags & 3);
......
......@@ -136,10 +136,10 @@ class NTLM {
int readInt(int offset) throws NTLMException {
try {
return internal[offset] & 0xff +
(internal[offset+1] & 0xff << 8) +
(internal[offset+2] & 0xff << 16) +
(internal[offset+3] & 0xff << 24);
return (internal[offset] & 0xff) +
((internal[offset+1] & 0xff) << 8) +
((internal[offset+2] & 0xff) << 16) +
((internal[offset+3] & 0xff) << 24);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new NTLMException(NTLMException.PACKET_READ_ERROR,
"Input message incorrect size");
......@@ -148,8 +148,8 @@ class NTLM {
int readShort(int offset) throws NTLMException {
try {
return internal[offset] & 0xff +
(internal[offset+1] & 0xff << 8);
return (internal[offset] & 0xff) +
((internal[offset+1] & 0xff << 8));
} catch (ArrayIndexOutOfBoundsException ex) {
throw new NTLMException(NTLMException.PACKET_READ_ERROR,
"Input message incorrect size");
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -34,7 +34,7 @@ import java.io.IOException;
*
* @since 1.5
*/
@FunctionalInterface
public interface Closeable extends AutoCloseable {
/**
......
/*
* Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
......@@ -35,6 +35,7 @@ package java.io;
*
* @since 1.2
*/
@FunctionalInterface
public interface FileFilter {
/**
......@@ -46,5 +47,4 @@ public interface FileFilter {
* should be included
*/
boolean accept(File pathname);
}
/*
* Copyright (c) 1994, 1998, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
......@@ -39,8 +39,8 @@ package java.io;
* @see java.io.File#list(java.io.FilenameFilter)
* @since JDK1.0
*/
public
interface FilenameFilter {
@FunctionalInterface
public interface FilenameFilter {
/**
* Tests if a specified file should be included in a file list.
*
......
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 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
......@@ -34,7 +34,7 @@ import java.io.IOException;
*
* @since 1.5
*/
@FunctionalInterface
public interface Flushable {
/**
......
/*
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 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
......@@ -31,6 +31,7 @@ package java.lang;
* @author Josh Bloch
* @since 1.7
*/
@FunctionalInterface
public interface AutoCloseable {
/**
* Closes this resource, relinquishing any underlying resources.
......
......@@ -3087,7 +3087,8 @@ public final
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public <A extends Annotation> A[] getAnnotations(Class<A> annotationClass) {
@Override
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass) {
Objects.requireNonNull(annotationClass);
initAnnotationsIfNecessary();
......@@ -3106,6 +3107,7 @@ public final
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@Override
@SuppressWarnings("unchecked")
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) {
Objects.requireNonNull(annotationClass);
......@@ -3118,7 +3120,8 @@ public final
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public <A extends Annotation> A[] getDeclaredAnnotations(Class<A> annotationClass) {
@Override
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationClass) {
Objects.requireNonNull(annotationClass);
initAnnotationsIfNecessary();
......
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
......@@ -93,7 +93,7 @@ import java.util.*;
* @see java.util.Comparator
* @since 1.2
*/
@FunctionalInterface
public interface Comparable<T> {
/**
* Compares this object with the specified object for order. Returns a
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -35,6 +35,7 @@ import java.util.Iterator;
*
* @since 1.5
*/
@FunctionalInterface
public interface Iterable<T> {
/**
......
......@@ -389,8 +389,9 @@ public class Package implements java.lang.reflect.AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public <A extends Annotation> A[] getAnnotations(Class<A> annotationClass) {
return getPackageInfo().getAnnotations(annotationClass);
@Override
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationClass) {
return getPackageInfo().getAnnotationsByType(annotationClass);
}
/**
......@@ -404,6 +405,7 @@ public class Package implements java.lang.reflect.AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@Override
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationClass) {
return getPackageInfo().getDeclaredAnnotation(annotationClass);
}
......@@ -412,8 +414,9 @@ public class Package implements java.lang.reflect.AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public <A extends Annotation> A[] getDeclaredAnnotations(Class<A> annotationClass) {
return getPackageInfo().getDeclaredAnnotations(annotationClass);
@Override
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationClass) {
return getPackageInfo().getDeclaredAnnotationsByType(annotationClass);
}
/**
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
......@@ -34,7 +34,7 @@ import java.io.IOException;
*
* @since 1.5
*/
@FunctionalInterface
public interface Readable {
/**
......@@ -51,5 +51,4 @@ public interface Readable {
* @throws java.nio.ReadOnlyBufferException if cb is a read only buffer
*/
public int read(java.nio.CharBuffer cb) throws IOException;
}
/*
* Copyright (c) 1994, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
......@@ -52,8 +52,8 @@ package java.lang;
* @see java.util.concurrent.Callable
* @since JDK1.0
*/
public
interface Runnable {
@FunctionalInterface
public interface Runnable {
/**
* When an object implementing interface <code>Runnable</code> is used
* to create a thread, starting the thread causes the object's
......
/*
* Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 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
......@@ -1851,6 +1851,7 @@ class Thread implements Runnable {
* @see ThreadGroup#uncaughtException
* @since 1.5
*/
@FunctionalInterface
public interface UncaughtExceptionHandler {
/**
* Method invoked when the given thread terminates due to the
......
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
......@@ -184,7 +184,8 @@ public class AccessibleObject implements AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public <T extends Annotation> T[] getAnnotations(Class<T> annotationClass) {
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
throw new AssertionError("All subclasses should override this method");
}
......@@ -199,6 +200,7 @@ public class AccessibleObject implements AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
@Override
public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass) {
// Only annotations on classes are inherited, for all other
// objects getDeclaredAnnotation is the same as
......@@ -210,11 +212,12 @@ public class AccessibleObject implements AnnotatedElement {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public <T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass) {
@Override
public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
// Only annotations on classes are inherited, for all other
// objects getDeclaredAnnotations is the same as
// getAnnotations.
return getAnnotations(annotationClass);
// objects getDeclaredAnnotationsByType is the same as
// getAnnotationsByType.
return getAnnotationsByType(annotationClass);
}
/**
......
......@@ -35,22 +35,43 @@ import java.lang.annotation.Annotation;
* arrays returned by accessors for array-valued enum members; it will
* have no affect on the arrays returned to other callers.
*
* <p>An annotation A is <em>directly present</em> on an element E if the
* RuntimeVisibleAnnotations or RuntimeVisibleParameterAnnotations attribute
* associated with E either:
* <p>The {@link #getAnnotationsByType(Class)} and {@link
* #getDeclaredAnnotationsByType(Class)} methods support multiple
* annotations of the same type on an element. If the argument to either method
* is a repeatable annotation type (JLS 9.6), then the method will "look
* through" a container annotation (JLS 9.7) which was generated at
* compile-time to wrap multiple annotations of the argument type.
*
* <p>The terms <em>directly present</em> and <em>present</em> are used
* throughout this interface to describe precisely which annotations are
* returned by methods:
*
* <ul>
* <li>An annotation A is <em>directly present</em> on an element E if E is
* associated with a RuntimeVisibleAnnotations or
* RuntimeVisibleParameterAnnotations attribute, and:
*
* <ul>
* <li>contains A; or
* <li>for invocations of get[Declared]Annotations(Class<T>),
* contains A or exactly one annotation C whose type is the containing
* annotation type of A's type (JLS 9.6) and whose value element contains A
* <li>for an invocation of {@code get[Declared]Annotation(Class<T>)} or
* {@code get[Declared]Annotations()}, the attribute contains A.
*
* <li>for an invocation of {@code get[Declared]AnnotationsByType(Class<T>)}, the
* attribute either contains A or, if the type of A is repeatable, contains
* exactly one annotation whose value element contains A and whose type is the
* containing annotation type of A's type (JLS 9.6).
* </ul>
*
* <p>An annotation A is <em>present</em> on an element E if either:
* <p>
* <li>An annotation A is <em>present</em> on an element E if either:
*
* <ul>
* <li>A is <em>directly present</em> on E; or
* <li>There are no annotations of A's type which are <em>directly present</em>
* on E, and E is a class, and A's type is inheritable (JLS 9.6.3.3), and A is
* present on the superclass of E
*
* <li>A is not <em>directly present</em> on E, and E is a class, and A's type
* is inheritable (JLS 9.6.3.3), and A is <em>present</em> on the superclass of
* E.
* </ul>
*
* </ul>
*
* <p>If an annotation returned by a method in this interface contains
......@@ -119,12 +140,19 @@ public interface AnnotatedElement {
<T extends Annotation> T getAnnotation(Class<T> annotationClass);
/**
* Returns an array of all this element's annotations for the
* specified type if one or more of such annotation is present,
* else an array of length zero.
* Returns annotations that are <em>present</em> on this element.
*
* If there are no annotations <em>present</em> on this element, the return
* value is an array of length 0.
*
* The caller of this method is free to modify the returned array;
* it will have no effect on the arrays returned to other callers.
* The difference between this method and {@link #getAnnotation(Class)}
* is that this method detects if its argument is a <em>repeatable
* annotation type</em> (JLS 9.6), and if so, attempts to find one or
* more annotations of that type by "looking through" a container
* annotation.
*
* The caller of this method is free to modify the returned array; it will
* have no effect on the arrays returned to other callers.
*
* @param annotationClass the Class object corresponding to the
* annotation type
......@@ -133,7 +161,7 @@ public interface AnnotatedElement {
* @throws NullPointerException if the given annotation class is null
* @since 1.8
*/
<T extends Annotation> T[] getAnnotations(Class<T> annotationClass);
<T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass);
/**
* Returns annotations that are <em>present</em> on this element.
......@@ -165,16 +193,21 @@ public interface AnnotatedElement {
*/
<T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass);
/**
* Returns an array of all this element's annotations for the
* specified type if one or more of such annotation is directly
* present, else an array of length zero.
/**
* Returns annotations that are <em>directly present</em> on this element.
* This method ignores inherited annotations.
*
* This method ignores inherited annotations. (Returns
* an array of length zero if no annotations are directly present
* on this element.) The caller of this method is free to modify
* the returned array; it will have no effect on the arrays
* returned to other callers.
* If there are no annotations <em>directly present</em> on this element,
* the return value is an array of length 0.
*
* The difference between this method and {@link
* #getDeclaredAnnotation(Class)} is that this method detects if its
* argument is a <em>repeatable annotation type</em> (JLS 9.6), and if so,
* attempts to find one or more annotations of that type by "looking
* through" a container annotation.
*
* The caller of this method is free to modify the returned array; it will
* have no effect on the arrays returned to other callers.
*
* @param annotationClass the Class object corresponding to the
* annotation type
......@@ -183,7 +216,7 @@ public interface AnnotatedElement {
* @throws NullPointerException if the given annotation class is null
* @since 1.8
*/
<T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass);
<T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass);
/**
* Returns annotations that are <em>directly present</em> on this element.
......
......@@ -278,6 +278,10 @@ public abstract class Executable extends AccessibleObject
* this object. Returns an array of length 0 if the executable
* has no parameters.
*
* The parameters of the underlying executable do not necessarily
* have unique names, or names that are legal identifiers in the
* Java programming language (JLS 3.8).
*
* @return an array of {@code Parameter} objects representing all
* the parameters to the executable this object represents
*/
......@@ -445,7 +449,8 @@ public abstract class Executable extends AccessibleObject
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public <T extends Annotation> T[] getAnnotations(Class<T> annotationClass) {
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
return AnnotationSupport.getMultipleAnnotations(declaredAnnotations(), annotationClass);
......
......@@ -1029,7 +1029,8 @@ class Field extends AccessibleObject implements Member {
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
public <T extends Annotation> T[] getAnnotations(Class<T> annotationClass) {
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
return AnnotationSupport.getMultipleAnnotations(declaredAnnotations(), annotationClass);
......
......@@ -342,13 +342,13 @@ class Modifier {
static final int SYNTHETIC = 0x00001000;
static final int ANNOTATION = 0x00002000;
static final int ENUM = 0x00004000;
static final int SYNTHESIZED = 0x00010000;
static final int MANDATED = 0x00008000;
static boolean isSynthetic(int mod) {
return (mod & SYNTHETIC) != 0;
}
static boolean isSynthesized(int mod) {
return (mod & SYNTHESIZED) != 0;
static boolean isMandated(int mod) {
return (mod & MANDATED) != 0;
}
/**
......
......@@ -44,7 +44,7 @@ public final class Parameter implements AnnotatedElement {
private final String name;
private final int modifiers;
private final Executable executable;
private int index;
private final int index;
/**
* Package-private constructor for {@code Parameter}.
......@@ -95,9 +95,14 @@ public final class Parameter implements AnnotatedElement {
}
/**
* Returns a string representation of the parameter's modifiers,
* its attributes, its type, its name, and a trailing ... if it is
* a variadic parameter.
* Returns a string describing this parameter. The format is the
* modifiers for the parameter, if any, in canonical order as
* recommended by <cite>The Java&trade; Language
* Specification</cite>, followed by the fully- qualified type of
* the parameter (excluding the last [] if the parameter is
* variable arity), followed by "..." if the parameter is variable
* arity, followed by a space, followed by the name of the
* parameter.
*
* @return A string representation of the parameter and associated
* information.
......@@ -118,7 +123,7 @@ public final class Parameter implements AnnotatedElement {
sb.append(typename);
sb.append(" ");
sb.append(name);
sb.append(getName());
return sb.toString();
}
......@@ -143,11 +148,23 @@ public final class Parameter implements AnnotatedElement {
}
/**
* Returns the name of the parameter represented by this
* {@code Parameter} object.
* Returns the name of the parameter. The names of the parameters
* of a single executable must all the be distinct. When names
* from the originating source are available, they are returned.
* Otherwise, an implementation of this method is free to create a
* name of this parameter, subject to the unquiness requirments.
*/
public String getName() {
return name;
// As per the spec, if a parameter has no name, return argX,
// where x is the index.
//
// Note: spec updates now outlaw empty strings as parameter
// names. The .equals("") is for compatibility with current
// JVM behavior. It may be removed at some point.
if(name == null || name.equals(""))
return "arg" + index;
else
return name;
}
/**
......@@ -190,20 +207,21 @@ public final class Parameter implements AnnotatedElement {
private transient volatile Class<?> parameterClassCache = null;
/**
* Returns {@code true} if this parameter is a synthesized
* construct; returns {@code false} otherwise.
* Returns {@code true} if this parameter is implicitly declared
* in source code; returns {@code false} otherwise.
*
* @return true if and only if this parameter is a synthesized
* construct as defined by
* <cite>The Java&trade; Language Specification</cite>.
* @return true if and only if this parameter is implicitly
* declared as defined by <cite>The Java&trade; Language
* Specification</cite>.
*/
public boolean isSynthesized() {
return Modifier.isSynthesized(getModifiers());
public boolean isImplicit() {
return Modifier.isMandated(getModifiers());
}
/**
* Returns {@code true} if this parameter is a synthetic
* construct; returns {@code false} otherwise.
* Returns {@code true} if this parameter is neither implicitly
* nor explicitly declared in source code; returns {@code false}
* otherwise.
*
* @jls 13.1 The Form of a Binary
* @return true if and only if this parameter is a synthetic
......@@ -240,7 +258,8 @@ public final class Parameter implements AnnotatedElement {
* {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
public <T extends Annotation> T[] getAnnotations(Class<T> annotationClass) {
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
return AnnotationSupport.getMultipleAnnotations(declaredAnnotations(), annotationClass);
......@@ -266,11 +285,12 @@ public final class Parameter implements AnnotatedElement {
/**
* @throws NullPointerException {@inheritDoc}
*/
public <T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass) {
@Override
public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) {
// Only annotations on classes are inherited, for all other
// objects getDeclaredAnnotations is the same as
// getAnnotations.
return getAnnotations(annotationClass);
return getAnnotationsByType(annotationClass);
}
/**
......
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
......@@ -117,8 +117,7 @@ import java.io.IOException;
*/
public interface DirectoryStream<T>
extends Closeable, Iterable<T>
{
extends Closeable, Iterable<T> {
/**
* An interface that is implemented by objects that decide if a directory
* entry should be accepted or filtered. A {@code Filter} is passed as the
......@@ -130,6 +129,7 @@ public interface DirectoryStream<T>
*
* @since 1.7
*/
@FunctionalInterface
public static interface Filter<T> {
/**
* Decides if the given directory entry should be accepted or filtered.
......
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
......@@ -34,7 +34,7 @@ package java.nio.file;
* @see FileSystem#getPathMatcher
* @see Files#newDirectoryStream(Path,String)
*/
@FunctionalInterface
public interface PathMatcher {
/**
* Tells if given path matches this matcher's pattern.
......
......@@ -218,6 +218,150 @@ public class KeyStore {
public ProtectionParameter getProtectionParameter();
}
/**
* Configuration data that specifies the keystores in a keystore domain.
* A keystore domain is a collection of keystores that are presented as a
* single logical keystore. The configuration data is used during
* {@code KeyStore}
* {@link #load(KeyStore.LoadStoreParameter) load} and
* {@link #store(KeyStore.LoadStoreParameter) store} operations.
* <p>
* The following syntax is supported for configuration data:
* <pre>
*
* domain <domainName> [<property> ...] {
* keystore <keystoreName> [<property> ...] ;
* ...
* };
* ...
*
* </pre>
* where {@code domainName} and {@code keystoreName} are identifiers
* and {@code property} is a key/value pairing. The key and value are
* separated by an 'equals' symbol and the value is enclosed in double
* quotes. A property value may be either a printable string or a binary
* string of colon-separated pairs of hexadecimal digits. Multi-valued
* properties are represented as a comma-separated list of values,
* enclosed in square brackets.
* See {@link Arrays#toString(java.lang.Object[])}.
* <p>
* To ensure that keystore entries are uniquely identified, each
* entry's alias is prefixed by its {@code keystoreName} followed
* by the entry name separator and each {@code keystoreName} must be
* unique within its domain. Entry name prefixes are omitted when
* storing a keystore.
* <p>
* Properties are context-sensitive: properties that apply to
* all the keystores in a domain are located in the domain clause,
* and properties that apply only to a specific keystore are located
* in that keystore's clause.
* Unless otherwise specified, a property in a keystore clause overrides
* a property of the same name in the domain clause. All property names
* are case-insensitive. The following properties are supported:
* <dl>
* <dt> {@code keystoreType="<type>"} </dt>
* <dd> The keystore type. </dd>
* <dt> {@code keystoreURI="<url>"} </dt>
* <dd> The keystore location. </dd>
* <dt> {@code keystoreProviderName="<name>"} </dt>
* <dd> The name of the keystore's JCE provider. </dd>
* <dt> {@code keystorePasswordEnv="<environment-variable>"} </dt>
* <dd> The environment variable that stores a keystore password.
* Alternatively, passwords may be supplied to the constructor
* method in a {@code Map<String, ProtectionParameter>}. </dd>
* <dt> {@code entryNameSeparator="<separator>"} </dt>
* <dd> The separator between a keystore name prefix and an entry name.
* When specified, it applies to all the entries in a domain.
* Its default value is a space. </dd>
* </dl>
* <p>
* For example, configuration data for a simple keystore domain
* comprising three keystores is shown below:
* <pre>
*
* domain app1 {
* keystore app1-truststore
* keystoreURI="file:///app1/etc/truststore.jks"
*
* keystore system-truststore
* keystoreURI="${java.home}/lib/security/cacerts"
*
* keystore app1-keystore
* keystoreType="PKCS12"
* keystoreURI="file:///app1/etc/keystore.p12"
* };
*
* </pre>
* @since 1.8
*/
public static final class DomainLoadStoreParameter
implements LoadStoreParameter {
private final URI configuration;
private final Map<String,ProtectionParameter> protectionParams;
/**
* Constructs a DomainLoadStoreParameter for a keystore domain with
* the parameters used to protect keystore data.
*
* @param configuration identifier for the domain configuration data.
* The name of the target domain should be specified in the
* {@code java.net.URI} fragment component when it is necessary
* to distinguish between several domain configurations at the
* same location.
*
* @param protectionParams the map from keystore name to the parameter
* used to protect keystore data.
* A {@code java.util.Collections.EMPTY_MAP} should be used
* when protection parameters are not required or when they have
* been specified by properties in the domain configuration data.
* It is cloned to prevent subsequent modification.
*
* @exception NullPointerExcetion if {@code configuration} or
* {@code protectionParams} is {@code null}
*/
public DomainLoadStoreParameter(URI configuration,
Map<String,ProtectionParameter> protectionParams) {
if (configuration == null || protectionParams == null) {
throw new NullPointerException("invalid null input");
}
this.configuration = configuration;
this.protectionParams =
Collections.unmodifiableMap(new HashMap<>(protectionParams));
}
/**
* Gets the identifier for the domain configuration data.
*
* @return the identifier for the configuration data
*/
public URI getConfiguration() {
return configuration;
}
/**
* Gets the keystore protection parameters for keystores in this
* domain.
*
* @return an unmodifiable map of keystore names to protection
* parameters
*/
public Map<String,ProtectionParameter> getProtectionParams() {
return protectionParams;
}
/**
* Gets the keystore protection parameters for this domain.
* Keystore domains do not support a protection parameter.
*
* @return always returns {@code null}
*/
@Override
public KeyStore.ProtectionParameter getProtectionParameter() {
return null;
}
}
/**
* A marker interface for keystore protection parameters.
*
......
......@@ -25,6 +25,9 @@
package java.sql;
import java.time.Instant;
import java.time.LocalDate;
/**
* <P>A thin wrapper around a millisecond value that allows
* JDBC to identify this as an SQL <code>DATE</code> value. A
......@@ -113,7 +116,6 @@ public class Date extends java.util.Date {
int firstDash;
int secondDash;
Date d = null;
if (s == null) {
throw new java.lang.IllegalArgumentException();
}
......@@ -255,4 +257,50 @@ public class Date extends java.util.Date {
* compatibility.
*/
static final long serialVersionUID = 1511598038487230103L;
/**
* Obtains an instance of {@code Date} from a {@link LocalDate} object
* with the same year, month and day of month value as the given
* {@code LocalDate}.
* <p>
* The provided {@code LocalDate} is interpreted as the local date
* in the local time zone.
*
* @param date a {@code LocalDate} to convert
* @return a {@code Date} object
* @exception NullPointerException if {@code date} is null
* @since 1.8
*/
@SuppressWarnings("deprecation")
public static Date valueOf(LocalDate date) {
return new Date(date.getYear() - 1900, date.getMonthValue() -1,
date.getDayOfMonth());
}
/**
* Converts this {@code Date} object to a {@code LocalDate}
* <p>
* The conversion creates a {@code LocalDate} that represents the same
* date value as this {@code Date} in local time zone
*
* @return a {@code LocalDate} object representing the same date value
*
* @since 1.8
*/
@SuppressWarnings("deprecation")
public LocalDate toLocalDate() {
return LocalDate.of(getYear() + 1900, getMonth() + 1, getDate());
}
/**
* This method always throws an UnsupportedOperationException and should
* not be used because SQL {@code Date} values do not have a time
* component.
*
* @exception java.lang.UnsupportedOperationException if this method is invoked
*/
@Override
public Instant toInstant() {
throw new java.lang.UnsupportedOperationException();
}
}
......@@ -190,7 +190,17 @@ public enum JDBCType implements SQLType {
/**
* Identifies the generic SQL type {@code REF_CURSOR}.
*/
REF_CURSOR(Types.REF_CURSOR);
REF_CURSOR(Types.REF_CURSOR),
/**
* Identifies the generic SQL type {@code TIME_WITH_TIMEZONE}.
*/
TIME_WITH_TIMEZONE(Types.TIME_WITH_TIMEZONE),
/**
* Identifies the generic SQL type {@code TIMESTAMP_WITH_TIMEZONE}.
*/
TIMESTAMP_WITH_TIMEZONE(Types.TIMESTAMP_WITH_TIMEZONE);
/**
* The Integer value for the JDBCType. It maps to a value in
......
/*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
......@@ -421,4 +421,38 @@ public interface SQLInput {
*/
RowId readRowId() throws SQLException;
//--------------------------JDBC 4.2 -----------------------------
/**
* Reads the next attribute in the stream and returns it as an
* {@code Object} in the Java programming language. The
* actual type of the object returned is determined by the specified
* Java data type, and any customizations present in this
* stream's type map.
*
* <P>A type map is registered with the stream by the JDBC driver before the
* stream is passed to the application.
*
* <P>When the attribute at the head of the stream is an SQL {@code NULL}
* the method returns {@code null}. If the attribute is an SQL
* structured or distinct
* type, it determines the SQL type of the attribute at the head of the stream.
* If the stream's type map has an entry for that SQL type, the driver
* constructs an object of the appropriate class and calls the method
* {@code SQLData.readSQL} on that object, which reads additional data from the
* stream, using the protocol described for that method.
*<p>
* The default implementation will throw {@code SQLFeatureNotSupportedException}
*
* @param type Class representing the Java data type to convert the attribute to.
* @return the attribute at the head of the stream as an {@code Object} in the
* Java programming language;{@code null} if the attribute is SQL {@code NULL}
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.8
*/
default <T> T readObject(Class<T> type) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
}
/*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
......@@ -272,7 +272,7 @@ package java.sql;
* Otherwise, it calls the <code>SQLData.writeSQL</code>
* method of the given object, which
* writes the object's attributes to the stream.
* The implementation of the method <code>SQLData.writeSQ</code>
* The implementation of the method <code>SQLData.writeSQL</code>
* calls the appropriate <code>SQLOutput</code> writer method(s)
* for writing each of the object's attributes in order.
* The attributes must be read from an <code>SQLInput</code>
......@@ -433,5 +433,43 @@ package java.sql;
*/
void writeSQLXML(SQLXML x) throws SQLException;
//--------------------------JDBC 4.2 -----------------------------
/**
* Writes to the stream the data contained in the given object. The
* object will be converted to the specified targetSqlType
* before being sent to the stream.
*<p>
* When the {@code object} is {@code null}, this
* method writes an SQL {@code NULL} to the stream.
* <p>
* If the object has a custom mapping (is of a class implementing the
* interface {@code SQLData}),
* the JDBC driver should call the method {@code SQLData.writeSQL} to
* write it to the SQL data stream.
* If, on the other hand, the object is of a class implementing
* {@code Ref}, {@code Blob}, {@code Clob}, {@code NClob},
* {@code Struct}, {@code java.net.URL},
* or {@code Array}, the driver should pass it to the database as a
* value of the corresponding SQL type.
*<P>
* The default implementation will throw {@code SQLFeatureNotSupportedException}
*
* @param x the object containing the input parameter value
* @param targetSqlType the SQL type to be sent to the database.
* @exception SQLException if a database access error occurs or
* if the Java Object specified by x is an InputStream
* or Reader object and the value of the scale parameter is less
* than zero
* @exception SQLFeatureNotSupportedException if
* the JDBC driver does not support this data type
* @see JDBCType
* @see SQLType
* @since 1.8
*/
default void writeObject(Object x, SQLType targetSqlType) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
}
......@@ -25,6 +25,9 @@
package java.sql;
import java.time.Instant;
import java.time.LocalTime;
/**
* <P>A thin wrapper around the <code>java.util.Date</code> class that allows the JDBC
* API to identify this as an SQL <code>TIME</code> value. The <code>Time</code>
......@@ -246,4 +249,45 @@ public class Time extends java.util.Date {
* compatibility.
*/
static final long serialVersionUID = 8397324403548013681L;
/**
* Obtains an instance of {@code Time} from a {@link LocalTime} object
* with the same hour, minute and second time value as the given
* {@code LocalTime}.
*
* @param time a {@code LocalTime} to convert
* @return a {@code Time} object
* @exception NullPointerException if {@code time} is null
* @since 1.8
*/
@SuppressWarnings("deprecation")
public static Time valueOf(LocalTime time) {
return new Time(time.getHour(), time.getMinute(), time.getSecond());
}
/**
* Converts this {@code Time} object to a {@code LocalTime}.
* <p>
* The conversion creates a {@code LocalTime} that represents the same
* hour, minute, and second time value as this {@code Time}.
*
* @return a {@code LocalTime} object representing the same time value
* @since 1.8
*/
@SuppressWarnings("deprecation")
public LocalTime toLocalTime() {
return LocalTime.of(getHours(), getMinutes(), getSeconds());
}
/**
* This method always throws an UnsupportedOperationException and should
* not be used because SQL {@code Time} values do not have a date
* component.
*
* @exception java.lang.UnsupportedOperationException if this method is invoked
*/
@Override
public Instant toInstant() {
throw new java.lang.UnsupportedOperationException();
}
}
......@@ -25,6 +25,8 @@
package java.sql;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.StringTokenizer;
/**
......@@ -485,7 +487,6 @@ public class Timestamp extends java.util.Date {
}
}
return i;
}
/**
......@@ -530,4 +531,89 @@ public class Timestamp extends java.util.Date {
static final long serialVersionUID = 2745179027874758501L;
private static final int MILLIS_PER_SECOND = 1000;
/**
* Obtains an instance of {@code Timestamp} from a {@code LocalDateTime}
* object, with the same year, month, day of month, hours, minutes,
* seconds and nanos date-time value as the provided {@code LocalDateTime}.
* <p>
* The provided {@code LocalDateTime} is interpreted as the local
* date-time in the local time zone.
*
* @param dateTime a {@code LocalDateTime} to convert
* @return a {@code Timestamp} object
* @exception NullPointerException if {@code dateTime} is null.
* @since 1.8
*/
@SuppressWarnings("deprecation")
public static Timestamp valueOf(LocalDateTime dateTime) {
return new Timestamp(dateTime.getYear() - 1900,
dateTime.getMonthValue() - 1,
dateTime.getDayOfMonth(),
dateTime.getHour(),
dateTime.getMinute(),
dateTime.getSecond(),
dateTime.getNano());
}
/**
* Converts this {@code Timestamp} object to a {@code LocalDateTime}.
* <p>
* The conversion creates a {@code LocalDateTime} that represents the
* same year, month, day of month, hours, minutes, seconds and nanos
* date-time value as this {@code Timestamp} in the local time zone.
*
* @return a {@code LocalDateTime} object representing the same date-time value
* @since 1.8
*/
@SuppressWarnings("deprecation")
public LocalDateTime toLocalDateTime() {
return LocalDateTime.of(getYear() + 1900,
getMonth() + 1,
getDate(),
getHours(),
getMinutes(),
getSeconds(),
getNanos());
}
/**
* Obtains an instance of {@code Timestamp} from an {@link Instant} object.
* <p>
* {@code Instant} can store points on the time-line further in the future
* and further in the past than {@code Date}. In this scenario, this method
* will throw an exception.
*
* @param instant the instant to convert
* @return an {@code Timestamp} representing the same point on the time-line as
* the provided instant
* @exception NullPointerException if {@code instant} is null.
* @exception IllegalArgumentException if the instant is too large to
* represent as a {@code Timesamp}
* @since 1.8
*/
public static Timestamp from(Instant instant) {
try {
Timestamp stamp = new Timestamp(instant.getEpochSecond() * MILLIS_PER_SECOND);
stamp.nanos = instant.getNano();
return stamp;
} catch (ArithmeticException ex) {
throw new IllegalArgumentException(ex);
}
}
/**
* Converts this {@code Timestamp} object to an {@code Instant}.
* <p>
* The conversion creates an {@code Instant} that represents the same
* point on the time-line as this {@code Timestamp}.
*
* @return an instant representing the same point on the time-line
* @since 1.8
*/
@Override
public Instant toInstant() {
return Instant.ofEpochSecond(super.getTime() / MILLIS_PER_SECOND, nanos);
}
}
......@@ -319,6 +319,24 @@ public class Types {
*/
public static final int REF_CURSOR = 2012;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* {@code TIME WITH TIMEZONE}.
*
* @since 1.8
*/
public static final int TIME_WITH_TIMEZONE = 2013;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* {@code TIMESTAMP WITH TIMEZONE}.
*
* @since 1.8
*/
public static final int TIMESTAMP_WITH_TIMEZONE = 2014;
// Prevent instantiation
private Types() {}
}
......@@ -377,60 +377,57 @@ public abstract class Clock {
* an instant on the time-line rather than a raw millisecond value.
* This method is provided to allow the use of the clock in high performance use cases
* where the creation of an object would be unacceptable.
* <p>
* The default implementation currently calls {@link #instant}.
*
* @return the current millisecond instant from this clock, measured from
* the Java epoch of 1970-01-01T00:00 UTC, not null
* @throws DateTimeException if the instant cannot be obtained, not thrown by most implementations
*/
public abstract long millis();
public long millis() {
return instant().toEpochMilli();
}
//-----------------------------------------------------------------------
/**
* Gets the current instant of the clock.
* <p>
* This returns an instant representing the current instant as defined by the clock.
* <p>
* The default implementation currently calls {@link #millis}.
*
* @return the current instant from this clock, not null
* @throws DateTimeException if the instant cannot be obtained, not thrown by most implementations
*/
public Instant instant() {
return Instant.ofEpochMilli(millis());
}
public abstract Instant instant();
//-----------------------------------------------------------------------
/**
* Checks if this clock is equal to another clock.
* <p>
* Clocks must compare equal based on their state and behavior.
* Clocks should override this method to compare equals based on
* their state and to meet the contract of {@link Object#equals}.
* If not overridden, the behavior is defined by {@link Object#equals}
*
* @param obj the object to check, null returns false
* @return true if this is equal to the other clock
*/
@Override
public abstract boolean equals(Object obj);
public boolean equals(Object obj) {
return super.equals(obj);
}
/**
* A hash code for this clock.
*
* @return a suitable hash code
*/
@Override
public abstract int hashCode();
//-----------------------------------------------------------------------
/**
* Returns a string describing this clock.
* <p>
* Clocks must have a string representation based on their state and behavior.
* For example, 'System[Europe/Paris]' could be used to represent the System
* clock in the 'Europe/Paris' time-zone.
* Clocks should override this method based on
* their state and to meet the contract of {@link Object#hashCode}.
* If not overridden, the behavior is defined by {@link Object#hashCode}
*
* @return a string representation of this clock, not null
* @return a suitable hash code
*/
@Override
public abstract String toString();
public int hashCode() {
return super.hashCode();
}
//-----------------------------------------------------------------------
/**
......@@ -460,6 +457,10 @@ public abstract class Clock {
return System.currentTimeMillis();
}
@Override
public Instant instant() {
return Instant.ofEpochMilli(millis());
}
@Override
public boolean equals(Object obj) {
if (obj instanceof SystemClock) {
return zone.equals(((SystemClock) obj).zone);
......
......@@ -170,8 +170,9 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
/**
* Obtains an instance of {@code DayOfWeek} from a temporal object.
* <p>
* A {@code TemporalAccessor} represents some form of date and time information.
* This factory converts the arbitrary temporal object to an instance of {@code DayOfWeek}.
* This obtains a day-of-week based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code DayOfWeek}.
* <p>
* The conversion extracts the {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} field.
* <p>
......@@ -206,8 +207,9 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
/**
* Gets the textual representation, such as 'Mon' or 'Friday'.
* <p>
* This returns the textual name used to identify the day-of-week.
* The parameters control the length of the returned text and the locale.
* This returns the textual name used to identify the day-of-week,
* suitable for presentation to the user.
* The parameters control the style of the returned text and the locale.
* <p>
* If no textual mapping is found then the {@link #getValue() numeric value} is returned.
*
......@@ -215,8 +217,8 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
* @param locale the locale to use, not null
* @return the text value of the day-of-week, not null
*/
public String getText(TextStyle style, Locale locale) {
return new DateTimeFormatterBuilder().appendText(DAY_OF_WEEK, style).toFormatter(locale).print(this);
public String getDisplayName(TextStyle style, Locale locale) {
return new DateTimeFormatterBuilder().appendText(DAY_OF_WEEK, style).toFormatter(locale).format(this);
}
//-----------------------------------------------------------------------
......@@ -232,7 +234,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
* All other {@code ChronoField} instances will return false.
* <p>
* If the field is not a {@code ChronoField}, then the result of this method
* is obtained by invoking {@code TemporalField.doIsSupported(TemporalAccessor)}
* is obtained by invoking {@code TemporalField.isSupportedBy(TemporalAccessor)}
* passing {@code this} as the argument.
* Whether the field is supported is determined by the field.
*
......@@ -244,7 +246,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
if (field instanceof ChronoField) {
return field == DAY_OF_WEEK;
}
return field != null && field.doIsSupported(this);
return field != null && field.isSupportedBy(this);
}
/**
......@@ -260,7 +262,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
* If the field is not a {@code ChronoField}, then the result of this method
* is obtained by invoking {@code TemporalField.doRange(TemporalAccessor)}
* is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)}
* passing {@code this} as the argument.
* Whether the range can be obtained is determined by the field.
*
......@@ -289,15 +291,13 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
* If the field is not a {@code ChronoField}, then the result of this method
* is obtained by invoking {@code TemporalField.doGet(TemporalAccessor)}
* is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)}
* passing {@code this} as the argument. Whether the value can be obtained,
* and what the value represents, is determined by the field.
*
* @param field the field to get, not null
* @return the value for the field, within the valid range of values
* @throws DateTimeException if a value for the field cannot be obtained
* @throws DateTimeException if the range of valid values for the field exceeds an {@code int}
* @throws DateTimeException if the value is outside the range of valid values for the field
* @throws ArithmeticException if numeric overflow occurs
*/
@Override
......@@ -320,7 +320,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
* If the field is not a {@code ChronoField}, then the result of this method
* is obtained by invoking {@code TemporalField.doGet(TemporalAccessor)}
* is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)}
* passing {@code this} as the argument. Whether the value can be obtained,
* and what the value represents, is determined by the field.
*
......@@ -336,7 +336,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster {
} else if (field instanceof ChronoField) {
throw new DateTimeException("Unsupported field: " + field.getName());
}
return field.doGet(this);
return field.getFrom(this);
}
//-----------------------------------------------------------------------
......
......@@ -64,11 +64,11 @@ package java.time;
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
import static java.time.temporal.ChronoUnit.MONTHS;
import java.time.chrono.Chronology;
import java.time.chrono.IsoChronology;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.TextStyle;
import java.time.temporal.Chrono;
import java.time.temporal.ChronoField;
import java.time.temporal.ISOChrono;
import java.time.temporal.Queries;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAccessor;
......@@ -192,8 +192,9 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
/**
* Obtains an instance of {@code Month} from a temporal object.
* <p>
* A {@code TemporalAccessor} represents some form of date and time information.
* This factory converts the arbitrary temporal object to an instance of {@code Month}.
* This obtains a month based on the specified temporal.
* A {@code TemporalAccessor} represents an arbitrary set of date and time information,
* which this factory converts to an instance of {@code Month}.
* <p>
* The conversion extracts the {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} field.
* The extraction is only permitted if the temporal object has an ISO
......@@ -211,7 +212,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
return (Month) temporal;
}
try {
if (ISOChrono.INSTANCE.equals(Chrono.from(temporal)) == false) {
if (IsoChronology.INSTANCE.equals(Chronology.from(temporal)) == false) {
temporal = LocalDate.from(temporal);
}
return of(temporal.get(MONTH_OF_YEAR));
......@@ -237,8 +238,9 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
/**
* Gets the textual representation, such as 'Jan' or 'December'.
* <p>
* This returns the textual name used to identify the month-of-year.
* The parameters control the length of the returned text and the locale.
* This returns the textual name used to identify the month-of-year,
* suitable for presentation to the user.
* The parameters control the style of the returned text and the locale.
* <p>
* If no textual mapping is found then the {@link #getValue() numeric value} is returned.
*
......@@ -246,8 +248,8 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
* @param locale the locale to use, not null
* @return the text value of the month-of-year, not null
*/
public String getText(TextStyle style, Locale locale) {
return new DateTimeFormatterBuilder().appendText(MONTH_OF_YEAR, style).toFormatter(locale).print(this);
public String getDisplayName(TextStyle style, Locale locale) {
return new DateTimeFormatterBuilder().appendText(MONTH_OF_YEAR, style).toFormatter(locale).format(this);
}
//-----------------------------------------------------------------------
......@@ -263,7 +265,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
* All other {@code ChronoField} instances will return false.
* <p>
* If the field is not a {@code ChronoField}, then the result of this method
* is obtained by invoking {@code TemporalField.doIsSupported(TemporalAccessor)}
* is obtained by invoking {@code TemporalField.isSupportedBy(TemporalAccessor)}
* passing {@code this} as the argument.
* Whether the field is supported is determined by the field.
*
......@@ -275,7 +277,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
if (field instanceof ChronoField) {
return field == MONTH_OF_YEAR;
}
return field != null && field.doIsSupported(this);
return field != null && field.isSupportedBy(this);
}
/**
......@@ -291,7 +293,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
* If the field is not a {@code ChronoField}, then the result of this method
* is obtained by invoking {@code TemporalField.doRange(TemporalAccessor)}
* is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)}
* passing {@code this} as the argument.
* Whether the range can be obtained is determined by the field.
*
......@@ -320,15 +322,13 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
* If the field is not a {@code ChronoField}, then the result of this method
* is obtained by invoking {@code TemporalField.doGet(TemporalAccessor)}
* is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)}
* passing {@code this} as the argument. Whether the value can be obtained,
* and what the value represents, is determined by the field.
*
* @param field the field to get, not null
* @return the value for the field, within the valid range of values
* @throws DateTimeException if a value for the field cannot be obtained
* @throws DateTimeException if the range of valid values for the field exceeds an {@code int}
* @throws DateTimeException if the value is outside the range of valid values for the field
* @throws ArithmeticException if numeric overflow occurs
*/
@Override
......@@ -351,7 +351,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
* If the field is not a {@code ChronoField}, then the result of this method
* is obtained by invoking {@code TemporalField.doGet(TemporalAccessor)}
* is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)}
* passing {@code this} as the argument. Whether the value can be obtained,
* and what the value represents, is determined by the field.
*
......@@ -367,7 +367,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
} else if (field instanceof ChronoField) {
throw new DateTimeException("Unsupported field: " + field.getName());
}
return field.doGet(this);
return field.getFrom(this);
}
//-----------------------------------------------------------------------
......@@ -554,8 +554,8 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
@SuppressWarnings("unchecked")
@Override
public <R> R query(TemporalQuery<R> query) {
if (query == Queries.chrono()) {
return (R) ISOChrono.INSTANCE;
if (query == Queries.chronology()) {
return (R) IsoChronology.INSTANCE;
} else if (query == Queries.precision()) {
return (R) MONTHS;
}
......@@ -599,7 +599,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster {
*/
@Override
public Temporal adjustInto(Temporal temporal) {
if (Chrono.from(temporal).equals(ISOChrono.INSTANCE) == false) {
if (Chronology.from(temporal).equals(IsoChronology.INSTANCE) == false) {
throw new DateTimeException("Adjustment only supported on ISO date-time");
}
return temporal.with(MONTH_OF_YEAR, getValue());
......
此差异已折叠。
......@@ -56,8 +56,6 @@
*/
package java.time;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.Externalizable;
import java.io.IOException;
import java.io.InvalidClassException;
......@@ -103,6 +101,12 @@ final class Ser implements Externalizable {
static final byte ZONE_DATE_TIME_TYPE = 6;
static final byte ZONE_REGION_TYPE = 7;
static final byte ZONE_OFFSET_TYPE = 8;
static final byte OFFSET_TIME_TYPE = 9;
static final byte OFFSET_DATE_TIME_TYPE = 10;
static final byte YEAR_TYPE = 11;
static final byte YEAR_MONTH_TYPE = 12;
static final byte MONTH_DAY_TYPE = 13;
static final byte PERIOD_TYPE = 14;
/** The type being serialized. */
private byte type;
......@@ -132,11 +136,12 @@ final class Ser implements Externalizable {
*
* @param out the data stream to write to, not null
*/
@Override
public void writeExternal(ObjectOutput out) throws IOException {
writeInternal(type, object, out);
}
static void writeInternal(byte type, Object object, DataOutput out) throws IOException {
static void writeInternal(byte type, Object object, ObjectOutput out) throws IOException {
out.writeByte(type);
switch (type) {
case DURATION_TYPE:
......@@ -163,6 +168,24 @@ final class Ser implements Externalizable {
case ZONE_DATE_TIME_TYPE:
((ZonedDateTime) object).writeExternal(out);
break;
case OFFSET_TIME_TYPE:
((OffsetTime) object).writeExternal(out);
break;
case OFFSET_DATE_TIME_TYPE:
((OffsetDateTime) object).writeExternal(out);
break;
case YEAR_TYPE:
((Year) object).writeExternal(out);
break;
case YEAR_MONTH_TYPE:
((YearMonth) object).writeExternal(out);
break;
case MONTH_DAY_TYPE:
((MonthDay) object).writeExternal(out);
break;
case PERIOD_TYPE:
((Period) object).writeExternal(out);
break;
default:
throw new InvalidClassException("Unknown serialized type");
}
......@@ -174,17 +197,17 @@ final class Ser implements Externalizable {
*
* @param in the data to read, not null
*/
public void readExternal(ObjectInput in) throws IOException {
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
type = in.readByte();
object = readInternal(type, in);
}
static Object read(DataInput in) throws IOException {
static Object read(ObjectInput in) throws IOException, ClassNotFoundException {
byte type = in.readByte();
return readInternal(type, in);
}
private static Object readInternal(byte type, DataInput in) throws IOException {
private static Object readInternal(byte type, ObjectInput in) throws IOException, ClassNotFoundException {
switch (type) {
case DURATION_TYPE: return Duration.readExternal(in);
case INSTANT_TYPE: return Instant.readExternal(in);
......@@ -194,6 +217,12 @@ final class Ser implements Externalizable {
case ZONE_DATE_TIME_TYPE: return ZonedDateTime.readExternal(in);
case ZONE_OFFSET_TYPE: return ZoneOffset.readExternal(in);
case ZONE_REGION_TYPE: return ZoneRegion.readExternal(in);
case OFFSET_TIME_TYPE: return OffsetTime.readExternal(in);
case OFFSET_DATE_TIME_TYPE: return OffsetDateTime.readExternal(in);
case YEAR_TYPE: return Year.readExternal(in);
case YEAR_MONTH_TYPE: return YearMonth.readExternal(in);
case MONTH_DAY_TYPE: return MonthDay.readExternal(in);
case PERIOD_TYPE: return Period.readExternal(in);
default:
throw new StreamCorruptedException("Unknown serialized type");
}
......
......@@ -113,7 +113,7 @@ final class ZoneRegion extends ZoneId implements Serializable {
* if the time-zone has available rules.
* <p>
* This method parses the ID and applies any appropriate normalization.
* It does not validate the ID against the known set of IDsfor which rules are available.
* It does not validate the ID against the known set of IDs for which rules are available.
* <p>
* This method is intended for advanced use cases.
* For example, consider a system that always retrieves time-zone rules from a remote server.
......@@ -135,18 +135,20 @@ final class ZoneRegion extends ZoneId implements Serializable {
* @param checkAvailable whether to check if the zone ID is available
* @return the zone ID, not null
* @throws DateTimeException if the ID format is invalid
* @throws DateTimeException if checking availability and the ID cannot be found
* @throws ZoneRulesException if checking availability and the ID cannot be found
*/
static ZoneRegion ofId(String zoneId, boolean checkAvailable) {
Objects.requireNonNull(zoneId, "zoneId");
if (zoneId.length() < 2 || zoneId.startsWith("UTC") ||
zoneId.startsWith("GMT") || (PATTERN.matcher(zoneId).matches() == false)) {
throw new DateTimeException("ZoneId format is not a valid region format");
if (zoneId.length() < 2 ||
zoneId.startsWith("UT") || // includes UTC
zoneId.startsWith("GMT") ||
(PATTERN.matcher(zoneId).matches() == false)) {
throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId);
}
ZoneRules rules = null;
try {
// always attempt load for better behavior after deserialization
rules = ZoneRulesProvider.getRules(zoneId);
rules = ZoneRulesProvider.getRules(zoneId, true);
} catch (ZoneRulesException ex) {
if (checkAvailable) {
throw ex;
......@@ -176,8 +178,8 @@ final class ZoneRegion extends ZoneId implements Serializable {
@Override
public ZoneRules getRules() {
// additional query for group provider when null allows for possibility
// that the provider was added after the ZoneId was created
return (rules != null ? rules : ZoneRulesProvider.getRules(id));
// that the provider was updated after the ZoneId was created
return (rules != null ? rules : ZoneRulesProvider.getRules(id, false));
}
//-----------------------------------------------------------------------
......
......@@ -54,7 +54,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package java.time.calendar;
package java.time.chrono;
import java.io.DataInput;
import java.io.DataOutput;
......@@ -64,7 +64,6 @@ import java.io.ObjectStreamException;
import java.io.Serializable;
import java.time.DateTimeException;
import java.time.LocalDate;
import java.time.temporal.Era;
import java.util.Arrays;
import sun.util.calendar.CalendarDate;
......@@ -86,7 +85,7 @@ import sun.util.calendar.CalendarDate;
* @since 1.8
*/
final class JapaneseEra
implements Era<JapaneseChrono>, Serializable {
implements Era, Serializable {
// The offset value to 0-based index from the era value.
// i.e., getValue() + ERA_OFFSET == 0-based index; except that -999 is mapped to zero
......@@ -133,7 +132,7 @@ final class JapaneseEra
private static final JapaneseEra[] KNOWN_ERAS;
static {
sun.util.calendar.Era[] sunEras = JapaneseChrono.JCAL.getEras();
sun.util.calendar.Era[] sunEras = JapaneseChronology.JCAL.getEras();
ERA_CONFIG = new sun.util.calendar.Era[sunEras.length + 1];
for (int i = 1; i < ERA_CONFIG.length; i++) {
ERA_CONFIG[i] = sunEras[i - 1];
......@@ -292,8 +291,8 @@ final class JapaneseEra
}
@Override
public JapaneseChrono getChrono() {
return JapaneseChrono.INSTANCE;
public JapaneseChronology getChronology() {
return JapaneseChronology.INSTANCE;
}
//-----------------------------------------------------------------------
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册