diff --git a/.hgtags b/.hgtags index 303bb6739f77048031056a9ae329c65542a8e798..7be0eb3751c7d4627115e28d9b13480c6fdd32e4 100644 --- a/.hgtags +++ b/.hgtags @@ -211,3 +211,4 @@ ac519af51769e92c51b597a730974e8607357709 jdk8-b83 d5228e624826a10ccc5b05f30ad8d839b58fe48d jdk8-b87 8dbb4b159e04de3c447c9242c70505e71f8624c7 jdk8-b88 845025546e35519fbb8970e79fc2a834063a5e19 jdk8-b89 +c63eda8f63008a4398d2c22ac8d72f7fef6f9238 jdk8-b90 diff --git a/make/com/sun/Makefile b/make/com/sun/Makefile index 052cd54103251886921165ea3db79b25bcea23d9..e33b27f8c1828b8c88462d5dea2a31b1db97dafd 100644 --- a/make/com/sun/Makefile +++ b/make/com/sun/Makefile @@ -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 diff --git a/make/com/sun/script/Makefile b/make/com/sun/script/Makefile deleted file mode 100644 index 58e134fad53f3d4122f50800cd62114e1dde00ed..0000000000000000000000000000000000000000 --- a/make/com/sun/script/Makefile +++ /dev/null @@ -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) - diff --git a/make/common/Release.gmk b/make/common/Release.gmk index 2cdfc0ef6baa7d4e7ec5cddd210851f94d00d6b1..ce2dda53d1d9c86e3b6e8ec51e939898a66f02da 100644 --- a/make/common/Release.gmk +++ b/make/common/Release.gmk @@ -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 diff --git a/make/sun/Makefile b/make/sun/Makefile index 35fb554a81a68b7fd812aea651b8754849b5159c..c9d6f9cc663ad0c08e5e3a9888de6ef3b57f27b4 100644 --- a/make/sun/Makefile +++ b/make/sun/Makefile @@ -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 diff --git a/make/sun/awt/mapfile-vers b/make/sun/awt/mapfile-vers index 5c6cfea808bb560247ecb0239c772bfa2e307573..f68ef5cfb9d98628ef4a1ce9718e2696f0836a93 100644 --- a/make/sun/awt/mapfile-vers +++ b/make/sun/awt/mapfile-vers @@ -87,6 +87,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; Java_java_awt_Dimension_initIDs; + Java_java_awt_Choice_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; diff --git a/make/sun/awt/mapfile-vers-bsd b/make/sun/awt/mapfile-vers-bsd index f606b3fbbb0ad921e004cca1da8179dc24f6eeb4..dcc59f09e0eff5a96447c92bf76d6a042cf6b881 100644 --- a/make/sun/awt/mapfile-vers-bsd +++ b/make/sun/awt/mapfile-vers-bsd @@ -87,6 +87,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; Java_java_awt_Dimension_initIDs; + Java_java_awt_Choice_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; diff --git a/make/sun/awt/mapfile-vers-linux b/make/sun/awt/mapfile-vers-linux index b7033b89fa89e789196a29550d9e9b7859954f2d..03f0cc07e47de8659d948fbb4938fd7f6dbb81c0 100644 --- a/make/sun/awt/mapfile-vers-linux +++ b/make/sun/awt/mapfile-vers-linux @@ -87,6 +87,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; Java_java_awt_Dimension_initIDs; + Java_java_awt_Choice_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; diff --git a/make/sun/javazic/tzdata/VERSION b/make/sun/javazic/tzdata/VERSION index 85db871ccf31919828a5cd032b0e01e766eed712..8ad1064e0581993ba8e28c93183ba74629d72d86 100644 --- a/make/sun/javazic/tzdata/VERSION +++ b/make/sun/javazic/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2012i +tzdata2013c diff --git a/make/sun/javazic/tzdata/africa b/make/sun/javazic/tzdata/africa index 7db9b3d269d705aa6cba636c6ede09b073da229e..2f5d3c5e3fc95d449a193e43508ba8355d63e8ed 100644 --- a/make/sun/javazic/tzdata/africa +++ b/make/sun/javazic/tzdata/africa @@ -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 +# . +# # 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 +# . +# +# 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 diff --git a/make/sun/javazic/tzdata/antarctica b/make/sun/javazic/tzdata/antarctica index 64b71d5c052fe9d145d6618fc3e3bbbdbd20ee38..daa03ea830c98ebb937e84e87311e003d9887ca6 100644 --- a/make/sun/javazic/tzdata/antarctica +++ b/make/sun/javazic/tzdata/antarctica @@ -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 - # # 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: # # 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: # # Casey Weather (1998-02-26) diff --git a/make/sun/javazic/tzdata/asia b/make/sun/javazic/tzdata/asia index 9ef3ef8df5405dd9bb987386b0136db84edb79c2..7818c029a60b5db9bd54c3c4677fcae490c4e667 100644 --- a/make/sun/javazic/tzdata/asia +++ b/make/sun/javazic/tzdata/asia @@ -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 +# . +# # 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 # -# 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 diff --git a/make/sun/javazic/tzdata/australasia b/make/sun/javazic/tzdata/australasia index 7f83448f3fba17ddce19294fd94741f567290672..db954a81dcd29fa5e9cb76304bbf345b6c57c458 100644 --- a/make/sun/javazic/tzdata/australasia +++ b/make/sun/javazic/tzdata/australasia @@ -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 +# +# . +# 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 +# . +# # A reliable and entertaining source about time zones is # Derek Howse, Greenwich time and longitude, Philip Wilson Publishers (1997). # diff --git a/make/sun/javazic/tzdata/europe b/make/sun/javazic/tzdata/europe index 9a0d0b9db9493129aa61582d8e9a22be92609510..268504d09839da7328da1739104ac9364e5af5b4 100644 --- a/make/sun/javazic/tzdata/europe +++ b/make/sun/javazic/tzdata/europe @@ -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 # (1914-03) # +# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94 +# . 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), # # 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 , 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 +# +# http://www.government.ru/gov/results/16355/print/ +# +# 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: +# +# http://www.worldtimezone.com/dst_news/dst_news_russia36.htm +# + +# From Sanjeev Gupta (2011-09-27): +# Scans of [Decree #23 of January 8, 1992] are available at: +# +# 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/ +# +# 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 +# +# http://www.rg.ru/2011/09/06/chas-zona-dok.html +# +# 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 +# +# http://en.wikipedia.org/wiki/Oymyakonsky_District#cite_note-RuTime-7 +# +# 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 +# +# http://base.consultant.ru/cons/cgi/online.cgi?req=doc;base=LAW;n=118896 +# +# 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. # diff --git a/make/sun/javazic/tzdata/northamerica b/make/sun/javazic/tzdata/northamerica index c3033267404018c90b67dc390137aaac4a82ffe2..858bf811ac9e08c1fa1a8824f860054115016706 100644 --- a/make/sun/javazic/tzdata/northamerica +++ b/make/sun/javazic/tzdata/northamerica @@ -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 # (1914-03) # +# Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94 +# . +# # 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): -# # http://www.alterpresse.org/spip.php?article12510 -# -# # http://radiovision2000haiti.net/home/?p=13253 -# # -# Our coverage: -# -# http://www.timeanddate.com/news/time/haiti-dst-2012.html -# - # 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 diff --git a/make/sun/javazic/tzdata/southamerica b/make/sun/javazic/tzdata/southamerica index 0d6797eab6b9c684c8131eba99daa358e08e51ad..d1865d3f19b07bb58aa6aff4924fc5c649daf7c4 100644 --- a/make/sun/javazic/tzdata/southamerica +++ b/make/sun/javazic/tzdata/southamerica @@ -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 +# . +# # 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 # # 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 -# +# There's also a note in only one of the major national papers ... # http://www.lanacion.com.ar/nota.asp?nota_id=1107912 -# -# -# 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 # http://pcdsh01.on.br/ 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. # (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 diff --git a/make/sun/javazic/tzdata/zone.tab b/make/sun/javazic/tzdata/zone.tab index ef380cd19fb124daf32219501e26679108f60649..cbcdc075bf77a7950240542795b0caa90e3b0c00 100644 --- a/make/sun/javazic/tzdata/zone.tab +++ b/make/sun/javazic/tzdata/zone.tab @@ -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 diff --git a/make/sun/nio/cs/Makefile b/make/sun/nio/cs/Makefile index 73fe55fbd082f7e543d40fe3825a951cff41aa11..3b45c774fe02cc242e5fcfd58ba4959d54edbfca 100644 --- a/make/sun/nio/cs/Makefile +++ b/make/sun/nio/cs/Makefile @@ -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) diff --git a/make/sun/org/mozilla/Makefile b/make/sun/org/mozilla/Makefile deleted file mode 100644 index 0805da63bdabb10a5c7670640da50dea2fc0c382..0000000000000000000000000000000000000000 --- a/make/sun/org/mozilla/Makefile +++ /dev/null @@ -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) - diff --git a/make/sun/org/mozilla/javascript/Makefile b/make/sun/org/mozilla/javascript/Makefile deleted file mode 100644 index f381b94e33cf35843a2988508c40f2eb631cdd3f..0000000000000000000000000000000000000000 --- a/make/sun/org/mozilla/javascript/Makefile +++ /dev/null @@ -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 diff --git a/make/sun/security/Makefile b/make/sun/security/Makefile index 9e9f8c50d3695d68635d67d4b94116ea90e3a158..0a1a7aa726506337ab0f8517b940074b8486e9c5 100644 --- a/make/sun/security/Makefile +++ b/make/sun/security/Makefile @@ -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 diff --git a/make/sun/security/ec/Makefile b/make/sun/security/ec/Makefile index f04ec0eec17ea8ce4768dc49605529b03199b0af..bceb031ad0ab8d80a01e3b423cca3d4a4051f1b9 100644 --- a/make/sun/security/ec/Makefile +++ b/make/sun/security/ec/Makefile @@ -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 diff --git a/make/sun/security/other/Makefile b/make/sun/security/other/Makefile index 5a3d9b04c958328e5b3345cb9ea1a30da6f9adc9..cb62c983c9eacf93ed15374ad85850d6ad28a415 100644 --- a/make/sun/security/other/Makefile +++ b/make/sun/security/other/Makefile @@ -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 # diff --git a/make/tools/src/build/tools/cldrconverter/CLDRConverter.java b/make/tools/src/build/tools/cldrconverter/CLDRConverter.java index f1185f18978610b743cfd6e7539345b803defc88..9cbf02a9c3b112fd69c35a107f902ad213e2752e 100644 --- a/make/tools/src/build/tools/cldrconverter/CLDRConverter.java +++ b/make/tools/src/build/tools/cldrconverter/CLDRConverter.java @@ -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 readBundleList() throws Exception { ResourceBundle.Control defCon = ResourceBundle.Control.getControl(ResourceBundle.Control.FORMAT_DEFAULT); List 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); diff --git a/make/tools/src/build/tools/deps/refs.allowed b/make/tools/src/build/tools/deps/refs.allowed index ef1bec7bbcdd6b3f3fde069c46013e187bec7ec6..7c15a04d91b771b3ab967d68573adb331de7d833 100644 --- a/make/tools/src/build/tools/deps/refs.allowed +++ b/make/tools/src/build/tools/deps/refs.allowed @@ -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 diff --git a/makefiles/CompileDemos.gmk b/makefiles/CompileDemos.gmk index f61d9404020061844b8d980c657a8c3c155c16ca..0a093b586a97109cebf49adddd3f9d67496702f8 100644 --- a/makefiles/CompileDemos.gmk +++ b/makefiles/CompileDemos.gmk @@ -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 diff --git a/makefiles/CompileLaunchers.gmk b/makefiles/CompileLaunchers.gmk index 7ecad956fbb5fd4b8e03dce032d1b6407ad0b31b..0621f4ce38b8277eab213dd27d771ef25d263b19 100644 --- a/makefiles/CompileLaunchers.gmk +++ b/makefiles/CompileLaunchers.gmk @@ -472,6 +472,7 @@ $(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE,\ -D "JDK_FNAME=unpack200.exe" \ -D "JDK_INTERNAL_NAME=unpack200" \ -D "JDK_FTYPE=0x1L",\ + DEBUG_SYMBOLS:=true,\ MANIFEST:=$(JDK_TOPDIR)/src/windows/resource/unpack200_proto.exe.manifest)) ifeq ($(OPENJDK_TARGET_OS),windows) @@ -555,6 +556,7 @@ ifneq ($(BUILD_JEXEC_SRC),) $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)$(SHARED_LIBRARY_SUFFIX)), \ OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/jexec_obj,\ OUTPUT_DIR:=$(BUILD_JEXEC_DST_DIR),\ + DEBUG_SYMBOLS:=true,\ PROGRAM:=jexec)) BUILD_LAUNCHERS += $(BUILD_JEXEC) diff --git a/makefiles/CompileNativeLibraries.gmk b/makefiles/CompileNativeLibraries.gmk index bb30367c276012c77d9aef66ffb6292a1a9b6b83..1836cbb13f9e670288dd9c7aa987968e1064bbb2 100644 --- a/makefiles/CompileNativeLibraries.gmk +++ b/makefiles/CompileNativeLibraries.gmk @@ -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 ########################################################################################## diff --git a/makefiles/CopyFiles.gmk b/makefiles/CopyFiles.gmk index ab3a360daaf4988dd89fa50ec26ee0fbbe80fbf5..272fd1f28b640aa0d7cc7aa3ebd8f1f4280fb08c 100644 --- a/makefiles/CopyFiles.gmk +++ b/makefiles/CopyFiles.gmk @@ -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 # diff --git a/makefiles/CopyIntoClasses.gmk b/makefiles/CopyIntoClasses.gmk index 8b5a1cd0a3f086d79afe3567f17f411e36070046..88ab3c48e4202446168f033bbc313c1eb22e5064 100644 --- a/makefiles/CopyIntoClasses.gmk +++ b/makefiles/CopyIntoClasses.gmk @@ -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 diff --git a/makefiles/CreateJars.gmk b/makefiles/CreateJars.gmk index 8127b054459e22c55408526be2b221f4c3bb9690..3225a862653c7f7018a510b8aa1c4784735f95f9 100644 --- a/makefiles/CreateJars.gmk +++ b/makefiles/CreateJars.gmk @@ -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)) diff --git a/makefiles/GensrcSwing.gmk b/makefiles/GensrcSwing.gmk index f5741ae5f46589890917f369756051e1d7deb0de..5350c143b7314053e276e45f093eeff9aa2061b5 100644 --- a/makefiles/GensrcSwing.gmk +++ b/makefiles/GensrcSwing.gmk @@ -68,10 +68,17 @@ BEANS_SRC = $(BEANS:%=$(JDK_TOPDIR)/src/share/classes/javax/swing/%.java) \ # Dummy variable so far, in the old build system it was false by default SWINGBEAN_DEBUG_FLAG = false # GenDocletBeanInfo is compiled in Tools.gmk and picks up from $(JDK_OUTPUTDIR)/btclasses -$(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo: $(BEANS_SRC) $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing/SwingBeanInfoBase.java $(JDK_OUTPUTDIR)/gensrc/sun/swing/BeanInfoUtils.java $(BUILD_TOOLS) +# LocaleDataMetaInfo needs to be generated before running this to avoid confusing errors +# in the build log. +$(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo: $(BEANS_SRC) \ + $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing/SwingBeanInfoBase.java \ + $(JDK_OUTPUTDIR)/gensrc/sun/swing/BeanInfoUtils.java $(BUILD_TOOLS) \ + | $(GENSRC_LOCALEDATAMETAINFO) $(ECHO) Generating beaninfo $(MKDIR) -p $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing - $(JAVA) -Djava.awt.headless=true $(NEW_JAVADOC) -doclet GenDocletBeanInfo \ + $(JAVA) -Djava.awt.headless=true $(NEW_JAVADOC) \ + -sourcepath "$(JDK_TOPDIR)/src/share/classes$(PATH_SEP)$(JDK_OUTPUTDIR)/gensrc" \ + -doclet GenDocletBeanInfo \ -x $(SWINGBEAN_DEBUG_FLAG) -d $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing \ -t $(DOCLETSRC_DIR)/SwingBeanInfo.template -docletpath $(JDK_OUTPUTDIR)/btclasses \ -XDignore.symbol.file=true \ diff --git a/makefiles/Images.gmk b/makefiles/Images.gmk index 2dde16fdf66509e9f28116923627d43e499cf23f..a1db8b9a148a3b75de59c5253ea4e7cc21330059 100644 --- a/makefiles/Images.gmk +++ b/makefiles/Images.gmk @@ -352,11 +352,8 @@ ifneq ($(OPENJDK_TARGET_OS),windows) JDK_MAN_PAGES += jvisualvm.1 endif - ifndef OPENJDK - MAN_SRC_BASEDIR:=$(JDK_TOPDIR)/src/closed - else - MAN_SRC_BASEDIR:=$(JDK_TOPDIR)/src - endif + # This variable is potentially overridden in the closed makefile. + MAN_SRC_BASEDIR ?= $(JDK_TOPDIR)/src ifeq ($(OPENJDK_TARGET_OS), linux) MAN_SRC_DIR:=$(MAN_SRC_BASEDIR)/linux/doc @@ -532,17 +529,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 diff --git a/makefiles/mapfiles/libawt/mapfile-vers b/makefiles/mapfiles/libawt/mapfile-vers index 924a2827a99bd822a55237ca2208d178deb2cdcb..8af9d14dd57050340cc1162f862587b58f225133 100644 --- a/makefiles/mapfiles/libawt/mapfile-vers +++ b/makefiles/mapfiles/libawt/mapfile-vers @@ -86,6 +86,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_setRule; Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_Choice_initIDs; Java_java_awt_Dimension_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; diff --git a/makefiles/mapfiles/libawt/mapfile-vers-linux b/makefiles/mapfiles/libawt/mapfile-vers-linux index 2514670ea3eb3875ac18b8906db1fff7da37eb0d..b0bfb1ca91af8a0532984a07f306cf31349a7401 100644 --- a/makefiles/mapfiles/libawt/mapfile-vers-linux +++ b/makefiles/mapfiles/libawt/mapfile-vers-linux @@ -86,6 +86,7 @@ SUNWprivate_1.1 { Java_sun_java2d_pipe_ShapeSpanIterator_setRule; Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_Choice_initIDs; Java_java_awt_Dimension_initIDs; Java_java_awt_event_MouseEvent_initIDs; Java_java_awt_image_DataBufferInt_initIDs; diff --git a/makefiles/profile-rtjar-includes.txt b/makefiles/profile-rtjar-includes.txt index a90af142db145b19388ed9b18c308de32697ad03..d740e01abe884a3b56bdb06beefa45c8899dfc3e 100644 --- a/makefiles/profile-rtjar-includes.txt +++ b/makefiles/profile-rtjar-includes.txt @@ -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 \ diff --git a/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java b/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java index dff48a4caa333bdc90e2e1e64007349cb3174c4a..f5cb0d576e61e410a32bf0814110e57c4b30c0d8 100644 --- a/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java +++ b/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -56,6 +56,8 @@ final class LWScrollBarPeer extends LWComponentPeer void initializeImpl() { super.initializeImpl(); final Scrollbar target = getTarget(); + setLineIncrement(target.getUnitIncrement()); + setPageIncrement(target.getBlockIncrement()); setValues(target.getValue(), target.getVisibleAmount(), target.getMinimum(), target.getMaximum()); diff --git a/src/macosx/classes/sun/lwawt/LWToolkit.java b/src/macosx/classes/sun/lwawt/LWToolkit.java index 529efd9d6b3a6768208192d96622a5a69dea0c03..fb7032f0b743bfa4c3dc1b32d51e4f97e4776482 100644 --- a/src/macosx/classes/sun/lwawt/LWToolkit.java +++ b/src/macosx/classes/sun/lwawt/LWToolkit.java @@ -53,7 +53,12 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { private Clipboard clipboard; private MouseInfoPeer mouseInfoPeer; - public LWToolkit() { + /** + * Dynamic Layout Resize client code setting. + */ + private volatile boolean dynamicLayoutSetting = true; + + protected LWToolkit() { } /* @@ -563,4 +568,37 @@ public abstract class LWToolkit extends SunToolkit implements Runnable { ((LWWindowPeer)w.getPeer()).ungrab(false); } } + + @Override + protected final Object lazilyLoadDesktopProperty(final String name) { + if (name.equals("awt.dynamicLayoutSupported")) { + return isDynamicLayoutSupported(); + } + return super.lazilyLoadDesktopProperty(name); + } + + @Override + public final void setDynamicLayout(final boolean dynamic) { + dynamicLayoutSetting = dynamic; + } + + @Override + protected final boolean isDynamicLayoutSet() { + return dynamicLayoutSetting; + } + + @Override + public final boolean isDynamicLayoutActive() { + // "Live resizing" is active by default and user's data is ignored. + return isDynamicLayoutSupported(); + } + + /** + * Returns true if dynamic layout of Containers on resize is supported by + * the underlying operating system and/or window manager. + */ + protected final boolean isDynamicLayoutSupported() { + // "Live resizing" is supported by default. + return true; + } } diff --git a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java index 791182c156547f8bf059df628bbfc7836b7ab918..e198024dd0c88183e23e39210755a17630205197 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java @@ -35,6 +35,7 @@ import java.security.PrivilegedAction; import javax.print.*; import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.HashPrintRequestAttributeSet; import sun.java2d.*; import sun.print.*; @@ -96,6 +97,14 @@ public class CPrinterJob extends RasterPrinterJob { return false; } + if (attributes == null) { + attributes = new HashPrintRequestAttributeSet(); + } + + if (getPrintService() instanceof StreamPrintService) { + return super.printDialog(attributes); + } + return jobSetup(getPageable(), checkAllowedToPrintToFile()); } @@ -130,6 +139,10 @@ public class CPrinterJob extends RasterPrinterJob { return page; } + if (getPrintService() instanceof StreamPrintService) { + return super.pageDialog(page); + } + PageFormat pageClone = (PageFormat) page.clone(); boolean doIt = pageSetup(pageClone, null); return doIt ? pageClone : page; diff --git a/src/macosx/native/sun/awt/AWTSurfaceLayers.m b/src/macosx/native/sun/awt/AWTSurfaceLayers.m index 6e9fbbca5abaa50e54a4955906326b33cc6a26bd..d12908c83a3ce7dcfb3fc8eff5707d342fc705b1 100644 --- a/src/macosx/native/sun/awt/AWTSurfaceLayers.m +++ b/src/macosx/native/sun/awt/AWTSurfaceLayers.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -28,6 +28,7 @@ #import "LWCToolkit.h" #import +#import @implementation AWTSurfaceLayers @@ -74,14 +75,12 @@ } - (void) setBounds:(CGRect)rect { - layer.anchorPoint = CGPointMake(0, 0); - // translates values to the coordinate system of the "root" layer - CGFloat newY = windowLayer.bounds.size.height - rect.origin.y - rect.size.height; - CGRect newRect = CGRectMake(rect.origin.x, newY, rect.size.width, rect.size.height); - - layer.frame = newRect; - + rect.origin.y = windowLayer.bounds.size.height - rect.origin.y - rect.size.height; + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + layer.frame = rect; + [CATransaction commit]; [AWTSurfaceLayers repaintLayersRecursively:layer]; } diff --git a/src/macosx/native/sun/java2d/opengl/CGLLayer.m b/src/macosx/native/sun/java2d/opengl/CGLLayer.m index e0074eb4ef3d68355c75dbdd2632087fca11b53c..f300ea404c462266d2f11cff06d619b0f1e1e709 100644 --- a/src/macosx/native/sun/java2d/opengl/CGLLayer.m +++ b/src/macosx/native/sun/java2d/opengl/CGLLayer.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -64,11 +64,13 @@ AWT_ASSERT_APPKIT_THREAD; //Disable CALayer's default animation NSMutableDictionary * actions = [[NSMutableDictionary alloc] initWithObjectsAndKeys: + [NSNull null], @"anchorPoint", [NSNull null], @"bounds", [NSNull null], @"contents", [NSNull null], @"contentsScale", [NSNull null], @"onOrderIn", [NSNull null], @"onOrderOut", + [NSNull null], @"position", [NSNull null], @"sublayers", nil]; self.actions = actions; diff --git a/src/share/bin/java.c b/src/share/bin/java.c index f08a52a9db24a0c20388227e0803860fcffc550b..73c532676b3c6bc9485c15a6185348c813ee8881 100644 --- a/src/share/bin/java.c +++ b/src/share/bin/java.c @@ -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 \ - -#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_LEAVE(rv) \ - if ((*env)->ExceptionOccurred(env)) { \ - JLI_ReportExceptionDescription(env); \ - ret = (rv); \ - LEAVE(); \ - } + 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(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(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 diff --git a/src/share/bin/java.h b/src/share/bin/java.h index ad1a1ff90e0b554fedc51dafd4666d21dc74bf59..83e97e60d9c50cd8396fc6f9990dc2a86b79dbaf 100644 --- a/src/share/bin/java.h +++ b/src/share/bin/java.h @@ -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_ */ diff --git a/src/share/bin/wildcard.c b/src/share/bin/wildcard.c index f8f664450e362c73c22e58a36c86cc9b589bfd72..96dac738aa08a75521f73279a473c01f55a45f7c 100644 --- a/src/share/bin/wildcard.c +++ b/src/share/bin/wildcard.c @@ -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; diff --git a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java index d281e11c8c8a5431a3522362412c5bcbf68b771d..0fbdefb8e0e14898e24fea1b28a4e63e194b9bd7 100644 --- a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java +++ b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java @@ -790,16 +790,12 @@ public class GIFImageReader extends ImageReader { } private void startPass(int pass) { - if (updateListeners == null) { + if (updateListeners == null || !imageMetadata.interlaceFlag) { return; } - int y = 0; - int yStep = 1; - if (imageMetadata.interlaceFlag) { - y = interlaceOffset[interlacePass]; - yStep = interlaceIncrement[interlacePass]; - } + int y = interlaceOffset[interlacePass]; + int yStep = interlaceIncrement[interlacePass]; int[] vals = ReaderUtil. computeUpdatedPixels(sourceRegion, diff --git a/src/share/classes/com/sun/java/util/jar/pack/Attribute.java b/src/share/classes/com/sun/java/util/jar/pack/Attribute.java index a6033c97b142655a4df82906bdd2d462e8e48e61..19a7a08598ed20741dfd85b7de8f8c4425b417f5 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Attribute.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Attribute.java @@ -99,6 +99,7 @@ class Attribute implements Comparable { return this == def.canon; } + @Override public int compareTo(Attribute that) { return this.def.compareTo(that.def); } @@ -212,20 +213,20 @@ class Attribute implements Comparable { // 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 { +"\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 { +"\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 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) { - define(sd, ctype, - "RuntimeVisibleParameterAnnotations", paramsLayout); + if (ctype != ATTR_CONTEXT_CODE) { define(sd, ctype, - "RuntimeInvisibleParameterAnnotations", paramsLayout); + "RuntimeVisibleAnnotations", annotationsLayout); 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 { 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 { && 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 { 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 { // 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 { return def.unparse(in, out); } + @Override public String toString() { return def +"{"+(bytes == null ? -1 : size())+"}" @@ -1309,7 +1364,7 @@ class Attribute implements Comparable { } out.putRef(bandIndex, globalRef); break; - default: assert(false); continue; + default: assert(false); } } return pos; @@ -1416,8 +1471,7 @@ class Attribute implements Comparable { 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 diff --git a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java index 322e2c333260148606a1cc82866e190fabc08fa5..1152aa73f0c2f38132550deedcc74c19bd05d1d3 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java +++ b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java @@ -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 - - // 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_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")); + + 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 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); diff --git a/src/share/classes/com/sun/java/util/jar/pack/Code.java b/src/share/classes/com/sun/java/util/jar/pack/Code.java index e84cdaa59a0915975e5433ccb1e9557ff476b804..423b0d7f779add9463ce52115b0a01558d0c6274 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Code.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Code.java @@ -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); diff --git a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java index 1ede29134b0c250dc6831d82a5afa9930e22b5e7..4f64ef41b7a3ed97bba06151294b23058f3a250e 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java +++ b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java @@ -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;" => {"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; diff --git a/src/share/classes/com/sun/java/util/jar/pack/Constants.java b/src/share/classes/com/sun/java/util/jar/pack/Constants.java index 5059bc07967273f811e893c750df10d8d39a4736..15991700f25714348653ed396a9ee8ea711fbe75 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Constants.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Constants.java @@ -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, diff --git a/src/share/classes/com/sun/java/util/jar/pack/Fixups.java b/src/share/classes/com/sun/java/util/jar/pack/Fixups.java index 0c99351222ae98155e14f5263ef48e48f426c126..647d1dbc4134ef7a9bfbb0a9fc2f553c9adf2ab1 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Fixups.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Fixups.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -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 { 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 { } } + @Override public void clear() { if (bytes != null) { // Clean the bytes: @@ -141,16 +144,16 @@ final class Fixups extends AbstractCollection { 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 { } } + 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 { @@ -248,15 +259,25 @@ final class Fixups extends AbstractCollection { 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 { 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 { } } + @Override public Iterator 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 c) { if (c instanceof Fixups) { // Use knowledge of Itr structure to avoid building little structs. @@ -367,7 +394,13 @@ final class Fixups extends AbstractCollection { } /// 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) { diff --git a/src/share/classes/com/sun/java/util/jar/pack/Package.java b/src/share/classes/com/sun/java/util/jar/pack/Package.java index 64f9db5c3098c957bc981fd8e91c48e80432ddeb..af78754e06b0c56f9e4a5030b9c7cf661f936e67 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Package.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Package.java @@ -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())) { diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java index b42dda30eb45983a570b894a3de3dd9cddefd818..000a643f873351d6e3756136d47973b925368356 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java @@ -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 in classRef. MemberEntry ref = pkg.cp.getOverloadingForIndex(CONSTANT_Methodref, classRef, "", 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) { diff --git a/src/share/classes/com/sun/jndi/dns/DnsContext.java b/src/share/classes/com/sun/jndi/dns/DnsContext.java index 24f7343ac70a22dbf2be5da107c690ba4f41aa0b..3c0b6a53137f63f105ec97f5a4633fb87151f268 100644 --- a/src/share/classes/com/sun/jndi/dns/DnsContext.java +++ b/src/share/classes/com/sun/jndi/dns/DnsContext.java @@ -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) 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; diff --git a/src/share/classes/com/sun/jndi/ldap/BasicControl.java b/src/share/classes/com/sun/jndi/ldap/BasicControl.java index d068704142a2d588a9fa3879e1e2715176e47837..007a40cb2e5d081411e65ffd5b0fac6fab0167da 100644 --- a/src/share/classes/com/sun/jndi/ldap/BasicControl.java +++ b/src/share/classes/com/sun/jndi/ldap/BasicControl.java @@ -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(); } } diff --git a/src/share/classes/com/sun/jndi/ldap/BerDecoder.java b/src/share/classes/com/sun/jndi/ldap/BerDecoder.java index 44b46f844b824f6bf32c73affe577e74be127a1c..55b46d36322d1077678b6e22e1b37a308aec5790 100644 --- a/src/share/classes/com/sun/jndi/ldap/BerDecoder.java +++ b/src/share/classes/com/sun/jndi/ldap/BerDecoder.java @@ -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; diff --git a/src/share/classes/com/sun/jndi/ldap/BerEncoder.java b/src/share/classes/com/sun/jndi/ldap/BerEncoder.java index fc8566dad4906c1686f51a1eee56235ec9c23e6f..a641b0dd7a46bcf26fe31856671337f00919a378 100644 --- a/src/share/classes/com/sun/jndi/ldap/BerEncoder.java +++ b/src/share/classes/com/sun/jndi/ldap/BerEncoder.java @@ -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. } /** diff --git a/src/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java b/src/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java index 737036155ce3612d4f76a2818c587789e10a2c60..28745bdb0d5003925f74fc7a9667746f5ad69d0a 100644 --- a/src/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java +++ b/src/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java @@ -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(); } /** diff --git a/src/share/classes/com/sun/script/javascript/ExternalScriptable.java b/src/share/classes/com/sun/script/javascript/ExternalScriptable.java deleted file mode 100644 index 856562085d4349c05047cf0cc97958f0d394a29d..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/ExternalScriptable.java +++ /dev/null @@ -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 indexedProps; - - // my prototype - private Scriptable prototype; - // my parent scope, if any - private Scriptable parent; - - ExternalScriptable(ScriptContext context) { - this(context, new HashMap()); - } - - ExternalScriptable(ScriptContext context, Map 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.

