提交 9f5e5109 编写于 作者: J jqzuo

Merge

...@@ -81,3 +81,4 @@ d58354a69011f3d3354765fa3167567c4c4a9612 jdk7-b101 ...@@ -81,3 +81,4 @@ d58354a69011f3d3354765fa3167567c4c4a9612 jdk7-b101
1a92820132a0221c5bdedd42d0888c57ce4cbb34 jdk7-b104 1a92820132a0221c5bdedd42d0888c57ce4cbb34 jdk7-b104
3b0abcb512807bb6f6d27755bc50103211bde6ee jdk7-b105 3b0abcb512807bb6f6d27755bc50103211bde6ee jdk7-b105
b91ef6b60f4e19bf4592c6dd594c9bac62487519 jdk7-b106 b91ef6b60f4e19bf4592c6dd594c9bac62487519 jdk7-b106
882103f334bb23745d3fd70fb7928c347478b0f4 jdk7-b107
...@@ -89,7 +89,7 @@ define FullPath ...@@ -89,7 +89,7 @@ define FullPath
$(shell $(CYGPATH_CMD) $1 2> $(DEV_NULL)) $(shell $(CYGPATH_CMD) $1 2> $(DEV_NULL))
endef endef
define OptFullPath define OptFullPath
$(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1"; else echo "$1"; fi) $(shell if [ "$1" != "" -a -d "$1" ]; then $(CYGPATH_CMD) "$1" 2> $(DEV_NULL); else echo "$1"; fi)
endef endef
else else
# Temporary until we upgrade to MKS 8.7, MKS pwd returns mixed mode path # Temporary until we upgrade to MKS 8.7, MKS pwd returns mixed mode path
......
...@@ -136,15 +136,20 @@ define GetVersion ...@@ -136,15 +136,20 @@ define GetVersion
$(shell echo $1 | sed -e 's@[^0-9]*\([0-9][0-9]*\.[0-9][.0-9]*\).*@\1@' ) $(shell echo $1 | sed -e 's@[^0-9]*\([0-9][0-9]*\.[0-9][.0-9]*\).*@\1@' )
endef endef
# Return one part of the version numbers, watch out for non digits.
define VersionWord # Number Version
$(word $1,$(subst ., ,$(subst -, ,$2)))
endef
# Given a major.minor.micro version, return the major, minor, or micro number # Given a major.minor.micro version, return the major, minor, or micro number
define MajorVersion define MajorVersion
$(if $(word 1, $(subst ., ,$1)),$(word 1, $(subst ., ,$1)),0) $(if $(call VersionWord,1,$1),$(call VersionWord,1,$1),0)
endef endef
define MinorVersion define MinorVersion
$(if $(word 2, $(subst ., ,$1)),$(word 2, $(subst ., ,$1)),0) $(if $(call VersionWord,2,$1),$(call VersionWord,2,$1),0)
endef endef
define MicroVersion define MicroVersion
$(if $(word 3, $(subst ., ,$1)),$(word 3, $(subst ., ,$1)),0) $(if $(call VersionWord,3,$1),$(call VersionWord,3,$1),0)
endef endef
# Macro that returns missing, same, newer, or older $1=version $2=required # Macro that returns missing, same, newer, or older $1=version $2=required
......
...@@ -340,6 +340,10 @@ PATH="${path4sdk}" ...@@ -340,6 +340,10 @@ PATH="${path4sdk}"
export PATH export PATH
# Export variables required for Zero # Export variables required for Zero
if [ "${SHARK_BUILD}" = true ] ; then
ZERO_BUILD=true
export ZERO_BUILD
fi
if [ "${ZERO_BUILD}" = true ] ; then if [ "${ZERO_BUILD}" = true ] ; then
# ZERO_LIBARCH is the name of the architecture-specific # ZERO_LIBARCH is the name of the architecture-specific
# subdirectory under $JAVA_HOME/jre/lib # subdirectory under $JAVA_HOME/jre/lib
...@@ -417,4 +421,55 @@ if [ "${ZERO_BUILD}" = true ] ; then ...@@ -417,4 +421,55 @@ if [ "${ZERO_BUILD}" = true ] ; then
fi fi
export LIBFFI_CFLAGS export LIBFFI_CFLAGS
export LIBFFI_LIBS export LIBFFI_LIBS
# LLVM_CFLAGS, LLVM_LDFLAGS and LLVM_LIBS tell the compiler how to
# compile and link against LLVM
if [ "${SHARK_BUILD}" = true ] ; then
if [ "${LLVM_CONFIG}" = "" ] ; then
LLVM_CONFIG=$(which llvm-config 2>/dev/null)
fi
if [ ! -x "${LLVM_CONFIG}" ] ; then
echo "ERROR: Unable to locate llvm-config"
exit 1
fi
llvm_components="jit engine nativecodegen"
unset LLVM_CFLAGS
for flag in $("${LLVM_CONFIG}" --cxxflags $llvm_components); do
if echo "${flag}" | grep -q '^-[ID]'; then
if [ "${flag}" != "-D_DEBUG" ] ; then
if [ "${LLVM_CFLAGS}" != "" ] ; then
LLVM_CFLAGS="${LLVM_CFLAGS} "
fi
LLVM_CFLAGS="${LLVM_CFLAGS}${flag}"
fi
fi
done
llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//')
LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}"
unset LLVM_LDFLAGS
for flag in $("${LLVM_CONFIG}" --ldflags $llvm_components); do
if echo "${flag}" | grep -q '^-L'; then
if [ "${LLVM_LDFLAGS}" != "" ] ; then
LLVM_LDFLAGS="${LLVM_LDFLAGS} "
fi
LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}"
fi
done
unset LLVM_LIBS
for flag in $("${LLVM_CONFIG}" --libs $llvm_components); do
if echo "${flag}" | grep -q '^-l'; then
if [ "${LLVM_LIBS}" != "" ] ; then
LLVM_LIBS="${LLVM_LIBS} "
fi
LLVM_LIBS="${LLVM_LIBS}${flag}"
fi
done
export LLVM_CFLAGS
export LLVM_LDFLAGS
export LLVM_LIBS
fi
fi fi
...@@ -21,4 +21,4 @@ ...@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any # or visit www.oracle.com if you need additional information or have any
# questions. # questions.
# #
tzdata2010i tzdata2010l
...@@ -316,8 +316,25 @@ Rule Egypt 2007 only - Sep Thu>=1 23:00s 0 - ...@@ -316,8 +316,25 @@ Rule Egypt 2007 only - Sep Thu>=1 23:00s 0 -
# and can be found by searching for "winter" in their search engine # and can be found by searching for "winter" in their search engine
# (at least today). # (at least today).
# From Alexander Krivenyshev (2010-07-20):
# According to News from Egypt - Al-Masry Al-Youm Egypt's cabinet has
# decided that Daylight Saving Time will not be used in Egypt during
# Ramadan.
#
# Arabic translation:
# "Clocks to go back during Ramadan--and then forward again"
# <a href="http://www.almasryalyoum.com/en/news/clocks-go-back-during-ramadan-and-then-forward-again">
# http://www.almasryalyoum.com/en/news/clocks-go-back-during-ramadan-and-then-forward-again
# </a>
# or
# <a href="http://www.worldtimezone.com/dst_news/dst_news_egypt02.html">
# http://www.worldtimezone.com/dst_news/dst_news_egypt02.html
# </a>
Rule Egypt 2008 only - Aug lastThu 23:00s 0 - Rule Egypt 2008 only - Aug lastThu 23:00s 0 -
Rule Egypt 2009 only - Aug 20 23:00s 0 - Rule Egypt 2009 only - Aug 20 23:00s 0 -
Rule Egypt 2010 only - Aug 11 0:00 0 -
Rule Egypt 2010 only - Sep 10 0:00 1:00 S
Rule Egypt 2010 max - Sep lastThu 23:00s 0 - Rule Egypt 2010 max - Sep lastThu 23:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
......
...@@ -2200,6 +2200,18 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 ...@@ -2200,6 +2200,18 @@ Zone Asia/Karachi 4:28:12 - LMT 1907
# "At 12:01am Friday, clocks in Israel and the West Bank will change to # "At 12:01am Friday, clocks in Israel and the West Bank will change to
# 1:01am, while Gaza clocks will change at 12:01am Saturday morning." # 1:01am, while Gaza clocks will change at 12:01am Saturday morning."
# From Steffen Thorsen (2010-08-11):
# According to several sources, including
# <a href="http://www.maannews.net/eng/ViewDetails.aspx?ID=306795">
# http://www.maannews.net/eng/ViewDetails.aspx?ID=306795
# </a>
# the clocks were set back one hour at 2010-08-11 00:00:00 local time in
# Gaza and the West Bank.
# Some more background info:
# <a href="http://www.timeanddate.com/news/time/westbank-gaza-end-dst-2010.html">
# http://www.timeanddate.com/news/time/westbank-gaza-end-dst-2010.html
# </a>
# The rules for Egypt are stolen from the `africa' file. # The rules for Egypt are stolen from the `africa' file.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule EgyptAsia 1957 only - May 10 0:00 1:00 S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S
...@@ -2220,6 +2232,7 @@ Rule Palestine 2008 only - Aug lastFri 2:00 0 - ...@@ -2220,6 +2232,7 @@ Rule Palestine 2008 only - Aug lastFri 2:00 0 -
Rule Palestine 2009 only - Mar lastFri 0:00 1:00 S Rule Palestine 2009 only - Mar lastFri 0:00 1:00 S
Rule Palestine 2010 max - Mar lastSat 0:01 1:00 S Rule Palestine 2010 max - Mar lastSat 0:01 1:00 S
Rule Palestine 2009 max - Sep Fri>=1 2:00 0 - Rule Palestine 2009 max - Sep Fri>=1 2:00 0 -
Rule Palestine 2010 only - Aug 11 0:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Gaza 2:17:52 - LMT 1900 Oct Zone Asia/Gaza 2:17:52 - LMT 1900 Oct
......
...@@ -368,10 +368,10 @@ Zone Pacific/Kwajalein 11:09:20 - LMT 1901 ...@@ -368,10 +368,10 @@ Zone Pacific/Kwajalein 11:09:20 - LMT 1901
# Micronesia # Micronesia
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Truk 10:07:08 - LMT 1901 Zone Pacific/Chuuk 10:07:08 - LMT 1901
10:00 - TRUT # Truk Time 10:00 - CHUT # Chuuk Time
Zone Pacific/Ponape 10:32:52 - LMT 1901 # Kolonia Zone Pacific/Pohnpei 10:32:52 - LMT 1901 # Kolonia
11:00 - PONT # Ponape Time 11:00 - PONT # Pohnpei Time
Zone Pacific/Kosrae 10:51:56 - LMT 1901 Zone Pacific/Kosrae 10:51:56 - LMT 1901
11:00 - KOST 1969 Oct # Kosrae Time 11:00 - KOST 1969 Oct # Kosrae Time
12:00 - KOST 1999 12:00 - KOST 1999
......
...@@ -112,7 +112,9 @@ Link Pacific/Chatham NZ-CHAT ...@@ -112,7 +112,9 @@ Link Pacific/Chatham NZ-CHAT
Link America/Denver Navajo Link America/Denver Navajo
Link Asia/Shanghai PRC Link Asia/Shanghai PRC
Link Pacific/Pago_Pago Pacific/Samoa Link Pacific/Pago_Pago Pacific/Samoa
Link Pacific/Truk Pacific/Yap Link Pacific/Chuuk Pacific/Yap
Link Pacific/Chuuk Pacific/Truk
Link Pacific/Pohnpei Pacific/Ponape
Link Europe/Warsaw Poland Link Europe/Warsaw Poland
Link Europe/Lisbon Portugal Link Europe/Lisbon Portugal
Link Asia/Taipei ROC Link Asia/Taipei ROC
......
...@@ -1035,22 +1035,47 @@ Zone Europe/Tallinn 1:39:00 - LMT 1880 ...@@ -1035,22 +1035,47 @@ Zone Europe/Tallinn 1:39:00 - LMT 1880
2:00 EU EE%sT 2:00 EU EE%sT
# Finland # Finland
#
# From Hannu Strang (1994-09-25 06:03:37 UTC): # From Hannu Strang (1994-09-25 06:03:37 UTC):
# Well, here in Helsinki we're just changing from summer time to regular one, # Well, here in Helsinki we're just changing from summer time to regular one,
# and it's supposed to change at 4am... # and it's supposed to change at 4am...
# From Janne Snabb (2010-0715):
# #
# From Paul Eggert (2006-03-22): # I noticed that the Finland data is not accurate for years 1981 and 1982.
# Shanks & Pottenger say Finland has switched at 02:00 standard time # During these two first trial years the DST adjustment was made one hour
# since 1981. Go with Strang instead. # earlier than in forthcoming years. Starting 1983 the adjustment was made
# according to the central European standards.
#
# This is documented in Heikki Oja: Aikakirja 2007, published by The Almanac
# Office of University of Helsinki, ISBN 952-10-3221-9, available online (in
# Finnish) at
#
# <a href="http://almanakka.helsinki.fi/aikakirja/Aikakirja2007kokonaan.pdf">
# http://almanakka.helsinki.fi/aikakirja/Aikakirja2007kokonaan.pdf
# </a>
#
# Page 105 (56 in PDF version) has a handy table of all past daylight savings
# transitions. It is easy enough to interpret without Finnish skills.
#
# This is also confirmed by Finnish Broadcasting Company's archive at:
# #
# <a href="http://www.yle.fi/elavaarkisto/?s=s&g=1&ag=5&t=&a=3401">
# http://www.yle.fi/elavaarkisto/?s=s&g=1&ag=5&t=&a=3401
# </a>
#
# The news clip from 1981 says that "the time between 2 and 3 o'clock does not
# exist tonight."
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Finland 1942 only - Apr 3 0:00 1:00 S Rule Finland 1942 only - Apr 3 0:00 1:00 S
Rule Finland 1942 only - Oct 3 0:00 0 - Rule Finland 1942 only - Oct 3 0:00 0 -
Rule Finland 1981 1982 - Mar lastSun 2:00 1:00 S
Rule Finland 1981 1982 - Sep lastSun 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Helsinki 1:39:52 - LMT 1878 May 31 Zone Europe/Helsinki 1:39:52 - LMT 1878 May 31
1:39:52 - HMT 1921 May # Helsinki Mean Time 1:39:52 - HMT 1921 May # Helsinki Mean Time
2:00 Finland EE%sT 1981 Mar 29 2:00 2:00 Finland EE%sT 1983
2:00 EU EE%sT 2:00 EU EE%sT
# Aaland Is # Aaland Is
......
...@@ -82,9 +82,9 @@ Leap 2008 Dec 31 23:59:60 + S ...@@ -82,9 +82,9 @@ Leap 2008 Dec 31 23:59:60 + S
# FAX : 33 (0) 1 40 51 22 91 # FAX : 33 (0) 1 40 51 22 91
# Internet : services.iers@obspm.fr # Internet : services.iers@obspm.fr
# #
# Paris, 4 July 2009 # Paris, 14 July 2010
# #
# Bulletin C 38 # Bulletin C 40
# #
# To authorities responsible # To authorities responsible
# for the measurement and # for the measurement and
...@@ -92,9 +92,9 @@ Leap 2008 Dec 31 23:59:60 + S ...@@ -92,9 +92,9 @@ Leap 2008 Dec 31 23:59:60 + S
# #
# INFORMATION ON UTC - TAI # INFORMATION ON UTC - TAI
# #
# NO positive leap second will be introduced at the end of December 2009. # NO positive leap second will be introduced at the end of December 2010.
# The difference between Coordinated Universal Time UTC and the # The difference between Coordinated Universal Time UTC and the
# International Atomic Time TAI is : # International Atomic Time TAI is :
# #
# from 2009 January 1, 0h UTC, until further notice : UTC-TAI = -34 s # from 2009 January 1, 0h UTC, until further notice : UTC-TAI = -34 s
# #
...@@ -104,6 +104,6 @@ Leap 2008 Dec 31 23:59:60 + S ...@@ -104,6 +104,6 @@ Leap 2008 Dec 31 23:59:60 + S
# will be no time step at the next possible date. # will be no time step at the next possible date.
# #
# Daniel GAMBIS # Daniel GAMBIS
# Director # Director
# Earth Orientation Center of IERS # Earth Orientation Center of IERS
# Observatoire de Paris, France # Observatoire de Paris, France
...@@ -1346,6 +1346,83 @@ Zone America/Montreal -4:54:16 - LMT 1884 ...@@ -1346,6 +1346,83 @@ Zone America/Montreal -4:54:16 - LMT 1884
# entry since our cutoff date of 1970, so we can move # entry since our cutoff date of 1970, so we can move
# America/Coral_Harbour to the 'backward' file. # America/Coral_Harbour to the 'backward' file.
# From Mark Brader (2010-03-06):
#
# Currently the database has:
#
# # Ontario
#
# # From Paul Eggert (2006-07-09):
# # Shanks & Pottenger write that since 1970 most of Ontario has been like
# # Toronto.
# # Thunder Bay skipped DST in 1973.
# # Many smaller locales did not observe peacetime DST until 1974;
# # Nipigon (EST) and Rainy River (CST) are the largest that we know of.
#
# In the (Toronto) Globe and Mail for Saturday, 1955-09-24, in the bottom
# right corner of page 1, it says that Toronto will return to standard
# time at 2 am Sunday morning (which agrees with the database), and that:
#
# The one-hour setback will go into effect throughout most of Ontario,
# except in areas like Windsor which remains on standard time all year.
#
# Windsor is, of course, a lot larger than Nipigon.
#
# I only came across this incidentally. I don't know if Windsor began
# observing DST when Detroit did, or in 1974, or on some other date.
#
# By the way, the article continues by noting that:
#
# Some cities in the United States have pushed the deadline back
# three weeks and will change over from daylight saving in October.
# From Arthur David Olson (2010-07-17):
#
# "Standard Time and Time Zones in Canada" appeared in
# The Journal of The Royal Astronomical Society of Canada,
# volume 26, number 2 (February 1932) and, as of 2010-07-17,
# was available at
# <a href="http://adsabs.harvard.edu/full/1932JRASC..26...49S">
# http://adsabs.harvard.edu/full/1932JRASC..26...49S
# </a>
#
# It includes the text below (starting on page 57):
#
# A list of the places in Canada using daylight saving time would
# require yearly revision. From information kindly furnished by
# the provincial governments and by the postmasters in many cities
# and towns, it is found that the following places used daylight sav-
# ing in 1930. The information for the province of Quebec is definite,
# for the other provinces only approximate:
#
# Province Daylight saving time used
# Prince Edward Island Not used.
# Nova Scotia In Halifax only.
# New Brunswick In St. John only.
# Quebec In the following places:
# Montreal Lachine
# Quebec Mont-Royal
# Levis Iberville
# St. Lambert Cap de la Madeleine
# Verdun Loretteville
# Westmount Richmond
# Outremont St. Jerome
# Longueuil Greenfield Park
# Arvida Waterloo
# Chambly-Canton Beaulieu
# Melbourne La Tuque
# St. Theophile Buckingham
# Ontario Used generally in the cities and towns along
# the southerly part of the province. Not
# used in the northwesterlhy part.
# Manitoba Not used.
# Saskatchewan In Regina only.
# Alberta Not used.
# British Columbia Not used.
#
# With some exceptions, the use of daylight saving may be said to be limited
# to those cities and towns lying between Quebec city and Windsor, Ont.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Toronto 1919 only - Mar 30 23:30 1:00 D Rule Toronto 1919 only - Mar 30 23:30 1:00 D
Rule Toronto 1919 only - Oct 26 0:00 0 S Rule Toronto 1919 only - Oct 26 0:00 0 S
...@@ -2111,7 +2188,44 @@ Zone America/Hermosillo -7:23:52 - LMT 1921 Dec 31 23:36:08 ...@@ -2111,7 +2188,44 @@ Zone America/Hermosillo -7:23:52 - LMT 1921 Dec 31 23:36:08
-8:00 - PST 1970 -8:00 - PST 1970
-7:00 Mexico M%sT 1999 -7:00 Mexico M%sT 1999
-7:00 - MST -7:00 - MST
# From Alexander Krivenyshev (2010-04-21):
# According to news, Bah&iacute;a de Banderas (Mexican state of Nayarit)
# changed time zone UTC-7 to new time zone UTC-6 on April 4, 2010 (to
# share the same time zone as nearby city Puerto Vallarta, Jalisco).
#
# (Spanish)
# Bah&iacute;a de Banderas homologa su horario al del centro del
# pa&iacute;s, a partir de este domingo
# <a href="http://www.nayarit.gob.mx/notes.asp?id=20748">
# http://www.nayarit.gob.mx/notes.asp?id=20748
# </a>
#
# Bah&iacute;a de Banderas homologa su horario con el del Centro del
# Pa&iacute;s
# <a href="http://www.bahiadebanderas.gob.mx/principal/index.php?option=com_content&view=article&id=261:bahia-de-banderas-homologa-su-horario-con-el-del-centro-del-pais&catid=42:comunicacion-social&Itemid=50">
# http://www.bahiadebanderas.gob.mx/principal/index.php?option=com_content&view=article&id=261:bahia-de-banderas-homologa-su-horario-con-el-del-centro-del-pais&catid=42:comunicacion-social&Itemid=50"
# </a>
#
# (English)
# Puerto Vallarta and Bah&iacute;a de Banderas: One Time Zone
# <a href="http://virtualvallarta.com/puertovallarta/puertovallarta/localnews/2009-12-03-Puerto-Vallarta-and-Bahia-de-Banderas-One-Time-Zone.shtml">
# http://virtualvallarta.com/puertovallarta/puertovallarta/localnews/2009-12-03-Puerto-Vallarta-and-Bahia-de-Banderas-One-Time-Zone.shtml
# </a>
#
# or
# <a href="http://www.worldtimezone.com/dst_news/dst_news_mexico08.html">
# http://www.worldtimezone.com/dst_news/dst_news_mexico08.html
# </a>
#
# "Mexico's Senate approved the amendments to the Mexican Schedule System that
# will allow Bah&iacute;a de Banderas and Puerto Vallarta to share the same time
# zone ..."
# Baja California Sur, Nayarit, Sinaloa # Baja California Sur, Nayarit, Sinaloa
# From Arthur David Olson (2010-05-01):
# Use "Bahia_Banderas" to keep the name to fourteen characters.
Zone America/Mazatlan -7:05:40 - LMT 1921 Dec 31 23:54:20 Zone America/Mazatlan -7:05:40 - LMT 1921 Dec 31 23:54:20
-7:00 - MST 1927 Jun 10 23:00 -7:00 - MST 1927 Jun 10 23:00
-6:00 - CST 1930 Nov 15 -6:00 - CST 1930 Nov 15
...@@ -2122,6 +2236,19 @@ Zone America/Mazatlan -7:05:40 - LMT 1921 Dec 31 23:54:20 ...@@ -2122,6 +2236,19 @@ Zone America/Mazatlan -7:05:40 - LMT 1921 Dec 31 23:54:20
-7:00 - MST 1949 Jan 14 -7:00 - MST 1949 Jan 14
-8:00 - PST 1970 -8:00 - PST 1970
-7:00 Mexico M%sT -7:00 Mexico M%sT
Zone America/Bahia_Banderas -7:01:00 - LMT 1921 Dec 31 23:59:00
-7:00 - MST 1927 Jun 10 23:00
-6:00 - CST 1930 Nov 15
-7:00 - MST 1931 May 1 23:00
-6:00 - CST 1931 Oct
-7:00 - MST 1932 Apr 1
-6:00 - CST 1942 Apr 24
-7:00 - MST 1949 Jan 14
-8:00 - PST 1970
-7:00 Mexico M%sT 2010 Apr 4 2:00
-6:00 Mexico C%sT
# Baja California (near US border) # Baja California (near US border)
Zone America/Tijuana -7:48:04 - LMT 1922 Jan 1 0:11:56 Zone America/Tijuana -7:48:04 - LMT 1922 Jan 1 0:11:56
-7:00 - MST 1924 -7:00 - MST 1924
......
...@@ -199,8 +199,8 @@ ET +0902+03842 Africa/Addis_Ababa ...@@ -199,8 +199,8 @@ ET +0902+03842 Africa/Addis_Ababa
FI +6010+02458 Europe/Helsinki FI +6010+02458 Europe/Helsinki
FJ -1808+17825 Pacific/Fiji FJ -1808+17825 Pacific/Fiji
FK -5142-05751 Atlantic/Stanley FK -5142-05751 Atlantic/Stanley
FM +0725+15147 Pacific/Truk Truk (Chuuk) and Yap FM +0725+15147 Pacific/Chuuk Chuuk (Truk) and Yap
FM +0658+15813 Pacific/Ponape Ponape (Pohnpei) FM +0658+15813 Pacific/Pohnpei Pohnpei (Ponape)
FM +0519+16259 Pacific/Kosrae Kosrae FM +0519+16259 Pacific/Kosrae Kosrae
FO +6201-00646 Atlantic/Faroe FO +6201-00646 Atlantic/Faroe
FR +4852+00220 Europe/Paris FR +4852+00220 Europe/Paris
...@@ -310,6 +310,7 @@ MX +2934-10425 America/Ojinaga US Mountain Time - Chihuahua near US border ...@@ -310,6 +310,7 @@ MX +2934-10425 America/Ojinaga US Mountain Time - Chihuahua near US border
MX +2904-11058 America/Hermosillo Mountain Standard Time - Sonora MX +2904-11058 America/Hermosillo Mountain Standard Time - Sonora
MX +3232-11701 America/Tijuana US Pacific Time - Baja California near US border MX +3232-11701 America/Tijuana US Pacific Time - Baja California near US border
MX +3018-11452 America/Santa_Isabel Mexican Pacific Time - Baja California away from US border MX +3018-11452 America/Santa_Isabel Mexican Pacific Time - Baja California away from US border
MX +2048-10515 America/Bahia_Banderas Mexican Central Time - Bahia de Banderas
MY +0310+10142 Asia/Kuala_Lumpur peninsular Malaysia MY +0310+10142 Asia/Kuala_Lumpur peninsular Malaysia
MY +0133+11020 Asia/Kuching Sabah & Sarawak MY +0133+11020 Asia/Kuching Sabah & Sarawak
MZ -2558+03235 Africa/Maputo MZ -2558+03235 Africa/Maputo
......
/* /*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -27,7 +27,6 @@ package com.sun.java.util.jar.pack; ...@@ -27,7 +27,6 @@ package com.sun.java.util.jar.pack;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import com.sun.java.util.jar.pack.Package.Class;
import com.sun.java.util.jar.pack.ConstantPool.*; import com.sun.java.util.jar.pack.ConstantPool.*;
/** /**
...@@ -96,20 +95,20 @@ class Attribute implements Comparable, Constants { ...@@ -96,20 +95,20 @@ class Attribute implements Comparable, Constants {
return this.def.compareTo(that.def); return this.def.compareTo(that.def);
} }
static private final byte[] noBytes = {}; private static final byte[] noBytes = {};
static private final HashMap canonLists = new HashMap(); private static final Map<List<Attribute>, List<Attribute>> canonLists = new HashMap<>();
static private final HashMap attributes = new HashMap(); private static final Map<Layout, Attribute> attributes = new HashMap<>();
static private final HashMap standardDefs = new HashMap(); private static final Map<Layout, Attribute> standardDefs = new HashMap<>();
// Canonicalized lists of trivial attrs (Deprecated, etc.) // Canonicalized lists of trivial attrs (Deprecated, etc.)
// are used by trimToSize, in order to reduce footprint // are used by trimToSize, in order to reduce footprint
// of some common cases. (Note that Code attributes are // of some common cases. (Note that Code attributes are
// always zero size.) // always zero size.)
public static List getCanonList(List al) { public static List getCanonList(List<Attribute> al) {
synchronized (canonLists) { synchronized (canonLists) {
List cl = (List) canonLists.get(al); List<Attribute> cl = canonLists.get(al);
if (cl == null) { if (cl == null) {
cl = new ArrayList(al.size()); cl = new ArrayList<>(al.size());
cl.addAll(al); cl.addAll(al);
cl = Collections.unmodifiableList(cl); cl = Collections.unmodifiableList(cl);
canonLists.put(al, cl); canonLists.put(al, cl);
...@@ -122,7 +121,7 @@ class Attribute implements Comparable, Constants { ...@@ -122,7 +121,7 @@ class Attribute implements Comparable, Constants {
public static Attribute find(int ctype, String name, String layout) { public static Attribute find(int ctype, String name, String layout) {
Layout key = Layout.makeKey(ctype, name, layout); Layout key = Layout.makeKey(ctype, name, layout);
synchronized (attributes) { synchronized (attributes) {
Attribute a = (Attribute) attributes.get(key); Attribute a = attributes.get(key);
if (a == null) { if (a == null) {
a = new Layout(ctype, name, layout).canonicalInstance(); a = new Layout(ctype, name, layout).canonicalInstance();
attributes.put(key, a); attributes.put(key, a);
...@@ -131,24 +130,29 @@ class Attribute implements Comparable, Constants { ...@@ -131,24 +130,29 @@ class Attribute implements Comparable, Constants {
} }
} }
public static Object keyForLookup(int ctype, String name) { public static Layout keyForLookup(int ctype, String name) {
return Layout.makeKey(ctype, name); return Layout.makeKey(ctype, name);
} }
// Find canonical empty attribute with given ctype and name, // Find canonical empty attribute with given ctype and name,
// and with the standard layout. // and with the standard layout.
public static Attribute lookup(Map defs, int ctype, String name) { public static Attribute lookup(Map<Layout, Attribute> defs, int ctype,
if (defs == null) defs = standardDefs; String name) {
return (Attribute) defs.get(Layout.makeKey(ctype, name)); if (defs == null) {
defs = standardDefs;
}
return defs.get(Layout.makeKey(ctype, name));
} }
public static Attribute define(Map defs, int ctype, String name, String layout) {
public static Attribute define(Map<Layout, Attribute> defs, int ctype,
String name, String layout) {
Attribute a = find(ctype, name, layout); Attribute a = find(ctype, name, layout);
defs.put(Layout.makeKey(ctype, name), a); defs.put(Layout.makeKey(ctype, name), a);
return a; return a;
} }
static { static {
Map sd = standardDefs; Map<Layout, Attribute> sd = standardDefs;
define(sd, ATTR_CONTEXT_CLASS, "Signature", "RSH"); define(sd, ATTR_CONTEXT_CLASS, "Signature", "RSH");
define(sd, ATTR_CONTEXT_CLASS, "Synthetic", ""); define(sd, ATTR_CONTEXT_CLASS, "Synthetic", "");
define(sd, ATTR_CONTEXT_CLASS, "Deprecated", ""); define(sd, ATTR_CONTEXT_CLASS, "Deprecated", "");
...@@ -244,7 +248,7 @@ class Attribute implements Comparable, Constants { ...@@ -244,7 +248,7 @@ class Attribute implements Comparable, Constants {
+"\n ()[] ]" +"\n ()[] ]"
) )
}; };
Map sd = standardDefs; Map<Layout, Attribute> sd = standardDefs;
String defaultLayout = mdLayouts[2]; String defaultLayout = mdLayouts[2];
String annotationsLayout = mdLayouts[1] + mdLayouts[2]; String annotationsLayout = mdLayouts[1] + mdLayouts[2];
String paramsLayout = mdLayouts[0] + annotationsLayout; String paramsLayout = mdLayouts[0] + annotationsLayout;
...@@ -275,10 +279,6 @@ class Attribute implements Comparable, Constants { ...@@ -275,10 +279,6 @@ class Attribute implements Comparable, Constants {
return null; return null;
} }
public static Map getStandardDefs() {
return new HashMap(standardDefs);
}
/** Base class for any attributed object (Class, Field, Method, Code). /** Base class for any attributed object (Class, Field, Method, Code).
* Flags are included because they are used to help transmit the * Flags are included because they are used to help transmit the
* presence of attributes. That is, flags are a mix of modifier * presence of attributes. That is, flags are a mix of modifier
...@@ -291,7 +291,7 @@ class Attribute implements Comparable, Constants { ...@@ -291,7 +291,7 @@ class Attribute implements Comparable, Constants {
protected abstract Entry[] getCPMap(); protected abstract Entry[] getCPMap();
protected int flags; // defined here for convenience protected int flags; // defined here for convenience
protected List attributes; protected List<Attribute> attributes;
public int attributeSize() { public int attributeSize() {
return (attributes == null) ? 0 : attributes.size(); return (attributes == null) ? 0 : attributes.size();
...@@ -301,16 +301,15 @@ class Attribute implements Comparable, Constants { ...@@ -301,16 +301,15 @@ class Attribute implements Comparable, Constants {
if (attributes == null) { if (attributes == null) {
return; return;
} }
if (attributes.size() == 0) { if (attributes.isEmpty()) {
attributes = null; attributes = null;
return; return;
} }
if (attributes instanceof ArrayList) { if (attributes instanceof ArrayList) {
ArrayList al = (ArrayList) attributes; ArrayList<Attribute> al = (ArrayList<Attribute>)attributes;
al.trimToSize(); al.trimToSize();
boolean allCanon = true; boolean allCanon = true;
for (Iterator i = al.iterator(); i.hasNext(); ) { for (Attribute a : al) {
Attribute a = (Attribute) i.next();
if (!a.isCanonical()) { if (!a.isCanonical()) {
allCanon = false; allCanon = false;
} }
...@@ -330,9 +329,9 @@ class Attribute implements Comparable, Constants { ...@@ -330,9 +329,9 @@ class Attribute implements Comparable, Constants {
public void addAttribute(Attribute a) { public void addAttribute(Attribute a) {
if (attributes == null) if (attributes == null)
attributes = new ArrayList(3); attributes = new ArrayList<>(3);
else if (!(attributes instanceof ArrayList)) else if (!(attributes instanceof ArrayList))
attributes = new ArrayList(attributes); // unfreeze it attributes = new ArrayList<>(attributes); // unfreeze it
attributes.add(a); attributes.add(a);
} }
...@@ -340,32 +339,31 @@ class Attribute implements Comparable, Constants { ...@@ -340,32 +339,31 @@ class Attribute implements Comparable, Constants {
if (attributes == null) return null; if (attributes == null) return null;
if (!attributes.contains(a)) return null; if (!attributes.contains(a)) return null;
if (!(attributes instanceof ArrayList)) if (!(attributes instanceof ArrayList))
attributes = new ArrayList(attributes); // unfreeze it attributes = new ArrayList<>(attributes); // unfreeze it
attributes.remove(a); attributes.remove(a);
return a; return a;
} }
public Attribute getAttribute(int n) { public Attribute getAttribute(int n) {
return (Attribute) attributes.get(n); return attributes.get(n);
} }
protected void visitRefs(int mode, Collection refs) { protected void visitRefs(int mode, Collection<Entry> refs) {
if (attributes == null) return; if (attributes == null) return;
for (Iterator i = attributes.iterator(); i.hasNext(); ) { for (Attribute a : attributes) {
Attribute a = (Attribute) i.next();
a.visitRefs(this, mode, refs); a.visitRefs(this, mode, refs);
} }
} }
static final List noAttributes = Arrays.asList(new Object[0]); static final List<Attribute> noAttributes = Arrays.asList(new Attribute[0]);
public List getAttributes() { public List<Attribute> getAttributes() {
if (attributes == null) if (attributes == null)
return noAttributes; return noAttributes;
return attributes; return attributes;
} }
public void setAttributes(List attrList) { public void setAttributes(List<Attribute> attrList) {
if (attrList.isEmpty()) if (attrList.isEmpty())
attributes = null; attributes = null;
else else
...@@ -374,8 +372,7 @@ class Attribute implements Comparable, Constants { ...@@ -374,8 +372,7 @@ class Attribute implements Comparable, Constants {
public Attribute getAttribute(String attrName) { public Attribute getAttribute(String attrName) {
if (attributes == null) return null; if (attributes == null) return null;
for (Iterator i = attributes.iterator(); i.hasNext(); ) { for (Attribute a : attributes) {
Attribute a = (Attribute) i.next();
if (a.name().equals(attrName)) if (a.name().equals(attrName))
return a; return a;
} }
...@@ -384,8 +381,7 @@ class Attribute implements Comparable, Constants { ...@@ -384,8 +381,7 @@ class Attribute implements Comparable, Constants {
public Attribute getAttribute(Layout attrDef) { public Attribute getAttribute(Layout attrDef) {
if (attributes == null) return null; if (attributes == null) return null;
for (Iterator i = attributes.iterator(); i.hasNext(); ) { for (Attribute a : attributes) {
Attribute a = (Attribute) i.next();
if (a.layout() == attrDef) if (a.layout() == attrDef)
return a; return a;
} }
...@@ -457,14 +453,8 @@ class Attribute implements Comparable, Constants { ...@@ -457,14 +453,8 @@ class Attribute implements Comparable, Constants {
public String layout() { return layout; } public String layout() { return layout; }
public Attribute canonicalInstance() { return canon; } public Attribute canonicalInstance() { return canon; }
// Cache of name reference.
private Entry nameRef; // name, for use by visitRefs
public Entry getNameRef() { public Entry getNameRef() {
Entry nameRef = this.nameRef; return ConstantPool.getUtf8Entry(name());
if (nameRef == null) {
this.nameRef = nameRef = ConstantPool.getUtf8Entry(name());
}
return nameRef;
} }
public boolean isEmpty() { return layout == ""; } public boolean isEmpty() { return layout == ""; }
...@@ -834,14 +824,14 @@ class Attribute implements Comparable, Constants { ...@@ -834,14 +824,14 @@ class Attribute implements Comparable, Constants {
*/ */
static //private static //private
Layout.Element[] tokenizeLayout(Layout self, int curCble, String layout) { Layout.Element[] tokenizeLayout(Layout self, int curCble, String layout) {
ArrayList col = new ArrayList(layout.length()); ArrayList<Layout.Element> col = new ArrayList<>(layout.length());
tokenizeLayout(self, curCble, layout, col); tokenizeLayout(self, curCble, layout, col);
Layout.Element[] res = new Layout.Element[col.size()]; Layout.Element[] res = new Layout.Element[col.size()];
col.toArray(res); col.toArray(res);
return res; return res;
} }
static //private static //private
void tokenizeLayout(Layout self, int curCble, String layout, ArrayList col) { void tokenizeLayout(Layout self, int curCble, String layout, ArrayList<Layout.Element> col) {
boolean prevBCI = false; boolean prevBCI = false;
for (int len = layout.length(), i = 0; i < len; ) { for (int len = layout.length(), i = 0; i < len; ) {
int start = i; int start = i;
...@@ -899,7 +889,7 @@ class Attribute implements Comparable, Constants { ...@@ -899,7 +889,7 @@ class Attribute implements Comparable, Constants {
case 'T': // union: 'T' any_int union_case* '(' ')' '[' body ']' case 'T': // union: 'T' any_int union_case* '(' ')' '[' body ']'
kind = EK_UN; kind = EK_UN;
i = tokenizeSInt(e, layout, i); i = tokenizeSInt(e, layout, i);
ArrayList cases = new ArrayList(); ArrayList<Layout.Element> cases = new ArrayList<>();
for (;;) { for (;;) {
// Keep parsing cases until we hit the default case. // Keep parsing cases until we hit the default case.
if (layout.charAt(i++) != '(') if (layout.charAt(i++) != '(')
...@@ -1053,7 +1043,7 @@ class Attribute implements Comparable, Constants { ...@@ -1053,7 +1043,7 @@ class Attribute implements Comparable, Constants {
} }
static //private static //private
String[] splitBodies(String layout) { String[] splitBodies(String layout) {
ArrayList bodies = new ArrayList(); ArrayList<String> bodies = new ArrayList<>();
// Parse several independent layout bodies: "[foo][bar]...[baz]" // Parse several independent layout bodies: "[foo][bar]...[baz]"
for (int i = 0; i < layout.length(); i++) { for (int i = 0; i < layout.length(); i++) {
if (layout.charAt(i++) != '[') if (layout.charAt(i++) != '[')
...@@ -1132,7 +1122,9 @@ class Attribute implements Comparable, Constants { ...@@ -1132,7 +1122,9 @@ class Attribute implements Comparable, Constants {
int parseIntBefore(String layout, int dash) { int parseIntBefore(String layout, int dash) {
int end = dash; int end = dash;
int beg = end; int beg = end;
while (beg > 0 && isDigit(layout.charAt(beg-1))) --beg; while (beg > 0 && isDigit(layout.charAt(beg-1))) {
--beg;
}
if (beg == end) return Integer.parseInt("empty"); if (beg == end) return Integer.parseInt("empty");
// skip backward over a sign // skip backward over a sign
if (beg >= 1 && layout.charAt(beg-1) == '-') --beg; if (beg >= 1 && layout.charAt(beg-1) == '-') --beg;
...@@ -1145,7 +1137,9 @@ class Attribute implements Comparable, Constants { ...@@ -1145,7 +1137,9 @@ class Attribute implements Comparable, Constants {
int end = beg; int end = beg;
int limit = layout.length(); int limit = layout.length();
if (end < limit && layout.charAt(end) == '-') ++end; if (end < limit && layout.charAt(end) == '-') ++end;
while (end < limit && isDigit(layout.charAt(end))) ++end; while (end < limit && isDigit(layout.charAt(end))) {
++end;
}
if (beg == end) return Integer.parseInt("empty"); if (beg == end) return Integer.parseInt("empty");
return Integer.parseInt(layout.substring(beg, end)); return Integer.parseInt(layout.substring(beg, end));
} }
......
/* /*
* Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
package com.sun.java.util.jar.pack; package com.sun.java.util.jar.pack;
import java.io.*;
import java.util.*; import java.util.*;
/** /**
...@@ -40,20 +39,13 @@ class ConstantPool implements Constants { ...@@ -40,20 +39,13 @@ class ConstantPool implements Constants {
return Utils.currentPropMap().getInteger(Utils.DEBUG_VERBOSE); return Utils.currentPropMap().getInteger(Utils.DEBUG_VERBOSE);
} }
// Uniquification tables for factory methods:
private static final HashMap utf8Entries = new HashMap();
private static final HashMap classEntries = new HashMap();
private static final HashMap literalEntries = new HashMap();
private static final HashMap signatureEntries = new HashMap();
private static final HashMap descriptorEntries = new HashMap();
private static final HashMap memberEntries = new HashMap();
/** Factory for Utf8 string constants. /** Factory for Utf8 string constants.
* Used for well-known strings like "SourceFile", "<init>", etc. * Used for well-known strings like "SourceFile", "<init>", etc.
* Also used to back up more complex constant pool entries, like Class. * Also used to back up more complex constant pool entries, like Class.
*/ */
public static synchronized Utf8Entry getUtf8Entry(String value) { public static synchronized Utf8Entry getUtf8Entry(String value) {
Utf8Entry e = (Utf8Entry) utf8Entries.get(value); Map<String, Utf8Entry> utf8Entries = Utils.getUtf8Entries();
Utf8Entry e = utf8Entries.get(value);
if (e == null) { if (e == null) {
e = new Utf8Entry(value); e = new Utf8Entry(value);
utf8Entries.put(e.stringValue(), e); utf8Entries.put(e.stringValue(), e);
...@@ -62,9 +54,10 @@ class ConstantPool implements Constants { ...@@ -62,9 +54,10 @@ class ConstantPool implements Constants {
} }
/** Factory for Class constants. */ /** Factory for Class constants. */
public static synchronized ClassEntry getClassEntry(String name) { public static synchronized ClassEntry getClassEntry(String name) {
ClassEntry e = (ClassEntry) classEntries.get(name); Map<String, ClassEntry> classEntries = Utils.getClassEntries();
ClassEntry e = classEntries.get(name);
if (e == null) { if (e == null) {
e = (ClassEntry) new ClassEntry(getUtf8Entry(name)); e = new ClassEntry(getUtf8Entry(name));
assert(name.equals(e.stringValue())); assert(name.equals(e.stringValue()));
classEntries.put(e.stringValue(), e); classEntries.put(e.stringValue(), e);
} }
...@@ -72,7 +65,8 @@ class ConstantPool implements Constants { ...@@ -72,7 +65,8 @@ class ConstantPool implements Constants {
} }
/** Factory for literal constants (String, Integer, etc.). */ /** Factory for literal constants (String, Integer, etc.). */
public static synchronized LiteralEntry getLiteralEntry(Comparable value) { public static synchronized LiteralEntry getLiteralEntry(Comparable value) {
LiteralEntry e = (LiteralEntry) literalEntries.get(value); Map<Object, LiteralEntry> literalEntries = Utils.getLiteralEntries();
LiteralEntry e = literalEntries.get(value);
if (e == null) { if (e == null) {
if (value instanceof String) if (value instanceof String)
e = new StringEntry(getUtf8Entry((String)value)); e = new StringEntry(getUtf8Entry((String)value));
...@@ -89,7 +83,8 @@ class ConstantPool implements Constants { ...@@ -89,7 +83,8 @@ class ConstantPool implements Constants {
/** Factory for signature (type) constants. */ /** Factory for signature (type) constants. */
public static synchronized SignatureEntry getSignatureEntry(String type) { public static synchronized SignatureEntry getSignatureEntry(String type) {
SignatureEntry e = (SignatureEntry) signatureEntries.get(type); Map<String, SignatureEntry> signatureEntries = Utils.getSignatureEntries();
SignatureEntry e = signatureEntries.get(type);
if (e == null) { if (e == null) {
e = new SignatureEntry(type); e = new SignatureEntry(type);
assert(e.stringValue().equals(type)); assert(e.stringValue().equals(type));
...@@ -104,8 +99,9 @@ class ConstantPool implements Constants { ...@@ -104,8 +99,9 @@ class ConstantPool implements Constants {
/** Factory for descriptor (name-and-type) constants. */ /** Factory for descriptor (name-and-type) constants. */
public static synchronized DescriptorEntry getDescriptorEntry(Utf8Entry nameRef, SignatureEntry typeRef) { public static synchronized DescriptorEntry getDescriptorEntry(Utf8Entry nameRef, SignatureEntry typeRef) {
Map<String, DescriptorEntry> descriptorEntries = Utils.getDescriptorEntries();
String key = DescriptorEntry.stringValueOf(nameRef, typeRef); String key = DescriptorEntry.stringValueOf(nameRef, typeRef);
DescriptorEntry e = (DescriptorEntry) descriptorEntries.get(key); DescriptorEntry e = descriptorEntries.get(key);
if (e == null) { if (e == null) {
e = new DescriptorEntry(nameRef, typeRef); e = new DescriptorEntry(nameRef, typeRef);
assert(e.stringValue().equals(key)) assert(e.stringValue().equals(key))
...@@ -121,8 +117,9 @@ class ConstantPool implements Constants { ...@@ -121,8 +117,9 @@ class ConstantPool implements Constants {
/** Factory for member reference constants. */ /** Factory for member reference constants. */
public static synchronized MemberEntry getMemberEntry(byte tag, ClassEntry classRef, DescriptorEntry descRef) { public static synchronized MemberEntry getMemberEntry(byte tag, ClassEntry classRef, DescriptorEntry descRef) {
Map<String, MemberEntry> memberEntries = Utils.getMemberEntries();
String key = MemberEntry.stringValueOf(tag, classRef, descRef); String key = MemberEntry.stringValueOf(tag, classRef, descRef);
MemberEntry e = (MemberEntry) memberEntries.get(key); MemberEntry e = memberEntries.get(key);
if (e == null) { if (e == null) {
e = new MemberEntry(tag, classRef, descRef); e = new MemberEntry(tag, classRef, descRef);
assert(e.stringValue().equals(key)) assert(e.stringValue().equals(key))
...@@ -489,8 +486,9 @@ class ConstantPool implements Constants { ...@@ -489,8 +486,9 @@ class ConstantPool implements Constants {
String[] parts = structureSignature(value); String[] parts = structureSignature(value);
formRef = getUtf8Entry(parts[0]); formRef = getUtf8Entry(parts[0]);
classRefs = new ClassEntry[parts.length-1]; classRefs = new ClassEntry[parts.length-1];
for (int i = 1; i < parts.length; i++) for (int i = 1; i < parts.length; i++) {
classRefs[i-1] = getClassEntry(parts[i]); classRefs[i - 1] = getClassEntry(parts[i]);
}
hashCode(); // force computation of valueHash hashCode(); // force computation of valueHash
} }
protected int computeValueHash() { protected int computeValueHash() {
...@@ -527,8 +525,9 @@ class ConstantPool implements Constants { ...@@ -527,8 +525,9 @@ class ConstantPool implements Constants {
String stringValueOf(Utf8Entry formRef, ClassEntry[] classRefs) { String stringValueOf(Utf8Entry formRef, ClassEntry[] classRefs) {
String[] parts = new String[1+classRefs.length]; String[] parts = new String[1+classRefs.length];
parts[0] = formRef.stringValue(); parts[0] = formRef.stringValue();
for (int i = 1; i < parts.length; i++) for (int i = 1; i < parts.length; i++) {
parts[i] = classRefs[i-1].stringValue(); parts[i] = classRefs[i - 1].stringValue();
}
return flattenSignature(parts).intern(); return flattenSignature(parts).intern();
} }
...@@ -543,19 +542,23 @@ class ConstantPool implements Constants { ...@@ -543,19 +542,23 @@ class ConstantPool implements Constants {
int size = 0; int size = 0;
for (int i = min; i < max; i++) { for (int i = min; i < max; i++) {
switch (form.charAt(i)) { switch (form.charAt(i)) {
case 'D': case 'D':
case 'J': case 'J':
if (countDoublesTwice) size++; if (countDoublesTwice) {
break; size++;
case '[': }
// Skip rest of array info. break;
while (form.charAt(i) == '[') ++i; case '[':
break; // Skip rest of array info.
case ';': while (form.charAt(i) == '[') {
continue; ++i;
default: }
assert(0 <= JAVA_SIGNATURE_CHARS.indexOf(form.charAt(i))); break;
break; case ';':
continue;
default:
assert (0 <= JAVA_SIGNATURE_CHARS.indexOf(form.charAt(i)));
break;
} }
size++; size++;
} }
...@@ -586,8 +589,9 @@ class ConstantPool implements Constants { ...@@ -586,8 +589,9 @@ class ConstantPool implements Constants {
s = "/" + formRef.stringValue(); s = "/" + formRef.stringValue();
} }
int i; int i;
while ((i = s.indexOf(';')) >= 0) while ((i = s.indexOf(';')) >= 0) {
s = s.substring(0,i) + s.substring(i+1); s = s.substring(0, i) + s.substring(i + 1);
}
return s; return s;
} }
} }
...@@ -732,11 +736,11 @@ class ConstantPool implements Constants { ...@@ -732,11 +736,11 @@ class ConstantPool implements Constants {
clearIndex(); clearIndex();
this.cpMap = cpMap; this.cpMap = cpMap;
} }
protected Index(String debugName, Collection cpMapList) { protected Index(String debugName, Collection<Entry> cpMapList) {
this(debugName); this(debugName);
setMap(cpMapList); setMap(cpMapList);
} }
protected void setMap(Collection cpMapList) { protected void setMap(Collection<Entry> cpMapList) {
cpMap = new Entry[cpMapList.size()]; cpMap = new Entry[cpMapList.size()];
cpMapList.toArray(cpMap); cpMapList.toArray(cpMap);
setMap(cpMap); setMap(cpMap);
...@@ -756,11 +760,13 @@ class ConstantPool implements Constants { ...@@ -756,11 +760,13 @@ class ConstantPool implements Constants {
// //
// As a special hack, if flattenSigs, signatures are // As a special hack, if flattenSigs, signatures are
// treated as equivalent entries of cpMap. This is wrong // treated as equivalent entries of cpMap. This is wrong
// fron a Collection point of view, because contains() // from a Collection point of view, because contains()
// reports true for signatures, but the iterator() // reports true for signatures, but the iterator()
// never produces them! // never produces them!
private int findIndexOf(Entry e) { private int findIndexOf(Entry e) {
if (indexKey == null) initializeIndex(); if (indexKey == null) {
initializeIndex();
}
int probe = findIndexLocation(e); int probe = findIndexLocation(e);
if (indexKey[probe] != e) { if (indexKey[probe] != e) {
if (flattenSigs && e.tag == CONSTANT_Signature) { if (flattenSigs && e.tag == CONSTANT_Signature) {
...@@ -832,7 +838,9 @@ class ConstantPool implements Constants { ...@@ -832,7 +838,9 @@ class ConstantPool implements Constants {
System.out.println("initialize Index "+debugName+" ["+size()+"]"); System.out.println("initialize Index "+debugName+" ["+size()+"]");
int hsize0 = (int)((cpMap.length + 10) * 1.5); int hsize0 = (int)((cpMap.length + 10) * 1.5);
int hsize = 1; int hsize = 1;
while (hsize < hsize0) hsize <<= 1; while (hsize < hsize0) {
hsize <<= 1;
}
indexKey = new Entry[hsize]; indexKey = new Entry[hsize];
indexValue = new int[hsize]; indexValue = new int[hsize];
for (int i = 0; i < cpMap.length; i++) { for (int i = 0; i < cpMap.length; i++) {
...@@ -855,7 +863,7 @@ class ConstantPool implements Constants { ...@@ -855,7 +863,7 @@ class ConstantPool implements Constants {
return toArray(new Entry[size()]); return toArray(new Entry[size()]);
} }
public Object clone() { public Object clone() {
return new Index(debugName, (Entry[]) cpMap.clone()); return new Index(debugName, cpMap.clone());
} }
public String toString() { public String toString() {
return "Index "+debugName+" ["+size()+"]"; return "Index "+debugName+" ["+size()+"]";
...@@ -901,22 +909,24 @@ class ConstantPool implements Constants { ...@@ -901,22 +909,24 @@ class ConstantPool implements Constants {
public static public static
Index[] partition(Index ix, int[] keys) { Index[] partition(Index ix, int[] keys) {
// %%% Should move this into class Index. // %%% Should move this into class Index.
ArrayList parts = new ArrayList(); ArrayList<List<Entry>> parts = new ArrayList<>();
Entry[] cpMap = ix.cpMap; Entry[] cpMap = ix.cpMap;
assert(keys.length == cpMap.length); assert(keys.length == cpMap.length);
for (int i = 0; i < keys.length; i++) { for (int i = 0; i < keys.length; i++) {
int key = keys[i]; int key = keys[i];
if (key < 0) continue; if (key < 0) continue;
while (key >= parts.size()) parts.add(null); while (key >= parts.size()) {
ArrayList part = (ArrayList) parts.get(key); parts.add(null);
}
List<Entry> part = parts.get(key);
if (part == null) { if (part == null) {
parts.set(key, part = new ArrayList()); parts.set(key, part = new ArrayList<>());
} }
part.add(cpMap[i]); part.add(cpMap[i]);
} }
Index[] indexes = new Index[parts.size()]; Index[] indexes = new Index[parts.size()];
for (int key = 0; key < indexes.length; key++) { for (int key = 0; key < indexes.length; key++) {
ArrayList part = (ArrayList) parts.get(key); List<Entry> part = parts.get(key);
if (part == null) continue; if (part == null) continue;
indexes[key] = new Index(ix.debugName+"/part#"+key, part); indexes[key] = new Index(ix.debugName+"/part#"+key, part);
assert(indexes[key].indexOf(part.get(0)) == 0); assert(indexes[key].indexOf(part.get(0)) == 0);
...@@ -1048,9 +1058,10 @@ class ConstantPool implements Constants { ...@@ -1048,9 +1058,10 @@ class ConstantPool implements Constants {
whichClasses[i] = whichClass; whichClasses[i] = whichClass;
} }
perClassIndexes = partition(allMembers, whichClasses); perClassIndexes = partition(allMembers, whichClasses);
for (int i = 0; i < perClassIndexes.length; i++) for (int i = 0; i < perClassIndexes.length; i++) {
assert(perClassIndexes[i]==null assert (perClassIndexes[i] == null ||
|| perClassIndexes[i].assertIsSorted()); perClassIndexes[i].assertIsSorted());
}
indexByTagAndClass[tag] = perClassIndexes; indexByTagAndClass[tag] = perClassIndexes;
} }
int whichClass = allClasses.indexOf(classRef); int whichClass = allClasses.indexOf(classRef);
...@@ -1113,7 +1124,7 @@ class ConstantPool implements Constants { ...@@ -1113,7 +1124,7 @@ class ConstantPool implements Constants {
* Also, discard null from cpRefs. * Also, discard null from cpRefs.
*/ */
public static public static
void completeReferencesIn(Set cpRefs, boolean flattenSigs) { void completeReferencesIn(Set<Entry> cpRefs, boolean flattenSigs) {
cpRefs.remove(null); cpRefs.remove(null);
for (ListIterator work = for (ListIterator work =
new ArrayList(cpRefs).listIterator(cpRefs.size()); new ArrayList(cpRefs).listIterator(cpRefs.size());
......
/* /*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
package com.sun.java.util.jar.pack; package com.sun.java.util.jar.pack;
import java.lang.Error;
import java.io.*; import java.io.*;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.*; import java.util.*;
...@@ -35,10 +34,11 @@ import java.util.zip.*; ...@@ -35,10 +34,11 @@ import java.util.zip.*;
/** Command line interface for Pack200. /** Command line interface for Pack200.
*/ */
class Driver { class Driver {
private static final ResourceBundle RESOURCE= ResourceBundle.getBundle("com.sun.java.util.jar.pack.DriverResource"); private static final ResourceBundle RESOURCE =
ResourceBundle.getBundle("com.sun.java.util.jar.pack.DriverResource");
public static void main(String[] ava) throws IOException { public static void main(String[] ava) throws IOException {
ArrayList<String> av = new ArrayList<String>(Arrays.asList(ava)); ArrayList<String> av = new ArrayList<>(Arrays.asList(ava));
boolean doPack = true; boolean doPack = true;
boolean doUnpack = false; boolean doUnpack = false;
...@@ -61,7 +61,7 @@ class Driver { ...@@ -61,7 +61,7 @@ class Driver {
} }
// Collect engine properties here: // Collect engine properties here:
HashMap<String,String> engProps = new HashMap<String,String>(); HashMap<String,String> engProps = new HashMap<>();
engProps.put(verboseProp, System.getProperty(verboseProp)); engProps.put(verboseProp, System.getProperty(verboseProp));
String optionMap; String optionMap;
...@@ -75,7 +75,7 @@ class Driver { ...@@ -75,7 +75,7 @@ class Driver {
} }
// Collect argument properties here: // Collect argument properties here:
HashMap<String,String> avProps = new HashMap<String,String>(); HashMap<String,String> avProps = new HashMap<>();
try { try {
for (;;) { for (;;) {
String state = parseCommandOptions(av, optionMap, avProps); String state = parseCommandOptions(av, optionMap, avProps);
...@@ -133,8 +133,9 @@ class Driver { ...@@ -133,8 +133,9 @@ class Driver {
if (engProps.get(verboseProp) != null) if (engProps.get(verboseProp) != null)
fileProps.list(System.out); fileProps.list(System.out);
propIn.close(); propIn.close();
for (Map.Entry<Object,Object> me : fileProps.entrySet()) for (Map.Entry<Object,Object> me : fileProps.entrySet()) {
engProps.put((String)me.getKey(), (String)me.getValue()); engProps.put((String) me.getKey(), (String) me.getValue());
}
} else if (state == "--version") { } else if (state == "--version") {
System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.VERSION), Driver.class.getName(), "1.31, 07/05/05")); System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.VERSION), Driver.class.getName(), "1.31, 07/05/05"));
return; return;
...@@ -493,7 +494,7 @@ class Driver { ...@@ -493,7 +494,7 @@ class Driver {
String resultString = null; String resultString = null;
// Convert options string into optLines dictionary. // Convert options string into optLines dictionary.
TreeMap<String,String[]> optmap = new TreeMap<String,String[]>(); TreeMap<String,String[]> optmap = new TreeMap<>();
loadOptmap: loadOptmap:
for (String optline : options.split("\n")) { for (String optline : options.split("\n")) {
String[] words = optline.split("\\p{Space}+"); String[] words = optline.split("\\p{Space}+");
...@@ -687,7 +688,9 @@ class Driver { ...@@ -687,7 +688,9 @@ class Driver {
// Report number of arguments consumed. // Report number of arguments consumed.
args.subList(0, argp.nextIndex()).clear(); args.subList(0, argp.nextIndex()).clear();
// Report any unconsumed partial argument. // Report any unconsumed partial argument.
while (pbp.hasPrevious()) args.add(0, pbp.previous()); while (pbp.hasPrevious()) {
args.add(0, pbp.previous());
}
//System.out.println(args+" // "+properties+" -> "+resultString); //System.out.println(args+" // "+properties+" -> "+resultString);
return resultString; return resultString;
} }
......
/* /*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,13 +28,8 @@ package com.sun.java.util.jar.pack; ...@@ -28,13 +28,8 @@ package com.sun.java.util.jar.pack;
import java.nio.*; import java.nio.*;
import java.io.*; import java.io.*;
import java.nio.channels.*;
import java.util.Date;
import java.util.jar.*; import java.util.jar.*;
import java.util.zip.*; import java.util.zip.*;
import java.util.*;
//import com.sun.java.util.jar.pack.Pack200;
class NativeUnpack { class NativeUnpack {
// Pointer to the native unpacker obj // Pointer to the native unpacker obj
...@@ -91,13 +86,13 @@ class NativeUnpack { ...@@ -91,13 +86,13 @@ class NativeUnpack {
NativeUnpack(UnpackerImpl p200) { NativeUnpack(UnpackerImpl p200) {
super(); super();
_p200 = p200; _p200 = p200;
_props = p200._props; _props = p200.props;
p200._nunp = this; p200._nunp = this;
} }
// for JNI callbacks // for JNI callbacks
static private Object currentInstance() { static private Object currentInstance() {
UnpackerImpl p200 = (UnpackerImpl) Utils.currentInstance.get(); UnpackerImpl p200 = (UnpackerImpl) Utils.getTLGlobals();
return (p200 == null)? null: p200._nunp; return (p200 == null)? null: p200._nunp;
} }
...@@ -216,10 +211,10 @@ class NativeUnpack { ...@@ -216,10 +211,10 @@ class NativeUnpack {
++_fileCount; ++_fileCount;
updateProgress(); updateProgress();
} }
presetInput = getUnusedInput();
long consumed = finish(); long consumed = finish();
if (_verbose > 0) if (_verbose > 0)
Utils.log.info("bytes consumed = "+consumed); Utils.log.info("bytes consumed = "+consumed);
presetInput = getUnusedInput();
if (presetInput == null && if (presetInput == null &&
!Utils.isPackMagic(Utils.readMagic(in))) { !Utils.isPackMagic(Utils.readMagic(in))) {
break; break;
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
package com.sun.java.util.jar.pack; package com.sun.java.util.jar.pack;
import com.sun.java.util.jar.pack.Attribute.Layout;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.*; import java.util.*;
import java.util.zip.*;
import java.util.jar.*; import java.util.jar.*;
import java.io.*; import java.io.*;
import com.sun.java.util.jar.pack.ConstantPool.*; import com.sun.java.util.jar.pack.ConstantPool.*;
...@@ -77,10 +77,11 @@ class Package implements Constants { ...@@ -77,10 +77,11 @@ class Package implements Constants {
cp = new ConstantPool.IndexGroup(); cp = new ConstantPool.IndexGroup();
classes.clear(); classes.clear();
files.clear(); files.clear();
BandStructure.nextSeqForDebug = 0;
} }
int getPackageVersion() { int getPackageVersion() {
return (package_majver << 16) + (int)package_minver; return (package_majver << 16) + package_minver;
} }
// Special empty versions of Code and InnerClasses, used for markers. // Special empty versions of Code and InnerClasses, used for markers.
...@@ -89,7 +90,7 @@ class Package implements Constants { ...@@ -89,7 +90,7 @@ class Package implements Constants {
public static final Attribute.Layout attrSourceFileSpecial; public static final Attribute.Layout attrSourceFileSpecial;
public static final Map attrDefs; public static final Map attrDefs;
static { static {
HashMap ad = new HashMap(2); HashMap<Layout, Attribute> ad = new HashMap<>(3);
attrCodeEmpty = Attribute.define(ad, ATTR_CONTEXT_METHOD, attrCodeEmpty = Attribute.define(ad, ATTR_CONTEXT_METHOD,
"Code", "").layout(); "Code", "").layout();
attrInnerClassesEmpty = Attribute.define(ad, ATTR_CONTEXT_CLASS, attrInnerClassesEmpty = Attribute.define(ad, ATTR_CONTEXT_CLASS,
...@@ -159,9 +160,9 @@ class Package implements Constants { ...@@ -159,9 +160,9 @@ class Package implements Constants {
} }
} }
ArrayList classes = new ArrayList(); ArrayList<Package.Class> classes = new ArrayList<>();
public List getClasses() { public List<Package.Class> getClasses() {
return classes; return classes;
} }
...@@ -186,11 +187,11 @@ class Package implements Constants { ...@@ -186,11 +187,11 @@ class Package implements Constants {
ClassEntry[] interfaces; ClassEntry[] interfaces;
// Class parts // Class parts
ArrayList fields; ArrayList<Field> fields;
ArrayList methods; ArrayList<Method> methods;
//ArrayList attributes; // in Attribute.Holder.this.attributes //ArrayList attributes; // in Attribute.Holder.this.attributes
// Note that InnerClasses may be collected at the package level. // Note that InnerClasses may be collected at the package level.
ArrayList innerClasses; ArrayList<InnerClass> innerClasses;
Class(int flags, ClassEntry thisClass, ClassEntry superClass, ClassEntry[] interfaces) { Class(int flags, ClassEntry thisClass, ClassEntry superClass, ClassEntry[] interfaces) {
this.magic = JAVA_MAGIC; this.magic = JAVA_MAGIC;
...@@ -270,7 +271,7 @@ class Package implements Constants { ...@@ -270,7 +271,7 @@ class Package implements Constants {
if (a != olda) { if (a != olda) {
if (verbose > 2) if (verbose > 2)
Utils.log.fine("recoding obvious SourceFile="+obvious); Utils.log.fine("recoding obvious SourceFile="+obvious);
List newAttrs = new ArrayList(getAttributes()); List<Attribute> newAttrs = new ArrayList<>(getAttributes());
int where = newAttrs.indexOf(olda); int where = newAttrs.indexOf(olda);
newAttrs.set(where, a); newAttrs.set(where, a);
setAttributes(newAttrs); setAttributes(newAttrs);
...@@ -295,12 +296,12 @@ class Package implements Constants { ...@@ -295,12 +296,12 @@ class Package implements Constants {
boolean hasInnerClasses() { boolean hasInnerClasses() {
return innerClasses != null; return innerClasses != null;
} }
List getInnerClasses() { List<InnerClass> getInnerClasses() {
return innerClasses; return innerClasses;
} }
public void setInnerClasses(Collection ics) { public void setInnerClasses(Collection<InnerClass> ics) {
innerClasses = (ics == null) ? null : new ArrayList(ics); innerClasses = (ics == null) ? null : new ArrayList<InnerClass>(ics);
// Edit the attribute list, if necessary. // Edit the attribute list, if necessary.
Attribute a = getAttribute(attrInnerClassesEmpty); Attribute a = getAttribute(attrInnerClassesEmpty);
if (innerClasses != null && a == null) if (innerClasses != null && a == null)
...@@ -318,19 +319,18 @@ class Package implements Constants { ...@@ -318,19 +319,18 @@ class Package implements Constants {
* The order of the resulting list is consistent * The order of the resulting list is consistent
* with that of Package.this.allInnerClasses. * with that of Package.this.allInnerClasses.
*/ */
public List computeGloballyImpliedICs() { public List<InnerClass> computeGloballyImpliedICs() {
HashSet cpRefs = new HashSet(); HashSet<Entry> cpRefs = new HashSet<>();
{ // This block temporarily displaces this.innerClasses. { // This block temporarily displaces this.innerClasses.
ArrayList innerClassesSaved = innerClasses; ArrayList<InnerClass> innerClassesSaved = innerClasses;
innerClasses = null; // ignore for the moment innerClasses = null; // ignore for the moment
visitRefs(VRM_CLASSIC, cpRefs); visitRefs(VRM_CLASSIC, cpRefs);
innerClasses = innerClassesSaved; innerClasses = innerClassesSaved;
} }
ConstantPool.completeReferencesIn(cpRefs, true); ConstantPool.completeReferencesIn(cpRefs, true);
HashSet icRefs = new HashSet(); HashSet<Entry> icRefs = new HashSet<>();
for (Iterator i = cpRefs.iterator(); i.hasNext(); ) { for (Entry e : cpRefs) {
Entry e = (Entry) i.next();
// Restrict cpRefs to InnerClasses entries only. // Restrict cpRefs to InnerClasses entries only.
if (!(e instanceof ClassEntry)) continue; if (!(e instanceof ClassEntry)) continue;
// For every IC reference, add its outers also. // For every IC reference, add its outers also.
...@@ -345,9 +345,8 @@ class Package implements Constants { ...@@ -345,9 +345,8 @@ class Package implements Constants {
// This loop is structured this way so as to accumulate // This loop is structured this way so as to accumulate
// entries into impliedICs in an order which reflects // entries into impliedICs in an order which reflects
// the order of allInnerClasses. // the order of allInnerClasses.
ArrayList impliedICs = new ArrayList(); ArrayList<InnerClass> impliedICs = new ArrayList<>();
for (Iterator i = allInnerClasses.iterator(); i.hasNext(); ) { for (InnerClass ic : allInnerClasses) {
InnerClass ic = (InnerClass) i.next();
// This one is locally relevant if it describes // This one is locally relevant if it describes
// a member of the current class, or if the current // a member of the current class, or if the current
// class uses it somehow. In the particular case // class uses it somehow. In the particular case
...@@ -366,10 +365,11 @@ class Package implements Constants { ...@@ -366,10 +365,11 @@ class Package implements Constants {
// Helper for both minimizing and expanding. // Helper for both minimizing and expanding.
// Computes a symmetric difference. // Computes a symmetric difference.
private List computeICdiff() { private List<InnerClass> computeICdiff() {
List impliedICs = computeGloballyImpliedICs(); List<InnerClass> impliedICs = computeGloballyImpliedICs();
List actualICs = getInnerClasses(); List<InnerClass> actualICs = getInnerClasses();
if (actualICs == null) actualICs = Collections.EMPTY_LIST; if (actualICs == null)
actualICs = Collections.EMPTY_LIST;
// Symmetric difference is calculated from I, A like this: // Symmetric difference is calculated from I, A like this:
// diff = (I+A) - (I*A) // diff = (I+A) - (I*A)
...@@ -388,8 +388,8 @@ class Package implements Constants { ...@@ -388,8 +388,8 @@ class Package implements Constants {
// Diff is A since I is empty. // Diff is A since I is empty.
} }
// (I*A) is non-trivial // (I*A) is non-trivial
HashSet center = new HashSet(actualICs); HashSet<InnerClass> center = new HashSet<>(actualICs);
center.retainAll(new HashSet(impliedICs)); center.retainAll(new HashSet<>(impliedICs));
impliedICs.addAll(actualICs); impliedICs.addAll(actualICs);
impliedICs.removeAll(center); impliedICs.removeAll(center);
// Diff is now I^A = (I+A)-(I*A). // Diff is now I^A = (I+A)-(I*A).
...@@ -407,9 +407,9 @@ class Package implements Constants { ...@@ -407,9 +407,9 @@ class Package implements Constants {
* to use the globally implied ICs changed. * to use the globally implied ICs changed.
*/ */
void minimizeLocalICs() { void minimizeLocalICs() {
List diff = computeICdiff(); List<InnerClass> diff = computeICdiff();
List actualICs = innerClasses; List<InnerClass> actualICs = innerClasses;
List localICs; // will be the diff, modulo edge cases List<InnerClass> localICs; // will be the diff, modulo edge cases
if (diff.isEmpty()) { if (diff.isEmpty()) {
// No diff, so transmit no attribute. // No diff, so transmit no attribute.
localICs = null; localICs = null;
...@@ -439,12 +439,12 @@ class Package implements Constants { ...@@ -439,12 +439,12 @@ class Package implements Constants {
* Otherwise, return positive if any IC tuples were added. * Otherwise, return positive if any IC tuples were added.
*/ */
int expandLocalICs() { int expandLocalICs() {
List localICs = innerClasses; List<InnerClass> localICs = innerClasses;
List actualICs; List<InnerClass> actualICs;
int changed; int changed;
if (localICs == null) { if (localICs == null) {
// Diff was empty. (Common case.) // Diff was empty. (Common case.)
List impliedICs = computeGloballyImpliedICs(); List<InnerClass> impliedICs = computeGloballyImpliedICs();
if (impliedICs.isEmpty()) { if (impliedICs.isEmpty()) {
actualICs = null; actualICs = null;
changed = 0; changed = 0;
...@@ -490,7 +490,7 @@ class Package implements Constants { ...@@ -490,7 +490,7 @@ class Package implements Constants {
protected Entry[] getCPMap() { protected Entry[] getCPMap() {
return cpMap; return cpMap;
} }
protected void visitRefs(int mode, Collection refs) { protected void visitRefs(int mode, Collection<Entry> refs) {
if (verbose > 2) Utils.log.fine("visitRefs "+this); if (verbose > 2) Utils.log.fine("visitRefs "+this);
// Careful: The descriptor is used by the package, // Careful: The descriptor is used by the package,
// but the classfile breaks it into component refs. // but the classfile breaks it into component refs.
...@@ -518,7 +518,7 @@ class Package implements Constants { ...@@ -518,7 +518,7 @@ class Package implements Constants {
super(flags, descriptor); super(flags, descriptor);
assert(!descriptor.isMethod()); assert(!descriptor.isMethod());
if (fields == null) if (fields == null)
fields = new ArrayList(); fields = new ArrayList<>();
boolean added = fields.add(this); boolean added = fields.add(this);
assert(added); assert(added);
order = fields.size(); order = fields.size();
...@@ -543,7 +543,7 @@ class Package implements Constants { ...@@ -543,7 +543,7 @@ class Package implements Constants {
super(flags, descriptor); super(flags, descriptor);
assert(descriptor.isMethod()); assert(descriptor.isMethod());
if (methods == null) if (methods == null)
methods = new ArrayList(); methods = new ArrayList<>();
boolean added = methods.add(this); boolean added = methods.add(this);
assert(added); assert(added);
} }
...@@ -573,7 +573,7 @@ class Package implements Constants { ...@@ -573,7 +573,7 @@ class Package implements Constants {
code.strip(attrName); code.strip(attrName);
super.strip(attrName); super.strip(attrName);
} }
protected void visitRefs(int mode, Collection refs) { protected void visitRefs(int mode, Collection<Entry> refs) {
super.visitRefs(mode, refs); super.visitRefs(mode, refs);
if (code != null) { if (code != null) {
if (mode == VRM_CLASSIC) { if (mode == VRM_CLASSIC) {
...@@ -614,7 +614,7 @@ class Package implements Constants { ...@@ -614,7 +614,7 @@ class Package implements Constants {
super.strip(attrName); super.strip(attrName);
} }
protected void visitRefs(int mode, Collection refs) { protected void visitRefs(int mode, Collection<Entry> refs) {
if (verbose > 2) Utils.log.fine("visitRefs "+this); if (verbose > 2) Utils.log.fine("visitRefs "+this);
refs.add(thisClass); refs.add(thisClass);
refs.add(superClass); refs.add(superClass);
...@@ -641,7 +641,7 @@ class Package implements Constants { ...@@ -641,7 +641,7 @@ class Package implements Constants {
super.visitRefs(mode, refs); super.visitRefs(mode, refs);
} }
protected void visitInnerClassRefs(int mode, Collection refs) { protected void visitInnerClassRefs(int mode, Collection<Entry> refs) {
Package.visitInnerClassRefs(innerClasses, mode, refs); Package.visitInnerClassRefs(innerClasses, mode, refs);
} }
...@@ -713,16 +713,15 @@ class Package implements Constants { ...@@ -713,16 +713,15 @@ class Package implements Constants {
} }
// What non-class files are in this unit? // What non-class files are in this unit?
ArrayList files = new ArrayList(); ArrayList<File> files = new ArrayList<>();
public List getFiles() { public List<File> getFiles() {
return files; return files;
} }
public List getClassStubs() { public List<File> getClassStubs() {
ArrayList classStubs = new ArrayList(classes.size()); ArrayList<File> classStubs = new ArrayList<>(classes.size());
for (Iterator i = classes.iterator(); i.hasNext(); ) { for (Class cls : classes) {
Class cls = (Class) i.next();
assert(cls.file.isClassStub()); assert(cls.file.isClassStub());
classStubs.add(cls.file); classStubs.add(cls.file);
} }
...@@ -840,7 +839,7 @@ class Package implements Constants { ...@@ -840,7 +839,7 @@ class Package implements Constants {
public InputStream getInputStream() { public InputStream getInputStream() {
InputStream in = new ByteArrayInputStream(append.toByteArray()); InputStream in = new ByteArrayInputStream(append.toByteArray());
if (prepend.size() == 0) return in; if (prepend.size() == 0) return in;
ArrayList isa = new ArrayList(prepend.size()+1); ArrayList<InputStream> isa = new ArrayList<>(prepend.size()+1);
for (Iterator i = prepend.iterator(); i.hasNext(); ) { for (Iterator i = prepend.iterator(); i.hasNext(); ) {
byte[] bytes = (byte[]) i.next(); byte[] bytes = (byte[]) i.next();
isa.add(new ByteArrayInputStream(bytes)); isa.add(new ByteArrayInputStream(bytes));
...@@ -849,7 +848,7 @@ class Package implements Constants { ...@@ -849,7 +848,7 @@ class Package implements Constants {
return new SequenceInputStream(Collections.enumeration(isa)); return new SequenceInputStream(Collections.enumeration(isa));
} }
protected void visitRefs(int mode, Collection refs) { protected void visitRefs(int mode, Collection<Entry> refs) {
assert(name != null); assert(name != null);
refs.add(name); refs.add(name);
} }
...@@ -877,8 +876,8 @@ class Package implements Constants { ...@@ -877,8 +876,8 @@ class Package implements Constants {
} }
// Is there a globally declared table of inner classes? // Is there a globally declared table of inner classes?
ArrayList allInnerClasses = new ArrayList(); ArrayList<InnerClass> allInnerClasses = new ArrayList<>();
HashMap allInnerClassesByThis; HashMap<ClassEntry, InnerClass> allInnerClassesByThis;
public public
List getAllInnerClasses() { List getAllInnerClasses() {
...@@ -886,15 +885,14 @@ class Package implements Constants { ...@@ -886,15 +885,14 @@ class Package implements Constants {
} }
public public
void setAllInnerClasses(Collection ics) { void setAllInnerClasses(Collection<InnerClass> ics) {
assert(ics != allInnerClasses); assert(ics != allInnerClasses);
allInnerClasses.clear(); allInnerClasses.clear();
allInnerClasses.addAll(ics); allInnerClasses.addAll(ics);
// Make an index: // Make an index:
allInnerClassesByThis = new HashMap(allInnerClasses.size()); allInnerClassesByThis = new HashMap<>(allInnerClasses.size());
for (Iterator i = allInnerClasses.iterator(); i.hasNext(); ) { for (InnerClass ic : allInnerClasses) {
InnerClass ic = (InnerClass) i.next();
Object pic = allInnerClassesByThis.put(ic.thisClass, ic); Object pic = allInnerClassesByThis.put(ic.thisClass, ic);
assert(pic == null); // caller must ensure key uniqueness! assert(pic == null); // caller must ensure key uniqueness!
} }
...@@ -904,7 +902,7 @@ class Package implements Constants { ...@@ -904,7 +902,7 @@ class Package implements Constants {
public public
InnerClass getGlobalInnerClass(Entry thisClass) { InnerClass getGlobalInnerClass(Entry thisClass) {
assert(thisClass instanceof ClassEntry); assert(thisClass instanceof ClassEntry);
return (InnerClass) allInnerClassesByThis.get(thisClass); return allInnerClassesByThis.get(thisClass);
} }
static static
...@@ -963,7 +961,7 @@ class Package implements Constants { ...@@ -963,7 +961,7 @@ class Package implements Constants {
return this.thisClass.compareTo(that.thisClass); return this.thisClass.compareTo(that.thisClass);
} }
protected void visitRefs(int mode, Collection refs) { protected void visitRefs(int mode, Collection<Entry> refs) {
refs.add(thisClass); refs.add(thisClass);
if (mode == VRM_CLASSIC || !predictable) { if (mode == VRM_CLASSIC || !predictable) {
// If the name can be demangled, the package omits // If the name can be demangled, the package omits
...@@ -980,7 +978,7 @@ class Package implements Constants { ...@@ -980,7 +978,7 @@ class Package implements Constants {
// Helper for building InnerClasses attributes. // Helper for building InnerClasses attributes.
static private static private
void visitInnerClassRefs(Collection innerClasses, int mode, Collection refs) { void visitInnerClassRefs(Collection innerClasses, int mode, Collection<Entry> refs) {
if (innerClasses == null) { if (innerClasses == null) {
return; // no attribute; nothing to do return; // no attribute; nothing to do
} }
...@@ -1165,9 +1163,8 @@ class Package implements Constants { ...@@ -1165,9 +1163,8 @@ class Package implements Constants {
} }
} }
protected void visitRefs(int mode, Collection refs) { protected void visitRefs(int mode, Collection<Entry> refs) {
for (Iterator i = classes.iterator(); i.hasNext(); ) { for ( Class c : classes) {
Class c = (Class)i.next();
c.visitRefs(mode, refs); c.visitRefs(mode, refs);
} }
if (mode != VRM_CLASSIC) { if (mode != VRM_CLASSIC) {
...@@ -1259,7 +1256,7 @@ class Package implements Constants { ...@@ -1259,7 +1256,7 @@ class Package implements Constants {
} }
// Use this before writing the package file. // Use this before writing the package file.
void buildGlobalConstantPool(Set requiredEntries) { void buildGlobalConstantPool(Set<Entry> requiredEntries) {
if (verbose > 1) if (verbose > 1)
Utils.log.fine("Checking for unused CP entries"); Utils.log.fine("Checking for unused CP entries");
requiredEntries.add(getRefString("")); // uconditionally present requiredEntries.add(getRefString("")); // uconditionally present
...@@ -1291,9 +1288,8 @@ class Package implements Constants { ...@@ -1291,9 +1288,8 @@ class Package implements Constants {
// Use this before writing the class files. // Use this before writing the class files.
void ensureAllClassFiles() { void ensureAllClassFiles() {
HashSet fileSet = new HashSet(files); HashSet<File> fileSet = new HashSet<>(files);
for (Iterator i = classes.iterator(); i.hasNext(); ) { for (Class cls : classes) {
Class cls = (Class) i.next();
// Add to the end of ths list: // Add to the end of ths list:
if (!fileSet.contains(cls.file)) if (!fileSet.contains(cls.file))
files.add(cls.file); files.add(cls.file);
......
/* /*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,12 +25,11 @@ ...@@ -25,12 +25,11 @@
package com.sun.java.util.jar.pack; package com.sun.java.util.jar.pack;
import com.sun.java.util.jar.pack.Attribute.Layout;
import java.util.*; import java.util.*;
import java.util.jar.*; import java.util.jar.*;
import java.util.zip.*;
import java.io.*; import java.io.*;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
/* /*
...@@ -41,31 +40,22 @@ import java.beans.PropertyChangeEvent; ...@@ -41,31 +40,22 @@ import java.beans.PropertyChangeEvent;
*/ */
public class PackerImpl implements Pack200.Packer { public class PackerImpl extends TLGlobals implements Pack200.Packer {
/** /**
* Constructs a Packer object and sets the initial state of * Constructs a Packer object and sets the initial state of
* the packer engines. * the packer engines.
*/ */
public PackerImpl() { public PackerImpl() {}
_props = new PropMap();
//_props.getProperty() consults defaultProps invisibly.
//_props.putAll(defaultProps);
}
// Private stuff.
final PropMap _props;
/** /**
* Get the set of options for the pack and unpack engines. * Get the set of options for the pack and unpack engines.
* @return A sorted association of option key strings to option values. * @return A sorted association of option key strings to option values.
*/ */
public SortedMap properties() { public SortedMap<String, String> properties() {
return _props; return props;
} }
//Driver routines //Driver routines
/** /**
...@@ -78,21 +68,22 @@ public class PackerImpl implements Pack200.Packer { ...@@ -78,21 +68,22 @@ public class PackerImpl implements Pack200.Packer {
*/ */
public void pack(JarFile in, OutputStream out) throws IOException { public void pack(JarFile in, OutputStream out) throws IOException {
assert(Utils.currentInstance.get() == null); assert(Utils.currentInstance.get() == null);
TimeZone tz = (_props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null : TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
TimeZone.getDefault(); ? null
: TimeZone.getDefault();
try { try {
Utils.currentInstance.set(this); Utils.currentInstance.set(this);
if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
if ("0".equals(_props.getProperty(Pack200.Packer.EFFORT))) { if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
Utils.copyJarFile(in, out); Utils.copyJarFile(in, out);
} else { } else {
(new DoPack()).run(in, out); (new DoPack()).run(in, out);
in.close();
} }
} finally { } finally {
Utils.currentInstance.set(null); Utils.currentInstance.set(null);
if (tz != null) TimeZone.setDefault(tz); if (tz != null) TimeZone.setDefault(tz);
in.close();
} }
} }
...@@ -112,21 +103,20 @@ public class PackerImpl implements Pack200.Packer { ...@@ -112,21 +103,20 @@ public class PackerImpl implements Pack200.Packer {
*/ */
public void pack(JarInputStream in, OutputStream out) throws IOException { public void pack(JarInputStream in, OutputStream out) throws IOException {
assert(Utils.currentInstance.get() == null); assert(Utils.currentInstance.get() == null);
TimeZone tz = (_props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null : TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null :
TimeZone.getDefault(); TimeZone.getDefault();
try { try {
Utils.currentInstance.set(this); Utils.currentInstance.set(this);
if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
if ("0".equals(_props.getProperty(Pack200.Packer.EFFORT))) { if ("0".equals(props.getProperty(Pack200.Packer.EFFORT))) {
Utils.copyJarFile(in, out); Utils.copyJarFile(in, out);
} else { } else {
(new DoPack()).run(in, out); (new DoPack()).run(in, out);
in.close();
} }
} finally { } finally {
Utils.currentInstance.set(null); Utils.currentInstance.set(null);
if (tz != null) TimeZone.setDefault(tz); if (tz != null) TimeZone.setDefault(tz);
in.close();
} }
} }
/** /**
...@@ -134,7 +124,7 @@ public class PackerImpl implements Pack200.Packer { ...@@ -134,7 +124,7 @@ public class PackerImpl implements Pack200.Packer {
* @param listener An object to be invoked when a property is changed. * @param listener An object to be invoked when a property is changed.
*/ */
public void addPropertyChangeListener(PropertyChangeListener listener) { public void addPropertyChangeListener(PropertyChangeListener listener) {
_props.addListener(listener); props.addListener(listener);
} }
/** /**
...@@ -142,7 +132,7 @@ public class PackerImpl implements Pack200.Packer { ...@@ -142,7 +132,7 @@ public class PackerImpl implements Pack200.Packer {
* @param listener The PropertyChange listener to be removed. * @param listener The PropertyChange listener to be removed.
*/ */
public void removePropertyChangeListener(PropertyChangeListener listener) { public void removePropertyChangeListener(PropertyChangeListener listener) {
_props.removeListener(listener); props.removeListener(listener);
} }
...@@ -151,11 +141,11 @@ public class PackerImpl implements Pack200.Packer { ...@@ -151,11 +141,11 @@ public class PackerImpl implements Pack200.Packer {
// The packer worker. // The packer worker.
private class DoPack { private class DoPack {
final int verbose = _props.getInteger(Utils.DEBUG_VERBOSE); final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
{ {
_props.setInteger(Pack200.Packer.PROGRESS, 0); props.setInteger(Pack200.Packer.PROGRESS, 0);
if (verbose > 0) Utils.log.info(_props.toString()); if (verbose > 0) Utils.log.info(props.toString());
} }
// Here's where the bits are collected before getting packed: // Here's where the bits are collected before getting packed:
...@@ -163,7 +153,7 @@ public class PackerImpl implements Pack200.Packer { ...@@ -163,7 +153,7 @@ public class PackerImpl implements Pack200.Packer {
final String unknownAttrCommand; final String unknownAttrCommand;
{ {
String uaMode = _props.getProperty(Pack200.Packer.UNKNOWN_ATTRIBUTE, Pack200.Packer.PASS); String uaMode = props.getProperty(Pack200.Packer.UNKNOWN_ATTRIBUTE, Pack200.Packer.PASS);
if (!(Pack200.Packer.STRIP.equals(uaMode) || if (!(Pack200.Packer.STRIP.equals(uaMode) ||
Pack200.Packer.PASS.equals(uaMode) || Pack200.Packer.PASS.equals(uaMode) ||
Pack200.Packer.ERROR.equals(uaMode))) { Pack200.Packer.ERROR.equals(uaMode))) {
...@@ -191,13 +181,12 @@ public class PackerImpl implements Pack200.Packer { ...@@ -191,13 +181,12 @@ public class PackerImpl implements Pack200.Packer {
}; };
for (int i = 0; i < ctypes.length; i++) { for (int i = 0; i < ctypes.length; i++) {
String pfx = keys[i]; String pfx = keys[i];
Map map = _props.prefixMap(pfx); Map<String, String> map = props.prefixMap(pfx);
for (Iterator j = map.keySet().iterator(); j.hasNext(); ) { for (String key : map.keySet()) {
String key = (String) j.next();
assert(key.startsWith(pfx)); assert(key.startsWith(pfx));
String name = key.substring(pfx.length()); String name = key.substring(pfx.length());
String layout = _props.getProperty(key); String layout = props.getProperty(key);
Object lkey = Attribute.keyForLookup(ctypes[i], name); Layout lkey = Attribute.keyForLookup(ctypes[i], name);
if (Pack200.Packer.STRIP.equals(layout) || if (Pack200.Packer.STRIP.equals(layout) ||
Pack200.Packer.PASS.equals(layout) || Pack200.Packer.PASS.equals(layout) ||
Pack200.Packer.ERROR.equals(layout)) { Pack200.Packer.ERROR.equals(layout)) {
...@@ -222,25 +211,25 @@ public class PackerImpl implements Pack200.Packer { ...@@ -222,25 +211,25 @@ public class PackerImpl implements Pack200.Packer {
} }
final boolean keepFileOrder final boolean keepFileOrder
= _props.getBoolean(Pack200.Packer.KEEP_FILE_ORDER); = props.getBoolean(Pack200.Packer.KEEP_FILE_ORDER);
final boolean keepClassOrder final boolean keepClassOrder
= _props.getBoolean(Utils.PACK_KEEP_CLASS_ORDER); = props.getBoolean(Utils.PACK_KEEP_CLASS_ORDER);
final boolean keepModtime final boolean keepModtime
= Pack200.Packer.KEEP.equals(_props.getProperty(Pack200.Packer.MODIFICATION_TIME)); = Pack200.Packer.KEEP.equals(props.getProperty(Pack200.Packer.MODIFICATION_TIME));
final boolean latestModtime final boolean latestModtime
= Pack200.Packer.LATEST.equals(_props.getProperty(Pack200.Packer.MODIFICATION_TIME)); = Pack200.Packer.LATEST.equals(props.getProperty(Pack200.Packer.MODIFICATION_TIME));
final boolean keepDeflateHint final boolean keepDeflateHint
= Pack200.Packer.KEEP.equals(_props.getProperty(Pack200.Packer.DEFLATE_HINT)); = Pack200.Packer.KEEP.equals(props.getProperty(Pack200.Packer.DEFLATE_HINT));
{ {
if (!keepModtime && !latestModtime) { if (!keepModtime && !latestModtime) {
int modtime = _props.getTime(Pack200.Packer.MODIFICATION_TIME); int modtime = props.getTime(Pack200.Packer.MODIFICATION_TIME);
if (modtime != Constants.NO_MODTIME) { if (modtime != Constants.NO_MODTIME) {
pkg.default_modtime = modtime; pkg.default_modtime = modtime;
} }
} }
if (!keepDeflateHint) { if (!keepDeflateHint) {
boolean deflate_hint = _props.getBoolean(Pack200.Packer.DEFLATE_HINT); boolean deflate_hint = props.getBoolean(Pack200.Packer.DEFLATE_HINT);
if (deflate_hint) { if (deflate_hint) {
pkg.default_options |= Constants.AO_DEFLATE_HINT; pkg.default_options |= Constants.AO_DEFLATE_HINT;
} }
...@@ -254,10 +243,10 @@ public class PackerImpl implements Pack200.Packer { ...@@ -254,10 +243,10 @@ public class PackerImpl implements Pack200.Packer {
final long segmentLimit; final long segmentLimit;
{ {
long limit; long limit;
if (_props.getProperty(Pack200.Packer.SEGMENT_LIMIT, "").equals("")) if (props.getProperty(Pack200.Packer.SEGMENT_LIMIT, "").equals(""))
limit = -1; limit = -1;
else else
limit = _props.getLong(Pack200.Packer.SEGMENT_LIMIT); limit = props.getLong(Pack200.Packer.SEGMENT_LIMIT);
limit = Math.min(Integer.MAX_VALUE, limit); limit = Math.min(Integer.MAX_VALUE, limit);
limit = Math.max(-1, limit); limit = Math.max(-1, limit);
if (limit == -1) if (limit == -1)
...@@ -265,10 +254,10 @@ public class PackerImpl implements Pack200.Packer { ...@@ -265,10 +254,10 @@ public class PackerImpl implements Pack200.Packer {
segmentLimit = limit; segmentLimit = limit;
} }
final List passFiles; // parsed pack.pass.file options final List<String> passFiles; // parsed pack.pass.file options
{ {
// Which class files will be passed through? // Which class files will be passed through?
passFiles = _props.getProperties(Pack200.Packer.PASS_FILE_PFX); passFiles = props.getProperties(Pack200.Packer.PASS_FILE_PFX);
for (ListIterator i = passFiles.listIterator(); i.hasNext(); ) { for (ListIterator i = passFiles.listIterator(); i.hasNext(); ) {
String file = (String) i.next(); String file = (String) i.next();
if (file == null) { i.remove(); continue; } if (file == null) { i.remove(); continue; }
...@@ -283,28 +272,28 @@ public class PackerImpl implements Pack200.Packer { ...@@ -283,28 +272,28 @@ public class PackerImpl implements Pack200.Packer {
{ {
// Fill in permitted range of major/minor version numbers. // Fill in permitted range of major/minor version numbers.
int ver; int ver;
if ((ver = _props.getInteger(Utils.COM_PREFIX+"min.class.majver")) != 0) if ((ver = props.getInteger(Utils.COM_PREFIX+"min.class.majver")) != 0)
pkg.min_class_majver = (short) ver; pkg.min_class_majver = (short) ver;
if ((ver = _props.getInteger(Utils.COM_PREFIX+"min.class.minver")) != 0) if ((ver = props.getInteger(Utils.COM_PREFIX+"min.class.minver")) != 0)
pkg.min_class_minver = (short) ver; pkg.min_class_minver = (short) ver;
if ((ver = _props.getInteger(Utils.COM_PREFIX+"max.class.majver")) != 0) if ((ver = props.getInteger(Utils.COM_PREFIX+"max.class.majver")) != 0)
pkg.max_class_majver = (short) ver; pkg.max_class_majver = (short) ver;
if ((ver = _props.getInteger(Utils.COM_PREFIX+"max.class.minver")) != 0) if ((ver = props.getInteger(Utils.COM_PREFIX+"max.class.minver")) != 0)
pkg.max_class_minver = (short) ver; pkg.max_class_minver = (short) ver;
if ((ver = _props.getInteger(Utils.COM_PREFIX+"package.minver")) != 0) if ((ver = props.getInteger(Utils.COM_PREFIX+"package.minver")) != 0)
pkg.package_minver = (short) ver; pkg.package_minver = (short) ver;
if ((ver = _props.getInteger(Utils.COM_PREFIX+"package.majver")) != 0) if ((ver = props.getInteger(Utils.COM_PREFIX+"package.majver")) != 0)
pkg.package_majver = (short) ver; pkg.package_majver = (short) ver;
} }
{ {
// Hook for testing: Forces use of special archive modes. // Hook for testing: Forces use of special archive modes.
int opt = _props.getInteger(Utils.COM_PREFIX+"archive.options"); int opt = props.getInteger(Utils.COM_PREFIX+"archive.options");
if (opt != 0) if (opt != 0)
pkg.default_options |= opt; pkg.default_options |= opt;
} }
// (Done collecting options from _props.) // (Done collecting options from props.)
boolean isClassFile(String name) { boolean isClassFile(String name) {
if (!name.endsWith(".class")) return false; if (!name.endsWith(".class")) return false;
...@@ -423,16 +412,18 @@ public class PackerImpl implements Pack200.Packer { ...@@ -423,16 +412,18 @@ public class PackerImpl implements Pack200.Packer {
Package.File file = null; Package.File file = null;
// (5078608) : discount the resource files in META-INF // (5078608) : discount the resource files in META-INF
// from segment computation. // from segment computation.
long inflen = (isMetaInfFile(name)) ? 0L : long inflen = (isMetaInfFile(name))
inFile.getInputLength(); ? 0L
: inFile.getInputLength();
if ((segmentSize += inflen) > segmentLimit) { if ((segmentSize += inflen) > segmentLimit) {
segmentSize -= inflen; segmentSize -= inflen;
int nextCount = -1; // don't know; it's a stream int nextCount = -1; // don't know; it's a stream
flushPartial(out, nextCount); flushPartial(out, nextCount);
} }
if (verbose > 1) if (verbose > 1) {
Utils.log.fine("Reading " + name); Utils.log.fine("Reading " + name);
}
assert(je.isDirectory() == name.endsWith("/")); assert(je.isDirectory() == name.endsWith("/"));
...@@ -450,18 +441,18 @@ public class PackerImpl implements Pack200.Packer { ...@@ -450,18 +441,18 @@ public class PackerImpl implements Pack200.Packer {
} }
void run(JarFile in, OutputStream out) throws IOException { void run(JarFile in, OutputStream out) throws IOException {
List inFiles = scanJar(in); List<InFile> inFiles = scanJar(in);
if (verbose > 0) if (verbose > 0)
Utils.log.info("Reading " + inFiles.size() + " files..."); Utils.log.info("Reading " + inFiles.size() + " files...");
int numDone = 0; int numDone = 0;
for (Iterator i = inFiles.iterator(); i.hasNext(); ) { for (InFile inFile : inFiles) {
InFile inFile = (InFile) i.next();
String name = inFile.name; String name = inFile.name;
// (5078608) : discount the resource files completely from segmenting // (5078608) : discount the resource files completely from segmenting
long inflen = (isMetaInfFile(name)) ? 0L : long inflen = (isMetaInfFile(name))
inFile.getInputLength() ; ? 0L
: inFile.getInputLength() ;
if ((segmentSize += inflen) > segmentLimit) { if ((segmentSize += inflen) > segmentLimit) {
segmentSize -= inflen; segmentSize -= inflen;
// Estimate number of remaining segments: // Estimate number of remaining segments:
...@@ -530,11 +521,11 @@ public class PackerImpl implements Pack200.Packer { ...@@ -530,11 +521,11 @@ public class PackerImpl implements Pack200.Packer {
} }
void flushPartial(OutputStream out, int nextCount) throws IOException { void flushPartial(OutputStream out, int nextCount) throws IOException {
if (pkg.files.size() == 0 && pkg.classes.size() == 0) { if (pkg.files.isEmpty() && pkg.classes.isEmpty()) {
return; // do not flush an empty segment return; // do not flush an empty segment
} }
flushPackage(out, Math.max(1, nextCount)); flushPackage(out, Math.max(1, nextCount));
_props.setInteger(Pack200.Packer.PROGRESS, 25); props.setInteger(Pack200.Packer.PROGRESS, 25);
// In case there will be another segment: // In case there will be another segment:
makeNextPackage(); makeNextPackage();
segmentCount += 1; segmentCount += 1;
...@@ -543,10 +534,10 @@ public class PackerImpl implements Pack200.Packer { ...@@ -543,10 +534,10 @@ public class PackerImpl implements Pack200.Packer {
} }
void flushAll(OutputStream out) throws IOException { void flushAll(OutputStream out) throws IOException {
_props.setInteger(Pack200.Packer.PROGRESS, 50); props.setInteger(Pack200.Packer.PROGRESS, 50);
flushPackage(out, 0); flushPackage(out, 0);
out.flush(); out.flush();
_props.setInteger(Pack200.Packer.PROGRESS, 100); props.setInteger(Pack200.Packer.PROGRESS, 100);
segmentCount += 1; segmentCount += 1;
segmentTotalSize += segmentSize; segmentTotalSize += segmentSize;
segmentSize = 0; segmentSize = 0;
...@@ -582,11 +573,11 @@ public class PackerImpl implements Pack200.Packer { ...@@ -582,11 +573,11 @@ public class PackerImpl implements Pack200.Packer {
pkg.trimStubs(); pkg.trimStubs();
// Do some stripping, maybe. // Do some stripping, maybe.
if (_props.getBoolean(Utils.COM_PREFIX+"strip.debug")) pkg.stripAttributeKind("Debug"); if (props.getBoolean(Utils.COM_PREFIX+"strip.debug")) pkg.stripAttributeKind("Debug");
if (_props.getBoolean(Utils.COM_PREFIX+"strip.compile")) pkg.stripAttributeKind("Compile"); if (props.getBoolean(Utils.COM_PREFIX+"strip.compile")) pkg.stripAttributeKind("Compile");
if (_props.getBoolean(Utils.COM_PREFIX+"strip.constants")) pkg.stripAttributeKind("Constant"); if (props.getBoolean(Utils.COM_PREFIX+"strip.constants")) pkg.stripAttributeKind("Constant");
if (_props.getBoolean(Utils.COM_PREFIX+"strip.exceptions")) pkg.stripAttributeKind("Exceptions"); if (props.getBoolean(Utils.COM_PREFIX+"strip.exceptions")) pkg.stripAttributeKind("Exceptions");
if (_props.getBoolean(Utils.COM_PREFIX+"strip.innerclasses")) pkg.stripAttributeKind("InnerClasses"); if (props.getBoolean(Utils.COM_PREFIX+"strip.innerclasses")) pkg.stripAttributeKind("InnerClasses");
// Must choose an archive version; PackageWriter does not. // Must choose an archive version; PackageWriter does not.
if (pkg.package_majver <= 0) pkg.choosePackageVersion(); if (pkg.package_majver <= 0) pkg.choosePackageVersion();
...@@ -606,11 +597,10 @@ public class PackerImpl implements Pack200.Packer { ...@@ -606,11 +597,10 @@ public class PackerImpl implements Pack200.Packer {
} }
} }
List scanJar(JarFile jf) throws IOException { List<InFile> scanJar(JarFile jf) throws IOException {
// Collect jar entries, preserving order. // Collect jar entries, preserving order.
List inFiles = new ArrayList(); List<InFile> inFiles = new ArrayList<>();
for (Enumeration e = jf.entries(); e.hasMoreElements(); ) { for (JarEntry je : Collections.list(jf.entries())) {
JarEntry je = (JarEntry) e.nextElement();
InFile inFile = new InFile(jf, je); InFile inFile = new InFile(jf, je);
assert(je.isDirectory() == inFile.name.endsWith("/")); assert(je.isDirectory() == inFile.name.endsWith("/"));
inFiles.add(inFile); inFiles.add(inFile);
......
...@@ -91,7 +91,7 @@ class PropMap extends TreeMap { ...@@ -91,7 +91,7 @@ class PropMap extends TreeMap {
String.valueOf(Boolean.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))); String.valueOf(Boolean.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)));
// The segment size is unlimited // The segment size is unlimited
props.put(Pack200.Packer.SEGMENT_LIMIT, ""); props.put(Pack200.Packer.SEGMENT_LIMIT, "-1");
// Preserve file ordering by default. // Preserve file ordering by default.
props.put(Pack200.Packer.KEEP_FILE_ORDER, Pack200.Packer.TRUE); props.put(Pack200.Packer.KEEP_FILE_ORDER, Pack200.Packer.TRUE);
......
/*
* Copyright (c) 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.java.util.jar.pack;
import com.sun.java.util.jar.pack.ConstantPool.ClassEntry;
import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry;
import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry;
import com.sun.java.util.jar.pack.ConstantPool.MemberEntry;
import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry;
import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
/*
* @author ksrini
*/
/*
* This class provides a container to hold the global variables, for packer
* and unpacker instances. This is typically stashed away in a ThreadLocal,
* and the storage is destroyed upon completion. Therefore any local
* references to these members must be eliminated appropriately to prevent a
* memory leak.
*/
class TLGlobals {
// Global environment
final PropMap props;
// Needed by ConstantPool.java
private final Map<String, Utf8Entry> utf8Entries;
private final Map<String, ClassEntry> classEntries;
private final Map<Object, LiteralEntry> literalEntries;
private final Map<String, SignatureEntry> signatureEntries;
private final Map<String, DescriptorEntry> descriptorEntries;
private final Map<String, MemberEntry> memberEntries;
TLGlobals() {
utf8Entries = new HashMap<>();
classEntries = new HashMap<>();
literalEntries = new HashMap<>();
signatureEntries = new HashMap<>();
descriptorEntries = new HashMap<>();
memberEntries = new HashMap<>();
props = new PropMap();
}
SortedMap<Object, Object> getPropMap() {
return props;
}
Map<String, Utf8Entry> getUtf8Entries() {
return utf8Entries;
}
Map<String, ClassEntry> getClassEntries() {
return classEntries;
}
Map<Object, LiteralEntry> getLiteralEntries() {
return literalEntries;
}
Map<String, DescriptorEntry> getDescriptorEntries() {
return descriptorEntries;
}
Map<String, SignatureEntry> getSignatureEntries() {
return signatureEntries;
}
Map<String, MemberEntry> getMemberEntries() {
return memberEntries;
}
}
/* /*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -30,7 +30,6 @@ import java.util.jar.*; ...@@ -30,7 +30,6 @@ import java.util.jar.*;
import java.util.zip.*; import java.util.zip.*;
import java.io.*; import java.io.*;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
/* /*
* Implementation of the Pack provider. * Implementation of the Pack provider.
...@@ -40,7 +39,7 @@ import java.beans.PropertyChangeEvent; ...@@ -40,7 +39,7 @@ import java.beans.PropertyChangeEvent;
*/ */
public class UnpackerImpl implements Pack200.Unpacker { public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
/** /**
...@@ -48,7 +47,7 @@ public class UnpackerImpl implements Pack200.Unpacker { ...@@ -48,7 +47,7 @@ public class UnpackerImpl implements Pack200.Unpacker {
* @param listener An object to be invoked when a property is changed. * @param listener An object to be invoked when a property is changed.
*/ */
public void addPropertyChangeListener(PropertyChangeListener listener) { public void addPropertyChangeListener(PropertyChangeListener listener) {
_props.addListener(listener); props.addListener(listener);
} }
...@@ -57,25 +56,19 @@ public class UnpackerImpl implements Pack200.Unpacker { ...@@ -57,25 +56,19 @@ public class UnpackerImpl implements Pack200.Unpacker {
* @param listener The PropertyChange listener to be removed. * @param listener The PropertyChange listener to be removed.
*/ */
public void removePropertyChangeListener(PropertyChangeListener listener) { public void removePropertyChangeListener(PropertyChangeListener listener) {
_props.removeListener(listener); props.removeListener(listener);
} }
public UnpackerImpl() { public UnpackerImpl() {}
_props = new PropMap();
//_props.getProperty() consults defaultProps invisibly.
//_props.putAll(defaultProps);
}
// Private stuff.
final PropMap _props;
/** /**
* Get the set of options for the pack and unpack engines. * Get the set of options for the pack and unpack engines.
* @return A sorted association of option key strings to option values. * @return A sorted association of option key strings to option values.
*/ */
public SortedMap properties() { public SortedMap<String, String> properties() {
return _props; return props;
} }
// Back-pointer to NativeUnpacker, when active. // Back-pointer to NativeUnpacker, when active.
...@@ -101,19 +94,20 @@ public class UnpackerImpl implements Pack200.Unpacker { ...@@ -101,19 +94,20 @@ public class UnpackerImpl implements Pack200.Unpacker {
*/ */
public void unpack(InputStream in0, JarOutputStream out) throws IOException { public void unpack(InputStream in0, JarOutputStream out) throws IOException {
assert(Utils.currentInstance.get() == null); assert(Utils.currentInstance.get() == null);
TimeZone tz = (_props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null : TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
TimeZone.getDefault(); ? null
: TimeZone.getDefault();
try { try {
Utils.currentInstance.set(this); Utils.currentInstance.set(this);
if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
final int verbose = _props.getInteger(Utils.DEBUG_VERBOSE); final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
BufferedInputStream in = new BufferedInputStream(in0); BufferedInputStream in = new BufferedInputStream(in0);
if (Utils.isJarMagic(Utils.readMagic(in))) { if (Utils.isJarMagic(Utils.readMagic(in))) {
if (verbose > 0) if (verbose > 0)
Utils.log.info("Copying unpacked JAR file..."); Utils.log.info("Copying unpacked JAR file...");
Utils.copyJarFile(new JarInputStream(in), out); Utils.copyJarFile(new JarInputStream(in), out);
} else if (_props.getBoolean(Utils.DEBUG_DISABLE_NATIVE)) { } else if (props.getBoolean(Utils.DEBUG_DISABLE_NATIVE)) {
(new DoUnpack()).run(in, out); (new DoUnpack()).run(in, out);
in.close(); in.close();
Utils.markJarFile(out); Utils.markJarFile(out);
...@@ -142,36 +136,38 @@ public class UnpackerImpl implements Pack200.Unpacker { ...@@ -142,36 +136,38 @@ public class UnpackerImpl implements Pack200.Unpacker {
// %%% Reconsider if native unpacker learns to memory-map the file. // %%% Reconsider if native unpacker learns to memory-map the file.
FileInputStream instr = new FileInputStream(in); FileInputStream instr = new FileInputStream(in);
unpack(instr, out); unpack(instr, out);
if (_props.getBoolean(Utils.UNPACK_REMOVE_PACKFILE)) { if (props.getBoolean(Utils.UNPACK_REMOVE_PACKFILE)) {
in.delete(); in.delete();
} }
} }
private class DoUnpack { private class DoUnpack {
final int verbose = _props.getInteger(Utils.DEBUG_VERBOSE); final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
{ {
_props.setInteger(Pack200.Unpacker.PROGRESS, 0); props.setInteger(Pack200.Unpacker.PROGRESS, 0);
} }
// Here's where the bits are read from disk: // Here's where the bits are read from disk:
final Package pkg = new Package(); final Package pkg = new Package();
final boolean keepModtime final boolean keepModtime
= Pack200.Packer.KEEP.equals(_props.getProperty(Utils.UNPACK_MODIFICATION_TIME, Pack200.Packer.KEEP)); = Pack200.Packer.KEEP.equals(
props.getProperty(Utils.UNPACK_MODIFICATION_TIME, Pack200.Packer.KEEP));
final boolean keepDeflateHint final boolean keepDeflateHint
= Pack200.Packer.KEEP.equals(_props.getProperty(Pack200.Unpacker.DEFLATE_HINT, Pack200.Packer.KEEP)); = Pack200.Packer.KEEP.equals(
props.getProperty(Pack200.Unpacker.DEFLATE_HINT, Pack200.Packer.KEEP));
final int modtime; final int modtime;
final boolean deflateHint; final boolean deflateHint;
{ {
if (!keepModtime) { if (!keepModtime) {
modtime = _props.getTime(Utils.UNPACK_MODIFICATION_TIME); modtime = props.getTime(Utils.UNPACK_MODIFICATION_TIME);
} else { } else {
modtime = pkg.default_modtime; modtime = pkg.default_modtime;
} }
deflateHint = (keepDeflateHint) ? false : deflateHint = (keepDeflateHint) ? false :
_props.getBoolean(java.util.jar.Pack200.Unpacker.DEFLATE_HINT); props.getBoolean(java.util.jar.Pack200.Unpacker.DEFLATE_HINT);
} }
// Checksum apparatus. // Checksum apparatus.
...@@ -181,7 +177,7 @@ public class UnpackerImpl implements Pack200.Unpacker { ...@@ -181,7 +177,7 @@ public class UnpackerImpl implements Pack200.Unpacker {
public void run(BufferedInputStream in, JarOutputStream out) throws IOException { public void run(BufferedInputStream in, JarOutputStream out) throws IOException {
if (verbose > 0) { if (verbose > 0) {
_props.list(System.out); props.list(System.out);
} }
for (int seg = 1; ; seg++) { for (int seg = 1; ; seg++) {
unpackSegment(in, out); unpackSegment(in, out);
...@@ -194,25 +190,26 @@ public class UnpackerImpl implements Pack200.Unpacker { ...@@ -194,25 +190,26 @@ public class UnpackerImpl implements Pack200.Unpacker {
} }
private void unpackSegment(InputStream in, JarOutputStream out) throws IOException { private void unpackSegment(InputStream in, JarOutputStream out) throws IOException {
_props.setProperty(java.util.jar.Pack200.Unpacker.PROGRESS,"0"); props.setProperty(java.util.jar.Pack200.Unpacker.PROGRESS,"0");
// Process the output directory or jar output. // Process the output directory or jar output.
new PackageReader(pkg, in).read(); new PackageReader(pkg, in).read();
if (_props.getBoolean("unpack.strip.debug")) pkg.stripAttributeKind("Debug"); if (props.getBoolean("unpack.strip.debug")) pkg.stripAttributeKind("Debug");
if (_props.getBoolean("unpack.strip.compile")) pkg.stripAttributeKind("Compile"); if (props.getBoolean("unpack.strip.compile")) pkg.stripAttributeKind("Compile");
_props.setProperty(java.util.jar.Pack200.Unpacker.PROGRESS,"50"); props.setProperty(java.util.jar.Pack200.Unpacker.PROGRESS,"50");
pkg.ensureAllClassFiles(); pkg.ensureAllClassFiles();
// Now write out the files. // Now write out the files.
HashSet classesToWrite = new HashSet(pkg.getClasses()); HashSet<Package.Class> classesToWrite = new HashSet<>(pkg.getClasses());
for (Iterator i = pkg.getFiles().iterator(); i.hasNext(); ) { for (Iterator i = pkg.getFiles().iterator(); i.hasNext(); ) {
Package.File file = (Package.File) i.next(); Package.File file = (Package.File) i.next();
String name = file.nameString; String name = file.nameString;
JarEntry je = new JarEntry(Utils.getJarEntryName(name)); JarEntry je = new JarEntry(Utils.getJarEntryName(name));
boolean deflate; boolean deflate;
deflate = (keepDeflateHint) ? (((file.options & Constants.FO_DEFLATE_HINT) != 0) || deflate = (keepDeflateHint)
((pkg.default_options & Constants.AO_DEFLATE_HINT) != 0)) : ? (((file.options & Constants.FO_DEFLATE_HINT) != 0) ||
deflateHint; ((pkg.default_options & Constants.AO_DEFLATE_HINT) != 0))
: deflateHint;
boolean needCRC = !deflate; // STORE mode requires CRC boolean needCRC = !deflate; // STORE mode requires CRC
...@@ -250,7 +247,7 @@ public class UnpackerImpl implements Pack200.Unpacker { ...@@ -250,7 +247,7 @@ public class UnpackerImpl implements Pack200.Unpacker {
Utils.log.info("Writing "+Utils.zeString((ZipEntry)je)); Utils.log.info("Writing "+Utils.zeString((ZipEntry)je));
} }
assert(classesToWrite.isEmpty()); assert(classesToWrite.isEmpty());
_props.setProperty(java.util.jar.Pack200.Unpacker.PROGRESS,"100"); props.setProperty(java.util.jar.Pack200.Unpacker.PROGRESS,"100");
pkg.reset(); // reset for the next segment, if any pkg.reset(); // reset for the next segment, if any
} }
} }
......
/* /*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,6 +25,13 @@ ...@@ -25,6 +25,13 @@
package com.sun.java.util.jar.pack; package com.sun.java.util.jar.pack;
import com.sun.java.util.jar.pack.Attribute.Layout;
import com.sun.java.util.jar.pack.ConstantPool.ClassEntry;
import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry;
import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry;
import com.sun.java.util.jar.pack.ConstantPool.MemberEntry;
import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry;
import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry;
import java.util.*; import java.util.*;
import java.util.jar.*; import java.util.jar.*;
import java.util.zip.*; import java.util.zip.*;
...@@ -113,17 +120,46 @@ class Utils { ...@@ -113,17 +120,46 @@ class Utils {
*/ */
static final String PACK_ZIP_ARCHIVE_MARKER_COMMENT = "PACK200"; static final String PACK_ZIP_ARCHIVE_MARKER_COMMENT = "PACK200";
// Keep a TLS point to the current Packer or Unpacker. // Keep a TLS point to the global data and environment.
// This makes it simpler to supply environmental options // This makes it simpler to supply environmental options
// to the engine code, especially the native code. // to the engine code, especially the native code.
static final ThreadLocal currentInstance = new ThreadLocal(); static final ThreadLocal<TLGlobals> currentInstance = new ThreadLocal<>();
// convenience methods to access the TL globals
static TLGlobals getTLGlobals() {
return currentInstance.get();
}
static Map<String, Utf8Entry> getUtf8Entries() {
return getTLGlobals().getUtf8Entries();
}
static Map<String, ClassEntry> getClassEntries() {
return getTLGlobals().getClassEntries();
}
static Map<Object, LiteralEntry> getLiteralEntries() {
return getTLGlobals().getLiteralEntries();
}
static Map<String, DescriptorEntry> getDescriptorEntries() {
return getTLGlobals().getDescriptorEntries();
}
static Map<String, SignatureEntry> getSignatureEntries() {
return getTLGlobals().getSignatureEntries();
}
static Map<String, MemberEntry> getMemberEntries() {
return getTLGlobals().getMemberEntries();
}
static PropMap currentPropMap() { static PropMap currentPropMap() {
Object obj = currentInstance.get(); Object obj = currentInstance.get();
if (obj instanceof PackerImpl) if (obj instanceof PackerImpl)
return ((PackerImpl)obj)._props; return ((PackerImpl)obj).props;
if (obj instanceof UnpackerImpl) if (obj instanceof UnpackerImpl)
return ((UnpackerImpl)obj)._props; return ((UnpackerImpl)obj).props;
return null; return null;
} }
......
...@@ -813,7 +813,8 @@ public final class Connection implements Runnable { ...@@ -813,7 +813,8 @@ public final class Connection implements Runnable {
try { try {
while (true) { while (true) {
try { try {
inbuf = new byte[10]; // type and length (at most 128 octets for long form)
inbuf = new byte[129];
offset = 0; offset = 0;
seqlen = 0; seqlen = 0;
......
...@@ -470,7 +470,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { ...@@ -470,7 +470,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
public AbstractStringBuilder append(CharSequence s, int start, int end) { public AbstractStringBuilder append(CharSequence s, int start, int end) {
if (s == null) if (s == null)
s = "null"; s = "null";
if ((start < 0) || (end < 0) || (start > end) || (end > s.length())) if ((start < 0) || (start > end) || (end > s.length()))
throw new IndexOutOfBoundsException( throw new IndexOutOfBoundsException(
"start " + start + ", end " + end + ", s.length() " "start " + start + ", end " + end + ", s.length() "
+ s.length()); + s.length());
...@@ -529,7 +529,8 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence { ...@@ -529,7 +529,8 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
* or {@code offset+len > str.length} * or {@code offset+len > str.length}
*/ */
public AbstractStringBuilder append(char str[], int offset, int len) { public AbstractStringBuilder append(char str[], int offset, int len) {
ensureCapacityInternal(count + len); if (len > 0) // let arraycopy report AIOOBE for len < 0
ensureCapacityInternal(count + len);
System.arraycopy(str, offset, value, count, len); System.arraycopy(str, offset, value, count, len);
count += len; count += len;
return this; return this;
......
...@@ -413,6 +413,18 @@ class Thread implements Runnable { ...@@ -413,6 +413,18 @@ class Thread implements Runnable {
tid = nextThreadID(); tid = nextThreadID();
} }
/**
* Throws CloneNotSupportedException as a Thread can not be meaningfully
* cloned. Construct a new Thread instead.
*
* @throws CloneNotSupportedException
* always
*/
@Override
protected Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
/** /**
* Allocates a new {@code Thread} object. This constructor has the same * Allocates a new {@code Thread} object. This constructor has the same
* effect as {@linkplain #Thread(ThreadGroup,Runnable,String) Thread} * effect as {@linkplain #Thread(ThreadGroup,Runnable,String) Thread}
......
...@@ -200,7 +200,16 @@ public class Throwable implements Serializable { ...@@ -200,7 +200,16 @@ public class Throwable implements Serializable {
* @serial * @serial
* @since 1.7 * @since 1.7
*/ */
private List<Throwable> suppressedExceptions = Collections.emptyList(); private List<Throwable> suppressedExceptions = null;
/*
* This field is lazily initialized when the first suppressed
* exception is added.
*
* OutOfMemoryError is preallocated in the VM for better OOM
* diagnosability during VM initialization. Constructor can't
* be not invoked. If a new field to be added in the future must
* be initialized to non-null, it requires a synchronized VM change.
*/
/** Message for trying to suppress a null exception. */ /** Message for trying to suppress a null exception. */
private static final String NULL_CAUSE_MESSAGE = "Cannot suppress a null exception."; private static final String NULL_CAUSE_MESSAGE = "Cannot suppress a null exception.";
...@@ -329,7 +338,7 @@ public class Throwable implements Serializable { ...@@ -329,7 +338,7 @@ public class Throwable implements Serializable {
* cause is nonexistent or unknown. * cause is nonexistent or unknown.
* @since 1.4 * @since 1.4
*/ */
public Throwable getCause() { public synchronized Throwable getCause() {
return (cause==this ? null : cause); return (cause==this ? null : cause);
} }
...@@ -563,7 +572,7 @@ public class Throwable implements Serializable { ...@@ -563,7 +572,7 @@ public class Throwable implements Serializable {
s.println("\tat " + traceElement); s.println("\tat " + traceElement);
// Print suppressed exceptions, if any // Print suppressed exceptions, if any
for (Throwable se : suppressedExceptions) for (Throwable se : getSuppressedExceptions())
se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION, "\t", dejaVu); se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION, "\t", dejaVu);
// Print cause, if any // Print cause, if any
...@@ -604,7 +613,7 @@ public class Throwable implements Serializable { ...@@ -604,7 +613,7 @@ public class Throwable implements Serializable {
s.println(prefix + "\t... " + framesInCommon + " more"); s.println(prefix + "\t... " + framesInCommon + " more");
// Print suppressed exceptions, if any // Print suppressed exceptions, if any
for (Throwable se : suppressedExceptions) for (Throwable se : getSuppressedExceptions())
se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION, se.printEnclosedStackTrace(s, trace, SUPPRESSED_CAPTION,
prefix +"\t", dejaVu); prefix +"\t", dejaVu);
...@@ -747,7 +756,9 @@ public class Throwable implements Serializable { ...@@ -747,7 +756,9 @@ public class Throwable implements Serializable {
if (defensiveCopy[i] == null) if (defensiveCopy[i] == null)
throw new NullPointerException("stackTrace[" + i + "]"); throw new NullPointerException("stackTrace[" + i + "]");
this.stackTrace = defensiveCopy; synchronized (this) {
this.stackTrace = defensiveCopy;
}
} }
/** /**
...@@ -772,11 +783,11 @@ public class Throwable implements Serializable { ...@@ -772,11 +783,11 @@ public class Throwable implements Serializable {
private void readObject(ObjectInputStream s) private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException { throws IOException, ClassNotFoundException {
s.defaultReadObject(); // read in all fields s.defaultReadObject(); // read in all fields
List<Throwable> suppressed = Collections.emptyList(); List<Throwable> suppressed = null;
if (suppressedExceptions != null && if (suppressedExceptions != null &&
!suppressedExceptions.isEmpty()) { // Copy Throwables to new list !suppressedExceptions.isEmpty()) { // Copy Throwables to new list
suppressed = new ArrayList<Throwable>(); suppressed = new ArrayList<Throwable>();
for(Throwable t : suppressedExceptions) { for (Throwable t : suppressedExceptions) {
if (t == null) if (t == null)
throw new NullPointerException(NULL_CAUSE_MESSAGE); throw new NullPointerException(NULL_CAUSE_MESSAGE);
suppressed.add(t); suppressed.add(t);
...@@ -819,7 +830,7 @@ public class Throwable implements Serializable { ...@@ -819,7 +830,7 @@ public class Throwable implements Serializable {
if (exception == this) if (exception == this)
throw new IllegalArgumentException("Self-suppression not permitted"); throw new IllegalArgumentException("Self-suppression not permitted");
if (suppressedExceptions.size() == 0) if (suppressedExceptions == null)
suppressedExceptions = new ArrayList<Throwable>(); suppressedExceptions = new ArrayList<Throwable>();
suppressedExceptions.add(exception); suppressedExceptions.add(exception);
} }
...@@ -835,7 +846,10 @@ public class Throwable implements Serializable { ...@@ -835,7 +846,10 @@ public class Throwable implements Serializable {
* suppressed to deliver this exception. * suppressed to deliver this exception.
* @since 1.7 * @since 1.7
*/ */
public Throwable[] getSuppressedExceptions() { public synchronized Throwable[] getSuppressedExceptions() {
return suppressedExceptions.toArray(EMPTY_THROWABLE_ARRAY); if (suppressedExceptions == null)
return EMPTY_THROWABLE_ARRAY;
else
return suppressedExceptions.toArray(EMPTY_THROWABLE_ARRAY);
} }
} }
...@@ -1093,14 +1093,8 @@ public final class HttpCookie implements Cloneable { ...@@ -1093,14 +1093,8 @@ public final class HttpCookie implements Cloneable {
return sb.toString(); return sb.toString();
} }
private static SimpleDateFormat[] cDateFormats = null; static final TimeZone GMT = TimeZone.getTimeZone("GMT");
static {
cDateFormats = new SimpleDateFormat[COOKIE_DATE_FORMATS.length];
for (int i = 0; i < COOKIE_DATE_FORMATS.length; i++) {
cDateFormats[i] = new SimpleDateFormat(COOKIE_DATE_FORMATS[i], Locale.US);
cDateFormats[i].setTimeZone(TimeZone.getTimeZone("GMT"));
}
}
/* /*
* @param dateString a date string in one of the formats * @param dateString a date string in one of the formats
* defined in Netscape cookie spec * defined in Netscape cookie spec
...@@ -1109,12 +1103,14 @@ public final class HttpCookie implements Cloneable { ...@@ -1109,12 +1103,14 @@ public final class HttpCookie implements Cloneable {
* time and the time specified by dateString * time and the time specified by dateString
*/ */
private long expiryDate2DeltaSeconds(String dateString) { private long expiryDate2DeltaSeconds(String dateString) {
for (SimpleDateFormat df : cDateFormats) { for (int i = 0; i < COOKIE_DATE_FORMATS.length; i++) {
SimpleDateFormat df = new SimpleDateFormat(COOKIE_DATE_FORMATS[i], Locale.US);
df.setTimeZone(GMT);
try { try {
Date date = df.parse(dateString); Date date = df.parse(dateString);
return (date.getTime() - whenCreated) / 1000; return (date.getTime() - whenCreated) / 1000;
} catch (Exception e) { } catch (Exception e) {
// Ignore, try the next date format
} }
} }
return 0; return 0;
......
...@@ -856,9 +856,7 @@ public final class URI ...@@ -856,9 +856,7 @@ public final class URI
try { try {
return new URI(str); return new URI(str);
} catch (URISyntaxException x) { } catch (URISyntaxException x) {
IllegalArgumentException y = new IllegalArgumentException(); throw new IllegalArgumentException(x.getMessage(), x);
y.initCause(x);
throw y;
} }
} }
......
/* /*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -131,17 +131,19 @@ import javax.security.auth.callback.*; ...@@ -131,17 +131,19 @@ import javax.security.auth.callback.*;
* to read existing entries from the keystore, or to write new entries * to read existing entries from the keystore, or to write new entries
* into the keystore: * into the keystore:
* <pre> * <pre>
* KeyStore.ProtectionParameter protParam =
* new KeyStore.PasswordProtection(password);
*
* // get my private key * // get my private key
* KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry) * KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
* ks.getEntry("privateKeyAlias", password); * ks.getEntry("privateKeyAlias", protParam);
* PrivateKey myPrivateKey = pkEntry.getPrivateKey(); * PrivateKey myPrivateKey = pkEntry.getPrivateKey();
* *
* // save my secret key * // save my secret key
* javax.crypto.SecretKey mySecretKey; * javax.crypto.SecretKey mySecretKey;
* KeyStore.SecretKeyEntry skEntry = * KeyStore.SecretKeyEntry skEntry =
* new KeyStore.SecretKeyEntry(mySecretKey); * new KeyStore.SecretKeyEntry(mySecretKey);
* ks.setEntry("secretKeyAlias", skEntry, * ks.setEntry("secretKeyAlias", skEntry, protParam);
* new KeyStore.PasswordProtection(password));
* *
* // store away the keystore * // store away the keystore
* java.io.FileOutputStream fos = null; * java.io.FileOutputStream fos = null;
......
...@@ -103,27 +103,46 @@ public class Date extends java.util.Date { ...@@ -103,27 +103,46 @@ public class Date extends java.util.Date {
* JDBC date escape format (yyyy-mm-dd) * JDBC date escape format (yyyy-mm-dd)
*/ */
public static Date valueOf(String s) { public static Date valueOf(String s) {
int year; final int YEAR_LENGTH = 4;
int month; final int MONTH_LENGTH = 2;
int day; final int DAY_LENGTH = 2;
final int MAX_MONTH = 12;
final int MAX_DAY = 31;
int firstDash; int firstDash;
int secondDash; int secondDash;
Date d = null;
if (s == null) throw new java.lang.IllegalArgumentException(); if (s == null) {
throw new java.lang.IllegalArgumentException();
}
firstDash = s.indexOf('-'); firstDash = s.indexOf('-');
secondDash = s.indexOf('-', firstDash+1); secondDash = s.indexOf('-', firstDash + 1);
if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length()-1)) {
year = Integer.parseInt(s.substring(0, firstDash)) - 1900; if ((firstDash > 0) && (secondDash > 0) && (secondDash < s.length() - 1)) {
month = Integer.parseInt(s.substring(firstDash+1, secondDash)) - 1; String yyyy = s.substring(0, firstDash);
day = Integer.parseInt(s.substring(secondDash+1)); String mm = s.substring(firstDash + 1, secondDash);
} else { String dd = s.substring(secondDash + 1);
if (yyyy.length() == YEAR_LENGTH && mm.length() == MONTH_LENGTH &&
dd.length() == DAY_LENGTH) {
int year = Integer.parseInt(yyyy);
int month = Integer.parseInt(mm);
int day = Integer.parseInt(dd);
if ((month >= 1 && month <= MAX_MONTH) && (day >= 1 && day <= MAX_DAY)) {
d = new Date(year - 1900, month - 1, day);
}
}
}
if (d == null) {
throw new java.lang.IllegalArgumentException(); throw new java.lang.IllegalArgumentException();
} }
return new Date(year, month, day); return d;
} }
/** /**
* Formats a date in the date escape format yyyy-mm-dd. * Formats a date in the date escape format yyyy-mm-dd.
* <P> * <P>
......
/* /*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -946,7 +946,6 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -946,7 +946,6 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
/** /**
* Returns the height of a table row, in pixels. * Returns the height of a table row, in pixels.
* The default row height is 16.0.
* *
* @return the height in pixels of a table row * @return the height in pixels of a table row
* @see #setRowHeight * @see #setRowHeight
......
...@@ -36,117 +36,71 @@ package sun.java2d.pisces; ...@@ -36,117 +36,71 @@ package sun.java2d.pisces;
* semantics are unclear. * semantics are unclear.
* *
*/ */
public class Dasher extends LineSink { public class Dasher implements LineSink {
private final LineSink output;
private final float[] dash;
private final float startPhase;
private final boolean startDashOn;
private final int startIdx;
LineSink output; private final float m00, m10, m01, m11;
int[] dash; private final float det;
int startPhase;
boolean startDashOn;
int startIdx;
int idx; private boolean firstDashOn;
boolean dashOn; private boolean starting;
int phase;
int sx, sy; private int idx;
int x0, y0; private boolean dashOn;
private float phase;
int m00, m01; private float sx, sy;
int m10, m11; private float x0, y0;
private float sx1, sy1;
Transform4 transform;
boolean symmetric;
long ldet;
boolean firstDashOn;
boolean starting;
int sx1, sy1;
/**
* Empty constructor. <code>setOutput</code> and
* <code>setParameters</code> must be called prior to calling any
* other methods.
*/
public Dasher() {}
/** /**
* Constructs a <code>Dasher</code>. * Constructs a <code>Dasher</code>.
* *
* @param output an output <code>LineSink</code>. * @param output an output <code>LineSink</code>.
* @param dash an array of <code>int</code>s containing the dash * @param dash an array of <code>int</code>s containing the dash pattern
* pattern in S15.16 format. * @param phase an <code>int</code> containing the dash phase
* @param phase an <code>int</code> containing the dash phase in
* S15.16 format.
* @param transform a <code>Transform4</code> object indicating * @param transform a <code>Transform4</code> object indicating
* the transform that has been previously applied to all incoming * the transform that has been previously applied to all incoming
* coordinates. This is required in order to compute dash lengths * coordinates. This is required in order to compute dash lengths
* properly. * properly.
*/ */
public Dasher(LineSink output, public Dasher(LineSink output,
int[] dash, int phase, float[] dash, float phase,
Transform4 transform) { float a00, float a01, float a10, float a11) {
setOutput(output);
setParameters(dash, phase, transform);
}
/**
* Sets the output <code>LineSink</code> of this
* <code>Dasher</code>.
*
* @param output an output <code>LineSink</code>.
*/
public void setOutput(LineSink output) {
this.output = output;
}
/**
* Sets the parameters of this <code>Dasher</code>.
*
* @param dash an array of <code>int</code>s containing the dash
* pattern in S15.16 format.
* @param phase an <code>int</code> containing the dash phase in
* S15.16 format.
* @param transform a <code>Transform4</code> object indicating
* the transform that has been previously applied to all incoming
* coordinates. This is required in order to compute dash lengths
* properly.
*/
public void setParameters(int[] dash, int phase,
Transform4 transform) {
if (phase < 0) { if (phase < 0) {
throw new IllegalArgumentException("phase < 0 !"); throw new IllegalArgumentException("phase < 0 !");
} }
this.output = output;
// Normalize so 0 <= phase < dash[0] // Normalize so 0 <= phase < dash[0]
int idx = 0; int idx = 0;
dashOn = true; dashOn = true;
int d; float d;
while (phase >= (d = dash[idx])) { while (phase >= (d = dash[idx])) {
phase -= d; phase -= d;
idx = (idx + 1) % dash.length; idx = (idx + 1) % dash.length;
dashOn = !dashOn; dashOn = !dashOn;
} }
this.dash = new int[dash.length]; this.dash = dash;
for (int i = 0; i < dash.length; i++) {
this.dash[i] = dash[i];
}
this.startPhase = this.phase = phase; this.startPhase = this.phase = phase;
this.startDashOn = dashOn; this.startDashOn = dashOn;
this.startIdx = idx; this.startIdx = idx;
this.transform = transform; m00 = a00;
m01 = a01;
this.m00 = transform.m00; m10 = a10;
this.m01 = transform.m01; m11 = a11;
this.m10 = transform.m10; det = m00 * m11 - m01 * m10;
this.m11 = transform.m11;
this.ldet = ((long)m00*m11 - (long)m01*m10) >> 16;
this.symmetric = (m00 == m11 && m10 == -m01);
} }
public void moveTo(int x0, int y0) { public void moveTo(float x0, float y0) {
output.moveTo(x0, y0); output.moveTo(x0, y0);
this.idx = startIdx; this.idx = startIdx;
this.dashOn = this.startDashOn; this.dashOn = this.startDashOn;
...@@ -160,7 +114,7 @@ public class Dasher extends LineSink { ...@@ -160,7 +114,7 @@ public class Dasher extends LineSink {
output.lineJoin(); output.lineJoin();
} }
private void goTo(int x1, int y1) { private void goTo(float x1, float y1) {
if (dashOn) { if (dashOn) {
if (starting) { if (starting) {
this.sx1 = x1; this.sx1 = x1;
...@@ -180,52 +134,64 @@ public class Dasher extends LineSink { ...@@ -180,52 +134,64 @@ public class Dasher extends LineSink {
this.y0 = y1; this.y0 = y1;
} }
public void lineTo(int x1, int y1) { public void lineTo(float x1, float y1) {
while (true) { // The widened line is squished to a 0 width one, so no drawing is done
int d = dash[idx] - phase; if (det == 0) {
int lx = x1 - x0; goTo(x1, y1);
int ly = y1 - y0; return;
}
// Compute segment length in the untransformed float dx = x1 - x0;
// coordinate system float dy = y1 - y0;
// IMPL NOTE - use fixed point
int l; // Compute segment length in the untransformed
if (symmetric) { // coordinate system
l = (int)((PiscesMath.hypot(lx, ly)*65536L)/ldet);
} else{
long la = ((long)ly*m00 - (long)lx*m10)/ldet;
long lb = ((long)ly*m01 - (long)lx*m11)/ldet;
l = (int)PiscesMath.hypot(la, lb);
}
if (l < d) { float la = (dy*m00 - dx*m10)/det;
float lb = (dy*m01 - dx*m11)/det;
float origLen = (float) Math.hypot(la, lb);
if (origLen == 0) {
// Let the output LineSink deal with cases where dx, dy are 0.
goTo(x1, y1);
return;
}
// The scaling factors needed to get the dx and dy of the
// transformed dash segments.
float cx = dx / origLen;
float cy = dy / origLen;
while (true) {
float leftInThisDashSegment = dash[idx] - phase;
if (origLen < leftInThisDashSegment) {
goTo(x1, y1); goTo(x1, y1);
// Advance phase within current dash segment // Advance phase within current dash segment
phase += l; phase += origLen;
return;
} else if (origLen == leftInThisDashSegment) {
goTo(x1, y1);
phase = 0f;
idx = (idx + 1) % dash.length;
dashOn = !dashOn;
return; return;
} }
long t; float dashx, dashy;
int xsplit, ysplit; float dashdx = dash[idx] * cx;
// // For zero length dashses, SE appears to move 1/8 unit float dashdy = dash[idx] * cy;
// // in device space if (phase == 0) {
// if (d == 0) { dashx = x0 + dashdx;
// double dlx = lx/65536.0; dashy = y0 + dashdy;
// double dly = ly/65536.0; } else {
// len = PiscesMath.hypot(dlx, dly); float p = (leftInThisDashSegment) / dash[idx];
// double dt = 1.0/(8*len); dashx = x0 + p * dashdx;
// double dxsplit = (x0/65536.0) + dt*dlx; dashy = y0 + p * dashdy;
// double dysplit = (y0/65536.0) + dt*dly; }
// xsplit = (int)(dxsplit*65536.0);
// ysplit = (int)(dysplit*65536.0);
// } else {
t = ((long)d << 16)/l;
xsplit = x0 + (int)(t*(x1 - x0) >> 16);
ysplit = y0 + (int)(t*(y1 - y0) >> 16);
// }
goTo(xsplit, ysplit);
goTo(dashx, dashy);
origLen -= (dash[idx] - phase);
// Advance to next dash segment // Advance to next dash segment
idx = (idx + 1) % dash.length; idx = (idx + 1) % dash.length;
dashOn = !dashOn; dashOn = !dashOn;
...@@ -233,6 +199,7 @@ public class Dasher extends LineSink { ...@@ -233,6 +199,7 @@ public class Dasher extends LineSink {
} }
} }
public void close() { public void close() {
lineTo(sx, sy); lineTo(sx, sy);
if (firstDashOn) { if (firstDashOn) {
......
...@@ -39,16 +39,16 @@ package sun.java2d.pisces; ...@@ -39,16 +39,16 @@ package sun.java2d.pisces;
* <code>LineSink</code> interface. * <code>LineSink</code> interface.
* *
*/ */
public abstract class LineSink { public interface LineSink {
/** /**
* Moves the current drawing position to the point <code>(x0, * Moves the current drawing position to the point <code>(x0,
* y0)</code>. * y0)</code>.
* *
* @param x0 the X coordinate in S15.16 format * @param x0 the X coordinate
* @param y0 the Y coordinate in S15.16 format * @param y0 the Y coordinate
*/ */
public abstract void moveTo(int x0, int y0); public void moveTo(float x0, float y0);
/** /**
* Provides a hint that the current segment should be joined to * Provides a hint that the current segment should be joined to
...@@ -65,29 +65,29 @@ public abstract class LineSink { ...@@ -65,29 +65,29 @@ public abstract class LineSink {
* <p> Other <code>LineSink</code> classes should simply pass this * <p> Other <code>LineSink</code> classes should simply pass this
* hint to their output sink as needed. * hint to their output sink as needed.
*/ */
public abstract void lineJoin(); public void lineJoin();
/** /**
* Draws a line from the current drawing position to the point * Draws a line from the current drawing position to the point
* <code>(x1, y1)</code> and sets the current drawing position to * <code>(x1, y1)</code> and sets the current drawing position to
* <code>(x1, y1)</code>. * <code>(x1, y1)</code>.
* *
* @param x1 the X coordinate in S15.16 format * @param x1 the X coordinate
* @param y1 the Y coordinate in S15.16 format * @param y1 the Y coordinate
*/ */
public abstract void lineTo(int x1, int y1); public void lineTo(float x1, float y1);
/** /**
* Closes the current path by drawing a line from the current * Closes the current path by drawing a line from the current
* drawing position to the point specified by the moset recent * drawing position to the point specified by the moset recent
* <code>moveTo</code> command. * <code>moveTo</code> command.
*/ */
public abstract void close(); public void close();
/** /**
* Ends the current path. It may be necessary to end a path in * Ends the current path. It may be necessary to end a path in
* order to allow end caps to be drawn. * order to allow end caps to be drawn.
*/ */
public abstract void end(); public void end();
} }
/*
* Copyright (c) 2007, 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 sun.java2d.pisces;
public class PiscesMath {
private PiscesMath() {}
private static final int SINTAB_LG_ENTRIES = 10;
private static final int SINTAB_ENTRIES = 1 << SINTAB_LG_ENTRIES;
private static int[] sintab;
public static final int PI = (int)(Math.PI*65536.0);
public static final int TWO_PI = (int)(2.0*Math.PI*65536.0);
public static final int PI_OVER_TWO = (int)((Math.PI/2.0)*65536.0);
public static final int SQRT_TWO = (int)(Math.sqrt(2.0)*65536.0);
static {
sintab = new int[SINTAB_ENTRIES + 1];
for (int i = 0; i < SINTAB_ENTRIES + 1; i++) {
double theta = i*(Math.PI/2.0)/SINTAB_ENTRIES;
sintab[i] = (int)(Math.sin(theta)*65536.0);
}
}
public static int sin(int theta) {
int sign = 1;
if (theta < 0) {
theta = -theta;
sign = -1;
}
// 0 <= theta
while (theta >= TWO_PI) {
theta -= TWO_PI;
}
// 0 <= theta < 2*PI
if (theta >= PI) {
theta = TWO_PI - theta;
sign = -sign;
}
// 0 <= theta < PI
if (theta > PI_OVER_TWO) {
theta = PI - theta;
}
// 0 <= theta <= PI/2
int itheta = (int)((long)theta*SINTAB_ENTRIES/(PI_OVER_TWO));
return sign*sintab[itheta];
}
public static int cos(int theta) {
return sin(PI_OVER_TWO - theta);
}
// public static double sqrt(double x) {
// double dsqrt = Math.sqrt(x);
// int ix = (int)(x*65536.0);
// Int Isqrt = Isqrt(Ix);
// Long Lx = (Long)(X*65536.0);
// Long Lsqrt = Lsqrt(Lx);
// System.Out.Println();
// System.Out.Println("X = " + X);
// System.Out.Println("Dsqrt = " + Dsqrt);
// System.Out.Println("Ix = " + Ix);
// System.Out.Println("Isqrt = " + Isqrt/65536.0);
// System.Out.Println("Lx = " + Lx);
// System.Out.Println("Lsqrt = " + Lsqrt/65536.0);
// Return Dsqrt;
// }
// From Ken Turkowski, _Fixed-Point Square Root_, In Graphics Gems V
public static int isqrt(int x) {
int fracbits = 16;
int root = 0;
int remHi = 0;
int remLo = x;
int count = 15 + fracbits/2;
do {
remHi = (remHi << 2) | (remLo >>> 30); // N.B. - unsigned shift R
remLo <<= 2;
root <<= 1;
int testdiv = (root << 1) + 1;
if (remHi >= testdiv) {
remHi -= testdiv;
root++;
}
} while (count-- != 0);
return root;
}
public static long lsqrt(long x) {
int fracbits = 16;
long root = 0;
long remHi = 0;
long remLo = x;
int count = 31 + fracbits/2;
do {
remHi = (remHi << 2) | (remLo >>> 62); // N.B. - unsigned shift R
remLo <<= 2;
root <<= 1;
long testDiv = (root << 1) + 1;
if (remHi >= testDiv) {
remHi -= testDiv;
root++;
}
} while (count-- != 0);
return root;
}
public static double hypot(double x, double y) {
// new RuntimeException().printStackTrace();
return Math.sqrt(x*x + y*y);
}
public static int hypot(int x, int y) {
return (int)((lsqrt((long)x*x + (long)y*y) + 128) >> 8);
}
public static long hypot(long x, long y) {
return (lsqrt(x*x + y*y) + 128) >> 8;
}
}
...@@ -27,6 +27,7 @@ package sun.java2d.pisces; ...@@ -27,6 +27,7 @@ package sun.java2d.pisces;
import java.awt.Shape; import java.awt.Shape;
import java.awt.BasicStroke; import java.awt.BasicStroke;
import java.awt.geom.FlatteningPathIterator;
import java.awt.geom.Path2D; import java.awt.geom.Path2D;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.geom.PathIterator; import java.awt.geom.PathIterator;
...@@ -37,23 +38,9 @@ import sun.java2d.pipe.RenderingEngine; ...@@ -37,23 +38,9 @@ import sun.java2d.pipe.RenderingEngine;
import sun.java2d.pipe.AATileGenerator; import sun.java2d.pipe.AATileGenerator;
public class PiscesRenderingEngine extends RenderingEngine { public class PiscesRenderingEngine extends RenderingEngine {
public static Transform4 IdentT4 = new Transform4();
public static double defaultFlat = 0.1; public static double defaultFlat = 0.1;
static int FloatToS15_16(float flt) { private static enum NormMode {OFF, ON_NO_AA, ON_WITH_AA}
flt = flt * 65536f + 0.5f;
if (flt <= -(65536f * 65536f)) {
return Integer.MIN_VALUE;
} else if (flt >= (65536f * 65536f)) {
return Integer.MAX_VALUE;
} else {
return (int) Math.floor(flt);
}
}
static float S15_16ToFloat(int fix) {
return (fix / 65536f);
}
/** /**
* Create a widened path as specified by the parameters. * Create a widened path as specified by the parameters.
...@@ -85,18 +72,19 @@ public class PiscesRenderingEngine extends RenderingEngine { ...@@ -85,18 +72,19 @@ public class PiscesRenderingEngine extends RenderingEngine {
strokeTo(src, strokeTo(src,
null, null,
width, width,
NormMode.OFF,
caps, caps,
join, join,
miterlimit, miterlimit,
dashes, dashes,
dashphase, dashphase,
new LineSink() { new LineSink() {
public void moveTo(int x0, int y0) { public void moveTo(float x0, float y0) {
p2d.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0)); p2d.moveTo(x0, y0);
} }
public void lineJoin() {} public void lineJoin() {}
public void lineTo(int x1, int y1) { public void lineTo(float x1, float y1) {
p2d.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1)); p2d.lineTo(x1, y1);
} }
public void close() { public void close() {
p2d.closePath(); p2d.closePath();
...@@ -142,14 +130,17 @@ public class PiscesRenderingEngine extends RenderingEngine { ...@@ -142,14 +130,17 @@ public class PiscesRenderingEngine extends RenderingEngine {
boolean antialias, boolean antialias,
final PathConsumer2D consumer) final PathConsumer2D consumer)
{ {
strokeTo(src, at, bs, thin, normalize, antialias, NormMode norm = (normalize) ?
((antialias) ? NormMode.ON_WITH_AA : NormMode.ON_NO_AA)
: NormMode.OFF;
strokeTo(src, at, bs, thin, norm, antialias,
new LineSink() { new LineSink() {
public void moveTo(int x0, int y0) { public void moveTo(float x0, float y0) {
consumer.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0)); consumer.moveTo(x0, y0);
} }
public void lineJoin() {} public void lineJoin() {}
public void lineTo(int x1, int y1) { public void lineTo(float x1, float y1) {
consumer.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1)); consumer.lineTo(x1, y1);
} }
public void close() { public void close() {
consumer.closePath(); consumer.closePath();
...@@ -164,7 +155,7 @@ public class PiscesRenderingEngine extends RenderingEngine { ...@@ -164,7 +155,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
AffineTransform at, AffineTransform at,
BasicStroke bs, BasicStroke bs,
boolean thin, boolean thin,
boolean normalize, NormMode normalize,
boolean antialias, boolean antialias,
LineSink lsink) LineSink lsink)
{ {
...@@ -181,6 +172,7 @@ public class PiscesRenderingEngine extends RenderingEngine { ...@@ -181,6 +172,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
strokeTo(src, strokeTo(src,
at, at,
lw, lw,
normalize,
bs.getEndCap(), bs.getEndCap(),
bs.getLineJoin(), bs.getLineJoin(),
bs.getMiterLimit(), bs.getMiterLimit(),
...@@ -258,6 +250,7 @@ public class PiscesRenderingEngine extends RenderingEngine { ...@@ -258,6 +250,7 @@ public class PiscesRenderingEngine extends RenderingEngine {
void strokeTo(Shape src, void strokeTo(Shape src,
AffineTransform at, AffineTransform at,
float width, float width,
NormMode normalize,
int caps, int caps,
int join, int join,
float miterlimit, float miterlimit,
...@@ -265,36 +258,139 @@ public class PiscesRenderingEngine extends RenderingEngine { ...@@ -265,36 +258,139 @@ public class PiscesRenderingEngine extends RenderingEngine {
float dashphase, float dashphase,
LineSink lsink) LineSink lsink)
{ {
Transform4 t4; float a00 = 1f, a01 = 0f, a10 = 0f, a11 = 1f;
if (at != null && !at.isIdentity()) {
if (at == null || at.isIdentity()) { a00 = (float)at.getScaleX();
t4 = IdentT4; a01 = (float)at.getShearX();
a10 = (float)at.getShearY();
a11 = (float)at.getScaleY();
}
lsink = new Stroker(lsink, width, caps, join, miterlimit, a00, a01, a10, a11);
if (dashes != null) {
lsink = new Dasher(lsink, dashes, dashphase, a00, a01, a10, a11);
}
PathIterator pi;
if (normalize != NormMode.OFF) {
pi = new FlatteningPathIterator(
new NormalizingPathIterator(src.getPathIterator(at), normalize),
defaultFlat);
} else { } else {
t4 = new Transform4(FloatToS15_16((float) at.getScaleX()), pi = src.getPathIterator(at, defaultFlat);
FloatToS15_16((float) at.getShearX()),
FloatToS15_16((float) at.getShearY()),
FloatToS15_16((float) at.getScaleY()));
} }
pathTo(pi, lsink);
}
lsink = new Stroker(lsink, private static class NormalizingPathIterator implements PathIterator {
FloatToS15_16(width),
caps, private final PathIterator src;
join,
FloatToS15_16(miterlimit), // the adjustment applied to the current position.
t4); private float curx_adjust, cury_adjust;
if (dashes != null) { // the adjustment applied to the last moveTo position.
int fdashes[] = new int[dashes.length]; private float movx_adjust, movy_adjust;
for (int i = 0; i < dashes.length; i++) {
fdashes[i] = FloatToS15_16(dashes[i]); // constants used in normalization computations
private final float lval, rval;
NormalizingPathIterator(PathIterator src, NormMode mode) {
this.src = src;
switch (mode) {
case ON_NO_AA:
// round to nearest (0.25, 0.25) pixel
lval = rval = 0.25f;
break;
case ON_WITH_AA:
// round to nearest pixel center
lval = 0f;
rval = 0.5f;
break;
case OFF:
throw new InternalError("A NormalizingPathIterator should " +
"not be created if no normalization is being done");
default:
throw new InternalError("Unrecognized normalization mode");
} }
lsink = new Dasher(lsink,
fdashes,
FloatToS15_16(dashphase),
t4);
} }
PathIterator pi = src.getPathIterator(at, defaultFlat); public int currentSegment(float[] coords) {
pathTo(pi, lsink); int type = src.currentSegment(coords);
int lastCoord;
switch(type) {
case PathIterator.SEG_CUBICTO:
lastCoord = 4;
break;
case PathIterator.SEG_QUADTO:
lastCoord = 2;
break;
case PathIterator.SEG_LINETO:
case PathIterator.SEG_MOVETO:
lastCoord = 0;
break;
case PathIterator.SEG_CLOSE:
// we don't want to deal with this case later. We just exit now
curx_adjust = movx_adjust;
cury_adjust = movy_adjust;
return type;
default:
throw new InternalError("Unrecognized curve type");
}
// normalize endpoint
float x_adjust = (float)Math.floor(coords[lastCoord] + lval) + rval -
coords[lastCoord];
float y_adjust = (float)Math.floor(coords[lastCoord+1] + lval) + rval -
coords[lastCoord + 1];
coords[lastCoord ] += x_adjust;
coords[lastCoord + 1] += y_adjust;
// now that the end points are done, normalize the control points
switch(type) {
case PathIterator.SEG_CUBICTO:
coords[0] += curx_adjust;
coords[1] += cury_adjust;
coords[2] += x_adjust;
coords[3] += y_adjust;
break;
case PathIterator.SEG_QUADTO:
coords[0] += (curx_adjust + x_adjust) / 2;
coords[1] += (cury_adjust + y_adjust) / 2;
break;
case PathIterator.SEG_LINETO:
break;
case PathIterator.SEG_MOVETO:
movx_adjust = x_adjust;
movy_adjust = y_adjust;
break;
case PathIterator.SEG_CLOSE:
throw new InternalError("This should be handled earlier.");
}
curx_adjust = x_adjust;
cury_adjust = y_adjust;
return type;
}
public int currentSegment(double[] coords) {
float[] tmp = new float[6];
int type = this.currentSegment(tmp);
for (int i = 0; i < 6; i++) {
coords[i] = (float) tmp[i];
}
return type;
}
public int getWindingRule() {
return src.getWindingRule();
}
public boolean isDone() {
return src.isDone();
}
public void next() {
src.next();
}
} }
void pathTo(PathIterator pi, LineSink lsink) { void pathTo(PathIterator pi, LineSink lsink) {
...@@ -302,13 +398,11 @@ public class PiscesRenderingEngine extends RenderingEngine { ...@@ -302,13 +398,11 @@ public class PiscesRenderingEngine extends RenderingEngine {
while (!pi.isDone()) { while (!pi.isDone()) {
switch (pi.currentSegment(coords)) { switch (pi.currentSegment(coords)) {
case PathIterator.SEG_MOVETO: case PathIterator.SEG_MOVETO:
lsink.moveTo(FloatToS15_16(coords[0]), lsink.moveTo(coords[0], coords[1]);
FloatToS15_16(coords[1]));
break; break;
case PathIterator.SEG_LINETO: case PathIterator.SEG_LINETO:
lsink.lineJoin(); lsink.lineJoin();
lsink.lineTo(FloatToS15_16(coords[0]), lsink.lineTo(coords[0], coords[1]);
FloatToS15_16(coords[1]));
break; break;
case PathIterator.SEG_CLOSE: case PathIterator.SEG_CLOSE:
lsink.lineJoin(); lsink.lineJoin();
...@@ -378,18 +472,28 @@ public class PiscesRenderingEngine extends RenderingEngine { ...@@ -378,18 +472,28 @@ public class PiscesRenderingEngine extends RenderingEngine {
int bbox[]) int bbox[])
{ {
PiscesCache pc = PiscesCache.createInstance(); PiscesCache pc = PiscesCache.createInstance();
Renderer r = new Renderer(); Renderer r;
r.setCache(pc); NormMode norm = (normalize) ? NormMode.ON_WITH_AA : NormMode.OFF;
r.setAntialiasing(3, 3);
r.beginRendering(clip.getLoX(), clip.getLoY(),
clip.getWidth(), clip.getHeight());
if (bs == null) { if (bs == null) {
PathIterator pi = s.getPathIterator(at, defaultFlat); PathIterator pi;
r.setWindingRule(pi.getWindingRule()); if (normalize) {
pi = new FlatteningPathIterator(
new NormalizingPathIterator(s.getPathIterator(at), norm),
defaultFlat);
} else {
pi = s.getPathIterator(at, defaultFlat);
}
r = new Renderer(3, 3,
clip.getLoX(), clip.getLoY(),
clip.getWidth(), clip.getHeight(),
pi.getWindingRule(), pc);
pathTo(pi, r); pathTo(pi, r);
} else { } else {
r.setWindingRule(PathIterator.WIND_NON_ZERO); r = new Renderer(3, 3,
strokeTo(s, at, bs, thin, normalize, true, r); clip.getLoX(), clip.getLoY(),
clip.getWidth(), clip.getHeight(),
PathIterator.WIND_NON_ZERO, pc);
strokeTo(s, at, bs, thin, norm, true, r);
} }
r.endRendering(); r.endRendering();
PiscesTileGenerator ptg = new PiscesTileGenerator(pc, r.MAX_AA_ALPHA); PiscesTileGenerator ptg = new PiscesTileGenerator(pc, r.MAX_AA_ALPHA);
...@@ -420,3 +524,4 @@ public class PiscesRenderingEngine extends RenderingEngine { ...@@ -420,3 +524,4 @@ public class PiscesRenderingEngine extends RenderingEngine {
} }
} }
} }
...@@ -59,7 +59,7 @@ public class FileURLConnection extends URLConnection { ...@@ -59,7 +59,7 @@ public class FileURLConnection extends URLConnection {
String filename; String filename;
boolean isDirectory = false; boolean isDirectory = false;
boolean exists = false; boolean exists = false;
List files; List<String> files;
long length = -1; long length = -1;
long lastModified = 0; long lastModified = 0;
...@@ -81,7 +81,10 @@ public class FileURLConnection extends URLConnection { ...@@ -81,7 +81,10 @@ public class FileURLConnection extends URLConnection {
filename = file.toString(); filename = file.toString();
isDirectory = file.isDirectory(); isDirectory = file.isDirectory();
if (isDirectory) { if (isDirectory) {
files = (List) Arrays.asList(file.list()); String[] fileList = file.list();
if (fileList == null)
throw new FileNotFoundException(filename + " exists, but is not accessible");
files = Arrays.<String>asList(fileList);
} else { } else {
is = new BufferedInputStream(new FileInputStream(filename)); is = new BufferedInputStream(new FileInputStream(filename));
...@@ -197,7 +200,7 @@ public class FileURLConnection extends URLConnection { ...@@ -197,7 +200,7 @@ public class FileURLConnection extends URLConnection {
Collections.sort(files, Collator.getInstance()); Collections.sort(files, Collator.getInstance());
for (int i = 0 ; i < files.size() ; i++) { for (int i = 0 ; i < files.size() ; i++) {
String fileName = (String)files.get(i); String fileName = files.get(i);
buf.append(fileName); buf.append(fileName);
buf.append("\n"); buf.append("\n");
} }
......
...@@ -1768,6 +1768,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection { ...@@ -1768,6 +1768,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// Not really necessary for a tunnel, but can't hurt // Not really necessary for a tunnel, but can't hurt
requests.setIfNotSet("Accept", acceptString); requests.setIfNotSet("Accept", acceptString);
if (http.getHttpKeepAliveSet()) {
requests.setIfNotSet("Proxy-Connection", "keep-alive");
}
setPreemptiveProxyAuthentication(requests); setPreemptiveProxyAuthentication(requests);
/* Log the CONNECT request */ /* Log the CONNECT request */
......
...@@ -187,7 +187,6 @@ class UnixFileSystem extends FileSystem { ...@@ -187,7 +187,6 @@ class UnixFileSystem extends FileSystem {
} }
} }
} }
assert canonicalize0(path).equals(res) || path.startsWith(javaHome);
return res; return res;
} }
} }
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册