diff --git a/make/common/Release.gmk b/make/common/Release.gmk
index 70033e457d0b168edc1f4335da2c5aaf95b9588a..5371d044b913f5bda6c2485ffc10a10ca01a6d90 100644
--- a/make/common/Release.gmk
+++ b/make/common/Release.gmk
@@ -348,7 +348,6 @@ TOOLS = \
sun/tools/serialver \
sun/tools/tree \
sun/tools/util \
- sun/security/tools/jarsigner/JarBASE64Encoder.class \
sun/security/tools/jarsigner/Main.class \
sun/security/tools/jarsigner/JarSignerParameters.class \
sun/security/tools/jarsigner/Resources.class \
@@ -576,7 +575,6 @@ $(NOT_RT_JAR_LIST): FRC
$(ECHO) "sun/tools/serialver/" >> $@
$(ECHO) "sun/tools/tree/" >> $@
$(ECHO) "sun/tools/util/" >> $@
- $(ECHO) "sun/security/tools/jarsigner/JarBASE64Encoder.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/Main.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/JarSignerParameters.class" >> $@
$(ECHO) "sun/security/tools/jarsigner/Resources.class" >> $@
diff --git a/make/java/java/FILES_java.gmk b/make/java/java/FILES_java.gmk
index 8c2f80c5248f4cc03d1d6437e38c7b9b73c3efbc..189b9fcb7c27f950b381d4b415e11b35eedf3aed 100644
--- a/make/java/java/FILES_java.gmk
+++ b/make/java/java/FILES_java.gmk
@@ -257,6 +257,7 @@ JAVA_JAVA_java = \
sun/util/calendar/ZoneInfoFile.java \
java/util/TooManyListenersException.java \
java/util/Comparator.java \
+ java/util/Comparators.java \
java/util/Collections.java \
java/util/Iterator.java \
java/util/ListIterator.java \
diff --git a/make/java/zip/Makefile b/make/java/zip/Makefile
index 67a8557de0b645c37c47db12290ff8d1bf3c7bc2..99afd603d7c588d49dffe4f83e2815d5042bf003 100644
--- a/make/java/zip/Makefile
+++ b/make/java/zip/Makefile
@@ -68,6 +68,16 @@ ifeq ($(PLATFORM), solaris)
FILES_reorder += reorder-$(ARCH)
endif
endif
+
+#
+# Use mapfile unconditionally (even with fastdebug).
+# JDK's internal zlib is incompatible with stock zlib, because the
+# size of struct z_stream has been changed, so internal zlib
+# implementation must not be allowed to leak outside of libzip.so,
+# else you get hard to debug failures with fastdebug jdk when user
+# native code includes stock zlib.
+#
+FILES_m = mapfile-vers
include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk
diff --git a/make/launchers/Makefile b/make/launchers/Makefile
index be16512e478a69920406fb607f0fc2b20a65b5cc..476451587938060e0b14fe54856373c9cd180c69 100644
--- a/make/launchers/Makefile
+++ b/make/launchers/Makefile
@@ -77,6 +77,7 @@ $(call make-launcher, jmap, sun.tools.jmap.JMap, \
-J-Dsun.jvm.hotspot.debugger.useWindbgDebugger, )
$(call make-launcher, jps, sun.tools.jps.Jps, , )
$(call make-launcher, jrunscript, com.sun.tools.script.shell.Main, , )
+$(call make-launcher, jjs, jdk.nashorn.tools.Shell, , )
$(call make-launcher, jsadebugd, sun.jvm.hotspot.jdi.SADebugServer, , )
$(call make-launcher, jstack, sun.tools.jstack.JStack, \
-J-Dsun.jvm.hotspot.debugger.useProcDebugger \
diff --git a/make/tools/javazic/Makefile b/make/tools/javazic/Makefile
deleted file mode 100644
index 4545c4d491c47017a54e55abcdb8606837a76a21..0000000000000000000000000000000000000000
--- a/make/tools/javazic/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright (c) 1998, 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.
-#
-
-#
-# Makefile for building the javazic tool
-#
-
-BUILDDIR = ../..
-PACKAGE = build.tools.javazic
-PRODUCT = javazic
-PROGRAM = javazic
-include $(BUILDDIR)/common/Defs.gmk
-
-BUILDTOOL_SOURCE_ROOT = $(BUILDDIR)/tools/src
-BUILDTOOL_MAIN = $(PKGDIR)/Main.java
-
-#
-# Build tool jar rules.
-#
-include $(BUILDDIR)/common/BuildToolJar.gmk
-
diff --git a/make/tools/src/build/tools/deps/refs.allowed b/make/tools/src/build/tools/deps/refs.allowed
index 91605d535febd4b246ab1aa9a8f2991e14379526..ad9d5271199032d6ad507198a76ec42eaf4426eb 100644
--- a/make/tools/src/build/tools/deps/refs.allowed
+++ b/make/tools/src/build/tools/deps/refs.allowed
@@ -33,8 +33,3 @@ sun.security.krb5.Realm=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,comp
#
java.beans.PropertyChangeListener=java.util.logging.LogManager,sun.org.mozilla.javascript.internal.Context,compact1,compact2,compact3
java.beans.PropertyChangeEvent=sun.org.mozilla.javascript.internal.Context,compact3
-
-# JFR traces even in builds with JFR disabled
-com.oracle.jrockit.jfr.FlightRecorder: com.sun.management.MissionControl, compact3
-com.oracle.jrockit.jfr.management.FlightRecorderMBean: com.sun.management.MissionControl, compact3
-
diff --git a/make/tools/src/build/tools/javazic/BackEnd.java b/make/tools/src/build/tools/javazic/BackEnd.java
deleted file mode 100644
index bfeda032037c9bb160f84fa3330ade01872138ec..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/BackEnd.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2000, 2004, 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.javazic;
-
-/**
- * BackEnd is an abstract base class for a back-end of compiling
- * Olson's zoneinfo database and generating Java zoneinfo database.
- *
- * @since 1.4
- */
-abstract class BackEnd {
-
- /**
- * Receives each zone's TimeZone information which was created by
- * {@link Zoneinfo#parse} in class Zoneinfo,
- * and processes it.
- *
- * @param tz Timezone object for each zone
- * @return 0 if no error occurred, otherwise 1.
- */
- abstract int processZoneinfo(Timezone tz);
-
- /**
- * Receives whole information which is generated by JavaZic's front-end
- * in the form of Mapping object and generates all Java zone information
- * files.
- *
- * @param m Mappings object which is generated by
- * {@link Main#compile() Main.compile()}.
- * @return 0 if no error occurred, otherwise 1.
- */
- abstract int generateSrc(Mappings m);
-
- /**
- * Decides which backend class should be used and returns its instance.
- * @return an instance of backend class
- */
- static BackEnd getBackEnd() {
- if (Zoneinfo.isYearForTimeZoneDataSpecified) {
- return new Simple();
- } else if (Main.outputDoc) {
- return new GenDoc();
- } else {
- return new Gen();
- }
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Checksum.java b/make/tools/src/build/tools/javazic/Checksum.java
deleted file mode 100644
index 565395d5c8df4effe976745bd6e3174d4988e44f..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Checksum.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2000, 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.javazic;
-
-import java.util.zip.CRC32;
-
-/**
- * Checksum provides methods for calculating a CRC32 value for a
- * transitions table.
- *
- * @since 1.4
- */
-public class Checksum extends CRC32
-{
- /**
- * Updates the CRC32 value from each byte of the given int
- * value. The bytes are used in the big endian order.
- * @param val the int value
- */
- public void update(int val) {
- byte[] b = new byte[4];
- b[0] = (byte)((val >>> 24) & 0xff);
- b[1] = (byte)((val >>> 16) & 0xff);
- b[2] = (byte)((val >>> 8) & 0xff);
- b[3] = (byte)(val & 0xff);
- update(b);
- }
-
- /**
- * Updates the CRC32 value from each byte of the given long
- * value. The bytes are used in the big endian order.
- * @param val the long value
- */
- void update(long val) {
- byte[] b = new byte[8];
- b[0] = (byte)((val >>> 56) & 0xff);
- b[1] = (byte)((val >>> 48) & 0xff);
- b[2] = (byte)((val >>> 40) & 0xff);
- b[3] = (byte)((val >>> 32) & 0xff);
- b[4] = (byte)((val >>> 24) & 0xff);
- b[5] = (byte)((val >>> 16) & 0xff);
- b[6] = (byte)((val >>> 8) & 0xff);
- b[7] = (byte)(val & 0xff);
- update(b);
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Gen.java b/make/tools/src/build/tools/javazic/Gen.java
deleted file mode 100644
index 8f3a8c5a37aceb6d2b8195625e4b35f6f77c5c37..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Gen.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright (c) 2000, 2011, 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.javazic;
-
-import java.io.IOException;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.DataOutputStream;
-import java.io.RandomAccessFile;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import sun.util.calendar.ZoneInfoFile;
-
-/**
- * Gen is one of back-end classes of javazic, and generates
- * ZoneInfoMappings and zone-specific file for each zone.
- */
-class Gen extends BackEnd {
-
- /**
- * Generates datafile in binary TLV format for each time zone.
- * Regarding contents of output files, see {@link ZoneInfoFile}.
- *
- * @param Timezone
- * @return 0 if no errors, or 1 if error occurred.
- */
- int processZoneinfo(Timezone tz) {
- try {
- int size;
- String outputDir = Main.getOutputDir();
- String zonefile = ZoneInfoFile.getFileName(tz.getName());
-
- /* If outputDir doesn't end with file-separator, adds it. */
- if (!outputDir.endsWith(File.separator)) {
- outputDir += File.separatorChar;
- }
-
- /* If zonefile includes file-separator, it's treated as part of
- * pathname. And make directory if necessary.
- */
- int index = zonefile.lastIndexOf(File.separatorChar);
- if (index != -1) {
- outputDir += zonefile.substring(0, index+1);
- }
- File outD = new File(outputDir);
- outD.mkdirs();
-
- FileOutputStream fos =
- new FileOutputStream(outputDir + zonefile.substring(index+1));
- DataOutputStream dos = new DataOutputStream(fos);
-
- /* Output Label */
- dos.write(ZoneInfoFile.JAVAZI_LABEL, 0,
- ZoneInfoFile.JAVAZI_LABEL.length);
-
- /* Output Version of ZoneInfoFile */
- dos.writeByte(ZoneInfoFile.JAVAZI_VERSION);
-
- List transitions = tz.getTransitions();
- if (transitions != null) {
- List dstOffsets = tz.getDstOffsets();
- List offsets = tz.getOffsets();
-
- if ((dstOffsets == null && offsets != null) ||
- (dstOffsets != null && offsets == null)) {
- Main.panic("Data not exist. (dstOffsets or offsets)");
- return 1;
- }
-
- /* Output Transition records */
- dos.writeByte(ZoneInfoFile.TAG_Transition);
- size = transitions.size();
- dos.writeShort((size * 8) & 0xFFFF);
- int dstoffset;
- for (int i = 0; i < size; i++) {
- /* if DST offset is 0, this means DST isn't used.
- * (NOT: offset's index is 0.)
- */
- if ((dstoffset = dstOffsets.get(i).intValue()) == -1) {
- dstoffset = 0;
- }
-
- dos.writeLong((transitions.get(i).longValue() << 12)
- | (dstoffset << 4)
- | offsets.get(i).intValue());
-
- }
-
- /* Output data for GMTOffset */
- List gmtoffset = tz.getGmtOffsets();
- dos.writeByte(ZoneInfoFile.TAG_Offset);
- size = gmtoffset.size();
- dos.writeShort((size * 4) & 0xFFFF);
- for (int i = 0; i < size; i++) {
- dos.writeInt(gmtoffset.get(i));
- }
- }
-
- /* Output data for SimpleTimeZone */
- List stz = tz.getLastRules();
- if (stz != null) {
- RuleRec[] rr = new RuleRec[2];
- boolean wall = true;
-
- rr[0] = stz.get(0);
- rr[1] = stz.get(1);
-
- dos.writeByte(ZoneInfoFile.TAG_SimpleTimeZone);
- wall = rr[0].getTime().isWall() && rr[1].getTime().isWall();
- if (wall) {
- dos.writeShort(32);
- } else {
- dos.writeShort(40);
- }
-
- for (int i = 0; i < 2; i++) {
- dos.writeInt(rr[i].getMonthNum() - 1); // 0-based month number
- dos.writeInt(rr[i].getDay().getDayForSimpleTimeZone());
- dos.writeInt(rr[i].getDay().getDayOfWeekForSimpleTimeZoneInt());
- dos.writeInt((int)rr[i].getTime().getTime());
- if (!wall) {
- dos.writeInt((rr[i].getTime().getType() & 0xFF) - 1);
- }
- }
- }
-
- /* Output RawOffset */
- dos.writeByte(ZoneInfoFile.TAG_RawOffset);
- dos.writeShort(4);
- dos.writeInt(tz.getRawOffset());
-
- /* Output willGMTOffsetChange flag */
- if (tz.willGMTOffsetChange()) {
- dos.writeByte(ZoneInfoFile.TAG_GMTOffsetWillChange);
- dos.writeShort(1);
- dos.writeByte(1);
- }
-
- /* Output LastDSTSaving */
- dos.writeByte(ZoneInfoFile.TAG_LastDSTSaving);
- dos.writeShort(2);
- dos.writeShort(tz.getLastDSTSaving()/1000);
-
- /* Output checksum */
- dos.writeByte(ZoneInfoFile.TAG_CRC32);
- dos.writeShort(4);
- dos.writeInt(tz.getCRC32());
-
- fos.close();
- dos.close();
- } catch(IOException e) {
- Main.panic("IO error: "+e.getMessage());
- return 1;
- }
-
- return 0;
- }
-
- /**
- * Generates ZoneInfoMappings in binary TLV format for each zone.
- * Regarding contents of output files, see {@link ZoneInfoFile}.
- *
- * @param Mappings
- * @return 0 if no errors, or 1 if error occurred.
- */
- int generateSrc(Mappings map) {
- try {
- int index;
- int block_size;
- int roi_size;
- long fp;
- String outputDir = Main.getOutputDir();
-
- /* If outputDir doesn't end with file-separator, adds it. */
- if (!outputDir.endsWith(File.separator)) {
- outputDir += File.separatorChar;
- }
-
- File outD = new File(outputDir);
- outD.mkdirs();
-
- /* Open ZoneInfoMapping file to write. */
- RandomAccessFile raf =
- new RandomAccessFile(outputDir + ZoneInfoFile.JAVAZM_FILE_NAME, "rw");
-
- /* Whether rawOffsetIndex list exists or not. */
- List roi = map.getRawOffsetsIndex();
- if (roi == null) {
- Main.panic("Data not exist. (rawOffsetsIndex)");
- return 1;
- }
- roi_size = roi.size();
-
- /* Whether rawOffsetIndexTable list exists or not. */
- List> roit = map.getRawOffsetsIndexTable();
- if (roit == null || roit.size() != roi_size) {
- Main.panic("Data not exist. (rawOffsetsIndexTable) Otherwise, Invalid size");
- return 1;
- }
-
- /* Output Label */
- raf.write(ZoneInfoFile.JAVAZM_LABEL, 0,
- ZoneInfoFile.JAVAZM_LABEL.length);
-
- /* Output Version */
- raf.writeByte(ZoneInfoFile.JAVAZM_VERSION);
-
- index = ZoneInfoFile.JAVAZM_LABEL.length + 2;
-
- /* Output Version of Olson's tzdata */
- byte[] b = Main.getVersionName().getBytes("UTF-8");
- raf.writeByte(ZoneInfoFile.TAG_TZDataVersion);
- raf.writeShort((b.length+1) & 0xFFFF);
- raf.write(b);
- raf.writeByte(0x00);
- index += b.length + 4;
-
- /* Output ID list. */
- raf.writeByte(ZoneInfoFile.TAG_ZoneIDs);
- block_size = 2;
- raf.writeShort(block_size & 0xFFFF);
- short nID = 0;
- raf.writeShort(nID & 0xFFFF);
- for (int i = 0; i < roi_size; i++) {
- for (String key : roit.get(i)) {
- byte size = (byte)key.getBytes("UTF-8").length;
- raf.writeByte(size & 0xFF);
- raf.write(key.getBytes("UTF-8"), 0, size);
- block_size += 1 + size;
- nID++;
- }
- }
- fp = raf.getFilePointer();
- raf.seek(index);
- raf.writeShort((block_size) & 0xFFFF);
- raf.writeShort(nID & 0xFFFF);
- raf.seek(fp);
-
- /* Output sorted rawOffset list. */
- raf.writeByte(ZoneInfoFile.TAG_RawOffsets);
- index += 3 + block_size;
- block_size = roi_size * 4;
- raf.writeShort(block_size & 0xFFFF);
- for (int i = 0; i < roi_size; i++) {
- raf.writeInt(Integer.parseInt(roi.get(i).toString()));
- }
-
- /* Output sorted rawOffsetIndex list. */
- raf.writeByte(ZoneInfoFile.TAG_RawOffsetIndices);
- index += 3 + block_size;
- block_size = 0;
- raf.writeShort(block_size & 0xFFFF);
- int num;
- for (int i = 0; i < roi_size; i++) {
- num = roit.get(i).size();
- block_size += num;
- for (int j = 0; j < num; j++) {
- raf.writeByte(i);
- }
- }
- fp = raf.getFilePointer();
- raf.seek(index);
- raf.writeShort((block_size) & 0xFFFF);
- raf.seek(fp);
-
- /* Whether alias list exists or not. */
- Map a = map.getAliases();
- if (a == null) {
- Main.panic("Data not exist. (aliases)");
- return 0;
- }
-
- /* Output ID list. */
- raf.writeByte(ZoneInfoFile.TAG_ZoneAliases);
- index += 3 + block_size;
- block_size = 2;
- raf.writeShort(block_size & 0xFFFF);
- raf.writeShort(a.size() & 0xFFFF);
- for (String key : a.keySet()) {
- String alias = a.get(key);
- byte key_size = (byte)key.length();
- byte alias_size = (byte)alias.length();
- raf.writeByte(key_size & 0xFF);
- raf.write(key.getBytes("UTF-8"), 0, key_size);
- raf.writeByte(alias_size & 0xFF);
- raf.write(alias.getBytes("UTF-8"), 0, alias_size);
- block_size += 2 + key_size + alias_size;
- }
- fp = raf.getFilePointer();
- raf.seek(index);
- raf.writeShort((block_size) & 0xFFFF);
- raf.seek(fp);
-
- /* Output the exclude list if it exists. */
- List excludedZones = map.getExcludeList();
- if (excludedZones != null) {
- raf.writeByte(ZoneInfoFile.TAG_ExcludedZones);
- index += 3 + block_size;
- block_size = 2;
- raf.writeShort(block_size & 0xFFFF); // place holder
- raf.writeShort(excludedZones.size()); // the number of excluded zones
- for (String name : excludedZones) {
- byte size = (byte) name.length();
- raf.writeByte(size); // byte length
- raf.write(name.getBytes("UTF-8"), 0, size); // zone name
- block_size += 1 + size;
- }
- fp = raf.getFilePointer();
- raf.seek(index);
- raf.writeShort(block_size & 0xFFFF);
- raf.seek(fp);
- }
-
- /* Close ZoneInfoMapping file. */
- raf.close();
- } catch(IOException e) {
- Main.panic("IO error: "+e.getMessage());
- return 1;
- }
-
- return 0;
- }
-}
diff --git a/make/tools/src/build/tools/javazic/GenDoc.java b/make/tools/src/build/tools/javazic/GenDoc.java
deleted file mode 100644
index c598b9b9dc5869e2bf7b35c0b180623a3f51d77f..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/GenDoc.java
+++ /dev/null
@@ -1,781 +0,0 @@
-/*
- * Copyright (c) 2001, 2011, 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.javazic;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import sun.util.calendar.ZoneInfoFile;
-
-/**
- * GenDoc is one of back-end classes of javazic, and generates
- * index.html and other html files which prints the detailed time zone
- * information for each zone.
- */
-class GenDoc extends BackEnd {
-
- private static final String docDir = "doc";
-
- private static final String header1 =
- "\n" +
- "\n\n\n\n" +
- "Java Platform, Standard Edition - TimeZone information based on ";
- private static final String header3 =
- "-->\n\n" +
- "Java Platform, Standard Edition TimeZone - ";
- private static final String header4 =
- "\n" +
- "\n\n";
-
- private static final String body1 =
- "\n";
- private static final String body2 =
- "\n";
-
- private static final String footer =
- "\n";
-
-
- // list of time zone name and zonefile name/real time zone name
- // e.g.
- // key (String) : value (String)
- // "America/Denver" : "America/Denver.html" (real time zone)
- // "America/Shiprock" : "America/Denver" (alias)
- TreeMap timezoneList = new TreeMap();
-
- // list of time zone's display name and time zone name
- // e.g.
- // key (String) : value (String)
- // "Tokyo, Asia" : "Asia/Tokyo"
- // "Marengo, Indiana, America" : "America/Indiana/Marengo"
- // (aliases included)
- TreeMap displayNameList = new TreeMap();
-
- // list of top level regions
- // e.g.
- // key (String) : value (String)
- // "America" : "America.html"
- // (including entries in America/Indiana/, America/Kentucky/, ...)
- TreeMap regionList = new TreeMap();
-
- // mapping list from zone name to latitude & longitude
- // This list is generated from zone.tab.
- // e.g.
- // key (String) : value (LatitudeAndLongitude object)
- // "Asia/Tokyo" : latitude=35.3916, longitude=13.9444
- // (aliases not included)
- HashMap mapList = null;
-
- // SortedMap of zone IDs sorted by their GMT offsets. If zone's GMT
- // offset will change in the future, its last known offset is
- // used.
- SortedMap> zonesByOffset = new TreeMap>();
-
- /**
- * Generates HTML document for each zone.
- * @param Timezone
- * @return 0 if no errors, or 1 if error occurred.
- */
- int processZoneinfo(Timezone tz) {
- try {
- int size;
- int index;
- String outputDir = Main.getOutputDir();
- String zonename = tz.getName();
- String zonefile = ZoneInfoFile.getFileName(zonename) + ".html";
- List stz = tz.getLastRules();
- timezoneList.put(zonename, zonefile);
- displayNameList.put(transform(zonename), zonename);
-
- // Populate zonesByOffset. (Zones that will change their
- // GMT offsets are also added to zonesByOffset here.)
- int lastKnownOffset = tz.getRawOffset();
- Set set = zonesByOffset.get(lastKnownOffset);
- if (set == null) {
- set = new TreeSet();
- zonesByOffset.put(lastKnownOffset, set);
- }
- set.add(zonename);
-
- /* If outputDir doesn't end with file-separator, adds it. */
- if (!outputDir.endsWith(File.separator)) {
- outputDir += File.separatorChar;
- }
- outputDir += docDir + File.separatorChar;
-
- index = zonename.indexOf('/');
- if (index != -1) {
- regionList.put(zonename.substring(0, index),
- zonename.substring(0, index) + ".html");
- }
-
- /* If zonefile includes file-separator, it's treated as part of
- * pathname. And make directory if necessary.
- */
- index = zonefile.lastIndexOf('/');
- if (index != -1) {
- zonefile.replace('/', File.separatorChar);
- outputDir += zonefile.substring(0, index+1);
- }
- File outD = new File(outputDir);
- outD.mkdirs();
-
- /* If mapfile is available, add a link to the appropriate map */
- if ((mapList == null) && (Main.getMapFile() != null)) {
- FileReader fr = new FileReader(Main.getMapFile());
- BufferedReader in = new BufferedReader(fr);
- mapList = new HashMap();
- String line;
- while ((line = in.readLine()) != null) {
- // skip blank and comment lines
- if (line.length() == 0 || line.charAt(0) == '#') {
- continue;
- }
- StringTokenizer tokens = new StringTokenizer(line);
- String token = tokens.nextToken(); /* We don't use the first token. */
- token = tokens.nextToken();
- LatitudeAndLongitude location = new LatitudeAndLongitude(token);
- token = tokens.nextToken();
- mapList.put(token, location);
- }
- in.close();
- }
-
- /* Open zoneinfo file to write. */
- FileWriter fw = new FileWriter(outputDir + zonefile.substring(index+1));
- BufferedWriter out = new BufferedWriter(fw);
-
- out.write(header1 + new Date() + header3 + zonename + header4);
- out.write(body1 + "" + zonename + "");
- LatitudeAndLongitude location = mapList.get(zonename);
- if (location != null) {
- int deg, min, sec;
-
- deg = location.getLatDeg();
- min = location.getLatMin();
- sec = location.getLatSec();
- if (deg < 0) {
- min = -min;
- sec = -sec;
- } else if (min < 0) {
- sec = -sec;
- }
- out.write(" " +
- "[map]");
- }
- out.write("\n
\n");
-
- List zone = tz.getZones();
- List rule = tz.getRules();
- if (rule != null && zone != null) {
- out.write("
\n");
- for (int i = 0; i < size; i++) {
- out.write("
\n");
- StringTokenizer st = new StringTokenizer(zone.get(i).getLine());
- String s = st.nextToken();
- if (s.equals("Zone")) { /* NAME */
- s = st.nextToken();
- s = st.nextToken();
- }
- out.write("
\n");
- }
- out.write(body2 + footer);
-
- out.close();
- fw.close();
- } catch(IOException e) {
- Main.panic("IO error: "+e.getMessage());
- return 1;
- }
-
- return 0;
- }
-
- /**
- * Generates index.html and other top-level frame files.
- * @param Mappings
- * @return 0 if no errors, or 1 if error occurred.
- */
- int generateSrc(Mappings map) {
- try {
- int len;
- Object o[];
- String outputDir = Main.getOutputDir();
- FileWriter fw1, fw2;
- BufferedWriter out1, out2;
-
- /* Whether alias list exists or not. */
- Map a = map.getAliases();
- if (a == null) {
- Main.panic("Data not exist. (aliases)");
- return 1;
- }
-
- timezoneList.putAll(a);
-
- /* If outputDir doesn't end with file-separator, adds it. */
- if (!outputDir.endsWith(File.separator)) {
- outputDir += File.separatorChar;
- }
- outputDir += docDir + File.separatorChar;
-
- File outD = new File(outputDir);
- outD.mkdirs();
-
- /* Creates index.html */
- fw1 = new FileWriter(outputDir + "index.html", false);
- out1 = new BufferedWriter(fw1);
-
- out1.write(header1 + new Date() + header2 + Main.getVersionName() +
- header4 +
- "\n" +
- "\n" +
- "
\nFrame Alert\n
\n\n" +
- "
\n\n" +
- "This document is designed to be viewed using the frames feature. If you see this\n" +
- "message, you are using a non-frame-capable web client.\n" +
- " \n" +
- "Link toNon-frame version.\n" +
- "
This is the list of time zones generated from " +
- Main.getVersionName() + " for Java Platform, " +
- "Standard Edition. The source code can be obtained " +
- "from ftp site " +
- "ftp://elsie.nci.nih.gov/pub/. A total of " +
- len +
- " time zones and aliases are supported " +
- "in this edition. For the " +
- "format of rules and zones, refer to the zic " +
- "(zoneinfo compiler) man page on " +
- "Solaris or Linux.
\n" +
- "
Note that the time zone data is not " +
- "a public interface of the Java Platform. No " +
- "applications should rely on the time zone data of " +
- "this document. Time zone names and data " +
- "may change without any prior notice.
\n" +
- body2 + footer);
-
- out1.close();
- fw1.close();
- } catch(IOException e) {
- Main.panic("IO error: "+e.getMessage());
- return 1;
- }
-
- return 0;
- }
-
- String transform(String s) {
- int index = s.lastIndexOf("/");
-
- /* If the string doesn't include any delimiter, return */
- if (index == -1) {
- return s;
- }
-
- int lastIndex = index;
- String str = s.substring(index+1);
- do {
- index = s.substring(0, lastIndex).lastIndexOf('/');
- str += ", " + s.substring(index+1, lastIndex);
- lastIndex = index;
- } while (index > -1);
-
- return str;
- }
-
- static class LatitudeAndLongitude {
-
- private int latDeg, latMin, latSec, longDeg, longMin, longSec;
-
- LatitudeAndLongitude(String s) {
- try {
- // First of all, check the string has the correct format:
- // either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS
-
- if (!s.startsWith("+") && !s.startsWith("-")) {
- Main.warning("Wrong latitude&longitude data: " + s);
- return;
- }
- int index;
- if (((index = s.lastIndexOf("+")) <= 0) &&
- ((index = s.lastIndexOf("-")) <= 0)) {
- Main.warning("Wrong latitude&longitude data: " + s);
- return;
- }
-
- if (index == 5) {
- latDeg = Integer.parseInt(s.substring(1, 3));
- latMin = Integer.parseInt(s.substring(3, 5));
- latSec = 0;
- } else if (index == 7) {
- latDeg = Integer.parseInt(s.substring(1, 3));
- latMin = Integer.parseInt(s.substring(3, 5));
- latSec = Integer.parseInt(s.substring(5, 7));
- } else {
- Main.warning("Wrong latitude&longitude data: " + s);
- return;
- }
- if (s.startsWith("-")){
- latDeg = -latDeg;
- latMin = -latMin;
- latSec = -latSec;
- }
-
- int len = s.length();
- if (index == 5 && len == 11) {
- longDeg = Integer.parseInt(s.substring(index+1, index+4));
- longMin = Integer.parseInt(s.substring(index+4, index+6));
- longSec = 0;
- } else if (index == 7 && len == 15) {
- longDeg = Integer.parseInt(s.substring(index+1, index+4));
- longMin = Integer.parseInt(s.substring(index+4, index+6));
- longSec = Integer.parseInt(s.substring(index+6, index+8));
- } else {
- Main.warning("Wrong latitude&longitude data: " + s);
- return;
- }
- if (s.charAt(index) == '-'){
- longDeg = -longDeg;
- longMin = -longMin;
- longSec = -longSec;
- }
- } catch(Exception e) {
- Main.warning("LatitudeAndLongitude() Parse error: " + s);
- }
- }
-
- int getLatDeg() {
- return latDeg;
- }
-
- int getLatMin() {
- return latMin;
- }
-
- int getLatSec() {
- return latSec;
- }
-
- int getLongDeg() {
- return longDeg;
- }
-
- int getLongMin() {
- return longMin;
- }
-
- int getLongSec() {
- return longSec;
- }
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Main.java b/make/tools/src/build/tools/javazic/Main.java
deleted file mode 100644
index a91ab91fff8794514edda999159c0bf82d106464..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Main.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (c) 2000, 2011, 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.javazic;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Main class for the javazic time zone data compiler.
- *
- * @since 1.4
- */
-public class Main {
-
- private static boolean verbose = false;
- static boolean outputDoc = false;
-
- private List ziFiles = new ArrayList();
- private static String zoneNamesFile = null;
- private static String versionName = "unknown";
- private static String outputDir = "zoneinfo";
- private static String mapFile = null;
-
- /**
- * Parses the specified arguments and sets up the variables.
- * @param argv the arguments
- */
- void processArgs(String[] argv) {
- for (int i = 0; i < argv.length; i++) {
- String arg = argv[i];
- if (arg.startsWith("-h")) {
- usage();
- System.exit(0);
- } else if (arg.equals("-d")) {
- outputDir = argv[++i];
- } else if (arg.equals("-v")) {
- verbose = true;
- } else if (arg.equals("-V")) {
- versionName = argv[++i];
- } else if (arg.equals("-doc")) {
- outputDoc = true;
- } else if (arg.equals("-map")) {
- outputDoc = true;
- mapFile = argv[++i];
- } else if (arg.equals("-f")) {
- zoneNamesFile = argv[++i];
- } else if (arg.equals("-S")) {
- try {
- Zoneinfo.setYear(Integer.parseInt(argv[++i]));
- } catch (Exception e) {
- error("invalid year: " + argv[i]);
- usage();
- System.exit(1);
- }
- } else {
- boolean isStartYear = arg.equals("-s");
- if (isStartYear || arg.equals("-e")) {
- try {
- int year = Integer.parseInt(argv[++i]);
- if (isStartYear) {
- Zoneinfo.setStartYear(year);
- } else {
- Zoneinfo.setEndYear(year);
- }
- } catch (Exception e) {
- error("invalid year: " + argv[i]);
- usage();
- System.exit(1);
- }
- } else {
- // the rest of args are zoneinfo source files
- while (i < argv.length) {
- ziFiles.add(argv[i++]);
- }
- }
- }
- }
- }
-
- /**
- * Parses zoneinfo source files
- */
- int compile() {
- int nFiles = ziFiles.size();
- int status = 0;
- Mappings maps = new Mappings();
- BackEnd backend = BackEnd.getBackEnd();
-
- for (int i = 0; i < nFiles; i++) {
- Zoneinfo frontend = Zoneinfo.parse(ziFiles.get(i));
-
- for (String key : frontend.getZones().keySet()) {
- info(key);
-
- Timezone tz = frontend.phase2(key);
- status |= backend.processZoneinfo(tz);
- }
-
- maps.add(frontend);
- }
-
- // special code for dealing with the conflicting name "MET"
- Zone.addMET();
-
- maps.resolve();
-
- status |= backend.generateSrc(maps);
-
- return status;
- }
-
- public static void main(String[] argv) {
- Main zic = new Main();
-
- /*
- * Parse args
- */
- zic.processArgs(argv);
-
- /*
- * Read target zone names
- */
- if (zoneNamesFile != null) {
- Zone.readZoneNames(zoneNamesFile);
- }
-
- int status = zic.compile();
-
- System.exit(status);
- }
-
- void usage() {
- System.err.println("Usage: javazic [options] file...\n"+
- " -f namefile file containing zone names\n"+
- " to be generated (ie, generating subset)\n"+
- " -d dir output directory\n"+
- " -v verbose\n"+
- " -V datavers specifies the tzdata version string\n"+
- " (eg, \"tzdata2000g\")"+
- " -S year output only SimleTimeZone data of that year\n"+
- " -s year start year (default: 1900)\n"+
- " -e year end year (default: 2037)\n"+
- " -doc generates HTML documents\n"+
- " -map mapfile generates HTML documents with map information\n"+
- " file... zoneinfo source file(s)");
- }
-
- /**
- * @return the output directory path name
- */
- static String getOutputDir() {
- return outputDir;
- }
-
- /**
- * @return the map file's path and name
- */
- static String getMapFile() {
- return mapFile;
- }
-
- /**
- * Returns the time zone data version string specified by the -V
- * option. If it is not specified, "unknown" is returned.
- * @return the time zone data version string
- */
- static String getVersionName() {
- return versionName;
- }
-
- /**
- * Prints out the specified fatal error message and calls {@link
- * java.lang.System#exit System.exit(1)}.
- * @param msg the fatal error message
- */
- static void panic(String msg) {
- printMessage("fatal error", msg);
- System.exit(1);
- }
-
- /**
- * Prints out the specified error message.
- * @param msg the error message
- */
- static void error(String msg) {
- printMessage("error", msg);
- }
-
- /**
- * Prints out the specified warning message.
- * @param msg the warning message
- */
- static void warning(String msg) {
- printMessage("warning", msg);
- }
-
- /**
- * Prints out the informative message.
- * @param msg the informative message
- */
- static void info(String msg) {
- if (verbose) {
- printMessage(null, msg);
- }
- }
-
- private static void printMessage(String type, String msg) {
- if (type != null) {
- type += ": ";
- } else {
- type = "";
- }
- System.err.println("javazic: " + type + msg);
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Mappings.java b/make/tools/src/build/tools/javazic/Mappings.java
deleted file mode 100644
index 885b9a091b6adff668f1d301000f0c70cb40140d..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Mappings.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package build.tools.javazic;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-/**
- * Mappings generates two Maps and a List which are used by
- * javazic BackEnd.
- *
- * @since 1.4
- */
-class Mappings {
- // All aliases specified by Link statements. It's alias name to
- // real name mappings.
- private Map aliases;
-
- private List rawOffsetsIndex;
-
- private List> rawOffsetsIndexTable;
-
- // Zone names to be excluded from rawOffset table. Those have GMT
- // offsets to change some future time.
- private List excludeList;
-
- /**
- * Constructor creates some necessary instances.
- */
- Mappings() {
- aliases = new TreeMap();
- rawOffsetsIndex = new LinkedList();
- rawOffsetsIndexTable = new LinkedList>();
- }
-
- /**
- * Generates aliases and rawOffsets tables.
- * @param zi a Zoneinfo containing Zones
- */
- void add(Zoneinfo zi) {
- Map zones = zi.getZones();
-
- for (String zoneName : zones.keySet()) {
- Zone zone = zones.get(zoneName);
- String zonename = zone.getName();
- int rawOffset = zone.get(zone.size()-1).getGmtOffset();
-
- // If the GMT offset of this Zone will change in some
- // future time, this Zone is added to the exclude list.
- boolean isExcluded = false;
- for (int i = 0; i < zone.size(); i++) {
- ZoneRec zrec = zone.get(i);
- if ((zrec.getGmtOffset() != rawOffset)
- && (zrec.getUntilTime(0) > Time.getCurrentTime())) {
- if (excludeList == null) {
- excludeList = new ArrayList();
- }
- excludeList.add(zone.getName());
- isExcluded = true;
- break;
- }
- }
-
- if (!rawOffsetsIndex.contains(new Integer(rawOffset))) {
- // Find the index to insert this raw offset zones
- int n = rawOffsetsIndex.size();
- int i;
- for (i = 0; i < n; i++) {
- if (rawOffsetsIndex.get(i) > rawOffset) {
- break;
- }
- }
- rawOffsetsIndex.add(i, rawOffset);
-
- Set perRawOffset = new TreeSet();
- if (!isExcluded) {
- perRawOffset.add(zonename);
- }
- rawOffsetsIndexTable.add(i, perRawOffset);
- } else if (!isExcluded) {
- int i = rawOffsetsIndex.indexOf(new Integer(rawOffset));
- Set perRawOffset = rawOffsetsIndexTable.get(i);
- perRawOffset.add(zonename);
- }
- }
-
- Map a = zi.getAliases();
- // If there are time zone names which refer to any of the
- // excluded zones, add those names to the excluded list.
- if (excludeList != null) {
- for (String zoneName : a.keySet()) {
- String realname = a.get(zoneName);
- if (excludeList.contains(realname)) {
- excludeList.add(zoneName);
- }
- }
- }
- aliases.putAll(a);
- }
-
- /**
- * Adds valid aliases to one of per-RawOffset table and removes
- * invalid aliases from aliases List. Aliases referring to
- * excluded zones are not added to a per-RawOffset table.
- */
- void resolve() {
- int index = rawOffsetsIndexTable.size();
- List toBeRemoved = new ArrayList();
- for (String key : aliases.keySet()) {
- boolean validname = false;
- for (int j = 0; j < index; j++) {
- Set perRO = rawOffsetsIndexTable.get(j);
- boolean isExcluded = (excludeList == null) ?
- false : excludeList.contains(key);
-
- if ((perRO.contains(aliases.get(key)) || isExcluded)
- && Zone.isTargetZone(key)) {
- validname = true;
- if (!isExcluded) {
- perRO.add(key);
- Main.info("Alias <"+key+"> added to the list.");
- }
- break;
- }
- }
-
- if (!validname) {
- Main.info("Alias <"+key+"> removed from the list.");
- toBeRemoved.add(key);
- }
- }
-
- // Remove zones, if any, from the list.
- for (String key : toBeRemoved) {
- aliases.remove(key);
- }
- // Eliminate any alias-to-alias mappings. For example, if
- // there are A->B and B->C, A->B is changed to A->C.
- Map newMap = new HashMap();
- for (String key : aliases.keySet()) {
- String realid = aliases.get(key);
- String leaf = realid;
- while (aliases.get(leaf) != null) {
- leaf = aliases.get(leaf);
- }
- if (!realid.equals(leaf)) {
- newMap.put(key, leaf);
- }
- }
- aliases.putAll(newMap);
- }
-
- Map getAliases() {
- return(aliases);
- }
-
- List getRawOffsetsIndex() {
- return(rawOffsetsIndex);
- }
-
- List> getRawOffsetsIndexTable() {
- return(rawOffsetsIndexTable);
- }
-
- List getExcludeList() {
- return excludeList;
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Month.java b/make/tools/src/build/tools/javazic/Month.java
deleted file mode 100644
index 9e70808809fe9ae40682b3a5c2ec744e8f019c31..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Month.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2000, 2004, 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.javazic;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Month enum handles month related manipulation.
- *
- * @since 1.4
- */
-enum Month {
- JANUARY("Jan"),
- FEBRUARY("Feb"),
- MARCH("Mar"),
- APRIL("Apr"),
- MAY("May"),
- JUNE("Jun"),
- JULY("Jul"),
- AUGUST("Aug"),
- SEPTEMBER("Sep"),
- OCTOBER("Oct"),
- NOVEMBER("Nov"),
- DECEMBER("Dec");
-
- private final String abbr;
-
- private static final Map abbreviations
- = new HashMap(12);
-
- static {
- for (Month m : Month.values()) {
- abbreviations.put(m.abbr, m);
- }
- }
-
- private Month(String abbr) {
- this.abbr = abbr;
- }
-
- int value() {
- return ordinal() + 1;
- }
-
- /**
- * Parses the specified string as a month abbreviation.
- * @param name the month abbreviation
- * @return the Month value
- */
- static Month parse(String name) {
- Month m = abbreviations.get(name);
- if (m != null) {
- return m;
- }
- return null;
- }
-
- /**
- * @param month the nunmth number (1-based)
- * @return the month name in uppercase of the specified month
- */
- static String toString(int month) {
- if (month >= JANUARY.value() && month <= DECEMBER.value()) {
- return "Calendar." + Month.values()[month - 1];
- }
- throw new IllegalArgumentException("wrong month number: " + month);
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Rule.java b/make/tools/src/build/tools/javazic/Rule.java
deleted file mode 100644
index c8e97fccae231af02ac866add772b0b02a3f3a9c..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Rule.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (c) 2000, 2004, 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.javazic;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * Rule manipulates Rule records.
- *
- * @since 1.4
- */
-class Rule {
-
- private List list;
- private String name;
-
- /**
- * Constructs a Rule which consists of a Rule record list. The
- * specified name is given to this Rule.
- * @param name the Rule name
- */
- Rule(String name) {
- this.name = name;
- list = new ArrayList();
- }
-
- /**
- * Added a RuleRec to the Rule record list.
- */
- void add(RuleRec rec) {
- list.add(rec);
- }
-
- /**
- * @return the Rule name
- */
- String getName() {
- return name;
- }
-
- /**
- * Gets all rule records that cover the given year.
- *
- * @param year the year number for which the rule is applicable.
- * @return rules in List that are collated in time. If no rule is found, an empty
- * List is returned.
- */
- List getRules(int year) {
- List rules = new ArrayList(3);
- for (RuleRec rec : list) {
- if (year >= rec.getFromYear() && year <= rec.getToYear()) {
- if ((rec.isOdd() && year % 2 == 0) || (rec.isEven() && year % 2 == 1))
- continue;
- rules.add(rec);
- }
- }
- int n = rules.size();
- if (n <= 1) {
- return rules;
- }
- if (n == 2) {
- RuleRec rec1 = rules.get(0);
- RuleRec rec2 = rules.get(1);
- if (rec1.getMonthNum() > rec2.getMonthNum()) {
- rules.set(0, rec2);
- rules.set(1, rec1);
- } else if (rec1.getMonthNum() == rec2.getMonthNum()) {
- // TODO: it's not accurate to ignore time types (STD, WALL, UTC)
- long t1 = Time.getLocalTime(year, rec1.getMonth(),
- rec1.getDay(), rec1.getTime().getTime());
- long t2 = Time.getLocalTime(year, rec2.getMonth(),
- rec2.getDay(), rec2.getTime().getTime());
- if (t1 > t2) {
- rules.set(0, rec2);
- rules.set(1, rec1);
- }
- }
- return rules;
- }
-
- final int y = year;
- RuleRec[] recs = new RuleRec[rules.size()];
- rules.toArray(recs);
- Arrays.sort(recs, new Comparator() {
- public int compare(RuleRec r1, RuleRec r2) {
- int n = r1.getMonthNum() - r2.getMonthNum();
- if (n != 0) {
- return n;
- }
- // TODO: it's not accurate to ignore time types (STD, WALL, UTC)
- long t1 = Time.getLocalTime(y, r1.getMonth(),
- r1.getDay(), r1.getTime().getTime());
- long t2 = Time.getLocalTime(y, r2.getMonth(),
- r2.getDay(), r2.getTime().getTime());
- return (int)(t1 - t2);
- }
- public boolean equals(Object o) {
- return this == o;
- }
- });
- rules.clear();
- for (int i = 0; i < n; i++) {
- rules.add(recs[i]);
- }
- return rules;
- }
-
- /**
- * Gets rule records that have either "max" or cover the endYear
- * value in its DST schedule.
- *
- * @return rules that contain last DST schedule. An empty
- * ArrayList is returned if no last rules are found.
- */
- List getLastRules() {
- RuleRec start = null;
- RuleRec end = null;
-
- for (int i = 0; i < list.size(); i++) {
- RuleRec rec = list.get(i);
- if (rec.isLastRule()) {
- if (rec.getSave() > 0) {
- start = rec;
- } else {
- end = rec;
- }
- }
- }
- if (start == null || end == null) {
- int endYear = Zoneinfo.getEndYear();
- for (int i = 0; i < list.size(); i++) {
- RuleRec rec = list.get(i);
- if (endYear >= rec.getFromYear() && endYear <= rec.getToYear()) {
- if (start == null && rec.getSave() > 0) {
- start = rec;
- } else {
- if (end == null && rec.getSave() == 0) {
- end = rec;
- }
- }
- }
- }
- }
-
- List r = new ArrayList(2);
- if (start == null || end == null) {
- if (start != null || end != null) {
- Main.warning("found last rules for "+name+" inconsistent.");
- }
- return r;
- }
-
- r.add(start);
- r.add(end);
- return r;
- }
-}
diff --git a/make/tools/src/build/tools/javazic/RuleDay.java b/make/tools/src/build/tools/javazic/RuleDay.java
deleted file mode 100644
index 5ce43f19fcea83d4fe77ee0b4fdf39aa3e51c592..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/RuleDay.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2000, 2010, 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.javazic;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * RuleDay class represents the value of the "ON" field. The day of
- * week values start from 1 following the {@link java.util.Calendar}
- * convention.
- *
- * @since 1.4
- */
-class RuleDay {
- private static final Map abbreviations = new HashMap(7);
- static {
- for (DayOfWeek day : DayOfWeek.values()) {
- abbreviations.put(day.getAbbr(), day);
- }
- }
-
- private String dayName = null;
- private DayOfWeek dow;
- private boolean lastOne = false;
- private int soonerOrLater = 0;
- private int thanDayOfMonth; // day of month (e.g., 8 for "Sun>=8")
-
- RuleDay() {
- }
-
- RuleDay(int day) {
- thanDayOfMonth = day;
- }
-
- int getDay() {
- return thanDayOfMonth;
- }
-
- /**
- * @return the day of week value (1-based)
- */
- int getDayOfWeekNum() {
- return dow.value();
- }
-
- /**
- * @return true if this rule day represents the last day of
- * week. (e.g., lastSun).
- */
- boolean isLast() {
- return lastOne;
- }
-
- /**
- * @return true if this rule day represents the day of week on or
- * later than (after) the {@link #getDay}. (e.g., Sun>=1)
- */
- boolean isLater() {
- return soonerOrLater > 0;
- }
-
- /**
- * @return true if this rule day represents the day of week on or
- * earlier than (before) the {@link #getDay}. (e.g., Sun<=15)
- */
- boolean isEarlier() {
- return soonerOrLater < 0;
- }
-
- /**
- * @return true if this rule day represents an exact day.
- */
- boolean isExact() {
- return soonerOrLater == 0;
- }
-
- /**
- * Parses the "ON" field and constructs a RuleDay.
- * @param day an "ON" field string (e.g., "Sun>=1")
- * @return a RuleDay representing the given "ON" field
- */
- static RuleDay parse(String day) {
- RuleDay d = new RuleDay();
- if (day.startsWith("last")) {
- d.lastOne = true;
- d.dayName = day.substring(4);
- d.dow = getDOW(d.dayName);
- } else {
- int index;
- if ((index = day.indexOf(">=")) != -1) {
- d.dayName = day.substring(0, index);
- d.dow = getDOW(d.dayName);
- d.soonerOrLater = 1; // greater or equal
- d.thanDayOfMonth = Integer.parseInt(day.substring(index+2));
- } else if ((index = day.indexOf("<=")) != -1) {
- d.dayName = day.substring(0, index);
- d.dow = getDOW(d.dayName);
- d.soonerOrLater = -1; // less or equal
- d.thanDayOfMonth = Integer.parseInt(day.substring(index+2));
- } else {
- // it should be an integer value.
- d.thanDayOfMonth = Integer.parseInt(day);
- }
- }
- return d;
- }
-
- /**
- * Converts this RuleDay to the SimpleTimeZone day rule.
- * @return the converted SimpleTimeZone day rule
- */
- int getDayForSimpleTimeZone() {
- if (isLast()) {
- return -1;
- }
- return isEarlier() ? -getDay() : getDay();
- }
-
- /**
- * Converts this RuleDay to the SimpleTimeZone day-of-week rule.
- * @return the SimpleTimeZone day-of-week rule value
- */
- int getDayOfWeekForSimpleTimeZoneInt() {
- if (isEarlier() || isLater()) {
- return -getDayOfWeekNum();
- }
- return isLast() ? getDayOfWeekNum() : 0;
- }
-
- /**
- * @return the string representation of the {@link
- * #getDayOfWeekForSimpleTimeZoneInt} value
- */
- String getDayOfWeekForSimpleTimeZone() {
- int d = getDayOfWeekForSimpleTimeZoneInt();
- if (d == 0) {
- return "0";
- }
- String sign = "";
- if (d < 0) {
- sign = "-";
- d = -d;
- }
- return sign + toString(d);
- }
-
- private static DayOfWeek getDOW(String abbr) {
- return abbreviations.get(abbr);
- }
-
- /**
- * Converts the specified day of week value to the day-of-week
- * name defined in {@link java.util.Calenda}.
- * @param dow 1-based day of week value
- * @return the Calendar day of week name with "Calendar." prefix.
- * @throws IllegalArgumentException if the specified dow value is out of range.
- */
- static String toString(int dow) {
- if (dow >= DayOfWeek.SUNDAY.value() && dow <= DayOfWeek.SATURDAY.value()) {
- return "Calendar." + DayOfWeek.values()[dow - 1];
- }
- throw new IllegalArgumentException("wrong Day_of_Week number: " + dow);
- }
-}
diff --git a/make/tools/src/build/tools/javazic/RuleRec.java b/make/tools/src/build/tools/javazic/RuleRec.java
deleted file mode 100644
index 377437257292df4003c24171a30eda8406803c48..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/RuleRec.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (c) 2000, 2004, 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.javazic;
-
-import java.util.StringTokenizer;
-
-/**
- * RuleRec class represents one record of the Rule set.
- *
- * @since 1.4
- */
-class RuleRec {
- private int fromYear;
- private int toYear;
- private String type;
- private Month inMonth;
- private RuleDay onDay;
- private Time atTime;
- private int save;
- private String letters;
- private String line;
- private boolean isLastRule;
-
- int getFromYear() {
- return fromYear;
- }
-
- int getToYear() {
- return toYear;
- }
-
- Month getMonth() {
- return inMonth;
- }
-
- int getMonthNum() {
- return inMonth.value();
- }
-
- RuleDay getDay() {
- return onDay;
- }
-
- Time getTime() {
- return atTime;
- }
-
- int getSave() {
- return save;
- }
-
- String getLine() {
- return line;
- }
-
- /**
- * Sets the line from the text file.
- * @param line the text of the line
- */
- void setLine(String line) {
- this.line = line;
- }
-
- /**
- * @return true if the rule type is "odd".
- */
- boolean isOdd() {
- return "odd".equals(type);
- }
-
- /**
- * @return true if the rule type is "even".
- */
- boolean isEven() {
- return "even".equals(type);
- }
-
- /**
- * Determines if this rule record is the last DST schedule rule.
- *
- * @return true if this rule record has "max" as TO (year).
- */
- boolean isLastRule() {
- return isLastRule;
- }
-
- /**
- * Determines if the unadjusted until time of the specified ZoneRec
- * is the same as the transition time of this rule in the same
- * year as the ZoneRec until year.
- *
- * @param zrec ZoneRec to compare to
- * @param save the amount of daylight saving in milliseconds
- * @param gmtOffset the GMT offset value in milliseconds
- * @return true if the unadjusted until time is the same as rule's
- * transition time.
- */
- boolean isSameTransition(ZoneRec zrec, int save, int gmtOffset) {
- long until, transition;
-
- if (zrec.getUntilTime().getType() != atTime.getType()) {
- until = zrec.getLocalUntilTime(save, gmtOffset);
- transition = Time.getLocalTime(zrec.getUntilYear(),
- getMonth(),
- getDay(),
- save,
- gmtOffset,
- atTime);
- } else {
- until = zrec.getLocalUntilTime();
- transition = Time.getLocalTime(zrec.getUntilYear(),
- getMonth(),
- getDay(),
- atTime.getTime());
- }
-
- return until == transition;
- }
-
- /**
- * Parses a Rule line and returns a RuleRec object.
- *
- * @param tokens a StringTokenizer object that should contain a
- * token for the "FROM" field and the rest.
- * @return a RuleRec object.
- */
- static RuleRec parse(StringTokenizer tokens) {
- RuleRec rec = new RuleRec();
- try {
- // FROM
- String token = tokens.nextToken();
- try {
- rec.fromYear = Integer.parseInt(token);
- } catch (NumberFormatException e) {
- // it's not integer
- if ("min".equals(token) || "minimum".equals(token)) {
- rec.fromYear = Zoneinfo.getMinYear();
- } else if ("max".equals(token) || "maximum".equals(token)) {
- rec.fromYear = Zoneinfo.getMaxYear();
- } else {
- Main.panic("invalid year value: "+token);
- }
- }
-
- // TO
- token = tokens.nextToken();
- rec.isLastRule = false;
- try {
- rec.toYear = Integer.parseInt(token);
- } catch (NumberFormatException e) {
- // it's not integer
- if ("min".equals(token) || "minimum".equals(token)) {
- rec.fromYear = Zoneinfo.getMinYear();
- } else if ("max".equals(token) || "maximum".equals(token)) {
- rec.toYear = Integer.MAX_VALUE;
- rec.isLastRule = true;
- } else if ("only".equals(token)) {
- rec.toYear = rec.fromYear;
- } else {
- Main.panic("invalid year value: "+token);
- }
- }
-
- // TYPE
- rec.type = tokens.nextToken();
-
- // IN
- rec.inMonth = Month.parse(tokens.nextToken());
-
- // ON
- rec.onDay = RuleDay.parse(tokens.nextToken());
-
- // AT
- rec.atTime = Time.parse(tokens.nextToken());
-
- // SAVE
- rec.save = (int) Time.parse(tokens.nextToken()).getTime();
-
- // LETTER/S
- rec.letters = tokens.nextToken();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return rec;
- }
-
- /**
- * Calculates the transition time of the given year under this rule.
- * @param year the year value
- * @param gmtOffset the GMT offset value in milliseconds
- * @param save the amount of daylight save time
- * @return the transition time in milliseconds of the given year in UTC.
- */
- long getTransitionTime(int year, int gmtOffset, int save) {
- long time = Time.getLocalTime(year, getMonth(),
- getDay(), atTime.getTime());
- if (atTime.isSTD()) {
- time -= gmtOffset;
- } else if (atTime.isWall()) {
- time -= gmtOffset + save;
- }
- return time;
- }
-
- private static int getInt(StringTokenizer tokens) {
- String token = tokens.nextToken();
- return Integer.parseInt(token);
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Simple.java b/make/tools/src/build/tools/javazic/Simple.java
deleted file mode 100644
index 69c7fe783f5ddbfb173e1ed404153e51ff3724a2..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Simple.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2000, 2011, 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.javazic;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-/**
- * Simple generates TimeZoneData, which had been used as internal
- * data of TimeZone before J2SDK1.3.
- * Since J2SDK1.4 doesn't need TimeZoneData, this class is for maintenance
- * of old JDK release.
- */
-class Simple extends BackEnd {
-
- /**
- * Zone records which are applied for given year.
- */
- private static Map lastZoneRecs = new HashMap<>();
-
- /**
- * Rule records which are applied for given year.
- */
- private static Map> lastRules = new TreeMap<>();
-
- /**
- * zone IDs sorted by their GMT offsets. If zone's GMT
- * offset will change in the future, its last known offset is
- * used.
- */
- private SortedMap> zonesByOffset = new TreeMap<>();
-
- /**
- * Sets last Rule records and Zone records for given timezone to
- * each Map.
- *
- * @param tz Timezone object for each zone
- * @return always 0
- */
- int processZoneinfo(Timezone tz) {
- String zonename = tz.getName();
-
- lastRules.put(zonename, tz.getLastRules());
- lastZoneRecs.put(zonename, tz.getLastZoneRec());
-
- // Populate zonesByOffset. (Zones that will change their
- // GMT offsets are also added to zonesByOffset here.)
- int lastKnownOffset = tz.getRawOffset();
- Set set = zonesByOffset.get(lastKnownOffset);
- if (set == null) {
- set = new TreeSet<>();
- zonesByOffset.put(lastKnownOffset, set);
- }
- set.add(zonename);
-
- return 0;
- }
-
- /**
- * Generates TimeZoneData to output SimpleTimeZone data.
- * @param map Mappings object which is generated by {@link Main#compile}.
- * @return 0 if no error occurred, otherwise 1.
- */
- int generateSrc(Mappings map) {
- try {
- File outD = new File(Main.getOutputDir());
- outD.mkdirs();
-
- FileWriter fw =
- new FileWriter(new File(outD, "TimeZoneData.java"), false);
- BufferedWriter out = new BufferedWriter(fw);
-
- out.write("import java.util.SimpleTimeZone;\n\n");
- out.write(" static SimpleTimeZone zones[] = {\n");
-
- Map a = map.getAliases();
- List roi = map.getRawOffsetsIndex();
- List> roit = map.getRawOffsetsIndexTable();
-
- int index = 0;
- for (int offset : zonesByOffset.keySet()) {
- int o = roi.get(index);
- Set set = zonesByOffset.get(offset);
- if (offset == o) {
- // Merge aliases into zonesByOffset
- set.addAll(roit.get(index));
- }
- index++;
-
- for (String key : set) {
- ZoneRec zrec;
- String realname;
- List stz;
- if ((realname = a.get(key)) != null) {
- // if this alias is not targeted, ignore it.
- if (!Zone.isTargetZone(key)) {
- continue;
- }
- stz = lastRules.get(realname);
- zrec = lastZoneRecs.get(realname);
- } else {
- stz = lastRules.get(key);
- zrec = lastZoneRecs.get(key);
- }
-
- out.write("\t//--------------------------------------------------------------------\n");
- String s = Time.toFormedString(offset);
- out.write("\tnew SimpleTimeZone(" +
- Time.toFormedString(offset) + ", \"" + key + "\"");
- if (realname != null) {
- out.write(" /* " + realname + " */");
- }
-
- if (stz == null) {
- out.write("),\n");
- } else {
- RuleRec rr0 = stz.get(0);
- RuleRec rr1 = stz.get(1);
-
- out.write(",\n\t " + Month.toString(rr0.getMonthNum()) +
- ", " + rr0.getDay().getDayForSimpleTimeZone() + ", " +
- rr0.getDay().getDayOfWeekForSimpleTimeZone() + ", " +
- Time.toFormedString((int)rr0.getTime().getTime()) + ", " +
- rr0.getTime().getTypeForSimpleTimeZone() + ",\n" +
-
- "\t " + Month.toString(rr1.getMonthNum()) + ", " +
- rr1.getDay().getDayForSimpleTimeZone() + ", " +
- rr1.getDay().getDayOfWeekForSimpleTimeZone() + ", " +
- Time.toFormedString((int)rr1.getTime().getTime())+ ", " +
- rr1.getTime().getTypeForSimpleTimeZone() + ",\n" +
-
- "\t " + Time.toFormedString(rr0.getSave()) + "),\n");
-
- out.write("\t// " + rr0.getLine() + "\n");
- out.write("\t// " + rr1.getLine() + "\n");
- }
-
- String zline = zrec.getLine();
- if (zline.indexOf("Zone") == -1) {
- zline = "Zone " + key + "\t" + zline.trim();
- }
- out.write("\t// " + zline + "\n");
- }
- }
- out.write(" };\n");
-
- out.close();
- fw.close();
- } catch(IOException e) {
- Main.panic("IO error: "+e.getMessage());
- return 1;
- }
-
- return 0;
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Time.java b/make/tools/src/build/tools/javazic/Time.java
deleted file mode 100644
index 66458a0020d00afa67eff0bbbc3babcde6bb059b..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Time.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (c) 2000, 2011, 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.javazic;
-
-import java.util.Locale;
-import sun.util.calendar.CalendarDate;
-import sun.util.calendar.CalendarSystem;
-import sun.util.calendar.Gregorian;
-
-/**
- * Time class represents the "AT" field and other time related information.
- *
- * @since 1.4
- */
-class Time {
-
- static final Gregorian gcal = CalendarSystem.getGregorianCalendar();
-
- // type is wall clock time
- private static final int WALL = 1;
-
- // type is standard time
- private static final int STD = 2;
-
- // type is UTC
- private static final int UTC = 3;
-
- // type of representing time
- private int type;
-
- /**
- * Time from the EPOCH in milliseconds
- */
- private long time;
-
- /**
- * Current time in milliseconds
- */
- private static final long currentTime = System.currentTimeMillis();
-
- Time() {
- time = 0L;
- }
-
- Time(long time) {
- this.time = time;
- }
-
- void setType(int type) {
- this.type = type;
- }
-
- long getTime() {
- return time;
- }
-
- int getType() {
- return type;
- }
-
- static long getCurrentTime() {
- return currentTime;
- }
-
- /**
- * @return true if the time is represented in wall-clock time.
- */
- boolean isWall() {
- return type == WALL;
- }
-
- /**
- * @return true if the time is represented in standard time.
- */
- boolean isSTD() {
- return type == STD;
- }
-
- /**
- * @return true if the time is represented in UTC time.
- */
- boolean isUTC() {
- return type == UTC;
- }
-
- /**
- * Converts the type to a string that represents the type in the
- * SimpleTimeZone time mode. (e.g., "SimpleTimeZone.WALL_TIME").
- * @return the converted string or null if the type is undefined.
- */
- String getTypeForSimpleTimeZone() {
- String stz = "SimpleTimeZone.";
- if (isWall()) {
- return stz+"WALL_TIME";
- }
- else if (isSTD()) {
- return stz+"STANDARD_TIME";
- }
- else if (isUTC()) {
- return stz+"UTC_TIME";
- }
- else {
- return null;
- }
- }
-
- /**
- * Converts the given Gregorian calendar field values to local time.
- * Local time is represented by the amount of milliseconds from
- * January 1, 1970 0:00 GMT.
- * @param year the year value
- * @param month the Month value
- * @param day the day represented by {@link RuleDay}
- * @param save the amount of daylight time in milliseconds
- * @param gmtOffset the GMT offset in milliseconds
- * @param time the time of the day represented by {@link Time}
- * @return local time
- */
- static long getLocalTime(int year, Month month, RuleDay day, int save,
- int gmtOffset, Time time) {
- long t = time.getTime();
-
- if (time.isSTD())
- t = time.getTime() + save;
- else if (time.isUTC())
- t = time.getTime() + save + gmtOffset;
-
- return getLocalTime(year, month, day, t);
- }
-
- /**
- * Converts the given Gregorian calendar field values to local time.
- * Local time is represented by the amount of milliseconds from
- * January 1, 1970 0:00 GMT.
- * @param year the year value
- * @param month the Month value
- * @param day the day value
- * @param time the time of the day in milliseconds
- * @return local time
- */
- static long getLocalTime(int year, Month month, int day, long time) {
- CalendarDate date = gcal.newCalendarDate(null);
- date.setDate(year, month.value(), day);
- long millis = gcal.getTime(date);
- return millis + time;
- }
-
- /**
- * Equivalent to getLocalTime(year, month, day, (long)time).
- * @param year the year value
- * @param month the Month value
- * @param day the day value
- * @param time the time of the day in milliseconds
- * @return local time
- */
- static long getLocalTime(int year, Month month, int day, int time) {
- return getLocalTime(year, month, day, (long)time);
- }
-
- /**
- * Equivalent to {@link #getLocalTime(int, Month, RuleDay, int)
- * getLocalTime(year, month, day, (int) time)}.
- * @param year the year value
- * @param month the Month value
- * @param day the day represented by {@link RuleDay}
- * @param time the time of the day represented by {@link Time}
- * @return local time
- */
- static long getLocalTime(int year, Month month, RuleDay day, long time) {
- return getLocalTime(year, month, day, (int) time);
- }
-
- /**
- * Converts the given Gregorian calendar field values to local time.
- * Local time is represented by the amount of milliseconds from
- * January 1, 1970 0:00 GMT.
- * @param year the year value
- * @param month the Month value
- * @param day the day represented by {@link RuleDay}
- * @param time the time of the day represented by {@link Time}
- * @return local time
- */
- static long getLocalTime(int year, Month month, RuleDay day, int time) {
- CalendarDate cdate = gcal.newCalendarDate(null);
- int monthValue = month.value();
-
- if (day.isLast()) { // e.g., "lastSun"
- cdate.setDate(year, monthValue, 1);
- cdate.setDayOfMonth(gcal.getMonthLength(cdate));
- cdate = gcal.getNthDayOfWeek(-1, day.getDayOfWeekNum(), cdate);
- } else if (day.isLater()) { // e.g., "Sun>=1"
- cdate.setDate(year, monthValue, day.getDay());
- cdate = gcal.getNthDayOfWeek(1, day.getDayOfWeekNum(), cdate);
- } else if (day.isExact()) {
- cdate.setDate(year, monthValue, day.getDay());
- } else if (day.isEarlier()) { // e.g., "Sun<=15"
- cdate.setDate(year, monthValue, day.getDay());
- cdate = gcal.getNthDayOfWeek(-1, day.getDayOfWeekNum(), cdate);
- } else {
- Main.panic("invalid day type: " + day);
- }
- return gcal.getTime(cdate) + time;
- }
-
- /**
- * Parses the given "AT" field and constructs a Time object.
- * @param the "AT" field string
- * @return the Time object
- */
- static Time parse(String time) {
- int sign;
- int index = 0;
- Time tm;
-
- if (time.charAt(0) == '-') {
- sign = -1;
- index++;
- } else {
- sign = 1;
- }
- int val = 0;
- int num = 0;
- int countDelim = 0;
- while (index < time.length()) {
- char c = time.charAt(index++);
- if (c == ':') {
- val = val * 60 + num;
- countDelim++;
- num = 0;
- continue;
- }
- int d = Character.digit(c, 10);
- if (d == -1) {
- --index;
- break;
- }
- num = num * 10 + d;
- }
- val = val * 60 + num;
- // convert val to second
- for (; countDelim < 2; countDelim++) {
- val *= 60;
- }
- tm = new Time((long)val * 1000 * sign);
- if (index < time.length()) {
- char c = time.charAt(index++);
- if (c == 's') {
- tm.setType(Time.STD);
- } else if (c == 'u' || c == 'g' || c == 'z') {
- tm.setType(Time.UTC);
- } else if (c == 'w') {
- tm.setType(Time.WALL);
- } else {
- Main.panic("unknown time mode: "+c);
- }
- } else {
- tm.setType(Time.WALL);
- }
- return tm;
- }
-
- /**
- * Converts the given milliseconds string to a "[+-]hh:mm" string.
- * @param ms the milliseconds string
- */
- static String toGMTFormat(String ms) {
- long sec = Long.parseLong(ms) / 1000;
- char sign;
- if (sec < 0) {
- sign = '-';
- sec = -sec;
- } else {
- sign = '+';
- }
- return String.format((Locale)null, "%c%02d:%02d",
- sign, sec/3600, (sec%3600)/60);
- }
-
- /**
- * Converts the given millisecond value to a string for a
- * SimpleTimeZone parameter.
- * @param ms the millisecond value
- * @return the string in a human readable form
- */
- static String toFormedString(int ms) {
- StringBuilder s = new StringBuilder();
- boolean minus = false;
-
- if (ms < 0) {
- s.append("-");
- minus = true;
- ms = -ms;
- } else if (ms == 0) {
- return "0";
- }
-
- int hour = ms / (60 * 60 * 1000);
- ms %= (60 * 60 * 1000);
- int minute = ms / (60 * 1000);
-
- if (hour != 0) {
- if (minus && minute != 0) {
- s.append("(");
- }
- s.append(Integer.toString(hour) + "*ONE_HOUR");
- }
-
- if (minute != 0) {
- if (hour != 0) {
- s.append("+");
- }
- s.append(Integer.toString(minute) + "*ONE_MINUTE");
- if (minus && hour != 0) {
- s.append(")");
- }
- }
-
- return s.toString();
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Timezone.java b/make/tools/src/build/tools/javazic/Timezone.java
deleted file mode 100644
index 941ea45456382427307479c3ca274b79bee7648c..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Timezone.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * Copyright (c) 2000, 2004, 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.javazic;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Timezone represents all information of a single point of time to
- * generate its time zone database.
- *
- * @since 1.4
- */
-class Timezone {
- /**
- * zone name of this time zone
- */
- private String name;
-
- /**
- * transition time values in UTC (millisecond)
- */
- private List transitions;
-
- /**
- * All offset values in millisecond
- * @see sun.util.calendar.ZoneInfo
- */
- private List offsets;
-
- /**
- * Indices of GMT offset values (both raw and raw+saving)
- * at transitions
- */
- private List gmtOffsets;
-
- /**
- * Indices of regular or "direct" saving time values
- * at transitions
- */
- private List dstOffsets;
-
- /**
- * Zone records of this time zone
- */
- private List usedZoneRecs;
-
- /**
- * Rule records referred to by this time zone
- */
- private List usedRuleRecs;
-
- /**
- * Type of DST rules in this time zone
- */
- private int dstType;
- static final int UNDEF_DST = 0; // DST type not set yet
- static final int NO_DST = 1; // never observed DST
- static final int LAST_DST = 2; // last rule ends in DST (all year round DST-only)
- static final int X_DST = 3; // used to observe DST
- static final int DST = 4; // observing DST regularly
-
- /**
- * Raw GMT offset of this time zone in the last rule
- */
- private int rawOffset;
-
- /**
- * The CRC32 value of the transitions data
- */
- private int crc32;
-
- /**
- * The last ZoneRec
- */
- private ZoneRec lastZoneRec;
-
- /**
- * The last DST rules. lastRules[0] is the DST start
- * rule. lastRules[1] is the DST end rules.
- */
- private List lastRules;
-
- /**
- * The amount of DST saving value (millisecond) in the last DST
- * rule.
- */
- private int lastSaving;
-
- /**
- * true if the raw offset will change in the future time.
- */
- private boolean willRawOffsetChange = false;
-
-
- /**
- * Constracts a Timezone object with the given zone name.
- * @param name the zone name
- */
- Timezone(String name) {
- this.name = name;
- }
-
- /**
- * @return the number of transitions
- */
- int getNTransitions() {
- if (transitions == null) {
- return 0;
- }
- return transitions.size();
- }
-
- /**
- * @return the zone name
- */
- String getName() {
- return name;
- }
-
- /**
- * Returns the list of all rule records that have been referred to
- * by this time zone.
- * @return the rule records list
- */
- List getRules() {
- return usedRuleRecs;
- }
-
- /**
- * Returns the list of all zone records that have been referred to
- * by this time zone.
- * @return the zone records list
- */
- List getZones() {
- return usedZoneRecs;
- }
-
- /**
- * @return the transition table (list)
- */
- List getTransitions() {
- return transitions;
- }
-
- /**
- * @return the offsets list
- */
- List getOffsets() {
- return offsets;
- }
-
- /**
- * @return the DST saving offsets list
- */
- List getDstOffsets() {
- return dstOffsets;
- }
-
- /**
- * @return the GMT offsets list
- */
- List getGmtOffsets() {
- return gmtOffsets;
- }
-
- /**
- * @return the checksum (crc32) value of the trasition table
- */
- int getCRC32() {
- return crc32;
- }
-
- /**
- * @return true if the GMT offset of this time zone would change
- * after the time zone database has been generated, false, otherwise.
- */
- boolean willGMTOffsetChange() {
- return willRawOffsetChange;
- }
-
- /**
- * @return the last known GMT offset value in milliseconds
- */
- int getRawOffset() {
- return rawOffset;
- }
-
- /**
- * Sets time zone's GMT offset to offset.
- * @param offset the GMT offset value in milliseconds
- */
- void setRawOffset(int offset) {
- rawOffset = offset;
- }
-
- /**
- * Sets time zone's GMT offset value to offset. If
- * startTime is future time, then the {@link
- * #willRawOffsetChange} value is set to true.
- * @param offset the GMT offset value in milliseconds
- * @param startTime the UTC time at which the GMT offset is in effective
- */
- void setRawOffset(int offset, long startTime) {
- // if this rawOffset is for the future time, let the run-time
- // look for the current GMT offset.
- if (startTime > Time.getCurrentTime()) {
- willRawOffsetChange = true;
- }
- setRawOffset(offset);
- }
-
- /**
- * Adds the specified transition information to the end of the transition table.
- * @param time the UTC time at which this transition happens
- * @param offset the total amount of the offset from GMT in milliseconds
- * @param dstOffset the amount of time in milliseconds saved at this transition
- */
- void addTransition(long time, int offset, int dstOffset) {
- if (transitions == null) {
- transitions = new ArrayList();
- offsets = new ArrayList();
- dstOffsets = new ArrayList();
- }
- transitions.add(time);
- offsets.add(offset);
- dstOffsets.add(dstOffset);
- }
-
- /**
- * Sets the type of historical daylight saving time
- * observation. For example, China used to observed daylight
- * saving time, but it no longer does. Then, X_DST is set to the
- * China time zone.
- * @param type the type of daylight saving time
- */
- void setDSTType(int type) {
- dstType = type;
- }
-
- /**
- * @return the type of historical daylight saving time
- * observation.
- */
- int getDSTType() {
- return dstType;
- }
-
- /**
- * Adds the specified zone record to the zone records list.
- * @param rec the zone record
- */
- void addUsedRec(ZoneRec rec) {
- if (usedZoneRecs == null) {
- usedZoneRecs = new ArrayList();
- }
- usedZoneRecs.add(rec);
- }
-
- /**
- * Adds the specified rule record to the rule records list.
- * @param rec the rule record
- */
- void addUsedRec(RuleRec rec) {
- if (usedRuleRecs == null) {
- usedRuleRecs = new ArrayList();
- }
- // if the last used rec is the same as the given rec, avoid
- // putting the same rule.
- int n = usedRuleRecs.size();
- for (int i = 0; i < n; i++) {
- if (usedRuleRecs.get(i).equals(rec)) {
- return;
- }
- }
- usedRuleRecs.add(rec);
- }
-
- /**
- * Sets the last zone record for this time zone.
- * @param the last zone record
- */
- void setLastZoneRec(ZoneRec zrec) {
- lastZoneRec = zrec;
- }
-
- /**
- * @return the last zone record for this time zone.
- */
- ZoneRec getLastZoneRec() {
- return lastZoneRec;
- }
-
- /**
- * Sets the last rule records for this time zone. Those are used
- * for generating SimpleTimeZone parameters.
- * @param rules the last rule records
- */
- void setLastRules(List rules) {
- int n = rules.size();
- if (n > 0) {
- lastRules = rules;
- RuleRec rec = rules.get(0);
- int offset = rec.getSave();
- if (offset > 0) {
- setLastDSTSaving(offset);
- } else {
- System.err.println("\t No DST starting rule in the last rules.");
- }
- }
- }
-
- /**
- * @return the last rule records for this time zone.
- */
- List getLastRules() {
- return lastRules;
- }
-
- /**
- * Sets the last daylight saving amount.
- * @param the daylight saving amount
- */
- void setLastDSTSaving(int offset) {
- lastSaving = offset;
- }
-
- /**
- * @return the last daylight saving amount.
- */
- int getLastDSTSaving() {
- return lastSaving;
- }
-
- /**
- * Calculates the CRC32 value from the transition table and sets
- * the value to crc32.
- */
- void checksum() {
- if (transitions == null) {
- crc32 = 0;
- return;
- }
- Checksum sum = new Checksum();
- for (int i = 0; i < transitions.size(); i++) {
- int offset = offsets.get(i);
- // adjust back to make the transition in local time
- sum.update(transitions.get(i) + offset);
- sum.update(offset);
- sum.update(dstOffsets.get(i));
- }
- crc32 = (int)sum.getValue();
- }
-
- /**
- * Removes unnecessary transitions for Java time zone support.
- */
- void optimize() {
- // if there is only one offset, delete all transitions. This
- // could happen if only time zone abbreviations changed.
- if (gmtOffsets.size() == 1) {
- transitions = null;
- usedRuleRecs = null;
- setDSTType(NO_DST);
- return;
- }
- for (int i = 0; i < (transitions.size() - 2); i++) { // don't remove the last one
- if (transitions.get(i) == transitions.get(i+1)) {
- transitions.remove(i);
- offsets.remove(i);
- dstOffsets.remove(i);
- i--;
- }
- }
-
- for (int i = 0; i < (transitions.size() - 2); i++) { // don't remove the last one
- if (offsets.get(i) == offsets.get(i+1)
- && dstOffsets.get(i) == dstOffsets.get(i+1)) {
- transitions.remove(i+1);
- offsets.remove(i+1);
- dstOffsets.remove(i+1);
- i--;
- }
- }
- }
-
- /**
- * Stores the specified offset value from GMT in the GMT offsets
- * table and returns its index. The offset value includes the base
- * GMT offset and any additional daylight saving if applicable. If
- * the same value as the specified offset is already in the table,
- * its index is returned.
- * @param offset the offset value in milliseconds
- * @return the index to the offset value in the GMT offsets table.
- */
- int getOffsetIndex(int offset) {
- return getOffsetIndex(offset, 0);
- }
-
- /**
- * Stores the specified daylight saving value in the GMT offsets
- * table and returns its index. If the same value as the specified
- * offset is already in the table, its index is returned. If 0 is
- * specified, it's not stored in the table and -1 is returned.
- * @param offset the offset value in milliseconds
- * @return the index to the specified offset value in the GMT
- * offsets table, or -1 if 0 is specified.
- */
- int getDstOffsetIndex(int offset) {
- if (offset == 0) {
- return -1;
- }
- return getOffsetIndex(offset, 1);
- }
-
- private int getOffsetIndex(int offset, int index) {
- if (gmtOffsets == null) {
- gmtOffsets = new ArrayList();
- }
- for (int i = index; i < gmtOffsets.size(); i++) {
- if (offset == gmtOffsets.get(i)) {
- return i;
- }
- }
- if (gmtOffsets.size() < index) {
- gmtOffsets.add(0);
- }
- gmtOffsets.add(offset);
- return gmtOffsets.size() - 1;
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Zone.java b/make/tools/src/build/tools/javazic/Zone.java
deleted file mode 100644
index 1f4e7029c15e2ca1c780e83c4a52f0eaaefe261b..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Zone.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2000, 2004, 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.javazic;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-/**
- * Zone holds information corresponding to a "Zone" part of a time
- * zone definition file.
- *
- * @since 1.4
- */
-class Zone {
- // zone name (e.g., "America/Los_Angeles")
- private String name;
-
- // zone records
- private List list;
-
- // target zone names for this compilation
- private static Set targetZones;
-
- /**
- * Constructs a Zone with the specified zone name.
- * @param name the zone name
- */
- Zone(String name) {
- this.name = name;
- list = new ArrayList();
- }
-
- /**
- * Reads time zone names to be generated, called "target zone
- * name", from the specified text file and creats an internal hash
- * table to keep those names. It's assumed that one text line
- * contains a zone name or comments if it starts with
- * '#'. Comments can't follow a zone name in a single line.
- * @param fileName the text file name
- */
- static void readZoneNames(String fileName) {
- if (fileName == null) {
- return;
- }
- BufferedReader in = null;
- try {
- FileReader fr = new FileReader(fileName);
- in = new BufferedReader(fr);
- } catch (FileNotFoundException e) {
- Main.panic("can't open file: " + fileName);
- }
- targetZones = new HashSet();
- String line;
-
- try {
- while ((line = in.readLine()) != null) {
- line = line.trim();
- if (line.length() == 0 || line.charAt(0) == '#') {
- continue;
- }
- if (!targetZones.add(line)) {
- Main.warning("duplicated target zone name: " + line);
- }
- }
- in.close();
- } catch (IOException e) {
- Main.panic("IO error: "+e.getMessage());
- }
- }
-
- /**
- * Determines whether the specified zone is one of the target zones.
- * If no target zones are specified, this method always returns
- * true for any zone name.
- * @param zoneName the zone name
- * @return true if the specified name is a target zone.
- */
- static boolean isTargetZone(String zoneName) {
- if (targetZones == null) {
- return true;
- }
- return targetZones.contains(zoneName);
- }
-
- /**
- * Forces to add "MET" to the target zone table. This is because
- * there is a conflict between Java zone name "WET" and Olson zone
- * name.
- */
- static void addMET() {
- if (targetZones != null) {
- targetZones.add("MET");
- }
- }
-
- /**
- * @return the zone name
- */
- String getName() {
- return name;
- }
-
- /**
- * Adds the specified zone record to the zone record list.
- */
- void add(ZoneRec rec) {
- list.add(rec);
- }
-
- /**
- * @param index the index at which the zone record in the list is returned.
- * @return the zone record specified by the index.
- */
- ZoneRec get(int index) {
- return list.get(index);
- }
-
- /**
- * @return the size of the zone record list
- */
- int size() {
- return list.size();
- }
-
- /**
- * Resolves the reference to a rule in each zone record.
- * @param zi the Zoneinfo object with which the rule reference is
- * resolved.
- */
- void resolve(Zoneinfo zi) {
- for (int i = 0; i < list.size(); i++) {
- ZoneRec rec = list.get(i);
- rec.resolve(zi);
- }
- }
-}
diff --git a/make/tools/src/build/tools/javazic/ZoneRec.java b/make/tools/src/build/tools/javazic/ZoneRec.java
deleted file mode 100644
index b175e0e93d4ed2e6252f401a3c7eb5c452bc9771..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/ZoneRec.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (c) 2000, 2004, 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.javazic;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-/**
- * ZoneRec hold information of time zone corresponding to each text
- * line of the "Zone" part.
- *
- * @since 1.4
- */
-class ZoneRec {
- private int gmtOffset;
- private String ruleName;
- private int directSave;
- private Rule ruleRef;
- private String format;
- private boolean hasUntil;
- private int untilYear;
- private Month untilMonth;
- private RuleDay untilDay;
- private Time untilTime;
- private long untilInMillis;
- private String line;
-
- /**
- * @return the "UNTIL" value in milliseconds
- */
- Time getUntilTime() {
- return untilTime;
- }
-
- /**
- * @return the GMT offset value in milliseconds
- */
- int getGmtOffset() {
- return gmtOffset;
- }
-
- /**
- * @return the rule name to which this zone record refers
- */
- String getRuleName() {
- return ruleName;
- }
-
- /**
- * @return the amount of saving time directly defined in the
- * "RULES/SAVE" field.
- */
- int getDirectSave() {
- return directSave;
- }
-
- /**
- * @return true if this zone record has a reference to a rule
- */
- boolean hasRuleReference() {
- return ruleRef != null;
- }
-
- /**
- * Returns the "FORMAT" field string of this zone record. This
- * @return the "FORMAT" field
- */
- String getFormat() {
- return format;
- }
-
- /**
- * @return the year in the "UNTIL" field
- */
- int getUntilYear() {
- return untilYear;
- }
-
- /**
- * Returns the "UNTIL" field value in milliseconds from Janurary
- * 1, 1970 0:00 GMT.
- * @param currentSave the amount of daylight saving in
- * milliseconds that is used to adjust wall-clock time.
- * @return the milliseconds value of the "UNTIL" field
- */
- long getUntilTime(int currentSave) {
- if (untilTime.isWall()) {
- return untilInMillis - currentSave;
- }
- return untilInMillis;
- }
-
- /**
- * Returns the "UNTIL" time in milliseconds without adjusting GMT
- * offsets or daylight saving.
- * @return local "UNTIL" time in milliseconds
- */
- long getLocalUntilTime() {
- return Time.getLocalTime(untilYear,
- untilMonth,
- untilDay,
- untilTime.getTime());
- }
-
- /**
- * Returns the "UNTIL" time in milliseconds with adjusting GMT offsets and daylight saving.
- * @return the "UNTIL" time after the adjustment
- */
- long getLocalUntilTime(int save, int gmtOffset) {
- return Time.getLocalTime(untilYear,
- untilMonth,
- untilDay,
- save,
- gmtOffset,
- untilTime);
- }
-
- /**
- * @return the text line of this zone record
- */
- String getLine() {
- return line;
- }
-
- /**
- * Sets the specified text line to this zone record
- */
- void setLine(String line) {
- this.line = line;
- }
-
- /**
- * @return true if this zone record has the "UNTIL" field
- */
- boolean hasUntil() {
- return this.hasUntil;
- }
-
- /**
- * Adjusts the "UNTIL" time to GMT offset if this zone record has
- * it. untilTime is not adjusted to daylight saving
- * in this method.
- */
- void adjustTime() {
- if (!hasUntil()) {
- return;
- }
- if (untilTime.isSTD() || untilTime.isWall()) {
- // adjust to gmt offset only here. adjust to real
- // wall-clock time when tracking rules
- untilInMillis -= gmtOffset;
- }
- }
-
- /**
- * @return the reference to the Rule object
- */
- Rule getRuleRef() {
- return ruleRef;
- }
-
- /**
- * Resolves the reference to a Rule and adjusts its "UNTIL" time
- * to GMT offset.
- */
- void resolve(Zoneinfo zi) {
- if (ruleName != null && (!"-".equals(ruleName))) {
- ruleRef = zi.getRule(ruleName);
- }
- adjustTime();
- }
-
- /**
- * Parses a Zone text line that is described by a StringTokenizer.
- * @param tokens represents tokens of a Zone text line
- * @return the zone record produced by parsing the text
- */
- static ZoneRec parse(StringTokenizer tokens) {
- ZoneRec rec = new ZoneRec();
- try {
- rec.gmtOffset = (int) Time.parse(tokens.nextToken()).getTime();
- String token = tokens.nextToken();
- char c = token.charAt(0);
- if (c >= '0' && c <= '9') {
- rec.directSave = (int) Time.parse(token).getTime();
- } else {
- rec.ruleName = token;
- }
- rec.format = tokens.nextToken();
- if (tokens.hasMoreTokens()) {
- rec.hasUntil = true;
- rec.untilYear = Integer.parseInt(tokens.nextToken());
- if (tokens.hasMoreTokens()) {
- rec.untilMonth = Month.parse(tokens.nextToken());
- } else {
- rec.untilMonth = Month.JANUARY;
- }
- if (tokens.hasMoreTokens()) {
- rec.untilDay = RuleDay.parse(tokens.nextToken());
- } else {
- rec.untilDay = new RuleDay(1);
- }
- if (tokens.hasMoreTokens()) {
- rec.untilTime = Time.parse(tokens.nextToken());
- } else {
- rec.untilTime = Time.parse("0:00");
- }
- rec.untilInMillis = rec.getLocalUntilTime();
- }
- } catch (Exception e) {
- // TODO: error reporting
- e.printStackTrace();
- }
- return rec;
- }
-
- private static void panic(String msg) {
- Main.panic(msg);
- }
-}
diff --git a/make/tools/src/build/tools/javazic/Zoneinfo.java b/make/tools/src/build/tools/javazic/Zoneinfo.java
deleted file mode 100644
index 129f87c57d29fdbf70fa2b8947c2bd8c02dfef7a..0000000000000000000000000000000000000000
--- a/make/tools/src/build/tools/javazic/Zoneinfo.java
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
- * Copyright (c) 2000, 2011, 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.javazic;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-/**
- * Zoneinfo provides javazic compiler front-end functionality.
- * @since 1.4
- */
-class Zoneinfo {
-
- private static final int minYear = 1900;
- private static final int maxYear = 2037;
- private static final long minTime = Time.getLocalTime(minYear, Month.JANUARY, 1, 0);
- private static int startYear = minYear;
- private static int endYear = maxYear;
-
- /**
- * True if javazic should generate a list of SimpleTimeZone
- * instances for the SimpleTimeZone-based time zone support.
- */
- static boolean isYearForTimeZoneDataSpecified = false;
-
- /**
- * Zone name to Zone mappings
- */
- private Map zones;
-
- /**
- * Rule name to Rule mappings
- */
- private Map rules;
-
- /**
- * Alias name to real name mappings
- */
- private Map aliases;
-
- /**
- * Constracts a Zoneinfo.
- */
- Zoneinfo() {
- zones = new HashMap();
- rules = new HashMap();
- aliases = new HashMap();
- }
-
- /**
- * Adds the given zone to the list of Zones.
- * @param zone Zone to be added to the list.
- */
- void add(Zone zone) {
- String name = zone.getName();
- zones.put(name, zone);
- }
-
- /**
- * Adds the given rule to the list of Rules.
- * @param rule Rule to be added to the list.
- */
- void add(Rule rule) {
- String name = rule.getName();
- rules.put(name, rule);
- }
-
- /**
- * Puts the specifid name pair to the alias table.
- * @param name1 an alias time zone name
- * @param name2 the real time zone of the alias name
- */
- void putAlias(String name1, String name2) {
- aliases.put(name1, name2);
- }
-
- /**
- * Sets the given year for SimpleTimeZone list output.
- * This method is called when the -S option is specified.
- * @param year the year for which SimpleTimeZone list should be generated
- */
- static void setYear(int year) {
- setStartYear(year);
- setEndYear(year);
- isYearForTimeZoneDataSpecified = true;
- }
-
- /**
- * Sets the start year.
- * @param year the start year value
- * @throws IllegalArgumentException if the specified year value is
- * smaller than the minimum year or greater than the end year.
- */
- static void setStartYear(int year) {
- if (year < minYear || year > endYear) {
- throw new IllegalArgumentException("invalid start year specified: " + year);
- }
- startYear = year;
- }
-
- /**
- * @return the start year value
- */
- static int getStartYear() {
- return startYear;
- }
-
- /**
- * Sets the end year.
- * @param year the end year value
- * @throws IllegalArgumentException if the specified year value is
- * smaller than the start year or greater than the maximum year.
- */
- static void setEndYear(int year) {
- if (year < startYear || year > maxYear) {
- throw new IllegalArgumentException();
- }
- endYear = year;
- }
-
- /**
- * @return the end year value
- */
- static int getEndYear() {
- return endYear;
- }
-
- /**
- * @return the minimum year value
- */
- static int getMinYear() {
- return minYear;
- }
-
- /**
- * @return the maximum year value
- */
- static int getMaxYear() {
- return maxYear;
- }
-
- /**
- * @return the alias table
- */
- Map getAliases() {
- return aliases;
- }
-
- /**
- * @return the Zone list
- */
- Map getZones() {
- return zones;
- }
-
- /**
- * @return a Zone specified by name.
- * @param name a zone name
- */
- Zone getZone(String name) {
- return zones.get(name);
- }
-
- /**
- * @return a Rule specified by name.
- * @param name a rule name
- */
- Rule getRule(String name) {
- return rules.get(name);
- }
-
- private static String line;
-
- private static int lineNum;
-
- /**
- * Parses the specified time zone data file and creates a Zoneinfo
- * that has all Rules, Zones and Links (aliases) information.
- * @param fname the time zone data file name
- * @return a Zoneinfo object
- */
- static Zoneinfo parse(String fname) {
- BufferedReader in = null;
- try {
- FileReader fr = new FileReader(fname);
- in = new BufferedReader(fr);
- } catch (FileNotFoundException e) {
- panic("can't open file: "+fname);
- }
- Zoneinfo zi = new Zoneinfo();
- boolean continued = false;
- Zone zone = null;
- String l;
- lineNum = 0;
-
- try {
- while ((line = in.readLine()) != null) {
- lineNum++;
- // skip blank and comment lines
- if (line.length() == 0 || line.charAt(0) == '#') {
- continue;
- }
-
- // trim trailing comments
- int rindex = line.lastIndexOf('#');
- if (rindex != -1) {
- // take the data part of the line
- l = line.substring(0, rindex);
- } else {
- l = line;
- }
-
- StringTokenizer tokens = new StringTokenizer(l);
- if (!tokens.hasMoreTokens()) {
- continue;
- }
- String token = tokens.nextToken();
-
- if (continued || "Zone".equals(token)) {
- if (zone == null) {
- if (!tokens.hasMoreTokens()) {
- panic("syntax error: zone no more token");
- }
- token = tokens.nextToken();
- // if the zone name is in "GMT+hh" or "GMT-hh"
- // format, ignore it due to spec conflict.
- if (token.startsWith("GMT+") || token.startsWith("GMT-")) {
- continue;
- }
- zone = new Zone(token);
- } else {
- // no way to push the current token back...
- tokens = new StringTokenizer(l);
- }
-
- ZoneRec zrec = ZoneRec.parse(tokens);
- zrec.setLine(line);
- zone.add(zrec);
- if ((continued = zrec.hasUntil()) == false) {
- if (Zone.isTargetZone(zone.getName())) {
- // zone.resolve(zi);
- zi.add(zone);
- }
- zone = null;
- }
- } else if ("Rule".equals(token)) {
- if (!tokens.hasMoreTokens()) {
- panic("syntax error: rule no more token");
- }
- token = tokens.nextToken();
- Rule rule = zi.getRule(token);
- if (rule == null) {
- rule = new Rule(token);
- zi.add(rule);
- }
- RuleRec rrec = RuleRec.parse(tokens);
- rrec.setLine(line);
- rule.add(rrec);
- } else if ("Link".equals(token)) {
- // Link
- try {
- String name1 = tokens.nextToken();
- String name2 = tokens.nextToken();
-
- // if the zone name is in "GMT+hh" or "GMT-hh"
- // format, ignore it due to spec conflict with
- // custom time zones. Also, ignore "ROC" for
- // PC-ness.
- if (name2.startsWith("GMT+") || name2.startsWith("GMT-")
- || "ROC".equals(name2)) {
- continue;
- }
- zi.putAlias(name2, name1);
- } catch (Exception e) {
- panic("syntax error: no more token for Link");
- }
- }
- }
- in.close();
- } catch (IOException ex) {
- panic("IO error: " + ex.getMessage());
- }
-
- return zi;
- }
-
- /**
- * Interprets a zone and constructs a Timezone object that
- * contains enough information on GMT offsets and DST schedules to
- * generate a zone info database.
- *
- * @param zoneName the zone name for which a Timezone object is
- * constructed.
- *
- * @return a Timezone object that contains all GMT offsets and DST
- * rules information.
- */
- Timezone phase2(String zoneName) {
- Timezone tz = new Timezone(zoneName);
- Zone zone = getZone(zoneName);
- zone.resolve(this);
-
- // TODO: merge phase2's for the regular and SimpleTimeZone ones.
- if (isYearForTimeZoneDataSpecified) {
- ZoneRec zrec = zone.get(zone.size()-1);
- tz.setLastZoneRec(zrec);
- tz.setRawOffset(zrec.getGmtOffset());
- if (zrec.hasRuleReference()) {
- /*
- * This part assumes that the specified year is covered by
- * the rules referred to by the last zone record.
- */
- List rrecs = zrec.getRuleRef().getRules(startYear);
-
- if (rrecs.size() == 2) {
- // make sure that one is a start rule and the other is
- // an end rule.
- RuleRec r0 = rrecs.get(0);
- RuleRec r1 = rrecs.get(1);
- if (r0.getSave() == 0 && r1.getSave() > 0) {
- rrecs.set(0, r1);
- rrecs.set(1, r0);
- } else if (!(r0.getSave() > 0 && r1.getSave() == 0)) {
- rrecs = null;
- Main.error(zoneName + ": rules for " + startYear + " not found.");
- }
- } else {
- rrecs = null;
- }
- if (rrecs != null) {
- tz.setLastRules(rrecs);
- }
- }
- return tz;
- }
-
- int gmtOffset;
- int year = minYear;
- int fromYear = year;
- long fromTime = Time.getLocalTime(startYear,
- Month.JANUARY,
- 1, 0);
-
- // take the index 0 for the GMT offset of the last zone record
- ZoneRec zrec = zone.get(zone.size()-1);
- tz.getOffsetIndex(zrec.getGmtOffset());
-
- int currentSave = 0;
- boolean usedZone;
- for (int zindex = 0; zindex < zone.size(); zindex++) {
- zrec = zone.get(zindex);
- usedZone = false;
- gmtOffset = zrec.getGmtOffset();
- int stdOffset = zrec.getDirectSave();
-
- // If this is the last zone record, take the last rule info.
- if (!zrec.hasUntil()) {
- tz.setRawOffset(gmtOffset, fromTime);
- if (zrec.hasRuleReference()) {
- tz.setLastRules(zrec.getRuleRef().getLastRules());
- } else if (stdOffset != 0) {
- // in case the last rule is all year round DST-only
- // (Asia/Amman once announced this rule.)
- tz.setLastDSTSaving(stdOffset);
- }
- }
- if (!zrec.hasRuleReference()) {
- if (!zrec.hasUntil() || zrec.getUntilTime(stdOffset) >= fromTime) {
- tz.addTransition(fromTime,
- tz.getOffsetIndex(gmtOffset+stdOffset),
- tz.getDstOffsetIndex(stdOffset));
- usedZone = true;
- }
- currentSave = stdOffset;
- // optimization in case the last rule is fixed.
- if (!zrec.hasUntil()) {
- if (tz.getNTransitions() > 0) {
- if (stdOffset == 0) {
- tz.setDSTType(Timezone.X_DST);
- } else {
- tz.setDSTType(Timezone.LAST_DST);
- }
- long time = Time.getLocalTime(maxYear,
- Month.JANUARY, 1, 0);
- time -= zrec.getGmtOffset();
- tz.addTransition(time,
- tz.getOffsetIndex(gmtOffset+stdOffset),
- tz.getDstOffsetIndex(stdOffset));
- tz.addUsedRec(zrec);
- } else {
- tz.setDSTType(Timezone.NO_DST);
- }
- break;
- }
- } else {
- Rule rule = zrec.getRuleRef();
- boolean fromTimeUsed = false;
- currentSave = 0;
- year_loop:
- for (year = getMinYear(); year <= endYear; year++) {
- if (zrec.hasUntil() && year > zrec.getUntilYear()) {
- break;
- }
- List rules = rule.getRules(year);
- if (rules.size() > 0) {
- for (int i = 0; i < rules.size(); i++) {
- RuleRec rrec = rules.get(i);
- long transition = rrec.getTransitionTime(year,
- gmtOffset,
- currentSave);
- if (zrec.hasUntil()) {
- if (transition >= zrec.getUntilTime(currentSave)) {
- break year_loop;
- }
- }
-
- if (fromTimeUsed == false) {
- if (fromTime <= transition) {
- fromTimeUsed = true;
-
- if (fromTime != minTime) {
- int prevsave;
-
- ZoneRec prevzrec = zone.get(zindex - 1);
-
- // See if until time in the previous
- // ZoneRec is the same thing as the
- // local time in the next rule.
- // (examples are Asia/Ashkhabad in 1991,
- // Europe/Riga in 1989)
-
- if (i > 0) {
- prevsave = rules.get(i-1).getSave();
- } else {
- List prevrules = rule.getRules(year-1);
-
- if (prevrules.size() > 0) {
- prevsave = prevrules.get(prevrules.size()-1).getSave();
- } else {
- prevsave = 0;
- }
- }
-
- if (rrec.isSameTransition(prevzrec, prevsave, gmtOffset)) {
- currentSave = rrec.getSave();
- tz.addTransition(fromTime,
- tz.getOffsetIndex(gmtOffset+currentSave),
- tz.getDstOffsetIndex(currentSave));
- tz.addUsedRec(rrec);
- usedZone = true;
- continue;
- }
- if (!prevzrec.hasRuleReference()
- || rule != prevzrec.getRuleRef()
- || (rule == prevzrec.getRuleRef()
- && gmtOffset != prevzrec.getGmtOffset())) {
- int save = (fromTime == transition) ? rrec.getSave() : currentSave;
- tz.addTransition(fromTime,
- tz.getOffsetIndex(gmtOffset+save),
- tz.getDstOffsetIndex(save));
- tz.addUsedRec(rrec);
- usedZone = true;
- }
- } else { // fromTime == minTime
- int save = rrec.getSave();
- tz.addTransition(minTime,
- tz.getOffsetIndex(gmtOffset),
- tz.getDstOffsetIndex(0));
-
- tz.addTransition(transition,
- tz.getOffsetIndex(gmtOffset+save),
- tz.getDstOffsetIndex(save));
-
- tz.addUsedRec(rrec);
- usedZone = true;
- }
- } else if (year == fromYear && i == rules.size()-1) {
- int save = rrec.getSave();
- tz.addTransition(fromTime,
- tz.getOffsetIndex(gmtOffset+save),
- tz.getDstOffsetIndex(save));
- }
- }
-
- currentSave = rrec.getSave();
- if (fromTime < transition) {
- tz.addTransition(transition,
- tz.getOffsetIndex(gmtOffset+currentSave),
- tz.getDstOffsetIndex(currentSave));
- tz.addUsedRec(rrec);
- usedZone = true;
- }
- }
- } else {
- if (year == fromYear) {
- tz.addTransition(fromTime,
- tz.getOffsetIndex(gmtOffset+currentSave),
- tz.getDstOffsetIndex(currentSave));
- fromTimeUsed = true;
- }
- if (year == endYear && !zrec.hasUntil()) {
- if (tz.getNTransitions() > 0) {
- // Assume that this Zone stopped DST
- tz.setDSTType(Timezone.X_DST);
- long time = Time.getLocalTime(maxYear, Month.JANUARY,
- 1, 0);
- time -= zrec.getGmtOffset();
- tz.addTransition(time,
- tz.getOffsetIndex(gmtOffset),
- tz.getDstOffsetIndex(0));
- usedZone = true;
- } else {
- tz.setDSTType(Timezone.NO_DST);
- }
- }
- }
- }
- }
- if (usedZone) {
- tz.addUsedRec(zrec);
- }
- if (zrec.hasUntil() && zrec.getUntilTime(currentSave) > fromTime) {
- fromTime = zrec.getUntilTime(currentSave);
- fromYear = zrec.getUntilYear();
- year = zrec.getUntilYear();
- }
- }
-
- if (tz.getDSTType() == Timezone.UNDEF_DST) {
- tz.setDSTType(Timezone.DST);
- }
- tz.optimize();
- tz.checksum();
- return tz;
- }
-
- private static void panic(String msg) {
- Main.panic(msg);
- }
-}
diff --git a/makefiles/CompileLaunchers.gmk b/makefiles/CompileLaunchers.gmk
index 170dc164ec4061cab7fc7071a9ff3be12faee3d6..501c986082e2c977a7690ad447d1ae2751860aa8 100644
--- a/makefiles/CompileLaunchers.gmk
+++ b/makefiles/CompileLaunchers.gmk
@@ -311,6 +311,9 @@ $(eval $(call SetupLauncher,jps,\
$(eval $(call SetupLauncher,jrunscript,\
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.script.shell.Main"$(COMMA) }'))
+$(eval $(call SetupLauncher,jjs,\
+ -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "jdk.nashorn.tools.Shell"$(COMMA) }'))
+
$(eval $(call SetupLauncher,jsadebugd,\
-DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "sun.jvm.hotspot.jdi.SADebugServer"$(COMMA) }' \
-DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }' \
diff --git a/makefiles/CreateJars.gmk b/makefiles/CreateJars.gmk
index 7e33790d299d184fccd830744c9a3f0cda9c694e..82b85dc97f3ee467a3043d626e132ccd3e88dc64 100644
--- a/makefiles/CreateJars.gmk
+++ b/makefiles/CreateJars.gmk
@@ -213,28 +213,28 @@ RT_JAR_EXCLUDES += \
org/relaxng/datatype \
sun/awt/HKSCS.class \
sun/awt/motif/X11GB2312.class \
- sun/awt/motif/X11GB2312\$$$$Decoder.class \
- sun/awt/motif/X11GB2312\$$$$Encoder.class \
+ sun/awt/motif/X11GB2312\$$Decoder.class \
+ sun/awt/motif/X11GB2312\$$Encoder.class \
sun/awt/motif/X11GBK.class \
- sun/awt/motif/X11GBK\$$$$Encoder.class \
+ sun/awt/motif/X11GBK\$$Encoder.class \
sun/awt/motif/X11KSC5601.class \
- sun/awt/motif/X11KSC5601\$$$$Decoder.class \
- sun/awt/motif/X11KSC5601\$$$$Encoder.class \
+ sun/awt/motif/X11KSC5601\$$Decoder.class \
+ sun/awt/motif/X11KSC5601\$$Encoder.class \
sun/jvmstat \
sun/net/spi/nameservice/dns \
sun/nio/cs/ext \
sun/rmi/rmic \
sun/security/ec/ECDHKeyAgreement.class \
sun/security/ec/ECDSASignature.class \
- sun/security/ec/ECDSASignature\$$$$Raw.class \
- sun/security/ec/ECDSASignature\$$$$SHA1.class \
- sun/security/ec/ECDSASignature\$$$$SHA224.class \
- sun/security/ec/ECDSASignature\$$$$SHA256.class \
- sun/security/ec/ECDSASignature\$$$$SHA384.class \
- sun/security/ec/ECDSASignature\$$$$SHA512.class \
+ sun/security/ec/ECDSASignature\$$Raw.class \
+ sun/security/ec/ECDSASignature\$$SHA1.class \
+ sun/security/ec/ECDSASignature\$$SHA224.class \
+ sun/security/ec/ECDSASignature\$$SHA256.class \
+ sun/security/ec/ECDSASignature\$$SHA384.class \
+ sun/security/ec/ECDSASignature\$$SHA512.class \
sun/security/ec/ECKeyFactory.class \
sun/security/ec/ECKeyPairGenerator.class \
- sun/security/ec/SunEC\$$$$1.class \
+ sun/security/ec/SunEC\$$1.class \
sun/security/ec/SunEC.class \
sun/security/ec/SunECEntries.class \
sun/security/internal \
@@ -1119,6 +1119,14 @@ endif
##########################################################################################
+# Import nashorn.jar from nashorn dist dir.
+$(IMAGES_OUTPUTDIR)/lib/ext/nashorn.jar: $(NASHORN_DIST)/nashorn.jar
+ $(install-file)
+
+JARS += $(IMAGES_OUTPUTDIR)/lib/ext/nashorn.jar
+
+##########################################################################################
+
-include $(CUSTOM_MAKE_DIR)/CreateJars.gmk
##########################################################################################
diff --git a/makefiles/Images.gmk b/makefiles/Images.gmk
index bb737f88878e31b86e134696e2733a16bb6f9df9..2d25473bce4d07616585418b696cb4a15f2ba292 100644
--- a/makefiles/Images.gmk
+++ b/makefiles/Images.gmk
@@ -602,6 +602,7 @@ define create-info-file
$(call info-file-item, "OS_NAME", "$(REQUIRED_OS_NAME)")
$(call info-file-item, "OS_VERSION", "$(REQUIRED_OS_VERSION)")
$(call info-file-item, "OS_ARCH", "$(OPENJDK_TARGET_CPU_LEGACY)")
+ if [ -n "$(JDK_ARCH_ABI_PROP_NAME)" ]; then $(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)"); fi
$(call info-file-item, "SOURCE", "$(ALL_SOURCE_TIPS)")
endef
diff --git a/makefiles/profile-rtjar-includes.txt b/makefiles/profile-rtjar-includes.txt
index 4722727ea311a2df122a5b65b4363e0689855664..4cc528e67d5be6a101330ba7486d163da61f4d3d 100644
--- a/makefiles/profile-rtjar-includes.txt
+++ b/makefiles/profile-rtjar-includes.txt
@@ -349,6 +349,7 @@ PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
com/sun/rowset/providers \
com/sun/script/javascript \
com/sun/script/util \
+ com/sun/security/auth \
com/sun/security/auth/callback \
com/sun/security/auth/login \
com/sun/security/auth/module \
@@ -448,8 +449,7 @@ PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
sun/tracing \
sun/tracing/dtrace
-PROFILE_3_RTJAR_INCLUDE_TYPES := \
- com/sun/security/auth/*.class
+PROFILE_3_RTJAR_INCLUDE_TYPES :=
PROFILE_3_RTJAR_EXCLUDE_TYPES := \
javax/management/remote/rmi/_RMIConnectionImpl_Tie.class \
@@ -457,10 +457,10 @@ PROFILE_3_RTJAR_EXCLUDE_TYPES := \
javax/management/remote/rmi/_RMIServerImpl_Tie.class \
javax/management/remote/rmi/_RMIServer_Stub.class \
com/sun/security/auth/callback/DialogCallbackHandler.class \
- com/sun/security/auth/callback/DialogCallbackHandler\$$$$1.class \
- com/sun/security/auth/callback/DialogCallbackHandler\$$$$2.class \
- com/sun/security/auth/callback/DialogCallbackHandler\$$$$Action.class \
- com/sun/security/auth/callback/DialogCallbackHandler\$$$$ConfirmationInfo.class
+ com/sun/security/auth/callback/DialogCallbackHandler\$$1.class \
+ com/sun/security/auth/callback/DialogCallbackHandler\$$2.class \
+ com/sun/security/auth/callback/DialogCallbackHandler\$$Action.class \
+ com/sun/security/auth/callback/DialogCallbackHandler\$$ConfirmationInfo.class
PROFILE_3_INCLUDE_METAINF_SERVICES := \
META-INF/services/javax.script.ScriptEngineFactory
diff --git a/src/share/back/transport.c b/src/share/back/transport.c
index 40608b3123954e9ef3836469bff6083776a2e13e..1d7335d660b9f86d43a6b5d8a58ac59366007805 100644
--- a/src/share/back/transport.c
+++ b/src/share/back/transport.c
@@ -117,6 +117,9 @@ loadTransportLibrary(char *libdir, char *name)
/* Construct library name (simple name or full path) */
dbgsysBuildLibName(libname, sizeof(libname), plibdir, name);
+ if (strlen(libname) == 0) {
+ return NULL;
+ }
/* dlopen (unix) / LoadLibrary (windows) the transport library */
handle = dbgsysLoadLibrary(libname, buf, sizeof(buf));
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Attribute.java b/src/share/classes/com/sun/java/util/jar/pack/Attribute.java
index f6ff030263ebde14079cdead6023e91d588920e3..a6033c97b142655a4df82906bdd2d462e8e48e61 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Attribute.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Attribute.java
@@ -177,7 +177,7 @@ class Attribute implements Comparable {
define(sd, ATTR_CONTEXT_METHOD, "Synthetic", "");
define(sd, ATTR_CONTEXT_METHOD, "Deprecated", "");
define(sd, ATTR_CONTEXT_METHOD, "Exceptions", "NH[RCH]");
- define(sd, ATTR_CONTEXT_METHOD, "MethodParameters", "NB[RUNHI]");
+ define(sd, ATTR_CONTEXT_METHOD, "MethodParameters", "NB[RUNHFH]");
//define(sd, ATTR_CONTEXT_METHOD, "Code", "HHNI[B]NH[PHPOHPOHRCNH]NH[RUHNI[B]]");
define(sd, ATTR_CONTEXT_CODE, "StackMapTable",
diff --git a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
index fdfb87dc136914ed7664c2b255c6881945825776..1a1ecef9055b244922626c1ba26de1d05febe5e3 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
@@ -1505,7 +1505,7 @@ class BandStructure {
// band for predefine method parameters
IntBand method_MethodParameters_NB = method_attr_bands.newIntBand("method_MethodParameters_NB", BYTE1);
CPRefBand method_MethodParameters_name_RUN = method_attr_bands.newCPRefBand("method_MethodParameters_name_RUN", UNSIGNED5, CONSTANT_Utf8, NULL_IS_OK);
- IntBand method_MethodParameters_flag_I = method_attr_bands.newIntBand("method_MethodParameters_flag_I");
+ IntBand method_MethodParameters_flag_FH = method_attr_bands.newIntBand("method_MethodParameters_flag_FH");
MultiBand class_attr_bands = class_bands.newMultiBand("(class_attr_bands)", UNSIGNED5);
IntBand class_flags_hi = class_attr_bands.newIntBand("class_flags_hi");
@@ -1776,9 +1776,9 @@ class BandStructure {
new Band[]{
method_MethodParameters_NB,
method_MethodParameters_name_RUN,
- method_MethodParameters_flag_I
+ method_MethodParameters_flag_FH
},
- "MethodParameters", "NB[RUNHI]");
+ "MethodParameters", "NB[RUNHFH]");
assert(attrCodeEmpty == Package.attrCodeEmpty);
predefineAttribute(X_ATTR_Signature, ATTR_CONTEXT_METHOD,
new Band[] { method_Signature_RS },
diff --git a/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java b/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
index 3df8706da37d4925734c4bc18ea21b41db0c5052..3da159f6e29033716cd7a5a48ecbfcb2a64b818c 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
@@ -564,7 +564,7 @@ class ClassReader {
code.bytes = new byte[readInt()];
in.readFully(code.bytes);
Entry[] cpMap = cls.getCPMap();
- Instruction.opcodeChecker(code.bytes, cpMap);
+ Instruction.opcodeChecker(code.bytes, cpMap, this.cls.version);
int nh = readUnsignedShort();
code.setHandlerCount(nh);
for (int i = 0; i < nh; i++) {
diff --git a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java
index ad2175f9993708df08acf34b85bfeb10da08191e..c23dcb9d4a7db75f410ce5c0d05e5f8341226d9d 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java
@@ -207,6 +207,10 @@ class ConstantPool {
return tag;
}
+ public final boolean tagEquals(int tag) {
+ return getTag() == tag;
+ }
+
public Entry getRef(int i) {
return null;
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Constants.java b/src/share/classes/com/sun/java/util/jar/pack/Constants.java
index 158826243811918e489f3ca2062399e053f581f6..5059bc07967273f811e893c750df10d8d39a4736 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Constants.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Constants.java
@@ -479,4 +479,10 @@ class Constants {
public final static int _qldc = _xldc_op+7;
public final static int _qldc_w = _xldc_op+8;
public final static int _xldc_limit = _xldc_op+9;
+
+ // handling of InterfaceMethodRef
+ public final static int _invoke_int_op = _xldc_limit;
+ public final static int _invokespecial_int = _invoke_int_op+0;
+ public final static int _invokestatic_int = _invoke_int_op+1;
+ public final static int _invoke_int_limit = _invoke_int_op+2;
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Instruction.java b/src/share/classes/com/sun/java/util/jar/pack/Instruction.java
index 31ee22b059d50df5ed1cbd840de04672093b96c5..93175fe8ecf76a37e465561cc7a8e5153466b2ca 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Instruction.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Instruction.java
@@ -446,12 +446,14 @@ class Instruction {
public static boolean isCPRefOp(int bc) {
if (bc < BC_INDEX[0].length && BC_INDEX[0][bc] > 0) return true;
if (bc >= _xldc_op && bc < _xldc_limit) return true;
+ if (bc == _invokespecial_int || bc == _invokestatic_int) return true;
return false;
}
public static byte getCPRefOpTag(int bc) {
if (bc < BC_INDEX[0].length && BC_INDEX[0][bc] > 0) return BC_TAG[0][bc];
if (bc >= _xldc_op && bc < _xldc_limit) return CONSTANT_LoadableValue;
+ if (bc == _invokestatic_int || bc == _invokespecial_int) return CONSTANT_InterfaceMethodref;
return CONSTANT_None;
}
@@ -647,7 +649,8 @@ class Instruction {
}
}
- public static void opcodeChecker(byte[] code, ConstantPool.Entry[] cpMap) throws FormatException {
+ public static void opcodeChecker(byte[] code, ConstantPool.Entry[] cpMap,
+ Package.Version clsVersion) throws FormatException {
Instruction i = at(code, 0);
while (i != null) {
int opcode = i.getBC();
@@ -658,10 +661,17 @@ class Instruction {
ConstantPool.Entry e = i.getCPRef(cpMap);
if (e != null) {
byte tag = i.getCPTag();
- if (!e.tagMatches(tag)) {
- String message = "illegal reference, expected type=" +
- ConstantPool.tagName(tag) + ": " +
- i.toString(cpMap);
+ boolean match = e.tagMatches(tag);
+ if (!match &&
+ (i.bc == _invokespecial || i.bc == _invokestatic) &&
+ e.tagMatches(CONSTANT_InterfaceMethodref) &&
+ clsVersion.greaterThan(Constants.JAVA7_MAX_CLASS_VERSION)) {
+ match = true;
+ }
+ if (!match) {
+ String message = "illegal reference, expected type="
+ + ConstantPool.tagName(tag) + ": "
+ + i.toString(cpMap);
throw new FormatException(message);
}
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
index 319b87933477bcced996f1408b5f050d70a298aa..b42dda30eb45983a570b894a3de3dd9cddefd818 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
@@ -1521,7 +1521,7 @@ class PackageReader extends BandStructure {
// *method_Exceptions_RC :UNSIGNED5 (cp_Class)
// *method_MethodParameters_NB: BYTE1
// *method_MethodParameters_RUN: UNSIGNED5 (cp_Utf8)
- // *method_MethodParameters_I: UNSIGNED5 (flag)
+ // *method_MethodParameters_FH: UNSIGNED5 (flag)
//
// code_attr_bands:
// *code_flags :UNSIGNED5
@@ -2256,6 +2256,12 @@ class PackageReader extends BandStructure {
int origBC = bc;
int size = 2;
switch (bc) {
+ case _invokestatic_int:
+ origBC = _invokestatic;
+ break;
+ case _invokespecial_int:
+ origBC = _invokespecial;
+ break;
case _ildc:
case _cldc:
case _fldc:
diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
index 47959294fd2be727d95bd5d3e5ed85392fad0e38..a78c9ae9969aa806c804f0de90cd04a15e910444 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
@@ -1409,6 +1409,10 @@ class PackageWriter extends BandStructure {
int bc = i.getBC();
if (!(bc >= _first_linker_op && bc <= _last_linker_op)) return -1;
MemberEntry ref = (MemberEntry) i.getCPRef(curCPMap);
+ // do not optimize this case, simply fall back to regular coding
+ if ((bc == _invokespecial || bc == _invokestatic) &&
+ ref.tagEquals(CONSTANT_InterfaceMethodref))
+ return -1;
ClassEntry refClass = ref.classRef;
int self_bc = _self_linker_op + (bc - _first_linker_op);
if (refClass == curClass.thisClass)
@@ -1609,7 +1613,16 @@ class PackageWriter extends BandStructure {
case CONSTANT_Fieldref:
bc_which = bc_fieldref; break;
case CONSTANT_Methodref:
- bc_which = bc_methodref; break;
+ if (ref.tagEquals(CONSTANT_InterfaceMethodref)) {
+ if (bc == _invokespecial)
+ vbc = _invokespecial_int;
+ if (bc == _invokestatic)
+ vbc = _invokestatic_int;
+ bc_which = bc_imethodref;
+ } else {
+ bc_which = bc_methodref;
+ }
+ break;
case CONSTANT_InterfaceMethodref:
bc_which = bc_imethodref; break;
case CONSTANT_InvokeDynamic:
diff --git a/src/share/classes/java/lang/Class.java b/src/share/classes/java/lang/Class.java
index 671d04a65c7278e45556a53009e60f63df7ad792..441f25a8a2c14e7ac10eba4490a37d4221dfeb92 100644
--- a/src/share/classes/java/lang/Class.java
+++ b/src/share/classes/java/lang/Class.java
@@ -25,6 +25,7 @@
package java.lang;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Member;
@@ -3083,6 +3084,16 @@ public final
return (A) annotations.get(annotationClass);
}
+ /**
+ * {@inheritDoc}
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.5
+ */
+ @Override
+ public boolean isAnnotationPresent(Class extends Annotation> annotationClass) {
+ return AnnotatedElement.super.isAnnotationPresent(annotationClass);
+ }
+
/**
* @throws NullPointerException {@inheritDoc}
* @since 1.8
diff --git a/src/share/classes/java/lang/ClassLoader.java b/src/share/classes/java/lang/ClassLoader.java
index e62c69a1ccd4dfb616af64d2346114036885583b..a1e18ffe62d90872813e7ac5ea9b1854281bcb5e 100644
--- a/src/share/classes/java/lang/ClassLoader.java
+++ b/src/share/classes/java/lang/ClassLoader.java
@@ -51,7 +51,6 @@ import java.util.Vector;
import java.util.Hashtable;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
-import sun.misc.ClassFileTransformer;
import sun.misc.CompoundEnumeration;
import sun.misc.Resource;
import sun.misc.URLClassPath;
@@ -669,41 +668,6 @@ public abstract class ClassLoader {
return source;
}
- private Class> defineTransformedClass(String name, byte[] b, int off, int len,
- ProtectionDomain pd,
- ClassFormatError cfe, String source)
- throws ClassFormatError
- {
- // Class format error - try to transform the bytecode and
- // define the class again
- //
- ClassFileTransformer[] transformers =
- ClassFileTransformer.getTransformers();
- Class> c = null;
-
- if (transformers != null) {
- for (ClassFileTransformer transformer : transformers) {
- try {
- // Transform byte code using transformer
- byte[] tb = transformer.transform(b, off, len);
- c = defineClass1(name, tb, 0, tb.length,
- pd, source);
- break;
- } catch (ClassFormatError cfe2) {
- // If ClassFormatError occurs, try next transformer
- }
- }
- }
-
- // Rethrow original ClassFormatError if unable to transform
- // bytecode to well-formed
- //
- if (c == null)
- throw cfe;
-
- return c;
- }
-
private void postDefineClass(Class> c, ProtectionDomain pd)
{
if (pd.getCodeSource() != null) {
@@ -783,17 +747,8 @@ public abstract class ClassLoader {
throws ClassFormatError
{
protectionDomain = preDefineClass(name, protectionDomain);
-
- Class> c = null;
String source = defineClassSourceLocation(protectionDomain);
-
- try {
- c = defineClass1(name, b, off, len, protectionDomain, source);
- } catch (ClassFormatError cfe) {
- c = defineTransformedClass(name, b, off, len, protectionDomain, cfe,
- source);
- }
-
+ Class> c = defineClass1(name, b, off, len, protectionDomain, source);
postDefineClass(c, protectionDomain);
return c;
}
@@ -881,20 +836,8 @@ public abstract class ClassLoader {
}
protectionDomain = preDefineClass(name, protectionDomain);
-
- Class> c = null;
String source = defineClassSourceLocation(protectionDomain);
-
- try {
- c = defineClass2(name, b, b.position(), len, protectionDomain,
- source);
- } catch (ClassFormatError cfe) {
- byte[] tb = new byte[len];
- b.get(tb); // get bytes out of byte buffer.
- c = defineTransformedClass(name, tb, 0, len, protectionDomain, cfe,
- source);
- }
-
+ Class> c = defineClass2(name, b, b.position(), len, protectionDomain, source);
postDefineClass(c, protectionDomain);
return c;
}
diff --git a/src/share/classes/java/lang/Deprecated.java b/src/share/classes/java/lang/Deprecated.java
index 2b1546bc64b2e208dfd1c3a5bdcbde725100115f..58a0691f0540b01f776b23c6fe9de10125f55d5f 100644
--- a/src/share/classes/java/lang/Deprecated.java
+++ b/src/share/classes/java/lang/Deprecated.java
@@ -1,5 +1,5 @@
/*
- * 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
@@ -36,6 +36,7 @@ import static java.lang.annotation.ElementType.*;
*
* @author Neal Gafter
* @since 1.5
+ * @jls 9.6.3.6 @Deprecated
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff --git a/src/share/classes/java/lang/Override.java b/src/share/classes/java/lang/Override.java
index ea6e54a151e48f43efb71d65061951a1ff200d30..bf77344296cb6f07b940fc132e5a6a3963c4650a 100644
--- a/src/share/classes/java/lang/Override.java
+++ b/src/share/classes/java/lang/Override.java
@@ -1,5 +1,5 @@
/*
- * 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
@@ -43,7 +43,7 @@ import java.lang.annotation.*;
*
* @author Peter von der Ahé
* @author Joshua Bloch
- * @jls 9.6.1.4 Override
+ * @jls 9.6.1.4 @Override
* @since 1.5
*/
@Target(ElementType.METHOD)
diff --git a/src/share/classes/java/lang/Package.java b/src/share/classes/java/lang/Package.java
index b9776f478dbb9d0393146e4cb2832a8aef66e95e..7d1d38db64db0b192af488e0fd7ea00cf76ac098 100644
--- a/src/share/classes/java/lang/Package.java
+++ b/src/share/classes/java/lang/Package.java
@@ -25,6 +25,7 @@
package java.lang;
+import java.lang.reflect.AnnotatedElement;
import java.io.InputStream;
import java.util.Enumeration;
@@ -385,6 +386,16 @@ public class Package implements java.lang.reflect.AnnotatedElement {
return getPackageInfo().getAnnotation(annotationClass);
}
+ /**
+ * {@inheritDoc}
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.5
+ */
+ @Override
+ public boolean isAnnotationPresent(Class extends Annotation> annotationClass) {
+ return AnnotatedElement.super.isAnnotationPresent(annotationClass);
+ }
+
/**
* @throws NullPointerException {@inheritDoc}
* @since 1.8
diff --git a/src/share/classes/java/lang/SafeVarargs.java b/src/share/classes/java/lang/SafeVarargs.java
index cb14134ffbe35dfa8f69c31b0a3b352c863f5917..6fcd48e97d7ab512045dad793d11dd397c0c821a 100644
--- a/src/share/classes/java/lang/SafeVarargs.java
+++ b/src/share/classes/java/lang/SafeVarargs.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -85,6 +85,7 @@ import java.lang.annotation.*;
* @since 1.7
* @jls 4.7 Reifiable Types
* @jls 8.4.1 Formal Parameters
+ * @jls 9.6.3.7 @SafeVarargs
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff --git a/src/share/classes/java/lang/SecurityManager.java b/src/share/classes/java/lang/SecurityManager.java
index 80181cd4e80fc43d312ea890aa464fbb9fe67885..31664dc6cb2e537e4b80c61d032d7db7d55edbed 100644
--- a/src/share/classes/java/lang/SecurityManager.java
+++ b/src/share/classes/java/lang/SecurityManager.java
@@ -1320,6 +1320,9 @@ class SecurityManager {
* AWTPermission("showWindowWithoutWarningBanner") permission,
* and returns true if a SecurityException is not thrown,
* otherwise it returns false.
+ * In the case of subset Profiles of Java SE that do not include the
+ * {@code java.awt} package, {@code checkPermission} is instead called
+ * to check the permission {@code java.security.AllPermission}.
*
* If you override this method, then you should make a call to
* super.checkTopLevelWindow
@@ -1340,8 +1343,12 @@ class SecurityManager {
if (window == null) {
throw new NullPointerException("window can't be null");
}
+ Permission perm = SecurityConstants.AWT.TOPLEVEL_WINDOW_PERMISSION;
+ if (perm == null) {
+ perm = SecurityConstants.ALL_PERMISSION;
+ }
try {
- checkPermission(SecurityConstants.AWT.TOPLEVEL_WINDOW_PERMISSION);
+ checkPermission(perm);
return true;
} catch (SecurityException se) {
// just return false
@@ -1379,6 +1386,9 @@ class SecurityManager {
* This method calls checkPermission with the
* AWTPermission("accessClipboard")
* permission.
+ * In the case of subset Profiles of Java SE that do not include the
+ * {@code java.awt} package, {@code checkPermission} is instead called
+ * to check the permission {@code java.security.AllPermission}.
*
* If you override this method, then you should make a call to
* super.checkSystemClipboardAccess
@@ -1391,7 +1401,11 @@ class SecurityManager {
* @see #checkPermission(java.security.Permission) checkPermission
*/
public void checkSystemClipboardAccess() {
- checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION);
+ Permission perm = SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION;
+ if (perm == null) {
+ perm = SecurityConstants.ALL_PERMISSION;
+ }
+ checkPermission(perm);
}
/**
@@ -1400,6 +1414,10 @@ class SecurityManager {
*
* This method calls checkPermission with the
* AWTPermission("accessEventQueue") permission.
+ * In the case of subset Profiles of Java SE that do not include the
+ * {@code java.awt} package, {@code checkPermission} is instead called
+ * to check the permission {@code java.security.AllPermission}.
+ *
*
* If you override this method, then you should make a call to
* super.checkAwtEventQueueAccess
@@ -1412,7 +1430,11 @@ class SecurityManager {
* @see #checkPermission(java.security.Permission) checkPermission
*/
public void checkAwtEventQueueAccess() {
- checkPermission(SecurityConstants.AWT.CHECK_AWT_EVENTQUEUE_PERMISSION);
+ Permission perm = SecurityConstants.AWT.CHECK_AWT_EVENTQUEUE_PERMISSION;
+ if (perm == null) {
+ perm = SecurityConstants.ALL_PERMISSION;
+ }
+ checkPermission(perm);
}
/*
diff --git a/src/share/classes/java/lang/SuppressWarnings.java b/src/share/classes/java/lang/SuppressWarnings.java
index babb060396a5be0da5ebb550497c86f3736c39cc..22895dc7b2cef9fe39c3c32900280bf083183663 100644
--- a/src/share/classes/java/lang/SuppressWarnings.java
+++ b/src/share/classes/java/lang/SuppressWarnings.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2011, 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
@@ -41,8 +41,13 @@ import static java.lang.annotation.ElementType.*;
* suppress a warning in a particular method, you should annotate that
* method rather than its class.
*
- * @since 1.5
* @author Josh Bloch
+ * @since 1.5
+ * @jls 4.8 Raw Types
+ * @jls 4.12.2 Variables of Reference Type
+ * @jls 5.1.9 Unchecked Conversion
+ * @jls 5.5.2 Checked Casts and Unchecked Casts
+ * @jls 9.6.3.5 @SuppressWarnings
*/
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
@Retention(RetentionPolicy.SOURCE)
@@ -56,9 +61,11 @@ public @interface SuppressWarnings {
* free to emit a warning if an annotation contains an unrecognized
* warning name.
*
- *
Compiler vendors should document the warning names they support in
- * conjunction with this annotation type. They are encouraged to cooperate
- * to ensure that the same names work across multiple compilers.
+ *
The string {@code "unchecked"} is used to suppress
+ * unchecked warnings. Compiler vendors should document the
+ * additional warning names they support in conjunction with this
+ * annotation type. They are encouraged to cooperate to ensure
+ * that the same names work across multiple compilers.
*/
String[] value();
}
diff --git a/src/share/classes/java/lang/annotation/Inherited.java b/src/share/classes/java/lang/annotation/Inherited.java
index a7efa6b41d2477de3043f503d708a535c197052f..83391e29eac4b93cbc48b927142ee7e4251a8731 100644
--- a/src/share/classes/java/lang/annotation/Inherited.java
+++ b/src/share/classes/java/lang/annotation/Inherited.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, 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
@@ -44,6 +44,7 @@ package java.lang.annotation;
*
* @author Joshua Bloch
* @since 1.5
+ * @jls 9.6.3.3 @Inherited
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff --git a/src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java b/src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java
deleted file mode 100644
index 37d00a98b40e85eaa3fe76af39e59bb821370e50..0000000000000000000000000000000000000000
--- a/src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java
+++ /dev/null
@@ -1,128 +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.
- */
-package java.lang.annotation;
-
-import java.util.Objects;
-
-/**
- * Thrown to indicate that an annotation type expected to act as a
- * container for another annotation type by virture of an @Repeatable
- * annotation, does not act as a container.
- *
- * @see java.lang.reflect.AnnotatedElement
- * @since 1.8
- * @jls 9.6 Annotation Types
- * @jls 9.7 Annotations
- */
-public class InvalidContainerAnnotationError extends AnnotationFormatError {
- private static final long serialVersionUID = 5023L;
-
- /**
- * The instance of the erroneous container.
- */
- private transient Annotation container;
-
- /**
- * The type of the annotation that should be contained in the
- * container.
- */
- private transient Class extends Annotation> annotationType;
-
- /**
- * Constructs a new InvalidContainerAnnotationError with the
- * specified detail message.
- *
- * @param message the detail message.
- */
- public InvalidContainerAnnotationError(String message) {
- super(message);
- }
-
- /**
- * Constructs a new InvalidContainerAnnotationError with the specified
- * detail message and cause. Note that the detail message associated
- * with {@code cause} is not automatically incorporated in
- * this error's detail message.
- *
- * @param message the detail message
- * @param cause the cause, may be {@code null}
- */
- public InvalidContainerAnnotationError(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Constructs a new InvalidContainerAnnotationError with the
- * specified cause and a detail message of {@code (cause == null ?
- * null : cause.toString())} (which typically contains the class
- * and detail message of {@code cause}).
- *
- * @param cause the cause, may be {@code null}
- */
- public InvalidContainerAnnotationError(Throwable cause) {
- super(cause);
- }
-
- /**
- * Constructs InvalidContainerAnnotationError for the specified
- * container instance and contained annotation type.
- *
- * @param message the detail message
- * @param cause the cause, may be {@code null}
- * @param container the erroneous container instance, may be
- * {@code null}
- * @param annotationType the annotation type intended to be
- * contained, may be {@code null}
- */
- public InvalidContainerAnnotationError(String message,
- Throwable cause,
- Annotation container,
- Class extends Annotation> annotationType) {
- super(message, cause);
- this.container = container;
- this.annotationType = annotationType;
- }
-
- /**
- * Returns the erroneous container.
- *
- * @return the erroneous container, may return {@code null}
- */
- public Annotation getContainer() {
- return container;
- }
-
- /**
- * Returns the annotation type intended to be contained. Returns
- * {@code null} if the annotation type intended to be contained
- * could not be determined.
- *
- * @return the annotation type intended to be contained, or {@code
- * null} if unknown
- */
- public Class extends Annotation> getAnnotationType() {
- return annotationType;
- }
-}
diff --git a/src/share/classes/java/lang/annotation/Retention.java b/src/share/classes/java/lang/annotation/Retention.java
index df04a31db90ab521b74ce47ca6cf53d9c8b02dd1..1c27ca0871eb0723acdd16145ba47a5b2b39d98b 100644
--- a/src/share/classes/java/lang/annotation/Retention.java
+++ b/src/share/classes/java/lang/annotation/Retention.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2006, 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
@@ -38,6 +38,7 @@ package java.lang.annotation;
*
* @author Joshua Bloch
* @since 1.5
+ * @jls 9.6.3.2 @Retention
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff --git a/src/share/classes/java/lang/annotation/Target.java b/src/share/classes/java/lang/annotation/Target.java
index dc67de3f071077ad77c1333c66132f378d2b3079..cdf4a748ae5aae3a5a94592165de32bfb22a86f9 100644
--- a/src/share/classes/java/lang/annotation/Target.java
+++ b/src/share/classes/java/lang/annotation/Target.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, 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
@@ -59,6 +59,9 @@ package java.lang.annotation;
* ...
* }
*
+ *
+ * @since 1.5
+ * @jls 9.6.3.1 @Target
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff --git a/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java b/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java
index 516443dc1863df3308db2ccfc56d7a4d8e844a65..892a9dd5316a1d4203c73ad7b8ed6b8b3867b6e6 100644
--- a/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java
+++ b/src/share/classes/java/lang/invoke/AbstractValidatingLambdaMetafactory.java
@@ -34,11 +34,11 @@ import sun.invoke.util.Wrapper;
import static sun.invoke.util.Wrapper.*;
/**
- * Abstract implementation of a meta-factory which provides parameter unrolling and input validation.
+ * Abstract implementation of a lambda metafactory which provides parameter unrolling and input validation.
*
- * @author Robert Field
+ * @see LambdaMetafactory
*/
-/*non-public*/ abstract class AbstractValidatingLambdaMetafactory {
+/* package */ abstract class AbstractValidatingLambdaMetafactory {
/*
* For context, the comments for the following fields are marked in quotes with their values, given this program:
@@ -54,16 +54,19 @@ import static sun.invoke.util.Wrapper.*;
final Class> targetClass; // The class calling the meta-factory via invokedynamic "class X"
final MethodType invokedType; // The type of the invoked method "(CC)II"
final Class> samBase; // The type of the returned instance "interface JJ"
- final boolean isSerializable; // Should the returned instance be serializable
+ final MethodHandle samMethod; // Raw method handle for the functional interface method
final MethodHandleInfo samInfo; // Info about the SAM method handle "MethodHandleInfo[9 II.foo(Object)Object]"
final Class> samClass; // Interface containing the SAM method "interface II"
final MethodType samMethodType; // Type of the SAM method "(Object)Object"
+ final MethodHandle implMethod; // Raw method handle for the implementation method
final MethodHandleInfo implInfo; // Info about the implementation method handle "MethodHandleInfo[5 CC.impl(int)String]"
final int implKind; // Invocation kind for implementation "5"=invokevirtual
final boolean implIsInstanceMethod; // Is the implementation an instance method "true"
final Class> implDefiningClass; // Type defining the implementation "class CC"
final MethodType implMethodType; // Type of the implementation method "(int)String"
final MethodType instantiatedMethodType; // Instantiated erased functional interface method type "(Integer)Object"
+ final boolean isSerializable; // Should the returned instance be serializable
+ final Class>[] markerInterfaces; // Additional marker interfaces to be implemented
/**
@@ -80,27 +83,35 @@ import static sun.invoke.util.Wrapper.*;
* @param implMethod The implementation method which should be called (with suitable adaptation of argument
* types, return types, and adjustment for captured arguments) when methods of the resulting
* functional interface instance are invoked.
- * @param instantiatedMethodType The signature of the SAM method from the functional interface's perspective
+ * @param instantiatedMethodType The signature of the primary functional interface method after type variables
+ * are substituted with their instantiation from the capture site
* @throws ReflectiveOperationException
+ * @throws LambdaConversionException If any of the meta-factory protocol invariants are violated
*/
AbstractValidatingLambdaMetafactory(MethodHandles.Lookup caller,
MethodType invokedType,
MethodHandle samMethod,
MethodHandle implMethod,
- MethodType instantiatedMethodType)
- throws ReflectiveOperationException {
+ MethodType instantiatedMethodType,
+ int flags,
+ Class>[] markerInterfaces)
+ throws ReflectiveOperationException, LambdaConversionException {
this.targetClass = caller.lookupClass();
this.invokedType = invokedType;
this.samBase = invokedType.returnType();
- this.isSerializable = Serializable.class.isAssignableFrom(samBase);
+ this.samMethod = samMethod;
this.samInfo = new MethodHandleInfo(samMethod);
this.samClass = samInfo.getDeclaringClass();
this.samMethodType = samInfo.getMethodType();
+ this.implMethod = implMethod;
this.implInfo = new MethodHandleInfo(implMethod);
- this.implKind = implInfo.getReferenceKind() == MethodHandleInfo.REF_invokeSpecial? MethodHandleInfo.REF_invokeVirtual : implInfo.getReferenceKind(); // @@@ Temp work-around to hotspot incorrectly converting to invokespecial
+ // @@@ Temporary work-around pending resolution of 8005119
+ this.implKind = (implInfo.getReferenceKind() == MethodHandleInfo.REF_invokeSpecial)
+ ? MethodHandleInfo.REF_invokeVirtual
+ : implInfo.getReferenceKind();
this.implIsInstanceMethod =
implKind == MethodHandleInfo.REF_invokeVirtual ||
implKind == MethodHandleInfo.REF_invokeSpecial ||
@@ -109,6 +120,30 @@ import static sun.invoke.util.Wrapper.*;
this.implMethodType = implInfo.getMethodType();
this.instantiatedMethodType = instantiatedMethodType;
+
+ if (!samClass.isInterface()) {
+ throw new LambdaConversionException(String.format(
+ "Functional interface %s is not an interface",
+ samClass.getName()));
+ }
+
+ boolean foundSerializableSupertype = Serializable.class.isAssignableFrom(samBase);
+ for (Class> c : markerInterfaces) {
+ if (!c.isInterface()) {
+ throw new LambdaConversionException(String.format(
+ "Marker interface %s is not an interface",
+ c.getName()));
+ }
+ foundSerializableSupertype |= Serializable.class.isAssignableFrom(c);
+ }
+ this.isSerializable = ((flags & LambdaMetafactory.FLAG_SERIALIZABLE) != 0)
+ || foundSerializableSupertype;
+
+ if (isSerializable && !foundSerializableSupertype) {
+ markerInterfaces = Arrays.copyOf(markerInterfaces, markerInterfaces.length + 1);
+ markerInterfaces[markerInterfaces.length-1] = Serializable.class;
+ }
+ this.markerInterfaces = markerInterfaces;
}
/**
@@ -127,8 +162,9 @@ import static sun.invoke.util.Wrapper.*;
void validateMetafactoryArgs() throws LambdaConversionException {
// Check target type is a subtype of class where SAM method is defined
if (!samClass.isAssignableFrom(samBase)) {
- throw new LambdaConversionException(String.format("Invalid target type %s for lambda conversion; not a subtype of functional interface %s",
- samBase.getName(), samClass.getName()));
+ throw new LambdaConversionException(
+ String.format("Invalid target type %s for lambda conversion; not a subtype of functional interface %s",
+ samBase.getName(), samClass.getName()));
}
switch (implKind) {
@@ -149,14 +185,16 @@ import static sun.invoke.util.Wrapper.*;
final int samArity = samMethodType.parameterCount();
final int instantiatedArity = instantiatedMethodType.parameterCount();
if (implArity + receiverArity != capturedArity + samArity) {
- throw new LambdaConversionException(String.format("Incorrect number of parameters for %s method %s; %d captured parameters, %d functional interface parameters, %d implementation parameters",
- implIsInstanceMethod ? "instance" : "static", implInfo,
- capturedArity, samArity, implArity));
+ throw new LambdaConversionException(
+ String.format("Incorrect number of parameters for %s method %s; %d captured parameters, %d functional interface method parameters, %d implementation parameters",
+ implIsInstanceMethod ? "instance" : "static", implInfo,
+ capturedArity, samArity, implArity));
}
if (instantiatedArity != samArity) {
- throw new LambdaConversionException(String.format("Incorrect number of parameters for %s method %s; %d functional interface parameters, %d SAM method parameters",
- implIsInstanceMethod ? "instance" : "static", implInfo,
- instantiatedArity, samArity));
+ throw new LambdaConversionException(
+ String.format("Incorrect number of parameters for %s method %s; %d instantiated parameters, %d functional interface method parameters",
+ implIsInstanceMethod ? "instance" : "static", implInfo,
+ instantiatedArity, samArity));
}
// If instance: first captured arg (receiver) must be subtype of class where impl method is defined
@@ -180,8 +218,9 @@ import static sun.invoke.util.Wrapper.*;
// check receiver type
if (!implDefiningClass.isAssignableFrom(receiverClass)) {
- throw new LambdaConversionException(String.format("Invalid receiver type %s; not a subtype of implementation type %s",
- receiverClass, implDefiningClass));
+ throw new LambdaConversionException(
+ String.format("Invalid receiver type %s; not a subtype of implementation type %s",
+ receiverClass, implDefiningClass));
}
} else {
// no receiver
@@ -196,7 +235,8 @@ import static sun.invoke.util.Wrapper.*;
Class> capturedParamType = invokedType.parameterType(i + capturedStart);
if (!capturedParamType.equals(implParamType)) {
throw new LambdaConversionException(
- String.format("Type mismatch in captured lambda parameter %d: expecting %s, found %s", i, capturedParamType, implParamType));
+ String.format("Type mismatch in captured lambda parameter %d: expecting %s, found %s",
+ i, capturedParamType, implParamType));
}
}
// Check for adaptation match on SAM arguments
@@ -206,7 +246,8 @@ import static sun.invoke.util.Wrapper.*;
Class> instantiatedParamType = instantiatedMethodType.parameterType(i + samOffset);
if (!isAdaptableTo(instantiatedParamType, implParamType, true)) {
throw new LambdaConversionException(
- String.format("Type mismatch for lambda argument %d: %s is not convertible to %s", i, instantiatedParamType, implParamType));
+ String.format("Type mismatch for lambda argument %d: %s is not convertible to %s",
+ i, instantiatedParamType, implParamType));
}
}
@@ -218,7 +259,8 @@ import static sun.invoke.util.Wrapper.*;
: implMethodType.returnType();
if (!isAdaptableToAsReturn(actualReturnType, expectedType)) {
throw new LambdaConversionException(
- String.format("Type mismatch for lambda return: %s is not convertible to %s", actualReturnType, expectedType));
+ String.format("Type mismatch for lambda return: %s is not convertible to %s",
+ actualReturnType, expectedType));
}
}
@@ -274,8 +316,8 @@ import static sun.invoke.util.Wrapper.*;
}
- /*********** Logging support -- for debugging only
- static final Executor logPool = Executors.newSingleThreadExecutor(); // @@@ For debugging only
+ /*********** Logging support -- for debugging only, uncomment as needed
+ static final Executor logPool = Executors.newSingleThreadExecutor();
protected static void log(final String s) {
MethodHandleProxyLambdaMetafactory.logPool.execute(new Runnable() {
@Override
@@ -297,17 +339,21 @@ import static sun.invoke.util.Wrapper.*;
***********************/
/**
- * Find the SAM method and corresponding methods which should be bridged. SAM method and those to be bridged
- * will have the same name and number of parameters. Check for matching default methods (non-abstract), they
- * should not be bridged-over and indicate a complex bridging situation.
+ * Find the functional interface method and corresponding abstract methods
+ * which should be bridged. The functional interface method and those to be
+ * bridged will have the same name and number of parameters. Check for
+ * matching default methods (non-abstract), the VM will create bridges for
+ * default methods; We don't have enough readily available type information
+ * to distinguish between where the functional interface method should be
+ * bridged and where the default method should be bridged; This situation is
+ * flagged.
*/
class MethodAnalyzer {
private final Method[] methods = samBase.getMethods();
- private final List methodsFound = new ArrayList<>(methods.length);
private Method samMethod = null;
private final List methodsToBridge = new ArrayList<>(methods.length);
- private boolean defaultMethodFound = false;
+ private boolean conflictFoundBetweenDefaultAndBridge = false;
MethodAnalyzer() {
String samMethodName = samInfo.getName();
@@ -315,31 +361,36 @@ import static sun.invoke.util.Wrapper.*;
int samParamLength = samParamTypes.length;
Class> samReturnType = samMethodType.returnType();
Class> objectClass = Object.class;
+ List defaultMethods = new ArrayList<>(methods.length);
for (Method m : methods) {
if (m.getName().equals(samMethodName) && m.getDeclaringClass() != objectClass) {
Class>[] mParamTypes = m.getParameterTypes();
if (mParamTypes.length == samParamLength) {
+ // Method matches name and parameter length -- and is not Object
if (Modifier.isAbstract(m.getModifiers())) {
- // Exclude methods with duplicate signatures
- if (methodUnique(m)) {
- if (m.getReturnType().equals(samReturnType) && Arrays.equals(mParamTypes, samParamTypes)) {
- // Exact match, this is the SAM method signature
- samMethod = m;
- } else {
- methodsToBridge.add(m);
- }
+ // Method is abstract
+ if (m.getReturnType().equals(samReturnType)
+ && Arrays.equals(mParamTypes, samParamTypes)) {
+ // Exact match, this is the SAM method signature
+ samMethod = m;
+ } else if (!hasMatchingBridgeSignature(m)) {
+ // Record bridges, exclude methods with duplicate signatures
+ methodsToBridge.add(m);
}
} else {
- // This is a default method, flag for special processing
- defaultMethodFound = true;
- // Ignore future matching abstracts.
- // Note, due to reabstraction, this is really a punt, hence pass-off to VM
- methodUnique(m);
+ // Record default methods for conflict testing
+ defaultMethods.add(m);
}
}
}
}
+ for (Method dm : defaultMethods) {
+ if (hasMatchingBridgeSignature(dm)) {
+ conflictFoundBetweenDefaultAndBridge = true;
+ break;
+ }
+ }
}
Method getSamMethod() {
@@ -350,27 +401,26 @@ import static sun.invoke.util.Wrapper.*;
return methodsToBridge;
}
- boolean wasDefaultMethodFound() {
- return defaultMethodFound;
+ boolean conflictFoundBetweenDefaultAndBridge() {
+ return conflictFoundBetweenDefaultAndBridge;
}
/**
- * Search the list of previously found methods to determine if there is a method with the same signature
- * (return and parameter types) as the specified method. If it wasn't found before, add to the found list.
+ * Search the list of previously found bridge methods to determine if there is a method with the same signature
+ * (return and parameter types) as the specified method.
*
* @param m The method to match
- * @return False if the method was found, True otherwise
+ * @return True if the method was found, False otherwise
*/
- private boolean methodUnique(Method m) {
+ private boolean hasMatchingBridgeSignature(Method m) {
Class>[] ptypes = m.getParameterTypes();
Class> rtype = m.getReturnType();
- for (Method md : methodsFound) {
+ for (Method md : methodsToBridge) {
if (md.getReturnType().equals(rtype) && Arrays.equals(ptypes, md.getParameterTypes())) {
+ return true;
+ }
+ }
return false;
}
}
- methodsFound.add(m);
- return true;
- }
- }
}
diff --git a/src/share/classes/java/lang/invoke/DirectMethodHandle.java b/src/share/classes/java/lang/invoke/DirectMethodHandle.java
index 0df8e730937f49054a33c0d783d2176d35ccb680..68fe71c72c0f3c00f733c363fdcf532550d8307b 100644
--- a/src/share/classes/java/lang/invoke/DirectMethodHandle.java
+++ b/src/share/classes/java/lang/invoke/DirectMethodHandle.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -55,8 +55,7 @@ class DirectMethodHandle extends MethodHandle {
}
// Factory methods:
-
- static DirectMethodHandle make(Class> receiver, MemberName member) {
+ static DirectMethodHandle make(byte refKind, Class> receiver, MemberName member) {
MethodType mtype = member.getMethodOrFieldType();
if (!member.isStatic()) {
if (!member.getDeclaringClass().isAssignableFrom(receiver) || member.isConstructor())
@@ -64,8 +63,14 @@ class DirectMethodHandle extends MethodHandle {
mtype = mtype.insertParameterTypes(0, receiver);
}
if (!member.isField()) {
- LambdaForm lform = preparedLambdaForm(member);
- return new DirectMethodHandle(mtype, lform, member);
+ if (refKind == REF_invokeSpecial) {
+ member = member.asSpecial();
+ LambdaForm lform = preparedLambdaForm(member);
+ return new Special(mtype, lform, member);
+ } else {
+ LambdaForm lform = preparedLambdaForm(member);
+ return new DirectMethodHandle(mtype, lform, member);
+ }
} else {
LambdaForm lform = preparedFieldLambdaForm(member);
if (member.isStatic()) {
@@ -79,6 +84,12 @@ class DirectMethodHandle extends MethodHandle {
}
}
}
+ static DirectMethodHandle make(Class> receiver, MemberName member) {
+ byte refKind = member.getReferenceKind();
+ if (refKind == REF_invokeSpecial)
+ refKind = REF_invokeVirtual;
+ return make(refKind, receiver, member);
+ }
static DirectMethodHandle make(MemberName member) {
if (member.isConstructor())
return makeAllocator(member);
@@ -114,6 +125,10 @@ class DirectMethodHandle extends MethodHandle {
//// Implementation methods.
@Override
+ MethodHandle viewAsType(MethodType newType) {
+ return new DirectMethodHandle(newType, form, member);
+ }
+ @Override
@ForceInline
MemberName internalMemberName() {
return member;
@@ -357,6 +372,21 @@ class DirectMethodHandle extends MethodHandle {
((DirectMethodHandle)mh).ensureInitialized();
}
+ /** This subclass represents invokespecial instructions. */
+ static class Special extends DirectMethodHandle {
+ private Special(MethodType mtype, LambdaForm form, MemberName member) {
+ super(mtype, form, member);
+ }
+ @Override
+ boolean isInvokeSpecial() {
+ return true;
+ }
+ @Override
+ MethodHandle viewAsType(MethodType newType) {
+ return new Special(newType, form, member);
+ }
+ }
+
/** This subclass handles constructor references. */
static class Constructor extends DirectMethodHandle {
final MemberName initMethod;
@@ -369,6 +399,10 @@ class DirectMethodHandle extends MethodHandle {
this.instanceClass = instanceClass;
assert(initMethod.isResolved());
}
+ @Override
+ MethodHandle viewAsType(MethodType newType) {
+ return new Constructor(newType, form, member, initMethod, instanceClass);
+ }
}
/*non-public*/ static Object constructorMethod(Object mh) {
@@ -395,6 +429,10 @@ class DirectMethodHandle extends MethodHandle {
@Override Object checkCast(Object obj) {
return fieldType.cast(obj);
}
+ @Override
+ MethodHandle viewAsType(MethodType newType) {
+ return new Accessor(newType, form, member, fieldOffset);
+ }
}
@ForceInline
@@ -434,6 +472,10 @@ class DirectMethodHandle extends MethodHandle {
@Override Object checkCast(Object obj) {
return fieldType.cast(obj);
}
+ @Override
+ MethodHandle viewAsType(MethodType newType) {
+ return new StaticAccessor(newType, form, member, staticBase, staticOffset);
+ }
}
@ForceInline
diff --git a/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java
index 13999001cdc259c3adf9ee83a76beea77e8ac3e9..f7191f7679f68347731e72d47ea3a39e6698919e 100644
--- a/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java
+++ b/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java
@@ -36,21 +36,28 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
/**
- * InnerClassLambdaMetafactory
+ * Lambda metafactory implementation which dynamically creates an inner-class-like class per lambda callsite.
+ *
+ * @see LambdaMetafactory
*/
-/*non-public*/ final class InnerClassLambdaMetafactory extends AbstractValidatingLambdaMetafactory {
+/* package */ final class InnerClassLambdaMetafactory extends AbstractValidatingLambdaMetafactory {
private static final int CLASSFILE_VERSION = 51;
- private static final Type TYPE_VOID = Type.getType(void.class);
private static final String METHOD_DESCRIPTOR_VOID = Type.getMethodDescriptor(Type.VOID_TYPE);
private static final String NAME_MAGIC_ACCESSOR_IMPL = "java/lang/invoke/MagicLambdaImpl";
- private static final String NAME_SERIALIZABLE = "java/io/Serializable";
private static final String NAME_CTOR = "";
//Serialization support
- private static final String NAME_SERIALIZED_LAMBDA = "com/oracle/java/lang/invoke/SerializedLambdaImpl";
+ private static final String NAME_SERIALIZED_LAMBDA = "java/lang/invoke/SerializedLambda";
private static final String DESCR_METHOD_WRITE_REPLACE = "()Ljava/lang/Object;";
private static final String NAME_METHOD_WRITE_REPLACE = "writeReplace";
private static final String NAME_OBJECT = "java/lang/Object";
+ private static final String DESCR_CTOR_SERIALIZED_LAMBDA
+ = MethodType.methodType(void.class,
+ Class.class,
+ int.class, String.class, String.class, String.class,
+ int.class, String.class, String.class, String.class,
+ String.class,
+ Object[].class).toMethodDescriptorString();
// Used to ensure that each spun class name is unique
private static final AtomicInteger counter = new AtomicInteger(0);
@@ -70,7 +77,7 @@ import java.security.PrivilegedAction;
private final Type[] instantiatedArgumentTypes; // ASM types for the functional interface arguments
/**
- * Meta-factory constructor.
+ * General meta-factory constructor, standard cases and allowing for uncommon options such as serialization.
*
* @param caller Stacked automatically by VM; represents a lookup context with the accessibility privileges
* of the caller.
@@ -83,16 +90,23 @@ import java.security.PrivilegedAction;
* @param implMethod The implementation method which should be called (with suitable adaptation of argument
* types, return types, and adjustment for captured arguments) when methods of the resulting
* functional interface instance are invoked.
- * @param instantiatedMethodType The signature of the SAM method from the functional interface's perspective
+ * @param instantiatedMethodType The signature of the primary functional interface method after type variables
+ * are substituted with their instantiation from the capture site
+ * @param flags A bitmask containing flags that may influence the translation of this lambda expression. Defined
+ * fields include FLAG_SERIALIZABLE.
+ * @param markerInterfaces Additional interfaces which the lambda object should implement.
* @throws ReflectiveOperationException
+ * @throws LambdaConversionException If any of the meta-factory protocol invariants are violated
*/
public InnerClassLambdaMetafactory(MethodHandles.Lookup caller,
MethodType invokedType,
MethodHandle samMethod,
MethodHandle implMethod,
- MethodType instantiatedMethodType)
- throws ReflectiveOperationException {
- super(caller, invokedType, samMethod, implMethod, instantiatedMethodType);
+ MethodType instantiatedMethodType,
+ int flags,
+ Class>[] markerInterfaces)
+ throws ReflectiveOperationException, LambdaConversionException {
+ super(caller, invokedType, samMethod, implMethod, instantiatedMethodType, flags, markerInterfaces);
implMethodClassName = implDefiningClass.getName().replace('.', '/');
implMethodName = implInfo.getName();
implMethodDesc = implMethodType.toMethodDescriptorString();
@@ -109,7 +123,6 @@ import java.security.PrivilegedAction;
argNames[i] = "arg$" + (i + 1);
}
instantiatedArgumentTypes = Type.getArgumentTypes(instantiatedMethodType.toMethodDescriptorString());
-
}
/**
@@ -120,7 +133,8 @@ import java.security.PrivilegedAction;
*
* @return a CallSite, which, when invoked, will return an instance of the
* functional interface
- * @throws ReflectiveOperationException, LambdaConversionException
+ * @throws ReflectiveOperationException
+ * @throws LambdaConversionException If properly formed functional interface is not found
*/
@Override
CallSite buildCallSite() throws ReflectiveOperationException, LambdaConversionException {
@@ -151,8 +165,8 @@ import java.security.PrivilegedAction;
} else {
return new ConstantCallSite(
MethodHandles.Lookup.IMPL_LOOKUP
- .findConstructor(innerClass, constructorType)
- .asType(constructorType.changeReturnType(samBase)));
+ .findConstructor(innerClass, constructorType)
+ .asType(constructorType.changeReturnType(samBase)));
}
}
@@ -161,16 +175,23 @@ import java.security.PrivilegedAction;
* interface, define and return the class.
*
* @return a Class which implements the functional interface
+ * @throws LambdaConversionException If properly formed functional interface is not found
*/
- private Class extends T> spinInnerClass() throws LambdaConversionException {
+ private Class> spinInnerClass() throws LambdaConversionException {
String samName = samBase.getName().replace('.', '/');
-
- cw.visit(CLASSFILE_VERSION, ACC_SUPER, lambdaClassName, null, NAME_MAGIC_ACCESSOR_IMPL,
- isSerializable ? new String[]{samName, NAME_SERIALIZABLE} : new String[]{samName});
+ String[] interfaces = new String[markerInterfaces.length + 1];
+ interfaces[0] = samName;
+ for (int i=0; i) Unsafe.getUnsafe().defineClass(lambdaClassName, classBytes, 0, classBytes.length, loader, pd);
+ return (Class>) Unsafe.getUnsafe().defineClass(lambdaClassName, classBytes, 0, classBytes.length,
+ loader, pd);
}
/**
@@ -253,40 +273,44 @@ import java.security.PrivilegedAction;
}
/**
- * Generate the serialization method (if needed)
+ * Generate the writeReplace method (if needed for serialization)
*/
- /****** This code is out of date -- known to be wrong -- and not currently used ******
- private void generateSerializationMethod(Type samType, String samMethodName) {
- String samMethodDesc = samMethodType.toMethodDescriptorString();
- TypeConvertingMethodAdapter mv = new TypeConvertingMethodAdapter(cw.visitMethod(ACC_PRIVATE + ACC_FINAL, NAME_METHOD_WRITE_REPLACE, DESCR_METHOD_WRITE_REPLACE, null, null));
+ private void generateWriteReplace() {
+ TypeConvertingMethodAdapter mv
+ = new TypeConvertingMethodAdapter(cw.visitMethod(ACC_PRIVATE + ACC_FINAL,
+ NAME_METHOD_WRITE_REPLACE, DESCR_METHOD_WRITE_REPLACE,
+ null, null));
mv.visitCode();
mv.visitTypeInsn(NEW, NAME_SERIALIZED_LAMBDA);
- mv.dup();
- mv.visitLdcInsn(samType);
- mv.visitLdcInsn(samMethodName);
- mv.visitLdcInsn(samMethodDesc);
- mv.visitLdcInsn(Type.getType(implDefiningClass));
- mv.visitLdcInsn(implMethodName);
- mv.visitLdcInsn(implMethodDesc);
+ mv.visitInsn(DUP);;
+ mv.visitLdcInsn(Type.getType(targetClass));
+ mv.visitLdcInsn(samInfo.getReferenceKind());
+ mv.visitLdcInsn(invokedType.returnType().getName().replace('.', '/'));
+ mv.visitLdcInsn(samInfo.getName());
+ mv.visitLdcInsn(samInfo.getMethodType().toMethodDescriptorString());
+ mv.visitLdcInsn(implInfo.getReferenceKind());
+ mv.visitLdcInsn(implInfo.getDeclaringClass().getName().replace('.', '/'));
+ mv.visitLdcInsn(implInfo.getName());
+ mv.visitLdcInsn(implInfo.getMethodType().toMethodDescriptorString());
+ mv.visitLdcInsn(instantiatedMethodType.toMethodDescriptorString());
mv.iconst(argTypes.length);
mv.visitTypeInsn(ANEWARRAY, NAME_OBJECT);
for (int i = 0; i < argTypes.length; i++) {
- mv.dup();
+ mv.visitInsn(DUP);
mv.iconst(i);
mv.visitVarInsn(ALOAD, 0);
- mv.getfield(lambdaClassName, argNames[i], argTypes[i].getDescriptor());
- mv.boxIfPrimitive(argTypes[i]);
+ mv.visitFieldInsn(GETFIELD, lambdaClassName, argNames[i], argTypes[i].getDescriptor());
+ mv.boxIfTypePrimitive(argTypes[i]);
mv.visitInsn(AASTORE);
}
- mv.invokespecial(NAME_SERIALIZED_LAMBDA, NAME_CTOR,
- "(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V");
+ mv.visitMethodInsn(INVOKESPECIAL, NAME_SERIALIZED_LAMBDA, NAME_CTOR,
+ DESCR_CTOR_SERIALIZED_LAMBDA);
mv.visitInsn(ARETURN);
mv.visitMaxs(-1, -1); // Maxs computed by ClassWriter.COMPUTE_MAXS, these arguments ignored
mv.visitEnd();
}
- ********/
/**
* Generate a method which calls the lambda implementation method,
@@ -321,11 +345,11 @@ import java.security.PrivilegedAction;
if (implKind == MethodHandleInfo.REF_newInvokeSpecial) {
visitTypeInsn(NEW, implMethodClassName);
- dup();
+ visitInsn(DUP);;
}
for (int i = 0; i < argTypes.length; i++) {
visitVarInsn(ALOAD, 0);
- getfield(lambdaClassName, argNames[i], argTypes[i].getDescriptor());
+ visitFieldInsn(GETFIELD, lambdaClassName, argNames[i], argTypes[i].getDescriptor());
}
convertArgumentTypes(Type.getArgumentTypes(m));
@@ -337,7 +361,7 @@ import java.security.PrivilegedAction;
// Note: if adapting from non-void to void, the 'return' instruction will pop the unneeded result
Type samReturnType = Type.getReturnType(m);
convertType(implMethodReturnType, samReturnType, samReturnType);
- areturn(samReturnType);
+ visitInsn(samReturnType.getOpcode(Opcodes.IRETURN));
visitMaxs(-1, -1); // Maxs computed by ClassWriter.COMPUTE_MAXS, these arguments ignored
visitEnd();
@@ -352,7 +376,7 @@ import java.security.PrivilegedAction;
Type rcvrType = samArgumentTypes[0];
Type instantiatedRcvrType = instantiatedArgumentTypes[0];
- load(lvIndex + 1, rcvrType);
+ visitVarInsn(rcvrType.getOpcode(ILOAD), lvIndex + 1);
lvIndex += rcvrType.getSize();
convertType(rcvrType, Type.getType(implDefiningClass), instantiatedRcvrType);
}
@@ -362,7 +386,7 @@ import java.security.PrivilegedAction;
Type targetType = implMethodArgumentTypes[argOffset + i];
Type instantiatedArgType = instantiatedArgumentTypes[i];
- load(lvIndex + 1, argType);
+ visitVarInsn(argType.getOpcode(ILOAD), lvIndex + 1);
lvIndex += argType.getSize();
convertType(argType, targetType, instantiatedArgType);
}
@@ -388,45 +412,5 @@ import java.security.PrivilegedAction;
throw new InternalError("Unexpected invocation kind: " + implKind);
}
}
-
- /**
- * The following methods are copied from
- * org.objectweb.asm.commons.InstructionAdapter. Part of ASM: a very
- * small and fast Java bytecode manipulation framework. Copyright (c)
- * 2000-2005 INRIA, France Telecom All rights reserved.
- *
- * Subclass with that (removing these methods) if that package/class is
- * ever added to the JDK.
- */
- private void iconst(final int cst) {
- if (cst >= -1 && cst <= 5) {
- mv.visitInsn(Opcodes.ICONST_0 + cst);
- } else if (cst >= Byte.MIN_VALUE && cst <= Byte.MAX_VALUE) {
- mv.visitIntInsn(Opcodes.BIPUSH, cst);
- } else if (cst >= Short.MIN_VALUE && cst <= Short.MAX_VALUE) {
- mv.visitIntInsn(Opcodes.SIPUSH, cst);
- } else {
- mv.visitLdcInsn(cst);
- }
- }
-
- private void load(final int var, final Type type) {
- mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), var);
- }
-
- private void dup() {
- mv.visitInsn(Opcodes.DUP);
- }
-
- private void areturn(final Type t) {
- mv.visitInsn(t.getOpcode(Opcodes.IRETURN));
- }
-
- private void getfield(
- final String owner,
- final String name,
- final String desc) {
- mv.visitFieldInsn(Opcodes.GETFIELD, owner, name, desc);
- }
}
}
diff --git a/src/share/classes/java/lang/invoke/LambdaMetafactory.java b/src/share/classes/java/lang/invoke/LambdaMetafactory.java
index 378494b48d3685885e07124d49d87ab4e3c02e49..d179d438e8a2d304e995b1918f83452fe9b374c1 100644
--- a/src/share/classes/java/lang/invoke/LambdaMetafactory.java
+++ b/src/share/classes/java/lang/invoke/LambdaMetafactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -42,14 +42,13 @@ package java.lang.invoke;
* method, and the static types of the captured lambda arguments, and link a call site which, when invoked,
* produces the lambda object.
*
- *
Two pieces of information are needed about the functional interface: the SAM method and the type of the SAM
- * method in the functional interface. The type can be different when parameterized types are used. For example,
- * consider
- * interface I<T> { int m(T x); } if this SAM type is used in a lambda
- * I<Byte> v = ..., we need both the actual SAM method which has the signature
- * (Object)int and the functional interface type of the method, which has signature
- * (Byte)int. The latter is the instantiated erased functional interface method type, or
- * simply instantiated method type.
+ *
When parameterized types are used, the instantiated type of the functional interface method may be different
+ * from that in the functional interface. For example, consider
+ * interface I<T> { int m(T x); } if this functional interface type is used in a lambda
+ * I<Byte> v = ..., we need both the actual functional interface method which has the signature
+ * (Object)int and the erased instantiated type of the functional interface method (or simply
+ * instantiated method type), which has signature
+ * (Byte)int.
*
*
While functional interfaces only have a single abstract method from the language perspective (concrete
* methods in Object are and default methods may be present), at the bytecode level they may actually have multiple
@@ -138,11 +137,25 @@ package java.lang.invoke;
*
*
*
+ * The default bootstrap ({@link #metaFactory}) represents the common cases and uses an optimized protocol.
+ * Alternate bootstraps (e.g., {@link #altMetaFactory}) exist to support uncommon cases such as serialization
+ * or additional marker superinterfaces.
*
*/
public class LambdaMetafactory {
+ /** Flag for alternate metafactories indicating the lambda object is must to be serializable */
+ public static final int FLAG_SERIALIZABLE = 1 << 0;
+
/**
+ * Flag for alternate metafactories indicating the lambda object implements other marker interfaces
+ * besides Serializable
+ */
+ public static final int FLAG_MARKERS = 1 << 1;
+
+ private static final Class>[] EMPTY_CLASS_ARRAY = new Class>[0];
+
+/**
* Standard meta-factory for conversion of lambda expressions or method references to functional interfaces.
*
* @param caller Stacked automatically by VM; represents a lookup context with the accessibility privileges
@@ -158,7 +171,8 @@ public class LambdaMetafactory {
* @param implMethod The implementation method which should be called (with suitable adaptation of argument
* types, return types, and adjustment for captured arguments) when methods of the resulting
* functional interface instance are invoked.
- * @param instantiatedMethodType The signature of the SAM method from the functional interface's perspective
+ * @param instantiatedMethodType The signature of the primary functional interface method after type variables
+ * are substituted with their instantiation from the capture site
* @return a CallSite, which, when invoked, will return an instance of the functional interface
* @throws ReflectiveOperationException
* @throws LambdaConversionException If any of the meta-factory protocol invariants are violated
@@ -171,7 +185,72 @@ public class LambdaMetafactory {
MethodType instantiatedMethodType)
throws ReflectiveOperationException, LambdaConversionException {
AbstractValidatingLambdaMetafactory mf;
- mf = new InnerClassLambdaMetafactory(caller, invokedType, samMethod, implMethod, instantiatedMethodType);
+ mf = new InnerClassLambdaMetafactory(caller, invokedType, samMethod, implMethod, instantiatedMethodType,
+ 0, EMPTY_CLASS_ARRAY);
+ mf.validateMetafactoryArgs();
+ return mf.buildCallSite();
+ }
+
+ /**
+ * Alternate meta-factory for conversion of lambda expressions or method references to functional interfaces,
+ * which supports serialization and other uncommon options.
+ *
+ * The declared argument list for this method is:
+ *
+ * CallSite altMetaFactory(MethodHandles.Lookup caller,
+ * String invokedName,
+ * MethodType invokedType,
+ * Object... args)
+ *
+ * but it behaves as if the argument list is:
+ *
+ * CallSite altMetaFactory(MethodHandles.Lookup caller,
+ * String invokedName,
+ * MethodType invokedType,
+ * MethodHandle samMethod
+ * MethodHandle implMethod,
+ * MethodType instantiatedMethodType,
+ * int flags,
+ * int markerInterfaceCount, // IF flags has MARKERS set
+ * Class... markerInterfaces // IF flags has MARKERS set
+ * )
+ *
+ *
+ * @param caller Stacked automatically by VM; represents a lookup context with the accessibility privileges
+ * of the caller.
+ * @param invokedName Stacked automatically by VM; the name of the invoked method as it appears at the call site.
+ * Currently unused.
+ * @param invokedType Stacked automatically by VM; the signature of the invoked method, which includes thefu
+ * expected static type of the returned lambda object, and the static types of the captured
+ * arguments for the lambda. In the event that the implementation method is an instance method,
+ * the first argument in the invocation signature will correspond to the receiver.
+ * @param args argument to pass, flags, marker interface count, and marker interfaces as described above
+ * @return a CallSite, which, when invoked, will return an instance of the functional interface
+ * @throws ReflectiveOperationException
+ * @throws LambdaConversionException If any of the meta-factory protocol invariants are violated
+ */
+ public static CallSite altMetaFactory(MethodHandles.Lookup caller,
+ String invokedName,
+ MethodType invokedType,
+ Object... args)
+ throws ReflectiveOperationException, LambdaConversionException {
+ MethodHandle samMethod = (MethodHandle)args[0];
+ MethodHandle implMethod = (MethodHandle)args[1];
+ MethodType instantiatedMethodType = (MethodType)args[2];
+ int flags = (Integer) args[3];
+ Class>[] markerInterfaces;
+ int argIndex = 4;
+ if ((flags & FLAG_MARKERS) != 0) {
+ int markerCount = (Integer) args[argIndex++];
+ markerInterfaces = new Class>[markerCount];
+ System.arraycopy(args, argIndex, markerInterfaces, 0, markerCount);
+ argIndex += markerCount;
+ }
+ else
+ markerInterfaces = EMPTY_CLASS_ARRAY;
+ AbstractValidatingLambdaMetafactory mf;
+ mf = new InnerClassLambdaMetafactory(caller, invokedType, samMethod, implMethod, instantiatedMethodType,
+ flags, markerInterfaces);
mf.validateMetafactoryArgs();
return mf.buildCallSite();
}
diff --git a/src/share/classes/java/lang/invoke/MethodHandle.java b/src/share/classes/java/lang/invoke/MethodHandle.java
index aa323eb358ad2dacf42b63ee5b0ef93714da1ef3..774faff5afb6b0bbd5134ccfc8818e14ff86cd44 100644
--- a/src/share/classes/java/lang/invoke/MethodHandle.java
+++ b/src/share/classes/java/lang/invoke/MethodHandle.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -1250,8 +1250,6 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
/*non-public*/
MethodHandle viewAsType(MethodType newType) {
// No actual conversions, just a new view of the same method.
- if (!type.isViewableAs(newType))
- throw new InternalError();
return MethodHandleImpl.makePairwiseConvert(this, newType, 0);
}
@@ -1267,6 +1265,11 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
return null; // DMH returns DMH.member
}
+ /*non-public*/
+ boolean isInvokeSpecial() {
+ return false; // DMH.Special returns true
+ }
+
/*non-public*/
Object internalValues() {
return null;
diff --git a/src/share/classes/java/lang/invoke/MethodHandleImpl.java b/src/share/classes/java/lang/invoke/MethodHandleImpl.java
index 3cdd99cc4a14a86c64bbf385b086d816d6e441e5..376a0a0f5528131730087d919430af12b75450d3 100644
--- a/src/share/classes/java/lang/invoke/MethodHandleImpl.java
+++ b/src/share/classes/java/lang/invoke/MethodHandleImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -367,11 +367,11 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
@Override
MethodHandle viewAsType(MethodType newType) {
- MethodHandle mh = super.viewAsType(newType);
+ if (newType.lastParameterType() != type().lastParameterType())
+ throw new InternalError();
+ MethodHandle newTarget = asFixedArity().viewAsType(newType);
// put back the varargs bit:
- MethodType type = mh.type();
- int arity = type.parameterCount();
- return mh.asVarargsCollector(type.parameterType(arity-1));
+ return new AsVarargsCollector(newTarget, newType, arrayType);
}
@Override
@@ -379,6 +379,12 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
return asFixedArity().internalMemberName();
}
+ /*non-public*/
+ @Override
+ boolean isInvokeSpecial() {
+ return asFixedArity().isInvokeSpecial();
+ }
+
@Override
MethodHandle bindArgument(int pos, char basicType, Object value) {
diff --git a/src/share/classes/java/lang/invoke/MethodHandleInfo.java b/src/share/classes/java/lang/invoke/MethodHandleInfo.java
index b73dd6350cd92f0febe76cf4f5d0884dc3e46c79..380ca59b6e1224cd7e78b26766d4c55b48c17c94 100644
--- a/src/share/classes/java/lang/invoke/MethodHandleInfo.java
+++ b/src/share/classes/java/lang/invoke/MethodHandleInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -26,10 +26,12 @@
package java.lang.invoke;
import java.lang.invoke.MethodHandleNatives.Constants;
-//Not yet public: public
-class MethodHandleInfo {
+/**
+ * Cracking (reflecting) method handles back into their constituent symbolic parts.
+ *
+ */
+final class MethodHandleInfo {
public static final int
- REF_NONE = Constants.REF_NONE,
REF_getField = Constants.REF_getField,
REF_getStatic = Constants.REF_getStatic,
REF_putField = Constants.REF_putField,
@@ -45,12 +47,17 @@ class MethodHandleInfo {
private final MethodType methodType;
private final int referenceKind;
- public MethodHandleInfo(MethodHandle mh) throws ReflectiveOperationException {
+ public MethodHandleInfo(MethodHandle mh) {
MemberName mn = mh.internalMemberName();
+ if (mn == null) throw new IllegalArgumentException("not a direct method handle");
this.declaringClass = mn.getDeclaringClass();
this.name = mn.getName();
- this.methodType = mn.getMethodType();
- this.referenceKind = mn.getReferenceKind();
+ this.methodType = mn.getMethodOrFieldType();
+ byte refKind = mn.getReferenceKind();
+ if (refKind == REF_invokeSpecial && !mh.isInvokeSpecial())
+ // Devirtualized method invocation is usually formally virtual.
+ refKind = REF_invokeVirtual;
+ this.referenceKind = refKind;
}
public Class> getDeclaringClass() {
@@ -65,7 +72,32 @@ class MethodHandleInfo {
return methodType;
}
+ public int getModifiers() {
+ return -1; //TODO
+ }
+
public int getReferenceKind() {
return referenceKind;
}
+
+ static String getReferenceKindString(int referenceKind) {
+ switch (referenceKind) {
+ case REF_getField: return "getfield";
+ case REF_getStatic: return "getstatic";
+ case REF_putField: return "putfield";
+ case REF_putStatic: return "putstatic";
+ case REF_invokeVirtual: return "invokevirtual";
+ case REF_invokeStatic: return "invokestatic";
+ case REF_invokeSpecial: return "invokespecial";
+ case REF_newInvokeSpecial: return "newinvokespecial";
+ case REF_invokeInterface: return "invokeinterface";
+ default: return "UNKNOWN_REFENCE_KIND" + "[" + referenceKind + "]";
+ }
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s %s.%s:%s", getReferenceKindString(referenceKind),
+ declaringClass.getName(), name, methodType);
+ }
}
diff --git a/src/share/classes/java/lang/invoke/MethodHandles.java b/src/share/classes/java/lang/invoke/MethodHandles.java
index e7007dd2b8974f8a788e5806be4f068d219d3424..80a44ff2f355eac38b4230aa1204b1afbbeafca5 100644
--- a/src/share/classes/java/lang/invoke/MethodHandles.java
+++ b/src/share/classes/java/lang/invoke/MethodHandles.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -1209,7 +1209,7 @@ return mh1;
checkMethod(refKind, refc, method);
if (method.isMethodHandleInvoke())
return fakeMethodHandleInvoke(method);
- MethodHandle mh = DirectMethodHandle.make(refc, method);
+ MethodHandle mh = DirectMethodHandle.make(refKind, refc, method);
mh = maybeBindCaller(method, mh);
mh = mh.setVarargs(method);
if (doRestrict)
diff --git a/src/share/classes/java/lang/invoke/SerializedLambda.java b/src/share/classes/java/lang/invoke/SerializedLambda.java
new file mode 100644
index 0000000000000000000000000000000000000000..3679e3f726d91716277a1e56db0cd595e0367e88
--- /dev/null
+++ b/src/share/classes/java/lang/invoke/SerializedLambda.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang.invoke;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Objects;
+
+/**
+ * Serialized form of a lambda expression. The properties of this class represent the information that is present
+ * at the lambda factory site, including the identity of the primary functional interface method, the identity of the
+ * implementation method, and any variables captured from the local environment at the time of lambda capture.
+ *
+ * @see LambdaMetafactory
+ */
+public final class SerializedLambda implements Serializable {
+ private static final long serialVersionUID = 8025925345765570181L;
+ private final Class> capturingClass;
+ private final String functionalInterfaceClass;
+ private final String functionalInterfaceMethodName;
+ private final String functionalInterfaceMethodSignature;
+ private final int functionalInterfaceMethodKind;
+ private final String implClass;
+ private final String implMethodName;
+ private final String implMethodSignature;
+ private final int implMethodKind;
+ private final String instantiatedMethodType;
+ private final Object[] capturedArgs;
+
+ /**
+ * Create a {@code SerializedLambda} from the low-level information present at the lambda factory site.
+ *
+ * @param capturingClass The class in which the lambda expression appears
+ * @param functionalInterfaceMethodKind Method handle kind (see {@link MethodHandleInfo}) for the
+ * functional interface method handle present at the lambda factory site
+ * @param functionalInterfaceClass Name, in slash-delimited form, for the functional interface class present at the
+ * lambda factory site
+ * @param functionalInterfaceMethodName Name of the primary method for the functional interface present at the
+ * lambda factory site
+ * @param functionalInterfaceMethodSignature Signature of the primary method for the functional interface present
+ * at the lambda factory site
+ * @param implMethodKind Method handle kind for the implementation method
+ * @param implClass Name, in slash-delimited form, for the class holding the implementation method
+ * @param implMethodName Name of the implementation method
+ * @param implMethodSignature Signature of the implementation method
+ * @param instantiatedMethodType The signature of the primary functional interface method after type variables
+ * are substituted with their instantiation from the capture site
+ * @param capturedArgs The dynamic arguments to the lambda factory site, which represent variables captured by
+ * the lambda
+ */
+ public SerializedLambda(Class> capturingClass,
+ int functionalInterfaceMethodKind,
+ String functionalInterfaceClass,
+ String functionalInterfaceMethodName,
+ String functionalInterfaceMethodSignature,
+ int implMethodKind,
+ String implClass,
+ String implMethodName,
+ String implMethodSignature,
+ String instantiatedMethodType,
+ Object[] capturedArgs) {
+ this.capturingClass = capturingClass;
+ this.functionalInterfaceMethodKind = functionalInterfaceMethodKind;
+ this.functionalInterfaceClass = functionalInterfaceClass;
+ this.functionalInterfaceMethodName = functionalInterfaceMethodName;
+ this.functionalInterfaceMethodSignature = functionalInterfaceMethodSignature;
+ this.implMethodKind = implMethodKind;
+ this.implClass = implClass;
+ this.implMethodName = implMethodName;
+ this.implMethodSignature = implMethodSignature;
+ this.instantiatedMethodType = instantiatedMethodType;
+ this.capturedArgs = Objects.requireNonNull(capturedArgs).clone();
+ }
+
+ /** Get the name of the class that captured this lambda */
+ public String getCapturingClass() {
+ return capturingClass.getName().replace('.', '/');
+ }
+
+ /** Get the name of the functional interface class to which this lambda has been converted */
+ public String getFunctionalInterfaceClass() {
+ return functionalInterfaceClass;
+ }
+
+ /** Get the name of the primary method for the functional interface to which this lambda has been converted */
+ public String getFunctionalInterfaceMethodName() {
+ return functionalInterfaceMethodName;
+ }
+
+ /** Get the signature of the primary method for the functional interface to which this lambda has been converted */
+ public String getFunctionalInterfaceMethodSignature() {
+ return functionalInterfaceMethodSignature;
+ }
+
+ /** Get the method handle kind (see {@link MethodHandleInfo}) of the primary method for the functional interface
+ * to which this lambda has been converted */
+ public int getFunctionalInterfaceMethodKind() {
+ return functionalInterfaceMethodKind;
+ }
+
+ /** Get the name of the class containing the implementation method */
+ public String getImplClass() {
+ return implClass;
+ }
+
+ /** Get the name of the implementation method */
+ public String getImplMethodName() {
+ return implMethodName;
+ }
+
+ /** Get the signature of the implementation method */
+ public String getImplMethodSignature() {
+ return implMethodSignature;
+ }
+
+ /** Get the method handle kind (see {@link MethodHandleInfo}) of the implementation method */
+ public int getImplMethodKind() {
+ return implMethodKind;
+ }
+
+ /**
+ * Get the signature of the primary functional interface method after type variables are substituted with
+ * their instantiation from the capture site
+ */
+ public final String getInstantiatedMethodType() {
+ return instantiatedMethodType;
+ }
+
+ /** Get the count of dynamic arguments to the lambda capture site */
+ public int getCapturedArgCount() {
+ return capturedArgs.length;
+ }
+
+ /** Get a dynamic argument to the lambda capture site */
+ public Object getCapturedArg(int i) {
+ return capturedArgs[i];
+ }
+
+ private Object readResolve() throws ReflectiveOperationException {
+ try {
+ Method deserialize = AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ @Override
+ public Method run() throws Exception {
+ Method m = capturingClass.getDeclaredMethod("$deserializeLambda$", SerializedLambda.class);
+ m.setAccessible(true);
+ return m;
+ }
+ });
+
+ return deserialize.invoke(null, this);
+ }
+ catch (PrivilegedActionException e) {
+ Exception cause = e.getException();
+ if (cause instanceof ReflectiveOperationException)
+ throw (ReflectiveOperationException) cause;
+ else if (cause instanceof RuntimeException)
+ throw (RuntimeException) cause;
+ else
+ throw new RuntimeException("Exception in SerializedLambda.readResolve", e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return String.format("SerializedLambda[capturingClass=%s, functionalInterfaceMethod=%s %s.%s:%s, " +
+ "implementation=%s %s.%s:%s, instantiatedMethodType=%s, numCaptured=%d]",
+ capturingClass, MethodHandleInfo.getReferenceKindString(functionalInterfaceMethodKind),
+ functionalInterfaceClass, functionalInterfaceMethodName, functionalInterfaceMethodSignature,
+ MethodHandleInfo.getReferenceKindString(implMethodKind), implClass, implMethodName,
+ implMethodSignature, instantiatedMethodType, capturedArgs.length);
+ }
+}
diff --git a/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java b/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java
index 7384bee464c55d2fe388c8903f0ac388ef4288e4..3aa63c84ae72ae163214dec5e07befd692b2212b 100644
--- a/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java
+++ b/src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java
@@ -27,6 +27,7 @@ package java.lang.invoke;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.org.objectweb.asm.Type;
import sun.invoke.util.Wrapper;
import static sun.invoke.util.Wrapper.*;
@@ -49,6 +50,9 @@ class TypeConvertingMethodAdapter extends MethodVisitor {
private static final Wrapper[] FROM_WRAPPER_NAME = new Wrapper[16];
+ // Table of wrappers for primitives, indexed by ASM type sorts
+ private static final Wrapper[] FROM_TYPE_SORT = new Wrapper[16];
+
static {
for (Wrapper w : Wrapper.values()) {
if (w.basicTypeChar() != 'L') {
@@ -71,6 +75,15 @@ class TypeConvertingMethodAdapter extends MethodVisitor {
initWidening(DOUBLE, Opcodes.I2D, BYTE, SHORT, INT, CHAR);
initWidening(DOUBLE, Opcodes.F2D, FLOAT);
initWidening(DOUBLE, Opcodes.L2D, LONG);
+
+ FROM_TYPE_SORT[Type.BYTE] = Wrapper.BYTE;
+ FROM_TYPE_SORT[Type.SHORT] = Wrapper.SHORT;
+ FROM_TYPE_SORT[Type.INT] = Wrapper.INT;
+ FROM_TYPE_SORT[Type.LONG] = Wrapper.LONG;
+ FROM_TYPE_SORT[Type.CHAR] = Wrapper.CHAR;
+ FROM_TYPE_SORT[Type.FLOAT] = Wrapper.FLOAT;
+ FROM_TYPE_SORT[Type.DOUBLE] = Wrapper.DOUBLE;
+ FROM_TYPE_SORT[Type.BOOLEAN] = Wrapper.BOOLEAN;
}
private static void initWidening(Wrapper to, int opcode, Wrapper... from) {
@@ -124,8 +137,9 @@ class TypeConvertingMethodAdapter extends MethodVisitor {
return "()" + w.basicTypeChar();
}
- void boxIfPrimitive(Wrapper w) {
- if (w.zero() != null) {
+ void boxIfTypePrimitive(Type t) {
+ Wrapper w = FROM_TYPE_SORT[t.getSort()];
+ if (w != null) {
box(w);
}
}
@@ -264,4 +278,22 @@ class TypeConvertingMethodAdapter extends MethodVisitor {
}
}
}
+
+ /**
+ * The following method is copied from
+ * org.objectweb.asm.commons.InstructionAdapter. Part of ASM: a very small
+ * and fast Java bytecode manipulation framework.
+ * Copyright (c) 2000-2005 INRIA, France Telecom All rights reserved.
+ */
+ void iconst(final int cst) {
+ if (cst >= -1 && cst <= 5) {
+ mv.visitInsn(Opcodes.ICONST_0 + cst);
+ } else if (cst >= Byte.MIN_VALUE && cst <= Byte.MAX_VALUE) {
+ mv.visitIntInsn(Opcodes.BIPUSH, cst);
+ } else if (cst >= Short.MIN_VALUE && cst <= Short.MAX_VALUE) {
+ mv.visitIntInsn(Opcodes.SIPUSH, cst);
+ } else {
+ mv.visitLdcInsn(cst);
+ }
+ }
}
diff --git a/src/share/classes/java/lang/reflect/AccessibleObject.java b/src/share/classes/java/lang/reflect/AccessibleObject.java
index d198d939d4b0442259dd81fbb03649fcd064337d..f98aed5db25e3f29e19df4e8d2314fbd92a719a9 100644
--- a/src/share/classes/java/lang/reflect/AccessibleObject.java
+++ b/src/share/classes/java/lang/reflect/AccessibleObject.java
@@ -181,6 +181,16 @@ public class AccessibleObject implements AnnotatedElement {
}
/**
+ * {@inheritDoc}
+ * @throws NullPointerException {@inheritDoc}
+ * @since 1.5
+ */
+ @Override
+ public boolean isAnnotationPresent(Class extends Annotation> annotationClass) {
+ return AnnotatedElement.super.isAnnotationPresent(annotationClass);
+ }
+
+ /**
* @throws NullPointerException {@inheritDoc}
* @since 1.8
*/
diff --git a/src/share/classes/java/lang/reflect/AnnotatedElement.java b/src/share/classes/java/lang/reflect/AnnotatedElement.java
index d6cffec2f28fba7fdf95379a45b5bcde89567233..b2c43de3d7b146b9403bb54e2249efc24cc66e7d 100644
--- a/src/share/classes/java/lang/reflect/AnnotatedElement.java
+++ b/src/share/classes/java/lang/reflect/AnnotatedElement.java
@@ -26,6 +26,7 @@
package java.lang.reflect;
import java.lang.annotation.Annotation;
+import java.lang.annotation.AnnotationFormatError;
/**
* Represents an annotated element of the program currently running in this
@@ -86,8 +87,8 @@ import java.lang.annotation.Annotation;
*
*
Attempting to read annotations of a repeatable annotation type T
* that are contained in an annotation whose type is not, in fact, the
- * containing annotation type of T will result in an
- * InvalidContainerAnnotationError.
+ * containing annotation type of T, will result in an {@link
+ * AnnotationFormatError}.
*
*
Finally, attempting to read a member whose definition has evolved
* incompatibly will result in a {@link
@@ -96,10 +97,9 @@ import java.lang.annotation.Annotation;
*
* @see java.lang.EnumConstantNotPresentException
* @see java.lang.TypeNotPresentException
- * @see java.lang.annotation.AnnotationFormatError
+ * @see AnnotationFormatError
* @see java.lang.annotation.AnnotationTypeMismatchException
* @see java.lang.annotation.IncompleteAnnotationException
- * @see java.lang.annotation.InvalidContainerAnnotationError
* @since 1.5
* @author Josh Bloch
*/
diff --git a/src/share/classes/java/lang/reflect/Constructor.java b/src/share/classes/java/lang/reflect/Constructor.java
index bbfd1d5ab9dd730010276c02a542d5738601fb5a..bdbd7c30e20c0c4ba516cd9b3cf86a3b06d3d2d5 100644
--- a/src/share/classes/java/lang/reflect/Constructor.java
+++ b/src/share/classes/java/lang/reflect/Constructor.java
@@ -532,6 +532,7 @@ public final class Constructor extends Executable {
* {@inheritDoc}
* @since 1.8
*/
+ @Override
public AnnotatedType getAnnotatedReturnType() {
return getAnnotatedReturnType0(getDeclaringClass());
}
diff --git a/src/share/classes/java/lang/reflect/Executable.java b/src/share/classes/java/lang/reflect/Executable.java
index 83b5e9c87a4bb79632ae223d808079ee7a330f4f..1a89968b175eb3d3154bcad2acd100917cd58d68 100644
--- a/src/share/classes/java/lang/reflect/Executable.java
+++ b/src/share/classes/java/lang/reflect/Executable.java
@@ -476,6 +476,20 @@ public abstract class Executable extends AccessibleObject
return declaredAnnotations;
}
+ /**
+ * Returns an AnnotatedType object that represents the potentially
+ * annotated return type of the method/constructor represented by this
+ * Executable.
+ *
+ * If this Executable represents a constructor, the AnnotatedType object
+ * represents the type of the constructed object.
+ *
+ * If this Executable represents a method, the AnnotatedType object
+ * represents the use of a type to specify the return type of the method.
+ *
+ * @since 1.8
+ */
+ public abstract AnnotatedType getAnnotatedReturnType();
/* Helper for subclasses of Executable.
*
diff --git a/src/share/classes/java/lang/reflect/Method.java b/src/share/classes/java/lang/reflect/Method.java
index 1507c77194aa60e8d526317292cc5130d86b6d30..30e764694d0a7e195471a0aa61b0c4cfc0de6e8b 100644
--- a/src/share/classes/java/lang/reflect/Method.java
+++ b/src/share/classes/java/lang/reflect/Method.java
@@ -629,6 +629,7 @@ public final class Method extends Executable {
* {@inheritDoc}
* @since 1.8
*/
+ @Override
public AnnotatedType getAnnotatedReturnType() {
return getAnnotatedReturnType0(getGenericReturnType());
}
diff --git a/src/share/classes/java/lang/reflect/Parameter.java b/src/share/classes/java/lang/reflect/Parameter.java
index 9c808310c0caac85db83a1a6f664f7a708108ee3..e479bfd9326e899cdddb92b1e0fd60ba9574332b 100644
--- a/src/share/classes/java/lang/reflect/Parameter.java
+++ b/src/share/classes/java/lang/reflect/Parameter.java
@@ -115,7 +115,9 @@ public final class Parameter implements AnnotatedElement {
(type.toString());
sb.append(Modifier.toString(getModifiers()));
- sb.append(" ");
+
+ if(0 != modifiers)
+ sb.append(" ");
if(isVarArgs())
sb.append(typename.replaceFirst("\\[\\]$", "..."));
diff --git a/src/share/classes/java/net/HttpConnectSocketImpl.java b/src/share/classes/java/net/HttpConnectSocketImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..b6e70cafd94647f84d19c13ed3766e38514e6c68
--- /dev/null
+++ b/src/share/classes/java/net/HttpConnectSocketImpl.java
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2010, 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.
+ */
+
+package java.net;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Basic SocketImpl that relies on the internal HTTP protocol handler
+ * implementation to perform the HTTP tunneling and authentication. The
+ * sockets impl is swapped out and replaced with the socket from the HTTP
+ * handler after the tunnel is successfully setup.
+ *
+ * @since 1.8
+ */
+
+/*package*/ class HttpConnectSocketImpl extends PlainSocketImpl {
+
+ private static final String httpURLClazzStr =
+ "sun.net.www.protocol.http.HttpURLConnection";
+ private static final String netClientClazzStr = "sun.net.NetworkClient";
+ private static final String doTunnelingStr = "doTunneling";
+ private static final Field httpField;
+ private static final Field serverSocketField;
+ private static final Method doTunneling;
+
+ private final String server;
+ private InetSocketAddress external_address;
+ private HashMap optionsMap = new HashMap<>();
+
+ static {
+ try {
+ Class> httpClazz = Class.forName(httpURLClazzStr, true, null);
+ httpField = httpClazz.getDeclaredField("http");
+ doTunneling = httpClazz.getDeclaredMethod(doTunnelingStr);
+ Class> netClientClazz = Class.forName(netClientClazzStr, true, null);
+ serverSocketField = netClientClazz.getDeclaredField("serverSocket");
+
+ java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction() {
+ public Void run() {
+ httpField.setAccessible(true);
+ serverSocketField.setAccessible(true);
+ return null;
+ }
+ });
+ } catch (ReflectiveOperationException x) {
+ throw new InternalError("Should not reach here", x);
+ }
+ }
+
+ HttpConnectSocketImpl(String server, int port) {
+ this.server = server;
+ this.port = port;
+ }
+
+ HttpConnectSocketImpl(Proxy proxy) {
+ SocketAddress a = proxy.address();
+ if ( !(a instanceof InetSocketAddress) )
+ throw new IllegalArgumentException("Unsupported address type");
+
+ InetSocketAddress ad = (InetSocketAddress) a;
+ server = ad.getHostString();
+ port = ad.getPort();
+ }
+
+ @Override
+ protected void connect(SocketAddress endpoint, int timeout)
+ throws IOException
+ {
+ if (endpoint == null || !(endpoint instanceof InetSocketAddress))
+ throw new IllegalArgumentException("Unsupported address type");
+ final InetSocketAddress epoint = (InetSocketAddress)endpoint;
+ final String destHost = epoint.isUnresolved() ? epoint.getHostName()
+ : epoint.getAddress().getHostAddress();
+ final int destPort = epoint.getPort();
+
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ security.checkConnect(destHost, destPort);
+
+ // Connect to the HTTP proxy server
+ String urlString = "http://" + destHost + ":" + destPort;
+ Socket httpSocket = privilegedDoTunnel(urlString, timeout);
+
+ // Success!
+ external_address = epoint;
+
+ // close the original socket impl and release its descriptor
+ close();
+
+ // update the Sockets impl to the impl from the http Socket
+ AbstractPlainSocketImpl psi = (AbstractPlainSocketImpl) httpSocket.impl;
+ this.getSocket().impl = psi;
+
+ // best effort is made to try and reset options previously set
+ Set> options = optionsMap.entrySet();
+ try {
+ for(Map.Entry entry : options) {
+ psi.setOption(entry.getKey(), entry.getValue());
+ }
+ } catch (IOException x) { /* gulp! */ }
+ }
+
+ @Override
+ public void setOption(int opt, Object val) throws SocketException {
+ super.setOption(opt, val);
+
+ if (external_address != null)
+ return; // we're connected, just return
+
+ // store options so that they can be re-applied to the impl after connect
+ optionsMap.put(opt, val);
+ }
+
+ private Socket privilegedDoTunnel(final String urlString,
+ final int timeout)
+ throws IOException
+ {
+ try {
+ return java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedExceptionAction() {
+ public Socket run() throws IOException {
+ return doTunnel(urlString, timeout);
+ }
+ });
+ } catch (java.security.PrivilegedActionException pae) {
+ throw (IOException) pae.getException();
+ }
+ }
+
+ private Socket doTunnel(String urlString, int connectTimeout)
+ throws IOException
+ {
+ Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(server, port));
+ URL destURL = new URL(urlString);
+ HttpURLConnection conn = (HttpURLConnection) destURL.openConnection(proxy);
+ conn.setConnectTimeout(connectTimeout);
+ conn.setReadTimeout(this.timeout);
+ conn.connect();
+ doTunneling(conn);
+ try {
+ Object httpClient = httpField.get(conn);
+ return (Socket) serverSocketField.get(httpClient);
+ } catch (IllegalAccessException x) {
+ throw new InternalError("Should not reach here", x);
+ }
+ }
+
+ private void doTunneling(HttpURLConnection conn) {
+ try {
+ doTunneling.invoke(conn);
+ } catch (ReflectiveOperationException x) {
+ throw new InternalError("Should not reach here", x);
+ }
+ }
+
+ @Override
+ protected InetAddress getInetAddress() {
+ if (external_address != null)
+ return external_address.getAddress();
+ else
+ return super.getInetAddress();
+ }
+
+ @Override
+ protected int getPort() {
+ if (external_address != null)
+ return external_address.getPort();
+ else
+ return super.getPort();
+ }
+
+ @Override
+ protected int getLocalPort() {
+ if (socket != null)
+ return super.getLocalPort();
+ if (external_address != null)
+ return external_address.getPort();
+ else
+ return super.getLocalPort();
+ }
+}
diff --git a/src/share/classes/java/net/Socket.java b/src/share/classes/java/net/Socket.java
index 22d4d6acd0a34623102026e2ebdf7eeb6c418e38..d4f28e9ab6dad194667e647b24d4cb60c96fb98e 100644
--- a/src/share/classes/java/net/Socket.java
+++ b/src/share/classes/java/net/Socket.java
@@ -117,8 +117,10 @@ class Socket implements java.io.Closeable {
if (proxy == null) {
throw new IllegalArgumentException("Invalid Proxy");
}
- Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY : sun.net.ApplicationProxy.create(proxy);
- if (p.type() == Proxy.Type.SOCKS) {
+ Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY
+ : sun.net.ApplicationProxy.create(proxy);
+ Proxy.Type type = p.type();
+ if (type == Proxy.Type.SOCKS || type == Proxy.Type.HTTP) {
SecurityManager security = System.getSecurityManager();
InetSocketAddress epoint = (InetSocketAddress) p.address();
if (epoint.getAddress() != null) {
@@ -133,7 +135,8 @@ class Socket implements java.io.Closeable {
security.checkConnect(epoint.getAddress().getHostAddress(),
epoint.getPort());
}
- impl = new SocksSocketImpl(p);
+ impl = type == Proxy.Type.SOCKS ? new SocksSocketImpl(p)
+ : new HttpConnectSocketImpl(p);
impl.setSocket(this);
} else {
if (p == Proxy.NO_PROXY) {
diff --git a/src/share/classes/java/net/URL.java b/src/share/classes/java/net/URL.java
index 6227103712692e1dfaefbfc233aec01b7e009527..caa1d5964cb6bb96e41f38df7dce8fc0086cf076 100644
--- a/src/share/classes/java/net/URL.java
+++ b/src/share/classes/java/net/URL.java
@@ -661,8 +661,8 @@ public final class URL implements java.io.Serializable {
* @param file the file on the host
* @param ref the internal reference in the URL
*/
- protected void set(String protocol, String host,
- int port, String file, String ref) {
+ void set(String protocol, String host, int port,
+ String file, String ref) {
synchronized (this) {
this.protocol = protocol;
this.host = host;
@@ -698,9 +698,9 @@ public final class URL implements java.io.Serializable {
* @param query the query part of this URL
* @since 1.3
*/
- protected void set(String protocol, String host, int port,
- String authority, String userInfo, String path,
- String query, String ref) {
+ void set(String protocol, String host, int port,
+ String authority, String userInfo, String path,
+ String query, String ref) {
synchronized (this) {
this.protocol = protocol;
this.host = host;
diff --git a/src/share/classes/java/net/URLStreamHandler.java b/src/share/classes/java/net/URLStreamHandler.java
index 6af130b6c4ce2c7d8f6d1634fb5d17b19ac23ef6..0561527488d2e464335c6fffbef453adb53b1592 100644
--- a/src/share/classes/java/net/URLStreamHandler.java
+++ b/src/share/classes/java/net/URLStreamHandler.java
@@ -509,8 +509,8 @@ public abstract class URLStreamHandler {
/**
* Sets the fields of the URL argument to the indicated values.
- * Only classes derived from URLStreamHandler are supposed to be able
- * to call the set method on a URL.
+ * Only classes derived from URLStreamHandler are able
+ * to use this method to set the values of the URL fields.
*
* @param u the URL to modify.
* @param protocol the protocol name.
@@ -539,8 +539,8 @@ public abstract class URLStreamHandler {
/**
* Sets the fields of the URL argument to the indicated values.
- * Only classes derived from URLStreamHandler are supposed to be able
- * to call the set method on a URL.
+ * Only classes derived from URLStreamHandler are able
+ * to use this method to set the values of the URL fields.
*
* @param u the URL to modify.
* @param protocol the protocol name. This value is ignored since 1.2.
diff --git a/src/share/classes/java/nio/file/Files.java b/src/share/classes/java/nio/file/Files.java
index c1c85b521e00a90537219bc3350096367ed40f4d..2db7ba25c4a9ec09d248611ab25a9a12261d0a27 100644
--- a/src/share/classes/java/nio/file/Files.java
+++ b/src/share/classes/java/nio/file/Files.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2012, 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
@@ -1152,7 +1152,7 @@ public final class Files {
* and file system dependent and therefore unspecified. Minimally, the
* {@link BasicFileAttributes#lastModifiedTime last-modified-time} is
* copied to the target file if supported by both the source and target
- * file store. Copying of file timestamps may result in precision
+ * file stores. Copying of file timestamps may result in precision
* loss.
*
*
@@ -1169,12 +1169,12 @@ public final class Files {
* implementation specific options.
*
*
Copying a file is not an atomic operation. If an {@link IOException}
- * is thrown then it possible that the target file is incomplete or some of
- * its file attributes have not been copied from the source file. When the
- * {@code REPLACE_EXISTING} option is specified and the target file exists,
- * then the target file is replaced. The check for the existence of the file
- * and the creation of the new file may not be atomic with respect to other
- * file system activities.
+ * is thrown, then it is possible that the target file is incomplete or some
+ * of its file attributes have not been copied from the source file. When
+ * the {@code REPLACE_EXISTING} option is specified and the target file
+ * exists, then the target file is replaced. The check for the existence of
+ * the file and the creation of the new file may not be atomic with respect
+ * to other file system activities.
*
*
Usage Example:
* Suppose we want to copy a file into a directory, giving it the same file
@@ -1279,15 +1279,16 @@ public final class Files {
*
An implementation of this interface may support additional
* implementation specific options.
*
- *
Where the move requires that the file be copied then the {@link
- * BasicFileAttributes#lastModifiedTime last-modified-time} is copied to the
- * new file. An implementation may also attempt to copy other file
- * attributes but is not required to fail if the file attributes cannot be
- * copied. When the move is performed as a non-atomic operation, and a {@code
- * IOException} is thrown, then the state of the files is not defined. The
- * original file and the target file may both exist, the target file may be
- * incomplete or some of its file attributes may not been copied from the
- * original file.
+ *
Moving a file will copy the {@link
+ * BasicFileAttributes#lastModifiedTime last-modified-time} to the target
+ * file if supported by both source and target file stores. Copying of file
+ * timestamps may result in precision loss. An implementation may also
+ * attempt to copy other file attributes but is not required to fail if the
+ * file attributes cannot be copied. When the move is performed as
+ * a non-atomic operation, and an {@code IOException} is thrown, then the
+ * state of the files is not defined. The original file and the target file
+ * may both exist, the target file may be incomplete or some of its file
+ * attributes may not been copied from the original file.
*
*
Usage Examples:
* Suppose we want to rename a file to "newname", keeping the file in the
diff --git a/src/share/classes/java/sql/CallableStatement.java b/src/share/classes/java/sql/CallableStatement.java
index 1200f771dade0bef53d4109b828299ae0865523a..a39af405220850be577583e8974a038d18ceee95 100644
--- a/src/share/classes/java/sql/CallableStatement.java
+++ b/src/share/classes/java/sql/CallableStatement.java
@@ -2621,7 +2621,7 @@ public interface CallableStatement extends PreparedStatement {
* parameter determines the Java type that must be used
* in the {@code get} method to read the value of that parameter.
*
- * This version of {@code registrOutParameter} should be
+ * This version of {@code registerOutParameter} should be
* used when the parameter is of JDBC type {@code JDBCType.NUMERIC}
* or {@code JDBCType.DECIMAL}.
*
@@ -2649,7 +2649,7 @@ public interface CallableStatement extends PreparedStatement {
/**
* Registers the designated output parameter.
* This version of
- * the method {@code registrOutParameter}
+ * the method {@code registerOutParameter}
* should be used for a user-defined or {@code REF} output parameter.
* Examples
* of user-defined types include: {@code STRUCT}, {@code DISTINCT},
@@ -2717,7 +2717,7 @@ public interface CallableStatement extends PreparedStatement {
* register the OUT Parameter.
* If the parameter is of JDBC type {@code JDBCType.NUMERIC}
* or {@code JDBCType.DECIMAL}, the version of
- * {@code registrOutParameter} that accepts a scale value
+ * {@code registerOutParameter} that accepts a scale value
* should be used.
* @exception SQLException if parameterName does not correspond to a named
* parameter; if a database access error occurs or
@@ -2745,7 +2745,7 @@ public interface CallableStatement extends PreparedStatement {
* parameter determines the Java type that must be used
* in the {@code get} method to read the value of that parameter.
*
- * This version of {@code registrOutParameter} should be
+ * This version of {@code registerOutParameter} should be
* used when the parameter is of JDBC type {@code JDBCType.NUMERIC}
* or {@code JDBCType.DECIMAL}.
*
@@ -2774,7 +2774,7 @@ public interface CallableStatement extends PreparedStatement {
/**
* Registers the designated output parameter. This version of
- * the method {@code registrOutParameter}
+ * the method {@code registerOutParameter}
* should be used for a user-named or REF output parameter. Examples
* of user-named types include: STRUCT, DISTINCT, JAVA_OBJECT, and
* named array types.
diff --git a/src/share/classes/java/text/DateFormat.java b/src/share/classes/java/text/DateFormat.java
index d1bb6e682dd2892d414c619b543fd4a44ae6e694..fcb21e6928cc18b8332422f5cd776274a8ed4a87 100644
--- a/src/share/classes/java/text/DateFormat.java
+++ b/src/share/classes/java/text/DateFormat.java
@@ -439,7 +439,12 @@ public abstract class DateFormat extends Format {
/**
* Gets the time formatter with the default formatting style
- * for the default locale.
+ * for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ *
This is equivalent to calling
+ * {@link #getTimeInstance(int, Locale) getTimeInstance(DEFAULT,
+ * Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @return a time formatter.
*/
public final static DateFormat getTimeInstance()
@@ -449,7 +454,12 @@ public abstract class DateFormat extends Format {
/**
* Gets the time formatter with the given formatting style
- * for the default locale.
+ * for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ *
This is equivalent to calling
+ * {@link #getTimeInstance(int, Locale) getTimeInstance(style,
+ * Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @param style the given formatting style. For example,
* SHORT for "h:mm a" in the US locale.
* @return a time formatter.
@@ -475,7 +485,12 @@ public abstract class DateFormat extends Format {
/**
* Gets the date formatter with the default formatting style
- * for the default locale.
+ * for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ *
This is equivalent to calling
+ * {@link #getDateInstance(int, Locale) getDateInstance(DEFAULT,
+ * Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @return a date formatter.
*/
public final static DateFormat getDateInstance()
@@ -485,7 +500,12 @@ public abstract class DateFormat extends Format {
/**
* Gets the date formatter with the given formatting style
- * for the default locale.
+ * for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ *
This is equivalent to calling
+ * {@link #getDateInstance(int, Locale) getDateInstance(style,
+ * Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @param style the given formatting style. For example,
* SHORT for "M/d/yy" in the US locale.
* @return a date formatter.
@@ -511,7 +531,12 @@ public abstract class DateFormat extends Format {
/**
* Gets the date/time formatter with the default formatting style
- * for the default locale.
+ * for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ *
This is equivalent to calling
+ * {@link #getDateTimeInstance(int, int, Locale) getDateTimeInstance(DEFAULT,
+ * DEFAULT, Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @return a date/time formatter.
*/
public final static DateFormat getDateTimeInstance()
@@ -521,7 +546,12 @@ public abstract class DateFormat extends Format {
/**
* Gets the date/time formatter with the given date and time
- * formatting styles for the default locale.
+ * formatting styles for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ *
This is equivalent to calling
+ * {@link #getDateTimeInstance(int, int, Locale) getDateTimeInstance(dateStyle,
+ * timeStyle, Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @param dateStyle the given date formatting style. For example,
* SHORT for "M/d/yy" in the US locale.
* @param timeStyle the given time formatting style. For example,
diff --git a/src/share/classes/java/text/DateFormatSymbols.java b/src/share/classes/java/text/DateFormatSymbols.java
index b4c380d2c0507daa2a562d1e73060a7f6cc779ea..80e4f03a38a727b51bdd275bd3570da812f10096 100644
--- a/src/share/classes/java/text/DateFormatSymbols.java
+++ b/src/share/classes/java/text/DateFormatSymbols.java
@@ -104,14 +104,19 @@ public class DateFormatSymbols implements Serializable, Cloneable {
/**
* Construct a DateFormatSymbols object by loading format data from
- * resources for the default locale. This constructor can only
+ * resources for the default {@link java.util.Locale.Category#FORMAT FORMAT}
+ * locale. This constructor can only
* construct instances for the locales supported by the Java
* runtime environment, not for those supported by installed
* {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
* implementations. For full locale coverage, use the
* {@link #getInstance(Locale) getInstance} method.
- *
+ *
This is equivalent to calling
+ * {@link #DateFormatSymbols(Locale)
+ * DateFormatSymbols(Locale.getDefault(Locale.Category.FORMAT))}.
* @see #getInstance()
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @exception java.util.MissingResourceException
* if the resources for the default locale cannot be
* found or cannot be loaded.
@@ -302,6 +307,10 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* as for those supported by installed
* {@link java.text.spi.DateFormatSymbolsProvider DateFormatSymbolsProvider}
* implementations.
+ *
This is equivalent to calling {@link #getInstance(Locale)
+ * getInstance(Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @return a DateFormatSymbols instance.
* @since 1.6
*/
diff --git a/src/share/classes/java/text/DecimalFormat.java b/src/share/classes/java/text/DecimalFormat.java
index 38c930372c1a175c9c413ec415bb698691af0673..bd37b2ed471b4133af29a210f07d5286ebeeb094 100644
--- a/src/share/classes/java/text/DecimalFormat.java
+++ b/src/share/classes/java/text/DecimalFormat.java
@@ -381,7 +381,8 @@ public class DecimalFormat extends NumberFormat {
/**
* Creates a DecimalFormat using the default pattern and symbols
- * for the default locale. This is a convenient way to obtain a
+ * for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ * This is a convenient way to obtain a
* DecimalFormat when internationalization is not the main concern.
*
* To obtain standard formats for a given locale, use the factory methods
@@ -411,7 +412,8 @@ public class DecimalFormat extends NumberFormat {
/**
* Creates a DecimalFormat using the given pattern and the symbols
- * for the default locale. This is a convenient way to obtain a
+ * for the default {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ * This is a convenient way to obtain a
* DecimalFormat when internationalization is not the main concern.
*
* To obtain standard formats for a given locale, use the factory methods
diff --git a/src/share/classes/java/text/DecimalFormatSymbols.java b/src/share/classes/java/text/DecimalFormatSymbols.java
index 9274208fe8f7c9ff6589232bf88949d81538c306..f0b2212eaf564919ab743aea6be3d1ea30653a9b 100644
--- a/src/share/classes/java/text/DecimalFormatSymbols.java
+++ b/src/share/classes/java/text/DecimalFormatSymbols.java
@@ -71,13 +71,19 @@ import sun.util.locale.provider.ResourceBundleBasedAdapter;
public class DecimalFormatSymbols implements Cloneable, Serializable {
/**
- * Create a DecimalFormatSymbols object for the default locale.
+ * Create a DecimalFormatSymbols object for the default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
* This constructor can only construct instances for the locales
* supported by the Java runtime environment, not for those
* supported by installed
* {@link java.text.spi.DecimalFormatSymbolsProvider DecimalFormatSymbolsProvider}
* implementations. For full locale coverage, use the
* {@link #getInstance(Locale) getInstance} method.
+ *
This is equivalent to calling
+ * {@link #DecimalFormatSymbols(Locale)
+ * DecimalFormatSymbols(Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
*/
public DecimalFormatSymbols() {
initialize( Locale.getDefault(Locale.Category.FORMAT) );
@@ -133,6 +139,11 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
* as for those supported by installed
* {@link java.text.spi.DecimalFormatSymbolsProvider
* DecimalFormatSymbolsProvider} implementations.
+ *
This is equivalent to calling
+ * {@link #getInstance(Locale)
+ * getInstance(Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @return a DecimalFormatSymbols instance.
* @since 1.6
*/
diff --git a/src/share/classes/java/text/MessageFormat.java b/src/share/classes/java/text/MessageFormat.java
index e695b37a6793de1a1d0ec0d6756261cea79ae314..e5c8c811f046aa3bea71cfb5a72cad35dcdac7a4 100644
--- a/src/share/classes/java/text/MessageFormat.java
+++ b/src/share/classes/java/text/MessageFormat.java
@@ -348,7 +348,8 @@ public class MessageFormat extends Format {
private static final long serialVersionUID = 6479157306784022952L;
/**
- * Constructs a MessageFormat for the default locale and the
+ * Constructs a MessageFormat for the default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale and the
* specified pattern.
* The constructor first sets the locale, then parses the pattern and
* creates a list of subformats for the format elements contained in it.
diff --git a/src/share/classes/java/text/NumberFormat.java b/src/share/classes/java/text/NumberFormat.java
index eaed665e54c07874e92bd78f09118bb612dec091..c1b8310096b8ee512de4c3e56f8814a2914c42cc 100644
--- a/src/share/classes/java/text/NumberFormat.java
+++ b/src/share/classes/java/text/NumberFormat.java
@@ -389,7 +389,8 @@ public abstract class NumberFormat extends Format {
//============== Locale Stuff =====================
/**
- * Returns a general-purpose number format for the current default locale.
+ * Returns a general-purpose number format for the current default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
* This is the same as calling
* {@link #getNumberInstance() getNumberInstance()}.
*/
@@ -407,7 +408,13 @@ public abstract class NumberFormat extends Format {
}
/**
- * Returns a general-purpose number format for the current default locale.
+ * Returns a general-purpose number format for the current default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ *
This is equivalent to calling
+ * {@link #getNumberInstance(Locale)
+ * getNumberInstance(Locale.getDefault(Locale.Category.FORMAT))}.
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
*/
public final static NumberFormat getNumberInstance() {
return getInstance(Locale.getDefault(Locale.Category.FORMAT), NUMBERSTYLE);
@@ -421,14 +428,20 @@ public abstract class NumberFormat extends Format {
}
/**
- * Returns an integer number format for the current default locale. The
+ * Returns an integer number format for the current default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale. The
* returned number format is configured to round floating point numbers
* to the nearest integer using half-even rounding (see {@link
* java.math.RoundingMode#HALF_EVEN RoundingMode.HALF_EVEN}) for formatting,
* and to parse only the integer part of an input string (see {@link
* #isParseIntegerOnly isParseIntegerOnly}).
+ *
This is equivalent to calling
+ * {@link #getIntegerInstance(Locale)
+ * getIntegerInstance(Locale.getDefault(Locale.Category.FORMAT))}.
*
* @see #getRoundingMode()
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @return a number format for integer values
* @since 1.4
*/
@@ -453,7 +466,14 @@ public abstract class NumberFormat extends Format {
}
/**
- * Returns a currency format for the current default locale.
+ * Returns a currency format for the current default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ *
This is equivalent to calling
+ * {@link #getCurrencyInstance(Locale)
+ * getCurrencyInstance(Locale.getDefault(Locale.Category.FORMAT))}.
+ *
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
*/
public final static NumberFormat getCurrencyInstance() {
return getInstance(Locale.getDefault(Locale.Category.FORMAT), CURRENCYSTYLE);
@@ -467,7 +487,14 @@ public abstract class NumberFormat extends Format {
}
/**
- * Returns a percentage format for the current default locale.
+ * Returns a percentage format for the current default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
+ *
This is equivalent to calling
+ * {@link #getPercentInstance(Locale)
+ * getPercentInstance(Locale.getDefault(Locale.Category.FORMAT))}.
+ *
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
*/
public final static NumberFormat getPercentInstance() {
return getInstance(Locale.getDefault(Locale.Category.FORMAT), PERCENTSTYLE);
diff --git a/src/share/classes/java/text/SimpleDateFormat.java b/src/share/classes/java/text/SimpleDateFormat.java
index 0c1f4aa6a61d3f773acced6acb11280ce17e64f6..82b48964eeae113055d11dbbd4140cfe72ad5fa7 100644
--- a/src/share/classes/java/text/SimpleDateFormat.java
+++ b/src/share/classes/java/text/SimpleDateFormat.java
@@ -547,7 +547,8 @@ public class SimpleDateFormat extends DateFormat {
/**
* Constructs a SimpleDateFormat using the default pattern and
- * date format symbols for the default locale.
+ * date format symbols for the default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
* Note: This constructor may not support all locales.
* For full coverage, use the factory methods in the {@link DateFormat}
* class.
@@ -560,11 +561,17 @@ public class SimpleDateFormat extends DateFormat {
/**
* Constructs a SimpleDateFormat using the given pattern and
- * the default date format symbols for the default locale.
+ * the default date format symbols for the default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
* Note: This constructor may not support all locales.
* For full coverage, use the factory methods in the {@link DateFormat}
* class.
+ *
This is equivalent to calling
+ * {@link #SimpleDateFormat(String, Locale)
+ * SimpleDateFormat(pattern, Locale.getDefault(Locale.Category.FORMAT))}.
*
+ * @see java.util.Locale#getDefault(java.util.Locale.Category)
+ * @see java.util.Locale.Category#FORMAT
* @param pattern the pattern describing the date and time format
* @exception NullPointerException if the given pattern is null
* @exception IllegalArgumentException if the given pattern is invalid
diff --git a/src/share/classes/java/time/chrono/HijrahDeviationReader.java b/src/share/classes/java/time/chrono/HijrahDeviationReader.java
index 67495d040eb8ec1cdb5a08c98d025c233f23c98d..0c207af62bc007406d774ae86ec5535a131a496b 100644
--- a/src/share/classes/java/time/chrono/HijrahDeviationReader.java
+++ b/src/share/classes/java/time/chrono/HijrahDeviationReader.java
@@ -70,7 +70,7 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;
import java.util.Arrays;
-import java.util.function.Block;
+import java.util.function.Consumer;
/**
* A reader for Hijrah Deviation files.
@@ -126,13 +126,13 @@ final class HijrahDeviationReader {
* @param typeId the name of the calendar
* @param calendarType the calendar type
* @return {@code true} if the file was read and each entry accepted by the
- * Block; else {@code false} no configuration was done
+ * Consumer; else {@code false} no configuration was done
*
* @throws IOException for zip/jar file handling exception.
* @throws ParseException if the format of the configuration file is wrong.
*/
static boolean readDeviation(String typeId, String calendarType,
- Block block) throws IOException, ParseException {
+ Consumer consumer) throws IOException, ParseException {
InputStream is = getConfigFileInputStream(typeId);
if (is != null) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
@@ -142,7 +142,7 @@ final class HijrahDeviationReader {
num++;
HijrahChronology.Deviation entry = parseLine(line, num);
if (entry != null) {
- block.accept(entry);
+ consumer.accept(entry);
}
}
}
diff --git a/src/share/classes/java/time/format/DateTimeFormatSymbols.java b/src/share/classes/java/time/format/DateTimeFormatSymbols.java
index 14a116760f1ac008eeee19057d74c52fafe9c2c6..0bfe8441020b58a3d689019731bd58caae964aaa 100644
--- a/src/share/classes/java/time/format/DateTimeFormatSymbols.java
+++ b/src/share/classes/java/time/format/DateTimeFormatSymbols.java
@@ -121,10 +121,16 @@ public final class DateTimeFormatSymbols {
}
/**
- * Obtains symbols for the default locale.
+ * Obtains symbols for the default
+ * {@link java.util.Locale.Category#FORMAT FORMAT} locale.
*
* This method provides access to locale sensitive symbols.
+ *
+ * This is equivalent to calling
+ * {@link #of(Locale)
+ * of(Locale.getDefault(Locale.Category.FORMAT))}.
*
+ * @see java.util.Locale.Category#FORMAT
* @return the info, not null
*/
public static DateTimeFormatSymbols ofDefaultLocale() {
diff --git a/src/share/classes/java/time/format/DateTimeFormatterBuilder.java b/src/share/classes/java/time/format/DateTimeFormatterBuilder.java
index f2ed2317865348fa23940161b0f405901f2f94d5..e413d4b1e64aec622e695433141ca734ac938d13 100644
--- a/src/share/classes/java/time/format/DateTimeFormatterBuilder.java
+++ b/src/share/classes/java/time/format/DateTimeFormatterBuilder.java
@@ -1007,7 +1007,7 @@ public final class DateTimeFormatterBuilder {
* is used, with {@code IsoChronology} as the fallback.
*
* Note that this method provides similar functionality to methods on
- * {@code DateFormat} such as {@link DateFormat#getDateTimeInstance(int, int)}.
+ * {@code DateFormat} such as {@link java.text.DateFormat#getDateTimeInstance(int, int)}.
*
* @param dateStyle the date style to use, null means no date required
* @param timeStyle the time style to use, null means no time required
diff --git a/src/share/classes/java/util/Calendar.java b/src/share/classes/java/util/Calendar.java
index f14ee6d6ef47aa9f5f56929b315146b3579542cc..c57f50c59b3ffe4520496b386d99f59a6589f0f3 100644
--- a/src/share/classes/java/util/Calendar.java
+++ b/src/share/classes/java/util/Calendar.java
@@ -1572,7 +1572,8 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableCalendar returned is based on the current time
- * in the default time zone with the default locale.
+ * in the default time zone with the default
+ * {@link Locale.Category#FORMAT FORMAT} locale.
*
* @return a Calendar.
*/
@@ -1614,7 +1616,8 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableCalendar returned is based on the current time
- * in the given time zone with the default locale.
+ * in the given time zone with the default
+ * {@link Locale.Category#FORMAT FORMAT} locale.
*
* @param zone the time zone to use
* @return a Calendar.
diff --git a/src/share/classes/java/util/Collections.java b/src/share/classes/java/util/Collections.java
index 58eae6f950969366280567ddf9c3db7d2b597f5f..b6bac484daca4071f0e4e24e4bc19fc0304c43f7 100644
--- a/src/share/classes/java/util/Collections.java
+++ b/src/share/classes/java/util/Collections.java
@@ -3759,7 +3759,7 @@ public class Collections {
return c2.compareTo(c1);
}
- private Object readResolve() { return reverseOrder(); }
+ private Object readResolve() { return Collections.reverseOrder(); }
}
/**
diff --git a/src/share/classes/java/util/Comparator.java b/src/share/classes/java/util/Comparator.java
index 35ead373b821fe134236c2aeb10cedcc85f005a3..017c2e78e2ced52e4167a4328711c49264ebe0d7 100644
--- a/src/share/classes/java/util/Comparator.java
+++ b/src/share/classes/java/util/Comparator.java
@@ -25,6 +25,11 @@
package java.util;
+import java.util.function.Function;
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+import java.util.function.ToDoubleFunction;
+
/**
* A comparison function, which imposes a total ordering on some
* collection of objects. Comparators can be passed to a sort method (such
@@ -165,4 +170,93 @@ public interface Comparator {
* @see Object#hashCode()
*/
boolean equals(Object obj);
+
+ /**
+ * Returns a comparator that imposes the reverse ordering of this
+ * comparator.
+ *
+ * @return A comparator that imposes the reverse ordering of this
+ * comparator.
+ * @since 1.8
+ */
+ default Comparator reverseOrder() {
+ return Collections.reverseOrder(this);
+ }
+
+ /**
+ * Constructs a lexicographic order comparator with another comparator.
+ * For example, a {@code Comparator byLastName} can be composed
+ * with another {@code Comparator byFirstName}, then {@code
+ * byLastName.thenComparing(byFirstName)} creates a {@code
+ * Comparator} which sorts by last name, and for equal last names
+ * sorts by first name.
+ *
+ * @param other the other comparator used when equals on this.
+ * @throws NullPointerException if the argument is null.
+ * @since 1.8
+ */
+ default Comparator thenComparing(Comparator super T> other) {
+ return Comparators.compose(this, other);
+ }
+
+ /**
+ * Constructs a lexicographic order comparator with a function that
+ * extracts a {@code Comparable} key. This default implementation calls
+ * {@code thenComparing(this, Comparators.comparing(keyExtractor))}.
+ *
+ * @param the {@link Comparable} type for comparison
+ * @param keyExtractor the function used to extract the {@link Comparable} sort key
+ * @throws NullPointerException if the argument is null.
+ * @see Comparators#comparing(Function)
+ * @see #thenComparing(Comparator)
+ * @since 1.8
+ */
+ default > Comparator thenComparing(Function super T, ? extends U> keyExtractor) {
+ return thenComparing(Comparators.comparing(keyExtractor));
+ }
+
+ /**
+ * Constructs a lexicographic order comparator with a function that
+ * extracts a {@code int} value. This default implementation calls {@code
+ * thenComparing(this, Comparators.comparing(keyExtractor))}.
+ *
+ * @param keyExtractor the function used to extract the integer value
+ * @throws NullPointerException if the argument is null.
+ * @see Comparators#comparing(ToIntFunction)
+ * @see #thenComparing(Comparator)
+ * @since 1.8
+ */
+ default Comparator thenComparing(ToIntFunction super T> keyExtractor) {
+ return thenComparing(Comparators.comparing(keyExtractor));
+ }
+
+ /**
+ * Constructs a lexicographic order comparator with a function that
+ * extracts a {@code long} value. This default implementation calls
+ * {@code thenComparing(this, Comparators.comparing(keyExtractor))}.
+ *
+ * @param keyExtractor the function used to extract the long value
+ * @throws NullPointerException if the argument is null.
+ * @see Comparators#comparing(ToLongFunction)
+ * @see #thenComparing(Comparator)
+ * @since 1.8
+ */
+ default Comparator thenComparing(ToLongFunction super T> keyExtractor) {
+ return thenComparing(Comparators.comparing(keyExtractor));
+ }
+
+ /**
+ * Constructs a lexicographic order comparator with a function that
+ * extracts a {@code double} value. This default implementation calls
+ * {@code thenComparing(this, Comparators.comparing(keyExtractor))}.
+ *
+ * @param keyExtractor the function used to extract the double value
+ * @throws NullPointerException if the argument is null.
+ * @see Comparators#comparing(ToDoubleFunction)
+ * @see #thenComparing(Comparator)
+ * @since 1.8
+ */
+ default Comparator thenComparing(ToDoubleFunction super T> keyExtractor) {
+ return thenComparing(Comparators.comparing(keyExtractor));
+ }
}
diff --git a/src/share/classes/java/util/Comparators.java b/src/share/classes/java/util/Comparators.java
new file mode 100644
index 0000000000000000000000000000000000000000..75821339b49b5d6e2fe978a61cf60969f3e14bea
--- /dev/null
+++ b/src/share/classes/java/util/Comparators.java
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util;
+
+import java.io.Serializable;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.function.ToDoubleFunction;
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+
+/**
+ * This class consists of {@code static} utility methods for comparators. Mostly
+ * factory method that returns a {@link Comparator}.
+ *
+ *
Unless otherwise noted, passing a {@code null} argument to a method in
+ * this class will cause a {@link NullPointerException} to be thrown.
+ *
+ * @see Comparator
+ * @since 1.8
+ */
+public class Comparators {
+ private Comparators() {
+ throw new AssertionError("no instances");
+ }
+
+ /**
+ * Compares {@link Comparable} objects in natural order.
+ *
+ * @see Comparable
+ */
+ private enum NaturalOrderComparator implements Comparator> {
+ INSTANCE;
+
+ @Override
+ public int compare(Comparable