- * - * A hint 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 list = new ArrayList(); - 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; - } - } -} diff --git a/src/share/classes/com/sun/script/javascript/JSAdapter.java b/src/share/classes/com/sun/script/javascript/JSAdapter.java deleted file mode 100644 index 53497e95f625ead1622e7228bc1fba9215beb84e..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/JSAdapter.java +++ /dev/null @@ -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__"; -} diff --git a/src/share/classes/com/sun/script/javascript/JavaAdapter.java b/src/share/classes/com/sun/script/javascript/JavaAdapter.java deleted file mode 100644 index 4e670065f63d6fb34ae5fc33b22112fc0d2e0506..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/JavaAdapter.java +++ /dev/null @@ -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; -} diff --git a/src/share/classes/com/sun/script/javascript/META-INF/services/javax.script.ScriptEngineFactory b/src/share/classes/com/sun/script/javascript/META-INF/services/javax.script.ScriptEngineFactory deleted file mode 100644 index de576fbc308150b7c14d310d329e80f886b12eea..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/META-INF/services/javax.script.ScriptEngineFactory +++ /dev/null @@ -1,5 +0,0 @@ - -#script engines supported - -com.sun.script.javascript.RhinoScriptEngineFactory #javascript - diff --git a/src/share/classes/com/sun/script/javascript/RhinoClassShutter.java b/src/share/classes/com/sun/script/javascript/RhinoClassShutter.java deleted file mode 100644 index ea376e8c4b0e0afe6ea161da6de4835051bec62f..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/RhinoClassShutter.java +++ /dev/null @@ -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 protectedClasses; - private static RhinoClassShutter theInstance; - - private RhinoClassShutter() { - } - - static synchronized ClassShutter getInstance() { - if (theInstance == null) { - theInstance = new RhinoClassShutter(); - protectedClasses = new HashMap(); - - // 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; - } -} diff --git a/src/share/classes/com/sun/script/javascript/RhinoCompiledScript.java b/src/share/classes/com/sun/script/javascript/RhinoCompiledScript.java deleted file mode 100644 index 4c6a82481c5726d050bdd6076afac217a7aba7a5..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/RhinoCompiledScript.java +++ /dev/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; - } - -} diff --git a/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java b/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java deleted file mode 100644 index d168a76437e0d1b9543f6e5b7393245f6a945d82..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java +++ /dev/null @@ -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 ScriptEngine 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 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(); - - //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 ? "" : 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 getInterface(Class clasz) { - try { - return implementor.getInterface(null, clasz); - } catch (ScriptException e) { - return null; - } - } - - public T getInterface(Object thiz, Class 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 = ""; - } - - 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")); - } - */ -} diff --git a/src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java b/src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java deleted file mode 100644 index c81ac796d9bbea7bd6ce07b7fb38f1f3388440f1..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java +++ /dev/null @@ -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 getExtensions() { - return extensions; - } - - public List getMimeTypes() { - return mimeTypes; - } - - public List 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 names; - private static List mimeTypes; - private static List extensions; - - static { - names = new ArrayList(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(4); - mimeTypes.add("application/javascript"); - mimeTypes.add("application/ecmascript"); - mimeTypes.add("text/javascript"); - mimeTypes.add("text/ecmascript"); - mimeTypes = Collections.unmodifiableList(mimeTypes); - - extensions = new ArrayList(1); - extensions.add("js"); - extensions = Collections.unmodifiableList(extensions); - } -} diff --git a/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java b/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java deleted file mode 100644 index 45295bb783351d7ce61be0e20af8b4346658f210..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java +++ /dev/null @@ -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 this 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; -} diff --git a/src/share/classes/com/sun/script/javascript/RhinoWrapFactory.java b/src/share/classes/com/sun/script/javascript/RhinoWrapFactory.java deleted file mode 100644 index 906ffbab5bb68f1b9017b74416f22e82133f7a3e..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/javascript/RhinoWrapFactory.java +++ /dev/null @@ -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); - } - } -} diff --git a/src/share/classes/com/sun/script/util/BindingsBase.java b/src/share/classes/com/sun/script/util/BindingsBase.java deleted file mode 100644 index de0704cb1644f6f90de98905752ba2a0cdc3b532..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/util/BindingsBase.java +++ /dev/null @@ -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 - 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 toMerge) { - for (Map.Entry 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"); - } - } -} diff --git a/src/share/classes/com/sun/script/util/BindingsEntrySet.java b/src/share/classes/com/sun/script/util/BindingsEntrySet.java deleted file mode 100644 index 375584411069822065d10ca509356aa16d229124..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/util/BindingsEntrySet.java +++ /dev/null @@ -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> { - - private BindingsBase base; - private String[] keys; - - public BindingsEntrySet(BindingsBase base) { - this.base = base; - keys = base.getNames(); - } - - public int size() { - return keys.length; - } - - public Iterator> iterator() { - return new BindingsIterator(); - } - - public class BindingsEntry implements Map.Entry { - 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> { - - 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]); - } - - } - -} diff --git a/src/share/classes/com/sun/script/util/BindingsImpl.java b/src/share/classes/com/sun/script/util/BindingsImpl.java deleted file mode 100644 index 44eed886565175dd6eb71c2aae6bb681cab4bc10..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/util/BindingsImpl.java +++ /dev/null @@ -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> 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; - } -} diff --git a/src/share/classes/com/sun/script/util/InterfaceImplementor.java b/src/share/classes/com/sun/script/util/InterfaceImplementor.java deleted file mode 100644 index 7e94c962f5c518be888caec47c925fff045c7394..0000000000000000000000000000000000000000 --- a/src/share/classes/com/sun/script/util/InterfaceImplementor.java +++ /dev/null @@ -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() { - 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 getInterface(Object thiz, Class 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; - } -} diff --git a/src/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java b/src/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java index 07072e3c898f88a823620155f18662c7e9dbc861..44cee0bf7b9368ed98cd18f81cbe7ca7b55a7520 100644 --- a/src/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java +++ b/src/share/classes/com/sun/security/sasl/digest/DigestMD5Client.java @@ -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); diff --git a/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java b/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java index 1299201267ae1a32a0d6d5f7fbe71570559bb606..736da0a05d3d569fe52ef23a301c9a45ebd78744 100644 --- a/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java +++ b/src/share/classes/com/sun/tools/jdi/AbstractLauncher.java @@ -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 { diff --git a/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java b/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java index b5086fd9d5fbeb2d413677d6999355e9fece5036..20be57c85c4a9845839c060617614f55a1ba870b 100644 --- a/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java +++ b/src/share/classes/com/sun/tools/jdi/SunCommandLineLauncher.java @@ -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; } diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java index 0dfb99996db5c8fe159040ef043351539af0da62..846ea97645055418b089578c7d8ef2da4f3fc06b 100644 --- a/src/share/classes/java/awt/Component.java +++ b/src/share/classes/java/awt/Component.java @@ -1671,6 +1671,15 @@ public abstract class Component implements ImageObserver, MenuContainer, /* do nothing */ } + /* + * Delete references from LightweithDispatcher of a heavyweight parent + */ + void clearLightweightDispatcherOnRemove(Component removedComponent) { + if (parent != null) { + parent.clearLightweightDispatcherOnRemove(removedComponent); + } + } + /** * @deprecated As of JDK version 1.1, * replaced by setVisible(boolean). @@ -6974,6 +6983,8 @@ public abstract class Component implements ImageObserver, MenuContainer, } synchronized (getTreeLock()) { + clearLightweightDispatcherOnRemove(this); + if (isFocusOwner() && KeyboardFocusManager.isAutoFocusTransferEnabledFor(this)) { transferFocus(true); } diff --git a/src/share/classes/java/awt/Container.java b/src/share/classes/java/awt/Container.java index 1118852f0e9dc3e2d4f8a834ec1e87450ff1de20..1525a7497c22d056fbe308d3b532b024198574e4 100644 --- a/src/share/classes/java/awt/Container.java +++ b/src/share/classes/java/awt/Container.java @@ -3306,6 +3306,16 @@ public class Container extends Component { } } + @Override + void clearLightweightDispatcherOnRemove(Component removedComponent) { + if (dispatcher != null) { + dispatcher.removeReferences(removedComponent); + } else { + //It is a Lightweight Container, should clear parent`s Dispatcher + super.clearLightweightDispatcherOnRemove(removedComponent); + } + } + final Container getTraversalRoot() { if (isFocusCycleRoot()) { return findTraversalRoot(); @@ -4411,6 +4421,7 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { //System.out.println("Disposing lw dispatcher"); stopListeningForOtherDrags(); mouseEventTarget = null; + targetLastEntered = null; } /** @@ -4502,6 +4513,7 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { // MOUSE_CLICKED. if (!isMouseGrab(e) && id != MouseEvent.MOUSE_CLICKED) { mouseEventTarget = (mouseOver != nativeContainer) ? mouseOver: null; + isCleaned = false; } if (mouseEventTarget != null) { @@ -4545,10 +4557,14 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { retargetMouseEvent(mouseOver, id, e); break; } - //Consuming of wheel events is implemented in "retargetMouseEvent". - if (id != MouseEvent.MOUSE_WHEEL) { - e.consume(); - } + //Consuming of wheel events is implemented in "retargetMouseEvent". + if (id != MouseEvent.MOUSE_WHEEL) { + e.consume(); + } + } else if (isCleaned && id != MouseEvent.MOUSE_WHEEL) { + //After mouseEventTarget was removed and cleaned should consume all events + //until new mouseEventTarget is found + e.consume(); } return e.isConsumed(); } @@ -4891,6 +4907,11 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { */ private transient Component targetLastEntered; + /** + * Indicates whether {@code mouseEventTarget} was removed and nulled + */ + private transient boolean isCleaned; + /** * Is the mouse over the native container */ @@ -4925,4 +4946,14 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK; + + void removeReferences(Component removedComponent) { + if (mouseEventTarget == removedComponent) { + isCleaned = true; + mouseEventTarget = null; + } + if (targetLastEntered == removedComponent) { + targetLastEntered = null; + } + } } diff --git a/src/share/classes/java/io/BufferedReader.java b/src/share/classes/java/io/BufferedReader.java index 556abb2a403a4d5d326d75a7fefc61f822a8bdf1..d742233a0fd6002fc85955afc43292633f99b2f4 100644 --- a/src/share/classes/java/io/BufferedReader.java +++ b/src/share/classes/java/io/BufferedReader.java @@ -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 + * terminal + * stream operation. + * + *

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. + * + *

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. + * + *

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} providing the lines of text + * described by this {@code BufferedReader} + * + * @since 1.8 + */ + public Stream lines() { + Iterator iter = new Iterator() { + 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)); + } } diff --git a/src/share/classes/java/io/File.java b/src/share/classes/java/io/File.java index dd313dd97d07872182231c1563f9cce9d8b24f47..1f1d044b1abe6ad7b7cab69ff3dac9a18cbf0075 100644 --- a/src/share/classes/java/io/File.java +++ b/src/share/classes/java/io/File.java @@ -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 0L + * @return The number of unallocated bytes on the partition or 0L * 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; } diff --git a/src/share/classes/java/io/FileInputStream.java b/src/share/classes/java/io/FileInputStream.java index d796bf090f04d7411aca056fcfa8ccc858983cac..740b6744047a50e27c7fbc40061610f762ec0575 100644 --- a/src/share/classes/java/io/FileInputStream.java +++ b/src/share/classes/java/io/FileInputStream.java @@ -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); diff --git a/src/share/classes/java/io/FileOutputStream.java b/src/share/classes/java/io/FileOutputStream.java index 50bd29bef5f46911f4566c1506c2849047716553..928e4f3cf15d4ea7f7134c64061af03d3b1deac8 100644 --- a/src/share/classes/java/io/FileOutputStream.java +++ b/src/share/classes/java/io/FileOutputStream.java @@ -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; diff --git a/src/share/classes/java/io/RandomAccessFile.java b/src/share/classes/java/io/RandomAccessFile.java index cf1e5c7cef46337826dae10e05aed0ba601908a7..adccfbc757a9e73935ee406dd64ee046eff5826b 100644 --- a/src/share/classes/java/io/RandomAccessFile.java +++ b/src/share/classes/java/io/RandomAccessFile.java @@ -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); diff --git a/src/share/classes/java/io/UncheckedIOException.java b/src/share/classes/java/io/UncheckedIOException.java new file mode 100644 index 0000000000000000000000000000000000000000..22c43e380797db4e6e0cc7fe28cedb9b0f3a5065 --- /dev/null +++ b/src/share/classes/java/io/UncheckedIOException.java @@ -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"); + } +} diff --git a/src/share/classes/java/lang/ProcessBuilder.java b/src/share/classes/java/lang/ProcessBuilder.java index 64f56d778295ee881e71fd467d9656760016d161..b467f45c3510630cd31be7b7ff790999167a4f01 100644 --- a/src/share/classes/java/lang/ProcessBuilder.java +++ b/src/share/classes/java/lang/ProcessBuilder.java @@ -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); diff --git a/src/share/classes/java/lang/StringBuffer.java b/src/share/classes/java/lang/StringBuffer.java index f31a53c98e66b260eee7c69de12f656d4637ef09..8ead0721ffd8edacc67ce66edfbab2371f802153 100644 --- a/src/share/classes/java/lang/StringBuffer.java +++ b/src/share/classes/java/lang/StringBuffer.java @@ -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); } /** diff --git a/src/share/classes/java/lang/System.java b/src/share/classes/java/lang/System.java index c7f69f5e49660adda8844073e0d73601f2bac4fa..bd72188c6b03e7065c24ac463b245306e28d6f90 100644 --- a/src/share/classes/java/lang/System.java +++ b/src/share/classes/java/lang/System.java @@ -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); + } }); } } diff --git a/src/share/classes/java/lang/invoke/MemberName.java b/src/share/classes/java/lang/invoke/MemberName.java index 59096015acc424d13fd26117cdac91d9af8324be..dfb468417d6cfa24cf4b2c38e0f9494b4f5c6b32 100644 --- a/src/share/classes/java/lang/invoke/MemberName.java +++ b/src/share/classes/java/lang/invoke/MemberName.java @@ -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()); diff --git a/src/share/classes/java/lang/reflect/Executable.java b/src/share/classes/java/lang/reflect/Executable.java index 78a1db91e81040bcef3bdf5f317fd47378b8dc7f..00e08a6437503d7817a36e8d199c966878d57e99 100644 --- a/src/share/classes/java/lang/reflect/Executable.java +++ b/src/share/classes/java/lang/reflect/Executable.java @@ -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); } } diff --git a/src/share/classes/java/lang/reflect/Field.java b/src/share/classes/java/lang/reflect/Field.java index a25223f68c10eca04fa3843caea25bac65579977..8b2603a663ef3fdc8b678efea9d1d10a0403a3ba 100644 --- a/src/share/classes/java/lang/reflect/Field.java +++ b/src/share/classes/java/lang/reflect/Field.java @@ -1161,6 +1161,6 @@ class Field extends AccessibleObject implements Member { this, getDeclaringClass(), getGenericType(), - TypeAnnotation.TypeAnnotationTarget.FIELD_TYPE); + TypeAnnotation.TypeAnnotationTarget.FIELD); } } diff --git a/src/share/classes/java/lang/reflect/Modifier.java b/src/share/classes/java/lang/reflect/Modifier.java index 227beeedd79e9a39509962ef7ca9c4f33bc3e159..7387bbeaa75a7b708f49c7a276ecbecced25eecb 100644 --- a/src/share/classes/java/lang/reflect/Modifier.java +++ b/src/share/classes/java/lang/reflect/Modifier.java @@ -350,8 +350,19 @@ public class Modifier { return (mod & MANDATED) != 0; } - /** - * See JLSv3 section 8.1.1. + // 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. + + /** + * 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; + } } diff --git a/src/share/classes/java/lang/reflect/Parameter.java b/src/share/classes/java/lang/reflect/Parameter.java index 57097e02c6f37de6594da51480e8b1c68a743033..c50e0febe41121575284d286fea8a437bf0e3fcc 100644 --- a/src/share/classes/java/lang/reflect/Parameter.java +++ b/src/share/classes/java/lang/reflect/Parameter.java @@ -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; /** diff --git a/src/share/classes/java/lang/reflect/Proxy.java b/src/share/classes/java/lang/reflect/Proxy.java index 66e06ea8d1cf01eb2a7aedf1e2e0b0aa0193bfb1..dd5c2ad433606aea340cf614cbb965a4ee7c4ac3 100644 --- a/src/share/classes/java/lang/reflect/Proxy.java +++ b/src/share/classes/java/lang/reflect/Proxy.java @@ -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) { diff --git a/src/share/classes/java/net/HttpURLConnection.java b/src/share/classes/java/net/HttpURLConnection.java index d52c26789faa4bd8763f992f248cadb8e661d846..193b9cef1c1d89b7c867e9de913b5d49b631feba 100644 --- a/src/share/classes/java/net/HttpURLConnection.java +++ b/src/share/classes/java/net/HttpURLConnection.java @@ -50,6 +50,18 @@ import java.util.Date; * Proxy settings as well as * various other settings. *

