Merge
This commit is contained in:
commit
8f6d37ee8e
@ -31,13 +31,6 @@ BUILDDIR = ../..
|
||||
PRODUCT = sun
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
ifndef OPENJDK
|
||||
ORG_EXISTS := $(call DirExists,$(CLOSED_SRC)/share/classes/sun/org,,)
|
||||
ifneq ("$(ORG_EXISTS)", "")
|
||||
SCRIPT_SUBDIR = script
|
||||
endif
|
||||
endif
|
||||
|
||||
# jarsigner is part of JRE
|
||||
SUBDIRS = java security net/ssl jarsigner
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2005, 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.
|
||||
#
|
||||
|
||||
|
||||
BUILDDIR = ../../..
|
||||
PACKAGE = com.sun.script
|
||||
PRODUCT = sun
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
AUTO_FILES_JAVA_DIRS = com/sun/script
|
||||
|
||||
#
|
||||
# Files that need to be copied
|
||||
#
|
||||
SERVICEDIR = $(CLASSBINDIR)/META-INF/services
|
||||
|
||||
FILES_copy = \
|
||||
$(SERVICEDIR)/javax.script.ScriptEngineFactory
|
||||
|
||||
include $(BUILDDIR)/common/Classes.gmk
|
||||
|
||||
all: classes copy-files
|
||||
|
||||
#
|
||||
# Copy the service provider configuration file into the resource
|
||||
# directory.
|
||||
#
|
||||
|
||||
copy-files: $(FILES_copy)
|
||||
|
||||
$(SERVICEDIR)/%: $(SHARE_SRC)/classes/com/sun/script/javascript/META-INF/services/%
|
||||
$(install-file)
|
||||
|
||||
.PHONY: copy-files
|
||||
|
||||
|
||||
clean::
|
||||
$(RM) -r $(CLASSDESTDIR)/com/sun/script/javascript
|
||||
$(RM) $(FILES_copy)
|
||||
|
@ -969,26 +969,35 @@ else
|
||||
|
||||
# Create the list of db *.zip files to bundle with jdk
|
||||
ABS_DB_PATH :=$(call FullPath,$(CLOSED_SHARE_SRC)/db)
|
||||
DB_ZIP_LIST = $(shell $(LS) $(ABS_DB_PATH)/*.zip 2>/dev/null)
|
||||
DB_BINARY_BUNDLE = $(shell $(LS) $(ABS_DB_PATH)/db-derby-*-bin.zip 2>/dev/null)
|
||||
|
||||
# Java DB image. Move the Java DB demo directory into the JDK's demo
|
||||
# dir and in the process, rename it to db. Also remove index.html,
|
||||
# since it presumes docs are co-located. Also remove register.html (no
|
||||
# longer relevant).
|
||||
initial-image-jdk-db: $(DB_ZIP_LIST)
|
||||
# since it presumes docs are co-located, javadoc, docs and tests and
|
||||
# update the copyright year of the JDK READMEs to that of the release.
|
||||
initial-image-jdk-db: $(DB_BINARY_BUNDLE)
|
||||
$(MKDIR) -p $(JDK_IMAGE_DIR)/db
|
||||
for d in $(DB_ZIP_LIST); do \
|
||||
($(CD) $(JDK_IMAGE_DIR)/db && $(UNZIP) -o $$d); \
|
||||
done
|
||||
$(CP) $(ABS_DB_PATH)/README-JDK.html $(JDK_IMAGE_DIR)/db
|
||||
$(CD) $(JDK_IMAGE_DIR)/db && $(UNZIP) -o $(DB_BINARY_BUNDLE)
|
||||
$(CD) $(JDK_IMAGE_DIR)/db && $(MV) db-derby-*-bin/* .
|
||||
$(CD) $(JDK_IMAGE_DIR)/db && $(RM) -r db-derby-*-bin
|
||||
$(CAT) $(ABS_DB_PATH)/README-JDK.html | \
|
||||
$(SED) "s/XXXX/$(shell cat $(JDK_TOPDIR)/src/closed/share/db/COPYRIGHTYEAR)/" > \
|
||||
$(JDK_IMAGE_DIR)/db/README-JDK.html
|
||||
$(CAT) $(ABS_DB_PATH)/3RDPARTY | \
|
||||
$(SED) "s/XXXX/$(shell cat $(JDK_TOPDIR)/src/closed/share/db/COPYRIGHTYEAR)/" > \
|
||||
$(JDK_IMAGE_DIR)/db/3RDPARTY
|
||||
ifndef NO_DEMOS
|
||||
$(RM) -rf $(DEMODIR)/db
|
||||
$(RM) -r $(DEMODIR)/db
|
||||
$(MV) $(JDK_IMAGE_DIR)/db/demo $(DEMODIR)/db
|
||||
$(CP) $(ABS_DB_PATH)/README-JDK-DEMOS.html $(DEMODIR)/db/
|
||||
$(CAT) $(ABS_DB_PATH)/README-JDK-DEMOS.html | \
|
||||
$(SED) "s/XXXX/$(shell cat $(JDK_TOPDIR)/src/closed/share/db/COPYRIGHTYEAR)/" > \
|
||||
$(DEMODIR)/db/README-JDK-DEMOS.html
|
||||
else
|
||||
$(RM) -rf $(JDK_IMAGE_DIR)/db/demo
|
||||
$(RM) -r $(JDK_IMAGE_DIR)/db/demo
|
||||
endif
|
||||
$(RM) $(JDK_IMAGE_DIR)/db/index.html $(JDK_IMAGE_DIR)/db/register.html
|
||||
@# remove stuff from original distro we don't want
|
||||
$(RM) $(JDK_IMAGE_DIR)/db/index.html $(JDK_IMAGE_DIR)/db/KEYS
|
||||
$(RM) -r $(JDK_IMAGE_DIR)/db/{docs,javadoc,test}
|
||||
endif
|
||||
|
||||
# The launcher source files we need for src.zip
|
||||
|
@ -31,12 +31,6 @@ BUILDDIR = ..
|
||||
PRODUCT = sun
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
# Rhino/Mozilla java sources
|
||||
ORG_EXISTS := $(call DirExists,$(CLOSED_SRC)/share/classes/sun/org,,)
|
||||
ifneq ("$(ORG_EXISTS)", "")
|
||||
ORG_SUBDIR = org
|
||||
endif
|
||||
|
||||
# Non windows subdirs
|
||||
ifneq ($(PLATFORM), windows)
|
||||
ifndef OPENJDK
|
||||
@ -83,7 +77,7 @@ SUBDIRS_desktop = audio $(RENDER_SUBDIR) image \
|
||||
$(LWAWT_PRE_SUBDIR) $(DISPLAY_LIBS) $(DGA_SUBDIR) $(LWAWT_SUBDIR) \
|
||||
jawt font jpeg cmm $(DISPLAY_TOOLS)
|
||||
SUBDIRS_management = management
|
||||
SUBDIRS_misc = $(ORG_SUBDIR) rmi tracing
|
||||
SUBDIRS_misc = rmi tracing
|
||||
SUBDIRS_tools = native2ascii serialver tools jconsole
|
||||
|
||||
ifndef OPENJDK
|
||||
|
@ -21,4 +21,4 @@
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
tzdata2012i
|
||||
tzdata2013c
|
||||
|
@ -27,9 +27,9 @@
|
||||
|
||||
# This data is by no means authoritative; if you think you know better,
|
||||
# go ahead and edit the file (and please send any changes to
|
||||
# tz@elsie.nci.nih.gov for general use in the future).
|
||||
# tz@iana.org for general use in the future).
|
||||
|
||||
# From Paul Eggert (2006-03-22):
|
||||
# From Paul Eggert (2013-02-21):
|
||||
#
|
||||
# A good source for time zone historical data outside the U.S. is
|
||||
# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
|
||||
@ -48,6 +48,10 @@
|
||||
# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
|
||||
# I found in the UCLA library.
|
||||
#
|
||||
# For data circa 1899, a common source is:
|
||||
# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
|
||||
# <http://www.jstor.org/stable/1774359>.
|
||||
#
|
||||
# A reliable and entertaining source about time zones is
|
||||
# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
|
||||
#
|
||||
@ -139,8 +143,12 @@ Zone Africa/Porto-Novo 0:10:28 - LMT 1912
|
||||
1:00 - WAT
|
||||
|
||||
# Botswana
|
||||
# From Paul Eggert (2013-02-21):
|
||||
# Milne says they were regulated by the Cape Town Signal in 1899;
|
||||
# assume they switched to 2:00 when Cape Town did.
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Africa/Gaborone 1:43:40 - LMT 1885
|
||||
1:30 - SAST 1903 Mar
|
||||
2:00 - CAT 1943 Sep 19 2:00
|
||||
2:00 1:00 CAST 1944 Mar 19 2:00
|
||||
2:00 - CAT
|
||||
@ -212,6 +220,11 @@ Zone Africa/Djibouti 2:52:36 - LMT 1911 Jul
|
||||
|
||||
# Egypt
|
||||
|
||||
# Milne says Cairo used 2:05:08.9, the local mean time of the Abbasizeh
|
||||
# observatory; round to nearest. Milne also says that the official time for
|
||||
# Egypt was mean noon at the Great Pyramid, 2:04:30.5, but apparently this
|
||||
# did not apply to Cairo, Alexandria, or Port Said.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Egypt 1940 only - Jul 15 0:00 1:00 S
|
||||
Rule Egypt 1940 only - Oct 1 0:00 0 -
|
||||
@ -352,7 +365,7 @@ Rule Egypt 2010 only - Sep 10 0:00 1:00 S
|
||||
Rule Egypt 2010 only - Sep lastThu 23:00s 0 -
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Africa/Cairo 2:05:00 - LMT 1900 Oct
|
||||
Zone Africa/Cairo 2:05:09 - LMT 1900 Oct
|
||||
2:00 Egypt EE%sT
|
||||
|
||||
# Equatorial Guinea
|
||||
@ -447,6 +460,20 @@ Zone Africa/Monrovia -0:43:08 - LMT 1882
|
||||
|
||||
# Libya
|
||||
|
||||
# From Even Scharning (2012-11-10):
|
||||
# Libya set their time one hour back at 02:00 on Saturday November 10.
|
||||
# http://www.libyaherald.com/2012/11/04/clocks-to-go-back-an-hour-on-saturday/
|
||||
# Here is an official source [in Arabic]: http://ls.ly/fb6Yc
|
||||
#
|
||||
# Steffen Thorsen forwarded a translation (2012-11-10) in
|
||||
# http://mm.icann.org/pipermail/tz/2012-November/018451.html
|
||||
#
|
||||
# From Tim Parenti (2012-11-11):
|
||||
# Treat the 2012-11-10 change as a zone change from UTC+2 to UTC+1.
|
||||
# The DST rules planned for 2013 and onward roughly mirror those of Europe
|
||||
# (either two days before them or five days after them, so as to fall on
|
||||
# lastFri instead of lastSun).
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Libya 1951 only - Oct 14 2:00 1:00 S
|
||||
Rule Libya 1952 only - Jan 1 0:00 0 -
|
||||
@ -461,17 +488,21 @@ Rule Libya 1986 only - Apr 4 0:00 1:00 S
|
||||
Rule Libya 1986 only - Oct 3 0:00 0 -
|
||||
Rule Libya 1987 1989 - Apr 1 0:00 1:00 S
|
||||
Rule Libya 1987 1989 - Oct 1 0:00 0 -
|
||||
Rule Libya 1997 only - Apr 4 0:00 1:00 S
|
||||
Rule Libya 1997 only - Oct 4 0:00 0 -
|
||||
Rule Libya 2013 max - Mar lastFri 1:00 1:00 S
|
||||
Rule Libya 2013 max - Oct lastFri 2:00 0 -
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Africa/Tripoli 0:52:44 - LMT 1920
|
||||
1:00 Libya CE%sT 1959
|
||||
2:00 - EET 1982
|
||||
1:00 Libya CE%sT 1990 May 4
|
||||
# The following entries are from Shanks & Pottenger;
|
||||
# The 1996 and 1997 entries are from Shanks & Pottenger;
|
||||
# the IATA SSIM data contain some obvious errors.
|
||||
2:00 - EET 1996 Sep 30
|
||||
1:00 - CET 1997 Apr 4
|
||||
1:00 1:00 CEST 1997 Oct 4
|
||||
2:00 - EET
|
||||
1:00 Libya CE%sT 1997 Oct 4
|
||||
2:00 - EET 2012 Nov 10 2:00
|
||||
1:00 Libya CE%sT
|
||||
|
||||
# Madagascar
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
@ -838,6 +869,41 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou
|
||||
# 3:00 am Friday, July 20, 2012 and will again be advanced by 60 minutes
|
||||
# August 20, 2012 from 2:00 am.
|
||||
|
||||
# From Paul Eggert (2013-03-06):
|
||||
# Morocco's daylight-saving transitions due to Ramadan seem to be
|
||||
# announced a bit in advance. On 2012-07-11 the Moroccan government
|
||||
# announced that year's Ramadan daylight-saving transitions would be
|
||||
# 2012-07-20 and 2012-08-20; see
|
||||
# <http://www.mmsp.gov.ma/fr/actualites.aspx?id=288>.
|
||||
#
|
||||
# To estimate what the Moroccan government will do in future years,
|
||||
# transition dates for 2013 through 2021 were determined by running
|
||||
# the following program under GNU Emacs 24.3:
|
||||
#
|
||||
# (let ((islamic-year 1434))
|
||||
# (while (< islamic-year 1444)
|
||||
# (let ((a
|
||||
# (calendar-gregorian-from-absolute
|
||||
# (calendar-islamic-to-absolute (list 9 1 islamic-year))))
|
||||
# (b
|
||||
# (calendar-gregorian-from-absolute
|
||||
# (calendar-islamic-to-absolute (list 10 1 islamic-year)))))
|
||||
# (insert
|
||||
# (format
|
||||
# (concat "Rule\tMorocco\t%d\tonly\t-\t%s\t %2d\t 3:00\t0\t-\n"
|
||||
# "Rule\tMorocco\t%d\tonly\t-\t%s\t %2d\t 2:00\t1:00\tS\n")
|
||||
# (car (cdr (cdr a))) (calendar-month-name (car a) t) (car (cdr a))
|
||||
# (car (cdr (cdr b))) (calendar-month-name (car b) t) (car (cdr b)))))
|
||||
# (setq islamic-year (+ 1 islamic-year))))
|
||||
#
|
||||
# with the results hand-edited for 2020-2022, when the normal spring-forward
|
||||
# date falls during the estimated Ramadan.
|
||||
#
|
||||
# From 2023 through 2038 Ramadan is not predicted to overlap with
|
||||
# daylight saving time. Starting in 2039 there will be overlap again,
|
||||
# but 32-bit time_t values roll around in 2038 so for now do not worry
|
||||
# about dates after 2038.
|
||||
|
||||
# RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
|
||||
Rule Morocco 1939 only - Sep 12 0:00 1:00 S
|
||||
@ -863,10 +929,28 @@ Rule Morocco 2010 only - May 2 0:00 1:00 S
|
||||
Rule Morocco 2010 only - Aug 8 0:00 0 -
|
||||
Rule Morocco 2011 only - Apr 3 0:00 1:00 S
|
||||
Rule Morocco 2011 only - Jul 31 0 0 -
|
||||
Rule Morocco 2012 max - Apr lastSun 2:00 1:00 S
|
||||
Rule Morocco 2012 2019 - Apr lastSun 2:00 1:00 S
|
||||
Rule Morocco 2012 max - Sep lastSun 3:00 0 -
|
||||
Rule Morocco 2012 only - Jul 20 3:00 0 -
|
||||
Rule Morocco 2012 only - Aug 20 2:00 1:00 S
|
||||
Rule Morocco 2013 only - Jul 9 3:00 0 -
|
||||
Rule Morocco 2013 only - Aug 8 2:00 1:00 S
|
||||
Rule Morocco 2014 only - Jun 29 3:00 0 -
|
||||
Rule Morocco 2014 only - Jul 29 2:00 1:00 S
|
||||
Rule Morocco 2015 only - Jun 18 3:00 0 -
|
||||
Rule Morocco 2015 only - Jul 18 2:00 1:00 S
|
||||
Rule Morocco 2016 only - Jun 7 3:00 0 -
|
||||
Rule Morocco 2016 only - Jul 7 2:00 1:00 S
|
||||
Rule Morocco 2017 only - May 27 3:00 0 -
|
||||
Rule Morocco 2017 only - Jun 26 2:00 1:00 S
|
||||
Rule Morocco 2018 only - May 16 3:00 0 -
|
||||
Rule Morocco 2018 only - Jun 15 2:00 1:00 S
|
||||
Rule Morocco 2019 only - May 6 3:00 0 -
|
||||
Rule Morocco 2019 only - Jun 5 2:00 1:00 S
|
||||
Rule Morocco 2020 only - May 24 2:00 1:00 S
|
||||
Rule Morocco 2021 only - May 13 2:00 1:00 S
|
||||
Rule Morocco 2022 only - May 3 2:00 1:00 S
|
||||
Rule Morocco 2023 max - Apr lastSun 2:00 1:00 S
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26
|
||||
|
@ -73,38 +73,8 @@ Rule ChileAQ 2009 only - Mar Sun>=9 3:00u 0 -
|
||||
Rule ChileAQ 2010 only - Apr Sun>=1 3:00u 0 -
|
||||
Rule ChileAQ 2011 only - May Sun>=2 3:00u 0 -
|
||||
Rule ChileAQ 2011 only - Aug Sun>=16 4:00u 1:00 S
|
||||
Rule ChileAQ 2012 only - Apr Sun>=23 3:00u 0 -
|
||||
Rule ChileAQ 2012 only - Sep Sun>=2 4:00u 1:00 S
|
||||
Rule ChileAQ 2013 max - Mar Sun>=9 3:00u 0 -
|
||||
Rule ChileAQ 2013 max - Oct Sun>=9 4:00u 1:00 S
|
||||
|
||||
# These rules are stolen from the `australasia' file.
|
||||
Rule AusAQ 1917 only - Jan 1 0:01 1:00 -
|
||||
Rule AusAQ 1917 only - Mar 25 2:00 0 -
|
||||
Rule AusAQ 1942 only - Jan 1 2:00 1:00 -
|
||||
Rule AusAQ 1942 only - Mar 29 2:00 0 -
|
||||
Rule AusAQ 1942 only - Sep 27 2:00 1:00 -
|
||||
Rule AusAQ 1943 1944 - Mar lastSun 2:00 0 -
|
||||
Rule AusAQ 1943 only - Oct 3 2:00 1:00 -
|
||||
Rule ATAQ 1967 only - Oct Sun>=1 2:00s 1:00 -
|
||||
Rule ATAQ 1968 only - Mar lastSun 2:00s 0 -
|
||||
Rule ATAQ 1968 1985 - Oct lastSun 2:00s 1:00 -
|
||||
Rule ATAQ 1969 1971 - Mar Sun>=8 2:00s 0 -
|
||||
Rule ATAQ 1972 only - Feb lastSun 2:00s 0 -
|
||||
Rule ATAQ 1973 1981 - Mar Sun>=1 2:00s 0 -
|
||||
Rule ATAQ 1982 1983 - Mar lastSun 2:00s 0 -
|
||||
Rule ATAQ 1984 1986 - Mar Sun>=1 2:00s 0 -
|
||||
Rule ATAQ 1986 only - Oct Sun>=15 2:00s 1:00 -
|
||||
Rule ATAQ 1987 1990 - Mar Sun>=15 2:00s 0 -
|
||||
Rule ATAQ 1987 only - Oct Sun>=22 2:00s 1:00 -
|
||||
Rule ATAQ 1988 1990 - Oct lastSun 2:00s 1:00 -
|
||||
Rule ATAQ 1991 1999 - Oct Sun>=1 2:00s 1:00 -
|
||||
Rule ATAQ 1991 2005 - Mar lastSun 2:00s 0 -
|
||||
Rule ATAQ 2000 only - Aug lastSun 2:00s 1:00 -
|
||||
Rule ATAQ 2001 max - Oct Sun>=1 2:00s 1:00 -
|
||||
Rule ATAQ 2006 only - Apr Sun>=1 2:00s 0 -
|
||||
Rule ATAQ 2007 only - Mar lastSun 2:00s 0 -
|
||||
Rule ATAQ 2008 max - Apr Sun>=1 2:00s 0 -
|
||||
Rule ChileAQ 2012 max - Apr Sun>=23 3:00u 0 -
|
||||
Rule ChileAQ 2012 max - Sep Sun>=2 4:00u 1:00 S
|
||||
|
||||
# Argentina - year-round bases
|
||||
# Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05
|
||||
@ -147,10 +117,7 @@ Rule ATAQ 2008 max - Apr Sun>=1 2:00s 0 -
|
||||
# </a>
|
||||
|
||||
# From Steffen Thorsen (2010-03-10):
|
||||
# We got these changes from the Australian Antarctic Division:
|
||||
# - Macquarie Island will stay on UTC+11 for winter and therefore not
|
||||
# switch back from daylight savings time when other parts of Australia do
|
||||
# on 4 April.
|
||||
# We got these changes from the Australian Antarctic Division: ...
|
||||
#
|
||||
# - Casey station reverted to its normal time of UTC+8 on 5 March 2010.
|
||||
# The change to UTC+11 is being considered as a regular summer thing but
|
||||
@ -161,9 +128,6 @@ Rule ATAQ 2008 max - Apr Sun>=1 2:00s 0 -
|
||||
#
|
||||
# - Mawson station stays on UTC+5.
|
||||
#
|
||||
# In addition to the Rule changes for Casey/Davis, it means that Macquarie
|
||||
# will no longer be like Hobart and will have to have its own Zone created.
|
||||
#
|
||||
# Background:
|
||||
# <a href="http://www.timeanddate.com/news/time/antartica-time-changes-2010.html">
|
||||
# http://www.timeanddate.com/news/time/antartica-time-changes-2010.html
|
||||
@ -190,12 +154,6 @@ Zone Antarctica/Mawson 0 - zzz 1954 Feb 13
|
||||
6:00 - MAWT 2009 Oct 18 2:00
|
||||
# Mawson Time
|
||||
5:00 - MAWT
|
||||
Zone Antarctica/Macquarie 0 - zzz 1911
|
||||
10:00 - EST 1916 Oct 1 2:00
|
||||
10:00 1:00 EST 1917 Feb
|
||||
10:00 AusAQ EST 1967
|
||||
10:00 ATAQ EST 2010 Apr 4 3:00
|
||||
11:00 - MIST # Macquarie Island Time
|
||||
# References:
|
||||
# <a href="http://www.antdiv.gov.au/aad/exop/sfo/casey/casey_aws.html">
|
||||
# Casey Weather (1998-02-26)
|
||||
|
@ -27,9 +27,9 @@
|
||||
|
||||
# This data is by no means authoritative; if you think you know better,
|
||||
# go ahead and edit the file (and please send any changes to
|
||||
# tz@elsie.nci.nih.gov for general use in the future).
|
||||
# tz@iana.org for general use in the future).
|
||||
|
||||
# From Paul Eggert (2006-03-22):
|
||||
# From Paul Eggert (2013-02-21):
|
||||
#
|
||||
# A good source for time zone historical data outside the U.S. is
|
||||
# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
|
||||
@ -48,6 +48,10 @@
|
||||
# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
|
||||
# I found in the UCLA library.
|
||||
#
|
||||
# For data circa 1899, a common source is:
|
||||
# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
|
||||
# <http://www.jstor.org/stable/1774359>.
|
||||
#
|
||||
# A reliable and entertaining source about time zones is
|
||||
# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
|
||||
#
|
||||
@ -302,9 +306,12 @@ Zone Asia/Brunei 7:39:40 - LMT 1926 Mar # Bandar Seri Begawan
|
||||
8:00 - BNT
|
||||
|
||||
# Burma / Myanmar
|
||||
|
||||
# Milne says 6:24:40 was the meridian of the time ball observatory at Rangoon.
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Asia/Rangoon 6:24:40 - LMT 1880 # or Yangon
|
||||
6:24:36 - RMT 1920 # Rangoon Mean Time?
|
||||
6:24:40 - RMT 1920 # Rangoon Mean Time?
|
||||
6:30 - BURT 1942 May # Burma Time
|
||||
9:00 - JST 1945 May 3
|
||||
6:30 - MMT # Myanmar Time
|
||||
@ -407,7 +414,8 @@ Zone Asia/Harbin 8:26:44 - LMT 1928 # or Haerbin
|
||||
8:00 PRC C%sT
|
||||
# Zhongyuan Time ("Central plain Time")
|
||||
# most of China
|
||||
Zone Asia/Shanghai 8:05:52 - LMT 1928
|
||||
# Milne gives 8:05:56.7; round to nearest.
|
||||
Zone Asia/Shanghai 8:05:57 - LMT 1928
|
||||
8:00 Shang C%sT 1949
|
||||
8:00 PRC C%sT
|
||||
# Long-shu Time (probably due to Long and Shu being two names of that area)
|
||||
@ -504,6 +512,10 @@ Zone Asia/Kashgar 5:03:56 - LMT 1928 # or Kashi or Kaxgar
|
||||
8:00 PRC C%sT
|
||||
|
||||
|
||||
# Hong Kong (Xianggang)
|
||||
|
||||
# Milne gives 7:36:41.7; round this.
|
||||
|
||||
# From Lee Yiu Chung (2009-10-24):
|
||||
# I found there are some mistakes for the...DST rule for Hong
|
||||
# Kong. [According] to the DST record from Hong Kong Observatory (actually,
|
||||
@ -570,7 +582,6 @@ Zone Asia/Kashgar 5:03:56 - LMT 1928 # or Kashi or Kaxgar
|
||||
# The Japanese surrender of Hong Kong was signed 1945-09-15.
|
||||
# For lack of anything better, use start of those days as the transition times.
|
||||
|
||||
# Hong Kong (Xianggang)
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule HK 1941 only - Apr 1 3:30 1:00 S
|
||||
Rule HK 1941 only - Sep 30 3:30 0 -
|
||||
@ -592,7 +603,7 @@ Rule HK 1973 only - Dec 30 3:30 1:00 S
|
||||
Rule HK 1979 only - May Sun>=8 3:30 1:00 S
|
||||
Rule HK 1979 only - Oct Sun>=16 3:30 0 -
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Asia/Hong_Kong 7:36:36 - LMT 1904 Oct 30
|
||||
Zone Asia/Hong_Kong 7:36:42 - LMT 1904 Oct 30
|
||||
8:00 HK HK%sT 1941 Dec 25
|
||||
9:00 - JST 1945 Sep 15
|
||||
8:00 HK HK%sT
|
||||
@ -669,6 +680,9 @@ Zone Asia/Macau 7:34:20 - LMT 1912
|
||||
###############################################################################
|
||||
|
||||
# Cyprus
|
||||
#
|
||||
# Milne says the Eastern Telegraph Company used 2:14:00. Stick with LMT.
|
||||
#
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Cyprus 1975 only - Apr 13 0:00 1:00 S
|
||||
Rule Cyprus 1975 only - Oct 12 0:00 0 -
|
||||
@ -1222,7 +1236,6 @@ Rule Zion 2012 only - Mar Fri>=26 2:00 1:00 D
|
||||
Rule Zion 2012 only - Sep 23 2:00 0 S
|
||||
|
||||
# From Ephraim Silverberg (2012-10-18):
|
||||
|
||||
# Yesterday, the Interior Ministry Committee, after more than a year
|
||||
# past, approved sending the proposed June 2011 changes to the Time
|
||||
# Decree Law back to the Knesset for second and third (final) votes
|
||||
@ -1235,6 +1248,10 @@ Rule Zion 2012 only - Sep 23 2:00 0 S
|
||||
# later (i.e. at 02:00 the first Monday after October 2).
|
||||
# [Rosh Hashana holidays are factored in until 2100.]
|
||||
|
||||
# From Ephraim Silverberg (2012-11-05):
|
||||
# The Knesset passed today (in second and final readings) the amendment to the
|
||||
# Time Decree Law making the changes ... law.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Zion 2013 max - Mar Fri>=23 2:00 1:00 D
|
||||
Rule Zion 2013 2026 - Oct Sun>=2 2:00 0 S
|
||||
@ -1824,8 +1841,11 @@ Zone Asia/Kathmandu 5:41:16 - LMT 1920
|
||||
5:45 - NPT # Nepal Time
|
||||
|
||||
# Oman
|
||||
|
||||
# Milne says 3:54:24 was the meridian of the Muscat Tidal Observatory.
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Asia/Muscat 3:54:20 - LMT 1920
|
||||
Zone Asia/Muscat 3:54:24 - LMT 1920
|
||||
4:00 - GST
|
||||
|
||||
# Pakistan
|
||||
@ -2072,8 +2092,7 @@ Zone Asia/Karachi 4:28:12 - LMT 1907
|
||||
# occurred before our cutoff date of 1970.
|
||||
# However, as we get more information, we may need to add entries
|
||||
# for parts of the West Bank as they transitioned from Israel's rules
|
||||
# to Palestine's rules. If you have more info about this, please
|
||||
# send it to tz@elsie.nci.nih.gov for incorporation into future editions.
|
||||
# to Palestine's rules.
|
||||
|
||||
# From IINS News Service - Israel - 1998-03-23 10:38:07 Israel time,
|
||||
# forwarded by Ephraim Silverberg:
|
||||
@ -2295,11 +2314,20 @@ Zone Asia/Karachi 4:28:12 - LMT 1907
|
||||
# http://www.timeanddate.com/news/time/gaza-west-bank-dst-2012.html
|
||||
# </a>
|
||||
|
||||
# From Arthur David Olson (2012-03-27):
|
||||
# The timeanddate article for 2012 says that "the end date has not yet been
|
||||
# announced" and that "Last year, both...paused daylight saving time during...
|
||||
# Ramadan. It is not yet known [for] 2012."
|
||||
# For now, assume both switch back on the last Friday in September. XXX
|
||||
# From Steffen Thorsen (2013-03-26):
|
||||
# The following news sources tells that Palestine will "start daylight saving
|
||||
# time from midnight on Friday, March 29, 2013" (translated).
|
||||
# [These are in Arabic and are for Gaza and for Ramallah, respectively.]
|
||||
# http://www.samanews.com/index.php?act=Show&id=154120
|
||||
# http://safa.ps/details/news/99844/%D8%B1%D8%A7%D9%85-%D8%A7%D9%84%D9%84%D9%87-%D8%A8%D8%AF%D8%A1-%D8%A7%D9%84%D8%AA%D9%88%D9%82%D9%8A%D8%AA-%D8%A7%D9%84%D8%B5%D9%8A%D9%81%D9%8A-29-%D8%A7%D9%84%D8%AC%D8%A7%D8%B1%D9%8A.html
|
||||
|
||||
# From Paul Eggert (2013-04-15):
|
||||
# For future dates, guess the last Thursday in March at 24:00 through
|
||||
# the first Friday on or after September 21 at 01:00. This is consistent with
|
||||
# the predictions in today's editions of the following URLs,
|
||||
# which are for Gaza and Hebron respectively:
|
||||
# http://www.timeanddate.com/worldclock/timezone.html?n=702
|
||||
# http://www.timeanddate.com/worldclock/timezone.html?n=2364
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule EgyptAsia 1957 only - May 10 0:00 1:00 S
|
||||
@ -2313,19 +2341,20 @@ Rule Palestine 1999 2005 - Apr Fri>=15 0:00 1:00 S
|
||||
Rule Palestine 1999 2003 - Oct Fri>=15 0:00 0 -
|
||||
Rule Palestine 2004 only - Oct 1 1:00 0 -
|
||||
Rule Palestine 2005 only - Oct 4 2:00 0 -
|
||||
Rule Palestine 2006 2008 - Apr 1 0:00 1:00 S
|
||||
Rule Palestine 2006 2007 - Apr 1 0:00 1:00 S
|
||||
Rule Palestine 2006 only - Sep 22 0:00 0 -
|
||||
Rule Palestine 2007 only - Sep Thu>=8 2:00 0 -
|
||||
Rule Palestine 2008 only - Aug lastFri 0:00 0 -
|
||||
Rule Palestine 2009 only - Mar lastFri 0:00 1:00 S
|
||||
Rule Palestine 2009 only - Sep Fri>=1 2:00 0 -
|
||||
Rule Palestine 2010 only - Mar lastSat 0:01 1:00 S
|
||||
Rule Palestine 2008 2009 - Mar lastFri 0:00 1:00 S
|
||||
Rule Palestine 2008 only - Sep 1 0:00 0 -
|
||||
Rule Palestine 2009 only - Sep Fri>=1 1:00 0 -
|
||||
Rule Palestine 2010 only - Mar 26 0:00 1:00 S
|
||||
Rule Palestine 2010 only - Aug 11 0:00 0 -
|
||||
|
||||
# From Arthur David Olson (2011-09-20):
|
||||
# 2011 transitions per http://www.timeanddate.com as of 2011-09-20.
|
||||
# From Paul Eggert (2012-10-12):
|
||||
# 2012 transitions per http://www.timeanddate.com as of 2012-10-12.
|
||||
Rule Palestine 2011 only - Apr 1 0:01 1:00 S
|
||||
Rule Palestine 2011 only - Aug 1 0:00 0 -
|
||||
Rule Palestine 2011 only - Aug 30 0:00 1:00 S
|
||||
Rule Palestine 2011 only - Sep 30 0:00 0 -
|
||||
Rule Palestine 2012 max - Mar lastThu 24:00 1:00 S
|
||||
Rule Palestine 2012 max - Sep Fri>=21 1:00 0 -
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Asia/Gaza 2:17:52 - LMT 1900 Oct
|
||||
@ -2333,26 +2362,20 @@ Zone Asia/Gaza 2:17:52 - LMT 1900 Oct
|
||||
2:00 EgyptAsia EE%sT 1967 Jun 5
|
||||
2:00 Zion I%sT 1996
|
||||
2:00 Jordan EE%sT 1999
|
||||
2:00 Palestine EE%sT 2011 Apr 2 12:01
|
||||
2:00 1:00 EEST 2011 Aug 1
|
||||
2:00 - EET 2012 Mar 30
|
||||
2:00 1:00 EEST 2012 Sep 21 1:00
|
||||
2:00 - EET
|
||||
2:00 Palestine EE%sT 2008 Aug 29 0:00
|
||||
2:00 - EET 2008 Sep
|
||||
2:00 Palestine EE%sT 2010
|
||||
2:00 - EET 2010 Mar 27 0:01
|
||||
2:00 Palestine EE%sT 2011 Aug 1
|
||||
2:00 - EET 2012
|
||||
2:00 Palestine EE%sT
|
||||
|
||||
Zone Asia/Hebron 2:20:23 - LMT 1900 Oct
|
||||
2:00 Zion EET 1948 May 15
|
||||
2:00 EgyptAsia EE%sT 1967 Jun 5
|
||||
2:00 Zion I%sT 1996
|
||||
2:00 Jordan EE%sT 1999
|
||||
2:00 Palestine EE%sT 2008 Aug
|
||||
2:00 1:00 EEST 2008 Sep
|
||||
2:00 Palestine EE%sT 2011 Apr 1 12:01
|
||||
2:00 1:00 EEST 2011 Aug 1
|
||||
2:00 - EET 2011 Aug 30
|
||||
2:00 1:00 EEST 2011 Sep 30 3:00
|
||||
2:00 - EET 2012 Mar 30
|
||||
2:00 1:00 EEST 2012 Sep 21 1:00
|
||||
2:00 - EET
|
||||
2:00 Palestine EE%sT
|
||||
|
||||
# Paracel Is
|
||||
# no information
|
||||
@ -2421,6 +2444,13 @@ Zone Asia/Singapore 6:55:25 - LMT 1901 Jan 1
|
||||
# no information
|
||||
|
||||
# Sri Lanka
|
||||
|
||||
# From Paul Eggert (2013-02-21):
|
||||
# Milne says "Madras mean time use from May 1, 1898. Prior to this Colombo
|
||||
# mean time, 5h. 4m. 21.9s. F., was used." But 5:04:21.9 differs considerably
|
||||
# from Colombo's meridian 5:19:24, so for now ignore Milne and stick with
|
||||
# Shanks and Pottenger.
|
||||
|
||||
# From Paul Eggert (1996-09-03):
|
||||
# "Sri Lanka advances clock by an hour to avoid blackout"
|
||||
# (www.virtual-pc.com/lankaweb/news/items/240596-2.html, 1996-05-24,
|
||||
@ -2720,6 +2750,12 @@ Zone Asia/Tashkent 4:37:12 - LMT 1924 May 2
|
||||
|
||||
# Vietnam
|
||||
|
||||
# From Paul Eggert (2013-02-21):
|
||||
# Milne gives 7:16:56 for the meridian of Saigon in 1899, as being
|
||||
# used in Lower Laos, Cambodia, and Annam. But this is quite a ways
|
||||
# from Saigon's location. For now, ignore this and stick with Shanks
|
||||
# and Pottenger.
|
||||
|
||||
# From Arthur David Olson (2008-03-18):
|
||||
# The English-language name of Vietnam's most populous city is "Ho Chi Min City";
|
||||
# we use Ho_Chi_Minh below to avoid a name of more than 14 characters.
|
||||
@ -2733,6 +2769,10 @@ Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jun 9
|
||||
7:00 - ICT
|
||||
|
||||
# Yemen
|
||||
|
||||
# Milne says 2:59:54 was the meridian of the saluting battery at Aden,
|
||||
# and that Yemen was at 1:55:56, the meridian of the Hagia Sophia.
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Asia/Aden 3:00:48 - LMT 1950
|
||||
Zone Asia/Aden 2:59:54 - LMT 1950
|
||||
3:00 - AST
|
||||
|
@ -241,9 +241,26 @@ Zone Australia/Lord_Howe 10:36:20 - LMT 1895 Feb
|
||||
# no times are set
|
||||
#
|
||||
# Macquarie
|
||||
# permanent occupation (scientific station) since 1948;
|
||||
# sealing and penguin oil station operated 1888/1917
|
||||
# like Australia/Hobart
|
||||
# Permanent occupation (scientific station) 1911-1915 and since 25 March 1948;
|
||||
# sealing and penguin oil station operated Nov 1899 to Apr 1919. See the
|
||||
# Tasmania Parks & Wildlife Service history of sealing at Macquarie Island
|
||||
# <http://www.parks.tas.gov.au/index.aspx?base=1828>
|
||||
# <http://www.parks.tas.gov.au/index.aspx?base=1831>.
|
||||
# Guess that it was like Australia/Hobart while inhabited before 2010.
|
||||
#
|
||||
# From Steffen Thorsen (2010-03-10):
|
||||
# We got these changes from the Australian Antarctic Division:
|
||||
# - Macquarie Island will stay on UTC+11 for winter and therefore not
|
||||
# switch back from daylight savings time when other parts of Australia do
|
||||
# on 4 April.
|
||||
Zone Antarctica/Macquarie 0 - zzz 1899 Nov
|
||||
10:00 - EST 1916 Oct 1 2:00
|
||||
10:00 1:00 EST 1917 Feb
|
||||
10:00 Aus EST 1919 Apr
|
||||
0 - zzz 1948 Mar 25
|
||||
10:00 Aus EST 1967
|
||||
10:00 AT EST 2010 Apr 4 3:00
|
||||
11:00 - MIST # Macquarie I Standard Time
|
||||
|
||||
# Christmas
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
@ -269,6 +286,9 @@ Zone Indian/Cocos 6:27:40 - LMT 1900
|
||||
6:30 - CCT # Cocos Islands Time
|
||||
|
||||
# Fiji
|
||||
|
||||
# Milne gives 11:55:44 for Suva.
|
||||
|
||||
# From Alexander Krivenyshev (2009-11-10):
|
||||
# According to Fiji Broadcasting Corporation, Fiji plans to re-introduce DST
|
||||
# from November 29th 2009 to April 25th 2010.
|
||||
@ -362,7 +382,7 @@ Rule Fiji 2010 max - Oct Sun>=18 2:00 1:00 S
|
||||
Rule Fiji 2011 only - Mar Sun>=1 3:00 0 -
|
||||
Rule Fiji 2012 max - Jan Sun>=18 3:00 0 -
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Pacific/Fiji 11:53:40 - LMT 1915 Oct 26 # Suva
|
||||
Zone Pacific/Fiji 11:55:44 - LMT 1915 Oct 26 # Suva
|
||||
12:00 Fiji FJ%sT # Fiji Time
|
||||
|
||||
# French Polynesia
|
||||
@ -803,9 +823,9 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
|
||||
|
||||
# This data is by no means authoritative; if you think you know better,
|
||||
# go ahead and edit the file (and please send any changes to
|
||||
# tz@elsie.nci.nih.gov for general use in the future).
|
||||
# tz@iana.org for general use in the future).
|
||||
|
||||
# From Paul Eggert (2006-03-22):
|
||||
# From Paul Eggert (2013-02-21):
|
||||
# A good source for time zone historical data outside the U.S. is
|
||||
# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
|
||||
# San Diego: ACS Publications, Inc. (2003).
|
||||
@ -823,6 +843,10 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
|
||||
# Whitman Publishing Co, 2 Niagara Av, Ealing, London (undated), which
|
||||
# I found in the UCLA library.
|
||||
#
|
||||
# For data circa 1899, a common source is:
|
||||
# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
|
||||
# <http://www.jstor.org/stable/1774359>.
|
||||
#
|
||||
# A reliable and entertaining source about time zones is
|
||||
# Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997).
|
||||
#
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
# This data is by no means authoritative; if you think you know better,
|
||||
# go ahead and edit the file (and please send any changes to
|
||||
# tz@elsie.nci.nih.gov for general use in the future).
|
||||
# tz@iana.org for general use in the future).
|
||||
|
||||
# From Paul Eggert (2006-03-22):
|
||||
# A good source for time zone historical data outside the U.S. is
|
||||
@ -53,6 +53,12 @@
|
||||
# William Willett, The Waste of Daylight, 19th edition
|
||||
# </a> (1914-03)
|
||||
#
|
||||
# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
|
||||
# <http://www.jstor.org/stable/1774359>. He writes:
|
||||
# "It is requested that corrections and additions to these tables
|
||||
# may be sent to Mr. John Milne, Royal Geographical Society,
|
||||
# Savile Row, London." Nowadays please email them to tz@iana.org.
|
||||
#
|
||||
# Brazil's Departamento Servico da Hora (DSH),
|
||||
# <a href="http://pcdsh01.on.br/HISTHV.htm">
|
||||
# History of Summer Time
|
||||
@ -689,6 +695,8 @@ Zone Europe/Andorra 0:06:04 - LMT 1901
|
||||
|
||||
# Austria
|
||||
|
||||
# Milne says Vienna time was 1:05:21.
|
||||
|
||||
# From Paul Eggert (2006-03-22): Shanks & Pottenger give 1918-06-16 and
|
||||
# 1945-11-18, but the Austrian Federal Office of Metrology and
|
||||
# Surveying (BEV) gives 1918-09-16 and for Vienna gives the "alleged"
|
||||
@ -706,7 +714,7 @@ Rule Austria 1948 only - Apr 18 2:00s 1:00 S
|
||||
Rule Austria 1980 only - Apr 6 0:00 1:00 S
|
||||
Rule Austria 1980 only - Sep 28 0:00 0 -
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Europe/Vienna 1:05:20 - LMT 1893 Apr
|
||||
Zone Europe/Vienna 1:05:21 - LMT 1893 Apr
|
||||
1:00 C-Eur CE%sT 1920
|
||||
1:00 Austria CE%sT 1940 Apr 1 2:00s
|
||||
1:00 C-Eur CE%sT 1945 Apr 2 2:00s
|
||||
@ -1262,6 +1270,21 @@ Zone Europe/Berlin 0:53:28 - LMT 1893 Apr
|
||||
1:00 Germany CE%sT 1980
|
||||
1:00 EU CE%sT
|
||||
|
||||
# From Tobias Conradi (2011-09-12):
|
||||
# Busingen <http://www.buesingen.de>, surrounded by the Swiss canton
|
||||
# Schaffhausen, did not start observing DST in 1980 as the rest of DE
|
||||
# (West Germany at that time) and DD (East Germany at that time) did.
|
||||
# DD merged into DE, the area is currently covered by code DE in ISO 3166-1,
|
||||
# which in turn is covered by the zone Europe/Berlin.
|
||||
#
|
||||
# Source for the time in Busingen 1980:
|
||||
# http://www.srf.ch/player/video?id=c012c029-03b7-4c2b-9164-aa5902cd58d3
|
||||
|
||||
# From Arthur David Olson (2012-03-03):
|
||||
# Busingen and Zurich have shared clocks since 1970.
|
||||
|
||||
Link Europe/Zurich Europe/Busingen
|
||||
|
||||
# Georgia
|
||||
# Please see the "asia" file for Asia/Tbilisi.
|
||||
# Herodotus (Histories, IV.45) says Georgia north of the Phasis (now Rioni)
|
||||
@ -2066,6 +2089,70 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct
|
||||
|
||||
# Russia
|
||||
|
||||
# From Alexander Krivenyshev (2011-09-15):
|
||||
# Based on last Russian Government Decree # 725 on August 31, 2011
|
||||
# (Government document
|
||||
# <a href="http://www.government.ru/gov/results/16355/print/">
|
||||
# http://www.government.ru/gov/results/16355/print/
|
||||
# </a>
|
||||
# in Russian)
|
||||
# there are few corrections have to be made for some Russian time zones...
|
||||
# All updated Russian Time Zones were placed in table and translated to English
|
||||
# by WorldTimeZone.com at the link below:
|
||||
# <a href="http://www.worldtimezone.com/dst_news/dst_news_russia36.htm">
|
||||
# http://www.worldtimezone.com/dst_news/dst_news_russia36.htm
|
||||
# </a>
|
||||
|
||||
# From Sanjeev Gupta (2011-09-27):
|
||||
# Scans of [Decree #23 of January 8, 1992] are available at:
|
||||
# <a href="http://government.consultant.ru/page.aspx?1223966">
|
||||
# http://government.consultant.ru/page.aspx?1223966
|
||||
# They are in Cyrillic letters (presumably Russian).
|
||||
|
||||
# From Arthur David Olson (2012-05-09):
|
||||
# Regarding the instant when clocks in time-zone-shifting parts of Russia
|
||||
# changed in September 2011:
|
||||
#
|
||||
# One source is
|
||||
# < a href="http://government.ru/gov/results/16355/>
|
||||
# http://government.ru/gov/results/16355/
|
||||
# </a>
|
||||
# which, according to translate.google.com, begins "Decree of August 31,
|
||||
# 2011 No 725" and contains no other dates or "effective date" information.
|
||||
#
|
||||
# Another source is
|
||||
# <a href="http://www.rg.ru/2011/09/06/chas-zona-dok.html">
|
||||
# http://www.rg.ru/2011/09/06/chas-zona-dok.html
|
||||
# </a>
|
||||
# which, according to translate.google.com, begins "Resolution of the
|
||||
# Government of the Russian Federation on August 31, 2011 N 725" and also
|
||||
# contains "Date first official publication: September 6, 2011 Posted on:
|
||||
# in the 'RG' - Federal Issue number 5573 September 6, 2011" but which
|
||||
# does not contain any "effective date" information.
|
||||
#
|
||||
# Another source is
|
||||
# <a href="http://en.wikipedia.org/wiki/Oymyakonsky_District#cite_note-RuTime-7">
|
||||
# http://en.wikipedia.org/wiki/Oymyakonsky_District#cite_note-RuTime-7
|
||||
# </a>
|
||||
# which, in note 8, contains "Resolution #725 of August 31, 2011...
|
||||
# Effective as of after 7 days following the day of the official publication"
|
||||
# but which does not contain any reference to September 6, 2011.
|
||||
#
|
||||
# The Wikipedia article refers to
|
||||
# <a href="http://base.consultant.ru/cons/cgi/online.cgi?req=doc;base=LAW;n=118896">
|
||||
# http://base.consultant.ru/cons/cgi/online.cgi?req=doc;base=LAW;n=118896
|
||||
# </a>
|
||||
# which seems to copy the text of the government.ru page.
|
||||
#
|
||||
# Tobias Conradi combines Wikipedia's
|
||||
# "as of after 7 days following the day of the official publication"
|
||||
# with www.rg.ru's "Date of first official publication: September 6, 2011" to get
|
||||
# September 13, 2011 as the cutover date (unusually, a Tuesday, as Tobias Conradi notes).
|
||||
#
|
||||
# None of the sources indicates a time of day for changing clocks.
|
||||
#
|
||||
# Go with 2011-09-13 0:00s.
|
||||
|
||||
# From Paul Eggert (2006-03-22):
|
||||
# Except for Moscow after 1919-07-01, I invented the time zone abbreviations.
|
||||
# Moscow time zone abbreviations after 1919-07-01, and Moscow rules after 1991,
|
||||
@ -2293,14 +2380,32 @@ Zone Asia/Yakutsk 8:38:40 - LMT 1919 Dec 15
|
||||
# [parts of] Respublika Sakha (Yakutiya).
|
||||
|
||||
# From Oscar van Vlijmen (2009-11-29):
|
||||
# The Sakha districts are: Bulunskij, Verkhoyanskij, Tomponskij, Ust'-Majskij,
|
||||
# Ust'-Yanskij.
|
||||
# The Sakha districts are: Bulunskij, Verkhoyanskij, ... Ust'-Yanskij.
|
||||
Zone Asia/Vladivostok 8:47:44 - LMT 1922 Nov 15
|
||||
9:00 - VLAT 1930 Jun 21 # Vladivostok Time
|
||||
10:00 Russia VLA%sT 1991 Mar 31 2:00s
|
||||
9:00 Russia VLA%sST 1992 Jan 19 2:00s
|
||||
10:00 Russia VLA%sT 2011 Mar 27 2:00s
|
||||
11:00 - VLAT
|
||||
|
||||
# From Arthur David Olson (2012-05-09):
|
||||
# Tomponskij and Ust'-Majskij switched from Vladivostok time to Yakutsk time
|
||||
# in 2011.
|
||||
#
|
||||
# From Paul Eggert (2012-11-25):
|
||||
# Shanks and Pottenger (2003) has Khandyga on Yakutsk time.
|
||||
# Make a wild guess that it switched to Vladivostok time in 2004.
|
||||
# This transition is no doubt wrong, but we have no better info.
|
||||
#
|
||||
Zone Asia/Khandyga 9:02:13 - LMT 1919 Dec 15
|
||||
8:00 - YAKT 1930 Jun 21 # Yakutsk Time
|
||||
9:00 Russia YAK%sT 1991 Mar 31 2:00s
|
||||
8:00 Russia YAK%sT 1992 Jan 19 2:00s
|
||||
9:00 Russia YAK%sT 2004
|
||||
10:00 Russia VLA%sT 2011 Mar 27 2:00s
|
||||
11:00 - VLAT 2011 Sep 13 0:00s # Decree 725?
|
||||
10:00 - YAKT
|
||||
|
||||
#
|
||||
# Sakhalinskaya oblast'.
|
||||
# The Zone name should be Yuzhno-Sakhalinsk, but that's too long.
|
||||
@ -2319,14 +2424,26 @@ Zone Asia/Sakhalin 9:30:48 - LMT 1905 Aug 23
|
||||
|
||||
# From Oscar van Vlijmen (2009-11-29):
|
||||
# The Sakha districts are: Abyjskij, Allaikhovskij, Verkhhhnekolymskij, Momskij,
|
||||
# Nizhnekolymskij, Ojmyakonskij, Srednekolymskij.
|
||||
# Nizhnekolymskij, ... Srednekolymskij.
|
||||
Zone Asia/Magadan 10:03:12 - LMT 1924 May 2
|
||||
10:00 - MAGT 1930 Jun 21 # Magadan Time
|
||||
11:00 Russia MAG%sT 1991 Mar 31 2:00s
|
||||
10:00 Russia MAG%sT 1992 Jan 19 2:00s
|
||||
11:00 Russia MAG%sT 2011 Mar 27 2:00s
|
||||
12:00 - MAGT
|
||||
#
|
||||
|
||||
# From Arthur David Olson (2012-05-09):
|
||||
# Ojmyakonskij and the Kuril Islands switched from
|
||||
# Magadan time to Vladivostok time in 2011.
|
||||
Zone Asia/Ust-Nera 9:32:54 - LMT 1919 Dec 15
|
||||
8:00 - YAKT 1930 Jun 21 # Yakutsk Time
|
||||
9:00 Russia YAKT 1981 Apr 1
|
||||
11:00 Russia MAG%sT 1991 Mar 31 2:00s
|
||||
10:00 Russia MAG%sT 1992 Jan 19 2:00s
|
||||
11:00 Russia MAG%sT 2011 Mar 27 2:00s
|
||||
12:00 - MAGT 2011 Sep 13 0:00s # Decree 725?
|
||||
11:00 - VLAT
|
||||
|
||||
# From Oscar van Vlijmen (2001-08-25): [This region consists of]
|
||||
# Kamchatskaya oblast', Koryakskij avtonomnyj okrug.
|
||||
#
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
# This data is by no means authoritative; if you think you know better,
|
||||
# go ahead and edit the file (and please send any changes to
|
||||
# tz@elsie.nci.nih.gov for general use in the future).
|
||||
# tz@iana.org for general use in the future).
|
||||
|
||||
# From Paul Eggert (1999-03-22):
|
||||
# A reliable and entertaining source about time zones is
|
||||
@ -1042,6 +1042,9 @@ Zone America/Menominee -5:50:27 - LMT 1885 Sep 18 12:00
|
||||
# William Willett, The Waste of Daylight, 19th edition
|
||||
# </a> (1914-03)
|
||||
#
|
||||
# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
|
||||
# <http://www.jstor.org/stable/1774359>.
|
||||
#
|
||||
# See the `europe' file for Greenland.
|
||||
|
||||
# Canada
|
||||
@ -2577,6 +2580,8 @@ Zone America/Antigua -4:07:12 - LMT 1912 Mar 2
|
||||
|
||||
# Bahamas
|
||||
#
|
||||
# For 1899 Milne gives -5:09:29.5; round that.
|
||||
#
|
||||
# From Sue Williams (2006-12-07):
|
||||
# The Bahamas announced about a month ago that they plan to change their DST
|
||||
# rules to sync with the U.S. starting in 2007....
|
||||
@ -2586,11 +2591,14 @@ Zone America/Antigua -4:07:12 - LMT 1912 Mar 2
|
||||
Rule Bahamas 1964 1975 - Oct lastSun 2:00 0 S
|
||||
Rule Bahamas 1964 1975 - Apr lastSun 2:00 1:00 D
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone America/Nassau -5:09:24 - LMT 1912 Mar 2
|
||||
Zone America/Nassau -5:09:30 - LMT 1912 Mar 2
|
||||
-5:00 Bahamas E%sT 1976
|
||||
-5:00 US E%sT
|
||||
|
||||
# Barbados
|
||||
|
||||
# For 1899 Milne gives -3:58:29.2; round that.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Barb 1977 only - Jun 12 2:00 1:00 D
|
||||
Rule Barb 1977 1978 - Oct Sun>=1 2:00 0 S
|
||||
@ -2598,8 +2606,8 @@ Rule Barb 1978 1980 - Apr Sun>=15 2:00 1:00 D
|
||||
Rule Barb 1979 only - Sep 30 2:00 0 S
|
||||
Rule Barb 1980 only - Sep 25 2:00 0 S
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone America/Barbados -3:58:28 - LMT 1924 # Bridgetown
|
||||
-3:58:28 - BMT 1932 # Bridgetown Mean Time
|
||||
Zone America/Barbados -3:58:29 - LMT 1924 # Bridgetown
|
||||
-3:58:29 - BMT 1932 # Bridgetown Mean Time
|
||||
-4:00 Barb A%sT
|
||||
|
||||
# Belize
|
||||
@ -2617,6 +2625,9 @@ Zone America/Belize -5:52:48 - LMT 1912 Apr
|
||||
|
||||
# Bermuda
|
||||
|
||||
# For 1899 Milne gives -4:19:18.3 as the meridian of the clock tower,
|
||||
# Bermuda dockyard, Ireland I; round that.
|
||||
|
||||
# From Dan Jones, reporting in The Royal Gazette (2006-06-26):
|
||||
|
||||
# Next year, however, clocks in the US will go forward on the second Sunday
|
||||
@ -2626,7 +2637,7 @@ Zone America/Belize -5:52:48 - LMT 1912 Apr
|
||||
# http://www.theroyalgazette.com/apps/pbcs.dll/article?AID=/20060529/NEWS/105290135
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Atlantic/Bermuda -4:19:04 - LMT 1930 Jan 1 2:00 # Hamilton
|
||||
Zone Atlantic/Bermuda -4:19:18 - LMT 1930 Jan 1 2:00 # Hamilton
|
||||
-4:00 - AST 1974 Apr 28 2:00
|
||||
-4:00 Bahamas A%sT 1976
|
||||
-4:00 US A%sT
|
||||
@ -2638,6 +2649,9 @@ Zone America/Cayman -5:25:32 - LMT 1890 # Georgetown
|
||||
-5:00 - EST
|
||||
|
||||
# Costa Rica
|
||||
|
||||
# Milne gives -5:36:13.3 as San Jose mean time; round to nearest.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule CR 1979 1980 - Feb lastSun 0:00 1:00 D
|
||||
Rule CR 1979 1980 - Jun Sun>=1 0:00 0 S
|
||||
@ -2648,14 +2662,19 @@ Rule CR 1991 only - Jul 1 0:00 0 S
|
||||
Rule CR 1992 only - Mar 15 0:00 0 S
|
||||
# There are too many San Joses elsewhere, so we'll use `Costa Rica'.
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone America/Costa_Rica -5:36:20 - LMT 1890 # San Jose
|
||||
-5:36:20 - SJMT 1921 Jan 15 # San Jose Mean Time
|
||||
Zone America/Costa_Rica -5:36:13 - LMT 1890 # San Jose
|
||||
-5:36:13 - SJMT 1921 Jan 15 # San Jose Mean Time
|
||||
-6:00 CR C%sT
|
||||
# Coco
|
||||
# no information; probably like America/Costa_Rica
|
||||
|
||||
# Cuba
|
||||
|
||||
# From Paul Eggert (2013-02-21):
|
||||
# Milne gives -5:28:50.45 for the observatory at Havana, -5:29:23.57
|
||||
# for the port, and -5:30 for meteorological observations.
|
||||
# For now, stick with Shanks & Pottenger.
|
||||
|
||||
# From Arthur David Olson (1999-03-29):
|
||||
# The 1999-03-28 exhibition baseball game held in Havana, Cuba, between
|
||||
# the Cuban National Team and the Baltimore Orioles was carried live on
|
||||
@ -3004,24 +3023,21 @@ Zone America/Guatemala -6:02:04 - LMT 1918 Oct 5
|
||||
# apparently using the same start and end date as USA/Canada.
|
||||
# So this means they have already changed their time.
|
||||
#
|
||||
# (Sources in French):
|
||||
# <a href="http://www.alterpresse.org/spip.php?article12510">
|
||||
# http://www.alterpresse.org/spip.php?article12510
|
||||
# </a>
|
||||
# <a href="http://radiovision2000haiti.net/home/?p=13253">
|
||||
# http://radiovision2000haiti.net/home/?p=13253
|
||||
# </a>
|
||||
#
|
||||
# Our coverage:
|
||||
# <a href="http://www.timeanddate.com/news/time/haiti-dst-2012.html">
|
||||
# http://www.timeanddate.com/news/time/haiti-dst-2012.html
|
||||
# </a>
|
||||
|
||||
# From Arthur David Olson (2012-03-11):
|
||||
# The alterpresse.org source seems to show a US-style leap from 2:00 a.m. to
|
||||
# 3:00 a.m. rather than the traditional Haitian jump at midnight.
|
||||
# Assume a US-style fall back as well XXX.
|
||||
# Do not yet assume that the change carries forward past 2012 XXX.
|
||||
# Assume a US-style fall back as well.
|
||||
|
||||
# From Steffen Thorsen (2013-03-10):
|
||||
# It appears that Haiti is observing DST this year as well, same rules
|
||||
# as US/Canada. They did it last year as well, and it looks like they
|
||||
# are going to observe DST every year now...
|
||||
#
|
||||
# http://radiovision2000haiti.net/public/haiti-avis-changement-dheure-dimanche/
|
||||
# http://www.canalplushaiti.net/?p=6714
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Haiti 1983 only - May 8 0:00 1:00 D
|
||||
@ -3033,8 +3049,8 @@ Rule Haiti 1988 1997 - Apr Sun>=1 1:00s 1:00 D
|
||||
Rule Haiti 1988 1997 - Oct lastSun 1:00s 0 S
|
||||
Rule Haiti 2005 2006 - Apr Sun>=1 0:00 1:00 D
|
||||
Rule Haiti 2005 2006 - Oct lastSun 0:00 0 S
|
||||
Rule Haiti 2012 only - Mar Sun>=8 2:00 1:00 D
|
||||
Rule Haiti 2012 only - Nov Sun>=1 2:00 0 S
|
||||
Rule Haiti 2012 max - Mar Sun>=8 2:00 1:00 D
|
||||
Rule Haiti 2012 max - Nov Sun>=1 2:00 0 S
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone America/Port-au-Prince -4:49:20 - LMT 1890
|
||||
-4:49 - PPMT 1917 Jan 24 12:00 # P-a-P MT
|
||||
|
@ -27,13 +27,17 @@
|
||||
|
||||
# This data is by no means authoritative; if you think you know better,
|
||||
# go ahead and edit the file (and please send any changes to
|
||||
# tz@elsie.nci.nih.gov for general use in the future).
|
||||
# tz@iana.org for general use in the future).
|
||||
|
||||
# From Paul Eggert (2006-03-22):
|
||||
# A good source for time zone historical data outside the U.S. is
|
||||
# Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition),
|
||||
# San Diego: ACS Publications, Inc. (2003).
|
||||
#
|
||||
# For data circa 1899, a common source is:
|
||||
# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
|
||||
# <http://www.jstor.org/stable/1774359>.
|
||||
#
|
||||
# Gwillim Law writes that a good source
|
||||
# for recent time zone data is the International Air Transport
|
||||
# Association's Standard Schedules Information Manual (IATA SSIM),
|
||||
@ -404,21 +408,11 @@ Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 S
|
||||
# <a/>
|
||||
# is the official page for the Province Government).
|
||||
#
|
||||
# There's also a note in only one of the major national papers (La Nación) at
|
||||
# <a href="http://www.lanacion.com.ar/nota.asp?nota_id=1107912">
|
||||
# There's also a note in only one of the major national papers ...
|
||||
# http://www.lanacion.com.ar/nota.asp?nota_id=1107912
|
||||
# </a>
|
||||
#
|
||||
# The press release says:
|
||||
# (...) anunció que el próximo domingo a las 00:00 los puntanos deberán
|
||||
# atrasar una hora sus relojes.
|
||||
#
|
||||
# A partir de entonces, San Luis establecerá el huso horario propio de
|
||||
# la Provincia. De esta manera, durante el periodo del calendario anual
|
||||
# 2009, el cambio horario quedará comprendido entre las 00:00 del tercer
|
||||
# domingo de marzo y las 24:00 del segundo sábado de octubre.
|
||||
# Quick&dirty translation
|
||||
# (...) announced that next Sunday, at 00:00, Puntanos (the San Luis
|
||||
# The press release says [quick and dirty translation]:
|
||||
# ... announced that next Sunday, at 00:00, Puntanos (the San Luis
|
||||
# inhabitants) will have to turn back one hour their clocks
|
||||
#
|
||||
# Since then, San Luis will establish its own Province timezone. Thus,
|
||||
@ -480,6 +474,9 @@ Rule Arg 2008 only - Oct Sun>=15 0:00 1:00 S
|
||||
# rules...San Luis is still using "Western ARgentina Time" and it got
|
||||
# stuck on Summer daylight savings time even though the summer is over.
|
||||
|
||||
# From Paul Eggert (2013-02-21):
|
||||
# Milne says Cordoba time was -4:16:48.2. Round to the nearest second.
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
#
|
||||
# Buenos Aires (BA), Capital Federal (CF),
|
||||
@ -835,9 +832,9 @@ Zone America/La_Paz -4:32:36 - LMT 1890
|
||||
|
||||
# From Guilherme Bernardes Rodrigues (2011-10-07):
|
||||
# There is news in the media, however there is still no decree about it.
|
||||
# I just send a e-mail to Zulmira Brandão at
|
||||
# I just send a e-mail to Zulmira Brandao at
|
||||
# <a href="http://pcdsh01.on.br/">http://pcdsh01.on.br/</a> the
|
||||
# oficial agency about time in Brazil, and she confirmed that the old rule is
|
||||
# official agency about time in Brazil, and she confirmed that the old rule is
|
||||
# still in force.
|
||||
|
||||
# From Guilherme Bernardes Rodrigues (2011-10-14)
|
||||
@ -1266,9 +1263,13 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914
|
||||
# b. Saturday, September 1, 2012, clocks should go forward 60 minutes; that is,
|
||||
# at 23:59:59, instead of passing to 0:00, the time should be adjusted to be
|
||||
# 01:00 on September 2.
|
||||
#
|
||||
# Note that...this is yet another "temporary" change that will be reevaluated
|
||||
# AGAIN in 2013.
|
||||
|
||||
# From Steffen Thorsen (2013-02-15):
|
||||
# According to several news sources, Chile has extended DST this year,
|
||||
# they will end DST later and start DST earlier than planned. They
|
||||
# hope to save energy. The new end date is 2013-04-28 00:00 and new
|
||||
# start date is 2013-09-08 00:00....
|
||||
# http://www.gob.cl/informa/2013/02/15/gobierno-anuncia-fechas-de-cambio-de-hora-para-el-ano-2013.htm
|
||||
|
||||
# NOTE: ChileAQ rules for Antarctic bases are stored separately in the
|
||||
# 'antarctica' file.
|
||||
@ -1311,10 +1312,8 @@ Rule Chile 2009 only - Mar Sun>=9 3:00u 0 -
|
||||
Rule Chile 2010 only - Apr Sun>=1 3:00u 0 -
|
||||
Rule Chile 2011 only - May Sun>=2 3:00u 0 -
|
||||
Rule Chile 2011 only - Aug Sun>=16 4:00u 1:00 S
|
||||
Rule Chile 2012 only - Apr Sun>=23 3:00u 0 -
|
||||
Rule Chile 2012 only - Sep Sun>=2 4:00u 1:00 S
|
||||
Rule Chile 2013 max - Mar Sun>=9 3:00u 0 -
|
||||
Rule Chile 2013 max - Oct Sun>=9 4:00u 1:00 S
|
||||
Rule Chile 2012 max - Apr Sun>=23 3:00u 0 -
|
||||
Rule Chile 2012 max - Sep Sun>=2 4:00u 1:00 S
|
||||
# IATA SSIM anomalies: (1992-02) says 1992-03-14;
|
||||
# (1996-09) says 1998-03-08. Ignore these.
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
@ -1336,17 +1335,23 @@ Zone Pacific/Easter -7:17:44 - LMT 1890
|
||||
# San Felix, and Antarctic bases, are like America/Santiago.
|
||||
|
||||
# Colombia
|
||||
|
||||
# Milne gives 4:56:16.4 for Bogota time in 1899; round to nearest. He writes,
|
||||
# "A variation of fifteen minutes in the public clocks of Bogota is not rare."
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule CO 1992 only - May 3 0:00 1:00 S
|
||||
Rule CO 1993 only - Apr 4 0:00 0 -
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone America/Bogota -4:56:20 - LMT 1884 Mar 13
|
||||
-4:56:20 - BMT 1914 Nov 23 # Bogota Mean Time
|
||||
Zone America/Bogota -4:56:16 - LMT 1884 Mar 13
|
||||
-4:56:16 - BMT 1914 Nov 23 # Bogota Mean Time
|
||||
-5:00 CO CO%sT # Colombia Time
|
||||
# Malpelo, Providencia, San Andres
|
||||
# no information; probably like America/Bogota
|
||||
|
||||
# Curacao
|
||||
|
||||
# Milne gives 4:35:46.9 for Curacao mean time; round to nearest.
|
||||
#
|
||||
# From Paul Eggert (2006-03-22):
|
||||
# Shanks & Pottenger say that The Bottom and Philipsburg have been at
|
||||
@ -1363,7 +1368,7 @@ Zone America/Bogota -4:56:20 - LMT 1884 Mar 13
|
||||
# though, as far as we know.
|
||||
#
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone America/Curacao -4:35:44 - LMT 1912 Feb 12 # Willemstad
|
||||
Zone America/Curacao -4:35:47 - LMT 1912 Feb 12 # Willemstad
|
||||
-4:30 - ANT 1965 # Netherlands Antilles Time
|
||||
-4:00 - AST
|
||||
|
||||
@ -1377,6 +1382,8 @@ Link America/Curacao America/Kralendijk # Bonaire, Sint Estatius and Saba
|
||||
|
||||
# Ecuador
|
||||
#
|
||||
# Milne says the Sentral and South American Telegraph Company used -5:24:15.
|
||||
#
|
||||
# From Paul Eggert (2007-03-04):
|
||||
# Apparently Ecuador had a failed experiment with DST in 1992.
|
||||
# <http://midena.gov.ec/content/view/1261/208/> (2007-02-27) and
|
||||
@ -1582,7 +1589,16 @@ Rule Para 2005 2009 - Mar Sun>=8 0:00 0 -
|
||||
# forward 60 minutes, in all the territory of the Paraguayan Republic.
|
||||
# ...
|
||||
Rule Para 2010 max - Oct Sun>=1 0:00 1:00 S
|
||||
Rule Para 2010 max - Apr Sun>=8 0:00 0 -
|
||||
Rule Para 2010 2012 - Apr Sun>=8 0:00 0 -
|
||||
#
|
||||
# From Steffen Thorsen (2013-03-07):
|
||||
# Paraguay will end DST on 2013-03-24 00:00....
|
||||
# http://www.ande.gov.py/interna.php?id=1075
|
||||
#
|
||||
# From Carlos Raul Perasso (2013-03-15):
|
||||
# The change in Paraguay is now final. Decree number 10780
|
||||
# http://www.presidencia.gov.py/uploads/pdf/presidencia-3b86ff4b691c79d4f5927ca964922ec74772ce857c02ca054a52a37b49afc7fb.pdf
|
||||
Rule Para 2013 max - Mar Sun>=22 0:00 0 -
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone America/Asuncion -3:50:40 - LMT 1890
|
||||
|
@ -65,7 +65,6 @@ AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula
|
||||
AQ -7824+10654 Antarctica/Vostok Vostok Station, Lake Vostok
|
||||
AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie
|
||||
AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I
|
||||
AQ -5430+15857 Antarctica/Macquarie Macquarie Island Station, Macquarie Island
|
||||
AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF)
|
||||
AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, MN, SE, SF)
|
||||
AR -2447-06525 America/Argentina/Salta (SA, LP, NQ, RN)
|
||||
@ -81,6 +80,7 @@ AR -5448-06818 America/Argentina/Ushuaia Tierra del Fuego (TF)
|
||||
AS -1416-17042 Pacific/Pago_Pago
|
||||
AT +4813+01620 Europe/Vienna
|
||||
AU -3133+15905 Australia/Lord_Howe Lord Howe Island
|
||||
AU -5430+15857 Antarctica/Macquarie Macquarie Island
|
||||
AU -4253+14719 Australia/Hobart Tasmania - most locations
|
||||
AU -3956+14352 Australia/Currie Tasmania - King Island
|
||||
AU -3749+14458 Australia/Melbourne Victoria
|
||||
@ -182,7 +182,8 @@ CW +1211-06900 America/Curacao
|
||||
CX -1025+10543 Indian/Christmas
|
||||
CY +3510+03322 Asia/Nicosia
|
||||
CZ +5005+01426 Europe/Prague
|
||||
DE +5230+01322 Europe/Berlin
|
||||
DE +5230+01322 Europe/Berlin most locations
|
||||
DE +4742+00841 Europe/Busingen Busingen
|
||||
DJ +1136+04309 Africa/Djibouti
|
||||
DK +5540+01235 Europe/Copenhagen
|
||||
DM +1518-06124 America/Dominica
|
||||
@ -364,8 +365,10 @@ RU +5345+08707 Asia/Novokuznetsk Moscow+03 - Novokuznetsk
|
||||
RU +5601+09250 Asia/Krasnoyarsk Moscow+04 - Yenisei River
|
||||
RU +5216+10420 Asia/Irkutsk Moscow+05 - Lake Baikal
|
||||
RU +6200+12940 Asia/Yakutsk Moscow+06 - Lena River
|
||||
RU +623923+1353314 Asia/Khandyga Moscow+06 - Tomponsky, Ust-Maysky
|
||||
RU +4310+13156 Asia/Vladivostok Moscow+07 - Amur River
|
||||
RU +4658+14242 Asia/Sakhalin Moscow+07 - Sakhalin Island
|
||||
RU +643337+1431336 Asia/Ust-Nera Moscow+07 - Oymyakonsky
|
||||
RU +5934+15048 Asia/Magadan Moscow+08 - Magadan
|
||||
RU +5301+15839 Asia/Kamchatka Moscow+08 - Kamchatka
|
||||
RU +6445+17729 Asia/Anadyr Moscow+08 - Bering Sea
|
||||
|
@ -87,9 +87,6 @@ build: $(FILES_genout_extcs) $(CHARSETS_JAR)
|
||||
#
|
||||
# Extra rules to build character converters.
|
||||
|
||||
SERVICE_DESCRIPTION = java.nio.charset.spi.CharsetProvider
|
||||
SERVICE_DESCRIPTION_PATH = META-INF/services/$(SERVICE_DESCRIPTION)
|
||||
|
||||
GENCSDATASRC = $(BUILDDIR)/tools/CharsetMapping
|
||||
GENCSSRCDIR = $(BUILDDIR)/tools/src/build/tools/charsetmapping
|
||||
GENCSEXT = $(GENSRCDIR)/sun/nio/cs/ext
|
||||
@ -118,10 +115,6 @@ $(FILES_genout_extcs): \
|
||||
$(GENCSSRCDIR)/HKSCS.java
|
||||
$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE) $(GENCSDATASRC) $(GENCSEXT) dbcs
|
||||
|
||||
$(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \
|
||||
$(SHARE_SRC)/classes/sun/nio/cs/ext/$(SERVICE_DESCRIPTION_PATH)
|
||||
$(install-file)
|
||||
|
||||
# no compression unless requested
|
||||
ifndef COMPRESS_JARS
|
||||
CREATE_JAR_OPTS_NOMANIFEST = cf0
|
||||
@ -129,10 +122,9 @@ else
|
||||
CREATE_JAR_OPTS_NOMANIFEST = cf
|
||||
endif
|
||||
|
||||
$(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) $(FILES_DAT)
|
||||
$(CHARSETS_JAR): $(FILES_class) $(FILES_DAT)
|
||||
$(BOOT_JAR_CMD) $(CREATE_JAR_OPTS_NOMANIFEST) $(CHARSETS_JAR) \
|
||||
-C $(CLASSDESTDIR) sun \
|
||||
-C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH) \
|
||||
$(BOOT_JAR_JFLAGS)
|
||||
@$(java-vm-cleanup)
|
||||
|
||||
|
@ -1,39 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2005, 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.
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile for building Mozilla JavaScript modules
|
||||
#
|
||||
|
||||
BUILDDIR = ../../..
|
||||
PRODUCT = org
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
SUBDIRS = javascript
|
||||
include $(BUILDDIR)/common/Subdirs.gmk
|
||||
|
||||
all build clean clobber::
|
||||
$(SUBDIRS-loop)
|
||||
|
@ -1,64 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2005, 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.
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile for building all of sun.org.mozilla.javascript.internal.*
|
||||
#
|
||||
|
||||
BUILDDIR = ../../../..
|
||||
PACKAGE = sun.org.mozilla.javascript.internal
|
||||
PRODUCT = sun
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
AUTO_FILES_JAVA_DIRS = sun/org/mozilla/javascript/internal
|
||||
|
||||
RESOURCEDIR = \
|
||||
$(CLASSDESTDIR)/sun/org/mozilla/javascript/internal/resources
|
||||
|
||||
FILES_copy = \
|
||||
$(RESOURCEDIR)/Messages.properties \
|
||||
$(RESOURCEDIR)/Messages_fr.properties
|
||||
|
||||
#
|
||||
# Rules
|
||||
#
|
||||
|
||||
include $(BUILDDIR)/common/Classes.gmk
|
||||
|
||||
all: classes copy-files
|
||||
|
||||
#
|
||||
# Copy resource messages file for Rhino JavaScript interpreter
|
||||
#
|
||||
|
||||
copy-files: $(FILES_copy)
|
||||
|
||||
$(RESOURCEDIR)/%: $(CLOSED_SRC)/share/classes/sun/org/mozilla/javascript/internal/resources/%
|
||||
$(install-file)
|
||||
|
||||
.PHONY: copy-files
|
||||
|
||||
clean clobber::
|
||||
$(RM) -rf $(CLASSDESTDIR)/sun/org/mozilla/javascript
|
@ -38,12 +38,10 @@ SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
|
||||
SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
# build sun/security/jgss/wrapper on non-windows non-macosx platforms
|
||||
# build sun/security/jgss/wrapper on non-windows platforms
|
||||
JGSS_WRAPPER =
|
||||
ifneq ($(PLATFORM), windows)
|
||||
ifneq ($(PLATFORM), macosx)
|
||||
JGSS_WRAPPER = jgss/wrapper
|
||||
endif
|
||||
JGSS_WRAPPER = jgss/wrapper
|
||||
endif
|
||||
|
||||
# Build PKCS#11 on all platforms
|
||||
|
@ -124,15 +124,6 @@ CLASSDESTDIR = $(TEMPDIR)/classes
|
||||
#
|
||||
AUTO_FILES_JAVA_DIRS = $(PKGDIR)
|
||||
|
||||
#
|
||||
# Exclude the sources that get built by ../other/Makefile
|
||||
#
|
||||
AUTO_JAVA_PRUNE = \
|
||||
ECParameters.java \
|
||||
ECPrivateKeyImpl.java \
|
||||
ECPublicKeyImpl.java \
|
||||
NamedCurve.java
|
||||
|
||||
#
|
||||
# Some licensees do not get the native ECC sources, but we still need to
|
||||
# be able to build "all" for them. Check here to see if the sources are
|
||||
|
@ -49,15 +49,6 @@ AUTO_FILES_JAVA_DIRS = \
|
||||
sun/security/x509 \
|
||||
com/sun/net/ssl/internal/ssl
|
||||
|
||||
#
|
||||
# EC classes used by the packages above
|
||||
#
|
||||
FILES_java += \
|
||||
sun/security/ec/ECParameters.java \
|
||||
sun/security/ec/ECPrivateKeyImpl.java \
|
||||
sun/security/ec/ECPublicKeyImpl.java \
|
||||
sun/security/ec/NamedCurve.java
|
||||
|
||||
#
|
||||
# Rules
|
||||
#
|
||||
|
@ -34,6 +34,8 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import org.xml.sax.SAXNotRecognizedException;
|
||||
import org.xml.sax.SAXNotSupportedException;
|
||||
|
||||
|
||||
/**
|
||||
@ -234,6 +236,17 @@ public class CLDRConverter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the parser to allow access to DTDs on the file system.
|
||||
*/
|
||||
private static void enableFileAccess(SAXParser parser) throws SAXNotSupportedException {
|
||||
try {
|
||||
parser.setProperty("http://javax.xml.XMLConstants/property/accessExternalDTD", "file");
|
||||
} catch (SAXNotRecognizedException ignore) {
|
||||
// property requires >= JAXP 1.5
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Bundle> readBundleList() throws Exception {
|
||||
ResourceBundle.Control defCon = ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT);
|
||||
List<Bundle> retList = new ArrayList<>();
|
||||
@ -279,6 +292,7 @@ public class CLDRConverter {
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
factory.setValidating(true);
|
||||
SAXParser parser = factory.newSAXParser();
|
||||
enableFileAccess(parser);
|
||||
LDMLParseHandler handler = new LDMLParseHandler(id);
|
||||
File file = new File(SOURCE_FILE_DIR + File.separator + id + ".xml");
|
||||
if (!file.exists()) {
|
||||
@ -314,6 +328,7 @@ public class CLDRConverter {
|
||||
SAXParserFactory factorySuppl = SAXParserFactory.newInstance();
|
||||
factorySuppl.setValidating(true);
|
||||
SAXParser parserSuppl = factorySuppl.newSAXParser();
|
||||
enableFileAccess(parserSuppl);
|
||||
handlerSuppl = new SupplementDataParseHandler();
|
||||
File fileSupply = new File(SPPL_SOURCE_FILE);
|
||||
parserSuppl.parse(fileSupply, handlerSuppl);
|
||||
@ -322,6 +337,7 @@ public class CLDRConverter {
|
||||
SAXParserFactory numberingParser = SAXParserFactory.newInstance();
|
||||
numberingParser.setValidating(true);
|
||||
SAXParser parserNumbering = numberingParser.newSAXParser();
|
||||
enableFileAccess(parserNumbering);
|
||||
handlerNumbering = new NumberingSystemsParseHandler();
|
||||
File fileNumbering = new File(NUMBERING_SOURCE_FILE);
|
||||
parserNumbering.parse(fileNumbering, handlerNumbering);
|
||||
@ -330,6 +346,7 @@ public class CLDRConverter {
|
||||
SAXParserFactory metazonesParser = SAXParserFactory.newInstance();
|
||||
metazonesParser.setValidating(true);
|
||||
SAXParser parserMetaZones = metazonesParser.newSAXParser();
|
||||
enableFileAccess(parserMetaZones);
|
||||
handlerMetaZones = new MetaZonesParseHandler();
|
||||
File fileMetaZones = new File(METAZONES_SOURCE_FILE);
|
||||
parserNumbering.parse(fileMetaZones, handlerMetaZones);
|
||||
|
@ -30,7 +30,5 @@ sun.security.krb5.Realm=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,comp
|
||||
|
||||
# Residual references to java.beans.
|
||||
# The RemoveMethods tool does not yet purge the constant pool.
|
||||
# Rhino is due to be replaced so not worth addressing this dependency now.
|
||||
#
|
||||
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
|
||||
java.beans.PropertyChangeListener=java.util.logging.LogManager,compact1,compact2,compact3
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
#
|
||||
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
@ -432,20 +433,22 @@ endif
|
||||
##################################################################################################
|
||||
|
||||
ifndef OPENJDK
|
||||
DB_DEMO_ZIPFILE := $(wildcard $(JDK_TOPDIR)/src/closed/share/db/*demo*.zip)
|
||||
DB_DEMO_ZIPFILE := $(wildcard $(JDK_TOPDIR)/src/closed/share/db/*.zip)
|
||||
|
||||
$(JDK_OUTPUTDIR)/demo/_the.db.unzipped: $(DB_DEMO_ZIPFILE)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(RM) -r $(JDK_OUTPUTDIR)/demo/db $(JDK_OUTPUTDIR)/demo/demo
|
||||
$(CD) $(JDK_OUTPUTDIR)/demo && $(UNZIP) -q -o $<
|
||||
$(MV) $(JDK_OUTPUTDIR)/demo/demo $(JDK_OUTPUTDIR)/demo/db
|
||||
$(MV) $(JDK_OUTPUTDIR)/demo/db-derby-*-bin/demo $(JDK_OUTPUTDIR)/demo/db
|
||||
$(CD) $(JDK_OUTPUTDIR)/demo && $(RM) -r db-derby-*-bin
|
||||
$(TOUCH) $@
|
||||
|
||||
# Copy this after the unzip above to avoid race with directory creation and mv command.
|
||||
$(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html: \
|
||||
$(JDK_TOPDIR)/src/closed/share/db/README-JDK-DEMOS.html \
|
||||
| $(JDK_OUTPUTDIR)/demo/_the.db.unzipped
|
||||
$(call install-file)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(CAT) $< | $(SED) "s/XXXX/$(shell cat $(JDK_TOPDIR)/src/closed/share/db/COPYRIGHTYEAR)/" > $@
|
||||
|
||||
BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/_the.db.unzipped $(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html
|
||||
endif
|
||||
|
@ -2560,7 +2560,6 @@ BUILD_LIBRARIES += $(BUILD_LIBJ2PCSC)
|
||||
##########################################################################################
|
||||
|
||||
ifneq ($(OPENJDK_TARGET_OS), windows)
|
||||
ifneq ($(OPENJDK_TARGET_OS), macosx)
|
||||
$(eval $(call SetupNativeCompilation,BUILD_LIBJ2GSS,\
|
||||
LIBRARY:=j2gss,\
|
||||
OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\
|
||||
@ -2581,7 +2580,6 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2GSS,\
|
||||
|
||||
BUILD_LIBRARIES += $(BUILD_LIBJ2GSS)
|
||||
endif
|
||||
endif
|
||||
|
||||
##########################################################################################
|
||||
|
||||
|
@ -458,24 +458,6 @@ endif # OPENJDK
|
||||
|
||||
ifndef OPENJDK
|
||||
|
||||
JS_RESOURCES_FILES := Messages.properties Messages_fr.properties
|
||||
JS_RESOURCES_SRC_DIR := $(JDK_TOPDIR)/src/closed/share/classes/sun/org/mozilla/javascript/internal/resources
|
||||
JS_RESOURCES_DST_DIR := $(JDK_OUTPUTDIR)/classes/sun/org/mozilla/javascript/internal/resources
|
||||
|
||||
JS_RESOURCES_SRC := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_SRC_DIR)/$(F))
|
||||
JS_RESOURCES_DST := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_DST_DIR)/$(F))
|
||||
|
||||
$(JS_RESOURCES_DST_DIR)/% : $(JS_RESOURCES_SRC_DIR)/%
|
||||
$(call install-file)
|
||||
|
||||
COPY_FILES += $(JS_RESOURCES_DST)
|
||||
|
||||
endif
|
||||
|
||||
##########################################################################################
|
||||
|
||||
ifndef OPENJDK
|
||||
|
||||
#
|
||||
# Solaris X11 Direct Graphics Access library
|
||||
#
|
||||
|
@ -172,10 +172,6 @@ ifneq ($(ALL_META-INF_DIRS_targetapi),)
|
||||
else
|
||||
ALL_META-INF_DIRS:=$(ALL_META-INF_DIRS_share)
|
||||
endif
|
||||
# Filter out META-INF dirs that shouldn't be included
|
||||
ifdef OPENJDK
|
||||
ALL_META-INF_DIRS:=$(filter-out %com/sun/script/javascript/META-INF,$(ALL_META-INF_DIRS))
|
||||
endif
|
||||
|
||||
ifndef OPENJDK
|
||||
ALL_META-INF_DIRS += $(JDK_TOPDIR)/src/closed/share/classes/sun/java2d/cmm/kcms/META-INF
|
||||
|
@ -201,7 +201,6 @@ RT_JAR_EXCLUDES += \
|
||||
META-INF/services/com.sun.jdi.connect.spi.TransportService \
|
||||
META-INF/services/com.sun.tools.attach.spi.AttachProvider \
|
||||
META-INF/services/com.sun.tools.xjc.Plugin \
|
||||
META-INF/services/java.nio.charset.spi.CharsetProvider \
|
||||
META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor \
|
||||
org/relaxng/datatype \
|
||||
sun/awt/HKSCS.class \
|
||||
@ -217,19 +216,7 @@ RT_JAR_EXCLUDES += \
|
||||
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/ECKeyFactory.class \
|
||||
sun/security/ec/ECKeyPairGenerator.class \
|
||||
sun/security/ec/SunEC\$$$$1.class \
|
||||
sun/security/ec/SunEC.class \
|
||||
sun/security/ec/SunECEntries.class \
|
||||
sun/security/ec \
|
||||
sun/security/internal \
|
||||
sun/security/mscapi \
|
||||
sun/security/pkcs11 \
|
||||
@ -428,8 +415,7 @@ $(eval $(call SetupArchive,BUILD_CHARSETS_JAR,,\
|
||||
SUFFIXES:=.class .dat,\
|
||||
INCLUDES:=sun/nio/cs/ext,\
|
||||
EXTRA_FILES := sun/awt/HKSCS.class \
|
||||
$(CHARSETS_EXTRA_FILES) \
|
||||
META-INF/services/java.nio.charset.spi.CharsetProvider, \
|
||||
$(CHARSETS_EXTRA_FILES), \
|
||||
JAR:=$(IMAGES_OUTPUTDIR)/lib/charsets.jar, \
|
||||
SKIP_METAINF := true, \
|
||||
CHECK_COMPRESS_JAR:=true))
|
||||
|
@ -532,17 +532,22 @@ ifndef OPENJDK
|
||||
$(IMAGES_OUTPUTDIR)/_unzip/%.unzipped: $(JDK_TOPDIR)/src/closed/share/db/%
|
||||
$(ECHO) Unzipping $(patsubst $(SRC_ROOT)/%,%,$<)
|
||||
$(MKDIR) -p $(JDK_IMAGE_DIR)/db
|
||||
cd $(JDK_IMAGE_DIR)/db && $(UNZIP) -q -o $< -x index.html 2> /dev/null
|
||||
cd $(JDK_IMAGE_DIR)/db && $(UNZIP) -q -o $< -x */index.html */KEYS */test/* *javadoc/* */docs/* */demo/* 2> /dev/null
|
||||
cd $(JDK_IMAGE_DIR)/db && $(MV) db-derby-*-bin/* . && $(RM) -r db-derby-*-bin
|
||||
$(MKDIR) -p $(@D)
|
||||
$(TOUCH) $@
|
||||
|
||||
$(JDK_IMAGE_DIR)/db/README-JDK.html: $(JDK_TOPDIR)/src/closed/share/db/README-JDK.html
|
||||
$(ECHO) $(LOG_INFO) Copying '$(patsubst $(OUTPUT_ROOT)/%,%,$@)'
|
||||
$(install-file)
|
||||
$(CAT) $< | $(SED) "s/XXXX/$(shell cat $(JDK_TOPDIR)/src/closed/share/db/COPYRIGHTYEAR)/" > $@
|
||||
|
||||
$(JDK_IMAGE_DIR)/db/3RDPARTY: $(JDK_TOPDIR)/src/closed/share/db/3RDPARTY
|
||||
$(ECHO) $(LOG_INFO) Copying '$(patsubst $(OUTPUT_ROOT)/%,%,$@)'
|
||||
$(CAT) $< | $(SED) "s/XXXX/$(shell cat $(JDK_TOPDIR)/src/closed/share/db/COPYRIGHTYEAR)/" > $@
|
||||
|
||||
JDK_DB_TARGETS := $(patsubst $(JDK_TOPDIR)/src/closed/share/db/%,$(IMAGES_OUTPUTDIR)/_unzip/%.unzipped,\
|
||||
$(call not-containing,demo,$(wildcard $(JDK_TOPDIR)/src/closed/share/db/*.zip))) \
|
||||
$(JDK_IMAGE_DIR)/db/README-JDK.html
|
||||
$(wildcard $(JDK_TOPDIR)/src/closed/share/db/*.zip)) \
|
||||
$(JDK_IMAGE_DIR)/db/README-JDK.html $(JDK_IMAGE_DIR)/db/3RDPARTY
|
||||
|
||||
endif
|
||||
|
||||
|
@ -57,6 +57,7 @@ PROFILE_1_RTJAR_INCLUDE_PACKAGES := \
|
||||
java/time \
|
||||
java/util \
|
||||
javax/net \
|
||||
javax/script \
|
||||
javax/security \
|
||||
jdk \
|
||||
sun/invoke \
|
||||
@ -111,7 +112,6 @@ PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
|
||||
com/sun/nio/sctp \
|
||||
com/sun/org/apache/xml/internal/security \
|
||||
com/sun/rowset \
|
||||
com/sun/script \
|
||||
com/sun/security/auth \
|
||||
com/sun/security/jgss \
|
||||
com/sun/security/ntlm \
|
||||
@ -125,7 +125,6 @@ PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
|
||||
javax/lang/model \
|
||||
javax/management \
|
||||
javax/naming \
|
||||
javax/script \
|
||||
javax/security/auth/kerberos \
|
||||
javax/security/sasl \
|
||||
javax/smartcardio \
|
||||
@ -140,7 +139,6 @@ PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
|
||||
sun/net/www/protocol/http/ntlm \
|
||||
sun/net/www/protocol/http/spnego \
|
||||
sun/nio/ch/sctp \
|
||||
sun/org/mozilla \
|
||||
sun/security/acl \
|
||||
sun/security/jgss \
|
||||
sun/security/krb5 \
|
||||
@ -161,10 +159,6 @@ PROFILE_3_RTJAR_EXCLUDE_TYPES := \
|
||||
javax/management/remote/rmi/_RMIServerImpl_Tie.class \
|
||||
javax/management/remote/rmi/_RMIServer_Stub.class
|
||||
|
||||
PROFILE_3_INCLUDE_METAINF_SERVICES := \
|
||||
META-INF/services/javax.script.ScriptEngineFactory
|
||||
|
||||
|
||||
FULL_JRE_RTJAR_INCLUDE_PACKAGES := \
|
||||
com/oracle \
|
||||
com/sun/accessibility/internal/resources \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 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
|
||||
@ -149,12 +149,15 @@ static int KnownVMIndex(const char* name);
|
||||
static void FreeKnownVMs();
|
||||
static jboolean IsWildCardEnabled();
|
||||
|
||||
#define ARG_CHECK(n, f, a) if (n < 1) { \
|
||||
JLI_ReportErrorMessage(f, a); \
|
||||
printUsage = JNI_TRUE; \
|
||||
*pret = 1; \
|
||||
return JNI_TRUE; \
|
||||
}
|
||||
#define ARG_CHECK(AC_arg_count, AC_failure_message, AC_questionable_arg) \
|
||||
do { \
|
||||
if (AC_arg_count < 1) { \
|
||||
JLI_ReportErrorMessage(AC_failure_message, AC_questionable_arg); \
|
||||
printUsage = JNI_TRUE; \
|
||||
*pret = 1; \
|
||||
return JNI_TRUE; \
|
||||
} \
|
||||
} while (JNI_FALSE)
|
||||
|
||||
/*
|
||||
* Running Java code in primordial thread caused many problems. We will
|
||||
@ -310,29 +313,37 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
|
||||
* mainThread.isAlive() to work as expected.
|
||||
*/
|
||||
#define LEAVE() \
|
||||
if ((*vm)->DetachCurrentThread(vm) != 0) { \
|
||||
JLI_ReportErrorMessage(JVM_ERROR2); \
|
||||
ret = 1; \
|
||||
} \
|
||||
(*vm)->DestroyJavaVM(vm); \
|
||||
return ret \
|
||||
do { \
|
||||
if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \
|
||||
JLI_ReportErrorMessage(JVM_ERROR2); \
|
||||
ret = 1; \
|
||||
} \
|
||||
if (JNI_TRUE) { \
|
||||
(*vm)->DestroyJavaVM(vm); \
|
||||
return ret; \
|
||||
} \
|
||||
} while (JNI_FALSE)
|
||||
|
||||
#define CHECK_EXCEPTION_NULL_LEAVE(e) \
|
||||
if ((*env)->ExceptionOccurred(env)) { \
|
||||
JLI_ReportExceptionDescription(env); \
|
||||
LEAVE(); \
|
||||
} \
|
||||
if ((e) == NULL) { \
|
||||
JLI_ReportErrorMessage(JNI_ERROR); \
|
||||
LEAVE(); \
|
||||
}
|
||||
#define CHECK_EXCEPTION_NULL_LEAVE(CENL_exception) \
|
||||
do { \
|
||||
if ((*env)->ExceptionOccurred(env)) { \
|
||||
JLI_ReportExceptionDescription(env); \
|
||||
LEAVE(); \
|
||||
} \
|
||||
if ((CENL_exception) == NULL) { \
|
||||
JLI_ReportErrorMessage(JNI_ERROR); \
|
||||
LEAVE(); \
|
||||
} \
|
||||
} while (JNI_FALSE)
|
||||
|
||||
#define CHECK_EXCEPTION_LEAVE(rv) \
|
||||
if ((*env)->ExceptionOccurred(env)) { \
|
||||
JLI_ReportExceptionDescription(env); \
|
||||
ret = (rv); \
|
||||
LEAVE(); \
|
||||
}
|
||||
#define CHECK_EXCEPTION_LEAVE(CEL_return_value) \
|
||||
do { \
|
||||
if ((*env)->ExceptionOccurred(env)) { \
|
||||
JLI_ReportExceptionDescription(env); \
|
||||
ret = (CEL_return_value); \
|
||||
LEAVE(); \
|
||||
} \
|
||||
} while (JNI_FALSE)
|
||||
|
||||
int JNICALL
|
||||
JavaMain(void * _args)
|
||||
@ -434,7 +445,7 @@ JavaMain(void * _args)
|
||||
* consistent in the UI we need to track and report the application main class.
|
||||
*/
|
||||
appClass = GetApplicationClass(env);
|
||||
NULL_CHECK(appClass);
|
||||
NULL_CHECK_RETURN_VALUE(appClass, -1);
|
||||
/*
|
||||
* PostJVMInit uses the class name as the application name for GUI purposes,
|
||||
* for example, on OSX this sets the application name in the menu bar for
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -242,14 +242,18 @@ typedef struct {
|
||||
InvocationFunctions ifn;
|
||||
} JavaMainArgs;
|
||||
|
||||
#define NULL_CHECK0(e) if ((e) == 0) { \
|
||||
JLI_ReportErrorMessage(JNI_ERROR); \
|
||||
return 0; \
|
||||
}
|
||||
#define NULL_CHECK_RETURN_VALUE(NCRV_check_pointer, NCRV_return_value) \
|
||||
do { \
|
||||
if ((NCRV_check_pointer) == NULL) { \
|
||||
JLI_ReportErrorMessage(JNI_ERROR); \
|
||||
return NCRV_return_value; \
|
||||
} \
|
||||
} while (JNI_FALSE)
|
||||
|
||||
#define NULL_CHECK(e) if ((e) == 0) { \
|
||||
JLI_ReportErrorMessage(JNI_ERROR); \
|
||||
return; \
|
||||
}
|
||||
#define NULL_CHECK0(NC0_check_pointer) \
|
||||
NULL_CHECK_RETURN_VALUE(NC0_check_pointer, 0)
|
||||
|
||||
#define NULL_CHECK(NC_check_pointer) \
|
||||
NULL_CHECK_RETURN_VALUE(NC_check_pointer, )
|
||||
|
||||
#endif /* _JAVA_H_ */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 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
|
||||
@ -136,8 +136,10 @@ WildcardIterator_for(const char *wildcard)
|
||||
{
|
||||
WildcardIterator it = NEW_(WildcardIterator);
|
||||
HANDLE handle = FindFirstFile(wildcard, &find_data);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
JLI_MemFree(it);
|
||||
return NULL;
|
||||
}
|
||||
it->handle = handle;
|
||||
it->firstFile = find_data.cFileName;
|
||||
return it;
|
||||
|
@ -99,6 +99,7 @@ class Attribute implements Comparable<Attribute> {
|
||||
return this == def.canon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Attribute that) {
|
||||
return this.def.compareTo(that.def);
|
||||
}
|
||||
@ -212,20 +213,20 @@ class Attribute implements Comparable<Attribute> {
|
||||
// Metadata.
|
||||
//
|
||||
// We define metadata using similar layouts
|
||||
// for all five kinds of metadata attributes.
|
||||
// for all five kinds of metadata attributes and 2 type metadata attributes
|
||||
//
|
||||
// Regular annotations are a counted list of [RSHNH[RUH(1)]][...]
|
||||
// pack.method.attribute.RuntimeVisibleAnnotations=[NH[(1)]][RSHNH[RUH(1)]][TB...]
|
||||
//
|
||||
// Parameter annotations are a counted list of regular annotations.
|
||||
// pack.method.attribute.RuntimeVisibleParameterAnnotations=[NH[(1)]][NH[(1)]][RSHNH[RUH(1)]][TB...]
|
||||
// pack.method.attribute.RuntimeVisibleParameterAnnotations=[NB[(1)]][NH[(1)]][RSHNH[RUH(1)]][TB...]
|
||||
//
|
||||
// RuntimeInvisible annotations are defined similarly...
|
||||
// Non-method annotations are defined similarly...
|
||||
//
|
||||
// Annotation are a simple tagged value [TB...]
|
||||
// pack.attribute.method.AnnotationDefault=[TB...]
|
||||
//
|
||||
|
||||
static {
|
||||
String mdLayouts[] = {
|
||||
Attribute.normalizeLayoutString
|
||||
@ -238,6 +239,9 @@ class Attribute implements Comparable<Attribute> {
|
||||
+"\n # annotations :="
|
||||
+"\n [ NH[(1)] ] # forward call to annotation"
|
||||
+"\n "
|
||||
),
|
||||
Attribute.normalizeLayoutString
|
||||
(""
|
||||
+"\n # annotation :="
|
||||
+"\n [RSH"
|
||||
+"\n NH[RUH (1)] # forward call to value"
|
||||
@ -259,24 +263,67 @@ class Attribute implements Comparable<Attribute> {
|
||||
+"\n ()[] ]"
|
||||
)
|
||||
};
|
||||
/*
|
||||
* RuntimeVisibleTypeAnnotation and RuntimeInvisibleTypeAnnotatation are
|
||||
* similar to RuntimeVisibleAnnotation and RuntimeInvisibleAnnotation,
|
||||
* a type-annotation union and a type-path structure precedes the
|
||||
* annotation structure
|
||||
*/
|
||||
String typeLayouts[] = {
|
||||
Attribute.normalizeLayoutString
|
||||
(""
|
||||
+"\n # type-annotations :="
|
||||
+"\n [ NH[(1)(2)(3)] ] # forward call to type-annotations"
|
||||
),
|
||||
Attribute.normalizeLayoutString
|
||||
( ""
|
||||
+"\n # type-annotation :="
|
||||
+"\n [TB"
|
||||
+"\n (0-1) [B] # {CLASS, METHOD}_TYPE_PARAMETER"
|
||||
+"\n (16) [FH] # CLASS_EXTENDS"
|
||||
+"\n (17-18) [BB] # {CLASS, METHOD}_TYPE_PARAMETER_BOUND"
|
||||
+"\n (19-21) [] # FIELD, METHOD_RETURN, METHOD_RECEIVER"
|
||||
+"\n (22) [B] # METHOD_FORMAL_PARAMETER"
|
||||
+"\n (23) [H] # THROWS"
|
||||
+"\n (64-65) [NH[PHOHH]] # LOCAL_VARIABLE, RESOURCE_VARIABLE"
|
||||
+"\n (66) [H] # EXCEPTION_PARAMETER"
|
||||
+"\n (67-70) [PH] # INSTANCEOF, NEW, {CONSTRUCTOR, METHOD}_REFERENCE_RECEIVER"
|
||||
+"\n (71-75) [PHB] # CAST, {CONSTRUCTOR,METHOD}_INVOCATION_TYPE_ARGUMENT, {CONSTRUCTOR, METHOD}_REFERENCE_TYPE_ARGUMENT"
|
||||
+"\n ()[] ]"
|
||||
),
|
||||
Attribute.normalizeLayoutString
|
||||
(""
|
||||
+"\n # type-path"
|
||||
+"\n [ NB[BB] ]"
|
||||
)
|
||||
};
|
||||
Map<Layout, Attribute> sd = standardDefs;
|
||||
String defaultLayout = mdLayouts[2];
|
||||
String annotationsLayout = mdLayouts[1] + mdLayouts[2];
|
||||
String defaultLayout = mdLayouts[3];
|
||||
String annotationsLayout = mdLayouts[1] + mdLayouts[2] + mdLayouts[3];
|
||||
String paramsLayout = mdLayouts[0] + annotationsLayout;
|
||||
String typesLayout = typeLayouts[0] + typeLayouts[1] +
|
||||
typeLayouts[2] + mdLayouts[2] + mdLayouts[3];
|
||||
|
||||
for (int ctype = 0; ctype < ATTR_CONTEXT_LIMIT; ctype++) {
|
||||
if (ctype == ATTR_CONTEXT_CODE) continue;
|
||||
define(sd, ctype,
|
||||
"RuntimeVisibleAnnotations", annotationsLayout);
|
||||
define(sd, ctype,
|
||||
"RuntimeInvisibleAnnotations", annotationsLayout);
|
||||
if (ctype == ATTR_CONTEXT_METHOD) {
|
||||
if (ctype != ATTR_CONTEXT_CODE) {
|
||||
define(sd, ctype,
|
||||
"RuntimeVisibleParameterAnnotations", paramsLayout);
|
||||
"RuntimeVisibleAnnotations", annotationsLayout);
|
||||
define(sd, ctype,
|
||||
"RuntimeInvisibleParameterAnnotations", paramsLayout);
|
||||
define(sd, ctype,
|
||||
"AnnotationDefault", defaultLayout);
|
||||
"RuntimeInvisibleAnnotations", annotationsLayout);
|
||||
|
||||
if (ctype == ATTR_CONTEXT_METHOD) {
|
||||
define(sd, ctype,
|
||||
"RuntimeVisibleParameterAnnotations", paramsLayout);
|
||||
define(sd, ctype,
|
||||
"RuntimeInvisibleParameterAnnotations", paramsLayout);
|
||||
define(sd, ctype,
|
||||
"AnnotationDefault", defaultLayout);
|
||||
}
|
||||
}
|
||||
define(sd, ctype,
|
||||
"RuntimeVisibleTypeAnnotations", typesLayout);
|
||||
define(sd, ctype,
|
||||
"RuntimeInvisibleTypeAnnotations", typesLayout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -529,6 +576,7 @@ class Attribute implements Comparable<Attribute> {
|
||||
return canon.addContent(bytes, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object x) {
|
||||
return ( x != null) && ( x.getClass() == Layout.class ) &&
|
||||
equals((Layout)x);
|
||||
@ -538,11 +586,13 @@ class Attribute implements Comparable<Attribute> {
|
||||
&& this.layout.equals(that.layout)
|
||||
&& this.ctype == that.ctype;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (((17 + name.hashCode())
|
||||
* 37 + layout.hashCode())
|
||||
* 37 + ctype);
|
||||
}
|
||||
@Override
|
||||
public int compareTo(Layout that) {
|
||||
int r;
|
||||
r = this.name.compareTo(that.name);
|
||||
@ -551,6 +601,7 @@ class Attribute implements Comparable<Attribute> {
|
||||
if (r != 0) return r;
|
||||
return this.ctype - that.ctype;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
String str = contextName(ctype)+"."+name+"["+layout+"]";
|
||||
// If -ea, print out more informative strings!
|
||||
@ -698,11 +749,14 @@ class Attribute implements Comparable<Attribute> {
|
||||
// References (to a local cpMap) are embedded in the bytes.
|
||||
def.parse(holder, bytes, 0, bytes.length,
|
||||
new ValueStream() {
|
||||
@Override
|
||||
public void putInt(int bandIndex, int value) {
|
||||
}
|
||||
@Override
|
||||
public void putRef(int bandIndex, Entry ref) {
|
||||
refs.add(ref);
|
||||
}
|
||||
@Override
|
||||
public int encodeBCI(int bci) {
|
||||
return bci;
|
||||
}
|
||||
@ -716,6 +770,7 @@ class Attribute implements Comparable<Attribute> {
|
||||
return def.unparse(in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return def
|
||||
+"{"+(bytes == null ? -1 : size())+"}"
|
||||
@ -1309,7 +1364,7 @@ class Attribute implements Comparable<Attribute> {
|
||||
}
|
||||
out.putRef(bandIndex, globalRef);
|
||||
break;
|
||||
default: assert(false); continue;
|
||||
default: assert(false);
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
@ -1416,8 +1471,7 @@ class Attribute implements Comparable<Attribute> {
|
||||
int localRef;
|
||||
if (globalRef != null) {
|
||||
// It's a one-element array, really an lvalue.
|
||||
fixups[0] = Fixups.add(fixups[0], null, out.size(),
|
||||
Fixups.U2_FORMAT, globalRef);
|
||||
fixups[0] = Fixups.addRefWithLoc(fixups[0], out.size(), globalRef);
|
||||
localRef = 0; // placeholder for fixups
|
||||
} else {
|
||||
localRef = 0; // fixed null value
|
||||
|
@ -48,6 +48,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.jar.Pack200;
|
||||
import static com.sun.java.util.jar.pack.Constants.*;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Define the structure and ordering of "bands" in a packed file.
|
||||
@ -495,6 +496,7 @@ class BandStructure {
|
||||
}
|
||||
|
||||
protected int lengthForDebug = -1; // DEBUG ONLY
|
||||
@Override
|
||||
public String toString() { // DEBUG ONLY
|
||||
int length = (lengthForDebug != -1 ? lengthForDebug : length());
|
||||
String str = name;
|
||||
@ -518,20 +520,24 @@ class BandStructure {
|
||||
super(name, regularCoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return values == null ? -1 : values.length;
|
||||
}
|
||||
|
||||
/** Declare predicted or needed capacity. */
|
||||
@Override
|
||||
protected void setCapacity(int cap) {
|
||||
assert(length <= cap);
|
||||
if (cap == -1) { values = null; return; }
|
||||
values = realloc(values, cap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return length;
|
||||
}
|
||||
@Override
|
||||
protected int valuesRemainingForDebug() {
|
||||
return length - valuesDisbursed;
|
||||
}
|
||||
@ -583,6 +589,7 @@ class BandStructure {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void chooseBandCodings() throws IOException {
|
||||
boolean canVary = canVaryCoding();
|
||||
if (!canVary || !shouldVaryCoding()) {
|
||||
@ -653,6 +660,7 @@ class BandStructure {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long computeOutputSize() {
|
||||
outputSize = getCodingChooser().computeByteSize(bandCoding,
|
||||
values, 0, length);
|
||||
@ -668,6 +676,7 @@ class BandStructure {
|
||||
return regularCoding.setD(0).getLength(X);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeDataTo(OutputStream out) throws IOException {
|
||||
if (length == 0) return; // nothing to write
|
||||
long len0 = 0;
|
||||
@ -691,6 +700,7 @@ class BandStructure {
|
||||
if (optDumpBands) dumpBand();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readDataFrom(InputStream in) throws IOException {
|
||||
length = valuesExpected();
|
||||
if (length == 0) return; // nothing to read
|
||||
@ -707,7 +717,6 @@ class BandStructure {
|
||||
if (XB < 0) {
|
||||
// Do not consume this value. No alternate coding.
|
||||
in.reset();
|
||||
XB = _meta_default;
|
||||
bandCoding = regularCoding;
|
||||
metaCoding = noMetaCoding;
|
||||
} else if (XB == _meta_default) {
|
||||
@ -733,6 +742,7 @@ class BandStructure {
|
||||
if (optDumpBands) dumpBand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneDisbursing() {
|
||||
super.doneDisbursing();
|
||||
values = null; // for GC
|
||||
@ -763,7 +773,10 @@ class BandStructure {
|
||||
/** Disburse one value. */
|
||||
protected int getValue() {
|
||||
assert(phase() == DISBURSE_PHASE);
|
||||
assert(valuesDisbursed < length);
|
||||
// when debugging return a zero if lengths are zero
|
||||
if (optDebugBands && length == 0 && valuesDisbursed == length)
|
||||
return 0;
|
||||
assert(valuesDisbursed <= length);
|
||||
return values[valuesDisbursed++];
|
||||
}
|
||||
|
||||
@ -784,9 +797,11 @@ class BandStructure {
|
||||
super(name, BYTE1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int capacity() {
|
||||
return bytes == null ? -1 : Integer.MAX_VALUE;
|
||||
}
|
||||
@Override
|
||||
protected void setCapacity(int cap) {
|
||||
assert(bytes == null); // do this just once
|
||||
bytes = new ByteArrayOutputStream(cap);
|
||||
@ -796,27 +811,32 @@ class BandStructure {
|
||||
bytes = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return bytes == null ? -1 : bytes.size();
|
||||
}
|
||||
public void reset() {
|
||||
bytes.reset();
|
||||
}
|
||||
@Override
|
||||
protected int valuesRemainingForDebug() {
|
||||
return (bytes == null) ? -1 : ((ByteArrayInputStream)in).available();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void chooseBandCodings() throws IOException {
|
||||
// No-op.
|
||||
assert(decodeEscapeValue(regularCoding.min(), regularCoding) < 0);
|
||||
assert(decodeEscapeValue(regularCoding.max(), regularCoding) < 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long computeOutputSize() {
|
||||
// do not cache
|
||||
return bytes.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDataTo(OutputStream out) throws IOException {
|
||||
if (length() == 0) return;
|
||||
bytes.writeTo(out);
|
||||
@ -834,6 +854,7 @@ class BandStructure {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDataFrom(InputStream in) throws IOException {
|
||||
int vex = valuesExpected();
|
||||
if (vex == 0) return;
|
||||
@ -852,11 +873,13 @@ class BandStructure {
|
||||
if (optDumpBands) dumpBand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readyToDisburse() {
|
||||
in = new ByteArrayInputStream(bytes.toByteArray());
|
||||
super.readyToDisburse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneDisbursing() {
|
||||
super.doneDisbursing();
|
||||
if (optDumpBands
|
||||
@ -882,11 +905,13 @@ class BandStructure {
|
||||
// Tap the stream.
|
||||
bytesForDump = new ByteArrayOutputStream();
|
||||
this.in = new FilterInputStream(in) {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int ch = in.read();
|
||||
if (ch >= 0) bytesForDump.write(ch);
|
||||
return ch;
|
||||
}
|
||||
@Override
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
int nr = in.read(b, off, len);
|
||||
if (nr >= 0) bytesForDump.write(b, off, nr);
|
||||
@ -917,6 +942,7 @@ class BandStructure {
|
||||
assert(b == (b & 0xFF));
|
||||
collectorStream().write(b);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "byte "+super.toString();
|
||||
}
|
||||
@ -1184,6 +1210,7 @@ class BandStructure {
|
||||
super(name, regularCoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Band init() {
|
||||
super.init();
|
||||
// This is all just to keep the asserts happy:
|
||||
@ -1259,12 +1286,17 @@ class BandStructure {
|
||||
int bandCount() { return bandCount; }
|
||||
|
||||
private int cap = -1;
|
||||
@Override
|
||||
public int capacity() { return cap; }
|
||||
@Override
|
||||
public void setCapacity(int cap) { this.cap = cap; }
|
||||
|
||||
@Override
|
||||
public int length() { return 0; }
|
||||
@Override
|
||||
public int valuesRemainingForDebug() { return 0; }
|
||||
|
||||
@Override
|
||||
protected void chooseBandCodings() throws IOException {
|
||||
// coding decision pass
|
||||
for (int i = 0; i < bandCount; i++) {
|
||||
@ -1273,6 +1305,7 @@ class BandStructure {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long computeOutputSize() {
|
||||
// coding decision pass
|
||||
long sum = 0;
|
||||
@ -1286,6 +1319,7 @@ class BandStructure {
|
||||
return sum;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeDataTo(OutputStream out) throws IOException {
|
||||
long preCount = 0;
|
||||
if (outputCounter != null) preCount = outputCounter.getCount();
|
||||
@ -1303,6 +1337,7 @@ class BandStructure {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readDataFrom(InputStream in) throws IOException {
|
||||
assert(false); // not called?
|
||||
for (int i = 0; i < bandCount; i++) {
|
||||
@ -1314,6 +1349,7 @@ class BandStructure {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{"+bandCount()+" bands: "+super.toString()+"}";
|
||||
}
|
||||
@ -1335,14 +1371,17 @@ class BandStructure {
|
||||
public long getCount() { return count; }
|
||||
public void setCount(long c) { count = c; }
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
count++;
|
||||
if (out != null) out.write(b);
|
||||
}
|
||||
@Override
|
||||
public void write(byte b[], int off, int len) throws IOException {
|
||||
count += len;
|
||||
if (out != null) out.write(b, off, len);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(getCount());
|
||||
}
|
||||
@ -1490,6 +1529,7 @@ class BandStructure {
|
||||
CPRefBand field_ConstantValue_KQ = field_attr_bands.newCPRefBand("field_ConstantValue_KQ", CONSTANT_FieldSpecific);
|
||||
CPRefBand field_Signature_RS = field_attr_bands.newCPRefBand("field_Signature_RS", CONSTANT_Signature);
|
||||
MultiBand field_metadata_bands = field_attr_bands.newMultiBand("(field_metadata_bands)", UNSIGNED5);
|
||||
MultiBand field_type_metadata_bands = field_attr_bands.newMultiBand("(field_type_metadata_bands)", UNSIGNED5);
|
||||
|
||||
CPRefBand method_descr = class_bands.newCPRefBand("method_descr", MDELTA5, CONSTANT_NameandType);
|
||||
MultiBand method_attr_bands = class_bands.newMultiBand("(method_attr_bands)", UNSIGNED5);
|
||||
@ -1507,6 +1547,7 @@ class BandStructure {
|
||||
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_FH = method_attr_bands.newIntBand("method_MethodParameters_flag_FH");
|
||||
MultiBand method_type_metadata_bands = method_attr_bands.newMultiBand("(method_type_metadata_bands)", UNSIGNED5);
|
||||
|
||||
MultiBand class_attr_bands = class_bands.newMultiBand("(class_attr_bands)", UNSIGNED5);
|
||||
IntBand class_flags_hi = class_attr_bands.newIntBand("class_flags_hi");
|
||||
@ -1527,6 +1568,7 @@ class BandStructure {
|
||||
CPRefBand class_InnerClasses_name_RUN = class_attr_bands.newCPRefBand("class_InnerClasses_name_RUN", UNSIGNED5, CONSTANT_Utf8, NULL_IS_OK);
|
||||
IntBand class_ClassFile_version_minor_H = class_attr_bands.newIntBand("class_ClassFile_version_minor_H");
|
||||
IntBand class_ClassFile_version_major_H = class_attr_bands.newIntBand("class_ClassFile_version_major_H");
|
||||
MultiBand class_type_metadata_bands = class_attr_bands.newMultiBand("(class_type_metadata_bands)", UNSIGNED5);
|
||||
|
||||
MultiBand code_bands = class_bands.newMultiBand("(code_bands)", UNSIGNED5);
|
||||
ByteBand code_headers = code_bands.newByteBand("code_headers"); //BYTE1
|
||||
@ -1545,7 +1587,7 @@ class BandStructure {
|
||||
IntBand code_attr_indexes = code_attr_bands.newIntBand("code_attr_indexes");
|
||||
IntBand code_attr_calls = code_attr_bands.newIntBand("code_attr_calls");
|
||||
|
||||
MultiBand stackmap_bands = code_attr_bands.newMultiBand("StackMapTable_bands", UNSIGNED5);
|
||||
MultiBand stackmap_bands = code_attr_bands.newMultiBand("(StackMapTable_bands)", UNSIGNED5);
|
||||
IntBand code_StackMapTable_N = stackmap_bands.newIntBand("code_StackMapTable_N");
|
||||
IntBand code_StackMapTable_frame_T = stackmap_bands.newIntBand("code_StackMapTable_frame_T",BYTE1);
|
||||
IntBand code_StackMapTable_local_N = stackmap_bands.newIntBand("code_StackMapTable_local_N");
|
||||
@ -1573,6 +1615,7 @@ class BandStructure {
|
||||
CPRefBand code_LocalVariableTypeTable_name_RU = code_attr_bands.newCPRefBand("code_LocalVariableTypeTable_name_RU", CONSTANT_Utf8);
|
||||
CPRefBand code_LocalVariableTypeTable_type_RS = code_attr_bands.newCPRefBand("code_LocalVariableTypeTable_type_RS", CONSTANT_Signature);
|
||||
IntBand code_LocalVariableTypeTable_slot = code_attr_bands.newIntBand("code_LocalVariableTypeTable_slot");
|
||||
MultiBand code_type_metadata_bands = code_attr_bands.newMultiBand("(code_type_metadata_bands)", UNSIGNED5);
|
||||
|
||||
// bands for bytecodes
|
||||
MultiBand bc_bands = all_bands.newMultiBand("(byte_codes)", UNSIGNED5);
|
||||
@ -1678,6 +1721,14 @@ class BandStructure {
|
||||
metadataBands[ATTR_CONTEXT_FIELD] = field_metadata_bands;
|
||||
metadataBands[ATTR_CONTEXT_METHOD] = method_metadata_bands;
|
||||
}
|
||||
// Table of bands which contains type_metadata (TypeAnnotations)
|
||||
protected MultiBand[] typeMetadataBands = new MultiBand[ATTR_CONTEXT_LIMIT];
|
||||
{
|
||||
typeMetadataBands[ATTR_CONTEXT_CLASS] = class_type_metadata_bands;
|
||||
typeMetadataBands[ATTR_CONTEXT_FIELD] = field_type_metadata_bands;
|
||||
typeMetadataBands[ATTR_CONTEXT_METHOD] = method_type_metadata_bands;
|
||||
typeMetadataBands[ATTR_CONTEXT_CODE] = code_type_metadata_bands;
|
||||
}
|
||||
|
||||
// Attribute layouts.
|
||||
public static final int ADH_CONTEXT_MASK = 0x3; // (ad_hdr & ADH_CONTEXT_MASK)
|
||||
@ -1793,36 +1844,47 @@ class BandStructure {
|
||||
|
||||
for (int ctype = 0; ctype < ATTR_CONTEXT_LIMIT; ctype++) {
|
||||
MultiBand xxx_metadata_bands = metadataBands[ctype];
|
||||
if (xxx_metadata_bands == null)
|
||||
continue; // no code attrs
|
||||
if (ctype != ATTR_CONTEXT_CODE) {
|
||||
// These arguments cause the bands to be built
|
||||
// automatically for this complicated layout:
|
||||
predefineAttribute(X_ATTR_RuntimeVisibleAnnotations,
|
||||
ATTR_CONTEXT_NAME[ctype]+"_RVA_",
|
||||
xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeVisibleAnnotations"));
|
||||
predefineAttribute(X_ATTR_RuntimeInvisibleAnnotations,
|
||||
ATTR_CONTEXT_NAME[ctype]+"_RIA_",
|
||||
xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeInvisibleAnnotations"));
|
||||
|
||||
// These arguments cause the bands to be built
|
||||
// automatically for this complicated layout:
|
||||
predefineAttribute(X_ATTR_RuntimeVisibleAnnotations,
|
||||
ATTR_CONTEXT_NAME[ctype]+"_RVA_",
|
||||
xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeVisibleAnnotations"));
|
||||
predefineAttribute(X_ATTR_RuntimeInvisibleAnnotations,
|
||||
ATTR_CONTEXT_NAME[ctype]+"_RIA_",
|
||||
xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeInvisibleAnnotations"));
|
||||
if (ctype != ATTR_CONTEXT_METHOD)
|
||||
continue;
|
||||
|
||||
predefineAttribute(METHOD_ATTR_RuntimeVisibleParameterAnnotations,
|
||||
"method_RVPA_", xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeVisibleParameterAnnotations"));
|
||||
predefineAttribute(METHOD_ATTR_RuntimeInvisibleParameterAnnotations,
|
||||
"method_RIPA_", xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeInvisibleParameterAnnotations"));
|
||||
predefineAttribute(METHOD_ATTR_AnnotationDefault,
|
||||
"method_AD_", xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"AnnotationDefault"));
|
||||
if (ctype == ATTR_CONTEXT_METHOD) {
|
||||
predefineAttribute(METHOD_ATTR_RuntimeVisibleParameterAnnotations,
|
||||
"method_RVPA_", xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeVisibleParameterAnnotations"));
|
||||
predefineAttribute(METHOD_ATTR_RuntimeInvisibleParameterAnnotations,
|
||||
"method_RIPA_", xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeInvisibleParameterAnnotations"));
|
||||
predefineAttribute(METHOD_ATTR_AnnotationDefault,
|
||||
"method_AD_", xxx_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"AnnotationDefault"));
|
||||
}
|
||||
}
|
||||
// All contexts have these
|
||||
MultiBand xxx_type_metadata_bands = typeMetadataBands[ctype];
|
||||
predefineAttribute(X_ATTR_RuntimeVisibleTypeAnnotations,
|
||||
ATTR_CONTEXT_NAME[ctype] + "_RVTA_",
|
||||
xxx_type_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeVisibleTypeAnnotations"));
|
||||
predefineAttribute(X_ATTR_RuntimeInvisibleTypeAnnotations,
|
||||
ATTR_CONTEXT_NAME[ctype] + "_RITA_",
|
||||
xxx_type_metadata_bands,
|
||||
Attribute.lookup(null, ctype,
|
||||
"RuntimeInvisibleTypeAnnotations"));
|
||||
}
|
||||
|
||||
|
||||
@ -2053,8 +2115,7 @@ class BandStructure {
|
||||
Attribute.Layout def = attr.layout();
|
||||
int ctype = def.ctype();
|
||||
return predefineAttribute(index, ctype,
|
||||
makeNewAttributeBands(bandPrefix, def,
|
||||
addHere),
|
||||
makeNewAttributeBands(bandPrefix, def, addHere),
|
||||
def.name(), def.layout());
|
||||
}
|
||||
|
||||
@ -2539,7 +2600,7 @@ class BandStructure {
|
||||
return true;
|
||||
}
|
||||
|
||||
// DEBUG ONLY: Validate next input band.
|
||||
// DEBUG ONLY: Validate next input band, ensure bands are read in sequence
|
||||
private boolean assertReadyToReadFrom(Band b, InputStream in) throws IOException {
|
||||
Band p = prevForAssertMap.get(b);
|
||||
// Any previous band must be done reading before this one starts.
|
||||
@ -2547,30 +2608,19 @@ class BandStructure {
|
||||
Utils.log.warning("Previous band not done reading.");
|
||||
Utils.log.info(" Previous band: "+p);
|
||||
Utils.log.info(" Next band: "+b);
|
||||
Thread.dumpStack();
|
||||
assert(verbose > 0); // die unless verbose is true
|
||||
}
|
||||
String name = b.name;
|
||||
if (optDebugBands && !name.startsWith("(")) {
|
||||
assert(bandSequenceList != null);
|
||||
// Verify synchronization between reader & writer:
|
||||
StringBuilder buf = new StringBuilder();
|
||||
int ch;
|
||||
while ((ch = in.read()) > 0)
|
||||
buf.append((char)ch);
|
||||
String inName = buf.toString();
|
||||
String inName = bandSequenceList.removeFirst();
|
||||
// System.out.println("Reading: " + name);
|
||||
if (!inName.equals(name)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Expected "+name+" but read: ");
|
||||
inName += (char)ch;
|
||||
while (inName.length() < 10) {
|
||||
inName += (char) in.read();
|
||||
}
|
||||
for (int i = 0; i < inName.length(); i++) {
|
||||
sb.append(inName.charAt(i));
|
||||
}
|
||||
Utils.log.warning(sb.toString());
|
||||
Utils.log.warning("Expected " + name + " but read: " + inName);
|
||||
return false;
|
||||
}
|
||||
Utils.log.info("Read band in sequence: " + name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -2590,7 +2640,12 @@ class BandStructure {
|
||||
return true;
|
||||
}
|
||||
|
||||
// DEBUG ONLY: Maybe write a debugging cookie to next output band.
|
||||
/*
|
||||
* DEBUG ONLY: write the bands to a list and read back the list in order,
|
||||
* this works perfectly if we use the java packer and unpacker, typically
|
||||
* this will work with --repack or if they are in the same jvm instance.
|
||||
*/
|
||||
static LinkedList<String> bandSequenceList = null;
|
||||
private boolean assertReadyToWriteTo(Band b, OutputStream out) throws IOException {
|
||||
Band p = prevForAssertMap.get(b);
|
||||
// Any previous band must be done writing before this one starts.
|
||||
@ -2598,16 +2653,15 @@ class BandStructure {
|
||||
Utils.log.warning("Previous band not done writing.");
|
||||
Utils.log.info(" Previous band: "+p);
|
||||
Utils.log.info(" Next band: "+b);
|
||||
Thread.dumpStack();
|
||||
assert(verbose > 0); // die unless verbose is true
|
||||
}
|
||||
String name = b.name;
|
||||
if (optDebugBands && !name.startsWith("(")) {
|
||||
if (bandSequenceList == null)
|
||||
bandSequenceList = new LinkedList<>();
|
||||
// Verify synchronization between reader & writer:
|
||||
for (int j = 0; j < name.length(); j++) {
|
||||
out.write((byte)name.charAt(j));
|
||||
}
|
||||
out.write((byte)0);
|
||||
bandSequenceList.add(name);
|
||||
// System.out.println("Writing: " + b);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -2664,7 +2718,7 @@ class BandStructure {
|
||||
buf.append("\\r");
|
||||
} else {
|
||||
String str = "000"+Integer.toHexString(ch);
|
||||
buf.append("\\u"+str.substring(str.length()-4));
|
||||
buf.append("\\u").append(str.substring(str.length()-4));
|
||||
}
|
||||
}
|
||||
ps.println(buf);
|
||||
|
@ -146,7 +146,6 @@ class Code extends Attribute.Holder {
|
||||
int verbose = getPackage().verbose;
|
||||
if (verbose > 2)
|
||||
System.out.println("Reference scan "+this);
|
||||
Class cls = thisClass();
|
||||
refs.addAll(Arrays.asList(handler_class));
|
||||
if (fixups != null) {
|
||||
fixups.visitRefs(refs);
|
||||
|
@ -785,53 +785,55 @@ class ConstantPool {
|
||||
return new String(sig);
|
||||
}
|
||||
|
||||
static private int skipClassNameChars(String sig, int i) {
|
||||
int len = sig.length();
|
||||
for (; i < len; i++) {
|
||||
char ch = sig.charAt(i);
|
||||
if (ch <= ' ') break;
|
||||
if (ch >= ';' && ch <= '@') break;
|
||||
}
|
||||
return i;
|
||||
static private int skipTo(char semi, String sig, int i) {
|
||||
i = sig.indexOf(semi, i);
|
||||
return (i >= 0) ? i : sig.length();
|
||||
}
|
||||
|
||||
static String[] structureSignature(String sig) {
|
||||
sig = sig.intern();
|
||||
|
||||
int formLen = 0;
|
||||
int nparts = 1;
|
||||
for (int i = 0; i < sig.length(); i++) {
|
||||
char ch = sig.charAt(i);
|
||||
formLen++;
|
||||
if (ch == 'L') {
|
||||
nparts++;
|
||||
int i2 = skipClassNameChars(sig, i+1);
|
||||
i = i2-1; // keep the semicolon in the form
|
||||
int i3 = sig.indexOf('<', i+1);
|
||||
if (i3 > 0 && i3 < i2)
|
||||
i = i3-1;
|
||||
}
|
||||
}
|
||||
char[] form = new char[formLen];
|
||||
if (nparts == 1) {
|
||||
int firstl = sig.indexOf('L');
|
||||
if (firstl < 0) {
|
||||
String[] parts = { sig };
|
||||
return parts;
|
||||
}
|
||||
String[] parts = new String[nparts];
|
||||
int j = 0;
|
||||
int k = 1;
|
||||
for (int i = 0; i < sig.length(); i++) {
|
||||
char ch = sig.charAt(i);
|
||||
form[j++] = ch;
|
||||
if (ch == 'L') {
|
||||
int i2 = skipClassNameChars(sig, i+1);
|
||||
parts[k++] = sig.substring(i+1, i2);
|
||||
i = i2;
|
||||
--i; // keep the semicolon in the form
|
||||
// Segment the string like sig.split("L\\([^;<]*\\)").
|
||||
// N.B.: Previous version of this code did a more complex match,
|
||||
// to next ch < ' ' or ch in [';'..'@']. The only important
|
||||
// characters are ';' and '<', since they are part of the
|
||||
// signature syntax.
|
||||
// Examples:
|
||||
// "(Ljava/lang/Object;IJLLoo;)V" => {"(L;IJL;)V", "java/lang/Object", "Loo"}
|
||||
// "Ljava/util/List<Ljava/lang/String;>;" => {"L<L;>;", "java/util/List", "java/lang/String"}
|
||||
char[] form = null;
|
||||
String[] parts = null;
|
||||
for (int pass = 0; pass <= 1; pass++) {
|
||||
// pass 0 is a sizing pass, pass 1 packs the arrays
|
||||
int formPtr = 0;
|
||||
int partPtr = 1;
|
||||
int nextsemi = 0, nextangl = 0; // next ';' or '<', or zero, or sigLen
|
||||
int lastj = 0;
|
||||
for (int i = firstl + 1, j; i > 0; i = sig.indexOf('L', j) + 1) {
|
||||
// sig[i-1] is 'L', while sig[j] will be the first ';' or '<' after it
|
||||
// each part is in sig[i .. j-1]
|
||||
if (nextsemi < i) nextsemi = skipTo(';', sig, i);
|
||||
if (nextangl < i) nextangl = skipTo('<', sig, i);
|
||||
j = (nextsemi < nextangl ? nextsemi : nextangl);
|
||||
if (pass != 0) {
|
||||
sig.getChars(lastj, i, form, formPtr);
|
||||
parts[partPtr] = sig.substring(i, j);
|
||||
}
|
||||
formPtr += (i - lastj);
|
||||
partPtr += 1;
|
||||
lastj = j;
|
||||
}
|
||||
if (pass != 0) {
|
||||
sig.getChars(lastj, sig.length(), form, formPtr);
|
||||
break;
|
||||
}
|
||||
formPtr += (sig.length() - lastj);
|
||||
form = new char[formPtr];
|
||||
parts = new String[partPtr];
|
||||
}
|
||||
assert(j == formLen);
|
||||
assert(k == parts.length);
|
||||
parts[0] = new String(form);
|
||||
//assert(flattenSignature(parts).equals(sig));
|
||||
return parts;
|
||||
|
@ -45,6 +45,7 @@ class Constants {
|
||||
1.5 to 1.5.X 49,0
|
||||
1.6 to 1.5.x 50,0
|
||||
1.7 to 1.6.x 51,0
|
||||
1.8 to 1.7.x 52,0
|
||||
*/
|
||||
|
||||
public final static Package.Version JAVA_MIN_CLASS_VERSION =
|
||||
@ -161,7 +162,9 @@ class Constants {
|
||||
METHOD_ATTR_RuntimeInvisibleParameterAnnotations = 24,
|
||||
CLASS_ATTR_ClassFile_version = 24,
|
||||
METHOD_ATTR_AnnotationDefault = 25,
|
||||
METHOD_ATTR_MethodParameters = 26,
|
||||
METHOD_ATTR_MethodParameters = 26, // JDK8
|
||||
X_ATTR_RuntimeVisibleTypeAnnotations = 27, // JDK8
|
||||
X_ATTR_RuntimeInvisibleTypeAnnotations = 28, // JDK8
|
||||
CODE_ATTR_StackMapTable = 0, // new in Java 6
|
||||
CODE_ATTR_LineNumberTable = 1,
|
||||
CODE_ATTR_LocalVariableTable = 2,
|
||||
|
@ -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
|
||||
@ -30,6 +30,7 @@ import java.util.AbstractCollection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Collection of relocatable constant pool references.
|
||||
@ -77,8 +78,9 @@ final class Fixups extends AbstractCollection<Fixups.Fixup> {
|
||||
|
||||
private static final int MINBIGSIZE = 1;
|
||||
// cleverly share empty bigDescs:
|
||||
private static int[] noBigDescs = {MINBIGSIZE};
|
||||
private static final int[] noBigDescs = {MINBIGSIZE};
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
@ -105,6 +107,7 @@ final class Fixups extends AbstractCollection<Fixups.Fixup> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if (bytes != null) {
|
||||
// Clean the bytes:
|
||||
@ -141,16 +144,16 @@ final class Fixups extends AbstractCollection<Fixups.Fixup> {
|
||||
assert(old.equals(new ArrayList<>(this)));
|
||||
}
|
||||
|
||||
static final int LOC_SHIFT = 1;
|
||||
static final int FMT_MASK = 0x1;
|
||||
static final byte UNUSED_BYTE = 0;
|
||||
static final byte OVERFLOW_BYTE = -1;
|
||||
private static final int LOC_SHIFT = 1;
|
||||
private static final int FMT_MASK = 0x1;
|
||||
private static final byte UNUSED_BYTE = 0;
|
||||
private static final byte OVERFLOW_BYTE = -1;
|
||||
// fill pointer of bigDescs array is in element [0]
|
||||
static final int BIGSIZE = 0;
|
||||
private static final int BIGSIZE = 0;
|
||||
|
||||
// Format values:
|
||||
public static final int U2_FORMAT = 0;
|
||||
public static final int U1_FORMAT = 1;
|
||||
private static final int U2_FORMAT = 0;
|
||||
private static final int U1_FORMAT = 1;
|
||||
|
||||
// Special values for the static methods.
|
||||
private static final int SPECIAL_LOC = 0;
|
||||
@ -232,6 +235,14 @@ final class Fixups extends AbstractCollection<Fixups.Fixup> {
|
||||
}
|
||||
}
|
||||
|
||||
void addU1(int pc, Entry ref) {
|
||||
add(pc, U1_FORMAT, ref);
|
||||
}
|
||||
|
||||
void addU2(int pc, Entry ref) {
|
||||
add(pc, U2_FORMAT, ref);
|
||||
}
|
||||
|
||||
/** Simple and necessary tuple to present each fixup. */
|
||||
public static
|
||||
class Fixup implements Comparable<Fixup> {
|
||||
@ -248,15 +259,25 @@ final class Fixups extends AbstractCollection<Fixups.Fixup> {
|
||||
public int location() { return descLoc(desc); }
|
||||
public int format() { return descFmt(desc); }
|
||||
public Entry entry() { return entry; }
|
||||
@Override
|
||||
public int compareTo(Fixup that) {
|
||||
// Ordering depends only on location.
|
||||
return this.location() - that.location();
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object x) {
|
||||
if (!(x instanceof Fixup)) return false;
|
||||
Fixup that = (Fixup) x;
|
||||
return this.desc == that.desc && this.entry == that.entry;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 59 * hash + this.desc;
|
||||
hash = 59 * hash + Objects.hashCode(this.entry);
|
||||
return hash;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "@"+location()+(format()==U1_FORMAT?".1":"")+"="+entry;
|
||||
}
|
||||
@ -267,8 +288,11 @@ final class Fixups extends AbstractCollection<Fixups.Fixup> {
|
||||
int index = 0; // index into entries
|
||||
int bigIndex = BIGSIZE+1; // index into bigDescs
|
||||
int next = head; // desc pointing to next fixup
|
||||
@Override
|
||||
public boolean hasNext() { return index < size; }
|
||||
@Override
|
||||
public void remove() { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public Fixup next() {
|
||||
int thisIndex = index;
|
||||
return new Fixup(nextDesc(), entries[thisIndex]);
|
||||
@ -293,17 +317,20 @@ final class Fixups extends AbstractCollection<Fixups.Fixup> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Fixup> iterator() {
|
||||
return new Itr();
|
||||
}
|
||||
public void add(int location, int format, Entry entry) {
|
||||
addDesc(makeDesc(location, format), entry);
|
||||
}
|
||||
@Override
|
||||
public boolean add(Fixup f) {
|
||||
addDesc(f.desc, f.entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends Fixup> c) {
|
||||
if (c instanceof Fixups) {
|
||||
// Use knowledge of Itr structure to avoid building little structs.
|
||||
@ -367,7 +394,13 @@ final class Fixups extends AbstractCollection<Fixups.Fixup> {
|
||||
}
|
||||
|
||||
/// Static methods that optimize the use of this class.
|
||||
public static
|
||||
static Object addRefWithBytes(Object f, byte[] bytes, Entry e) {
|
||||
return add(f, bytes, 0, U2_FORMAT, e);
|
||||
}
|
||||
static Object addRefWithLoc(Object f, int loc, Entry entry) {
|
||||
return add(f, null, loc, U2_FORMAT, entry);
|
||||
}
|
||||
private static
|
||||
Object add(Object prevFixups,
|
||||
byte[] bytes, int loc, int fmt,
|
||||
Entry e) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 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
|
||||
@ -259,7 +259,7 @@ class Package {
|
||||
byte[] bytes = new byte[2];
|
||||
sfName = getRefString(obvious);
|
||||
Object f = null;
|
||||
f = Fixups.add(f, bytes, 0, Fixups.U2_FORMAT, sfName);
|
||||
f = Fixups.addRefWithBytes(f, bytes, sfName);
|
||||
a = attrSourceFileSpecial.addContent(bytes, f);
|
||||
}
|
||||
} else if (obvious.equals(sfName.stringValue())) {
|
||||
|
@ -116,7 +116,7 @@ class PackageReader extends BandStructure {
|
||||
int nr = super.read(b, off, len);
|
||||
servedPos = pos;
|
||||
if (nr >= 0) served += nr;
|
||||
assert(served <= limit || limit == -1);
|
||||
//assert(served <= limit || limit == -1);
|
||||
return nr;
|
||||
}
|
||||
public long skip(long n) throws IOException {
|
||||
@ -1500,6 +1500,7 @@ class PackageReader extends BandStructure {
|
||||
// ic_local_bands
|
||||
// *class_ClassFile_version_minor_H :UNSIGNED5
|
||||
// *class_ClassFile_version_major_H :UNSIGNED5
|
||||
// class_type_metadata_bands
|
||||
//
|
||||
// field_attr_bands:
|
||||
// *field_flags :UNSIGNED5
|
||||
@ -1509,6 +1510,7 @@ class PackageReader extends BandStructure {
|
||||
// *field_Signature_RS :UNSIGNED5 (cp_Signature)
|
||||
// field_metadata_bands
|
||||
// *field_ConstantValue_KQ :UNSIGNED5 (cp_Int, etc.; see note)
|
||||
// field_type_metadata_bands
|
||||
//
|
||||
// method_attr_bands:
|
||||
// *method_flags :UNSIGNED5
|
||||
@ -1522,6 +1524,7 @@ class PackageReader extends BandStructure {
|
||||
// *method_MethodParameters_NB: BYTE1
|
||||
// *method_MethodParameters_RUN: UNSIGNED5 (cp_Utf8)
|
||||
// *method_MethodParameters_FH: UNSIGNED5 (flag)
|
||||
// method_type_metadata_bands
|
||||
//
|
||||
// code_attr_bands:
|
||||
// *code_flags :UNSIGNED5
|
||||
@ -1537,6 +1540,7 @@ class PackageReader extends BandStructure {
|
||||
// *code_LocalVariableTable_name_RU :UNSIGNED5 (cp_Utf8)
|
||||
// *code_LocalVariableTable_type_RS :UNSIGNED5 (cp_Signature)
|
||||
// *code_LocalVariableTable_slot :UNSIGNED5
|
||||
// code_type_metadata_bands
|
||||
|
||||
countAttrs(ctype, holders);
|
||||
readAttrs(ctype, holders);
|
||||
@ -1703,8 +1707,9 @@ class PackageReader extends BandStructure {
|
||||
class_InnerClasses_outer_RCN.readFrom(in);
|
||||
class_InnerClasses_name_RUN.expectLength(tupleCount);
|
||||
class_InnerClasses_name_RUN.readFrom(in);
|
||||
} else if (totalCount == 0) {
|
||||
// Expect no elements at all. Skip quickly.
|
||||
} else if (!optDebugBands && totalCount == 0) {
|
||||
// Expect no elements at all. Skip quickly. however if we
|
||||
// are debugging bands, read all bands regardless
|
||||
for (int j = 0; j < ab.length; j++) {
|
||||
ab[j].doneWithUnusedBand();
|
||||
}
|
||||
@ -1723,11 +1728,17 @@ class PackageReader extends BandStructure {
|
||||
assert(cbles[j].kind == Attribute.EK_CBLE);
|
||||
int entryCount = forwardCounts[j];
|
||||
forwardCounts[j] = -1; // No more, please!
|
||||
if (cbles[j].flagTest(Attribute.EF_BACK))
|
||||
if (totalCount > 0 && cbles[j].flagTest(Attribute.EF_BACK))
|
||||
entryCount += xxx_attr_calls.getInt();
|
||||
readAttrBands(cbles[j].body, entryCount, forwardCounts, ab);
|
||||
}
|
||||
}
|
||||
// mark them read, to satisfy asserts
|
||||
if (optDebugBands && totalCount == 0) {
|
||||
for (int j = 0; j < ab.length; j++) {
|
||||
ab[j].doneDisbursing();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!predef) break;
|
||||
@ -2154,11 +2165,10 @@ class PackageReader extends BandStructure {
|
||||
if (size == 1) ldcRefSet.add(ref);
|
||||
int fmt;
|
||||
switch (size) {
|
||||
case 1: fmt = Fixups.U1_FORMAT; break;
|
||||
case 2: fmt = Fixups.U2_FORMAT; break;
|
||||
case 1: fixupBuf.addU1(pc, ref); break;
|
||||
case 2: fixupBuf.addU2(pc, ref); break;
|
||||
default: assert(false); fmt = 0;
|
||||
}
|
||||
fixupBuf.add(pc, fmt, ref);
|
||||
buf[pc+0] = buf[pc+1] = 0;
|
||||
pc += size;
|
||||
}
|
||||
@ -2193,7 +2203,7 @@ class PackageReader extends BandStructure {
|
||||
int coding = bc_initref.getInt();
|
||||
// Find the nth overloading of <init> in classRef.
|
||||
MemberEntry ref = pkg.cp.getOverloadingForIndex(CONSTANT_Methodref, classRef, "<init>", coding);
|
||||
fixupBuf.add(pc, Fixups.U2_FORMAT, ref);
|
||||
fixupBuf.addU2(pc, ref);
|
||||
buf[pc+0] = buf[pc+1] = 0;
|
||||
pc += 2;
|
||||
assert(Instruction.opLength(origBC) == (pc - curPC));
|
||||
@ -2226,7 +2236,7 @@ class PackageReader extends BandStructure {
|
||||
insnMap[numInsns++] = curPC;
|
||||
}
|
||||
buf[pc++] = (byte) origBC;
|
||||
fixupBuf.add(pc, Fixups.U2_FORMAT, ref);
|
||||
fixupBuf.addU2(pc, ref);
|
||||
buf[pc+0] = buf[pc+1] = 0;
|
||||
pc += 2;
|
||||
assert(Instruction.opLength(origBC) == (pc - curPC));
|
||||
@ -2289,11 +2299,10 @@ class PackageReader extends BandStructure {
|
||||
buf[pc++] = (byte) origBC;
|
||||
int fmt;
|
||||
switch (size) {
|
||||
case 1: fmt = Fixups.U1_FORMAT; break;
|
||||
case 2: fmt = Fixups.U2_FORMAT; break;
|
||||
case 1: fixupBuf.addU1(pc, ref); break;
|
||||
case 2: fixupBuf.addU2(pc, ref); break;
|
||||
default: assert(false); fmt = 0;
|
||||
}
|
||||
fixupBuf.add(pc, fmt, ref);
|
||||
buf[pc+0] = buf[pc+1] = 0;
|
||||
pc += size;
|
||||
if (origBC == _multianewarray) {
|
||||
|
@ -102,7 +102,7 @@ public class DnsContext extends ComponentDirContext {
|
||||
this.domain = new DnsName(domain.endsWith(".")
|
||||
? domain
|
||||
: domain + ".");
|
||||
this.servers = servers;
|
||||
this.servers = (servers == null) ? null : servers.clone();
|
||||
this.environment = (Hashtable<Object,Object>) environment.clone();
|
||||
envShared = false;
|
||||
parentIsDns = false;
|
||||
@ -129,11 +129,11 @@ public class DnsContext extends ComponentDirContext {
|
||||
* no conflict.
|
||||
*/
|
||||
private DnsContext(DnsContext ctx) {
|
||||
environment = ctx.environment;
|
||||
environment = ctx.environment; // shared environment, copy-on-write
|
||||
envShared = ctx.envShared = true;
|
||||
parentIsDns = ctx.parentIsDns;
|
||||
domain = ctx.domain;
|
||||
servers = ctx.servers;
|
||||
servers = ctx.servers; // shared servers, no write operation
|
||||
resolver = ctx.resolver;
|
||||
authoritative = ctx.authoritative;
|
||||
recursion = ctx.recursion;
|
||||
|
@ -81,7 +81,7 @@ public class BasicControl implements Control {
|
||||
this.id = id;
|
||||
this.criticality = criticality;
|
||||
if (value != null) {
|
||||
this.value = value;
|
||||
this.value = value.clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public final class BerDecoder extends Ber {
|
||||
*/
|
||||
public BerDecoder(byte buf[], int offset, int bufsize) {
|
||||
|
||||
this.buf = buf;
|
||||
this.buf = buf; // shared buffer, be careful to use this class
|
||||
this.bufsize = bufsize;
|
||||
this.origOffset = offset;
|
||||
|
||||
|
@ -99,7 +99,7 @@ public final class BerEncoder extends Ber {
|
||||
if (curSeqIndex != 0) {
|
||||
throw new IllegalStateException("BER encode error: Unbalanced SEQUENCEs.");
|
||||
}
|
||||
return buf;
|
||||
return buf; // shared buffer, be careful to use this method.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,7 +134,9 @@ final public class StartTlsResponseImpl extends StartTlsResponse {
|
||||
* @see #negotiate
|
||||
*/
|
||||
public void setEnabledCipherSuites(String[] suites) {
|
||||
this.suites = suites;
|
||||
// The impl does accept null suites, although the spec requires
|
||||
// a non-null list.
|
||||
this.suites = suites == null ? null : suites.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,467 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.script.javascript;
|
||||
import sun.org.mozilla.javascript.internal.*;
|
||||
import javax.script.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* ExternalScriptable is an implementation of Scriptable
|
||||
* backed by a JSR 223 ScriptContext instance.
|
||||
*
|
||||
* @author Mike Grogan
|
||||
* @author A. Sundararajan
|
||||
* @since 1.6
|
||||
*/
|
||||
|
||||
final class ExternalScriptable implements Scriptable {
|
||||
/* Underlying ScriptContext that we use to store
|
||||
* named variables of this scope.
|
||||
*/
|
||||
private ScriptContext context;
|
||||
|
||||
/* JavaScript allows variables to be named as numbers (indexed
|
||||
* properties). This way arrays, objects (scopes) are treated uniformly.
|
||||
* Note that JSR 223 API supports only String named variables and
|
||||
* so we can't store these in Bindings. Also, JavaScript allows name
|
||||
* of the property name to be even empty String! Again, JSR 223 API
|
||||
* does not support empty name. So, we use the following fallback map
|
||||
* to store such variables of this scope. This map is not exposed to
|
||||
* JSR 223 API. We can just script objects "as is" and need not convert.
|
||||
*/
|
||||
private Map<Object, Object> indexedProps;
|
||||
|
||||
// my prototype
|
||||
private Scriptable prototype;
|
||||
// my parent scope, if any
|
||||
private Scriptable parent;
|
||||
|
||||
ExternalScriptable(ScriptContext context) {
|
||||
this(context, new HashMap<Object, Object>());
|
||||
}
|
||||
|
||||
ExternalScriptable(ScriptContext context, Map<Object, Object> indexedProps) {
|
||||
if (context == null) {
|
||||
throw new NullPointerException("context is null");
|
||||
}
|
||||
this.context = context;
|
||||
this.indexedProps = indexedProps;
|
||||
}
|
||||
|
||||
ScriptContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
private boolean isEmpty(String name) {
|
||||
return name.equals("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the class.
|
||||
*/
|
||||
public String getClassName() {
|
||||
return "Global";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the named property or NOT_FOUND.
|
||||
*
|
||||
* If the property was created using defineProperty, the
|
||||
* appropriate getter method is called.
|
||||
*
|
||||
* @param name the name of the property
|
||||
* @param start the object in which the lookup began
|
||||
* @return the value of the property (may be null), or NOT_FOUND
|
||||
*/
|
||||
public synchronized Object get(String name, Scriptable start) {
|
||||
if (isEmpty(name)) {
|
||||
if (indexedProps.containsKey(name)) {
|
||||
return indexedProps.get(name);
|
||||
} else {
|
||||
return NOT_FOUND;
|
||||
}
|
||||
} else {
|
||||
synchronized (context) {
|
||||
int scope = context.getAttributesScope(name);
|
||||
if (scope != -1) {
|
||||
Object value = context.getAttribute(name, scope);
|
||||
return Context.javaToJS(value, this);
|
||||
} else {
|
||||
return NOT_FOUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the indexed property or NOT_FOUND.
|
||||
*
|
||||
* @param index the numeric index for the property
|
||||
* @param start the object in which the lookup began
|
||||
* @return the value of the property (may be null), or NOT_FOUND
|
||||
*/
|
||||
public synchronized Object get(int index, Scriptable start) {
|
||||
Integer key = new Integer(index);
|
||||
if (indexedProps.containsKey(index)) {
|
||||
return indexedProps.get(key);
|
||||
} else {
|
||||
return NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the named property is defined.
|
||||
*
|
||||
* @param name the name of the property
|
||||
* @param start the object in which the lookup began
|
||||
* @return true if and only if the property was found in the object
|
||||
*/
|
||||
public synchronized boolean has(String name, Scriptable start) {
|
||||
if (isEmpty(name)) {
|
||||
return indexedProps.containsKey(name);
|
||||
} else {
|
||||
synchronized (context) {
|
||||
return context.getAttributesScope(name) != -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the property index is defined.
|
||||
*
|
||||
* @param index the numeric index for the property
|
||||
* @param start the object in which the lookup began
|
||||
* @return true if and only if the property was found in the object
|
||||
*/
|
||||
public synchronized boolean has(int index, Scriptable start) {
|
||||
Integer key = new Integer(index);
|
||||
return indexedProps.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the named property, creating it if need be.
|
||||
*
|
||||
* @param name the name of the property
|
||||
* @param start the object whose property is being set
|
||||
* @param value value to set the property to
|
||||
*/
|
||||
public void put(String name, Scriptable start, Object value) {
|
||||
if (start == this) {
|
||||
synchronized (this) {
|
||||
if (isEmpty(name)) {
|
||||
indexedProps.put(name, value);
|
||||
} else {
|
||||
synchronized (context) {
|
||||
int scope = context.getAttributesScope(name);
|
||||
if (scope == -1) {
|
||||
scope = ScriptContext.ENGINE_SCOPE;
|
||||
}
|
||||
context.setAttribute(name, jsToJava(value), scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
start.put(name, start, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the indexed property, creating it if need be.
|
||||
*
|
||||
* @param index the numeric index for the property
|
||||
* @param start the object whose property is being set
|
||||
* @param value value to set the property to
|
||||
*/
|
||||
public void put(int index, Scriptable start, Object value) {
|
||||
if (start == this) {
|
||||
synchronized (this) {
|
||||
indexedProps.put(new Integer(index), value);
|
||||
}
|
||||
} else {
|
||||
start.put(index, start, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a named property from the object.
|
||||
*
|
||||
* If the property is not found, no action is taken.
|
||||
*
|
||||
* @param name the name of the property
|
||||
*/
|
||||
public synchronized void delete(String name) {
|
||||
if (isEmpty(name)) {
|
||||
indexedProps.remove(name);
|
||||
} else {
|
||||
synchronized (context) {
|
||||
int scope = context.getAttributesScope(name);
|
||||
if (scope != -1) {
|
||||
context.removeAttribute(name, scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the indexed property from the object.
|
||||
*
|
||||
* If the property is not found, no action is taken.
|
||||
*
|
||||
* @param index the numeric index for the property
|
||||
*/
|
||||
public void delete(int index) {
|
||||
indexedProps.remove(new Integer(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the prototype of the object.
|
||||
* @return the prototype
|
||||
*/
|
||||
public Scriptable getPrototype() {
|
||||
return prototype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the prototype of the object.
|
||||
* @param prototype the prototype to set
|
||||
*/
|
||||
public void setPrototype(Scriptable prototype) {
|
||||
this.prototype = prototype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent scope of the object.
|
||||
* @return the parent scope
|
||||
*/
|
||||
public Scriptable getParentScope() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent scope of the object.
|
||||
* @param parent the parent scope to set
|
||||
*/
|
||||
public void setParentScope(Scriptable parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of property ids.
|
||||
*
|
||||
* Not all property ids need be returned. Those properties
|
||||
* whose ids are not returned are considered non-enumerable.
|
||||
*
|
||||
* @return an array of Objects. Each entry in the array is either
|
||||
* a java.lang.String or a java.lang.Number
|
||||
*/
|
||||
public synchronized Object[] getIds() {
|
||||
String[] keys = getAllKeys();
|
||||
int size = keys.length + indexedProps.size();
|
||||
Object[] res = new Object[size];
|
||||
System.arraycopy(keys, 0, res, 0, keys.length);
|
||||
int i = keys.length;
|
||||
// now add all indexed properties
|
||||
for (Object index : indexedProps.keySet()) {
|
||||
res[i++] = index;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default value of the object with a given hint.
|
||||
* The hints are String.class for type String, Number.class for type
|
||||
* Number, Scriptable.class for type Object, and Boolean.class for
|
||||
* type Boolean. <p>
|
||||
*
|
||||
* A <code>hint</code> of null means "no hint".
|
||||
*
|
||||
* See ECMA 8.6.2.6.
|
||||
*
|
||||
* @param hint the type hint
|
||||
* @return the default value
|
||||
*/
|
||||
public Object getDefaultValue(Class typeHint) {
|
||||
for (int i=0; i < 2; i++) {
|
||||
boolean tryToString;
|
||||
if (typeHint == ScriptRuntime.StringClass) {
|
||||
tryToString = (i == 0);
|
||||
} else {
|
||||
tryToString = (i == 1);
|
||||
}
|
||||
|
||||
String methodName;
|
||||
Object[] args;
|
||||
if (tryToString) {
|
||||
methodName = "toString";
|
||||
args = ScriptRuntime.emptyArgs;
|
||||
} else {
|
||||
methodName = "valueOf";
|
||||
args = new Object[1];
|
||||
String hint;
|
||||
if (typeHint == null) {
|
||||
hint = "undefined";
|
||||
} else if (typeHint == ScriptRuntime.StringClass) {
|
||||
hint = "string";
|
||||
} else if (typeHint == ScriptRuntime.ScriptableClass) {
|
||||
hint = "object";
|
||||
} else if (typeHint == ScriptRuntime.FunctionClass) {
|
||||
hint = "function";
|
||||
} else if (typeHint == ScriptRuntime.BooleanClass
|
||||
|| typeHint == Boolean.TYPE)
|
||||
{
|
||||
hint = "boolean";
|
||||
} else if (typeHint == ScriptRuntime.NumberClass ||
|
||||
typeHint == ScriptRuntime.ByteClass ||
|
||||
typeHint == Byte.TYPE ||
|
||||
typeHint == ScriptRuntime.ShortClass ||
|
||||
typeHint == Short.TYPE ||
|
||||
typeHint == ScriptRuntime.IntegerClass ||
|
||||
typeHint == Integer.TYPE ||
|
||||
typeHint == ScriptRuntime.FloatClass ||
|
||||
typeHint == Float.TYPE ||
|
||||
typeHint == ScriptRuntime.DoubleClass ||
|
||||
typeHint == Double.TYPE)
|
||||
{
|
||||
hint = "number";
|
||||
} else {
|
||||
throw Context.reportRuntimeError(
|
||||
"Invalid JavaScript value of type " +
|
||||
typeHint.toString());
|
||||
}
|
||||
args[0] = hint;
|
||||
}
|
||||
Object v = ScriptableObject.getProperty(this, methodName);
|
||||
if (!(v instanceof Function))
|
||||
continue;
|
||||
Function fun = (Function) v;
|
||||
Context cx = RhinoScriptEngine.enterContext();
|
||||
try {
|
||||
v = fun.call(cx, fun.getParentScope(), this, args);
|
||||
} finally {
|
||||
cx.exit();
|
||||
}
|
||||
if (v != null) {
|
||||
if (!(v instanceof Scriptable)) {
|
||||
return v;
|
||||
}
|
||||
if (typeHint == ScriptRuntime.ScriptableClass
|
||||
|| typeHint == ScriptRuntime.FunctionClass)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
if (tryToString && v instanceof Wrapper) {
|
||||
// Let a wrapped java.lang.String pass for a primitive
|
||||
// string.
|
||||
Object u = ((Wrapper)v).unwrap();
|
||||
if (u instanceof String)
|
||||
return u;
|
||||
}
|
||||
}
|
||||
}
|
||||
// fall through to error
|
||||
String arg = (typeHint == null) ? "undefined" : typeHint.getName();
|
||||
throw Context.reportRuntimeError(
|
||||
"Cannot find default value for object " + arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements the instanceof operator.
|
||||
*
|
||||
* @param instance The value that appeared on the LHS of the instanceof
|
||||
* operator
|
||||
* @return true if "this" appears in value's prototype chain
|
||||
*
|
||||
*/
|
||||
public boolean hasInstance(Scriptable instance) {
|
||||
// Default for JS objects (other than Function) is to do prototype
|
||||
// chasing.
|
||||
Scriptable proto = instance.getPrototype();
|
||||
while (proto != null) {
|
||||
if (proto.equals(this)) return true;
|
||||
proto = proto.getPrototype();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String[] getAllKeys() {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
synchronized (context) {
|
||||
for (int scope : context.getScopes()) {
|
||||
Bindings bindings = context.getBindings(scope);
|
||||
if (bindings != null) {
|
||||
list.ensureCapacity(bindings.size());
|
||||
for (String key : bindings.keySet()) {
|
||||
list.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String[] res = new String[list.size()];
|
||||
list.toArray(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* We convert script values to the nearest Java value.
|
||||
* We unwrap wrapped Java objects so that access from
|
||||
* Bindings.get() would return "workable" value for Java.
|
||||
* But, at the same time, we need to make few special cases
|
||||
* and hence the following function is used.
|
||||
*/
|
||||
private Object jsToJava(Object jsObj) {
|
||||
if (jsObj instanceof Wrapper) {
|
||||
Wrapper njb = (Wrapper) jsObj;
|
||||
/* importClass feature of ImporterTopLevel puts
|
||||
* NativeJavaClass in global scope. If we unwrap
|
||||
* it, importClass won't work.
|
||||
*/
|
||||
if (njb instanceof NativeJavaClass) {
|
||||
return njb;
|
||||
}
|
||||
|
||||
/* script may use Java primitive wrapper type objects
|
||||
* (such as java.lang.Integer, java.lang.Boolean etc)
|
||||
* explicitly. If we unwrap, then these script objects
|
||||
* will become script primitive types. For example,
|
||||
*
|
||||
* var x = new java.lang.Double(3.0); print(typeof x);
|
||||
*
|
||||
* will print 'number'. We don't want that to happen.
|
||||
*/
|
||||
Object obj = njb.unwrap();
|
||||
if (obj instanceof Number || obj instanceof String ||
|
||||
obj instanceof Boolean || obj instanceof Character) {
|
||||
// special type wrapped -- we just leave it as is.
|
||||
return njb;
|
||||
} else {
|
||||
// return unwrapped object for any other object.
|
||||
return obj;
|
||||
}
|
||||
} else { // not-a-Java-wrapper
|
||||
return jsObj;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,338 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
package com.sun.script.javascript;
|
||||
|
||||
import sun.org.mozilla.javascript.internal.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* JSAdapter is java.lang.reflect.Proxy equivalent for JavaScript. JSAdapter
|
||||
* calls specially named JavaScript methods on an adaptee object when property
|
||||
* access is attempted on it.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* var y = {
|
||||
* __get__ : function (name) { ... }
|
||||
* __has__ : function (name) { ... }
|
||||
* __put__ : function (name, value) {...}
|
||||
* __delete__ : function (name) { ... }
|
||||
* __getIds__ : function () { ... }
|
||||
* };
|
||||
*
|
||||
* var x = new JSAdapter(y);
|
||||
*
|
||||
* x.i; // calls y.__get__
|
||||
* i in x; // calls y.__has__
|
||||
* x.p = 10; // calls y.__put__
|
||||
* delete x.p; // calls y.__delete__
|
||||
* for (i in x) { print(i); } // calls y.__getIds__
|
||||
*
|
||||
* If a special JavaScript method is not found in the adaptee, then JSAdapter
|
||||
* forwards the property access to the adaptee itself.
|
||||
*
|
||||
* JavaScript caller of adapter object is isolated from the fact that
|
||||
* the property access/mutation/deletion are really calls to
|
||||
* JavaScript methods on adaptee. Use cases include 'smart'
|
||||
* properties, property access tracing/debugging, encaptulation with
|
||||
* easy client access - in short JavaScript becomes more "Self" like.
|
||||
*
|
||||
* Note that Rhino already supports special properties like __proto__
|
||||
* (to set, get prototype), __parent__ (to set, get parent scope). We
|
||||
* follow the same double underscore nameing convention here. Similarly
|
||||
* the name JSAdapter is derived from JavaAdapter -- which is a facility
|
||||
* to extend, implement Java classes/interfaces by JavaScript.
|
||||
*
|
||||
* @author A. Sundararajan
|
||||
* @since 1.6
|
||||
*/
|
||||
public final class JSAdapter implements Scriptable, Function {
|
||||
private JSAdapter(Scriptable obj) {
|
||||
setAdaptee(obj);
|
||||
}
|
||||
|
||||
// initializer to setup JSAdapter prototype in the given scope
|
||||
public static void init(Context cx, Scriptable scope, boolean sealed)
|
||||
throws RhinoException {
|
||||
JSAdapter obj = new JSAdapter(cx.newObject(scope));
|
||||
obj.setParentScope(scope);
|
||||
obj.setPrototype(getFunctionPrototype(scope));
|
||||
obj.isPrototype = true;
|
||||
ScriptableObject.defineProperty(scope, "JSAdapter", obj,
|
||||
ScriptableObject.DONTENUM);
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return "JSAdapter";
|
||||
}
|
||||
|
||||
public Object get(String name, Scriptable start) {
|
||||
Function func = getAdapteeFunction(GET_PROP);
|
||||
if (func != null) {
|
||||
return call(func, new Object[] { name });
|
||||
} else {
|
||||
start = getAdaptee();
|
||||
return start.get(name, start);
|
||||
}
|
||||
}
|
||||
|
||||
public Object get(int index, Scriptable start) {
|
||||
Function func = getAdapteeFunction(GET_PROP);
|
||||
if (func != null) {
|
||||
return call(func, new Object[] { new Integer(index) });
|
||||
} else {
|
||||
start = getAdaptee();
|
||||
return start.get(index, start);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean has(String name, Scriptable start) {
|
||||
Function func = getAdapteeFunction(HAS_PROP);
|
||||
if (func != null) {
|
||||
Object res = call(func, new Object[] { name });
|
||||
return Context.toBoolean(res);
|
||||
} else {
|
||||
start = getAdaptee();
|
||||
return start.has(name, start);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean has(int index, Scriptable start) {
|
||||
Function func = getAdapteeFunction(HAS_PROP);
|
||||
if (func != null) {
|
||||
Object res = call(func, new Object[] { new Integer(index) });
|
||||
return Context.toBoolean(res);
|
||||
} else {
|
||||
start = getAdaptee();
|
||||
return start.has(index, start);
|
||||
}
|
||||
}
|
||||
|
||||
public void put(String name, Scriptable start, Object value) {
|
||||
if (start == this) {
|
||||
Function func = getAdapteeFunction(PUT_PROP);
|
||||
if (func != null) {
|
||||
call(func, new Object[] { name, value });
|
||||
} else {
|
||||
start = getAdaptee();
|
||||
start.put(name, start, value);
|
||||
}
|
||||
} else {
|
||||
start.put(name, start, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void put(int index, Scriptable start, Object value) {
|
||||
if (start == this) {
|
||||
Function func = getAdapteeFunction(PUT_PROP);
|
||||
if( func != null) {
|
||||
call(func, new Object[] { new Integer(index), value });
|
||||
} else {
|
||||
start = getAdaptee();
|
||||
start.put(index, start, value);
|
||||
}
|
||||
} else {
|
||||
start.put(index, start, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(String name) {
|
||||
Function func = getAdapteeFunction(DEL_PROP);
|
||||
if (func != null) {
|
||||
call(func, new Object[] { name });
|
||||
} else {
|
||||
getAdaptee().delete(name);
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(int index) {
|
||||
Function func = getAdapteeFunction(DEL_PROP);
|
||||
if (func != null) {
|
||||
call(func, new Object[] { new Integer(index) });
|
||||
} else {
|
||||
getAdaptee().delete(index);
|
||||
}
|
||||
}
|
||||
|
||||
public Scriptable getPrototype() {
|
||||
return prototype;
|
||||
}
|
||||
|
||||
public void setPrototype(Scriptable prototype) {
|
||||
this.prototype = prototype;
|
||||
}
|
||||
|
||||
public Scriptable getParentScope() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParentScope(Scriptable parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Object[] getIds() {
|
||||
Function func = getAdapteeFunction(GET_PROPIDS);
|
||||
if (func != null) {
|
||||
Object val = call(func, new Object[0]);
|
||||
// in most cases, adaptee would return native JS array
|
||||
if (val instanceof NativeArray) {
|
||||
NativeArray array = (NativeArray) val;
|
||||
Object[] res = new Object[(int)array.getLength()];
|
||||
for (int index = 0; index < res.length; index++) {
|
||||
res[index] = mapToId(array.get(index, array));
|
||||
}
|
||||
return res;
|
||||
} else if (val instanceof NativeJavaArray) {
|
||||
// may be attempt wrapped Java array
|
||||
Object tmp = ((NativeJavaArray)val).unwrap();
|
||||
Object[] res;
|
||||
if (tmp.getClass() == Object[].class) {
|
||||
Object[] array = (Object[]) tmp;
|
||||
res = new Object[array.length];
|
||||
for (int index = 0; index < array.length; index++) {
|
||||
res[index] = mapToId(array[index]);
|
||||
}
|
||||
} else {
|
||||
// just return an empty array
|
||||
res = Context.emptyArgs;
|
||||
}
|
||||
return res;
|
||||
} else {
|
||||
// some other return type, just return empty array
|
||||
return Context.emptyArgs;
|
||||
}
|
||||
} else {
|
||||
return getAdaptee().getIds();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasInstance(Scriptable scriptable) {
|
||||
if (scriptable instanceof JSAdapter) {
|
||||
return true;
|
||||
} else {
|
||||
Scriptable proto = scriptable.getPrototype();
|
||||
while (proto != null) {
|
||||
if (proto.equals(this)) return true;
|
||||
proto = proto.getPrototype();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getDefaultValue(Class hint) {
|
||||
return getAdaptee().getDefaultValue(hint);
|
||||
}
|
||||
|
||||
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
|
||||
Object[] args)
|
||||
throws RhinoException {
|
||||
if (isPrototype) {
|
||||
return construct(cx, scope, args);
|
||||
} else {
|
||||
Scriptable tmp = getAdaptee();
|
||||
if (tmp instanceof Function) {
|
||||
return ((Function)tmp).call(cx, scope, tmp, args);
|
||||
} else {
|
||||
throw Context.reportRuntimeError("TypeError: not a function");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Scriptable construct(Context cx, Scriptable scope, Object[] args)
|
||||
throws RhinoException {
|
||||
if (isPrototype) {
|
||||
Scriptable topLevel = ScriptableObject.getTopLevelScope(scope);
|
||||
JSAdapter newObj;
|
||||
if (args.length > 0) {
|
||||
newObj = new JSAdapter(Context.toObject(args[0], topLevel));
|
||||
} else {
|
||||
throw Context.reportRuntimeError("JSAdapter requires adaptee");
|
||||
}
|
||||
return newObj;
|
||||
} else {
|
||||
Scriptable tmp = getAdaptee();
|
||||
if (tmp instanceof Function) {
|
||||
return ((Function)tmp).construct(cx, scope, args);
|
||||
} else {
|
||||
throw Context.reportRuntimeError("TypeError: not a constructor");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Scriptable getAdaptee() {
|
||||
return adaptee;
|
||||
}
|
||||
|
||||
public void setAdaptee(Scriptable adaptee) {
|
||||
if (adaptee == null) {
|
||||
throw new NullPointerException("adaptee can not be null");
|
||||
}
|
||||
this.adaptee = adaptee;
|
||||
}
|
||||
|
||||
//-- internals only below this point
|
||||
|
||||
// map a property id. Property id can only be an Integer or String
|
||||
private Object mapToId(Object tmp) {
|
||||
if (tmp instanceof Double) {
|
||||
return new Integer(((Double)tmp).intValue());
|
||||
} else {
|
||||
return Context.toString(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
private static Scriptable getFunctionPrototype(Scriptable scope) {
|
||||
return ScriptableObject.getFunctionPrototype(scope);
|
||||
}
|
||||
|
||||
private Function getAdapteeFunction(String name) {
|
||||
Object o = ScriptableObject.getProperty(getAdaptee(), name);
|
||||
return (o instanceof Function)? (Function)o : null;
|
||||
}
|
||||
|
||||
private Object call(Function func, Object[] args) {
|
||||
Context cx = Context.getCurrentContext();
|
||||
Scriptable thisObj = getAdaptee();
|
||||
Scriptable scope = func.getParentScope();
|
||||
try {
|
||||
return func.call(cx, scope, thisObj, args);
|
||||
} catch (RhinoException re) {
|
||||
throw Context.reportRuntimeError(re.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private Scriptable prototype;
|
||||
private Scriptable parent;
|
||||
private Scriptable adaptee;
|
||||
private boolean isPrototype;
|
||||
|
||||
// names of adaptee JavaScript functions
|
||||
private static final String GET_PROP = "__get__";
|
||||
private static final String HAS_PROP = "__has__";
|
||||
private static final String PUT_PROP = "__put__";
|
||||
private static final String DEL_PROP = "__delete__";
|
||||
private static final String GET_PROPIDS = "__getIds__";
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.script.javascript;
|
||||
|
||||
import javax.script.Invocable;
|
||||
import sun.org.mozilla.javascript.internal.*;
|
||||
|
||||
/**
|
||||
* This class implements Rhino-like JavaAdapter to help implement a Java
|
||||
* interface in JavaScript. We support this using Invocable.getInterface.
|
||||
* Using this JavaAdapter, script author could write:
|
||||
*
|
||||
* var r = new java.lang.Runnable() {
|
||||
* run: function() { script... }
|
||||
* };
|
||||
*
|
||||
* r.run();
|
||||
* new java.lang.Thread(r).start();
|
||||
*
|
||||
* Note that Rhino's JavaAdapter support allows extending a Java class and/or
|
||||
* implementing one or more interfaces. This JavaAdapter implementation does
|
||||
* not support these.
|
||||
*
|
||||
* @author A. Sundararajan
|
||||
* @since 1.6
|
||||
*/
|
||||
final class JavaAdapter extends ScriptableObject implements Function {
|
||||
private JavaAdapter(Invocable engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
static void init(Context cx, Scriptable scope, boolean sealed)
|
||||
throws RhinoException {
|
||||
RhinoTopLevel topLevel = (RhinoTopLevel) scope;
|
||||
Invocable engine = topLevel.getScriptEngine();
|
||||
JavaAdapter obj = new JavaAdapter(engine);
|
||||
obj.setParentScope(scope);
|
||||
obj.setPrototype(getFunctionPrototype(scope));
|
||||
/*
|
||||
* Note that we can't use defineProperty. A property of this
|
||||
* name is already defined in Context.initStandardObjects. We
|
||||
* simply overwrite the property value!
|
||||
*/
|
||||
ScriptableObject.putProperty(topLevel, "JavaAdapter", obj);
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return "JavaAdapter";
|
||||
}
|
||||
|
||||
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
|
||||
Object[] args) throws RhinoException {
|
||||
return construct(cx, scope, args);
|
||||
}
|
||||
|
||||
public Scriptable construct(Context cx, Scriptable scope, Object[] args)
|
||||
throws RhinoException {
|
||||
if (args.length == 2) {
|
||||
Class<?> clazz = null;
|
||||
Object obj1 = args[0];
|
||||
if (obj1 instanceof Wrapper) {
|
||||
Object o = ((Wrapper)obj1).unwrap();
|
||||
if (o instanceof Class && ((Class)o).isInterface()) {
|
||||
clazz = (Class) o;
|
||||
}
|
||||
} else if (obj1 instanceof Class) {
|
||||
if (((Class)obj1).isInterface()) {
|
||||
clazz = (Class) obj1;
|
||||
}
|
||||
}
|
||||
if (clazz == null) {
|
||||
throw Context.reportRuntimeError("JavaAdapter: first arg should be interface Class");
|
||||
}
|
||||
|
||||
Scriptable topLevel = ScriptableObject.getTopLevelScope(scope);
|
||||
return cx.toObject(engine.getInterface(args[1], clazz), topLevel);
|
||||
} else {
|
||||
throw Context.reportRuntimeError("JavaAdapter requires two arguments");
|
||||
}
|
||||
}
|
||||
|
||||
private Invocable engine;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
|
||||
#script engines supported
|
||||
|
||||
com.sun.script.javascript.RhinoScriptEngineFactory #javascript
|
||||
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
package com.sun.script.javascript;
|
||||
|
||||
import java.util.*;
|
||||
import sun.org.mozilla.javascript.internal.*;
|
||||
|
||||
/**
|
||||
* This class prevents script access to certain sensitive classes.
|
||||
* Note that this class checks over and above SecurityManager. i.e., although
|
||||
* a SecurityManager would pass, class shutter may still prevent access.
|
||||
*
|
||||
* @author A. Sundararajan
|
||||
* @since 1.6
|
||||
*/
|
||||
final class RhinoClassShutter implements ClassShutter {
|
||||
private static Map<String, Boolean> protectedClasses;
|
||||
private static RhinoClassShutter theInstance;
|
||||
|
||||
private RhinoClassShutter() {
|
||||
}
|
||||
|
||||
static synchronized ClassShutter getInstance() {
|
||||
if (theInstance == null) {
|
||||
theInstance = new RhinoClassShutter();
|
||||
protectedClasses = new HashMap<String, Boolean>();
|
||||
|
||||
// For now, we just have AccessController. Allowing scripts
|
||||
// to this class will allow it to execute doPrivileged in
|
||||
// bootstrap context. We can add more classes for other reasons.
|
||||
protectedClasses.put("java.security.AccessController", Boolean.TRUE);
|
||||
}
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
public boolean visibleToScripts(String fullClassName) {
|
||||
// first do the security check.
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
int i = fullClassName.lastIndexOf(".");
|
||||
if (i != -1) {
|
||||
try {
|
||||
sm.checkPackageAccess(fullClassName.substring(0, i));
|
||||
} catch (SecurityException se) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// now, check is it a protected class.
|
||||
return protectedClasses.get(fullClassName) == null;
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.script.javascript;
|
||||
import javax.script.*;
|
||||
import sun.org.mozilla.javascript.internal.*;
|
||||
|
||||
/**
|
||||
* Represents compiled JavaScript code.
|
||||
*
|
||||
* @author Mike Grogan
|
||||
* @since 1.6
|
||||
*/
|
||||
final class RhinoCompiledScript extends CompiledScript {
|
||||
|
||||
private RhinoScriptEngine engine;
|
||||
private Script script;
|
||||
|
||||
|
||||
RhinoCompiledScript(RhinoScriptEngine engine, Script script) {
|
||||
this.engine = engine;
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
public Object eval(ScriptContext context) throws ScriptException {
|
||||
|
||||
Object result = null;
|
||||
Context cx = RhinoScriptEngine.enterContext();
|
||||
try {
|
||||
|
||||
Scriptable scope = engine.getRuntimeScope(context);
|
||||
Object ret = script.exec(cx, scope);
|
||||
result = engine.unwrapReturnValue(ret);
|
||||
} catch (RhinoException re) {
|
||||
int line = (line = re.lineNumber()) == 0 ? -1 : line;
|
||||
String msg;
|
||||
if (re instanceof JavaScriptException) {
|
||||
msg = String.valueOf(((JavaScriptException)re).getValue());
|
||||
} else {
|
||||
msg = re.toString();
|
||||
}
|
||||
ScriptException se = new ScriptException(msg, re.sourceName(), line);
|
||||
se.initCause(re);
|
||||
throw se;
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ScriptEngine getEngine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
}
|
@ -1,398 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 com.sun.script.javascript;
|
||||
import com.sun.script.util.*;
|
||||
import javax.script.*;
|
||||
import sun.org.mozilla.javascript.internal.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of <code>ScriptEngine</code> using the Mozilla Rhino
|
||||
* interpreter.
|
||||
*
|
||||
* @author Mike Grogan
|
||||
* @author A. Sundararajan
|
||||
* @since 1.6
|
||||
*/
|
||||
public final class RhinoScriptEngine extends AbstractScriptEngine
|
||||
implements Invocable, Compilable {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
/* Scope where standard JavaScript objects and our
|
||||
* extensions to it are stored. Note that these are not
|
||||
* user defined engine level global variables. These are
|
||||
* variables have to be there on all compliant ECMAScript
|
||||
* scopes. We put these standard objects in this top level.
|
||||
*/
|
||||
private RhinoTopLevel topLevel;
|
||||
|
||||
/* map used to store indexed properties in engine scope
|
||||
* refer to comment on 'indexedProps' in ExternalScriptable.java.
|
||||
*/
|
||||
private Map<Object, Object> indexedProps;
|
||||
|
||||
private ScriptEngineFactory factory;
|
||||
private InterfaceImplementor implementor;
|
||||
|
||||
private static final int languageVersion = getLanguageVersion();
|
||||
private static final int optimizationLevel = getOptimizationLevel();
|
||||
static {
|
||||
ContextFactory.initGlobal(new ContextFactory() {
|
||||
protected Context makeContext() {
|
||||
Context cx = super.makeContext();
|
||||
cx.setLanguageVersion(languageVersion);
|
||||
cx.setOptimizationLevel(optimizationLevel);
|
||||
cx.setClassShutter(RhinoClassShutter.getInstance());
|
||||
cx.setWrapFactory(RhinoWrapFactory.getInstance());
|
||||
return cx;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final String RHINO_JS_VERSION = "rhino.js.version";
|
||||
private static int getLanguageVersion() {
|
||||
int version;
|
||||
String tmp = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction(RHINO_JS_VERSION));
|
||||
if (tmp != null) {
|
||||
version = Integer.parseInt((String)tmp);
|
||||
} else {
|
||||
version = Context.VERSION_1_8;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
private static final String RHINO_OPT_LEVEL = "rhino.opt.level";
|
||||
private static int getOptimizationLevel() {
|
||||
int optLevel = -1;
|
||||
// disable optimizer under security manager, for now.
|
||||
if (System.getSecurityManager() == null) {
|
||||
optLevel = Integer.getInteger(RHINO_OPT_LEVEL, -1);
|
||||
}
|
||||
return optLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of RhinoScriptEngine
|
||||
*/
|
||||
public RhinoScriptEngine() {
|
||||
|
||||
Context cx = enterContext();
|
||||
try {
|
||||
topLevel = new RhinoTopLevel(cx, this);
|
||||
} finally {
|
||||
cx.exit();
|
||||
}
|
||||
|
||||
indexedProps = new HashMap<Object, Object>();
|
||||
|
||||
//construct object used to implement getInterface
|
||||
implementor = new InterfaceImplementor(this) {
|
||||
protected boolean isImplemented(Object thiz, Class<?> iface) {
|
||||
Context cx = enterContext();
|
||||
try {
|
||||
if (thiz != null && !(thiz instanceof Scriptable)) {
|
||||
thiz = cx.toObject(thiz, topLevel);
|
||||
}
|
||||
Scriptable engineScope = getRuntimeScope(context);
|
||||
Scriptable localScope = (thiz != null)? (Scriptable) thiz :
|
||||
engineScope;
|
||||
for (Method method : iface.getMethods()) {
|
||||
// ignore methods of java.lang.Object class
|
||||
if (method.getDeclaringClass() == Object.class) {
|
||||
continue;
|
||||
}
|
||||
Object obj = ScriptableObject.getProperty(localScope, method.getName());
|
||||
if (! (obj instanceof Function)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} finally {
|
||||
cx.exit();
|
||||
}
|
||||
}
|
||||
|
||||
protected Object convertResult(Method method, Object res)
|
||||
throws ScriptException {
|
||||
Class desiredType = method.getReturnType();
|
||||
if (desiredType == Void.TYPE) {
|
||||
return null;
|
||||
} else {
|
||||
return Context.jsToJava(res, desiredType);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Object eval(Reader reader, ScriptContext ctxt)
|
||||
throws ScriptException {
|
||||
Object ret;
|
||||
|
||||
Context cx = enterContext();
|
||||
try {
|
||||
Scriptable scope = getRuntimeScope(ctxt);
|
||||
String filename = (String) get(ScriptEngine.FILENAME);
|
||||
filename = filename == null ? "<Unknown source>" : filename;
|
||||
|
||||
ret = cx.evaluateReader(scope, reader, filename , 1, null);
|
||||
} catch (RhinoException re) {
|
||||
if (DEBUG) re.printStackTrace();
|
||||
int line = (line = re.lineNumber()) == 0 ? -1 : line;
|
||||
String msg;
|
||||
if (re instanceof JavaScriptException) {
|
||||
msg = String.valueOf(((JavaScriptException)re).getValue());
|
||||
} else {
|
||||
msg = re.toString();
|
||||
}
|
||||
ScriptException se = new ScriptException(msg, re.sourceName(), line);
|
||||
se.initCause(re);
|
||||
throw se;
|
||||
} catch (IOException ee) {
|
||||
throw new ScriptException(ee);
|
||||
} finally {
|
||||
cx.exit();
|
||||
}
|
||||
|
||||
return unwrapReturnValue(ret);
|
||||
}
|
||||
|
||||
public Object eval(String script, ScriptContext ctxt) throws ScriptException {
|
||||
if (script == null) {
|
||||
throw new NullPointerException("null script");
|
||||
}
|
||||
return eval(new StringReader(script) , ctxt);
|
||||
}
|
||||
|
||||
public ScriptEngineFactory getFactory() {
|
||||
if (factory != null) {
|
||||
return factory;
|
||||
} else {
|
||||
return new RhinoScriptEngineFactory();
|
||||
}
|
||||
}
|
||||
|
||||
public Bindings createBindings() {
|
||||
return new SimpleBindings();
|
||||
}
|
||||
|
||||
//Invocable methods
|
||||
public Object invokeFunction(String name, Object... args)
|
||||
throws ScriptException, NoSuchMethodException {
|
||||
return invoke(null, name, args);
|
||||
}
|
||||
|
||||
public Object invokeMethod(Object thiz, String name, Object... args)
|
||||
throws ScriptException, NoSuchMethodException {
|
||||
if (thiz == null) {
|
||||
throw new IllegalArgumentException("script object can not be null");
|
||||
}
|
||||
return invoke(thiz, name, args);
|
||||
}
|
||||
|
||||
private Object invoke(Object thiz, String name, Object... args)
|
||||
throws ScriptException, NoSuchMethodException {
|
||||
Context cx = enterContext();
|
||||
try {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("method name is null");
|
||||
}
|
||||
|
||||
if (thiz != null && !(thiz instanceof Scriptable)) {
|
||||
thiz = cx.toObject(thiz, topLevel);
|
||||
}
|
||||
|
||||
Scriptable engineScope = getRuntimeScope(context);
|
||||
Scriptable localScope = (thiz != null)? (Scriptable) thiz :
|
||||
engineScope;
|
||||
Object obj = ScriptableObject.getProperty(localScope, name);
|
||||
if (! (obj instanceof Function)) {
|
||||
throw new NoSuchMethodException("no such method: " + name);
|
||||
}
|
||||
|
||||
Function func = (Function) obj;
|
||||
Scriptable scope = func.getParentScope();
|
||||
if (scope == null) {
|
||||
scope = engineScope;
|
||||
}
|
||||
Object result = func.call(cx, scope, localScope,
|
||||
wrapArguments(args));
|
||||
return unwrapReturnValue(result);
|
||||
} catch (RhinoException re) {
|
||||
if (DEBUG) re.printStackTrace();
|
||||
int line = (line = re.lineNumber()) == 0 ? -1 : line;
|
||||
ScriptException se = new ScriptException(re.toString(), re.sourceName(), line);
|
||||
se.initCause(re);
|
||||
throw se;
|
||||
} finally {
|
||||
cx.exit();
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T getInterface(Class<T> clasz) {
|
||||
try {
|
||||
return implementor.getInterface(null, clasz);
|
||||
} catch (ScriptException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T getInterface(Object thiz, Class<T> clasz) {
|
||||
if (thiz == null) {
|
||||
throw new IllegalArgumentException("script object can not be null");
|
||||
}
|
||||
|
||||
try {
|
||||
return implementor.getInterface(thiz, clasz);
|
||||
} catch (ScriptException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String printSource =
|
||||
"function print(str, newline) { \n" +
|
||||
" if (typeof(str) == 'undefined') { \n" +
|
||||
" str = 'undefined'; \n" +
|
||||
" } else if (str == null) { \n" +
|
||||
" str = 'null'; \n" +
|
||||
" } \n" +
|
||||
" var out = context.getWriter(); \n" +
|
||||
" if (!(out instanceof java.io.PrintWriter))\n" +
|
||||
" out = new java.io.PrintWriter(out); \n" +
|
||||
" out.print(String(str)); \n" +
|
||||
" if (newline) out.print('\\n'); \n" +
|
||||
" out.flush(); \n" +
|
||||
"}\n" +
|
||||
"function println(str) { \n" +
|
||||
" print(str, true); \n" +
|
||||
"}";
|
||||
|
||||
Scriptable getRuntimeScope(ScriptContext ctxt) {
|
||||
if (ctxt == null) {
|
||||
throw new NullPointerException("null script context");
|
||||
}
|
||||
|
||||
// we create a scope for the given ScriptContext
|
||||
Scriptable newScope = new ExternalScriptable(ctxt, indexedProps);
|
||||
|
||||
// Set the prototype of newScope to be 'topLevel' so that
|
||||
// JavaScript standard objects are visible from the scope.
|
||||
newScope.setPrototype(topLevel);
|
||||
|
||||
// define "context" variable in the new scope
|
||||
newScope.put("context", newScope, ctxt);
|
||||
|
||||
// define "print", "println" functions in the new scope
|
||||
Context cx = enterContext();
|
||||
try {
|
||||
cx.evaluateString(newScope, printSource, "print", 1, null);
|
||||
} finally {
|
||||
cx.exit();
|
||||
}
|
||||
return newScope;
|
||||
}
|
||||
|
||||
|
||||
//Compilable methods
|
||||
public CompiledScript compile(String script) throws ScriptException {
|
||||
return compile(new StringReader(script));
|
||||
}
|
||||
|
||||
public CompiledScript compile(java.io.Reader script) throws ScriptException {
|
||||
CompiledScript ret = null;
|
||||
Context cx = enterContext();
|
||||
|
||||
try {
|
||||
String fileName = (String) get(ScriptEngine.FILENAME);
|
||||
if (fileName == null) {
|
||||
fileName = "<Unknown Source>";
|
||||
}
|
||||
|
||||
Scriptable scope = getRuntimeScope(context);
|
||||
Script scr = cx.compileReader(scope, script, fileName, 1, null);
|
||||
ret = new RhinoCompiledScript(this, scr);
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) e.printStackTrace();
|
||||
throw new ScriptException(e);
|
||||
} finally {
|
||||
cx.exit();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//package-private helpers
|
||||
|
||||
static Context enterContext() {
|
||||
// call this always so that initializer of this class runs
|
||||
// and initializes custom wrap factory and class shutter.
|
||||
return Context.enter();
|
||||
}
|
||||
|
||||
void setEngineFactory(ScriptEngineFactory fac) {
|
||||
factory = fac;
|
||||
}
|
||||
|
||||
Object[] wrapArguments(Object[] args) {
|
||||
if (args == null) {
|
||||
return Context.emptyArgs;
|
||||
}
|
||||
Object[] res = new Object[args.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
res[i] = Context.javaToJS(args[i], topLevel);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Object unwrapReturnValue(Object result) {
|
||||
if (result instanceof Wrapper) {
|
||||
result = ( (Wrapper) result).unwrap();
|
||||
}
|
||||
|
||||
return result instanceof Undefined ? null : result;
|
||||
}
|
||||
|
||||
/*
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
System.out.println("No file specified");
|
||||
return;
|
||||
}
|
||||
|
||||
InputStreamReader r = new InputStreamReader(new FileInputStream(args[0]));
|
||||
ScriptEngine engine = new RhinoScriptEngine();
|
||||
|
||||
engine.put("x", "y");
|
||||
engine.put(ScriptEngine.FILENAME, args[0]);
|
||||
engine.eval(r);
|
||||
System.out.println(engine.get("x"));
|
||||
}
|
||||
*/
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 com.sun.script.javascript;
|
||||
import javax.script.*;
|
||||
import java.util.*;
|
||||
import sun.org.mozilla.javascript.internal.*;
|
||||
import com.sun.script.util.*;
|
||||
|
||||
/**
|
||||
* Factory to create RhinoScriptEngine
|
||||
*
|
||||
* @author Mike Grogan
|
||||
* @since 1.6
|
||||
*/
|
||||
public class RhinoScriptEngineFactory extends ScriptEngineFactoryBase {
|
||||
|
||||
public RhinoScriptEngineFactory() {
|
||||
}
|
||||
|
||||
public List<String> getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
|
||||
public List<String> getMimeTypes() {
|
||||
return mimeTypes;
|
||||
}
|
||||
|
||||
public List<String> getNames() {
|
||||
return names;
|
||||
}
|
||||
|
||||
public Object getParameter(String key) {
|
||||
if (key.equals(ScriptEngine.NAME)) {
|
||||
return "javascript";
|
||||
} else if (key.equals(ScriptEngine.ENGINE)) {
|
||||
return "Mozilla Rhino";
|
||||
} else if (key.equals(ScriptEngine.ENGINE_VERSION)) {
|
||||
return "1.7 release 3 PRERELEASE";
|
||||
} else if (key.equals(ScriptEngine.LANGUAGE)) {
|
||||
return "ECMAScript";
|
||||
} else if (key.equals(ScriptEngine.LANGUAGE_VERSION)) {
|
||||
return "1.8";
|
||||
} else if (key.equals("THREADING")) {
|
||||
return "MULTITHREADED";
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid key");
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptEngine getScriptEngine() {
|
||||
RhinoScriptEngine ret = new RhinoScriptEngine();
|
||||
ret.setEngineFactory(this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getMethodCallSyntax(String obj, String method, String... args) {
|
||||
|
||||
String ret = obj + "." + method + "(";
|
||||
int len = args.length;
|
||||
if (len == 0) {
|
||||
ret += ")";
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
ret += args[i];
|
||||
if (i != len - 1) {
|
||||
ret += ",";
|
||||
} else {
|
||||
ret += ")";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getOutputStatement(String toDisplay) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
int len = toDisplay.length();
|
||||
buf.append("print(\"");
|
||||
for (int i = 0; i < len; i++) {
|
||||
char ch = toDisplay.charAt(i);
|
||||
switch (ch) {
|
||||
case '"':
|
||||
buf.append("\\\"");
|
||||
break;
|
||||
case '\\':
|
||||
buf.append("\\\\");
|
||||
break;
|
||||
default:
|
||||
buf.append(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
buf.append("\")");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String getProgram(String... statements) {
|
||||
int len = statements.length;
|
||||
String ret = "";
|
||||
for (int i = 0; i < len; i++) {
|
||||
ret += statements[i] + ";";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
public static void main(String[] args) {
|
||||
RhinoScriptEngineFactory fact = new RhinoScriptEngineFactory();
|
||||
System.out.println(fact.getParameter(ScriptEngine.ENGINE_VERSION));
|
||||
}
|
||||
*/
|
||||
|
||||
private static List<String> names;
|
||||
private static List<String> mimeTypes;
|
||||
private static List<String> extensions;
|
||||
|
||||
static {
|
||||
names = new ArrayList<String>(6);
|
||||
names.add("js");
|
||||
names.add("rhino");
|
||||
names.add("JavaScript");
|
||||
names.add("javascript");
|
||||
names.add("ECMAScript");
|
||||
names.add("ecmascript");
|
||||
names = Collections.unmodifiableList(names);
|
||||
|
||||
mimeTypes = new ArrayList<String>(4);
|
||||
mimeTypes.add("application/javascript");
|
||||
mimeTypes.add("application/ecmascript");
|
||||
mimeTypes.add("text/javascript");
|
||||
mimeTypes.add("text/ecmascript");
|
||||
mimeTypes = Collections.unmodifiableList(mimeTypes);
|
||||
|
||||
extensions = new ArrayList<String>(1);
|
||||
extensions.add("js");
|
||||
extensions = Collections.unmodifiableList(extensions);
|
||||
}
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 com.sun.script.javascript;
|
||||
|
||||
import sun.org.mozilla.javascript.internal.*;
|
||||
import javax.script.*;
|
||||
|
||||
/**
|
||||
* This class serves as top level scope for Rhino. This class adds
|
||||
* 3 top level functions (bindings, scope, sync) and two constructors
|
||||
* (JSAdapter, JavaAdapter).
|
||||
*
|
||||
* @author A. Sundararajan
|
||||
* @since 1.6
|
||||
*/
|
||||
public final class RhinoTopLevel extends ImporterTopLevel {
|
||||
RhinoTopLevel(Context cx, RhinoScriptEngine engine) {
|
||||
super(cx);
|
||||
this.engine = engine;
|
||||
|
||||
|
||||
// initialize JSAdapter lazily. Reduces footprint & startup time.
|
||||
new LazilyLoadedCtor(this, "JSAdapter",
|
||||
"com.sun.script.javascript.JSAdapter",
|
||||
false);
|
||||
|
||||
/*
|
||||
* initialize JavaAdapter. We can't lazy initialize this because
|
||||
* lazy initializer attempts to define a new property. But, JavaAdapter
|
||||
* is an exisiting property that we overwrite.
|
||||
*/
|
||||
JavaAdapter.init(cx, this, false);
|
||||
|
||||
// add top level functions
|
||||
String names[] = { "bindings", "scope", "sync" };
|
||||
defineFunctionProperties(names, RhinoTopLevel.class,
|
||||
ScriptableObject.DONTENUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* The bindings function takes a JavaScript scope object
|
||||
* of type ExternalScriptable and returns the underlying Bindings
|
||||
* instance.
|
||||
*
|
||||
* var page = scope(pageBindings);
|
||||
* with (page) {
|
||||
* // code that uses page scope
|
||||
* }
|
||||
* var b = bindings(page);
|
||||
* // operate on bindings here.
|
||||
*/
|
||||
public static Object bindings(Context cx, Scriptable thisObj, Object[] args,
|
||||
Function funObj) {
|
||||
if (args.length == 1) {
|
||||
Object arg = args[0];
|
||||
if (arg instanceof Wrapper) {
|
||||
arg = ((Wrapper)arg).unwrap();
|
||||
}
|
||||
if (arg instanceof ExternalScriptable) {
|
||||
ScriptContext ctx = ((ExternalScriptable)arg).getContext();
|
||||
Bindings bind = ctx.getBindings(ScriptContext.ENGINE_SCOPE);
|
||||
return Context.javaToJS(bind,
|
||||
ScriptableObject.getTopLevelScope(thisObj));
|
||||
}
|
||||
}
|
||||
return cx.getUndefinedValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* The scope function creates a new JavaScript scope object
|
||||
* with given Bindings object as backing store. This can be used
|
||||
* to create a script scope based on arbitrary Bindings instance.
|
||||
* For example, in webapp scenario, a 'page' level Bindings instance
|
||||
* may be wrapped as a scope and code can be run in JavaScripe 'with'
|
||||
* statement:
|
||||
*
|
||||
* var page = scope(pageBindings);
|
||||
* with (page) {
|
||||
* // code that uses page scope
|
||||
* }
|
||||
*/
|
||||
public static Object scope(Context cx, Scriptable thisObj, Object[] args,
|
||||
Function funObj) {
|
||||
if (args.length == 1) {
|
||||
Object arg = args[0];
|
||||
if (arg instanceof Wrapper) {
|
||||
arg = ((Wrapper)arg).unwrap();
|
||||
}
|
||||
if (arg instanceof Bindings) {
|
||||
ScriptContext ctx = new SimpleScriptContext();
|
||||
ctx.setBindings((Bindings)arg, ScriptContext.ENGINE_SCOPE);
|
||||
Scriptable res = new ExternalScriptable(ctx);
|
||||
res.setPrototype(ScriptableObject.getObjectPrototype(thisObj));
|
||||
res.setParentScope(ScriptableObject.getTopLevelScope(thisObj));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return cx.getUndefinedValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* The sync function creates a synchronized function (in the sense
|
||||
* of a Java synchronized method) from an existing function. The
|
||||
* new function synchronizes on the <code>this</code> object of
|
||||
* its invocation.
|
||||
* js> var o = { f : sync(function(x) {
|
||||
* print("entry");
|
||||
* Packages.java.lang.Thread.sleep(x*1000);
|
||||
* print("exit");
|
||||
* })};
|
||||
* js> thread(function() {o.f(5);});
|
||||
* entry
|
||||
* js> thread(function() {o.f(5);});
|
||||
* js>
|
||||
* exit
|
||||
* entry
|
||||
* exit
|
||||
*/
|
||||
public static Object sync(Context cx, Scriptable thisObj, Object[] args,
|
||||
Function funObj) {
|
||||
if (args.length == 1 && args[0] instanceof Function) {
|
||||
return new Synchronizer((Function)args[0]);
|
||||
} else {
|
||||
throw Context.reportRuntimeError("wrong argument(s) for sync");
|
||||
}
|
||||
}
|
||||
|
||||
RhinoScriptEngine getScriptEngine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
private RhinoScriptEngine engine;
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.script.javascript;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import static sun.security.util.SecurityConstants.*;
|
||||
import sun.org.mozilla.javascript.internal.*;
|
||||
|
||||
/**
|
||||
* This wrap factory is used for security reasons. JSR 223 script
|
||||
* engine interface and JavaScript engine classes are run as bootstrap
|
||||
* classes. For example, java.lang.Class.forName method (when called without
|
||||
* class loader) uses caller's class loader. This may be exploited by script
|
||||
* authors to access classes otherwise not accessible. For example,
|
||||
* classes in sun.* namespace are normally not accessible to untrusted
|
||||
* code and hence should not be accessible to JavaScript run from
|
||||
* untrusted code.
|
||||
*
|
||||
* @author A. Sundararajan
|
||||
* @since 1.6
|
||||
*/
|
||||
final class RhinoWrapFactory extends WrapFactory {
|
||||
private RhinoWrapFactory() {}
|
||||
private static RhinoWrapFactory theInstance;
|
||||
|
||||
static synchronized WrapFactory getInstance() {
|
||||
if (theInstance == null) {
|
||||
theInstance = new RhinoWrapFactory();
|
||||
}
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
// We use instance of this class to wrap security sensitive
|
||||
// Java object. Please refer below.
|
||||
private static class RhinoJavaObject extends NativeJavaObject {
|
||||
RhinoJavaObject(Scriptable scope, Object obj, Class type) {
|
||||
// we pass 'null' to object. NativeJavaObject uses
|
||||
// passed 'type' to reflect fields and methods when
|
||||
// object is null.
|
||||
super(scope, null, type);
|
||||
|
||||
// Now, we set actual object. 'javaObject' is protected
|
||||
// field of NativeJavaObject.
|
||||
javaObject = obj;
|
||||
}
|
||||
}
|
||||
|
||||
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope,
|
||||
Object javaObject, Class staticType) {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
ClassShutter classShutter = RhinoClassShutter.getInstance();
|
||||
if (javaObject instanceof ClassLoader) {
|
||||
// Check with Security Manager whether we can expose a
|
||||
// ClassLoader...
|
||||
if (sm != null) {
|
||||
sm.checkPermission(GET_CLASSLOADER_PERMISSION);
|
||||
}
|
||||
// if we fall through here, check permission succeeded.
|
||||
return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
|
||||
} else {
|
||||
String name = null;
|
||||
if (javaObject instanceof Class) {
|
||||
name = ((Class)javaObject).getName();
|
||||
} else if (javaObject instanceof Member) {
|
||||
Member member = (Member) javaObject;
|
||||
// Check member access. Don't allow reflective access to
|
||||
// non-public members. Note that we can't call checkMemberAccess
|
||||
// because that expects exact stack depth!
|
||||
if (sm != null && !Modifier.isPublic(member.getModifiers())) {
|
||||
return null;
|
||||
}
|
||||
name = member.getDeclaringClass().getName();
|
||||
}
|
||||
// Now, make sure that no ClassShutter prevented Class or Member
|
||||
// of it is accessed reflectively. Note that ClassShutter may
|
||||
// prevent access to a class, even though SecurityManager permit.
|
||||
if (name != null) {
|
||||
if (!classShutter.visibleToScripts(name)) {
|
||||
return null;
|
||||
} else {
|
||||
return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we have got some non-reflective object.
|
||||
Class dynamicType = javaObject.getClass();
|
||||
String name = dynamicType.getName();
|
||||
if (!classShutter.visibleToScripts(name)) {
|
||||
// Object of some sensitive class (such as sun.net.www.*
|
||||
// objects returned from public method of java.net.URL class.
|
||||
// We expose this object as though it is an object of some
|
||||
// super class that is safe for access.
|
||||
|
||||
Class type = null;
|
||||
|
||||
// Whenever a Java Object is wrapped, we are passed with a
|
||||
// staticType which is the type found from environment. For
|
||||
// example, method return type known from signature. The dynamic
|
||||
// type would be the actual Class of the actual returned object.
|
||||
// If the staticType is an interface, we just use that type.
|
||||
if (staticType != null && staticType.isInterface()) {
|
||||
type = staticType;
|
||||
} else {
|
||||
// dynamicType is always a class type and never an interface.
|
||||
// find an accessible super class of the dynamic type.
|
||||
while (dynamicType != null) {
|
||||
dynamicType = dynamicType.getSuperclass();
|
||||
name = dynamicType.getName();
|
||||
if (classShutter.visibleToScripts(name)) {
|
||||
type = dynamicType; break;
|
||||
}
|
||||
}
|
||||
// atleast java.lang.Object has to be accessible. So, when
|
||||
// we reach here, type variable should not be null.
|
||||
assert type != null:
|
||||
"even java.lang.Object is not accessible?";
|
||||
}
|
||||
// create custom wrapper with the 'safe' type.
|
||||
return new RhinoJavaObject(scope, javaObject, type);
|
||||
} else {
|
||||
return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
package com.sun.script.util;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import java.util.Map;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
/**
|
||||
* Abstract super class for Bindings implementations
|
||||
*
|
||||
* @author Mike Grogan
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class BindingsBase extends AbstractMap<String, Object>
|
||||
implements Bindings {
|
||||
|
||||
//AbstractMap methods
|
||||
public Object get(Object name) {
|
||||
checkKey(name);
|
||||
return getImpl((String)name);
|
||||
}
|
||||
|
||||
public Object remove(Object key) {
|
||||
checkKey(key);
|
||||
return removeImpl((String)key);
|
||||
}
|
||||
|
||||
public Object put(String key, Object value) {
|
||||
checkKey(key);
|
||||
return putImpl(key, value);
|
||||
}
|
||||
|
||||
public void putAll(Map<? extends String, ? extends Object> toMerge) {
|
||||
for (Map.Entry<? extends String, ? extends Object> entry : toMerge.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
checkKey(key);
|
||||
putImpl(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
//BindingsBase methods
|
||||
public abstract Object putImpl(String name, Object value);
|
||||
public abstract Object getImpl(String name);
|
||||
public abstract Object removeImpl(String name);
|
||||
public abstract String[] getNames();
|
||||
|
||||
protected void checkKey(Object key) {
|
||||
if (key == null) {
|
||||
throw new NullPointerException("key can not be null");
|
||||
}
|
||||
if (!(key instanceof String)) {
|
||||
throw new ClassCastException("key should be String");
|
||||
}
|
||||
if (key.equals("")) {
|
||||
throw new IllegalArgumentException("key can not be empty");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
package com.sun.script.util;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Entry set implementation for Bindings implementations
|
||||
*
|
||||
* @author Mike Grogan
|
||||
* @since 1.6
|
||||
*/
|
||||
public class BindingsEntrySet extends AbstractSet<Map.Entry<String, Object>> {
|
||||
|
||||
private BindingsBase base;
|
||||
private String[] keys;
|
||||
|
||||
public BindingsEntrySet(BindingsBase base) {
|
||||
this.base = base;
|
||||
keys = base.getNames();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return keys.length;
|
||||
}
|
||||
|
||||
public Iterator<Map.Entry<String, Object>> iterator() {
|
||||
return new BindingsIterator();
|
||||
}
|
||||
|
||||
public class BindingsEntry implements Map.Entry<String, Object> {
|
||||
private String key;
|
||||
public BindingsEntry(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public Object setValue(Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return base.get(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class BindingsIterator implements Iterator<Map.Entry<String, Object>> {
|
||||
|
||||
private int current = 0;
|
||||
private boolean stale = false;
|
||||
|
||||
public boolean hasNext() {
|
||||
return (current < keys.length);
|
||||
}
|
||||
|
||||
public BindingsEntry next() {
|
||||
stale = false;
|
||||
return new BindingsEntry(keys[current++]);
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
if (stale || current == 0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
stale = true;
|
||||
base.remove(keys[current - 1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
package com.sun.script.util;
|
||||
import java.util.*;
|
||||
import javax.script.Bindings;
|
||||
|
||||
/*
|
||||
* Abstract super class for Bindings implementations. Handles
|
||||
* global and local scopes.
|
||||
*
|
||||
* @author Mike Grogan
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class BindingsImpl extends BindingsBase {
|
||||
|
||||
//get method delegates to global if key is not defined in
|
||||
//base class or local scope
|
||||
protected Bindings global = null;
|
||||
|
||||
//get delegates to local scope
|
||||
protected Bindings local = null;
|
||||
|
||||
public void setGlobal(Bindings n) {
|
||||
global = n;
|
||||
}
|
||||
|
||||
public void setLocal(Bindings n) {
|
||||
local = n;
|
||||
}
|
||||
|
||||
public Set<Map.Entry<String, Object>> entrySet() {
|
||||
return new BindingsEntrySet(this);
|
||||
}
|
||||
|
||||
public Object get(Object key) {
|
||||
checkKey(key);
|
||||
|
||||
Object ret = null;
|
||||
if ((local != null) && (null != (ret = local.get(key)))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = getImpl((String)key);
|
||||
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
} else if (global != null) {
|
||||
return global.get(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object remove(Object key) {
|
||||
checkKey(key);
|
||||
Object ret = get(key);
|
||||
if (ret != null) {
|
||||
removeImpl((String)key);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 com.sun.script.util;
|
||||
|
||||
import javax.script.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.security.*;
|
||||
|
||||
/*
|
||||
* java.lang.reflect.Proxy based interface implementor. This is meant
|
||||
* to be used to implement Invocable.getInterface.
|
||||
*
|
||||
* @author Mike Grogan
|
||||
* @since 1.6
|
||||
*/
|
||||
public class InterfaceImplementor {
|
||||
|
||||
private Invocable engine;
|
||||
|
||||
/** Creates a new instance of Invocable */
|
||||
public InterfaceImplementor(Invocable engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
private final class InterfaceImplementorInvocationHandler
|
||||
implements InvocationHandler {
|
||||
private Object thiz;
|
||||
private AccessControlContext accCtxt;
|
||||
|
||||
public InterfaceImplementorInvocationHandler(Object thiz,
|
||||
AccessControlContext accCtxt) {
|
||||
this.thiz = thiz;
|
||||
this.accCtxt = accCtxt;
|
||||
}
|
||||
|
||||
public Object invoke(Object proxy , Method method, Object[] args)
|
||||
throws java.lang.Throwable {
|
||||
// give chance to convert input args
|
||||
args = convertArguments(method, args);
|
||||
Object result;
|
||||
final Method m = method;
|
||||
final Object[] a = args;
|
||||
result = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||
public Object run() throws Exception {
|
||||
if (thiz == null) {
|
||||
return engine.invokeFunction(m.getName(), a);
|
||||
} else {
|
||||
return engine.invokeMethod(thiz, m.getName(), a);
|
||||
}
|
||||
}
|
||||
}, accCtxt);
|
||||
// give chance to convert the method result
|
||||
return convertResult(method, result);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T getInterface(Object thiz, Class<T> iface)
|
||||
throws ScriptException {
|
||||
if (iface == null || !iface.isInterface()) {
|
||||
throw new IllegalArgumentException("interface Class expected");
|
||||
}
|
||||
if (! isImplemented(thiz, iface)) {
|
||||
return null;
|
||||
}
|
||||
AccessControlContext accCtxt = AccessController.getContext();
|
||||
return iface.cast(Proxy.newProxyInstance(iface.getClassLoader(),
|
||||
new Class[]{iface},
|
||||
new InterfaceImplementorInvocationHandler(thiz, accCtxt)));
|
||||
}
|
||||
|
||||
protected boolean isImplemented(Object thiz, Class<?> iface) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// called to convert method result after invoke
|
||||
protected Object convertResult(Method method, Object res)
|
||||
throws ScriptException {
|
||||
// default is identity conversion
|
||||
return res;
|
||||
}
|
||||
|
||||
// called to convert method arguments before invoke
|
||||
protected Object[] convertArguments(Method method, Object[] args)
|
||||
throws ScriptException {
|
||||
// default is identity conversion
|
||||
return args;
|
||||
}
|
||||
}
|
@ -348,14 +348,23 @@ final class DigestMD5Client extends DigestMD5Base implements SaslClient {
|
||||
0, false);
|
||||
cbh.handle(new Callback[] {ccb, ncb, pcb});
|
||||
|
||||
/* Acquire realm from RealmChoiceCallback*/
|
||||
negotiatedRealm = realmTokens[ccb.getSelectedIndexes()[0]];
|
||||
// Acquire realm from RealmChoiceCallback
|
||||
int[] selected = ccb.getSelectedIndexes();
|
||||
if (selected == null
|
||||
|| selected[0] < 0
|
||||
|| selected[0] >= realmTokens.length) {
|
||||
throw new SaslException("DIGEST-MD5: Invalid realm chosen");
|
||||
}
|
||||
negotiatedRealm = realmTokens[selected[0]];
|
||||
}
|
||||
|
||||
passwd = pcb.getPassword();
|
||||
pcb.clearPassword();
|
||||
username = ncb.getName();
|
||||
|
||||
} catch (SaslException se) {
|
||||
throw se;
|
||||
|
||||
} catch (UnsupportedCallbackException e) {
|
||||
throw new SaslException("DIGEST-MD5: Cannot perform callback to " +
|
||||
"acquire realm, authentication ID or password", e);
|
||||
|
@ -142,7 +142,7 @@ abstract class AbstractLauncher extends ConnectorImpl implements LaunchingConnec
|
||||
* This class simply provides a context for a single launch and
|
||||
* accept. It provides instance fields that can be used by
|
||||
* all threads involved. This stuff can't be in the Connector proper
|
||||
* because the connector is is a singleton and not specific to any
|
||||
* because the connector is a singleton and is not specific to any
|
||||
* one launch.
|
||||
*/
|
||||
private class Helper {
|
||||
|
@ -213,7 +213,7 @@ public class SunCommandLineLauncher extends AbstractLauncher implements Launchin
|
||||
exePath = exe;
|
||||
}
|
||||
// Quote only if necessary in case the quote arg value is bogus
|
||||
if (hasWhitespace(exe)) {
|
||||
if (hasWhitespace(exePath)) {
|
||||
exePath = quote + exePath + quote;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 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,6 +26,13 @@
|
||||
package java.io;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Spliterator;
|
||||
import java.util.Spliterators;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
/**
|
||||
* Reads text from a character-input stream, buffering characters so as to
|
||||
* provide for the efficient reading of characters, arrays, and lines.
|
||||
@ -522,4 +529,64 @@ public class BufferedReader extends Reader {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code Stream}, the elements of which are lines read from
|
||||
* this {@code BufferedReader}. The {@link Stream} is lazily populated,
|
||||
* i.e, read only occurs during the
|
||||
* <a href="../util/stream/package-summary.html#StreamOps">terminal
|
||||
* stream operation</a>.
|
||||
*
|
||||
* <p> The reader must not be operated on during the execution of the
|
||||
* terminal stream operation. Otherwise, the result of the terminal stream
|
||||
* operation is undefined.
|
||||
*
|
||||
* <p> After execution of the terminal stream operation there are no
|
||||
* guarantees that the reader will be at a specific position from which to
|
||||
* read the next character or line.
|
||||
*
|
||||
* <p> If an {@link IOException} is thrown when accessing the underlying
|
||||
* {@code BufferedReader}, it is wrapped in an {@link
|
||||
* UncheckedIOException} which will be thrown from the {@code Stream}
|
||||
* method that caused the read to take place. This method will return a
|
||||
* Stream if invoked on a BufferedReader that is closed. Any operation on
|
||||
* that stream requires reading from the BufferedReader after is it closed
|
||||
* will cause an UncheckedIOException to be thrown.
|
||||
*
|
||||
* @return a {@code Stream<String>} providing the lines of text
|
||||
* described by this {@code BufferedReader}
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public Stream<String> lines() {
|
||||
Iterator<String> iter = new Iterator<String>() {
|
||||
String nextLine = null;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (nextLine != null) {
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
nextLine = readLine();
|
||||
return (nextLine != null);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String next() {
|
||||
if (nextLine != null || hasNext()) {
|
||||
String line = nextLine;
|
||||
nextLine = null;
|
||||
return line;
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
};
|
||||
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter, Spliterator.ORDERED));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -156,7 +156,7 @@ public class File
|
||||
private static final FileSystem fs = DefaultFileSystem.getFileSystem();
|
||||
|
||||
/**
|
||||
* This abstract pathname's normalized pathname string. A normalized
|
||||
* This abstract pathname's normalized pathname string. A normalized
|
||||
* pathname string uses the default name-separator character and does not
|
||||
* contain any duplicate or redundant separators.
|
||||
*
|
||||
@ -164,6 +164,32 @@ public class File
|
||||
*/
|
||||
private final String path;
|
||||
|
||||
/**
|
||||
* Enum type that indicates the status of a file path.
|
||||
*/
|
||||
private static enum PathStatus { INVALID, CHECKED };
|
||||
|
||||
/**
|
||||
* The flag indicating whether the file path is invalid.
|
||||
*/
|
||||
private transient PathStatus status = null;
|
||||
|
||||
/**
|
||||
* Check if the file has an invalid path. Currently, the inspection of
|
||||
* a file path is very limited, and it only covers Nul character check.
|
||||
* Returning true means the path is definitely invalid/garbage. But
|
||||
* returning false does not guarantee that the path is valid.
|
||||
*
|
||||
* @return true if the file path is invalid.
|
||||
*/
|
||||
final boolean isInvalid() {
|
||||
if (status == null) {
|
||||
status = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED
|
||||
: PathStatus.INVALID;
|
||||
}
|
||||
return status == PathStatus.INVALID;
|
||||
}
|
||||
|
||||
/**
|
||||
* The length of this abstract pathname's prefix, or zero if it has no
|
||||
* prefix.
|
||||
@ -586,6 +612,9 @@ public class File
|
||||
* @see Path#toRealPath
|
||||
*/
|
||||
public String getCanonicalPath() throws IOException {
|
||||
if (isInvalid()) {
|
||||
throw new IOException("Invalid file path");
|
||||
}
|
||||
return fs.canonicalize(fs.resolve(this));
|
||||
}
|
||||
|
||||
@ -651,6 +680,9 @@ public class File
|
||||
*/
|
||||
@Deprecated
|
||||
public URL toURL() throws MalformedURLException {
|
||||
if (isInvalid()) {
|
||||
throw new MalformedURLException("Invalid file path");
|
||||
}
|
||||
return new URL("file", "", slashify(getAbsolutePath(), isDirectory()));
|
||||
}
|
||||
|
||||
@ -730,6 +762,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.checkAccess(this, FileSystem.ACCESS_READ);
|
||||
}
|
||||
|
||||
@ -755,6 +790,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkWrite(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.checkAccess(this, FileSystem.ACCESS_WRITE);
|
||||
}
|
||||
|
||||
@ -775,6 +813,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return ((fs.getBooleanAttributes(this) & FileSystem.BA_EXISTS) != 0);
|
||||
}
|
||||
|
||||
@ -802,6 +843,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return ((fs.getBooleanAttributes(this) & FileSystem.BA_DIRECTORY)
|
||||
!= 0);
|
||||
}
|
||||
@ -832,6 +876,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return ((fs.getBooleanAttributes(this) & FileSystem.BA_REGULAR) != 0);
|
||||
}
|
||||
|
||||
@ -858,6 +905,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return ((fs.getBooleanAttributes(this) & FileSystem.BA_HIDDEN) != 0);
|
||||
}
|
||||
|
||||
@ -887,6 +937,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return 0L;
|
||||
}
|
||||
return fs.getLastModifiedTime(this);
|
||||
}
|
||||
|
||||
@ -915,6 +968,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return 0L;
|
||||
}
|
||||
return fs.getLength(this);
|
||||
}
|
||||
|
||||
@ -950,6 +1006,9 @@ public class File
|
||||
public boolean createNewFile() throws IOException {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) security.checkWrite(path);
|
||||
if (isInvalid()) {
|
||||
throw new IOException("Invalid file path");
|
||||
}
|
||||
return fs.createFileExclusively(path);
|
||||
}
|
||||
|
||||
@ -976,6 +1035,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkDelete(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.delete(this);
|
||||
}
|
||||
|
||||
@ -1011,6 +1073,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkDelete(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return;
|
||||
}
|
||||
DeleteOnExitHook.add(path);
|
||||
}
|
||||
|
||||
@ -1051,6 +1116,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return null;
|
||||
}
|
||||
return fs.list(this);
|
||||
}
|
||||
|
||||
@ -1242,6 +1310,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkWrite(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.createDirectory(this);
|
||||
}
|
||||
|
||||
@ -1317,6 +1388,12 @@ public class File
|
||||
security.checkWrite(path);
|
||||
security.checkWrite(dest.path);
|
||||
}
|
||||
if (dest == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (this.isInvalid() || dest.isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.rename(this, dest);
|
||||
}
|
||||
|
||||
@ -1352,6 +1429,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkWrite(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.setLastModifiedTime(this, time);
|
||||
}
|
||||
|
||||
@ -1379,6 +1459,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkWrite(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.setReadOnly(this);
|
||||
}
|
||||
|
||||
@ -1419,6 +1502,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkWrite(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.setPermission(this, FileSystem.ACCESS_WRITE, writable, ownerOnly);
|
||||
}
|
||||
|
||||
@ -1493,6 +1579,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkWrite(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.setPermission(this, FileSystem.ACCESS_READ, readable, ownerOnly);
|
||||
}
|
||||
|
||||
@ -1570,6 +1659,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkWrite(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.setPermission(this, FileSystem.ACCESS_EXECUTE, executable, ownerOnly);
|
||||
}
|
||||
|
||||
@ -1629,6 +1721,9 @@ public class File
|
||||
if (security != null) {
|
||||
security.checkExec(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return false;
|
||||
}
|
||||
return fs.checkAccess(this, FileSystem.ACCESS_EXECUTE);
|
||||
}
|
||||
|
||||
@ -1705,6 +1800,9 @@ public class File
|
||||
sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
|
||||
sm.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return 0L;
|
||||
}
|
||||
return fs.getSpace(this, FileSystem.SPACE_TOTAL);
|
||||
}
|
||||
|
||||
@ -1721,7 +1819,7 @@ public class File
|
||||
* makes no guarantee that write operations to this file system
|
||||
* will succeed.
|
||||
*
|
||||
* @return The number of unallocated bytes on the partition <tt>0L</tt>
|
||||
* @return The number of unallocated bytes on the partition or <tt>0L</tt>
|
||||
* if the abstract pathname does not name a partition. This
|
||||
* value will be less than or equal to the total file system size
|
||||
* returned by {@link #getTotalSpace}.
|
||||
@ -1740,6 +1838,9 @@ public class File
|
||||
sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
|
||||
sm.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return 0L;
|
||||
}
|
||||
return fs.getSpace(this, FileSystem.SPACE_FREE);
|
||||
}
|
||||
|
||||
@ -1778,6 +1879,9 @@ public class File
|
||||
sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
|
||||
sm.checkRead(path);
|
||||
}
|
||||
if (isInvalid()) {
|
||||
return 0L;
|
||||
}
|
||||
return fs.getSpace(this, FileSystem.SPACE_USABLE);
|
||||
}
|
||||
|
||||
@ -1787,8 +1891,8 @@ public class File
|
||||
private TempDirectory() { }
|
||||
|
||||
// temporary directory location
|
||||
private static final File tmpdir = new File(fs.normalize(AccessController
|
||||
.doPrivileged(new GetPropertyAction("java.io.tmpdir"))));
|
||||
private static final File tmpdir = new File(AccessController
|
||||
.doPrivileged(new GetPropertyAction("java.io.tmpdir")));
|
||||
static File location() {
|
||||
return tmpdir;
|
||||
}
|
||||
@ -1899,6 +2003,9 @@ public class File
|
||||
throw se;
|
||||
}
|
||||
}
|
||||
if (f.isInvalid()) {
|
||||
throw new IOException("Unable to create temporary file");
|
||||
}
|
||||
} while (!fs.createFileExclusively(f.getPath()));
|
||||
return f;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -123,6 +123,9 @@ class FileInputStream extends InputStream
|
||||
if (name == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (file.isInvalid()) {
|
||||
throw new FileNotFoundException("Invalid file path");
|
||||
}
|
||||
fd = new FileDescriptor();
|
||||
fd.attach(this);
|
||||
open(name);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -196,6 +196,9 @@ class FileOutputStream extends OutputStream
|
||||
if (name == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (file.isInvalid()) {
|
||||
throw new FileNotFoundException("Invalid file path");
|
||||
}
|
||||
this.fd = new FileDescriptor();
|
||||
fd.attach(this);
|
||||
this.append = append;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -228,6 +228,9 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
|
||||
if (name == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (file.isInvalid()) {
|
||||
throw new FileNotFoundException("Invalid file path");
|
||||
}
|
||||
fd = new FileDescriptor();
|
||||
fd.attach(this);
|
||||
open(name, imode);
|
||||
|
90
jdk/src/share/classes/java/io/UncheckedIOException.java
Normal file
90
jdk/src/share/classes/java/io/UncheckedIOException.java
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.io;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Wraps an {@link IOException} with an unchecked exception.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public class UncheckedIOException extends RuntimeException {
|
||||
private static final long serialVersionUID = -8134305061645241065L;
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*
|
||||
* @param message
|
||||
* the detail message, can be null
|
||||
* @param cause
|
||||
* the {@code IOException}
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* if the cause is {@code null}
|
||||
*/
|
||||
public UncheckedIOException(String message, IOException cause) {
|
||||
super(message, Objects.requireNonNull(cause));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of this class.
|
||||
*
|
||||
* @param cause
|
||||
* the {@code IOException}
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* if the cause is {@code null}
|
||||
*/
|
||||
public UncheckedIOException(IOException cause) {
|
||||
super(Objects.requireNonNull(cause));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this exception.
|
||||
*
|
||||
* @return the {@code IOException} which is the cause of this exception.
|
||||
*/
|
||||
@Override
|
||||
public IOException getCause() {
|
||||
return (IOException) super.getCause();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to read the object from a stream.
|
||||
*
|
||||
* @throws InvalidObjectException
|
||||
* if the object is invalid or has a cause that is not
|
||||
* an {@code IOException}
|
||||
*/
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
s.defaultReadObject();
|
||||
Throwable cause = super.getCause();
|
||||
if (!(cause instanceof IOException))
|
||||
throw new InvalidObjectException("Cause must be an IOException");
|
||||
}
|
||||
}
|
@ -29,7 +29,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.security.AccessControlException;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
@ -1024,10 +1023,10 @@ public final class ProcessBuilder
|
||||
dir,
|
||||
redirects,
|
||||
redirectErrorStream);
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
String exceptionInfo = ": " + e.getMessage();
|
||||
Throwable cause = e;
|
||||
if (security != null) {
|
||||
if ((e instanceof IOException) && security != null) {
|
||||
// Can not disclose the fail reason for read-protected files.
|
||||
try {
|
||||
security.checkRead(prog);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
package java.lang;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A thread-safe, mutable sequence of characters.
|
||||
@ -98,6 +99,12 @@ package java.lang;
|
||||
implements java.io.Serializable, CharSequence
|
||||
{
|
||||
|
||||
/**
|
||||
* A cache of the last value returned by toString. Cleared
|
||||
* whenever the StringBuffer is modified.
|
||||
*/
|
||||
private transient char[] toStringCache;
|
||||
|
||||
/** use serialVersionUID from JDK 1.0.2 for interoperability */
|
||||
static final long serialVersionUID = 3388685877147921107L;
|
||||
|
||||
@ -183,6 +190,7 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized void setLength(int newLength) {
|
||||
toStringCache = null;
|
||||
super.setLength(newLength);
|
||||
}
|
||||
|
||||
@ -247,17 +255,20 @@ package java.lang;
|
||||
public synchronized void setCharAt(int index, char ch) {
|
||||
if ((index < 0) || (index >= count))
|
||||
throw new StringIndexOutOfBoundsException(index);
|
||||
toStringCache = null;
|
||||
value[index] = ch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized StringBuffer append(Object obj) {
|
||||
toStringCache = null;
|
||||
super.append(String.valueOf(obj));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized StringBuffer append(String str) {
|
||||
toStringCache = null;
|
||||
super.append(str);
|
||||
return this;
|
||||
}
|
||||
@ -287,6 +298,7 @@ package java.lang;
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized StringBuffer append(StringBuffer sb) {
|
||||
toStringCache = null;
|
||||
super.append(sb);
|
||||
return this;
|
||||
}
|
||||
@ -296,6 +308,7 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
synchronized StringBuffer append(AbstractStringBuilder asb) {
|
||||
toStringCache = null;
|
||||
super.append(asb);
|
||||
return this;
|
||||
}
|
||||
@ -325,6 +338,7 @@ package java.lang;
|
||||
public StringBuffer append(CharSequence s) {
|
||||
// Note, synchronization achieved via invocations of other StringBuffer methods after
|
||||
// narrowing of s to specific type
|
||||
// Ditto for toStringCache clearing
|
||||
super.append(s);
|
||||
return this;
|
||||
}
|
||||
@ -336,12 +350,14 @@ package java.lang;
|
||||
@Override
|
||||
public synchronized StringBuffer append(CharSequence s, int start, int end)
|
||||
{
|
||||
toStringCache = null;
|
||||
super.append(s, start, end);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized StringBuffer append(char[] str) {
|
||||
toStringCache = null;
|
||||
super.append(str);
|
||||
return this;
|
||||
}
|
||||
@ -351,24 +367,28 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer append(char[] str, int offset, int len) {
|
||||
toStringCache = null;
|
||||
super.append(str, offset, len);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized StringBuffer append(boolean b) {
|
||||
toStringCache = null;
|
||||
super.append(b);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized StringBuffer append(char c) {
|
||||
toStringCache = null;
|
||||
super.append(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized StringBuffer append(int i) {
|
||||
toStringCache = null;
|
||||
super.append(i);
|
||||
return this;
|
||||
}
|
||||
@ -378,24 +398,28 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer appendCodePoint(int codePoint) {
|
||||
toStringCache = null;
|
||||
super.appendCodePoint(codePoint);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized StringBuffer append(long lng) {
|
||||
toStringCache = null;
|
||||
super.append(lng);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized StringBuffer append(float f) {
|
||||
toStringCache = null;
|
||||
super.append(f);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized StringBuffer append(double d) {
|
||||
toStringCache = null;
|
||||
super.append(d);
|
||||
return this;
|
||||
}
|
||||
@ -406,6 +430,7 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer delete(int start, int end) {
|
||||
toStringCache = null;
|
||||
super.delete(start, end);
|
||||
return this;
|
||||
}
|
||||
@ -416,6 +441,7 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer deleteCharAt(int index) {
|
||||
toStringCache = null;
|
||||
super.deleteCharAt(index);
|
||||
return this;
|
||||
}
|
||||
@ -426,6 +452,7 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer replace(int start, int end, String str) {
|
||||
toStringCache = null;
|
||||
super.replace(start, end, str);
|
||||
return this;
|
||||
}
|
||||
@ -465,6 +492,7 @@ package java.lang;
|
||||
public synchronized StringBuffer insert(int index, char[] str, int offset,
|
||||
int len)
|
||||
{
|
||||
toStringCache = null;
|
||||
super.insert(index, str, offset, len);
|
||||
return this;
|
||||
}
|
||||
@ -474,6 +502,7 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer insert(int offset, Object obj) {
|
||||
toStringCache = null;
|
||||
super.insert(offset, String.valueOf(obj));
|
||||
return this;
|
||||
}
|
||||
@ -483,6 +512,7 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer insert(int offset, String str) {
|
||||
toStringCache = null;
|
||||
super.insert(offset, str);
|
||||
return this;
|
||||
}
|
||||
@ -492,6 +522,7 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer insert(int offset, char[] str) {
|
||||
toStringCache = null;
|
||||
super.insert(offset, str);
|
||||
return this;
|
||||
}
|
||||
@ -504,6 +535,7 @@ package java.lang;
|
||||
public StringBuffer insert(int dstOffset, CharSequence s) {
|
||||
// Note, synchronization achieved via invocations of other StringBuffer methods
|
||||
// after narrowing of s to specific type
|
||||
// Ditto for toStringCache clearing
|
||||
super.insert(dstOffset, s);
|
||||
return this;
|
||||
}
|
||||
@ -516,6 +548,7 @@ package java.lang;
|
||||
public synchronized StringBuffer insert(int dstOffset, CharSequence s,
|
||||
int start, int end)
|
||||
{
|
||||
toStringCache = null;
|
||||
super.insert(dstOffset, s, start, end);
|
||||
return this;
|
||||
}
|
||||
@ -527,6 +560,7 @@ package java.lang;
|
||||
public StringBuffer insert(int offset, boolean b) {
|
||||
// Note, synchronization achieved via invocation of StringBuffer insert(int, String)
|
||||
// after conversion of b to String by super class method
|
||||
// Ditto for toStringCache clearing
|
||||
super.insert(offset, b);
|
||||
return this;
|
||||
}
|
||||
@ -536,6 +570,7 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer insert(int offset, char c) {
|
||||
toStringCache = null;
|
||||
super.insert(offset, c);
|
||||
return this;
|
||||
}
|
||||
@ -547,6 +582,7 @@ package java.lang;
|
||||
public StringBuffer insert(int offset, int i) {
|
||||
// Note, synchronization achieved via invocation of StringBuffer insert(int, String)
|
||||
// after conversion of i to String by super class method
|
||||
// Ditto for toStringCache clearing
|
||||
super.insert(offset, i);
|
||||
return this;
|
||||
}
|
||||
@ -558,6 +594,7 @@ package java.lang;
|
||||
public StringBuffer insert(int offset, long l) {
|
||||
// Note, synchronization achieved via invocation of StringBuffer insert(int, String)
|
||||
// after conversion of l to String by super class method
|
||||
// Ditto for toStringCache clearing
|
||||
super.insert(offset, l);
|
||||
return this;
|
||||
}
|
||||
@ -569,6 +606,7 @@ package java.lang;
|
||||
public StringBuffer insert(int offset, float f) {
|
||||
// Note, synchronization achieved via invocation of StringBuffer insert(int, String)
|
||||
// after conversion of f to String by super class method
|
||||
// Ditto for toStringCache clearing
|
||||
super.insert(offset, f);
|
||||
return this;
|
||||
}
|
||||
@ -580,6 +618,7 @@ package java.lang;
|
||||
public StringBuffer insert(int offset, double d) {
|
||||
// Note, synchronization achieved via invocation of StringBuffer insert(int, String)
|
||||
// after conversion of d to String by super class method
|
||||
// Ditto for toStringCache clearing
|
||||
super.insert(offset, d);
|
||||
return this;
|
||||
}
|
||||
@ -623,13 +662,17 @@ package java.lang;
|
||||
*/
|
||||
@Override
|
||||
public synchronized StringBuffer reverse() {
|
||||
toStringCache = null;
|
||||
super.reverse();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String toString() {
|
||||
return new String(value, 0, count);
|
||||
if (toStringCache == null) {
|
||||
toStringCache = Arrays.copyOfRange(value, 0, count);
|
||||
}
|
||||
return new String(toStringCache, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1246,6 +1246,9 @@ public final class System {
|
||||
public StackTraceElement getStackTraceElement(Throwable t, int i) {
|
||||
return t.getStackTraceElement(i);
|
||||
}
|
||||
public String newStringUnsafe(char[] chars) {
|
||||
return new String(chars, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -236,6 +236,8 @@ import java.util.Objects;
|
||||
assert(MethodHandleNatives.refKindIsMethod(refKind));
|
||||
if (clazz.isInterface())
|
||||
assert(refKind == REF_invokeInterface ||
|
||||
refKind == REF_invokeStatic ||
|
||||
refKind == REF_invokeSpecial ||
|
||||
refKind == REF_invokeVirtual && isObjectPublicMethod());
|
||||
} else {
|
||||
assert(false);
|
||||
@ -268,7 +270,7 @@ import java.util.Objects;
|
||||
assert(refKind == REF_invokeSpecial) : this;
|
||||
return true;
|
||||
}
|
||||
assert(false) : this;
|
||||
assert(false) : this+" != "+MethodHandleNatives.refKindName((byte)originalRefKind);
|
||||
return true;
|
||||
}
|
||||
private boolean staticIsConsistent() {
|
||||
@ -485,14 +487,19 @@ import java.util.Objects;
|
||||
if (this.type == null)
|
||||
this.type = new Object[] { m.getReturnType(), m.getParameterTypes() };
|
||||
if (wantSpecial) {
|
||||
assert(!isAbstract()) : this;
|
||||
if (getReferenceKind() == REF_invokeVirtual)
|
||||
changeReferenceKind(REF_invokeSpecial, REF_invokeVirtual);
|
||||
else if (getReferenceKind() == REF_invokeInterface)
|
||||
// invokeSpecial on a default method
|
||||
changeReferenceKind(REF_invokeSpecial, REF_invokeInterface);
|
||||
}
|
||||
}
|
||||
public MemberName asSpecial() {
|
||||
switch (getReferenceKind()) {
|
||||
case REF_invokeSpecial: return this;
|
||||
case REF_invokeVirtual: return clone().changeReferenceKind(REF_invokeSpecial, REF_invokeVirtual);
|
||||
case REF_invokeInterface: return clone().changeReferenceKind(REF_invokeSpecial, REF_invokeInterface);
|
||||
case REF_newInvokeSpecial: return clone().changeReferenceKind(REF_invokeSpecial, REF_newInvokeSpecial);
|
||||
}
|
||||
throw new IllegalArgumentException(this.toString());
|
||||
|
@ -486,8 +486,8 @@ public abstract class Executable extends AccessibleObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an AnnotatedType object that represents the potentially
|
||||
* annotated return type of the method/constructor represented by this
|
||||
* Returns an AnnotatedType object that represents the use of a type to
|
||||
* specify the return type of the method/constructor represented by this
|
||||
* Executable.
|
||||
*
|
||||
* If this Executable represents a constructor, the AnnotatedType object
|
||||
@ -510,12 +510,12 @@ public abstract class Executable extends AccessibleObject
|
||||
*/
|
||||
AnnotatedType getAnnotatedReturnType0(Type returnType) {
|
||||
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
returnType,
|
||||
TypeAnnotation.TypeAnnotationTarget.METHOD_RETURN_TYPE);
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
returnType,
|
||||
TypeAnnotation.TypeAnnotationTarget.METHOD_RETURN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -535,12 +535,12 @@ public abstract class Executable extends AccessibleObject
|
||||
*/
|
||||
public AnnotatedType getAnnotatedReceiverType() {
|
||||
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
getDeclaringClass(),
|
||||
TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER_TYPE);
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
getDeclaringClass(),
|
||||
TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -556,7 +556,13 @@ public abstract class Executable extends AccessibleObject
|
||||
* @since 1.8
|
||||
*/
|
||||
public AnnotatedType[] getAnnotatedParameterTypes() {
|
||||
throw new UnsupportedOperationException("Not yet");
|
||||
return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
getParameterTypes(),
|
||||
TypeAnnotation.TypeAnnotationTarget.METHOD_FORMAL_PARAMETER);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -573,12 +579,12 @@ public abstract class Executable extends AccessibleObject
|
||||
*/
|
||||
public AnnotatedType[] getAnnotatedExceptionTypes() {
|
||||
return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes(),
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
getGenericExceptionTypes(),
|
||||
TypeAnnotation.TypeAnnotationTarget.THROWS);
|
||||
sun.misc.SharedSecrets.getJavaLangAccess().
|
||||
getConstantPool(getDeclaringClass()),
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
getGenericExceptionTypes(),
|
||||
TypeAnnotation.TypeAnnotationTarget.THROWS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1161,6 +1161,6 @@ class Field extends AccessibleObject implements Member {
|
||||
this,
|
||||
getDeclaringClass(),
|
||||
getGenericType(),
|
||||
TypeAnnotation.TypeAnnotationTarget.FIELD_TYPE);
|
||||
TypeAnnotation.TypeAnnotationTarget.FIELD);
|
||||
}
|
||||
}
|
||||
|
@ -350,8 +350,19 @@ public class Modifier {
|
||||
return (mod & MANDATED) != 0;
|
||||
}
|
||||
|
||||
// Note on the FOO_MODIFIERS fields and fooModifiers() methods:
|
||||
// the sets of modifiers are not guaranteed to be constants
|
||||
// across time and Java SE releases. Therefore, it would not be
|
||||
// appropriate to expose an external interface to this information
|
||||
// that would allow the values to be treated as Java-level
|
||||
// constants since the values could be constant folded and updates
|
||||
// to the sets of modifiers missed. Thus, the fooModifiers()
|
||||
// methods return an unchanging values for a given release, but a
|
||||
// value that can potentially change over time.
|
||||
|
||||
/**
|
||||
* See JLSv3 section 8.1.1.
|
||||
* The Java source modifiers that can be applied to a class.
|
||||
* @jls 8.1.1 Class Modifiers
|
||||
*/
|
||||
private static final int CLASS_MODIFIERS =
|
||||
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
|
||||
@ -359,7 +370,8 @@ public class Modifier {
|
||||
Modifier.STRICT;
|
||||
|
||||
/**
|
||||
* See JLSv3 section 9.1.1.
|
||||
* The Java source modifiers that can be applied to an interface.
|
||||
* @jls 9.1.1 Interface Modifiers
|
||||
*/
|
||||
private static final int INTERFACE_MODIFIERS =
|
||||
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
|
||||
@ -367,13 +379,15 @@ public class Modifier {
|
||||
|
||||
|
||||
/**
|
||||
* See JLSv3 section 8.8.3.
|
||||
* The Java source modifiers that can be applied to a constructor.
|
||||
* @jls 8.8.3 Constructor Modifiers
|
||||
*/
|
||||
private static final int CONSTRUCTOR_MODIFIERS =
|
||||
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
|
||||
|
||||
/**
|
||||
* See JLSv3 section 8.4.3.
|
||||
* The Java source modifiers that can be applied to a method.
|
||||
* @jls8.4.3 Method Modifiers
|
||||
*/
|
||||
private static final int METHOD_MODIFIERS =
|
||||
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
|
||||
@ -381,13 +395,21 @@ public class Modifier {
|
||||
Modifier.SYNCHRONIZED | Modifier.NATIVE | Modifier.STRICT;
|
||||
|
||||
/**
|
||||
* See JLSv3 section 8.3.1.
|
||||
* The Java source modifiers that can be applied to a field.
|
||||
* @jls 8.3.1 Field Modifiers
|
||||
*/
|
||||
private static final int FIELD_MODIFIERS =
|
||||
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
|
||||
Modifier.STATIC | Modifier.FINAL | Modifier.TRANSIENT |
|
||||
Modifier.VOLATILE;
|
||||
|
||||
/**
|
||||
* The Java source modifiers that can be applied to a method or constructor parameter.
|
||||
* @jls 8.4.1 Formal Parameters
|
||||
*/
|
||||
private static final int PARAMETER_MODIFIERS =
|
||||
Modifier.FINAL;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -411,7 +433,7 @@ public class Modifier {
|
||||
* Return an {@code int} value OR-ing together the source language
|
||||
* modifiers that can be applied to an interface.
|
||||
* @return an {@code int} value OR-ing together the source language
|
||||
* modifiers that can be applied to an inteface.
|
||||
* modifiers that can be applied to an interface.
|
||||
*
|
||||
* @jls 9.1.1 Interface Modifiers
|
||||
* @since 1.7
|
||||
@ -446,7 +468,6 @@ public class Modifier {
|
||||
return METHOD_MODIFIERS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an {@code int} value OR-ing together the source language
|
||||
* modifiers that can be applied to a field.
|
||||
@ -459,4 +480,17 @@ public class Modifier {
|
||||
public static int fieldModifiers() {
|
||||
return FIELD_MODIFIERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an {@code int} value OR-ing together the source language
|
||||
* modifiers that can be applied to a parameter.
|
||||
* @return an {@code int} value OR-ing together the source language
|
||||
* modifiers that can be applied to a parameter.
|
||||
*
|
||||
* @jls 8.4.1 Formal Parameters
|
||||
* @since 1.8
|
||||
*/
|
||||
public static int parameterModifiers() {
|
||||
return PARAMETER_MODIFIERS;
|
||||
}
|
||||
}
|
||||
|
@ -200,6 +200,19 @@ public final class Parameter implements AnnotatedElement {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an AnnotatedType object that represents the use of a type to
|
||||
* specify the type of the formal parameter represented by this Parameter.
|
||||
*
|
||||
* @return an {@code AnnotatedType} object representing the use of a type
|
||||
* to specify the type of the formal parameter represented by this
|
||||
* Parameter
|
||||
*/
|
||||
public AnnotatedType getAnnotatedType() {
|
||||
// no caching for now
|
||||
return executable.getAnnotatedParameterTypes()[index];
|
||||
}
|
||||
|
||||
private transient volatile Class<?> parameterClassCache = null;
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,7 @@ import java.security.PrivilegedAction;
|
||||
import java.util.Arrays;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.BiFunction;
|
||||
import sun.misc.ProxyGenerator;
|
||||
@ -255,9 +256,13 @@ public class Proxy implements java.io.Serializable {
|
||||
* (typically, a dynamic proxy class) with the specified value
|
||||
* for its invocation handler.
|
||||
*
|
||||
* @param h the invocation handler for this proxy instance
|
||||
* @param h the invocation handler for this proxy instance
|
||||
*
|
||||
* @throws NullPointerException if the given invocation handler, {@code h},
|
||||
* is {@code null}.
|
||||
*/
|
||||
protected Proxy(InvocationHandler h) {
|
||||
Objects.requireNonNull(h);
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
@ -698,9 +703,7 @@ public class Proxy implements java.io.Serializable {
|
||||
InvocationHandler h)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
if (h == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
Objects.requireNonNull(h);
|
||||
|
||||
final SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
|
@ -50,6 +50,18 @@ import java.util.Date;
|
||||
* <a href="doc-files/net-properties.html#Proxies">Proxy settings</a> as well as
|
||||
* <a href="doc-files/net-properties.html#MiscHTTP"> various other settings</a>.
|
||||
* </P>
|
||||
* <p>
|
||||
* <b>Security permissions</b>
|
||||
* <p>
|
||||
* If a security manager is installed, and if a method is called which results in an
|
||||
* attempt to open a connection, the caller must possess either:-
|
||||
* <ul><li>a "connect" {@link SocketPermission} to the host/port combination of the
|
||||
* destination URL or</li>
|
||||
* <li>a {@link HttpURLPermission} that permits this request.</li>
|
||||
* </ul><p>
|
||||
* If automatic redirection is enabled, and this request is redirected to another
|
||||
* destination, then the caller must also have permission to connect to the
|
||||
* redirected host/URL.
|
||||
*
|
||||
* @see java.net.HttpURLConnection#disconnect()
|
||||
* @since JDK1.1
|
||||
|
406
jdk/src/share/classes/java/net/HttpURLPermission.java
Normal file
406
jdk/src/share/classes/java/net/HttpURLPermission.java
Normal file
@ -0,0 +1,406 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. 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.ObjectInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.security.Permission;
|
||||
|
||||
/**
|
||||
* Represents permission to access a resource or set of resources defined by a
|
||||
* given http or https url, and for a given set of user-settable request methods
|
||||
* and request headers. The <i>name</i> of the permission is the url string.
|
||||
* The <i>actions</i> string is a concatenation of the request methods and headers.
|
||||
* The range of method and header names is not restricted by this class.
|
||||
* <p><b>The url</b><p>
|
||||
* The url string is also used to instantiate a {@link URI} object which is
|
||||
* used for comparison with other HttpURLPermission instances. Therefore, any
|
||||
* references in this specification to url, mean this URI object.
|
||||
* The path component of the url comprises a sequence of path segments, separated
|
||||
* by '/' characters. The path is specified in a similar way to the path
|
||||
* in {@link java.io.FilePermission}. There are three different ways
|
||||
* as the following examples show:
|
||||
* <table border>
|
||||
* <tr><th>Example url</th><th>Description</th></tr>
|
||||
* <tr><td style="white-space:nowrap;">http://www.oracle.com/a/b/c.html</td>
|
||||
* <td>A url which identifies a specific (single) resource</td>
|
||||
* </tr>
|
||||
* <tr><td>http://www.oracle.com/a/b/*</td>
|
||||
* <td>The '*' character refers to all resources in the same "directory" - in
|
||||
* other words all resources with the same number of path components, and
|
||||
* which only differ in the final path component, represented by the '*'.
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr><td>http://www.oracle.com/a/b/-</li>
|
||||
* <td>The '-' character refers to all resources recursively below the
|
||||
* preceding path (eg. http://www.oracle.com/a/b/c/d/e.html matches this
|
||||
* example).
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* <p>
|
||||
* The '*' and '-' may only be specified in the final segment of a path and must be
|
||||
* the only character in that segment. Any query or fragment components of the
|
||||
* url are ignored when constructing HttpURLPermissions.
|
||||
* <p>
|
||||
* As a special case, urls of the form, "http:*" or "https:*" are accepted to
|
||||
* mean any url of the given scheme.
|
||||
* <p><b>The actions string</b><p>
|
||||
* The actions string of a HttpURLPermission is a concatenation of the <i>method list</i>
|
||||
* and the <i>request headers list</i>. These are lists of the permitted HTTP request
|
||||
* methods and permitted request headers of the permission (respectively). The two lists
|
||||
* are separated by a colon ':' character and elements of each list are comma separated.
|
||||
* Some examples are:
|
||||
* <pre>
|
||||
* "POST,GET,DELETE"
|
||||
* "GET:X-Foo-Request,X-Bar-Request"
|
||||
* "POST,GET:Header1,Header2"
|
||||
* </pre>
|
||||
* The first example specifies the methods: POST, GET and DELETE, but no request headers.
|
||||
* The second example specifies one request method and two headers. The third
|
||||
* example specifies two request methods, and two headers.
|
||||
* <p>
|
||||
* The colon separator need not be present if the request headers list is empty.
|
||||
* No white-space is permitted in the actions string. The action strings supplied to
|
||||
* the HttpURLPermission constructors are case-insensitive and are normalized by converting
|
||||
* method names to upper-case and header names to the form defines in RFC2616 (lower case
|
||||
* with initial letter of each word capitalized). Either list can contain a wild-card '*'
|
||||
* character which signifies all request methods or headers respectively.
|
||||
* <p>
|
||||
* Note. Depending on the context of use, some request methods and headers may be permitted
|
||||
* at all times, and others may not be permitted at any time. For example, the
|
||||
* HTTP protocol handler might disallow certain headers such as Content-Length
|
||||
* from being set by application code, regardless of whether the security policy
|
||||
* in force, permits it.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public final class HttpURLPermission extends Permission {
|
||||
|
||||
private static final long serialVersionUID = -2702463814894478682L;
|
||||
|
||||
private transient URI uri;
|
||||
private transient List<String> methods;
|
||||
private transient List<String> requestHeaders;
|
||||
|
||||
// serialized field
|
||||
private String actions;
|
||||
|
||||
/**
|
||||
* Creates a new HttpURLPermission from a url string and which permits the given
|
||||
* request methods and user-settable request headers.
|
||||
* The name of the permission is its url string. Only the scheme, authority
|
||||
* and path components of the url are used. Any fragment or query
|
||||
* components are ignored. The permissions action string is as specified above.
|
||||
*
|
||||
* @param url the url string
|
||||
*
|
||||
* @param actions the actions string
|
||||
*
|
||||
* @throws IllegalArgumentException if url does not result in a valid {@link URI},
|
||||
* its scheme is not http or https, or if actions contains white-space.
|
||||
*/
|
||||
public HttpURLPermission(String url, String actions) {
|
||||
super(url);
|
||||
init(actions);
|
||||
}
|
||||
|
||||
private void init(String actions) {
|
||||
URI uri = parseURI(getName());
|
||||
int colon = actions.indexOf(':');
|
||||
if (actions.lastIndexOf(':') != colon) {
|
||||
throw new IllegalArgumentException("invalid actions string");
|
||||
}
|
||||
|
||||
String methods, headers;
|
||||
if (colon == -1) {
|
||||
methods = actions;
|
||||
headers = "";
|
||||
} else {
|
||||
methods = actions.substring(0, colon);
|
||||
headers = actions.substring(colon+1);
|
||||
}
|
||||
|
||||
List<String> l = normalizeMethods(methods);
|
||||
Collections.sort(l);
|
||||
this.methods = Collections.unmodifiableList(l);
|
||||
|
||||
l = normalizeHeaders(headers);
|
||||
Collections.sort(l);
|
||||
this.requestHeaders = Collections.unmodifiableList(l);
|
||||
|
||||
this.actions = actions();
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a HttpURLPermission with the given url string and unrestricted
|
||||
* methods and request headers by invoking the two argument
|
||||
* constructor as follows: HttpURLPermission(url, "*:*")
|
||||
*
|
||||
* @throws IllegalArgumentException if url does not result in a valid {@link URI}
|
||||
*/
|
||||
public HttpURLPermission(String url) {
|
||||
this(url, "*:*");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the normalized method list and request
|
||||
* header list, in the form:
|
||||
* <pre>
|
||||
* "method-names : header-names"
|
||||
* </pre>
|
||||
* <p>
|
||||
* where method-names is the list of methods separated by commas
|
||||
* and header-names is the list of permitted headers separated by commas.
|
||||
* There is no white space in the returned String. If header-names is empty
|
||||
* then the colon separator will not be present.
|
||||
*/
|
||||
public String getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this HttpURLPermission implies the given permission.
|
||||
* Specifically, the following checks are done as if in the
|
||||
* following sequence:
|
||||
* <p><ul>
|
||||
* <li>if 'p' is not an instance of HttpURLPermission return false</li>
|
||||
* <li>if any of p's methods are not in this's method list, and if
|
||||
* this's method list is not equal to "*", then return false.</li>
|
||||
* <li>if any of p's headers are not in this's request header list, and if
|
||||
* this's request header list is not equal to "*", then return false.</li>
|
||||
* <li>if this's url is equal to p's url , then return true</li>
|
||||
* <li>if this's url scheme is not equal to p's url scheme return false</li>
|
||||
* <li>if the scheme specific part of this's url is '*' return true</li>
|
||||
* <li>if this's url authority is not equal to p's url authority
|
||||
* return false</li>
|
||||
* <li>if the path or paths specified by p's url are contained in the
|
||||
* set of paths specified by this's url, then return true
|
||||
* <li>otherwise, return false</li>
|
||||
* </ol>
|
||||
* <p>
|
||||
* Some examples of how paths are matched are shown below:
|
||||
* <p>
|
||||
* <table border>
|
||||
* <tr><th>this's path</th><th>p's path</th><th>match</th></tr>
|
||||
* <tr><td>/a/b</td><td>/a/b</td><td>yes</td></tr>
|
||||
* <tr><td>/a/b/*</td><td>/a/b/c</td><td>yes</td></tr>
|
||||
* <tr><td>/a/b/*</td><td>/a/b/c/d</td><td>no</td></tr>
|
||||
* <tr><td>/a/b/-</td><td>/a/b/c/d</td><td>yes</td></tr>
|
||||
* <tr><td>/a/b/-</td><td>/a/b/c/d/e</td><td>yes</td></tr>
|
||||
* <tr><td>/a/b/-</td><td>/a/b/c/*</td><td>yes</td></tr>
|
||||
* <tr><td>/a/b/*</td><td>/a/b/c/-</td><td>no</td></tr>
|
||||
* </table>
|
||||
*/
|
||||
public boolean implies(Permission p) {
|
||||
if (! (p instanceof HttpURLPermission)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HttpURLPermission that = (HttpURLPermission)p;
|
||||
|
||||
if (!this.methods.get(0).equals("*") &&
|
||||
Collections.indexOfSubList(this.methods, that.methods) == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.requestHeaders.isEmpty() && !that.requestHeaders.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.requestHeaders.isEmpty() &&
|
||||
!this.requestHeaders.get(0).equals("*") &&
|
||||
Collections.indexOfSubList(this.requestHeaders,
|
||||
that.requestHeaders) == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.uri.equals(that.uri)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this.uri.getScheme().equals(that.uri.getScheme())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.uri.getSchemeSpecificPart().equals("*")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String thisAuthority = this.uri.getAuthority();
|
||||
|
||||
if (thisAuthority != null &&
|
||||
!thisAuthority.equals(that.uri.getAuthority())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String thispath = this.uri.getPath();
|
||||
String thatpath = that.uri.getPath();
|
||||
|
||||
if (thispath.endsWith("/-")) {
|
||||
String thisprefix = thispath.substring(0, thispath.length() - 1);
|
||||
return thatpath.startsWith(thisprefix);
|
||||
}
|
||||
|
||||
if (thispath.endsWith("/*")) {
|
||||
String thisprefix = thispath.substring(0, thispath.length() - 1);
|
||||
if (!thatpath.startsWith(thisprefix)) {
|
||||
return false;
|
||||
}
|
||||
String thatsuffix = thatpath.substring(thisprefix.length());
|
||||
// suffix must not contain '/' chars
|
||||
if (thatsuffix.indexOf('/') != -1) {
|
||||
return false;
|
||||
}
|
||||
if (thatsuffix.equals("-")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if, this.getActions().equals(p.getActions())
|
||||
* and p's url equals this's url. Returns false otherwise.
|
||||
*/
|
||||
public boolean equals(Object p) {
|
||||
if (!(p instanceof HttpURLPermission)) {
|
||||
return false;
|
||||
}
|
||||
HttpURLPermission that = (HttpURLPermission)p;
|
||||
return this.getActions().equals(that.getActions()) &&
|
||||
this.uri.equals(that.uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode calculated from the hashcode of the
|
||||
* actions String and the url
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getActions().hashCode() + uri.hashCode();
|
||||
}
|
||||
|
||||
|
||||
private List<String> normalizeMethods(String methods) {
|
||||
List<String> l = new ArrayList<>();
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (int i=0; i<methods.length(); i++) {
|
||||
char c = methods.charAt(i);
|
||||
if (c == ',') {
|
||||
String s = b.toString();
|
||||
if (s.length() > 0)
|
||||
l.add(s);
|
||||
b = new StringBuilder();
|
||||
} else if (c == ' ' || c == '\t') {
|
||||
throw new IllegalArgumentException("white space not allowed");
|
||||
} else {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
c += 'A' - 'a';
|
||||
}
|
||||
b.append(c);
|
||||
}
|
||||
}
|
||||
String s = b.toString();
|
||||
if (s.length() > 0)
|
||||
l.add(s);
|
||||
return l;
|
||||
}
|
||||
|
||||
private List<String> normalizeHeaders(String headers) {
|
||||
List<String> l = new ArrayList<>();
|
||||
StringBuilder b = new StringBuilder();
|
||||
boolean capitalizeNext = true;
|
||||
for (int i=0; i<headers.length(); i++) {
|
||||
char c = headers.charAt(i);
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
if (capitalizeNext) {
|
||||
c += 'A' - 'a';
|
||||
capitalizeNext = false;
|
||||
}
|
||||
b.append(c);
|
||||
} else if (c == ' ' || c == '\t') {
|
||||
throw new IllegalArgumentException("white space not allowed");
|
||||
} else if (c == '-') {
|
||||
capitalizeNext = true;
|
||||
b.append(c);
|
||||
} else if (c == ',') {
|
||||
String s = b.toString();
|
||||
if (s.length() > 0)
|
||||
l.add(s);
|
||||
b = new StringBuilder();
|
||||
capitalizeNext = true;
|
||||
} else {
|
||||
capitalizeNext = false;
|
||||
b.append(c);
|
||||
}
|
||||
}
|
||||
String s = b.toString();
|
||||
if (s.length() > 0)
|
||||
l.add(s);
|
||||
return l;
|
||||
}
|
||||
|
||||
private URI parseURI(String url) {
|
||||
URI u = URI.create(url);
|
||||
String scheme = u.getScheme();
|
||||
if (!(scheme.equalsIgnoreCase("http") ||
|
||||
scheme.equalsIgnoreCase("https"))) {
|
||||
throw new IllegalArgumentException ("unexpected URL scheme");
|
||||
}
|
||||
if (!u.getSchemeSpecificPart().equals("*")) {
|
||||
u = URI.create(scheme + "://" + u.getAuthority() + u.getPath());
|
||||
}
|
||||
return u;
|
||||
}
|
||||
|
||||
private String actions() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (String s : methods) {
|
||||
b.append(s);
|
||||
}
|
||||
b.append(":");
|
||||
for (String s : requestHeaders) {
|
||||
b.append(s);
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
/**
|
||||
* restore the state of this object from stream
|
||||
*/
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws IOException, ClassNotFoundException {
|
||||
ObjectInputStream.GetField fields = s.readFields();
|
||||
String actions = (String)fields.get("actions", null);
|
||||
|
||||
init(actions);
|
||||
}
|
||||
}
|
@ -607,9 +607,9 @@ class ServerSocket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable SO_TIMEOUT with the specified timeout, in
|
||||
* milliseconds. With this option set to a non-zero timeout,
|
||||
* a call to accept() for this ServerSocket
|
||||
* Enable/disable {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT} with the
|
||||
* specified timeout, in milliseconds. With this option set to a non-zero
|
||||
* timeout, a call to accept() for this ServerSocket
|
||||
* will block for only this amount of time. If the timeout expires,
|
||||
* a <B>java.net.SocketTimeoutException</B> is raised, though the
|
||||
* ServerSocket is still valid. The option <B>must</B> be enabled
|
||||
@ -629,9 +629,9 @@ class ServerSocket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve setting for SO_TIMEOUT. 0 returns implies that the
|
||||
* option is disabled (i.e., timeout of infinity).
|
||||
* @return the SO_TIMEOUT value
|
||||
* Retrieve setting for {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT}.
|
||||
* 0 returns implies that the option is disabled (i.e., timeout of infinity).
|
||||
* @return the {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT} value
|
||||
* @exception IOException if an I/O error occurs
|
||||
* @since JDK1.1
|
||||
* @see #setSoTimeout(int)
|
||||
@ -649,7 +649,8 @@ class ServerSocket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable the SO_REUSEADDR socket option.
|
||||
* Enable/disable the {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR}
|
||||
* socket option.
|
||||
* <p>
|
||||
* When a TCP connection is closed the connection may remain
|
||||
* in a timeout state for a period of time after the connection
|
||||
@ -660,24 +661,23 @@ class ServerSocket implements java.io.Closeable {
|
||||
* <tt>SocketAddress</tt> if there is a connection in the
|
||||
* timeout state involving the socket address or port.
|
||||
* <p>
|
||||
* Enabling <tt>SO_REUSEADDR</tt> prior to binding the socket
|
||||
* using {@link #bind(SocketAddress)} allows the socket to be
|
||||
* bound even though a previous connection is in a timeout
|
||||
* state.
|
||||
* Enabling {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} prior to
|
||||
* binding the socket using {@link #bind(SocketAddress)} allows the socket
|
||||
* to be bound even though a previous connection is in a timeout state.
|
||||
* <p>
|
||||
* When a <tt>ServerSocket</tt> is created the initial setting
|
||||
* of <tt>SO_REUSEADDR</tt> is not defined. Applications can
|
||||
* use {@link #getReuseAddress()} to determine the initial
|
||||
* setting of <tt>SO_REUSEADDR</tt>.
|
||||
* of {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is not defined.
|
||||
* Applications can use {@link #getReuseAddress()} to determine the initial
|
||||
* setting of {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR}.
|
||||
* <p>
|
||||
* The behaviour when <tt>SO_REUSEADDR</tt> is enabled or
|
||||
* disabled after a socket is bound (See {@link #isBound()})
|
||||
* The behaviour when {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is
|
||||
* enabled or disabled after a socket is bound (See {@link #isBound()})
|
||||
* is not defined.
|
||||
*
|
||||
* @param on whether to enable or disable the socket option
|
||||
* @exception SocketException if an error occurs enabling or
|
||||
* disabling the <tt>SO_RESUEADDR</tt> socket option,
|
||||
* or the socket is closed.
|
||||
* disabling the {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR}
|
||||
* socket option, or the socket is closed.
|
||||
* @since 1.4
|
||||
* @see #getReuseAddress()
|
||||
* @see #bind(SocketAddress)
|
||||
@ -691,9 +691,10 @@ class ServerSocket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if SO_REUSEADDR is enabled.
|
||||
* Tests if {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is enabled.
|
||||
*
|
||||
* @return a <code>boolean</code> indicating whether or not SO_REUSEADDR is enabled.
|
||||
* @return a <code>boolean</code> indicating whether or not
|
||||
* {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is enabled.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @since 1.4
|
||||
@ -768,15 +769,16 @@ class ServerSocket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a default proposed value for the SO_RCVBUF option for sockets
|
||||
* Sets a default proposed value for the
|
||||
* {@link SocketOptions#SO_RCVBUF SO_RCVBUF} option for sockets
|
||||
* accepted from this <tt>ServerSocket</tt>. The value actually set
|
||||
* in the accepted socket must be determined by calling
|
||||
* {@link Socket#getReceiveBufferSize()} after the socket
|
||||
* is returned by {@link #accept()}.
|
||||
* <p>
|
||||
* The value of SO_RCVBUF is used both to set the size of the internal
|
||||
* socket receive buffer, and to set the size of the TCP receive window
|
||||
* that is advertized to the remote peer.
|
||||
* The value of {@link SocketOptions#SO_RCVBUF SO_RCVBUF} is used both to
|
||||
* set the size of the internal socket receive buffer, and to set the size
|
||||
* of the TCP receive window that is advertized to the remote peer.
|
||||
* <p>
|
||||
* It is possible to change the value subsequently, by calling
|
||||
* {@link Socket#setReceiveBufferSize(int)}. However, if the application
|
||||
@ -812,15 +814,16 @@ class ServerSocket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the SO_RCVBUF option for this <tt>ServerSocket</tt>,
|
||||
* that is the proposed buffer size that will be used for Sockets accepted
|
||||
* from this <tt>ServerSocket</tt>.
|
||||
* Gets the value of the {@link SocketOptions#SO_RCVBUF SO_RCVBUF} option
|
||||
* for this <tt>ServerSocket</tt>, that is the proposed buffer size that
|
||||
* will be used for Sockets accepted from this <tt>ServerSocket</tt>.
|
||||
*
|
||||
* <p>Note, the value actually set in the accepted socket is determined by
|
||||
* calling {@link Socket#getReceiveBufferSize()}.
|
||||
* @return the value of the SO_RCVBUF option for this <tt>Socket</tt>.
|
||||
* @return the value of the {@link SocketOptions#SO_RCVBUF SO_RCVBUF}
|
||||
* option for this <tt>Socket</tt>.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @see #setReceiveBufferSize(int)
|
||||
* @since 1.4
|
||||
*/
|
||||
|
@ -924,7 +924,8 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
|
||||
* Enable/disable {@link SocketOptions#TCP_NODELAY TCP_NODELAY}
|
||||
* (disable/enable Nagle's algorithm).
|
||||
*
|
||||
* @param on <code>true</code> to enable TCP_NODELAY,
|
||||
* <code>false</code> to disable.
|
||||
@ -943,9 +944,10 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if TCP_NODELAY is enabled.
|
||||
* Tests if {@link SocketOptions#TCP_NODELAY TCP_NODELAY} is enabled.
|
||||
*
|
||||
* @return a <code>boolean</code> indicating whether or not TCP_NODELAY is enabled.
|
||||
* @return a <code>boolean</code> indicating whether or not
|
||||
* {@link SocketOptions#TCP_NODELAY TCP_NODELAY} is enabled.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @since JDK1.1
|
||||
@ -958,8 +960,9 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable SO_LINGER with the specified linger time in seconds.
|
||||
* The maximum timeout value is platform specific.
|
||||
* Enable/disable {@link SocketOptions#SO_LINGER SO_LINGER} with the
|
||||
* specified linger time in seconds. The maximum timeout value is platform
|
||||
* specific.
|
||||
*
|
||||
* The setting only affects socket close.
|
||||
*
|
||||
@ -987,12 +990,13 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns setting for SO_LINGER. -1 returns implies that the
|
||||
* Returns setting for {@link SocketOptions#SO_LINGER SO_LINGER}.
|
||||
* -1 returns implies that the
|
||||
* option is disabled.
|
||||
*
|
||||
* The setting only affects socket close.
|
||||
*
|
||||
* @return the setting for SO_LINGER.
|
||||
* @return the setting for {@link SocketOptions#SO_LINGER SO_LINGER}.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @since JDK1.1
|
||||
@ -1027,7 +1031,8 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable OOBINLINE (receipt of TCP urgent data)
|
||||
* Enable/disable {@link SocketOptions#SO_OOBINLINE SO_OOBINLINE}
|
||||
* (receipt of TCP urgent data)
|
||||
*
|
||||
* By default, this option is disabled and TCP urgent data received on a
|
||||
* socket is silently discarded. If the user wishes to receive urgent data, then
|
||||
@ -1039,8 +1044,9 @@ class Socket implements java.io.Closeable {
|
||||
* and there is no capability to distinguish between normal data and urgent
|
||||
* data unless provided by a higher level protocol.
|
||||
*
|
||||
* @param on <code>true</code> to enable OOBINLINE,
|
||||
* <code>false</code> to disable.
|
||||
* @param on <code>true</code> to enable
|
||||
* {@link SocketOptions#SO_OOBINLINE SO_OOBINLINE},
|
||||
* <code>false</code> to disable.
|
||||
*
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
@ -1056,9 +1062,11 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if OOBINLINE is enabled.
|
||||
* Tests if {@link SocketOptions#SO_OOBINLINE SO_OOBINLINE} is enabled.
|
||||
*
|
||||
* @return a <code>boolean</code> indicating whether or not
|
||||
* {@link SocketOptions#SO_OOBINLINE SO_OOBINLINE}is enabled.
|
||||
*
|
||||
* @return a <code>boolean</code> indicating whether or not OOBINLINE is enabled.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @since 1.4
|
||||
@ -1071,15 +1079,16 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable SO_TIMEOUT with the specified timeout, in
|
||||
* milliseconds. With this option set to a non-zero timeout,
|
||||
* a read() call on the InputStream associated with this Socket
|
||||
* will block for only this amount of time. If the timeout expires,
|
||||
* a <B>java.net.SocketTimeoutException</B> is raised, though the
|
||||
* Enable/disable {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT}
|
||||
* with the specified timeout, in milliseconds. With this option set
|
||||
* to a non-zero timeout, a read() call on the InputStream associated with
|
||||
* this Socket will block for only this amount of time. If the timeout
|
||||
* expires, a <B>java.net.SocketTimeoutException</B> is raised, though the
|
||||
* Socket is still valid. The option <B>must</B> be enabled
|
||||
* prior to entering the blocking operation to have effect. The
|
||||
* timeout must be > 0.
|
||||
* A timeout of zero is interpreted as an infinite timeout.
|
||||
*
|
||||
* @param timeout the specified timeout, in milliseconds.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
@ -1096,11 +1105,13 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns setting for SO_TIMEOUT. 0 returns implies that the
|
||||
* option is disabled (i.e., timeout of infinity).
|
||||
* @return the setting for SO_TIMEOUT
|
||||
* Returns setting for {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT}.
|
||||
* 0 returns implies that the option is disabled (i.e., timeout of infinity).
|
||||
*
|
||||
* @return the setting for {@link SocketOptions#SO_TIMEOUT SO_TIMEOUT}
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
*
|
||||
* @since JDK1.1
|
||||
* @see #setSoTimeout(int)
|
||||
*/
|
||||
@ -1117,14 +1128,15 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SO_SNDBUF option to the specified value for this
|
||||
* <tt>Socket</tt>. The SO_SNDBUF option is used by the platform's
|
||||
* networking code as a hint for the size to set
|
||||
* the underlying network I/O buffers.
|
||||
* Sets the {@link SocketOptions#SO_SNDBUF SO_SNDBUF} option to the
|
||||
* specified value for this <tt>Socket</tt>.
|
||||
* The {@link SocketOptions#SO_SNDBUF SO_SNDBUF} option is used by the
|
||||
* platform's networking code as a hint for the size to set the underlying
|
||||
* network I/O buffers.
|
||||
*
|
||||
* <p>Because SO_SNDBUF is a hint, applications that want to
|
||||
* verify what size the buffers were set to should call
|
||||
* {@link #getSendBufferSize()}.
|
||||
* <p>Because {@link SocketOptions#SO_SNDBUF SO_SNDBUF} is a hint,
|
||||
* applications that want to verify what size the buffers were set to
|
||||
* should call {@link #getSendBufferSize()}.
|
||||
*
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
@ -1149,10 +1161,11 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value of the SO_SNDBUF option for this <tt>Socket</tt>,
|
||||
* that is the buffer size used by the platform
|
||||
* Get value of the {@link SocketOptions#SO_SNDBUF SO_SNDBUF} option
|
||||
* for this <tt>Socket</tt>, that is the buffer size used by the platform
|
||||
* for output on this <tt>Socket</tt>.
|
||||
* @return the value of the SO_SNDBUF option for this <tt>Socket</tt>.
|
||||
* @return the value of the {@link SocketOptions#SO_SNDBUF SO_SNDBUF}
|
||||
* option for this <tt>Socket</tt>.
|
||||
*
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
@ -1172,25 +1185,26 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SO_RCVBUF option to the specified value for this
|
||||
* <tt>Socket</tt>. The SO_RCVBUF option is used by the platform's
|
||||
* networking code as a hint for the size to set
|
||||
* Sets the {@link SocketOptions#SO_RCVBUF SO_RCVBUF} option to the
|
||||
* specified value for this <tt>Socket</tt>. The
|
||||
* {@link SocketOptions#SO_RCVBUF SO_RCVBUF} option is
|
||||
* used by the platform's networking code as a hint for the size to set
|
||||
* the underlying network I/O buffers.
|
||||
*
|
||||
* <p>Increasing the receive buffer size can increase the performance of
|
||||
* network I/O for high-volume connection, while decreasing it can
|
||||
* help reduce the backlog of incoming data.
|
||||
*
|
||||
* <p>Because SO_RCVBUF is a hint, applications that want to
|
||||
* verify what size the buffers were set to should call
|
||||
* {@link #getReceiveBufferSize()}.
|
||||
* <p>Because {@link SocketOptions#SO_RCVBUF SO_RCVBUF} is a hint,
|
||||
* applications that want to verify what size the buffers were set to
|
||||
* should call {@link #getReceiveBufferSize()}.
|
||||
*
|
||||
* <p>The value of SO_RCVBUF is also used to set the TCP receive window
|
||||
* that is advertized to the remote peer. Generally, the window size
|
||||
* can be modified at any time when a socket is connected. However, if
|
||||
* a receive window larger than 64K is required then this must be requested
|
||||
* <B>before</B> the socket is connected to the remote peer. There are two
|
||||
* cases to be aware of:<p>
|
||||
* <p>The value of {@link SocketOptions#SO_RCVBUF SO_RCVBUF} is also used
|
||||
* to set the TCP receive window that is advertized to the remote peer.
|
||||
* Generally, the window size can be modified at any time when a socket is
|
||||
* connected. However, if a receive window larger than 64K is required then
|
||||
* this must be requested <B>before</B> the socket is connected to the
|
||||
* remote peer. There are two cases to be aware of:<p>
|
||||
* <ol>
|
||||
* <li>For sockets accepted from a ServerSocket, this must be done by calling
|
||||
* {@link ServerSocket#setReceiveBufferSize(int)} before the ServerSocket
|
||||
@ -1221,11 +1235,12 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the SO_RCVBUF option for this <tt>Socket</tt>,
|
||||
* that is the buffer size used by the platform for
|
||||
* input on this <tt>Socket</tt>.
|
||||
* Gets the value of the {@link SocketOptions#SO_RCVBUF SO_RCVBUF} option
|
||||
* for this <tt>Socket</tt>, that is the buffer size used by the platform
|
||||
* for input on this <tt>Socket</tt>.
|
||||
*
|
||||
* @return the value of the SO_RCVBUF option for this <tt>Socket</tt>.
|
||||
* @return the value of the {@link SocketOptions#SO_RCVBUF SO_RCVBUF}
|
||||
* option for this <tt>Socket</tt>.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @see #setReceiveBufferSize(int)
|
||||
@ -1244,9 +1259,9 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable SO_KEEPALIVE.
|
||||
* Enable/disable {@link SocketOptions#SO_KEEPALIVE SO_KEEPALIVE}.
|
||||
*
|
||||
* @param on whether or not to have socket keep alive turned on.
|
||||
* @param on whether or not to have socket keep alive turned on.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @since 1.3
|
||||
@ -1259,9 +1274,10 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if SO_KEEPALIVE is enabled.
|
||||
* Tests if {@link SocketOptions#SO_KEEPALIVE SO_KEEPALIVE} is enabled.
|
||||
*
|
||||
* @return a <code>boolean</code> indicating whether or not SO_KEEPALIVE is enabled.
|
||||
* @return a <code>boolean</code> indicating whether or not
|
||||
* {@link SocketOptions#SO_KEEPALIVE SO_KEEPALIVE} is enabled.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @since 1.3
|
||||
@ -1317,6 +1333,7 @@ class Socket implements java.io.Closeable {
|
||||
* traffic class or type-of-service
|
||||
* @since 1.4
|
||||
* @see #getTrafficClass
|
||||
* @see SocketOptions#IP_TOS
|
||||
*/
|
||||
public void setTrafficClass(int tc) throws SocketException {
|
||||
if (tc < 0 || tc > 255)
|
||||
@ -1341,13 +1358,15 @@ class Socket implements java.io.Closeable {
|
||||
* traffic class or type-of-service value.
|
||||
* @since 1.4
|
||||
* @see #setTrafficClass(int)
|
||||
* @see SocketOptions#IP_TOS
|
||||
*/
|
||||
public int getTrafficClass() throws SocketException {
|
||||
return ((Integer) (getImpl().getOption(SocketOptions.IP_TOS))).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable the SO_REUSEADDR socket option.
|
||||
* Enable/disable the {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR}
|
||||
* socket option.
|
||||
* <p>
|
||||
* When a TCP connection is closed the connection may remain
|
||||
* in a timeout state for a period of time after the connection
|
||||
@ -1358,22 +1377,22 @@ class Socket implements java.io.Closeable {
|
||||
* <tt>SocketAddress</tt> if there is a connection in the
|
||||
* timeout state involving the socket address or port.
|
||||
* <p>
|
||||
* Enabling <tt>SO_REUSEADDR</tt> prior to binding the socket
|
||||
* using {@link #bind(SocketAddress)} allows the socket to be
|
||||
* bound even though a previous connection is in a timeout
|
||||
* Enabling {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR}
|
||||
* prior to binding the socket using {@link #bind(SocketAddress)} allows
|
||||
* the socket to be bound even though a previous connection is in a timeout
|
||||
* state.
|
||||
* <p>
|
||||
* When a <tt>Socket</tt> is created the initial setting
|
||||
* of <tt>SO_REUSEADDR</tt> is disabled.
|
||||
* of {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is disabled.
|
||||
* <p>
|
||||
* The behaviour when <tt>SO_REUSEADDR</tt> is enabled or
|
||||
* disabled after a socket is bound (See {@link #isBound()})
|
||||
* The behaviour when {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is
|
||||
* enabled or disabled after a socket is bound (See {@link #isBound()})
|
||||
* is not defined.
|
||||
*
|
||||
* @param on whether to enable or disable the socket option
|
||||
* @exception SocketException if an error occurs enabling or
|
||||
* disabling the <tt>SO_RESUEADDR</tt> socket option,
|
||||
* or the socket is closed.
|
||||
* disabling the {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR}
|
||||
* socket option, or the socket is closed.
|
||||
* @since 1.4
|
||||
* @see #getReuseAddress()
|
||||
* @see #bind(SocketAddress)
|
||||
@ -1387,9 +1406,10 @@ class Socket implements java.io.Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if SO_REUSEADDR is enabled.
|
||||
* Tests if {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is enabled.
|
||||
*
|
||||
* @return a <code>boolean</code> indicating whether or not SO_REUSEADDR is enabled.
|
||||
* @return a <code>boolean</code> indicating whether or not
|
||||
* {@link SocketOptions#SO_REUSEADDR SO_REUSEADDR} is enabled.
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
* @since 1.4
|
||||
|
@ -427,46 +427,38 @@ public abstract class Charset
|
||||
}
|
||||
|
||||
/* The extended set of charsets */
|
||||
private static Object extendedProviderLock = new Object();
|
||||
private static boolean extendedProviderProbed = false;
|
||||
private static CharsetProvider extendedProvider = null;
|
||||
|
||||
private static void probeExtendedProvider() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
try {
|
||||
Class<?> epc
|
||||
= Class.forName("sun.nio.cs.ext.ExtendedCharsets");
|
||||
extendedProvider = (CharsetProvider)epc.newInstance();
|
||||
} catch (ClassNotFoundException x) {
|
||||
// Extended charsets not available
|
||||
// (charsets.jar not present)
|
||||
} catch (InstantiationException x) {
|
||||
throw new Error(x);
|
||||
} catch (IllegalAccessException x) {
|
||||
throw new Error(x);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
private static class ExtendedProviderHolder {
|
||||
static final CharsetProvider extendedProvider = extendedProvider();
|
||||
// returns ExtendedProvider, if installed
|
||||
private static CharsetProvider extendedProvider() {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<CharsetProvider>() {
|
||||
public CharsetProvider run() {
|
||||
try {
|
||||
Class<?> epc
|
||||
= Class.forName("sun.nio.cs.ext.ExtendedCharsets");
|
||||
return (CharsetProvider)epc.newInstance();
|
||||
} catch (ClassNotFoundException x) {
|
||||
// Extended charsets not available
|
||||
// (charsets.jar not present)
|
||||
} catch (InstantiationException |
|
||||
IllegalAccessException x) {
|
||||
throw new Error(x);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static Charset lookupExtendedCharset(String charsetName) {
|
||||
CharsetProvider ecp = null;
|
||||
synchronized (extendedProviderLock) {
|
||||
if (!extendedProviderProbed) {
|
||||
probeExtendedProvider();
|
||||
extendedProviderProbed = true;
|
||||
}
|
||||
ecp = extendedProvider;
|
||||
}
|
||||
CharsetProvider ecp = ExtendedProviderHolder.extendedProvider;
|
||||
return (ecp != null) ? ecp.charsetForName(charsetName) : null;
|
||||
}
|
||||
|
||||
private static Charset lookup(String charsetName) {
|
||||
if (charsetName == null)
|
||||
throw new IllegalArgumentException("Null charset name");
|
||||
|
||||
Object[] a;
|
||||
if ((a = cache1) != null && charsetName.equals(a[0]))
|
||||
return (Charset)a[1];
|
||||
@ -483,7 +475,6 @@ public abstract class Charset
|
||||
cache1 = a;
|
||||
return (Charset)a[1];
|
||||
}
|
||||
|
||||
Charset cs;
|
||||
if ((cs = standardProvider.charsetForName(charsetName)) != null ||
|
||||
(cs = lookupExtendedCharset(charsetName)) != null ||
|
||||
@ -589,6 +580,9 @@ public abstract class Charset
|
||||
new TreeMap<String,Charset>(
|
||||
ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
|
||||
put(standardProvider.charsets(), m);
|
||||
CharsetProvider ecp = ExtendedProviderHolder.extendedProvider;
|
||||
if (ecp != null)
|
||||
put(ecp.charsets(), m);
|
||||
for (Iterator<CharsetProvider> i = providers(); i.hasNext();) {
|
||||
CharsetProvider cp = i.next();
|
||||
put(cp.charsets(), m);
|
||||
|
@ -103,7 +103,7 @@ import java.util.TimeZone;
|
||||
* system clock This may use {@link System#currentTimeMillis()}, or a higher
|
||||
* resolution clock if one is available.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This abstract class must be implemented with care to ensure other operate correctly.
|
||||
* All implementations that can be instantiated must be final, immutable and thread-safe.
|
||||
* <p>
|
||||
@ -112,13 +112,23 @@ import java.util.TimeZone;
|
||||
* obtain the time from a central time server across the network. Obviously, in this case the
|
||||
* lookup could fail, and so the method is permitted to throw an exception.
|
||||
* <p>
|
||||
* The returned instants from {@code Clock} work on a time-scale that ignores leap seconds.
|
||||
* If the implementation wraps a source that provides leap second information, then a mechanism
|
||||
* should be used to "smooth" the leap second, such as UTC-SLS.
|
||||
* The returned instants from {@code Clock} work on a time-scale that ignores leap seconds,
|
||||
* as described in {@link Instant}. If the implementation wraps a source that provides leap
|
||||
* second information, then a mechanism should be used to "smooth" the leap second.
|
||||
* The Java Time-Scale mandates the use of UTC-SLS, however clock implementations may choose
|
||||
* how accurate they are with the time-scale so long as they document how they work.
|
||||
* Implementations are therefore not required to actually perform the UTC-SLS slew or to
|
||||
* otherwise be aware of leap seconds.
|
||||
* <p>
|
||||
* Implementations should implement {@code Serializable} wherever possible and must
|
||||
* document whether or not they do support serialization.
|
||||
*
|
||||
* @implNote
|
||||
* The clock implementation provided here is based on {@link System#currentTimeMillis()}.
|
||||
* That method provides little to no guarantee about the accuracy of the clock.
|
||||
* Applications requiring a more accurate clock must implement this abstract class
|
||||
* themselves using a different external clock, such as an NTP server.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public abstract class Clock {
|
||||
@ -370,7 +380,7 @@ public abstract class Clock {
|
||||
/**
|
||||
* Gets the current millisecond instant of the clock.
|
||||
* <p>
|
||||
* This returns the millisecond-based instant, measured from 1970-01-01T00:00 UTC.
|
||||
* This returns the millisecond-based instant, measured from 1970-01-01T00:00Z (UTC).
|
||||
* This is equivalent to the definition of {@link System#currentTimeMillis()}.
|
||||
* <p>
|
||||
* Most applications should avoid this method and use {@link Instant} to represent
|
||||
@ -381,7 +391,7 @@ public abstract class Clock {
|
||||
* The default implementation currently calls {@link #instant}.
|
||||
*
|
||||
* @return the current millisecond instant from this clock, measured from
|
||||
* the Java epoch of 1970-01-01T00:00 UTC, not null
|
||||
* the Java epoch of 1970-01-01T00:00Z (UTC), not null
|
||||
* @throws DateTimeException if the instant cannot be obtained, not thrown by most implementations
|
||||
*/
|
||||
public long millis() {
|
||||
|
@ -67,7 +67,7 @@ package java.time;
|
||||
* This exception is used to indicate problems with creating, querying
|
||||
* and manipulating date-time objects.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is intended for use in a single thread.
|
||||
*
|
||||
* @since 1.8
|
||||
|
@ -100,7 +100,7 @@ import java.util.Locale;
|
||||
* As such, this enum may be used by any calendar system that has the day-of-week
|
||||
* concept defined exactly equivalent to the ISO calendar system.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This is an immutable and thread-safe enum.
|
||||
*
|
||||
* @since 1.8
|
||||
|
@ -118,7 +118,7 @@ import java.util.regex.Pattern;
|
||||
* most applications.
|
||||
* See {@link Instant} for a discussion as to the meaning of the second and time-scales.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
|
@ -142,47 +142,60 @@ import java.util.Objects;
|
||||
* introduce other changes.
|
||||
* <p>
|
||||
* Given the complexity of accurate timekeeping described above, this Java API defines
|
||||
* its own time-scale with a simplification. The Java time-scale is defined as follows:
|
||||
* its own time-scale, the <i>Java Time-Scale</i>.
|
||||
* <p>
|
||||
* The Java Time-Scale divides each calendar day into exactly 86400
|
||||
* subdivisions, known as seconds. These seconds may differ from the
|
||||
* SI second. It closely matches the de facto international civil time
|
||||
* scale, the definition of which changes from time to time.
|
||||
* <p>
|
||||
* The Java Time-Scale has slightly different definitions for different
|
||||
* segments of the time-line, each based on the consensus international
|
||||
* time scale that is used as the basis for civil time. Whenever the
|
||||
* internationally-agreed time scale is modified or replaced, a new
|
||||
* segment of the Java Time-Scale must be defined for it. Each segment
|
||||
* must meet these requirements:
|
||||
* <p><ul>
|
||||
* <li>midday will always be exactly as defined by the agreed international civil time</li>
|
||||
* <li>other times during the day will be broadly in line with the agreed international civil time</li>
|
||||
* <li>the day will be divided into exactly 86400 subdivisions, referred to as "seconds"</li>
|
||||
* <li>the Java "second" may differ from an SI second</li>
|
||||
* <li>a well-defined algorithm must be specified to map each second in the accurate agreed
|
||||
* international civil time to each "second" in this time-scale</li>
|
||||
* <li>the Java Time-Scale shall closely match the underlying international
|
||||
* civil time scale;</li>
|
||||
* <li>the Java Time-Scale shall exactly match the international civil
|
||||
* time scale at noon each day;</li>
|
||||
* <li>the Java Time-Scale shall have a precisely-defined relationship to
|
||||
* the international civil time scale.</li>
|
||||
* </ul><p>
|
||||
* Agreed international civil time is the base time-scale agreed by international convention,
|
||||
* which in 2012 is UTC (with leap-seconds).
|
||||
* There are currently, as of 2013, two segments in the Java time-scale.
|
||||
* <p>
|
||||
* In 2012, the definition of the Java time-scale is the same as UTC for all days except
|
||||
* those where a leap-second occurs. On days where a leap-second does occur, the time-scale
|
||||
* effectively eliminates the leap-second, maintaining the fiction of 86400 seconds in the day.
|
||||
* The approved well-defined algorithm to eliminate leap-seconds is specified as
|
||||
* For the segment from 1972-11-03 (exact boundary discussed below) until
|
||||
* further notice, the consensus international time scale is UTC (with
|
||||
* leap seconds). In this segment, the Java Time-Scale is identical to
|
||||
* <a href="http://www.cl.cam.ac.uk/~mgk25/time/utc-sls/">UTC-SLS</a>.
|
||||
* This is identical to UTC on days that do not have a leap second.
|
||||
* On days that do have a leap second, the leap second is spread equally
|
||||
* over the last 1000 seconds of the day, maintaining the appearance of
|
||||
* exactly 86400 seconds per day.
|
||||
* <p>
|
||||
* UTC-SLS is a simple algorithm that smoothes the leap-second over the last 1000 seconds of
|
||||
* the day, making each of the last 1000 seconds 1/1000th longer or shorter than an SI second.
|
||||
* Implementations built on an accurate leap-second aware time source should use UTC-SLS.
|
||||
* Use of a different algorithm risks confusion and misinterpretation of instants around a
|
||||
* leap-second and is discouraged.
|
||||
* For the segment prior to 1972-11-03, extending back arbitrarily far,
|
||||
* the consensus international time scale is defined to be UT1, applied
|
||||
* proleptically, which is equivalent to the (mean) solar time on the
|
||||
* prime meridian (Greenwich). In this segment, the Java Time-Scale is
|
||||
* identical to the consensus international time scale. The exact
|
||||
* boundary between the two segments is the instant where UT1 = UTC
|
||||
* between 1972-11-03T00:00 and 1972-11-04T12:00.
|
||||
* <p>
|
||||
* The main benefit of always dividing the day into 86400 subdivisions is that it matches the
|
||||
* expectations of most users of the API. The alternative is to force every user to understand
|
||||
* what a leap second is and to force them to have special logic to handle them.
|
||||
* Most applications do not have access to a clock that is accurate enough to record leap-seconds.
|
||||
* Most applications also do not have a problem with a second being a very small amount longer or
|
||||
* shorter than a real SI second during a leap-second.
|
||||
* <p>
|
||||
* One final problem is the definition of the agreed international civil time before the
|
||||
* introduction of modern UTC in 1972. This includes the Java epoch of {@code 1970-01-01}.
|
||||
* It is intended that instants before 1972 be interpreted based on the solar day divided
|
||||
* into 86400 subdivisions, as per the principles of UT1.
|
||||
* Implementations of the Java time-scale using the JSR-310 API are not
|
||||
* required to provide any clock that is sub-second accurate, or that
|
||||
* progresses monotonically or smoothly. Implementations are therefore
|
||||
* not required to actually perform the UTC-SLS slew or to otherwise be
|
||||
* aware of leap seconds. JSR-310 does, however, require that
|
||||
* implementations must document the approach they use when defining a
|
||||
* clock representing the current instant.
|
||||
* See {@link Clock} for details on the available clocks.
|
||||
* <p>
|
||||
* The Java time-scale is used for all date-time classes.
|
||||
* This includes {@code Instant}, {@code LocalDate}, {@code LocalTime}, {@code OffsetDateTime},
|
||||
* {@code ZonedDateTime} and {@code Duration}.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
@ -1030,16 +1043,16 @@ public final class Instant
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the period between this instant and another instant in
|
||||
* terms of the specified unit.
|
||||
* Calculates the amount of time until another instant in terms of the specified unit.
|
||||
* <p>
|
||||
* This calculates the period between two instants in terms of a single unit.
|
||||
* This calculates the amount of time between two {@code Instant}
|
||||
* objects in terms of a single {@code TemporalUnit}.
|
||||
* The start and end points are {@code this} and the specified instant.
|
||||
* The result will be negative if the end is before the start.
|
||||
* The calculation returns a whole number, representing the number of
|
||||
* complete units between the two instants.
|
||||
* The {@code Temporal} passed to this method must be an {@code Instant}.
|
||||
* For example, the period in days between two dates can be calculated
|
||||
* For example, the amount in days between two dates can be calculated
|
||||
* using {@code startInstant.periodUntil(endInstant, SECONDS)}.
|
||||
* <p>
|
||||
* There are two equivalent ways of using this method.
|
||||
@ -1064,10 +1077,10 @@ public final class Instant
|
||||
* <p>
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @param endInstant the end date, which must be a {@code LocalDate}, not null
|
||||
* @param unit the unit to measure the period in, not null
|
||||
* @return the amount of the period between this date and the end date
|
||||
* @throws DateTimeException if the period cannot be calculated
|
||||
* @param endInstant the end date, which must be an {@code Instant}, not null
|
||||
* @param unit the unit to measure the amount in, not null
|
||||
* @return the amount of time between this instant and the end instant
|
||||
* @throws DateTimeException if the amount cannot be calculated
|
||||
* @throws UnsupportedTemporalTypeException if the unit is not supported
|
||||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
@ -1075,7 +1088,7 @@ public final class Instant
|
||||
public long periodUntil(Temporal endInstant, TemporalUnit unit) {
|
||||
if (endInstant instanceof Instant == false) {
|
||||
Objects.requireNonNull(endInstant, "endInstant");
|
||||
throw new DateTimeException("Unable to calculate period between objects of two different types");
|
||||
throw new DateTimeException("Unable to calculate amount as objects are of two different types");
|
||||
}
|
||||
Instant end = (Instant) endInstant;
|
||||
if (unit instanceof ChronoUnit) {
|
||||
|
@ -121,7 +121,7 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
@ -1489,19 +1489,19 @@ public final class LocalDate
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the period between this date and another date in
|
||||
* terms of the specified unit.
|
||||
* Calculates the amount of time until another date in terms of the specified unit.
|
||||
* <p>
|
||||
* This calculates the period between two dates in terms of a single unit.
|
||||
* This calculates the amount of time between two {@code LocalDate}
|
||||
* objects in terms of a single {@code TemporalUnit}.
|
||||
* The start and end points are {@code this} and the specified date.
|
||||
* The result will be negative if the end is before the start.
|
||||
* The {@code Temporal} passed to this method must be a {@code LocalDate}.
|
||||
* For example, the period in days between two dates can be calculated
|
||||
* For example, the amount in days between two dates can be calculated
|
||||
* using {@code startDate.periodUntil(endDate, DAYS)}.
|
||||
* <p>
|
||||
* The calculation returns a whole number, representing the number of
|
||||
* complete units between the two dates.
|
||||
* For example, the period in months between 2012-06-15 and 2012-08-14
|
||||
* For example, the amount in months between 2012-06-15 and 2012-08-14
|
||||
* will only be one month as it is one day short of two months.
|
||||
* <p>
|
||||
* There are two equivalent ways of using this method.
|
||||
@ -1527,9 +1527,9 @@ public final class LocalDate
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @param endDate the end date, which must be a {@code LocalDate}, not null
|
||||
* @param unit the unit to measure the period in, not null
|
||||
* @return the amount of the period between this date and the end date
|
||||
* @throws DateTimeException if the period cannot be calculated
|
||||
* @param unit the unit to measure the amount in, not null
|
||||
* @return the amount of time between this date and the end date
|
||||
* @throws DateTimeException if the amount cannot be calculated
|
||||
* @throws UnsupportedTemporalTypeException if the unit is not supported
|
||||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
@ -1538,7 +1538,7 @@ public final class LocalDate
|
||||
Objects.requireNonNull(unit, "unit");
|
||||
if (endDate instanceof LocalDate == false) {
|
||||
Objects.requireNonNull(endDate, "endDate");
|
||||
throw new DateTimeException("Unable to calculate period between objects of two different types");
|
||||
throw new DateTimeException("Unable to calculate amount as objects are of two different types");
|
||||
}
|
||||
LocalDate end = (LocalDate) endDate;
|
||||
if (unit instanceof ChronoUnit) {
|
||||
|
@ -119,7 +119,7 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
@ -1562,19 +1562,19 @@ public final class LocalDateTime
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the period between this date-time and another date-time in
|
||||
* terms of the specified unit.
|
||||
* Calculates the amount of time until another date-time in terms of the specified unit.
|
||||
* <p>
|
||||
* This calculates the period between two date-times in terms of a single unit.
|
||||
* This calculates the amount of time between two {@code LocalDateTime}
|
||||
* objects in terms of a single {@code TemporalUnit}.
|
||||
* The start and end points are {@code this} and the specified date-time.
|
||||
* The result will be negative if the end is before the start.
|
||||
* The {@code Temporal} passed to this method must be a {@code LocalDateTime}.
|
||||
* For example, the period in days between two date-times can be calculated
|
||||
* For example, the amount in days between two date-times can be calculated
|
||||
* using {@code startDateTime.periodUntil(endDateTime, DAYS)}.
|
||||
* <p>
|
||||
* The calculation returns a whole number, representing the number of
|
||||
* complete units between the two date-times.
|
||||
* For example, the period in months between 2012-06-15T00:00 and 2012-08-14T23:59
|
||||
* For example, the amount in months between 2012-06-15T00:00 and 2012-08-14T23:59
|
||||
* will only be one month as it is one minute short of two months.
|
||||
* <p>
|
||||
* There are two equivalent ways of using this method.
|
||||
@ -1602,9 +1602,9 @@ public final class LocalDateTime
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @param endDateTime the end date-time, which must be a {@code LocalDateTime}, not null
|
||||
* @param unit the unit to measure the period in, not null
|
||||
* @return the amount of the period between this date-time and the end date-time
|
||||
* @throws DateTimeException if the period cannot be calculated
|
||||
* @param unit the unit to measure the amount in, not null
|
||||
* @return the amount of time between this date-time and the end date-time
|
||||
* @throws DateTimeException if the amount cannot be calculated
|
||||
* @throws UnsupportedTemporalTypeException if the unit is not supported
|
||||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
@ -1612,7 +1612,7 @@ public final class LocalDateTime
|
||||
public long periodUntil(Temporal endDateTime, TemporalUnit unit) {
|
||||
if (endDateTime instanceof LocalDateTime == false) {
|
||||
Objects.requireNonNull(endDateTime, "endDateTime");
|
||||
throw new DateTimeException("Unable to calculate period between objects of two different types");
|
||||
throw new DateTimeException("Unable to calculate amount as objects are of two different types");
|
||||
}
|
||||
LocalDateTime end = (LocalDateTime) endDateTime;
|
||||
if (unit instanceof ChronoUnit) {
|
||||
|
@ -109,7 +109,7 @@ import java.util.Objects;
|
||||
* in most of the world. This API assumes that all calendar systems use the same
|
||||
* representation, this class, for time-of-day.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
@ -974,9 +974,6 @@ public final class LocalTime
|
||||
* Returns a {@code LocalTime} with the specified number of half-days added.
|
||||
* This is equivalent to {@link #plusHours(long)} with the amount
|
||||
* multiplied by 12.
|
||||
* <li>{@code DAYS} -
|
||||
* Returns a {@code LocalTime} with the specified number of days added.
|
||||
* This returns {@code this} time.
|
||||
* </ul>
|
||||
* <p>
|
||||
* All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}.
|
||||
@ -1007,7 +1004,6 @@ public final class LocalTime
|
||||
case MINUTES: return plusMinutes(amountToAdd);
|
||||
case HOURS: return plusHours(amountToAdd);
|
||||
case HALF_DAYS: return plusHours((amountToAdd % 2) * 12);
|
||||
case DAYS: return this;
|
||||
}
|
||||
throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName());
|
||||
}
|
||||
@ -1291,19 +1287,19 @@ public final class LocalTime
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the period between this time and another time in
|
||||
* terms of the specified unit.
|
||||
* Calculates the amount of time until another time in terms of the specified unit.
|
||||
* <p>
|
||||
* This calculates the period between two times in terms of a single unit.
|
||||
* This calculates the amount of time between two {@code LocalTime}
|
||||
* objects in terms of a single {@code TemporalUnit}.
|
||||
* The start and end points are {@code this} and the specified time.
|
||||
* The result will be negative if the end is before the start.
|
||||
* The {@code Temporal} passed to this method must be a {@code LocalTime}.
|
||||
* For example, the period in hours between two times can be calculated
|
||||
* For example, the amount in hours between two times can be calculated
|
||||
* using {@code startTime.periodUntil(endTime, HOURS)}.
|
||||
* <p>
|
||||
* The calculation returns a whole number, representing the number of
|
||||
* complete units between the two times.
|
||||
* For example, the period in hours between 11:30 and 13:29 will only
|
||||
* For example, the amount in hours between 11:30 and 13:29 will only
|
||||
* be one hour as it is one minute short of two hours.
|
||||
* <p>
|
||||
* There are two equivalent ways of using this method.
|
||||
@ -1329,9 +1325,9 @@ public final class LocalTime
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @param endTime the end time, which must be a {@code LocalTime}, not null
|
||||
* @param unit the unit to measure the period in, not null
|
||||
* @return the amount of the period between this time and the end time
|
||||
* @throws DateTimeException if the period cannot be calculated
|
||||
* @param unit the unit to measure the amount in, not null
|
||||
* @return the amount of time between this time and the end time
|
||||
* @throws DateTimeException if the amount cannot be calculated
|
||||
* @throws UnsupportedTemporalTypeException if the unit is not supported
|
||||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
@ -1339,7 +1335,7 @@ public final class LocalTime
|
||||
public long periodUntil(Temporal endTime, TemporalUnit unit) {
|
||||
if (endTime instanceof LocalTime == false) {
|
||||
Objects.requireNonNull(endTime, "endTime");
|
||||
throw new DateTimeException("Unable to calculate period between objects of two different types");
|
||||
throw new DateTimeException("Unable to calculate amount as objects are of two different types");
|
||||
}
|
||||
LocalTime end = (LocalTime) endTime;
|
||||
if (unit instanceof ChronoUnit) {
|
||||
|
@ -97,7 +97,7 @@ import java.util.Locale;
|
||||
* As such, this enum may be used by any calendar system that has the month-of-year
|
||||
* concept defined exactly equivalent to the ISO-8601 calendar system.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This is an immutable and thread-safe enum.
|
||||
*
|
||||
* @since 1.8
|
||||
|
@ -111,7 +111,7 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
|
@ -111,7 +111,7 @@ import java.util.Objects;
|
||||
* in simpler applications. This class may be used when modeling date-time concepts in
|
||||
* more detail, or when communicating to a database or in a network protocol.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
@ -1521,10 +1521,10 @@ public final class OffsetDateTime
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the period between this date-time and another date-time in
|
||||
* terms of the specified unit.
|
||||
* Calculates the amount of time until another date-time in terms of the specified unit.
|
||||
* <p>
|
||||
* This calculates the period between two date-times in terms of a single unit.
|
||||
* This calculates the amount of time between two {@code OffsetDateTime}
|
||||
* objects in terms of a single {@code TemporalUnit}.
|
||||
* The start and end points are {@code this} and the specified date-time.
|
||||
* The result will be negative if the end is before the start.
|
||||
* For example, the period in days between two date-times can be calculated
|
||||
@ -1564,9 +1564,9 @@ public final class OffsetDateTime
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @param endDateTime the end date-time, which must be an {@code OffsetDateTime}, not null
|
||||
* @param unit the unit to measure the period in, not null
|
||||
* @return the amount of the period between this date-time and the end date-time
|
||||
* @throws DateTimeException if the period cannot be calculated
|
||||
* @param unit the unit to measure the amount in, not null
|
||||
* @return the amount of time between this date-time and the end date-time
|
||||
* @throws DateTimeException if the amount cannot be calculated
|
||||
* @throws UnsupportedTemporalTypeException if the unit is not supported
|
||||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
@ -1574,7 +1574,7 @@ public final class OffsetDateTime
|
||||
public long periodUntil(Temporal endDateTime, TemporalUnit unit) {
|
||||
if (endDateTime instanceof OffsetDateTime == false) {
|
||||
Objects.requireNonNull(endDateTime, "endDateTime");
|
||||
throw new DateTimeException("Unable to calculate period between objects of two different types");
|
||||
throw new DateTimeException("Unable to calculate amount as objects are of two different types");
|
||||
}
|
||||
if (unit instanceof ChronoUnit) {
|
||||
OffsetDateTime end = (OffsetDateTime) endDateTime;
|
||||
|
@ -102,7 +102,7 @@ import java.util.Objects;
|
||||
* For example, the value "13:45.30.123456789+02:00" can be stored
|
||||
* in an {@code OffsetTime}.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
@ -1077,10 +1077,10 @@ public final class OffsetTime
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the period between this time and another time in
|
||||
* terms of the specified unit.
|
||||
* Calculates the amount of time until another time in terms of the specified unit.
|
||||
* <p>
|
||||
* This calculates the period between two times in terms of a single unit.
|
||||
* This calculates the amount of time between two {@code OffsetTime}
|
||||
* objects in terms of a single {@code TemporalUnit}.
|
||||
* The start and end points are {@code this} and the specified time.
|
||||
* The result will be negative if the end is before the start.
|
||||
* For example, the period in hours between two times can be calculated
|
||||
@ -1118,9 +1118,9 @@ public final class OffsetTime
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @param endTime the end time, which must be an {@code OffsetTime}, not null
|
||||
* @param unit the unit to measure the period in, not null
|
||||
* @return the amount of the period between this time and the end time
|
||||
* @throws DateTimeException if the period cannot be calculated
|
||||
* @param unit the unit to measure the amount in, not null
|
||||
* @return the amount of time between this time and the end time
|
||||
* @throws DateTimeException if the amount cannot be calculated
|
||||
* @throws UnsupportedTemporalTypeException if the unit is not supported
|
||||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
@ -1128,7 +1128,7 @@ public final class OffsetTime
|
||||
public long periodUntil(Temporal endTime, TemporalUnit unit) {
|
||||
if (endTime instanceof OffsetTime == false) {
|
||||
Objects.requireNonNull(endTime, "endTime");
|
||||
throw new DateTimeException("Unable to calculate period between objects of two different types");
|
||||
throw new DateTimeException("Unable to calculate amount as objects are of two different types");
|
||||
}
|
||||
if (unit instanceof ChronoUnit) {
|
||||
OffsetTime end = (OffsetTime) endTime;
|
||||
|
@ -119,7 +119,7 @@ import java.util.regex.Pattern;
|
||||
* The months and years fields may be {@linkplain #normalized() normalized}.
|
||||
* The normalization assumes a 12 month year, so is not appropriate for all calendar systems.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
|
@ -66,7 +66,7 @@ import java.io.StreamCorruptedException;
|
||||
/**
|
||||
* The shared serialization delegate for this package.
|
||||
*
|
||||
* <h3>Implementation notes</h3>
|
||||
* @implNote
|
||||
* This class wraps the object being serialized, and takes a byte representing the type of the class to
|
||||
* be serialized. This byte can also be used for versioning the serialization format. In this case another
|
||||
* byte flag would be used in order to specify an alternative version of the type format.
|
||||
|
@ -115,7 +115,7 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
@ -813,10 +813,10 @@ public final class Year
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the period between this year and another year in
|
||||
* terms of the specified unit.
|
||||
* Calculates the amount of time until another year in terms of the specified unit.
|
||||
* <p>
|
||||
* This calculates the period between two years in terms of a single unit.
|
||||
* This calculates the amount of time between two {@code Year}
|
||||
* objects in terms of a single {@code TemporalUnit}.
|
||||
* The start and end points are {@code this} and the specified year.
|
||||
* The result will be negative if the end is before the start.
|
||||
* The {@code Temporal} passed to this method must be a {@code Year}.
|
||||
@ -851,9 +851,9 @@ public final class Year
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @param endYear the end year, which must be a {@code Year}, not null
|
||||
* @param unit the unit to measure the period in, not null
|
||||
* @return the amount of the period between this year and the end year
|
||||
* @throws DateTimeException if the period cannot be calculated
|
||||
* @param unit the unit to measure the amount in, not null
|
||||
* @return the amount of time between this year and the end year
|
||||
* @throws DateTimeException if the amount cannot be calculated
|
||||
* @throws UnsupportedTemporalTypeException if the unit is not supported
|
||||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
@ -861,7 +861,7 @@ public final class Year
|
||||
public long periodUntil(Temporal endYear, TemporalUnit unit) {
|
||||
if (endYear instanceof Year == false) {
|
||||
Objects.requireNonNull(endYear, "endYear");
|
||||
throw new DateTimeException("Unable to calculate period between objects of two different types");
|
||||
throw new DateTimeException("Unable to calculate amount as objects are of two different types");
|
||||
}
|
||||
Year end = (Year) endYear;
|
||||
if (unit instanceof ChronoUnit) {
|
||||
|
@ -110,7 +110,7 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
@ -944,10 +944,10 @@ public final class YearMonth
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the period between this year-month and another year-month in
|
||||
* terms of the specified unit.
|
||||
* Calculates the amount of time until another year-month in terms of the specified unit.
|
||||
* <p>
|
||||
* This calculates the period between two year-months in terms of a single unit.
|
||||
* This calculates the amount of time between two {@code YearMonth}
|
||||
* objects in terms of a single {@code TemporalUnit}.
|
||||
* The start and end points are {@code this} and the specified year-month.
|
||||
* The result will be negative if the end is before the start.
|
||||
* The {@code Temporal} passed to this method must be a {@code YearMonth}.
|
||||
@ -982,9 +982,9 @@ public final class YearMonth
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @param endYearMonth the end year-month, which must be a {@code YearMonth}, not null
|
||||
* @param unit the unit to measure the period in, not null
|
||||
* @return the amount of the period between this year-month and the end year-month
|
||||
* @throws DateTimeException if the period cannot be calculated
|
||||
* @param unit the unit to measure the amount in, not null
|
||||
* @return the amount of time between this year-month and the end year-month
|
||||
* @throws DateTimeException if the amount cannot be calculated
|
||||
* @throws UnsupportedTemporalTypeException if the unit is not supported
|
||||
* @throws ArithmeticException if numeric overflow occurs
|
||||
*/
|
||||
@ -992,7 +992,7 @@ public final class YearMonth
|
||||
public long periodUntil(Temporal endYearMonth, TemporalUnit unit) {
|
||||
if (endYearMonth instanceof YearMonth == false) {
|
||||
Objects.requireNonNull(endYearMonth, "endYearMonth");
|
||||
throw new DateTimeException("Unable to calculate period between objects of two different types");
|
||||
throw new DateTimeException("Unable to calculate amount as objects are of two different types");
|
||||
}
|
||||
YearMonth end = (YearMonth) endYearMonth;
|
||||
if (unit instanceof ChronoUnit) {
|
||||
|
@ -157,7 +157,7 @@ import java.util.TimeZone;
|
||||
* This approach is designed to allow a {@link ZonedDateTime} to be loaded and
|
||||
* queried, but not modified, on a Java Runtime with incomplete time-zone information.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This abstract class has two implementations, both of which are immutable and thread-safe.
|
||||
* One implementation models region-based IDs, the other is {@code ZoneOffset} modelling
|
||||
* offset-based IDs. This difference is visible in serialization.
|
||||
|
@ -114,7 +114,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
* Implementations may choose to cache certain common offsets, however
|
||||
* applications must not rely on such caching.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
|
@ -83,7 +83,7 @@ import java.util.regex.Pattern;
|
||||
* By contrast, the region identifier is well-defined and long-lived.
|
||||
* This separation also allows rules to be shared between regions if appropriate.
|
||||
*
|
||||
* <h3>Specification for implementors</h3>
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @since 1.8
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user