+ *

+ * Security permissions + *

+ * 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:- + *

  • a "connect" {@link SocketPermission} to the host/port combination of the + * destination URL or
  • + *
  • a {@link HttpURLPermission} that permits this request.
  • + *

+ * 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 diff --git a/src/share/classes/java/net/HttpURLPermission.java b/src/share/classes/java/net/HttpURLPermission.java new file mode 100644 index 0000000000000000000000000000000000000000..52d6e79344a776ad15b70a0b738e3ba29dd266c3 --- /dev/null +++ b/src/share/classes/java/net/HttpURLPermission.java @@ -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 name of the permission is the url string. + * The actions string is a concatenation of the request methods and headers. + * The range of method and header names is not restricted by this class. + *

The url

+ * 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: + * + * + * + * + * + * + * + * + * + * + *
Example urlDescription
http://www.oracle.com/a/b/c.htmlA url which identifies a specific (single) resource
http://www.oracle.com/a/b/*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 '*'. + *
http://www.oracle.com/a/b/- + * 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). + *
+ *

+ * 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. + *

+ * As a special case, urls of the form, "http:*" or "https:*" are accepted to + * mean any url of the given scheme. + *

The actions string

+ * The actions string of a HttpURLPermission is a concatenation of the method list + * and the request headers list. 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: + *

+ *         "POST,GET,DELETE"
+ *         "GET:X-Foo-Request,X-Bar-Request"
+ *         "POST,GET:Header1,Header2"
+ * 
+ * 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. + *

+ * 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. + *

+ * 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 methods; + private transient List 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 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: + *

+     *      "method-names : header-names"
+     * 
+ *

+ * 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: + *