mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
Merge
This commit is contained in:
commit
3cd103bbeb
289 changed files with 12747 additions and 7091 deletions
|
@ -397,12 +397,10 @@ else
|
|||
INCLUDE_SA = true
|
||||
endif
|
||||
|
||||
ifdef CROSS_COMPILE_ARCH
|
||||
# X11 headers are not under /usr/include
|
||||
OTHER_CFLAGS += -I$(OPENWIN_HOME)/include
|
||||
OTHER_CXXFLAGS += -I$(OPENWIN_HOME)/include
|
||||
OTHER_CPPFLAGS += -I$(OPENWIN_HOME)/include
|
||||
endif
|
||||
# X11 headers are not under /usr/include
|
||||
OTHER_CFLAGS += -I$(OPENWIN_HOME)/include
|
||||
OTHER_CXXFLAGS += -I$(OPENWIN_HOME)/include
|
||||
OTHER_CPPFLAGS += -I$(OPENWIN_HOME)/include
|
||||
|
||||
LIB_LOCATION ?= $(LIBDIR)
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ FILES_java += java/util/prefs/MacOSXPreferences.java \
|
|||
java/util/prefs/MacOSXPreferencesFactory.java
|
||||
|
||||
CFLAGS_$(VARIANT)/java_props_md.o = -Os -x objective-c
|
||||
CFLAGS_$(VARIANT)/java_props_macosx.o = -Os -x objective-c
|
||||
endif
|
||||
|
||||
#
|
||||
|
|
|
@ -38,31 +38,31 @@ FILES_compiled_properties_orig := $(FILES_compiled_properties)
|
|||
# only FILES_java and FILES_compiled_properties variables will be picked up
|
||||
#
|
||||
# $(BUILDDIR)/java/util/FILES_java.gmk & $(BUILDDIR)/java/util/FILES_properties.gmk
|
||||
# contain "sun.util.resources" for US language support
|
||||
# contain "sun.util.resources" for EN language support
|
||||
|
||||
include $(BUILDDIR)/java/util/FILES_java.gmk
|
||||
include $(BUILDDIR)/java/util/FILES_properties.gmk
|
||||
|
||||
US_Resources_java := $(FILES_java)
|
||||
US_Resources_properties := $(FILES_compiled_properties)
|
||||
EN_Resources_java := $(FILES_java)
|
||||
EN_Resources_properties := $(FILES_compiled_properties)
|
||||
|
||||
# $(BUILDDIR)/java/text/FILES_java.gmk contains the "sun.text.resources" for
|
||||
# US language support
|
||||
# EN language support
|
||||
|
||||
include $(BUILDDIR)/java/text/base/FILES_java.gmk
|
||||
|
||||
US_Resources_java += $(FILES_java)
|
||||
EN_Resources_java += $(FILES_java)
|
||||
|
||||
FILES_compiled_properties=
|
||||
|
||||
# $(BUILDDIR)/sun/text/FILES_java.gmk & $(BUILDDIR)/sun/text/FILES_properties.gmk
|
||||
# contain both resources for Non-US language support
|
||||
# contain both resources for Non-EN language support
|
||||
|
||||
include $(BUILDDIR)/sun/text/FILES_java.gmk
|
||||
include $(BUILDDIR)/sun/text/FILES_properties.gmk
|
||||
|
||||
NonUS_Resources_java := $(FILES_java)
|
||||
NonUS_Resources_properties := $(FILES_compiled_properties)
|
||||
NonEN_Resources_java := $(FILES_java)
|
||||
NonEN_Resources_properties := $(FILES_compiled_properties)
|
||||
|
||||
# Restore the orignal FILES_java & FILES_compiled_properties variables
|
||||
FILES_java := $(FILES_java_orig)
|
||||
|
@ -80,30 +80,30 @@ RESOURCE_NAMES="FormatData CollationData TimeZoneNames LocaleNames CurrencyNames
|
|||
ifeq ($(PLATFORM), macosx)
|
||||
|
||||
$(LocaleDataMetaInfo_Dest):$(LocaleDataMetaInfo_Src) $(LOCALEGEN_SH)
|
||||
@$(RM) $@.tmp.us $@.tmp.nonus;
|
||||
@$(RM) $@.tmp.en $@.tmp.nonen;
|
||||
@$(prep-target)
|
||||
@$(ECHO) $(US_Resources_properties) | $(NAWK) 'gsub(/.properties/,"\n") {print}' > $@.tmp.us;
|
||||
@$(ECHO) $(US_Resources_java) | $(NAWK) 'gsub(/.java/,"\n") {print}' >> $@.tmp.us;
|
||||
@$(ECHO) $(NonUS_Resources_properties) | $(NAWK) 'gsub(/.properties/,"\n") {print}' > $@.tmp.nonus;
|
||||
@$(ECHO) $(NonUS_Resources_java) | $(NAWK) 'gsub(/.java/,"\n") {print}' >> $@.tmp.nonus;
|
||||
@$(ECHO) $(EN_Resources_properties) | $(NAWK) 'gsub(/.properties/,"\n") {print}' > $@.tmp.en;
|
||||
@$(ECHO) $(EN_Resources_java) | $(NAWK) 'gsub(/.java/,"\n") {print}' >> $@.tmp.en;
|
||||
@$(ECHO) $(NonEN_Resources_properties) | $(NAWK) 'gsub(/.properties/,"\n") {print}' > $@.tmp.nonen;
|
||||
@$(ECHO) $(NonEN_Resources_java) | $(NAWK) 'gsub(/.java/,"\n") {print}' >> $@.tmp.nonen;
|
||||
NAWK="$(NAWK)" SED="$(SED)" SORT="$(SORT)" \
|
||||
$(SH) $(LOCALEGEN_SH) $(RESOURCE_NAMES) $@.tmp.us \
|
||||
$@.tmp.nonus $< $@
|
||||
@$(RM) $@.tmp.us $@.tmp.nonus;
|
||||
$(SH) $(LOCALEGEN_SH) $(RESOURCE_NAMES) $@.tmp.en \
|
||||
$@.tmp.nonen $< $@
|
||||
@$(RM) $@.tmp.en $@.tmp.nonen;
|
||||
|
||||
else
|
||||
|
||||
$(LocaleDataMetaInfo_Dest):$(LocaleDataMetaInfo_Src) $(LOCALEGEN_SH)
|
||||
@$(RM) $@.tmp.us $@.tmp.nonus;
|
||||
@$(RM) $@.tmp.en $@.tmp.nonen;
|
||||
@$(prep-target)
|
||||
@$(ECHO) $(subst .properties,'\n',$(US_Resources_properties)) > $@.tmp.us;
|
||||
@$(ECHO) $(subst .java,'\n',$(US_Resources_java)) >> $@.tmp.us;
|
||||
@$(ECHO) $(subst .properties,'\n',$(NonUS_Resources_properties)) > $@.tmp.nonus;
|
||||
@$(ECHO) $(subst .java,'\n',$(NonUS_Resources_java)) >> $@.tmp.nonus;
|
||||
@$(ECHO) $(subst .properties,'\n',$(EN_Resources_properties)) > $@.tmp.en;
|
||||
@$(ECHO) $(subst .java,'\n',$(EN_Resources_java)) >> $@.tmp.en;
|
||||
@$(ECHO) $(subst .properties,'\n',$(NonEN_Resources_properties)) > $@.tmp.nonen;
|
||||
@$(ECHO) $(subst .java,'\n',$(NonEN_Resources_java)) >> $@.tmp.nonen;
|
||||
NAWK="$(NAWK)" SED="$(SED)" SORT="$(SORT)" \
|
||||
$(SH) $(LOCALEGEN_SH) $(RESOURCE_NAMES) $@.tmp.us \
|
||||
$@.tmp.nonus $< $@
|
||||
@$(RM) $@.tmp.us $@.tmp.nonus;
|
||||
$(SH) $(LOCALEGEN_SH) $(RESOURCE_NAMES) $@.tmp.en \
|
||||
$@.tmp.nonen $< $@
|
||||
@$(RM) $@.tmp.en $@.tmp.nonen;
|
||||
endif
|
||||
|
||||
genlocales : $(LocaleDataMetaInfo_Dest)
|
||||
|
|
|
@ -35,11 +35,11 @@
|
|||
# A list of resource base name list;
|
||||
RESOURCE_NAMES=$1
|
||||
|
||||
# A list of US resources;
|
||||
US_FILES_LIST=$2
|
||||
# A list of EN resources;
|
||||
EN_FILES_LIST=$2
|
||||
|
||||
# A list of non-US resources;
|
||||
NONUS_FILES_LIST=$3
|
||||
# A list of non-EN resources;
|
||||
NONEN_FILES_LIST=$3
|
||||
|
||||
INPUT_FILE=$4
|
||||
OUTPUT_FILE=$5
|
||||
|
@ -53,23 +53,23 @@ getlocalelist() {
|
|||
sed_script="$SED -e \"s@^#warn .*@// -- This file was mechanically generated: Do not edit! -- //@\" "
|
||||
|
||||
# ja-JP-JP and th-TH-TH need to be manually added, as they don't have any resource files.
|
||||
nonusall=" ja-JP-JP th-TH-TH "
|
||||
nonenall=" ja-JP-JP th-TH-TH "
|
||||
|
||||
for FILE in $RESOURCE_NAMES
|
||||
do
|
||||
getlocalelist $FILE $US_FILES_LIST
|
||||
sed_script=$sed_script"-e \"s@#"$FILE"_USLocales#@$localelist@g\" "
|
||||
usall=$usall" "$localelist
|
||||
getlocalelist $FILE $NONUS_FILES_LIST
|
||||
sed_script=$sed_script"-e \"s@#"$FILE"_NonUSLocales#@$localelist@g\" "
|
||||
nonusall=$nonusall" "$localelist
|
||||
getlocalelist $FILE $EN_FILES_LIST
|
||||
sed_script=$sed_script"-e \"s@#"$FILE"_ENLocales#@$localelist@g\" "
|
||||
enall=$enall" "$localelist
|
||||
getlocalelist $FILE $NONEN_FILES_LIST
|
||||
sed_script=$sed_script"-e \"s@#"$FILE"_NonENLocales#@$localelist@g\" "
|
||||
nonenall=$nonenall" "$localelist
|
||||
done
|
||||
|
||||
usall=`(for LOC in $usall; do echo $LOC;done) |$SORT -u`
|
||||
nonusall=`(for LOC in $nonusall; do echo $LOC;done) |$SORT -u`
|
||||
enall=`(for LOC in $enall; do echo $LOC;done) |$SORT -u`
|
||||
nonenall=`(for LOC in $nonenall; do echo $LOC;done) |$SORT -u`
|
||||
|
||||
sed_script=$sed_script"-e \"s@#AvailableLocales_USLocales#@$usall@g\" "
|
||||
sed_script=$sed_script"-e \"s@#AvailableLocales_NonUSLocales#@$nonusall@g\" "
|
||||
sed_script=$sed_script"-e \"s@#AvailableLocales_ENLocales#@$enall@g\" "
|
||||
sed_script=$sed_script"-e \"s@#AvailableLocales_NonENLocales#@$nonenall@g\" "
|
||||
|
||||
sed_script=$sed_script"$INPUT_FILE > $OUTPUT_FILE"
|
||||
eval $sed_script
|
||||
|
|
|
@ -107,5 +107,17 @@ FILES_java = \
|
|||
sun/text/resources/FormatData.java \
|
||||
sun/text/resources/JavaTimeSupplementary.java \
|
||||
sun/text/resources/en/FormatData_en.java \
|
||||
sun/text/resources/en/FormatData_en_AU.java \
|
||||
sun/text/resources/en/FormatData_en_CA.java \
|
||||
sun/text/resources/en/FormatData_en_GB.java \
|
||||
sun/text/resources/en/FormatData_en_IE.java \
|
||||
sun/text/resources/en/FormatData_en_IN.java \
|
||||
sun/text/resources/en/FormatData_en_MT.java \
|
||||
sun/text/resources/en/FormatData_en_NZ.java \
|
||||
sun/text/resources/en/FormatData_en_PH.java \
|
||||
sun/text/resources/en/FormatData_en_SG.java \
|
||||
sun/text/resources/en/FormatData_en_US.java \
|
||||
sun/text/resources/en/FormatData_en_ZA.java \
|
||||
sun/text/resources/en/JavaTimeSupplementary_en.java \
|
||||
sun/text/resources/en/JavaTimeSupplementary_en_GB.java \
|
||||
sun/text/resources/en/JavaTimeSupplementary_en_SG.java
|
||||
|
|
|
@ -30,4 +30,7 @@ FILES_java = \
|
|||
sun/util/resources/LocaleNamesBundle.java \
|
||||
sun/util/resources/TimeZoneNamesBundle.java \
|
||||
sun/util/resources/TimeZoneNames.java \
|
||||
sun/util/resources/en/TimeZoneNames_en.java
|
||||
sun/util/resources/en/TimeZoneNames_en.java \
|
||||
sun/util/resources/en/TimeZoneNames_en_CA.java \
|
||||
sun/util/resources/en/TimeZoneNames_en_GB.java \
|
||||
sun/util/resources/en/TimeZoneNames_en_IE.java
|
||||
|
|
|
@ -26,9 +26,25 @@
|
|||
FILES_compiled_properties = \
|
||||
sun/util/resources/LocaleNames.properties \
|
||||
sun/util/resources/en/LocaleNames_en.properties \
|
||||
sun/util/resources/en/LocaleNames_en_MT.properties \
|
||||
sun/util/resources/en/LocaleNames_en_PH.properties \
|
||||
sun/util/resources/en/LocaleNames_en_SG.properties \
|
||||
\
|
||||
sun/util/resources/CalendarData.properties \
|
||||
sun/util/resources/en/CalendarData_en.properties \
|
||||
sun/util/resources/en/CalendarData_en_GB.properties \
|
||||
sun/util/resources/en/CalendarData_en_IE.properties \
|
||||
sun/util/resources/en/CalendarData_en_MT.properties \
|
||||
\
|
||||
sun/util/resources/CurrencyNames.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_US.properties
|
||||
sun/util/resources/en/CurrencyNames_en_AU.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_CA.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_GB.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_IE.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_IN.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_MT.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_NZ.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_PH.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_SG.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_US.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_ZA.properties
|
||||
|
|
|
@ -96,16 +96,6 @@ FILES_java = \
|
|||
sun/text/resources/el/FormatData_el.java \
|
||||
sun/text/resources/el/FormatData_el_CY.java \
|
||||
sun/text/resources/el/FormatData_el_GR.java \
|
||||
sun/text/resources/en/FormatData_en_AU.java \
|
||||
sun/text/resources/en/FormatData_en_CA.java \
|
||||
sun/text/resources/en/FormatData_en_GB.java \
|
||||
sun/text/resources/en/FormatData_en_IE.java \
|
||||
sun/text/resources/en/FormatData_en_IN.java \
|
||||
sun/text/resources/en/FormatData_en_MT.java \
|
||||
sun/text/resources/en/FormatData_en_NZ.java \
|
||||
sun/text/resources/en/FormatData_en_PH.java \
|
||||
sun/text/resources/en/FormatData_en_SG.java \
|
||||
sun/text/resources/en/FormatData_en_ZA.java \
|
||||
sun/text/resources/es/FormatData_es.java \
|
||||
sun/text/resources/es/FormatData_es_BO.java \
|
||||
sun/text/resources/es/FormatData_es_AR.java \
|
||||
|
@ -214,9 +204,6 @@ FILES_java = \
|
|||
sun/util/resources/zh/CurrencyNames_zh_SG.java \
|
||||
sun/util/resources/zh/LocaleNames_zh_HK.java \
|
||||
sun/util/resources/de/TimeZoneNames_de.java \
|
||||
sun/util/resources/en/TimeZoneNames_en_CA.java \
|
||||
sun/util/resources/en/TimeZoneNames_en_GB.java \
|
||||
sun/util/resources/en/TimeZoneNames_en_IE.java \
|
||||
sun/util/resources/es/TimeZoneNames_es.java \
|
||||
sun/util/resources/fr/TimeZoneNames_fr.java \
|
||||
sun/util/resources/hi/TimeZoneNames_hi.java \
|
||||
|
@ -237,8 +224,6 @@ FILES_java = \
|
|||
sun/text/resources/da/JavaTimeSupplementary_da.java \
|
||||
sun/text/resources/de/JavaTimeSupplementary_de.java \
|
||||
sun/text/resources/el/JavaTimeSupplementary_el.java \
|
||||
sun/text/resources/en/JavaTimeSupplementary_en_GB.java \
|
||||
sun/text/resources/en/JavaTimeSupplementary_en_SG.java \
|
||||
sun/text/resources/es/JavaTimeSupplementary_es.java \
|
||||
sun/text/resources/et/JavaTimeSupplementary_et.java \
|
||||
sun/text/resources/fi/JavaTimeSupplementary_fi.java \
|
||||
|
|
|
@ -33,9 +33,6 @@ FILES_compiled_properties = \
|
|||
sun/util/resources/de/LocaleNames_de.properties \
|
||||
sun/util/resources/el/LocaleNames_el.properties \
|
||||
sun/util/resources/el/LocaleNames_el_CY.properties \
|
||||
sun/util/resources/en/LocaleNames_en_MT.properties \
|
||||
sun/util/resources/en/LocaleNames_en_PH.properties \
|
||||
sun/util/resources/en/LocaleNames_en_SG.properties \
|
||||
sun/util/resources/es/LocaleNames_es.properties \
|
||||
sun/util/resources/es/LocaleNames_es_US.properties \
|
||||
sun/util/resources/et/LocaleNames_et.properties \
|
||||
|
@ -88,9 +85,6 @@ FILES_compiled_properties = \
|
|||
sun/util/resources/de/CalendarData_de.properties \
|
||||
sun/util/resources/el/CalendarData_el.properties \
|
||||
sun/util/resources/el/CalendarData_el_CY.properties \
|
||||
sun/util/resources/en/CalendarData_en_GB.properties \
|
||||
sun/util/resources/en/CalendarData_en_IE.properties \
|
||||
sun/util/resources/en/CalendarData_en_MT.properties \
|
||||
sun/util/resources/es/CalendarData_es.properties \
|
||||
sun/util/resources/es/CalendarData_es_ES.properties \
|
||||
sun/util/resources/es/CalendarData_es_US.properties \
|
||||
|
@ -164,16 +158,6 @@ FILES_compiled_properties = \
|
|||
sun/util/resources/de/CurrencyNames_de_LU.properties \
|
||||
sun/util/resources/el/CurrencyNames_el_CY.properties \
|
||||
sun/util/resources/el/CurrencyNames_el_GR.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_AU.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_CA.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_GB.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_IE.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_IN.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_MT.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_NZ.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_PH.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_SG.properties \
|
||||
sun/util/resources/en/CurrencyNames_en_ZA.properties \
|
||||
sun/util/resources/es/CurrencyNames_es.properties \
|
||||
sun/util/resources/es/CurrencyNames_es_AR.properties \
|
||||
sun/util/resources/es/CurrencyNames_es_BO.properties \
|
||||
|
|
|
@ -11,7 +11,7 @@ public class CharacterName {
|
|||
FileReader reader = null;
|
||||
try {
|
||||
if (args.length != 2) {
|
||||
System.err.println("Usage: java CharacterName UniocdeData.txt uniName.dat");
|
||||
System.err.println("Usage: java CharacterName UnicodeData.txt uniName.dat");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -211,6 +211,7 @@ ifneq ($(OPENJDK_TARGET_OS),macosx)
|
|||
LIBJAVA_EXCLUDE_FILES += java_props_macosx.c
|
||||
else
|
||||
BUILD_LIBJAVA_java_props_md.c_CFLAGS:=-x objective-c
|
||||
BUILD_LIBJAVA_java_props_macosx.c_CFLAGS:=-x objective-c
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS),windows)
|
||||
|
@ -252,6 +253,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA,\
|
|||
LDFLAGS_SUFFIX_linux:=$(LIBDL) $(BUILD_LIBFDLIBM),\
|
||||
LDFLAGS_SUFFIX_macosx:=-L$(JDK_OUTPUTDIR)/objs/ -lfdlibm \
|
||||
-framework CoreFoundation \
|
||||
-framework Foundation \
|
||||
-framework Security -framework SystemConfiguration, \
|
||||
LDFLAGS_SUFFIX_windows:=-export:winFileHandleOpen -export:handleLseek \
|
||||
jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
|
||||
|
|
|
@ -80,39 +80,6 @@ LOCALEDATA_INCLUDE_LOCALES := ar be bg ca cs da de el es et fi fr ga hi hr hu in
|
|||
LOCALEDATA_INCLUDES := $(addprefix sun/text/resources/,$(LOCALEDATA_INCLUDE_LOCALES)) \
|
||||
$(addprefix sun/util/resources/,$(LOCALEDATA_INCLUDE_LOCALES))
|
||||
|
||||
# For non-US English locale data
|
||||
|
||||
LOCALEDATA_INCLUDES += \
|
||||
sun/text/resources/en/FormatData_en_AU.class \
|
||||
sun/text/resources/en/FormatData_en_CA.class \
|
||||
sun/text/resources/en/FormatData_en_GB.class \
|
||||
sun/text/resources/en/FormatData_en_IE.class \
|
||||
sun/text/resources/en/FormatData_en_IN.class \
|
||||
sun/text/resources/en/FormatData_en_MT.class \
|
||||
sun/text/resources/en/FormatData_en_NZ.class \
|
||||
sun/text/resources/en/FormatData_en_PH.class \
|
||||
sun/text/resources/en/FormatData_en_SG.class \
|
||||
sun/text/resources/en/FormatData_en_ZA.class \
|
||||
sun/util/resources/en/CalendarData_en_GB.class \
|
||||
sun/util/resources/en/CalendarData_en_IE.class \
|
||||
sun/util/resources/en/CalendarData_en_MT.class \
|
||||
sun/util/resources/en/CurrencyNames_en_AU.class \
|
||||
sun/util/resources/en/CurrencyNames_en_CA.class \
|
||||
sun/util/resources/en/CurrencyNames_en_GB.class \
|
||||
sun/util/resources/en/CurrencyNames_en_IE.class \
|
||||
sun/util/resources/en/CurrencyNames_en_IN.class \
|
||||
sun/util/resources/en/CurrencyNames_en_MT.class \
|
||||
sun/util/resources/en/CurrencyNames_en_NZ.class \
|
||||
sun/util/resources/en/CurrencyNames_en_PH.class \
|
||||
sun/util/resources/en/CurrencyNames_en_SG.class \
|
||||
sun/util/resources/en/CurrencyNames_en_ZA.class \
|
||||
sun/util/resources/en/LocaleNames_en_MT.class \
|
||||
sun/util/resources/en/LocaleNames_en_PH.class \
|
||||
sun/util/resources/en/LocaleNames_en_SG.class \
|
||||
sun/util/resources/en/TimeZoneNames_en_CA.class \
|
||||
sun/util/resources/en/TimeZoneNames_en_GB.class \
|
||||
sun/util/resources/en/TimeZoneNames_en_IE.class
|
||||
|
||||
$(eval $(call SetupArchive,BUILD_LOCALEDATA_JAR,,\
|
||||
SRCS:=$(JDK_OUTPUTDIR)/classes,\
|
||||
SUFFIXES:=.class _dict _th,\
|
||||
|
|
|
@ -50,27 +50,27 @@ ifneq (,$(MISSING_RESOURCES)$(NEW_RESOURCES))
|
|||
$(shell $(RM) $(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java)
|
||||
endif
|
||||
|
||||
# The US locales
|
||||
US_LOCALES:=en en-US
|
||||
# The EN locales
|
||||
EN_LOCALES:=en%
|
||||
|
||||
# ja-JP-JP and th-TH-TH need to be manually added, as they don't have any resource files.
|
||||
ALL_NON_US_LOCALES:=ja-JP-JP th-TH-TH
|
||||
ALL_NON_EN_LOCALES:=ja-JP-JP th-TH-TH
|
||||
|
||||
SED_ARGS:=-e 's|$(HASH)warn This file is preprocessed before being compiled|// -- This file was mechanically generated: Do not edit! -- //|g'
|
||||
|
||||
# This macro creates a sed expression that substitues for example:
|
||||
# #FormatData_USLocales# with: en and/or en_US.
|
||||
# #FormatData_ENLocales# with: en% locales.
|
||||
define CaptureLocale
|
||||
$1_LOCALES := $$(subst _,-,$$(filter-out $1,$$(subst $1_,,$$(filter $1_%,$(LOCALE_RESOURCES)))))
|
||||
$1_US_LOCALES := $$(filter $(US_LOCALES),$$($1_LOCALES))
|
||||
$1_NON_US_LOCALES := $$(filter-out $(US_LOCALES),$$($1_LOCALES))
|
||||
$1_EN_LOCALES := $$(filter $(EN_LOCALES),$$($1_LOCALES))
|
||||
$1_NON_EN_LOCALES := $$(filter-out $(EN_LOCALES),$$($1_LOCALES))
|
||||
|
||||
ALL_US_LOCALES += $$($1_US_LOCALES)
|
||||
ALL_NON_US_LOCALES += $$($1_NON_US_LOCALES)
|
||||
ALL_EN_LOCALES += $$($1_EN_LOCALES)
|
||||
ALL_NON_EN_LOCALES += $$($1_NON_EN_LOCALES)
|
||||
|
||||
# Don't sed in a space if there are no locales.
|
||||
SED_ARGS+= -e 's/$$(HASH)$1_USLocales$$(HASH)/$$(if $$($1_US_LOCALES),$$(SPACE)$$($1_US_LOCALES),)/g'
|
||||
SED_ARGS+= -e 's/$$(HASH)$1_NonUSLocales$$(HASH)/$$(if $$($1_NON_US_LOCALES),$$(SPACE)$$($1_NON_US_LOCALES),)/g'
|
||||
SED_ARGS+= -e 's/$$(HASH)$1_ENLocales$$(HASH)/$$(if $$($1_EN_LOCALES),$$(SPACE)$$($1_EN_LOCALES),)/g'
|
||||
SED_ARGS+= -e 's/$$(HASH)$1_NonENLocales$$(HASH)/$$(if $$($1_NON_EN_LOCALES),$$(SPACE)$$($1_NON_EN_LOCALES),)/g'
|
||||
endef
|
||||
|
||||
#sun.text.resources.FormatData
|
||||
|
@ -91,8 +91,8 @@ $(eval $(call CaptureLocale,CurrencyNames))
|
|||
#sun.util.resources.CalendarData
|
||||
$(eval $(call CaptureLocale,CalendarData))
|
||||
|
||||
SED_ARGS+= -e 's/$(HASH)AvailableLocales_USLocales$(HASH)/$(sort $(ALL_US_LOCALES))/g'
|
||||
SED_ARGS+= -e 's/$(HASH)AvailableLocales_NonUSLocales$(HASH)/$(sort $(ALL_NON_US_LOCALES))/g'
|
||||
SED_ARGS+= -e 's/$(HASH)AvailableLocales_ENLocales$(HASH)/$(sort $(ALL_EN_LOCALES))/g'
|
||||
SED_ARGS+= -e 's/$(HASH)AvailableLocales_NonENLocales$(HASH)/$(sort $(ALL_NON_EN_LOCALES))/g'
|
||||
|
||||
$(JDK_OUTPUTDIR)/gensrc/sun/util/locale/provider/LocaleDataMetaInfo.java: \
|
||||
$(JDK_TOPDIR)/src/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,6 +25,10 @@
|
|||
|
||||
DISABLE_WARNINGS:=-Xlint:all,-deprecation,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally
|
||||
|
||||
# To build with all warnings enabled, do the following:
|
||||
# make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
|
||||
JAVAC_WARNINGS:=-Xlint:-unchecked,-deprecation,-overrides,classfile,dep-ann,divzero,varargs -Werror
|
||||
|
||||
# The generate old bytecode javac setup uses the new compiler to compile for the
|
||||
# boot jdk to generate tools that need to be run with the boot jdk.
|
||||
# Thus we force the target bytecode to 7.
|
||||
|
@ -41,7 +45,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE,\
|
|||
JVM:=$(JAVA),\
|
||||
JAVAC:=$(NEW_JAVAC),\
|
||||
FLAGS:=-bootclasspath $(JDK_OUTPUTDIR)/classes -source 8 -target 8 \
|
||||
-encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS) \
|
||||
-encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS) \
|
||||
$(GENERATE_JDKBYTECODE_EXTRA_FLAGS),\
|
||||
SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
|
||||
SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.*;
|
|||
import sun.awt.*;
|
||||
import sun.lwawt.macosx.*;
|
||||
import sun.print.*;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
|
||||
|
@ -502,7 +503,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
|||
public Clipboard getSystemClipboard() {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkSystemClipboardAccess();
|
||||
security.checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION);
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
|
|
|
@ -58,6 +58,13 @@ public class Association {
|
|||
|
||||
/**
|
||||
* Initializes a new instance of this class.
|
||||
*
|
||||
* @param associationID
|
||||
* The association ID
|
||||
* @param maxInStreams
|
||||
* The maximum number of inbound streams
|
||||
* @param maxOutStreams
|
||||
* The maximum number of outbound streams
|
||||
*/
|
||||
protected Association(int associationID,
|
||||
int maxInStreams,
|
||||
|
|
|
@ -41,6 +41,9 @@ public class IllegalReceiveException extends IllegalStateException {
|
|||
|
||||
/**
|
||||
* Constructs an instance of this class with the specified message.
|
||||
*
|
||||
* @param msg
|
||||
* The String that contains a detailed message
|
||||
*/
|
||||
public IllegalReceiveException(String msg) {
|
||||
super(msg);
|
||||
|
|
|
@ -41,6 +41,9 @@ public class IllegalUnbindException extends IllegalStateException {
|
|||
|
||||
/**
|
||||
* Constructs an instance of this class with the specified detailed message.
|
||||
*
|
||||
* @param msg
|
||||
* The String that contains a detailed message
|
||||
*/
|
||||
public IllegalUnbindException(String msg) {
|
||||
super(msg);
|
||||
|
|
|
@ -40,6 +40,9 @@ public class InvalidStreamException extends IllegalArgumentException {
|
|||
|
||||
/**
|
||||
* Constructs an instance of this class with the specified detailed message.
|
||||
*
|
||||
* @param msg
|
||||
* The String that contains a detailed message
|
||||
*/
|
||||
public InvalidStreamException(String msg) {
|
||||
super(msg);
|
||||
|
|
|
@ -48,7 +48,7 @@ import java.net.SocketAddress;
|
|||
* longer required to be sent after the time period expires. It is not a hard
|
||||
* timeout and may be influenced by whether the association supports the partial
|
||||
* reliability extension, <a href=http://www.ietf.org/rfc/rfc3758.txt>RFC 3758
|
||||
* <a>
|
||||
* </a>.
|
||||
*
|
||||
* <P> {@code MessageInfo} instances are not safe for use by multiple concurrent
|
||||
* threads. If a MessageInfo is to be used by more than one thread then access
|
||||
|
|
|
@ -40,6 +40,8 @@ package com.sun.nio.sctp;
|
|||
public interface Notification {
|
||||
/**
|
||||
* Returns the association that this notification is applicable to.
|
||||
*
|
||||
* @return The association
|
||||
*/
|
||||
public Association association();
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ import java.nio.channels.SelectionKey;
|
|||
* {@link #setOption(SctpSocketOption,Object) setOption} method. An SCTP
|
||||
* channel support the following options:
|
||||
* <blockquote>
|
||||
* <table border>
|
||||
* <table border summary="Socket options">
|
||||
* <tr>
|
||||
* <th>Option Name</th>
|
||||
* <th>Description</th>
|
||||
|
@ -636,6 +636,9 @@ public abstract class SctpChannel
|
|||
/**
|
||||
* Returns the value of a socket option.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of the socket option value
|
||||
*
|
||||
* @param name
|
||||
* The socket option
|
||||
*
|
||||
|
@ -659,6 +662,9 @@ public abstract class SctpChannel
|
|||
/**
|
||||
* Sets the value of a socket option.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of the socket option value
|
||||
*
|
||||
* @param name
|
||||
* The socket option
|
||||
*
|
||||
|
@ -752,6 +758,9 @@ public abstract class SctpChannel
|
|||
* the {@code receive} method of this channel, if it does an
|
||||
* {@link IllegalReceiveException} will be thrown.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of the attachment
|
||||
*
|
||||
* @param dst
|
||||
* The buffer into which message bytes are to be transferred
|
||||
*
|
||||
|
@ -831,7 +840,7 @@ public abstract class SctpChannel
|
|||
* there was insufficient room for the message in the underlying
|
||||
* output buffer
|
||||
*
|
||||
* @throws InvalidStreamExcepton
|
||||
* @throws InvalidStreamException
|
||||
* If {@code streamNumner} is negative or greater than or equal to
|
||||
* the maximum number of outgoing streams
|
||||
*
|
||||
|
|
|
@ -63,7 +63,7 @@ import java.nio.channels.SelectionKey;
|
|||
* {@link #setOption(SctpSocketOption,Object,Association) setOption} method. An
|
||||
* {@code SctpMultiChannel} supports the following options:
|
||||
* <blockquote>
|
||||
* <table border>
|
||||
* <table border summary="Socket options">
|
||||
* <tr>
|
||||
* <th>Option Name</th>
|
||||
* <th>Description</th>
|
||||
|
@ -394,6 +394,9 @@ public abstract class SctpMultiChannel
|
|||
* Returns all of the remote addresses to which the given association on
|
||||
* this channel's socket is connected.
|
||||
*
|
||||
* @param association
|
||||
* The association
|
||||
*
|
||||
* @return All of the remote addresses for the given association, or
|
||||
* an empty {@code Set} if the association has been shutdown
|
||||
*
|
||||
|
@ -431,6 +434,9 @@ public abstract class SctpMultiChannel
|
|||
* ignored if given. However, if the option is association specific then the
|
||||
* association must be given.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of the socket option value
|
||||
*
|
||||
* @param name
|
||||
* The socket option
|
||||
*
|
||||
|
@ -464,6 +470,9 @@ public abstract class SctpMultiChannel
|
|||
* ignored if given. However, if the option is association specific then the
|
||||
* association must be given.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of the socket option value
|
||||
*
|
||||
* @param name
|
||||
* The socket option
|
||||
*
|
||||
|
@ -567,6 +576,9 @@ public abstract class SctpMultiChannel
|
|||
* the {@code receive} method of this channel, if it does an
|
||||
* {@link IllegalReceiveException} will be thrown.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of the attachment
|
||||
*
|
||||
* @param buffer
|
||||
* The buffer into which bytes are to be transferred
|
||||
*
|
||||
|
@ -673,7 +685,7 @@ public abstract class SctpMultiChannel
|
|||
* there was insufficient room for the message in the underlying
|
||||
* output buffer
|
||||
*
|
||||
* @throws InvalidStreamExcepton
|
||||
* @throws InvalidStreamException
|
||||
* If {@code streamNumber} is negative, or if an association already
|
||||
* exists and {@code streamNumber} is greater than the maximum number
|
||||
* of outgoing streams
|
||||
|
|
|
@ -47,7 +47,7 @@ import java.nio.channels.spi.AbstractSelectableChannel;
|
|||
* {@link #setOption(SctpSocketOption,Object) setOption} method. SCTP server socket
|
||||
* channels support the following options:
|
||||
* <blockquote>
|
||||
* <table border>
|
||||
* <table border summary="Socket options">
|
||||
* <tr>
|
||||
* <th>Option Name</th>
|
||||
* <th>Description</th>
|
||||
|
@ -345,6 +345,9 @@ public abstract class SctpServerChannel
|
|||
/**
|
||||
* Returns the value of a socket option.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of the socket option value
|
||||
*
|
||||
* @param name
|
||||
* The socket option
|
||||
*
|
||||
|
@ -367,6 +370,9 @@ public abstract class SctpServerChannel
|
|||
/**
|
||||
* Sets the value of a socket option.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of the socket option value
|
||||
*
|
||||
* @param name
|
||||
* The socket option
|
||||
*
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.text.BreakIterator;
|
|||
import javax.swing.text.AttributeSet;
|
||||
import javax.accessibility.*;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
/**
|
||||
* The <code>TextComponent</code> class is the superclass of
|
||||
|
@ -728,7 +729,7 @@ public class TextComponent extends Component implements Accessible {
|
|||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm == null) return true;
|
||||
try {
|
||||
sm.checkSystemClipboardAccess();
|
||||
sm.checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION);
|
||||
return true;
|
||||
} catch (SecurityException e) {}
|
||||
return false;
|
||||
|
|
|
@ -1270,12 +1270,8 @@ public abstract class Toolkit {
|
|||
* <p>
|
||||
* Each actual implementation of this method should first check if there
|
||||
* is a security manager installed. If there is, the method should call
|
||||
* the security manager's <code>checkSystemClipboardAccess</code> method
|
||||
* to ensure it's ok to to access the system clipboard. If the default
|
||||
* implementation of <code>checkSystemClipboardAccess</code> is used (that
|
||||
* is, that method is not overriden), then this results in a call to the
|
||||
* security manager's <code>checkPermission</code> method with an <code>
|
||||
* AWTPermission("accessClipboard")</code> permission.
|
||||
* the security manager's {@link SecurityManager#checkPermission
|
||||
* checkPermission} method to check {@code AWTPermission("accessClipboard")}.
|
||||
*
|
||||
* @return the system Clipboard
|
||||
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
|
||||
|
@ -1318,14 +1314,9 @@ public abstract class Toolkit {
|
|||
* system selection <code>Clipboard</code> as described above.
|
||||
* <p>
|
||||
* Each actual implementation of this method should first check if there
|
||||
* is a <code>SecurityManager</code> installed. If there is, the method
|
||||
* should call the <code>SecurityManager</code>'s
|
||||
* <code>checkSystemClipboardAccess</code> method to ensure that client
|
||||
* code has access the system selection. If the default implementation of
|
||||
* <code>checkSystemClipboardAccess</code> is used (that is, if the method
|
||||
* is not overridden), then this results in a call to the
|
||||
* <code>SecurityManager</code>'s <code>checkPermission</code> method with
|
||||
* an <code>AWTPermission("accessClipboard")</code> permission.
|
||||
* is a security manager installed. If there is, the method should call
|
||||
* the security manager's {@link SecurityManager#checkPermission
|
||||
* checkPermission} method to check {@code AWTPermission("accessClipboard")}.
|
||||
*
|
||||
* @return the system selection as a <code>Clipboard</code>, or
|
||||
* <code>null</code> if the native platform does not support a
|
||||
|
@ -1699,25 +1690,20 @@ public abstract class Toolkit {
|
|||
* therefore not assume that the EventQueue instance returned
|
||||
* by this method will be shared by other applets or the system.
|
||||
*
|
||||
* <p>First, if there is a security manager, its
|
||||
* <code>checkAwtEventQueueAccess</code>
|
||||
* method is called.
|
||||
* If the default implementation of <code>checkAwtEventQueueAccess</code>
|
||||
* is used (that is, that method is not overriden), then this results in
|
||||
* a call to the security manager's <code>checkPermission</code> method
|
||||
* with an <code>AWTPermission("accessEventQueue")</code> permission.
|
||||
* <p> If there is a security manager then its
|
||||
* {@link SecurityManager#checkPermission checkPermission} method
|
||||
* is called to check {@code AWTPermission("accessEventQueue")}.
|
||||
*
|
||||
* @return the <code>EventQueue</code> object
|
||||
* @throws SecurityException
|
||||
* if a security manager exists and its <code>{@link
|
||||
* java.lang.SecurityManager#checkAwtEventQueueAccess}</code>
|
||||
* method denies access to the <code>EventQueue</code>
|
||||
* if a security manager is set and it denies access to
|
||||
* the {@code EventQueue}
|
||||
* @see java.awt.AWTPermission
|
||||
*/
|
||||
public final EventQueue getSystemEventQueue() {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkAwtEventQueueAccess();
|
||||
security.checkPermission(SecurityConstants.AWT.CHECK_AWT_EVENTQUEUE_PERMISSION);
|
||||
}
|
||||
return getSystemEventQueueImpl();
|
||||
}
|
||||
|
|
|
@ -195,10 +195,9 @@ public class Window extends Container implements Accessible {
|
|||
/**
|
||||
* This represents the warning message that is
|
||||
* to be displayed in a non secure window. ie :
|
||||
* a window that has a security manager installed for
|
||||
* which calling SecurityManager.checkTopLevelWindow()
|
||||
* is false. This message can be displayed anywhere in
|
||||
* the window.
|
||||
* a window that has a security manager installed that denies
|
||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}.
|
||||
* This message can be displayed anywhere in the window.
|
||||
*
|
||||
* @serial
|
||||
* @see #getWarningString
|
||||
|
@ -417,11 +416,10 @@ public class Window extends Container implements Accessible {
|
|||
* Constructs a new, initially invisible window in default size with the
|
||||
* specified {@code GraphicsConfiguration}.
|
||||
* <p>
|
||||
* If there is a security manager, this method first calls
|
||||
* the security manager's {@code checkTopLevelWindow}
|
||||
* method with {@code this}
|
||||
* as its argument to determine whether or not the window
|
||||
* must be displayed with a warning banner.
|
||||
* If there is a security manager, then it is invoked to check
|
||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}
|
||||
* to determine whether or not the window must be displayed with
|
||||
* a warning banner.
|
||||
*
|
||||
* @param gc the {@code GraphicsConfiguration} of the target screen
|
||||
* device. If {@code gc} is {@code null}, the system default
|
||||
|
@ -432,7 +430,6 @@ public class Window extends Container implements Accessible {
|
|||
* {@code GraphicsEnvironment.isHeadless()} returns {@code true}
|
||||
*
|
||||
* @see java.awt.GraphicsEnvironment#isHeadless
|
||||
* @see java.lang.SecurityManager#checkTopLevelWindow
|
||||
*/
|
||||
Window(GraphicsConfiguration gc) {
|
||||
init(gc);
|
||||
|
@ -511,25 +508,16 @@ public class Window extends Container implements Accessible {
|
|||
|
||||
/**
|
||||
* Constructs a new, initially invisible window in the default size.
|
||||
*
|
||||
* <p>First, if there is a security manager, its
|
||||
* {@code checkTopLevelWindow}
|
||||
* method is called with {@code this}
|
||||
* as its argument
|
||||
* to see if it's ok to display the window without a warning banner.
|
||||
* If the default implementation of {@code checkTopLevelWindow}
|
||||
* is used (that is, that method is not overriden), then this results in
|
||||
* a call to the security manager's {@code checkPermission} method
|
||||
* with an {@code AWTPermission("showWindowWithoutWarningBanner")}
|
||||
* permission. It that method raises a SecurityException,
|
||||
* {@code checkTopLevelWindow} returns false, otherwise it
|
||||
* returns true. If it returns false, a warning banner is created.
|
||||
* <p>
|
||||
* If there is a security manager set, it is invoked to check
|
||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}.
|
||||
* If that check fails with a {@code SecurityException} then a warning
|
||||
* banner is created.
|
||||
*
|
||||
* @exception HeadlessException when
|
||||
* {@code GraphicsEnvironment.isHeadless()} returns {@code true}
|
||||
*
|
||||
* @see java.awt.GraphicsEnvironment#isHeadless
|
||||
* @see java.lang.SecurityManager#checkTopLevelWindow
|
||||
*/
|
||||
Window() throws HeadlessException {
|
||||
GraphicsEnvironment.checkHeadless();
|
||||
|
@ -541,11 +529,10 @@ public class Window extends Container implements Accessible {
|
|||
* {@code Frame} as its owner. The window will not be focusable
|
||||
* unless its owner is showing on the screen.
|
||||
* <p>
|
||||
* If there is a security manager, this method first calls
|
||||
* the security manager's {@code checkTopLevelWindow}
|
||||
* method with {@code this}
|
||||
* as its argument to determine whether or not the window
|
||||
* must be displayed with a warning banner.
|
||||
* If there is a security manager set, it is invoked to check
|
||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}.
|
||||
* If that check fails with a {@code SecurityException} then a warning
|
||||
* banner is created.
|
||||
*
|
||||
* @param owner the {@code Frame} to act as owner or {@code null}
|
||||
* if this window has no owner
|
||||
|
@ -555,7 +542,6 @@ public class Window extends Container implements Accessible {
|
|||
* {@code GraphicsEnvironment.isHeadless} returns {@code true}
|
||||
*
|
||||
* @see java.awt.GraphicsEnvironment#isHeadless
|
||||
* @see java.lang.SecurityManager#checkTopLevelWindow
|
||||
* @see #isShowing
|
||||
*/
|
||||
public Window(Frame owner) {
|
||||
|
@ -570,11 +556,10 @@ public class Window extends Container implements Accessible {
|
|||
* unless its nearest owning {@code Frame} or {@code Dialog}
|
||||
* is showing on the screen.
|
||||
* <p>
|
||||
* If there is a security manager, this method first calls
|
||||
* the security manager's {@code checkTopLevelWindow}
|
||||
* method with {@code this}
|
||||
* as its argument to determine whether or not the window
|
||||
* must be displayed with a warning banner.
|
||||
* If there is a security manager set, it is invoked to check
|
||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}.
|
||||
* If that check fails with a {@code SecurityException} then a
|
||||
* warning banner is created.
|
||||
*
|
||||
* @param owner the {@code Window} to act as owner or
|
||||
* {@code null} if this window has no owner
|
||||
|
@ -585,7 +570,6 @@ public class Window extends Container implements Accessible {
|
|||
* {@code true}
|
||||
*
|
||||
* @see java.awt.GraphicsEnvironment#isHeadless
|
||||
* @see java.lang.SecurityManager#checkTopLevelWindow
|
||||
* @see #isShowing
|
||||
*
|
||||
* @since 1.2
|
||||
|
@ -603,11 +587,10 @@ public class Window extends Container implements Accessible {
|
|||
* its nearest owning {@code Frame} or {@code Dialog}
|
||||
* is showing on the screen.
|
||||
* <p>
|
||||
* If there is a security manager, this method first calls
|
||||
* the security manager's {@code checkTopLevelWindow}
|
||||
* method with {@code this}
|
||||
* as its argument to determine whether or not the window
|
||||
* must be displayed with a warning banner.
|
||||
* If there is a security manager set, it is invoked to check
|
||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}. If that
|
||||
* check fails with a {@code SecurityException} then a warning banner
|
||||
* is created.
|
||||
*
|
||||
* @param owner the window to act as owner or {@code null}
|
||||
* if this window has no owner
|
||||
|
@ -621,7 +604,6 @@ public class Window extends Container implements Accessible {
|
|||
* {@code true}
|
||||
*
|
||||
* @see java.awt.GraphicsEnvironment#isHeadless
|
||||
* @see java.lang.SecurityManager#checkTopLevelWindow
|
||||
* @see GraphicsConfiguration#getBounds
|
||||
* @see #isShowing
|
||||
* @since 1.3
|
||||
|
@ -1362,10 +1344,9 @@ public class Window extends Container implements Accessible {
|
|||
* Gets the warning string that is displayed with this window.
|
||||
* If this window is insecure, the warning string is displayed
|
||||
* somewhere in the visible area of the window. A window is
|
||||
* insecure if there is a security manager, and the security
|
||||
* manager's {@code checkTopLevelWindow} method returns
|
||||
* {@code false} when this window is passed to it as an
|
||||
* argument.
|
||||
* insecure if there is a security manager and the security
|
||||
* manager denies
|
||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}.
|
||||
* <p>
|
||||
* If the window is secure, then {@code getWarningString}
|
||||
* returns {@code null}. If the window is insecure, this
|
||||
|
@ -1373,7 +1354,6 @@ public class Window extends Container implements Accessible {
|
|||
* {@code awt.appletWarning}
|
||||
* and returns the string value of that property.
|
||||
* @return the warning string for this window.
|
||||
* @see java.lang.SecurityManager#checkTopLevelWindow(java.lang.Object)
|
||||
*/
|
||||
public final String getWarningString() {
|
||||
return warningString;
|
||||
|
@ -1383,10 +1363,12 @@ public class Window extends Container implements Accessible {
|
|||
warningString = null;
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
if (!sm.checkTopLevelWindow(this)) {
|
||||
try {
|
||||
sm.checkPermission(SecurityConstants.AWT.TOPLEVEL_WINDOW_PERMISSION);
|
||||
} catch (SecurityException se) {
|
||||
// make sure the privileged action is only
|
||||
// for getting the property! We don't want the
|
||||
// above checkTopLevelWindow call to always succeed!
|
||||
// above checkPermission call to always succeed!
|
||||
warningString = AccessController.doPrivileged(
|
||||
new GetPropertyAction("awt.appletWarning",
|
||||
"Java Applet Window"));
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.Arrays;
|
|||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
/**
|
||||
* The root event class for all component-level input events.
|
||||
|
@ -350,7 +351,7 @@ public abstract class InputEvent extends ComponentEvent {
|
|||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
try {
|
||||
sm.checkSystemClipboardAccess();
|
||||
sm.checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION);
|
||||
b = true;
|
||||
} catch (SecurityException se) {
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
|
|
|
@ -124,9 +124,11 @@ public final class Console implements Flushable
|
|||
* {@link java.io.Reader#read(java.nio.CharBuffer) read(java.nio.CharBuffer)}
|
||||
* on the returned object will not read in characters beyond the line
|
||||
* bound for each invocation, even if the destination buffer has space for
|
||||
* more characters. A line bound is considered to be any one of a line feed
|
||||
* (<tt>'\n'</tt>), a carriage return (<tt>'\r'</tt>), a carriage return
|
||||
* followed immediately by a linefeed, or an end of stream.
|
||||
* more characters. The {@code Reader}'s {@code read} methods may block if a
|
||||
* line bound has not been entered or reached on the console's input device.
|
||||
* A line bound is considered to be any one of a line feed (<tt>'\n'</tt>),
|
||||
* a carriage return (<tt>'\r'</tt>), a carriage return followed immediately
|
||||
* by a linefeed, or an end of stream.
|
||||
*
|
||||
* @return The reader associated with this console
|
||||
*/
|
||||
|
|
|
@ -26,7 +26,24 @@
|
|||
package java.lang;
|
||||
|
||||
/**
|
||||
* A resource that must be closed when it is no longer needed.
|
||||
* An object that may hold resources (such as file or socket handles)
|
||||
* until it is closed. The {@link #close()} method of an {@code AutoCloseable}
|
||||
* object is called automatically when exiting a {@code
|
||||
* try}-with-resources block for which the object has been declared in
|
||||
* the resource specification header. This construction ensures prompt
|
||||
* release, avoiding resource exhaustion exceptions and errors that
|
||||
* may otherwise occur.
|
||||
*
|
||||
* @apiNote
|
||||
* <p>It is possible, and in fact common, for a base class to
|
||||
* implement AutoCloseable even though not all of its subclasses or
|
||||
* instances will hold releasable resources. For code that must operate
|
||||
* in complete generality, or when it is known that the {@code AutoCloseable}
|
||||
* instance requires resource release, it is recommended to use {@code
|
||||
* try}-with-resources constructions. However, when using facilities such as
|
||||
* {@link java.util.stream.Stream} that support both I/O-based and
|
||||
* non-I/O-based forms, {@code try}-with-resources blocks are in
|
||||
* general unnecessary when using non-I/O-based forms.
|
||||
*
|
||||
* @author Josh Bloch
|
||||
* @since 1.7
|
||||
|
|
|
@ -821,6 +821,10 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* <p> If this object represents a primitive type or void, the method
|
||||
* returns an array of length 0.
|
||||
*
|
||||
* <p> If this {@code Class} object represents an array type, the
|
||||
* interfaces {@code Cloneable} and {@code java.io.Serializable} are
|
||||
* returned in that order.
|
||||
*
|
||||
* @return an array of interfaces implemented by this class.
|
||||
*/
|
||||
public Class<?>[] getInterfaces() {
|
||||
|
@ -1484,22 +1488,24 @@ public final class Class<T> implements java.io.Serializable,
|
|||
/**
|
||||
* Returns an array containing {@code Field} objects reflecting all
|
||||
* the accessible public fields of the class or interface represented by
|
||||
* this {@code Class} object. The elements in the array returned are
|
||||
* not sorted and are not in any particular order. This method returns an
|
||||
* array of length 0 if the class or interface has no accessible public
|
||||
* fields, or if it represents an array class, a primitive type, or void.
|
||||
* this {@code Class} object.
|
||||
*
|
||||
* <p> Specifically, if this {@code Class} object represents a class,
|
||||
* this method returns the public fields of this class and of all its
|
||||
* superclasses. If this {@code Class} object represents an
|
||||
* interface, this method returns the fields of this interface and of all
|
||||
* its superinterfaces.
|
||||
* <p> If this {@code Class} object represents a class or interface with no
|
||||
* no accessible public fields, then this method returns an array of length
|
||||
* 0.
|
||||
*
|
||||
* <p> The implicit length field for array class is not reflected by this
|
||||
* method. User code should use the methods of class {@code Array} to
|
||||
* manipulate arrays.
|
||||
* <p> If this {@code Class} object represents a class, then this method
|
||||
* returns the public fields of the class and of all its superclasses.
|
||||
*
|
||||
* <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.
|
||||
* <p> If this {@code Class} object represents an interface, then this
|
||||
* method returns the fields of the interface and of all its
|
||||
* superinterfaces.
|
||||
*
|
||||
* <p> If this {@code Class} object represents an array type, a primitive
|
||||
* type, or void, then this method returns an array of length 0.
|
||||
*
|
||||
* <p> The elements in the returned array are not sorted and are not in any
|
||||
* particular order.
|
||||
*
|
||||
* @return the array of {@code Field} objects representing the
|
||||
* public fields
|
||||
|
@ -1512,6 +1518,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* of this class.
|
||||
*
|
||||
* @since JDK1.1
|
||||
* @jls 8.2 Class Members
|
||||
* @jls 8.3 Field Declarations
|
||||
*/
|
||||
@CallerSensitive
|
||||
public Field[] getFields() throws SecurityException {
|
||||
|
@ -1521,23 +1529,33 @@ public final class Class<T> implements java.io.Serializable,
|
|||
|
||||
|
||||
/**
|
||||
* Returns an array containing {@code Method} objects reflecting all
|
||||
* the public <em>member</em> methods of the class or interface represented
|
||||
* by this {@code Class} object, including those declared by the class
|
||||
* or interface and those inherited from superclasses and
|
||||
* superinterfaces. Array classes return all the (public) member methods
|
||||
* inherited from the {@code Object} class. The elements in the array
|
||||
* returned are not sorted and are not in any particular order. This
|
||||
* method returns an array of length 0 if this {@code Class} object
|
||||
* represents a class or interface that has no public member methods, or if
|
||||
* this {@code Class} object represents a primitive type or void.
|
||||
* Returns an array containing {@code Method} objects reflecting all the
|
||||
* public methods of the class or interface represented by this {@code
|
||||
* Class} object, including those declared by the class or interface and
|
||||
* those inherited from superclasses and superinterfaces.
|
||||
*
|
||||
* <p> The class initialization method {@code <clinit>} is not
|
||||
* included in the returned array. If the class declares multiple public
|
||||
* member methods with the same parameter types, they are all included in
|
||||
* the returned array.
|
||||
* <p> If this {@code Class} object represents a type that has multiple
|
||||
* public methods with the same name and parameter types, but different
|
||||
* return types, then the returned array has a {@code Method} object for
|
||||
* each such method.
|
||||
*
|
||||
* <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4.
|
||||
* <p> If this {@code Class} object represents a type with a class
|
||||
* initialization method {@code <clinit>}, then the returned array does
|
||||
* <em>not</em> have a corresponding {@code Method} object.
|
||||
*
|
||||
* <p> If this {@code Class} object represents an array type, then the
|
||||
* returned array has a {@code Method} object for each of the public
|
||||
* methods inherited by the array type from {@code Object}. It does not
|
||||
* contain a {@code Method} object for {@code clone()}.
|
||||
*
|
||||
* <p> If this {@code Class} object represents a class or interface with no
|
||||
* public methods, then the returned array has length 0.
|
||||
*
|
||||
* <p> If this {@code Class} object represents a primitive type or void,
|
||||
* then the returned array has length 0.
|
||||
*
|
||||
* <p> The elements in the returned array are not sorted and are not in any
|
||||
* particular order.
|
||||
*
|
||||
* @return the array of {@code Method} objects representing the
|
||||
* public methods of this class
|
||||
|
@ -1549,6 +1567,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* s.checkPackageAccess()} denies access to the package
|
||||
* of this class.
|
||||
*
|
||||
* @jls 8.2 Class Members
|
||||
* @jls 8.4 Method Declarations
|
||||
* @since JDK1.1
|
||||
*/
|
||||
@CallerSensitive
|
||||
|
@ -1595,13 +1615,14 @@ public final class Class<T> implements java.io.Serializable,
|
|||
|
||||
|
||||
/**
|
||||
* Returns a {@code Field} object that reflects the specified public
|
||||
* member field of the class or interface represented by this
|
||||
* {@code Class} object. The {@code name} parameter is a
|
||||
* {@code String} specifying the simple name of the desired field.
|
||||
* Returns a {@code Field} object that reflects the specified public member
|
||||
* field of the class or interface represented by this {@code Class}
|
||||
* object. The {@code name} parameter is a {@code String} specifying the
|
||||
* simple name of the desired field.
|
||||
*
|
||||
* <p> The field to be reflected is determined by the algorithm that
|
||||
* follows. Let C be the class represented by this object:
|
||||
* follows. Let C be the class or interface represented by this object:
|
||||
*
|
||||
* <OL>
|
||||
* <LI> If C declares a public field with the name specified, that is the
|
||||
* field to be reflected.</LI>
|
||||
|
@ -1614,7 +1635,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* is thrown.</LI>
|
||||
* </OL>
|
||||
*
|
||||
* <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.
|
||||
* <p> If this {@code Class} object represents an array type, then this
|
||||
* method does not find the {@code length} field of the array type.
|
||||
*
|
||||
* @param name the field name
|
||||
* @return the {@code Field} object of this class specified by
|
||||
|
@ -1631,6 +1653,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* of this class.
|
||||
*
|
||||
* @since JDK1.1
|
||||
* @jls 8.2 Class Members
|
||||
* @jls 8.3 Field Declarations
|
||||
*/
|
||||
@CallerSensitive
|
||||
public Field getField(String name)
|
||||
|
@ -1685,7 +1709,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* method and the method being overridden would have the same
|
||||
* signature but different return types.
|
||||
*
|
||||
* <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4.
|
||||
* <p> If this {@code Class} object represents an array type, then this
|
||||
* method does not find the {@code clone()} method.
|
||||
*
|
||||
* @param name the name of the method
|
||||
* @param parameterTypes the list of parameters
|
||||
|
@ -1702,6 +1727,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* s.checkPackageAccess()} denies access to the package
|
||||
* of this class.
|
||||
*
|
||||
* @jls 8.2 Class Members
|
||||
* @jls 8.4 Method Declarations
|
||||
* @since JDK1.1
|
||||
*/
|
||||
@CallerSensitive
|
||||
|
@ -1800,12 +1827,15 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* declared by the class or interface represented by this
|
||||
* {@code Class} object. This includes public, protected, default
|
||||
* (package) access, and private fields, but excludes inherited fields.
|
||||
* The elements in the array returned are not sorted and are not in any
|
||||
* particular order. This method returns an array of length 0 if the class
|
||||
* or interface declares no fields, or if this {@code Class} object
|
||||
* represents a primitive type, an array class, or void.
|
||||
*
|
||||
* <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.
|
||||
* <p> If this {@code Class} object represents a class or interface with no
|
||||
* declared fields, then this method returns an array of length 0.
|
||||
*
|
||||
* <p> If this {@code Class} object represents an array type, a primitive
|
||||
* type, or void, then this method returns an array of length 0.
|
||||
*
|
||||
* <p> The elements in the returned array are not sorted and are not in any
|
||||
* particular order.
|
||||
*
|
||||
* @return the array of {@code Field} objects representing all the
|
||||
* declared fields of this class
|
||||
|
@ -1831,6 +1861,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* </ul>
|
||||
*
|
||||
* @since JDK1.1
|
||||
* @jls 8.2 Class Members
|
||||
* @jls 8.3 Field Declarations
|
||||
*/
|
||||
@CallerSensitive
|
||||
public Field[] getDeclaredFields() throws SecurityException {
|
||||
|
@ -1840,20 +1872,29 @@ public final class Class<T> implements java.io.Serializable,
|
|||
|
||||
|
||||
/**
|
||||
* Returns an array of {@code Method} objects reflecting all the
|
||||
* methods declared by the class or interface represented by this
|
||||
* {@code Class} object. This includes public, protected, default
|
||||
* (package) access, and private methods, but excludes inherited methods.
|
||||
* The elements in the array returned are not sorted and are not in any
|
||||
* particular order. This method returns an array of length 0 if the class
|
||||
* or interface declares no methods, or if this {@code Class} object
|
||||
* represents a primitive type, an array class, or void. The class
|
||||
* initialization method {@code <clinit>} is not included in the
|
||||
* returned array. If the class declares multiple public member methods
|
||||
* with the same parameter types, they are all included in the returned
|
||||
* array.
|
||||
*
|
||||
* <p> See <em>The Java Language Specification</em>, section 8.2.
|
||||
* Returns an array containing {@code Method} objects reflecting all the
|
||||
* declared methods of the class or interface represented by this {@code
|
||||
* Class} object, including public, protected, default (package)
|
||||
* access, and private methods, but excluding inherited methods.
|
||||
*
|
||||
* <p> If this {@code Class} object represents a type that has multiple
|
||||
* declared methods with the same name and parameter types, but different
|
||||
* return types, then the returned array has a {@code Method} object for
|
||||
* each such method.
|
||||
*
|
||||
* <p> If this {@code Class} object represents a type that has a class
|
||||
* initialization method {@code <clinit>}, then the returned array does
|
||||
* <em>not</em> have a corresponding {@code Method} object.
|
||||
*
|
||||
* <p> If this {@code Class} object represents a class or interface with no
|
||||
* declared methods, then the returned array has length 0.
|
||||
*
|
||||
* <p> If this {@code Class} object represents an array type, a primitive
|
||||
* type, or void, then the returned array has length 0.
|
||||
*
|
||||
* <p> The elements in the returned array are not sorted and are not in any
|
||||
* particular order.
|
||||
*
|
||||
* @return the array of {@code Method} objects representing all the
|
||||
* declared methods of this class
|
||||
|
@ -1878,6 +1919,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
*
|
||||
* </ul>
|
||||
*
|
||||
* @jls 8.2 Class Members
|
||||
* @jls 8.4 Method Declarations
|
||||
* @since JDK1.1
|
||||
*/
|
||||
@CallerSensitive
|
||||
|
@ -1935,9 +1978,11 @@ public final class Class<T> implements java.io.Serializable,
|
|||
/**
|
||||
* Returns a {@code Field} object that reflects the specified declared
|
||||
* field of the class or interface represented by this {@code Class}
|
||||
* object. The {@code name} parameter is a {@code String} that
|
||||
* specifies the simple name of the desired field. Note that this method
|
||||
* will not reflect the {@code length} field of an array class.
|
||||
* object. The {@code name} parameter is a {@code String} that specifies
|
||||
* the simple name of the desired field.
|
||||
*
|
||||
* <p> If this {@code Class} object represents an array type, then this
|
||||
* method does not find the {@code length} field of the array type.
|
||||
*
|
||||
* @param name the name of the field
|
||||
* @return the {@code Field} object for the specified field in this
|
||||
|
@ -1967,6 +2012,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* </ul>
|
||||
*
|
||||
* @since JDK1.1
|
||||
* @jls 8.2 Class Members
|
||||
* @jls 8.3 Field Declarations
|
||||
*/
|
||||
@CallerSensitive
|
||||
public Field getDeclaredField(String name)
|
||||
|
@ -1994,6 +2041,9 @@ public final class Class<T> implements java.io.Serializable,
|
|||
* name is "<init>"or "<clinit>" a {@code NoSuchMethodException}
|
||||
* is raised.
|
||||
*
|
||||
* <p> If this {@code Class} object represents an array type, then this
|
||||
* method does not find the {@code clone()} method.
|
||||
*
|
||||
* @param name the name of the method
|
||||
* @param parameterTypes the parameter array
|
||||
* @return the {@code Method} object for the method of this class
|
||||
|
@ -2021,6 +2071,8 @@ public final class Class<T> implements java.io.Serializable,
|
|||
*
|
||||
* </ul>
|
||||
*
|
||||
* @jls 8.2 Class Members
|
||||
* @jls 8.4 Method Declarations
|
||||
* @since JDK1.1
|
||||
*/
|
||||
@CallerSensitive
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -646,7 +646,7 @@ public final class Math {
|
|||
|
||||
/**
|
||||
* Returns the closest {@code int} to the argument, with ties
|
||||
* rounding up.
|
||||
* rounding to positive infinity.
|
||||
*
|
||||
* <p>
|
||||
* Special cases:
|
||||
|
@ -665,15 +665,37 @@ public final class Math {
|
|||
* @see java.lang.Integer#MIN_VALUE
|
||||
*/
|
||||
public static int round(float a) {
|
||||
if (a != 0x1.fffffep-2f) // greatest float value less than 0.5
|
||||
return (int)floor(a + 0.5f);
|
||||
else
|
||||
return 0;
|
||||
int intBits = Float.floatToRawIntBits(a);
|
||||
int biasedExp = (intBits & FloatConsts.EXP_BIT_MASK)
|
||||
>> (FloatConsts.SIGNIFICAND_WIDTH - 1);
|
||||
int shift = (FloatConsts.SIGNIFICAND_WIDTH - 2
|
||||
+ FloatConsts.EXP_BIAS) - biasedExp;
|
||||
if ((shift & -32) == 0) { // shift >= 0 && shift < 32
|
||||
// a is a finite number such that pow(2,-32) <= ulp(a) < 1
|
||||
int r = ((intBits & FloatConsts.SIGNIF_BIT_MASK)
|
||||
| (FloatConsts.SIGNIF_BIT_MASK + 1));
|
||||
if (intBits < 0) {
|
||||
r = -r;
|
||||
}
|
||||
// In the comments below each Java expression evaluates to the value
|
||||
// the corresponding mathematical expression:
|
||||
// (r) evaluates to a / ulp(a)
|
||||
// (r >> shift) evaluates to floor(a * 2)
|
||||
// ((r >> shift) + 1) evaluates to floor((a + 1/2) * 2)
|
||||
// (((r >> shift) + 1) >> 1) evaluates to floor(a + 1/2)
|
||||
return ((r >> shift) + 1) >> 1;
|
||||
} else {
|
||||
// a is either
|
||||
// - a finite number with abs(a) < exp(2,FloatConsts.SIGNIFICAND_WIDTH-32) < 1/2
|
||||
// - a finite number with ulp(a) >= 1 and hence a is a mathematical integer
|
||||
// - an infinity or NaN
|
||||
return (int) a;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the closest {@code long} to the argument, with ties
|
||||
* rounding up.
|
||||
* rounding to positive infinity.
|
||||
*
|
||||
* <p>Special cases:
|
||||
* <ul><li>If the argument is NaN, the result is 0.
|
||||
|
@ -692,10 +714,32 @@ public final class Math {
|
|||
* @see java.lang.Long#MIN_VALUE
|
||||
*/
|
||||
public static long round(double a) {
|
||||
if (a != 0x1.fffffffffffffp-2) // greatest double value less than 0.5
|
||||
return (long)floor(a + 0.5d);
|
||||
else
|
||||
return 0;
|
||||
long longBits = Double.doubleToRawLongBits(a);
|
||||
long biasedExp = (longBits & DoubleConsts.EXP_BIT_MASK)
|
||||
>> (DoubleConsts.SIGNIFICAND_WIDTH - 1);
|
||||
long shift = (DoubleConsts.SIGNIFICAND_WIDTH - 2
|
||||
+ DoubleConsts.EXP_BIAS) - biasedExp;
|
||||
if ((shift & -64) == 0) { // shift >= 0 && shift < 64
|
||||
// a is a finite number such that pow(2,-64) <= ulp(a) < 1
|
||||
long r = ((longBits & DoubleConsts.SIGNIF_BIT_MASK)
|
||||
| (DoubleConsts.SIGNIF_BIT_MASK + 1));
|
||||
if (longBits < 0) {
|
||||
r = -r;
|
||||
}
|
||||
// In the comments below each Java expression evaluates to the value
|
||||
// the corresponding mathematical expression:
|
||||
// (r) evaluates to a / ulp(a)
|
||||
// (r >> shift) evaluates to floor(a * 2)
|
||||
// ((r >> shift) + 1) evaluates to floor((a + 1/2) * 2)
|
||||
// (((r >> shift) + 1) >> 1) evaluates to floor(a + 1/2)
|
||||
return ((r >> shift) + 1) >> 1;
|
||||
} else {
|
||||
// a is either
|
||||
// - a finite number with abs(a) < exp(2,DoubleConsts.SIGNIFICAND_WIDTH-64) < 1/2
|
||||
// - a finite number with ulp(a) >= 1 and hence a is a mathematical integer
|
||||
// - an infinity or NaN
|
||||
return (long) a;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class RandomNumberGeneratorHolder {
|
||||
|
|
|
@ -1336,9 +1336,16 @@ class SecurityManager {
|
|||
* top-level windows; <code>false</code> otherwise.
|
||||
* @exception NullPointerException if the <code>window</code> argument is
|
||||
* <code>null</code>.
|
||||
* @deprecated The dependency on {@code AWTPermission} creates an
|
||||
* impediment to future modularization of the Java platform.
|
||||
* Users of this method should instead invoke
|
||||
* {@link #checkPermission} directly.
|
||||
* This method will be changed in a future release to check
|
||||
* the permission {@code java.security.AllPermission}.
|
||||
* @see java.awt.Window
|
||||
* @see #checkPermission(java.security.Permission) checkPermission
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean checkTopLevelWindow(Object window) {
|
||||
if (window == null) {
|
||||
throw new NullPointerException("window can't be null");
|
||||
|
@ -1398,8 +1405,15 @@ class SecurityManager {
|
|||
* @since JDK1.1
|
||||
* @exception SecurityException if the calling thread does not have
|
||||
* permission to access the system clipboard.
|
||||
* @deprecated The dependency on {@code AWTPermission} creates an
|
||||
* impediment to future modularization of the Java platform.
|
||||
* Users of this method should instead invoke
|
||||
* {@link #checkPermission} directly.
|
||||
* This method will be changed in a future release to check
|
||||
* the permission {@code java.security.AllPermission}.
|
||||
* @see #checkPermission(java.security.Permission) checkPermission
|
||||
*/
|
||||
@Deprecated
|
||||
public void checkSystemClipboardAccess() {
|
||||
Permission perm = SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION;
|
||||
if (perm == null) {
|
||||
|
@ -1427,8 +1441,15 @@ class SecurityManager {
|
|||
* @since JDK1.1
|
||||
* @exception SecurityException if the calling thread does not have
|
||||
* permission to access the AWT event queue.
|
||||
* @deprecated The dependency on {@code AWTPermission} creates an
|
||||
* impediment to future modularization of the Java platform.
|
||||
* Users of this method should instead invoke
|
||||
* {@link #checkPermission} directly.
|
||||
* This method will be changed in a future release to check
|
||||
* the permission {@code java.security.AllPermission}.
|
||||
* @see #checkPermission(java.security.Permission) checkPermission
|
||||
*/
|
||||
@Deprecated
|
||||
public void checkAwtEventQueueAccess() {
|
||||
Permission perm = SecurityConstants.AWT.CHECK_AWT_EVENTQUEUE_PERMISSION;
|
||||
if (perm == null) {
|
||||
|
|
|
@ -633,7 +633,7 @@ public final class StrictMath {
|
|||
|
||||
/**
|
||||
* Returns the closest {@code int} to the argument, with ties
|
||||
* rounding up.
|
||||
* rounding to positive infinity.
|
||||
*
|
||||
* <p>Special cases:
|
||||
* <ul><li>If the argument is NaN, the result is 0.
|
||||
|
@ -656,7 +656,7 @@ public final class StrictMath {
|
|||
|
||||
/**
|
||||
* Returns the closest {@code long} to the argument, with ties
|
||||
* rounding up.
|
||||
* rounding to positive infinity.
|
||||
*
|
||||
* <p>Special cases:
|
||||
* <ul><li>If the argument is NaN, the result is 0.
|
||||
|
|
|
@ -2457,8 +2457,8 @@ public final class String
|
|||
* String message = String.join(" ", strings);
|
||||
* //message returned is: "Java is cool"
|
||||
*
|
||||
* Set<String> strings = new HashSet<>();
|
||||
* Strings.add("Java"); strings.add("is");
|
||||
* Set<String> strings = new LinkedHashSet<>();
|
||||
* strings.add("Java"); strings.add("is");
|
||||
* strings.add("very"); strings.add("cool");
|
||||
* String message = String.join("-", strings);
|
||||
* //message returned is: "Java-is-very-cool"
|
||||
|
@ -2652,7 +2652,7 @@ public final class String
|
|||
* returns {@code "t\u005Cu0131tle"}, where '\u005Cu0131' is the
|
||||
* LATIN SMALL LETTER DOTLESS I character.
|
||||
* To obtain correct results for locale insensitive strings, use
|
||||
* {@code toLowerCase(Locale.ENGLISH)}.
|
||||
* {@code toLowerCase(Locale.ROOT)}.
|
||||
* <p>
|
||||
* @return the {@code String}, converted to lowercase.
|
||||
* @see java.lang.String#toLowerCase(Locale)
|
||||
|
@ -2815,7 +2815,7 @@ public final class String
|
|||
* returns {@code "T\u005Cu0130TLE"}, where '\u005Cu0130' is the
|
||||
* LATIN CAPITAL LETTER I WITH DOT ABOVE character.
|
||||
* To obtain correct results for locale insensitive strings, use
|
||||
* {@code toUpperCase(Locale.ENGLISH)}.
|
||||
* {@code toUpperCase(Locale.ROOT)}.
|
||||
* <p>
|
||||
* @return the {@code String}, converted to uppercase.
|
||||
* @see java.lang.String#toUpperCase(Locale)
|
||||
|
|
|
@ -124,7 +124,7 @@ import static sun.invoke.util.Wrapper.isWrapperType;
|
|||
this.samMethodType = samMethodType;
|
||||
|
||||
this.implMethod = implMethod;
|
||||
this.implInfo = new MethodHandleInfo(implMethod);
|
||||
this.implInfo = caller.revealDirect(implMethod);
|
||||
// @@@ Temporary work-around pending resolution of 8005119
|
||||
this.implKind = (implInfo.getReferenceKind() == MethodHandleInfo.REF_invokeSpecial)
|
||||
? MethodHandleInfo.REF_invokeVirtual
|
||||
|
|
145
jdk/src/share/classes/java/lang/invoke/InfoFromMemberName.java
Normal file
145
jdk/src/share/classes/java/lang/invoke/InfoFromMemberName.java
Normal file
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.lang.invoke;
|
||||
|
||||
import java.security.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.invoke.MethodHandleNatives.Constants;
|
||||
import java.lang.invoke.MethodHandles.Lookup;
|
||||
import static java.lang.invoke.MethodHandleStatics.*;
|
||||
|
||||
/*
|
||||
* Auxiliary to MethodHandleInfo, wants to nest in MethodHandleInfo but must be non-public.
|
||||
*/
|
||||
/*non-public*/
|
||||
final
|
||||
class InfoFromMemberName implements MethodHandleInfo {
|
||||
private final MemberName member;
|
||||
private final int referenceKind;
|
||||
|
||||
InfoFromMemberName(Lookup lookup, MemberName member, byte referenceKind) {
|
||||
assert(member.isResolved() || member.isMethodHandleInvoke());
|
||||
assert(member.referenceKindIsConsistentWith(referenceKind));
|
||||
this.member = member;
|
||||
this.referenceKind = referenceKind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getDeclaringClass() {
|
||||
return member.getDeclaringClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return member.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodType getMethodType() {
|
||||
return member.getMethodOrFieldType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getModifiers() {
|
||||
return member.getModifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReferenceKind() {
|
||||
return referenceKind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MethodHandleInfo.toString(getReferenceKind(), getDeclaringClass(), getName(), getMethodType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Member> T reflectAs(Class<T> expected, Lookup lookup) {
|
||||
if (member.isMethodHandleInvoke() && !member.isVarargs()) {
|
||||
// This member is an instance of a signature-polymorphic method, which cannot be reflected
|
||||
// A method handle invoker can come in either of two forms:
|
||||
// A generic placeholder (present in the source code, and varargs)
|
||||
// and a signature-polymorphic instance (synthetic and not varargs).
|
||||
// For more information see comments on {@link MethodHandleNatives#linkMethod}.
|
||||
throw new IllegalArgumentException("cannot reflect signature polymorphic method");
|
||||
}
|
||||
Member mem = AccessController.doPrivileged(new PrivilegedAction<Member>() {
|
||||
public Member run() {
|
||||
try {
|
||||
return reflectUnchecked();
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new IllegalArgumentException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
Class<?> defc = getDeclaringClass();
|
||||
byte refKind = (byte) getReferenceKind();
|
||||
lookup.checkAccess(refKind, defc, convertToMemberName(refKind, mem));
|
||||
} catch (IllegalAccessException ex) {
|
||||
throw new IllegalArgumentException(ex);
|
||||
}
|
||||
return expected.cast(mem);
|
||||
}
|
||||
|
||||
private Member reflectUnchecked() throws ReflectiveOperationException {
|
||||
byte refKind = (byte) getReferenceKind();
|
||||
Class<?> defc = getDeclaringClass();
|
||||
boolean isPublic = Modifier.isPublic(getModifiers());
|
||||
if (MethodHandleNatives.refKindIsMethod(refKind)) {
|
||||
if (isPublic)
|
||||
return defc.getMethod(getName(), getMethodType().parameterArray());
|
||||
else
|
||||
return defc.getDeclaredMethod(getName(), getMethodType().parameterArray());
|
||||
} else if (MethodHandleNatives.refKindIsConstructor(refKind)) {
|
||||
if (isPublic)
|
||||
return defc.getConstructor(getMethodType().parameterArray());
|
||||
else
|
||||
return defc.getDeclaredConstructor(getMethodType().parameterArray());
|
||||
} else if (MethodHandleNatives.refKindIsField(refKind)) {
|
||||
if (isPublic)
|
||||
return defc.getField(getName());
|
||||
else
|
||||
return defc.getDeclaredField(getName());
|
||||
} else {
|
||||
throw new IllegalArgumentException("referenceKind="+refKind);
|
||||
}
|
||||
}
|
||||
|
||||
private static MemberName convertToMemberName(byte refKind, Member mem) throws IllegalAccessException {
|
||||
if (mem instanceof Method) {
|
||||
boolean wantSpecial = (refKind == REF_invokeSpecial);
|
||||
return new MemberName((Method) mem, wantSpecial);
|
||||
} else if (mem instanceof Constructor) {
|
||||
return new MemberName((Constructor) mem);
|
||||
} else if (mem instanceof Field) {
|
||||
boolean isSetter = (refKind == REF_putField || refKind == REF_putStatic);
|
||||
return new MemberName((Field) mem, isSetter);
|
||||
}
|
||||
throw new InternalError(mem.getClass().getName());
|
||||
}
|
||||
}
|
|
@ -612,6 +612,12 @@ class InvokerBytecodeGenerator {
|
|||
return false; // inner class of some sort
|
||||
if (cls.getClassLoader() != MethodHandle.class.getClassLoader())
|
||||
return false; // not on BCP
|
||||
MethodType mtype = member.getMethodOrFieldType();
|
||||
if (!isStaticallyNameable(mtype.returnType()))
|
||||
return false;
|
||||
for (Class<?> ptype : mtype.parameterArray())
|
||||
if (!isStaticallyNameable(ptype))
|
||||
return false;
|
||||
if (!member.isPrivate() && VerifyAccess.isSamePackage(MethodHandle.class, cls))
|
||||
return true; // in java.lang.invoke package
|
||||
if (member.isPublic() && isStaticallyNameable(cls))
|
||||
|
|
|
@ -87,6 +87,7 @@ class Invokers {
|
|||
lform = invokeForm(mtype, true, MethodTypeForm.LF_EX_INVOKER);
|
||||
invoker = SimpleMethodHandle.make(invokerType, lform);
|
||||
}
|
||||
invoker = invoker.withInternalMemberName(MemberName.makeMethodHandleInvoke("invokeExact", mtype));
|
||||
assert(checkInvoker(invoker));
|
||||
exactInvoker = invoker;
|
||||
return invoker;
|
||||
|
@ -110,6 +111,7 @@ class Invokers {
|
|||
lform = invokeForm(mtype, true, MethodTypeForm.LF_GEN_INVOKER);
|
||||
invoker = SimpleMethodHandle.make(invokerType, lform);
|
||||
}
|
||||
invoker = invoker.withInternalMemberName(MemberName.makeMethodHandleInvoke("invoke", mtype));
|
||||
assert(checkInvoker(invoker));
|
||||
generalInvoker = invoker;
|
||||
return invoker;
|
||||
|
|
|
@ -320,14 +320,18 @@ import java.util.Objects;
|
|||
|
||||
/** Utility method to query if this member is a method handle invocation (invoke or invokeExact). */
|
||||
public boolean isMethodHandleInvoke() {
|
||||
final int bits = Modifier.NATIVE | Modifier.FINAL;
|
||||
final int bits = MH_INVOKE_MODS;
|
||||
final int negs = Modifier.STATIC;
|
||||
if (testFlags(bits | negs, bits) &&
|
||||
clazz == MethodHandle.class) {
|
||||
return name.equals("invoke") || name.equals("invokeExact");
|
||||
return isMethodHandleInvokeName(name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean isMethodHandleInvokeName(String name) {
|
||||
return name.equals("invoke") || name.equals("invokeExact");
|
||||
}
|
||||
private static final int MH_INVOKE_MODS = Modifier.NATIVE | Modifier.FINAL | Modifier.PUBLIC;
|
||||
|
||||
/** Utility method to query the modifier flags of this member. */
|
||||
public boolean isStatic() {
|
||||
|
@ -482,12 +486,27 @@ import java.util.Objects;
|
|||
m.getClass(); // NPE check
|
||||
// fill in vmtarget, vmindex while we have m in hand:
|
||||
MethodHandleNatives.init(this, m);
|
||||
if (clazz == null) { // MHN.init failed
|
||||
if (m.getDeclaringClass() == MethodHandle.class &&
|
||||
isMethodHandleInvokeName(m.getName())) {
|
||||
// The JVM did not reify this signature-polymorphic instance.
|
||||
// Need a special case here.
|
||||
// See comments on MethodHandleNatives.linkMethod.
|
||||
MethodType type = MethodType.methodType(m.getReturnType(), m.getParameterTypes());
|
||||
int flags = flagsMods(IS_METHOD, m.getModifiers(), REF_invokeVirtual);
|
||||
init(MethodHandle.class, m.getName(), type, flags);
|
||||
if (isMethodHandleInvoke())
|
||||
return;
|
||||
}
|
||||
throw new LinkageError(m.toString());
|
||||
}
|
||||
assert(isResolved() && this.clazz != null);
|
||||
this.name = m.getName();
|
||||
if (this.type == null)
|
||||
this.type = new Object[] { m.getReturnType(), m.getParameterTypes() };
|
||||
if (wantSpecial) {
|
||||
assert(!isAbstract()) : this;
|
||||
if (isAbstract())
|
||||
throw new AbstractMethodError(this.toString());
|
||||
if (getReferenceKind() == REF_invokeVirtual)
|
||||
changeReferenceKind(REF_invokeSpecial, REF_invokeVirtual);
|
||||
else if (getReferenceKind() == REF_invokeInterface)
|
||||
|
@ -562,6 +581,22 @@ import java.util.Objects;
|
|||
initResolved(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a name for a signature-polymorphic invoker.
|
||||
* This is a placeholder for a signature-polymorphic instance
|
||||
* (of MH.invokeExact, etc.) that the JVM does not reify.
|
||||
* See comments on {@link MethodHandleNatives#linkMethod}.
|
||||
*/
|
||||
static MemberName makeMethodHandleInvoke(String name, MethodType type) {
|
||||
return makeMethodHandleInvoke(name, type, MH_INVOKE_MODS | SYNTHETIC);
|
||||
}
|
||||
static MemberName makeMethodHandleInvoke(String name, MethodType type, int mods) {
|
||||
MemberName mem = new MemberName(MethodHandle.class, name, type, REF_invokeVirtual);
|
||||
mem.flags |= mods; // it's not resolved, but add these modifiers anyway
|
||||
assert(mem.isMethodHandleInvoke()) : mem;
|
||||
return mem;
|
||||
}
|
||||
|
||||
// bare-bones constructor; the JVM will fill it in
|
||||
MemberName() { }
|
||||
|
||||
|
|
|
@ -1284,6 +1284,21 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
|
|||
return null; // DMH returns DMH.member
|
||||
}
|
||||
|
||||
/*non-public*/
|
||||
MethodHandle withInternalMemberName(MemberName member) {
|
||||
if (member != null) {
|
||||
return MethodHandleImpl.makeWrappedMember(this, member);
|
||||
} else if (internalMemberName() == null) {
|
||||
// The required internaMemberName is null, and this MH (like most) doesn't have one.
|
||||
return this;
|
||||
} else {
|
||||
// The following case is rare. Mask the internalMemberName by wrapping the MH in a BMH.
|
||||
MethodHandle result = rebind();
|
||||
assert (result.internalMemberName() == null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/*non-public*/
|
||||
boolean isInvokeSpecial() {
|
||||
return false; // DMH.Special returns true
|
||||
|
@ -1356,7 +1371,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
|
|||
MethodHandle rebind() {
|
||||
// Bind 'this' into a new invoker, of the known class BMH.
|
||||
MethodType type2 = type();
|
||||
LambdaForm form2 = reinvokerForm(type2.basicType());
|
||||
LambdaForm form2 = reinvokerForm(this);
|
||||
// form2 = lambda (bmh, arg*) { thismh = bmh[0]; invokeBasic(thismh, arg*) }
|
||||
return BoundMethodHandle.bindSingle(type2, form2, this);
|
||||
}
|
||||
|
@ -1369,23 +1384,38 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
|
|||
/** Create a LF which simply reinvokes a target of the given basic type.
|
||||
* The target MH must override {@link #reinvokerTarget} to provide the target.
|
||||
*/
|
||||
static LambdaForm reinvokerForm(MethodType mtype) {
|
||||
mtype = mtype.basicType();
|
||||
static LambdaForm reinvokerForm(MethodHandle target) {
|
||||
MethodType mtype = target.type().basicType();
|
||||
LambdaForm reinvoker = mtype.form().cachedLambdaForm(MethodTypeForm.LF_REINVOKE);
|
||||
if (reinvoker != null) return reinvoker;
|
||||
MethodHandle MH_invokeBasic = MethodHandles.basicInvoker(mtype);
|
||||
if (mtype.parameterSlotCount() >= MethodType.MAX_MH_ARITY)
|
||||
return makeReinvokerForm(target.type(), target); // cannot cache this
|
||||
reinvoker = makeReinvokerForm(mtype, null);
|
||||
return mtype.form().setCachedLambdaForm(MethodTypeForm.LF_REINVOKE, reinvoker);
|
||||
}
|
||||
private static LambdaForm makeReinvokerForm(MethodType mtype, MethodHandle customTargetOrNull) {
|
||||
boolean customized = (customTargetOrNull != null);
|
||||
MethodHandle MH_invokeBasic = customized ? null : MethodHandles.basicInvoker(mtype);
|
||||
final int THIS_BMH = 0;
|
||||
final int ARG_BASE = 1;
|
||||
final int ARG_LIMIT = ARG_BASE + mtype.parameterCount();
|
||||
int nameCursor = ARG_LIMIT;
|
||||
final int NEXT_MH = nameCursor++;
|
||||
final int NEXT_MH = customized ? -1 : nameCursor++;
|
||||
final int REINVOKE = nameCursor++;
|
||||
LambdaForm.Name[] names = LambdaForm.arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
|
||||
names[NEXT_MH] = new LambdaForm.Name(NF_reinvokerTarget, names[THIS_BMH]);
|
||||
Object[] targetArgs = Arrays.copyOfRange(names, THIS_BMH, ARG_LIMIT, Object[].class);
|
||||
targetArgs[0] = names[NEXT_MH]; // overwrite this MH with next MH
|
||||
names[REINVOKE] = new LambdaForm.Name(MH_invokeBasic, targetArgs);
|
||||
return mtype.form().setCachedLambdaForm(MethodTypeForm.LF_REINVOKE, new LambdaForm("BMH.reinvoke", ARG_LIMIT, names));
|
||||
Object[] targetArgs;
|
||||
MethodHandle targetMH;
|
||||
if (customized) {
|
||||
targetArgs = Arrays.copyOfRange(names, ARG_BASE, ARG_LIMIT, Object[].class);
|
||||
targetMH = customTargetOrNull;
|
||||
} else {
|
||||
names[NEXT_MH] = new LambdaForm.Name(NF_reinvokerTarget, names[THIS_BMH]);
|
||||
targetArgs = Arrays.copyOfRange(names, THIS_BMH, ARG_LIMIT, Object[].class);
|
||||
targetArgs[0] = names[NEXT_MH]; // overwrite this MH with next MH
|
||||
targetMH = MethodHandles.basicInvoker(mtype);
|
||||
}
|
||||
names[REINVOKE] = new LambdaForm.Name(targetMH, targetArgs);
|
||||
return new LambdaForm("BMH.reinvoke", ARG_LIMIT, names);
|
||||
}
|
||||
|
||||
private static final LambdaForm.NamedFunction NF_reinvokerTarget;
|
||||
|
|
|
@ -317,7 +317,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
|||
private MethodHandle cache;
|
||||
|
||||
AsVarargsCollector(MethodHandle target, MethodType type, Class<?> arrayType) {
|
||||
super(type, reinvokerForm(type));
|
||||
super(type, reinvokerForm(target));
|
||||
this.target = target;
|
||||
this.arrayType = arrayType;
|
||||
this.cache = target.asCollector(arrayType, 0);
|
||||
|
@ -778,16 +778,27 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
|||
}
|
||||
static <T extends Throwable> Empty throwException(T t) throws T { throw t; }
|
||||
|
||||
static MethodHandle FAKE_METHOD_HANDLE_INVOKE;
|
||||
static
|
||||
MethodHandle fakeMethodHandleInvoke(MemberName method) {
|
||||
MethodType type = method.getInvocationType();
|
||||
assert(type.equals(MethodType.methodType(Object.class, Object[].class)));
|
||||
MethodHandle mh = FAKE_METHOD_HANDLE_INVOKE;
|
||||
static MethodHandle[] FAKE_METHOD_HANDLE_INVOKE = new MethodHandle[2];
|
||||
static MethodHandle fakeMethodHandleInvoke(MemberName method) {
|
||||
int idx;
|
||||
assert(method.isMethodHandleInvoke());
|
||||
switch (method.getName()) {
|
||||
case "invoke": idx = 0; break;
|
||||
case "invokeExact": idx = 1; break;
|
||||
default: throw new InternalError(method.getName());
|
||||
}
|
||||
MethodHandle mh = FAKE_METHOD_HANDLE_INVOKE[idx];
|
||||
if (mh != null) return mh;
|
||||
mh = throwException(type.insertParameterTypes(0, UnsupportedOperationException.class));
|
||||
MethodType type = MethodType.methodType(Object.class, UnsupportedOperationException.class,
|
||||
MethodHandle.class, Object[].class);
|
||||
mh = throwException(type);
|
||||
mh = mh.bindTo(new UnsupportedOperationException("cannot reflectively invoke MethodHandle"));
|
||||
FAKE_METHOD_HANDLE_INVOKE = mh;
|
||||
if (!method.getInvocationType().equals(mh.type()))
|
||||
throw new InternalError(method.toString());
|
||||
mh = mh.withInternalMemberName(method);
|
||||
mh = mh.asVarargsCollector(Object[].class);
|
||||
assert(method.isVarargs());
|
||||
FAKE_METHOD_HANDLE_INVOKE[idx] = mh;
|
||||
return mh;
|
||||
}
|
||||
|
||||
|
@ -821,7 +832,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
|||
MethodHandle vamh = prepareForInvoker(mh);
|
||||
// Cache the result of makeInjectedInvoker once per argument class.
|
||||
MethodHandle bccInvoker = CV_makeInjectedInvoker.get(hostClass);
|
||||
return restoreToType(bccInvoker.bindTo(vamh), mh.type());
|
||||
return restoreToType(bccInvoker.bindTo(vamh), mh.type(), mh.internalMemberName());
|
||||
}
|
||||
|
||||
private static MethodHandle makeInjectedInvoker(Class<?> hostClass) {
|
||||
|
@ -876,8 +887,11 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
|||
}
|
||||
|
||||
// Undo the adapter effect of prepareForInvoker:
|
||||
private static MethodHandle restoreToType(MethodHandle vamh, MethodType type) {
|
||||
return vamh.asCollector(Object[].class, type.parameterCount()).asType(type);
|
||||
private static MethodHandle restoreToType(MethodHandle vamh, MethodType type, MemberName member) {
|
||||
MethodHandle mh = vamh.asCollector(Object[].class, type.parameterCount());
|
||||
mh = mh.asType(type);
|
||||
mh = mh.withInternalMemberName(member);
|
||||
return mh;
|
||||
}
|
||||
|
||||
private static final MethodHandle MH_checkCallerClass;
|
||||
|
@ -939,4 +953,41 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** This subclass allows a wrapped method handle to be re-associated with an arbitrary member name. */
|
||||
static class WrappedMember extends MethodHandle {
|
||||
private final MethodHandle target;
|
||||
private final MemberName member;
|
||||
|
||||
private WrappedMember(MethodHandle target, MethodType type, MemberName member) {
|
||||
super(type, reinvokerForm(target));
|
||||
this.target = target;
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
@Override
|
||||
MethodHandle reinvokerTarget() {
|
||||
return target;
|
||||
}
|
||||
@Override
|
||||
MemberName internalMemberName() {
|
||||
return member;
|
||||
}
|
||||
@Override
|
||||
boolean isInvokeSpecial() {
|
||||
return target.isInvokeSpecial();
|
||||
}
|
||||
@Override
|
||||
MethodHandle viewAsType(MethodType newType) {
|
||||
return new WrappedMember(target, newType, member);
|
||||
}
|
||||
}
|
||||
|
||||
static MethodHandle makeWrappedMember(MethodHandle target, MemberName member) {
|
||||
if (member.equals(target.internalMemberName()))
|
||||
return target;
|
||||
return new WrappedMember(target, target.type(), member);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,80 +24,246 @@
|
|||
*/
|
||||
|
||||
package java.lang.invoke;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.lang.invoke.MethodHandleNatives.Constants;
|
||||
import java.lang.invoke.MethodHandles.Lookup;
|
||||
import static java.lang.invoke.MethodHandleStatics.*;
|
||||
|
||||
/**
|
||||
* Cracking (reflecting) method handles back into their constituent symbolic parts.
|
||||
* A symbolic reference obtained by cracking a method handle into its consitutent symbolic parts.
|
||||
* To crack a direct method handle, call {@link Lookup#revealDirect Lookup.revealDirect}.
|
||||
* <p>
|
||||
* A <em>direct method handle</em> represents a method, constructor, or field without
|
||||
* any intervening argument bindings or other transformations.
|
||||
* The method, constructor, or field referred to by a direct method handle is called
|
||||
* its <em>underlying member</em>.
|
||||
* Direct method handles may be obtained in any of these ways:
|
||||
* <ul>
|
||||
* <li>By executing an {@code ldc} instruction on a {@code CONSTANT_MethodHandle} constant.
|
||||
* (See the Java Virtual Machine Specification, sections 4.4.8 and 5.4.3.)
|
||||
* <li>By calling one of the <a href="MethodHandles.Lookup.html#lookups">Lookup Factory Methods</a>,
|
||||
* such as {@link Lookup#findVirtual Lookup.findVirtual},
|
||||
* to resolve a symbolic reference into a method handle.
|
||||
* A symbolic reference consists of a class, name string, and type.
|
||||
* <li>By calling the factory method {@link Lookup#unreflect Lookup.unreflect}
|
||||
* or {@link Lookup#unreflectSpecial Lookup.unreflectSpecial}
|
||||
* to convert a {@link Method} into a method handle.
|
||||
* <li>By calling the factory method {@link Lookup#unreflectConstructor Lookup.unreflectConstructor}
|
||||
* to convert a {@link Constructor} into a method handle.
|
||||
* <li>By calling the factory method {@link Lookup#unreflectGetter Lookup.unreflectGetter}
|
||||
* or {@link Lookup#unreflectSetter Lookup.unreflectSetter}
|
||||
* to convert a {@link Field} into a method handle.
|
||||
* </ul>
|
||||
* In all of these cases, it is possible to crack the resulting direct method handle
|
||||
* to recover a symbolic reference for the underlying method, constructor, or field.
|
||||
* Cracking must be done via a {@code Lookup} object equivalent to that which created
|
||||
* the target method handle, or which has enough access permissions to recreate
|
||||
* an equivalent method handle.
|
||||
*
|
||||
* <h1><a name="refkinds"></a>Reference kinds</h1>
|
||||
* The <a href="MethodHandles.Lookup.html#lookups">Lookup Factory Methods</a>
|
||||
* correspond to all major use cases for methods, constructors, and fields.
|
||||
* These use cases may be distinguished using small integers as follows:
|
||||
* <table border=1 cellpadding=5 summary="reference kinds">
|
||||
* <tr><th>reference kind</th><th>descriptive name</th><th>scope</th><th>member</th><th>behavior</th></tr>
|
||||
* <tr>
|
||||
* <td>{@code 1}</td><td>{@code REF_getField}</td><td>{@code class}</td>
|
||||
* <td>{@code FT f;}</td><td>{@code (T) this.f;}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code 2}</td><td>{@code REF_getStatic}</td><td>{@code class} or {@code interface}</td>
|
||||
* <td>{@code static}<br>{@code FT f;}</td><td>{@code (T) C.f;}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code 3}</td><td>{@code REF_putField}</td><td>{@code class}</td>
|
||||
* <td>{@code FT f;}</td><td>{@code this.f = x;}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code 4}</td><td>{@code REF_putStatic}</td><td>{@code class}</td>
|
||||
* <td>{@code static}<br>{@code FT f;}</td><td>{@code C.f = arg;}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code 5}</td><td>{@code REF_invokeVirtual}</td><td>{@code class}</td>
|
||||
* <td>{@code T m(A*);}</td><td>{@code (T) this.m(arg*);}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code 6}</td><td>{@code REF_invokeStatic}</td><td>{@code class} or {@code interface}</td>
|
||||
* <td>{@code static}<br>{@code T m(A*);}</td><td>{@code (T) C.m(arg*);}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code 7}</td><td>{@code REF_invokeSpecial}</td><td>{@code class} or {@code interface}</td>
|
||||
* <td>{@code T m(A*);}</td><td>{@code (T) super.m(arg*);}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code 8}</td><td>{@code REF_newInvokeSpecial}</td><td>{@code class}</td>
|
||||
* <td>{@code C(A*);}</td><td>{@code new C(arg*);}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code 9}</td><td>{@code REF_invokeInterface}</td><td>{@code interface}</td>
|
||||
* <td>{@code T m(A*);}</td><td>{@code (T) this.m(arg*);}</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* @since 1.8
|
||||
*/
|
||||
final class MethodHandleInfo {
|
||||
public static final int
|
||||
REF_getField = Constants.REF_getField,
|
||||
REF_getStatic = Constants.REF_getStatic,
|
||||
REF_putField = Constants.REF_putField,
|
||||
REF_putStatic = Constants.REF_putStatic,
|
||||
REF_invokeVirtual = Constants.REF_invokeVirtual,
|
||||
REF_invokeStatic = Constants.REF_invokeStatic,
|
||||
REF_invokeSpecial = Constants.REF_invokeSpecial,
|
||||
REF_newInvokeSpecial = Constants.REF_newInvokeSpecial,
|
||||
REF_invokeInterface = Constants.REF_invokeInterface;
|
||||
public
|
||||
interface MethodHandleInfo {
|
||||
/**
|
||||
* A direct method handle reference kind,
|
||||
* as defined in the <a href="MethodHandleInfo.html#refkinds">table above</a>.
|
||||
*/
|
||||
public static final int
|
||||
REF_getField = Constants.REF_getField,
|
||||
REF_getStatic = Constants.REF_getStatic,
|
||||
REF_putField = Constants.REF_putField,
|
||||
REF_putStatic = Constants.REF_putStatic,
|
||||
REF_invokeVirtual = Constants.REF_invokeVirtual,
|
||||
REF_invokeStatic = Constants.REF_invokeStatic,
|
||||
REF_invokeSpecial = Constants.REF_invokeSpecial,
|
||||
REF_newInvokeSpecial = Constants.REF_newInvokeSpecial,
|
||||
REF_invokeInterface = Constants.REF_invokeInterface;
|
||||
|
||||
private final Class<?> declaringClass;
|
||||
private final String name;
|
||||
private final MethodType methodType;
|
||||
private final int referenceKind;
|
||||
/**
|
||||
* Returns the reference kind of the cracked method handle, which in turn
|
||||
* determines whether the method handle's underlying member was a constructor, method, or field.
|
||||
* See the <a href="MethodHandleInfo.html#refkinds">table above</a> for definitions.
|
||||
* @return the integer code for the kind of reference used to access the underlying member
|
||||
*/
|
||||
public int getReferenceKind();
|
||||
|
||||
public MethodHandleInfo(MethodHandle mh) {
|
||||
MemberName mn = mh.internalMemberName();
|
||||
if (mn == null) throw new IllegalArgumentException("not a direct method handle");
|
||||
this.declaringClass = mn.getDeclaringClass();
|
||||
this.name = mn.getName();
|
||||
this.methodType = mn.getMethodOrFieldType();
|
||||
byte refKind = mn.getReferenceKind();
|
||||
if (refKind == REF_invokeSpecial && !mh.isInvokeSpecial())
|
||||
// Devirtualized method invocation is usually formally virtual.
|
||||
refKind = REF_invokeVirtual;
|
||||
this.referenceKind = refKind;
|
||||
}
|
||||
/**
|
||||
* Returns the class in which the cracked method handle's underlying member was defined.
|
||||
* @return the declaring class of the underlying member
|
||||
*/
|
||||
public Class<?> getDeclaringClass();
|
||||
|
||||
public Class<?> getDeclaringClass() {
|
||||
return declaringClass;
|
||||
}
|
||||
/**
|
||||
* Returns the name of the cracked method handle's underlying member.
|
||||
* This is {@code "<init>"} if the underlying member was a constructor,
|
||||
* else it is a simple method name or field name.
|
||||
* @return the simple name of the underlying member
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* Returns the nominal type of the cracked symbolic reference, expressed as a method type.
|
||||
* If the reference is to a constructor, the return type will be {@code void}.
|
||||
* If it is to a non-static method, the method type will not mention the {@code this} parameter.
|
||||
* If it is to a field and the requested access is to read the field,
|
||||
* the method type will have no parameters and return the field type.
|
||||
* If it is to a field and the requested access is to write the field,
|
||||
* the method type will have one parameter of the field type and return {@code void}.
|
||||
* <p>
|
||||
* Note that original direct method handle may include a leading {@code this} parameter,
|
||||
* or (in the case of a constructor) will replace the {@code void} return type
|
||||
* with the constructed class.
|
||||
* The nominal type does not include any {@code this} parameter,
|
||||
* and (in the case of a constructor) will return {@code void}.
|
||||
* @return the type of the underlying member, expressed as a method type
|
||||
*/
|
||||
public MethodType getMethodType();
|
||||
|
||||
public MethodType getMethodType() {
|
||||
return methodType;
|
||||
}
|
||||
// Utility methods.
|
||||
// NOTE: class/name/type and reference kind constitute a symbolic reference
|
||||
// member and modifiers are an add-on, derived from Core Reflection (or the equivalent)
|
||||
|
||||
public int getModifiers() {
|
||||
return -1; //TODO
|
||||
}
|
||||
/**
|
||||
* Reflects the underlying member as a method, constructor, or field object.
|
||||
* If the underlying member is public, it is reflected as if by
|
||||
* {@code getMethod}, {@code getConstructor}, or {@code getField}.
|
||||
* Otherwise, it is reflected as if by
|
||||
* {@code getDeclaredMethod}, {@code getDeclaredConstructor}, or {@code getDeclaredField}.
|
||||
* The underlying member must be accessible to the given lookup object.
|
||||
* @param <T> the desired type of the result, either {@link Member} or a subtype
|
||||
* @param expected a class object representing the desired result type {@code T}
|
||||
* @param lookup the lookup object that created this MethodHandleInfo, or one with equivalent access privileges
|
||||
* @return a reference to the method, constructor, or field object
|
||||
* @exception ClassCastException if the member is not of the expected type
|
||||
* @exception NullPointerException if either argument is {@code null}
|
||||
* @exception IllegalArgumentException if the underlying member is not accessible to the given lookup object
|
||||
*/
|
||||
public <T extends Member> T reflectAs(Class<T> expected, Lookup lookup);
|
||||
|
||||
public int getReferenceKind() {
|
||||
return referenceKind;
|
||||
}
|
||||
/**
|
||||
* Returns the access modifiers of the underlying member.
|
||||
* @return the Java language modifiers for underlying member,
|
||||
* or -1 if the member cannot be accessed
|
||||
* @see Modifier
|
||||
* @see reflectAs
|
||||
*/
|
||||
public int getModifiers();
|
||||
|
||||
static String getReferenceKindString(int referenceKind) {
|
||||
switch (referenceKind) {
|
||||
case REF_getField: return "getfield";
|
||||
case REF_getStatic: return "getstatic";
|
||||
case REF_putField: return "putfield";
|
||||
case REF_putStatic: return "putstatic";
|
||||
case REF_invokeVirtual: return "invokevirtual";
|
||||
case REF_invokeStatic: return "invokestatic";
|
||||
case REF_invokeSpecial: return "invokespecial";
|
||||
case REF_newInvokeSpecial: return "newinvokespecial";
|
||||
case REF_invokeInterface: return "invokeinterface";
|
||||
default: return "UNKNOWN_REFENCE_KIND" + "[" + referenceKind + "]";
|
||||
}
|
||||
/**
|
||||
* Determines if the underlying member was a variable arity method or constructor.
|
||||
* Such members are represented by method handles that are varargs collectors.
|
||||
* @implSpec
|
||||
* This produces a result equivalent to:
|
||||
* <pre>{@code
|
||||
* getReferenceKind() >= REF_invokeVirtual && Modifier.isTransient(getModifiers())
|
||||
* }</pre>
|
||||
*
|
||||
*
|
||||
* @return {@code true} if and only if the underlying member was declared with variable arity.
|
||||
*/
|
||||
// spelling derived from java.lang.reflect.Executable, not MethodHandle.isVarargsCollector
|
||||
public default boolean isVarArgs() {
|
||||
// fields are never varargs:
|
||||
if (MethodHandleNatives.refKindIsField((byte) getReferenceKind()))
|
||||
return false;
|
||||
// not in the public API: Modifier.VARARGS
|
||||
final int ACC_VARARGS = 0x00000080; // from JVMS 4.6 (Table 4.20)
|
||||
assert(ACC_VARARGS == Modifier.TRANSIENT);
|
||||
return Modifier.isTransient(getModifiers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s %s.%s:%s", getReferenceKindString(referenceKind),
|
||||
declaringClass.getName(), name, methodType);
|
||||
/**
|
||||
* Returns the descriptive name of the given reference kind,
|
||||
* as defined in the <a href="MethodHandleInfo.html#refkinds">table above</a>.
|
||||
* The conventional prefix "REF_" is omitted.
|
||||
* @param referenceKind an integer code for a kind of reference used to access a class member
|
||||
* @return a mixed-case string such as {@code "getField"}
|
||||
* @exception IllegalArgumentException if the argument is not a valid
|
||||
* <a href="MethodHandleInfo.html#refkinds">reference kind number</a>
|
||||
*/
|
||||
public static String referenceKindToString(int referenceKind) {
|
||||
if (!MethodHandleNatives.refKindIsValid(referenceKind))
|
||||
throw newIllegalArgumentException("invalid reference kind", referenceKind);
|
||||
return MethodHandleNatives.refKindName((byte)referenceKind);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation for a {@code MethodHandleInfo},
|
||||
* given the four parts of its symbolic reference.
|
||||
* This is defined to be of the form {@code "RK C.N:MT"}, where {@code RK} is the
|
||||
* {@linkplain #referenceKindToString reference kind string} for {@code kind},
|
||||
* {@code C} is the {@linkplain java.lang.Class#getName name} of {@code defc}
|
||||
* {@code N} is the {@code name}, and
|
||||
* {@code MT} is the {@code type}.
|
||||
* These four values may be obtained from the
|
||||
* {@linkplain #getReferenceKind reference kind},
|
||||
* {@linkplain #getDeclaringClass declaring class},
|
||||
* {@linkplain #getName member name},
|
||||
* and {@linkplain #getMethodType method type}
|
||||
* of a {@code MethodHandleInfo} object.
|
||||
*
|
||||
* @implSpec
|
||||
* This produces a result equivalent to:
|
||||
* <pre>{@code
|
||||
* String.format("%s %s.%s:%s", referenceKindToString(kind), defc.getName(), name, type)
|
||||
* }</pre>
|
||||
*
|
||||
* @param kind the {@linkplain #getReferenceKind reference kind} part of the symbolic reference
|
||||
* @param defc the {@linkplain #getDeclaringClass declaring class} part of the symbolic reference
|
||||
* @param name the {@linkplain #getName member name} part of the symbolic reference
|
||||
* @param type the {@linkplain #getMethodType method type} part of the symbolic reference
|
||||
* @return a string of the form {@code "RK C.N:MT"}
|
||||
* @exception IllegalArgumentException if the first argument is not a valid
|
||||
* <a href="MethodHandleInfo.html#refkinds">reference kind number</a>
|
||||
* @exception NullPointerException if any reference argument is {@code null}
|
||||
*/
|
||||
public static String toString(int kind, Class<?> defc, String name, MethodType type) {
|
||||
Objects.requireNonNull(name); Objects.requireNonNull(type);
|
||||
return String.format("%s %s.%s:%s", referenceKindToString(kind), defc.getName(), name, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,6 +205,9 @@ class MethodHandleNatives {
|
|||
static boolean refKindIsMethod(byte refKind) {
|
||||
return !refKindIsField(refKind) && (refKind != REF_newInvokeSpecial);
|
||||
}
|
||||
static boolean refKindIsConstructor(byte refKind) {
|
||||
return (refKind == REF_newInvokeSpecial);
|
||||
}
|
||||
static boolean refKindHasReceiver(byte refKind) {
|
||||
assert(refKindIsValid(refKind));
|
||||
return (refKind & 1) != 0;
|
||||
|
@ -313,7 +316,65 @@ class MethodHandleNatives {
|
|||
* The method assumes the following arguments on the stack:
|
||||
* 0: the method handle being invoked
|
||||
* 1-N: the arguments to the method handle invocation
|
||||
* N+1: an implicitly added type argument (the given MethodType)
|
||||
* N+1: an optional, implicitly added argument (typically the given MethodType)
|
||||
* <p>
|
||||
* The nominal method at such a call site is an instance of
|
||||
* a signature-polymorphic method (see @PolymorphicSignature).
|
||||
* Such method instances are user-visible entities which are
|
||||
* "split" from the generic placeholder method in {@code MethodHandle}.
|
||||
* (Note that the placeholder method is not identical with any of
|
||||
* its instances. If invoked reflectively, is guaranteed to throw an
|
||||
* {@code UnsupportedOperationException}.)
|
||||
* If the signature-polymorphic method instance is ever reified,
|
||||
* it appears as a "copy" of the original placeholder
|
||||
* (a native final member of {@code MethodHandle}) except
|
||||
* that its type descriptor has shape required by the instance,
|
||||
* and the method instance is <em>not</em> varargs.
|
||||
* The method instance is also marked synthetic, since the
|
||||
* method (by definition) does not appear in Java source code.
|
||||
* <p>
|
||||
* The JVM is allowed to reify this method as instance metadata.
|
||||
* For example, {@code invokeBasic} is always reified.
|
||||
* But the JVM may instead call {@code linkMethod}.
|
||||
* If the result is an * ordered pair of a {@code (method, appendix)},
|
||||
* the method gets all the arguments (0..N inclusive)
|
||||
* plus the appendix (N+1), and uses the appendix to complete the call.
|
||||
* In this way, one reusable method (called a "linker method")
|
||||
* can perform the function of any number of polymorphic instance
|
||||
* methods.
|
||||
* <p>
|
||||
* Linker methods are allowed to be weakly typed, with any or
|
||||
* all references rewritten to {@code Object} and any primitives
|
||||
* (except {@code long}/{@code float}/{@code double})
|
||||
* rewritten to {@code int}.
|
||||
* A linker method is trusted to return a strongly typed result,
|
||||
* according to the specific method type descriptor of the
|
||||
* signature-polymorphic instance it is emulating.
|
||||
* This can involve (as necessary) a dynamic check using
|
||||
* data extracted from the appendix argument.
|
||||
* <p>
|
||||
* The JVM does not inspect the appendix, other than to pass
|
||||
* it verbatim to the linker method at every call.
|
||||
* This means that the JDK runtime has wide latitude
|
||||
* for choosing the shape of each linker method and its
|
||||
* corresponding appendix.
|
||||
* Linker methods should be generated from {@code LambdaForm}s
|
||||
* so that they do not become visible on stack traces.
|
||||
* <p>
|
||||
* The {@code linkMethod} call is free to omit the appendix
|
||||
* (returning null) and instead emulate the required function
|
||||
* completely in the linker method.
|
||||
* As a corner case, if N==255, no appendix is possible.
|
||||
* In this case, the method returned must be custom-generated to
|
||||
* to perform any needed type checking.
|
||||
* <p>
|
||||
* If the JVM does not reify a method at a call site, but instead
|
||||
* calls {@code linkMethod}, the corresponding call represented
|
||||
* in the bytecodes may mention a valid method which is not
|
||||
* representable with a {@code MemberName}.
|
||||
* Therefore, use cases for {@code linkMethod} tend to correspond to
|
||||
* special cases in reflective code such as {@code findVirtual}
|
||||
* or {@code revealDirect}.
|
||||
*/
|
||||
static MemberName linkMethod(Class<?> callerClass, int refKind,
|
||||
Class<?> defc, String name, Object type,
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
package java.lang.invoke;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -54,6 +52,7 @@ import sun.security.util.SecurityConstants;
|
|||
* </ul>
|
||||
* <p>
|
||||
* @author John Rose, JSR 292 EG
|
||||
* @since 1.7
|
||||
*/
|
||||
public class MethodHandles {
|
||||
|
||||
|
@ -96,6 +95,38 @@ public class MethodHandles {
|
|||
return Lookup.PUBLIC_LOOKUP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an unchecked "crack" of a direct method handle.
|
||||
* The result is as if the user had obtained a lookup object capable enough
|
||||
* to crack the target method handle, called
|
||||
* {@link java.lang.invoke.MethodHandles.Lookup#revealDirect Lookup.revealDirect}
|
||||
* on the target to obtain its symbolic reference, and then called
|
||||
* {@link java.lang.invoke.MethodHandleInfo#reflectAs MethodHandleInfo.reflectAs}
|
||||
* to resolve the symbolic reference to a member.
|
||||
* <p>
|
||||
* If there is a security manager, its {@code checkPermission} method
|
||||
* is called with a {@code ReflectPermission("suppressAccessChecks")} permission.
|
||||
* @param <T> the desired type of the result, either {@link Member} or a subtype
|
||||
* @param target a direct method handle to crack into symbolic reference components
|
||||
* @param expected a class object representing the desired result type {@code T}
|
||||
* @return a reference to the method, constructor, or field object
|
||||
* @exception SecurityException if the caller is not privileged to call {@code setAccessible}
|
||||
* @exception NullPointerException if either argument is {@code null}
|
||||
* @exception IllegalArgumentException if the target is not a direct method handle
|
||||
* @exception ClassCastException if the member is not of the expected type
|
||||
* @since 1.8
|
||||
*/
|
||||
public static <T extends Member> T
|
||||
reflectAs(Class<T> expected, MethodHandle target) {
|
||||
SecurityManager smgr = System.getSecurityManager();
|
||||
if (smgr != null) smgr.checkPermission(ACCESS_PERMISSION);
|
||||
Lookup lookup = Lookup.IMPL_LOOKUP; // use maximally privileged lookup
|
||||
return lookup.revealDirect(target).reflectAs(expected, lookup);
|
||||
}
|
||||
// Copied from AccessibleObject, as used by Method.setAccessible, etc.:
|
||||
static final private java.security.Permission ACCESS_PERMISSION =
|
||||
new ReflectPermission("suppressAccessChecks");
|
||||
|
||||
/**
|
||||
* A <em>lookup object</em> is a factory for creating method handles,
|
||||
* when the creation requires access checking.
|
||||
|
@ -647,6 +678,7 @@ public class MethodHandles {
|
|||
return invoker(type);
|
||||
if ("invokeExact".equals(name))
|
||||
return exactInvoker(type);
|
||||
assert(!MemberName.isMethodHandleInvokeName(name));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -892,6 +924,10 @@ return mh1;
|
|||
* @throws NullPointerException if the argument is null
|
||||
*/
|
||||
public MethodHandle unreflect(Method m) throws IllegalAccessException {
|
||||
if (m.getDeclaringClass() == MethodHandle.class) {
|
||||
MethodHandle mh = unreflectForMH(m);
|
||||
if (mh != null) return mh;
|
||||
}
|
||||
MemberName method = new MemberName(m);
|
||||
byte refKind = method.getReferenceKind();
|
||||
if (refKind == REF_invokeSpecial)
|
||||
|
@ -900,6 +936,12 @@ return mh1;
|
|||
Lookup lookup = m.isAccessible() ? IMPL_LOOKUP : this;
|
||||
return lookup.getDirectMethod(refKind, method.getDeclaringClass(), method, findBoundCallerClass(method));
|
||||
}
|
||||
private MethodHandle unreflectForMH(Method m) {
|
||||
// these names require special lookups because they throw UnsupportedOperationException
|
||||
if (MemberName.isMethodHandleInvokeName(m.getName()))
|
||||
return MethodHandleImpl.fakeMethodHandleInvoke(new MemberName(m));
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a method handle for a reflected method.
|
||||
|
@ -1004,6 +1046,46 @@ return mh1;
|
|||
return unreflectField(f, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cracks a direct method handle created by this lookup object or a similar one.
|
||||
* Security and access checks are performed to ensure that this lookup object
|
||||
* is capable of reproducing the target method handle.
|
||||
* This means that the cracking may fail if target is a direct method handle
|
||||
* but was created by an unrelated lookup object.
|
||||
* @param target a direct method handle to crack into symbolic reference components
|
||||
* @return a symbolic reference which can be used to reconstruct this method handle from this lookup object
|
||||
* @exception SecurityException if a security manager is present and it
|
||||
* <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
|
||||
* @throws IllegalArgumentException if the target is not a direct method handle or if access checking fails
|
||||
* @exception NullPointerException if the target is {@code null}
|
||||
* @since 1.8
|
||||
*/
|
||||
public MethodHandleInfo revealDirect(MethodHandle target) {
|
||||
MemberName member = target.internalMemberName();
|
||||
if (member == null || (!member.isResolved() && !member.isMethodHandleInvoke()))
|
||||
throw newIllegalArgumentException("not a direct method handle");
|
||||
Class<?> defc = member.getDeclaringClass();
|
||||
byte refKind = member.getReferenceKind();
|
||||
assert(MethodHandleNatives.refKindIsValid(refKind));
|
||||
if (refKind == REF_invokeSpecial && !target.isInvokeSpecial())
|
||||
// Devirtualized method invocation is usually formally virtual.
|
||||
// To avoid creating extra MemberName objects for this common case,
|
||||
// we encode this extra degree of freedom using MH.isInvokeSpecial.
|
||||
refKind = REF_invokeVirtual;
|
||||
if (refKind == REF_invokeVirtual && defc.isInterface())
|
||||
// Symbolic reference is through interface but resolves to Object method (toString, etc.)
|
||||
refKind = REF_invokeInterface;
|
||||
// Check SM permissions and member access before cracking.
|
||||
try {
|
||||
checkSecurityManager(defc, member);
|
||||
checkAccess(refKind, defc, member);
|
||||
} catch (IllegalAccessException ex) {
|
||||
throw new IllegalArgumentException(ex);
|
||||
}
|
||||
// Produce the handle to the results.
|
||||
return new InfoFromMemberName(this, member, refKind);
|
||||
}
|
||||
|
||||
/// Helper methods, all package-private.
|
||||
|
||||
MemberName resolveOrFail(byte refKind, Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
|
||||
|
@ -1201,12 +1283,12 @@ return mh1;
|
|||
private MethodHandle getDirectMethodCommon(byte refKind, Class<?> refc, MemberName method,
|
||||
boolean doRestrict, Class<?> callerClass) throws IllegalAccessException {
|
||||
checkMethod(refKind, refc, method);
|
||||
if (method.isMethodHandleInvoke())
|
||||
return fakeMethodHandleInvoke(method);
|
||||
assert(!method.isMethodHandleInvoke());
|
||||
|
||||
Class<?> refcAsSuper;
|
||||
if (refKind == REF_invokeSpecial &&
|
||||
refc != lookupClass() &&
|
||||
!refc.isInterface() &&
|
||||
refc != (refcAsSuper = lookupClass().getSuperclass()) &&
|
||||
refc.isAssignableFrom(lookupClass())) {
|
||||
assert(!method.getName().equals("<init>")); // not this code path
|
||||
|
@ -1234,9 +1316,6 @@ return mh1;
|
|||
mh = restrictReceiver(method, mh, lookupClass());
|
||||
return mh;
|
||||
}
|
||||
private MethodHandle fakeMethodHandleInvoke(MemberName method) {
|
||||
return throwException(method.getReturnType(), UnsupportedOperationException.class);
|
||||
}
|
||||
private MethodHandle maybeBindCaller(MemberName method, MethodHandle mh,
|
||||
Class<?> callerClass)
|
||||
throws IllegalAccessException {
|
||||
|
|
|
@ -225,7 +225,7 @@ public final class SerializedLambda implements Serializable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
String implKind=MethodHandleInfo.getReferenceKindString(implMethodKind);
|
||||
String implKind=MethodHandleInfo.referenceKindToString(implMethodKind);
|
||||
return String.format("SerializedLambda[%s=%s, %s=%s.%s:%s, " +
|
||||
"%s=%s %s.%s:%s, %s=%s, %s=%d]",
|
||||
"capturingClass", capturingClass,
|
||||
|
|
|
@ -428,20 +428,32 @@ public abstract class Executable extends AccessibleObject
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array of arrays that represent the annotations on
|
||||
* the formal parameters, in declaration order, of the executable
|
||||
* represented by this object. (Returns an array of length zero if
|
||||
* the underlying executable is parameterless. If the executable has
|
||||
* one or more parameters, a nested array of length zero is
|
||||
* returned for each parameter with no annotations.) The
|
||||
* annotation objects contained in the returned arrays are
|
||||
* serializable. The caller of this method is free to modify the
|
||||
* returned arrays; it will have no effect on the arrays returned
|
||||
* to other callers.
|
||||
* Returns an array of arrays of {@code Annotation}s that
|
||||
* represent the annotations on the formal parameters, in
|
||||
* declaration order, of the {@code Executable} represented by
|
||||
* this object. Synthetic and mandated parameters (see
|
||||
* explanation below), such as the outer "this" parameter to an
|
||||
* inner class constructor will be represented in the returned
|
||||
* array. If the executable has no parameters (meaning no formal,
|
||||
* no synthetic, and no mandated parameters), a zero-length array
|
||||
* will be returned. If the {@code Executable} has one or more
|
||||
* parameters, a nested array of length zero is returned for each
|
||||
* parameter with no annotations. The annotation objects contained
|
||||
* in the returned arrays are serializable. The caller of this
|
||||
* method is free to modify the returned arrays; it will have no
|
||||
* effect on the arrays returned to other callers.
|
||||
*
|
||||
* @return an array of arrays that represent the annotations on the formal
|
||||
* parameters, in declaration order, of the executable represented by this
|
||||
* object
|
||||
* A compiler may add extra parameters that are implicitly
|
||||
* declared in source ("mandated"), as well as parameters that
|
||||
* are neither implicitly nor explicitly declared in source
|
||||
* ("synthetic") to the parameter list for a method. See {@link
|
||||
* java.lang.reflect.Parameter} for more information.
|
||||
*
|
||||
* @see java.lang.reflect.Parameter
|
||||
* @see java.lang.reflect.Parameter#getAnnotations
|
||||
* @return an array of arrays that represent the annotations on
|
||||
* the formal and implicit parameters, in declaration order, of
|
||||
* the executable represented by this object
|
||||
*/
|
||||
public abstract Annotation[][] getParameterAnnotations();
|
||||
|
||||
|
|
|
@ -719,7 +719,3 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
|
|||
public final static int SHUT_RD = 0;
|
||||
public final static int SHUT_WR = 1;
|
||||
}
|
||||
|
||||
class InetAddressContainer {
|
||||
InetAddress addr;
|
||||
}
|
||||
|
|
|
@ -292,13 +292,17 @@ public final class IDN {
|
|||
if (useSTD3ASCIIRules) {
|
||||
for (int i = 0; i < dest.length(); i++) {
|
||||
int c = dest.charAt(i);
|
||||
if (!isLDHChar(c)) {
|
||||
throw new IllegalArgumentException("Contains non-LDH characters");
|
||||
if (isNonLDHAsciiCodePoint(c)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Contains non-LDH ASCII characters");
|
||||
}
|
||||
}
|
||||
|
||||
if (dest.charAt(0) == '-' || dest.charAt(dest.length() - 1) == '-') {
|
||||
throw new IllegalArgumentException("Has leading or trailing hyphen");
|
||||
if (dest.charAt(0) == '-' ||
|
||||
dest.charAt(dest.length() - 1) == '-') {
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
"Has leading or trailing hyphen");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,26 +405,20 @@ public final class IDN {
|
|||
//
|
||||
// LDH stands for "letter/digit/hyphen", with characters restricted to the
|
||||
// 26-letter Latin alphabet <A-Z a-z>, the digits <0-9>, and the hyphen
|
||||
// <->
|
||||
// non-LDH = 0..0x2C, 0x2E..0x2F, 0x3A..0x40, 0x56..0x60, 0x7B..0x7F
|
||||
// <->.
|
||||
// Non LDH refers to characters in the ASCII range, but which are not
|
||||
// letters, digits or the hypen.
|
||||
//
|
||||
private static boolean isLDHChar(int ch){
|
||||
// high runner case
|
||||
if(ch > 0x007A){
|
||||
return false;
|
||||
}
|
||||
//['-' '0'..'9' 'A'..'Z' 'a'..'z']
|
||||
if((ch == 0x002D) ||
|
||||
(0x0030 <= ch && ch <= 0x0039) ||
|
||||
(0x0041 <= ch && ch <= 0x005A) ||
|
||||
(0x0061 <= ch && ch <= 0x007A)
|
||||
){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// non-LDH = 0..0x2C, 0x2E..0x2F, 0x3A..0x40, 0x5B..0x60, 0x7B..0x7F
|
||||
//
|
||||
private static boolean isNonLDHAsciiCodePoint(int ch){
|
||||
return (0x0000 <= ch && ch <= 0x002C) ||
|
||||
(0x002E <= ch && ch <= 0x002F) ||
|
||||
(0x003A <= ch && ch <= 0x0040) ||
|
||||
(0x005B <= ch && ch <= 0x0060) ||
|
||||
(0x007B <= ch && ch <= 0x007F);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// search dots in a string and return the index of that character;
|
||||
// or if there is no dots, return the length of input string
|
||||
|
|
30
jdk/src/share/classes/java/net/InetAddressContainer.java
Normal file
30
jdk/src/share/classes/java/net/InetAddressContainer.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.net;
|
||||
|
||||
class InetAddressContainer {
|
||||
InetAddress addr;
|
||||
}
|
|
@ -25,34 +25,56 @@
|
|||
|
||||
package java.nio.file;
|
||||
|
||||
import java.nio.file.attribute.*;
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
import java.nio.file.spi.FileTypeDetector;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.SeekableByteChannel;
|
||||
import java.io.Closeable;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.*;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.stream.CloseableStream;
|
||||
import java.util.stream.DelegatingStream;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.file.attribute.BasicFileAttributeView;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.DosFileAttributes;
|
||||
import java.nio.file.attribute.FileAttribute;
|
||||
import java.nio.file.attribute.FileAttributeView;
|
||||
import java.nio.file.attribute.FileOwnerAttributeView;
|
||||
import java.nio.file.attribute.FileStoreAttributeView;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.nio.file.attribute.PosixFileAttributeView;
|
||||
import java.nio.file.attribute.PosixFileAttributes;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.nio.file.attribute.UserPrincipal;
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
import java.nio.file.spi.FileTypeDetector;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.Spliterator;
|
||||
import java.util.Spliterators;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
/**
|
||||
* This class consists exclusively of static methods that operate on files,
|
||||
|
@ -74,6 +96,21 @@ public final class Files {
|
|||
return path.getFileSystem().provider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Closeable to a Runnable by converting checked IOException
|
||||
* to UncheckedIOException
|
||||
*/
|
||||
private static Runnable asUncheckedRunnable(Closeable c) {
|
||||
return () -> {
|
||||
try {
|
||||
c.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// -- File contents --
|
||||
|
||||
/**
|
||||
|
@ -3228,29 +3265,7 @@ public final class Files {
|
|||
// -- Stream APIs --
|
||||
|
||||
/**
|
||||
* Implementation of CloseableStream
|
||||
*/
|
||||
private static class DelegatingCloseableStream<T> extends DelegatingStream<T>
|
||||
implements CloseableStream<T>
|
||||
{
|
||||
private final Closeable closeable;
|
||||
|
||||
DelegatingCloseableStream(Closeable c, Stream<T> delegate) {
|
||||
super(delegate);
|
||||
this.closeable = c;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a lazily populated {@code CloseableStream}, the elements of
|
||||
* Return a lazily populated {@code Stream}, the elements of
|
||||
* which are the entries in the directory. The listing is not recursive.
|
||||
*
|
||||
* <p> The elements of the stream are {@link Path} objects that are
|
||||
|
@ -3264,10 +3279,13 @@ public final class Files {
|
|||
* reflect updates to the directory that occur after returning from this
|
||||
* method.
|
||||
*
|
||||
* <p> When not using the try-with-resources construct, then the stream's
|
||||
* {@link CloseableStream#close close} method should be invoked after the
|
||||
* operation is completed so as to free any resources held for the open
|
||||
* directory. Operating on a closed stream behaves as if the end of stream
|
||||
* <p> The returned stream encapsulates a {@link DirectoryStream}.
|
||||
* If timely disposal of file system resources is required, the
|
||||
* {@code try}-with-resources construct should be used to ensure that the
|
||||
* stream's {@link Stream#close close} method is invoked after the stream
|
||||
* operations are completed.
|
||||
*
|
||||
* <p> Operating on a closed stream behaves as if the end of stream
|
||||
* has been reached. Due to read-ahead, one or more elements may be
|
||||
* returned after the stream has been closed.
|
||||
*
|
||||
|
@ -3278,7 +3296,7 @@ public final class Files {
|
|||
*
|
||||
* @param dir The path to the directory
|
||||
*
|
||||
* @return The {@code CloseableStream} describing the content of the
|
||||
* @return The {@code Stream} describing the content of the
|
||||
* directory
|
||||
*
|
||||
* @throws NotDirectoryException
|
||||
|
@ -3294,43 +3312,54 @@ public final class Files {
|
|||
* @see #newDirectoryStream(Path)
|
||||
* @since 1.8
|
||||
*/
|
||||
public static CloseableStream<Path> list(Path dir) throws IOException {
|
||||
public static Stream<Path> list(Path dir) throws IOException {
|
||||
DirectoryStream<Path> ds = Files.newDirectoryStream(dir);
|
||||
final Iterator<Path> delegate = ds.iterator();
|
||||
try {
|
||||
final Iterator<Path> delegate = ds.iterator();
|
||||
|
||||
// Re-wrap DirectoryIteratorException to UncheckedIOException
|
||||
Iterator<Path> it = new Iterator<Path>() {
|
||||
public boolean hasNext() {
|
||||
try {
|
||||
return delegate.hasNext();
|
||||
} catch (DirectoryIteratorException e) {
|
||||
throw new UncheckedIOException(e.getCause());
|
||||
// Re-wrap DirectoryIteratorException to UncheckedIOException
|
||||
Iterator<Path> it = new Iterator<Path>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
try {
|
||||
return delegate.hasNext();
|
||||
} catch (DirectoryIteratorException e) {
|
||||
throw new UncheckedIOException(e.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
public Path next() {
|
||||
try {
|
||||
return delegate.next();
|
||||
} catch (DirectoryIteratorException e) {
|
||||
throw new UncheckedIOException(e.getCause());
|
||||
@Override
|
||||
public Path next() {
|
||||
try {
|
||||
return delegate.next();
|
||||
} catch (DirectoryIteratorException e) {
|
||||
throw new UncheckedIOException(e.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Stream<Path> s = StreamSupport.stream(
|
||||
Spliterators.spliteratorUnknownSize(it, Spliterator.DISTINCT),
|
||||
false);
|
||||
return new DelegatingCloseableStream<>(ds, s);
|
||||
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, Spliterator.DISTINCT), false)
|
||||
.onClose(asUncheckedRunnable(ds));
|
||||
} catch (Error|RuntimeException e) {
|
||||
try {
|
||||
ds.close();
|
||||
} catch (IOException ex) {
|
||||
try {
|
||||
e.addSuppressed(ex);
|
||||
} catch (Throwable ignore) {}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@code CloseableStream} that is lazily populated with {@code
|
||||
* Return a {@code Stream} that is lazily populated with {@code
|
||||
* Path} by walking the file tree rooted at a given starting file. The
|
||||
* file tree is traversed <em>depth-first</em>, the elements in the stream
|
||||
* are {@link Path} objects that are obtained as if by {@link
|
||||
* Path#resolve(Path) resolving} the relative path against {@code start}.
|
||||
*
|
||||
* <p> The {@code stream} walks the file tree as elements are consumed.
|
||||
* The {@code CloseableStream} returned is guaranteed to have at least one
|
||||
* The {@code Stream} returned is guaranteed to have at least one
|
||||
* element, the starting file itself. For each file visited, the stream
|
||||
* attempts to read its {@link BasicFileAttributes}. If the file is a
|
||||
* directory and can be opened successfully, entries in the directory, and
|
||||
|
@ -3370,10 +3399,11 @@ public final class Files {
|
|||
* <p> When a security manager is installed and it denies access to a file
|
||||
* (or directory), then it is ignored and not included in the stream.
|
||||
*
|
||||
* <p> When not using the try-with-resources construct, then the stream's
|
||||
* {@link CloseableStream#close close} method should be invoked after the
|
||||
* operation is completed so as to free any resources held for the open
|
||||
* directory. Operate the stream after it is closed will throw an
|
||||
* <p> The returned stream encapsulates one or more {@link DirectoryStream}s.
|
||||
* If timely disposal of file system resources is required, the
|
||||
* {@code try}-with-resources construct should be used to ensure that the
|
||||
* stream's {@link Stream#close close} method is invoked after the stream
|
||||
* operations are completed. Operating on a closed stream will result in an
|
||||
* {@link java.lang.IllegalStateException}.
|
||||
*
|
||||
* <p> If an {@link IOException} is thrown when accessing the directory
|
||||
|
@ -3388,7 +3418,7 @@ public final class Files {
|
|||
* @param options
|
||||
* options to configure the traversal
|
||||
*
|
||||
* @return the {@link CloseableStream} of {@link Path}
|
||||
* @return the {@link Stream} of {@link Path}
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the {@code maxDepth} parameter is negative
|
||||
|
@ -3401,21 +3431,22 @@ public final class Files {
|
|||
* if an I/O error is thrown when accessing the starting file.
|
||||
* @since 1.8
|
||||
*/
|
||||
public static CloseableStream<Path> walk(Path start, int maxDepth,
|
||||
FileVisitOption... options)
|
||||
throws IOException
|
||||
{
|
||||
public static Stream<Path> walk(Path start, int maxDepth,
|
||||
FileVisitOption... options)
|
||||
throws IOException {
|
||||
FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options);
|
||||
|
||||
Stream<Path> s = StreamSupport.stream(
|
||||
Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT),
|
||||
false).
|
||||
map(entry -> entry.file());
|
||||
return new DelegatingCloseableStream<>(iterator, s);
|
||||
try {
|
||||
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT), false)
|
||||
.onClose(iterator::close)
|
||||
.map(entry -> entry.file());
|
||||
} catch (Error|RuntimeException e) {
|
||||
iterator.close();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@code CloseableStream} that is lazily populated with {@code
|
||||
* Return a {@code Stream} that is lazily populated with {@code
|
||||
* Path} by walking the file tree rooted at a given starting file. The
|
||||
* file tree is traversed <em>depth-first</em>, the elements in the stream
|
||||
* are {@link Path} objects that are obtained as if by {@link
|
||||
|
@ -3428,12 +3459,19 @@ public final class Files {
|
|||
* </pre></blockquote>
|
||||
* In other words, it visits all levels of the file tree.
|
||||
*
|
||||
* <p> The returned stream encapsulates one or more {@link DirectoryStream}s.
|
||||
* If timely disposal of file system resources is required, the
|
||||
* {@code try}-with-resources construct should be used to ensure that the
|
||||
* stream's {@link Stream#close close} method is invoked after the stream
|
||||
* operations are completed. Operating on a closed stream will result in an
|
||||
* {@link java.lang.IllegalStateException}.
|
||||
*
|
||||
* @param start
|
||||
* the starting file
|
||||
* @param options
|
||||
* options to configure the traversal
|
||||
*
|
||||
* @return the {@link CloseableStream} of {@link Path}
|
||||
* @return the {@link Stream} of {@link Path}
|
||||
*
|
||||
* @throws SecurityException
|
||||
* If the security manager denies access to the starting file.
|
||||
|
@ -3446,15 +3484,14 @@ public final class Files {
|
|||
* @see #walk(Path, int, FileVisitOption...)
|
||||
* @since 1.8
|
||||
*/
|
||||
public static CloseableStream<Path> walk(Path start,
|
||||
FileVisitOption... options)
|
||||
throws IOException
|
||||
{
|
||||
public static Stream<Path> walk(Path start,
|
||||
FileVisitOption... options)
|
||||
throws IOException {
|
||||
return walk(start, Integer.MAX_VALUE, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@code CloseableStream} that is lazily populated with {@code
|
||||
* Return a {@code Stream} that is lazily populated with {@code
|
||||
* Path} by searching for files in a file tree rooted at a given starting
|
||||
* file.
|
||||
*
|
||||
|
@ -3463,12 +3500,19 @@ public final class Files {
|
|||
* {@link BiPredicate} is invoked with its {@link Path} and {@link
|
||||
* BasicFileAttributes}. The {@code Path} object is obtained as if by
|
||||
* {@link Path#resolve(Path) resolving} the relative path against {@code
|
||||
* start} and is only included in the returned {@link CloseableStream} if
|
||||
* start} and is only included in the returned {@link Stream} if
|
||||
* the {@code BiPredicate} returns true. Compare to calling {@link
|
||||
* java.util.stream.Stream#filter filter} on the {@code Stream}
|
||||
* returned by {@code walk} method, this method may be more efficient by
|
||||
* avoiding redundant retrieval of the {@code BasicFileAttributes}.
|
||||
*
|
||||
* <p> The returned stream encapsulates one or more {@link DirectoryStream}s.
|
||||
* If timely disposal of file system resources is required, the
|
||||
* {@code try}-with-resources construct should be used to ensure that the
|
||||
* stream's {@link Stream#close close} method is invoked after the stream
|
||||
* operations are completed. Operating on a closed stream will result in an
|
||||
* {@link java.lang.IllegalStateException}.
|
||||
*
|
||||
* <p> If an {@link IOException} is thrown when accessing the directory
|
||||
* after returned from this method, it is wrapped in an {@link
|
||||
* UncheckedIOException} which will be thrown from the method that caused
|
||||
|
@ -3484,7 +3528,7 @@ public final class Files {
|
|||
* @param options
|
||||
* options to configure the traversal
|
||||
*
|
||||
* @return the {@link CloseableStream} of {@link Path}
|
||||
* @return the {@link Stream} of {@link Path}
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the {@code maxDepth} parameter is negative
|
||||
|
@ -3499,24 +3543,25 @@ public final class Files {
|
|||
* @see #walk(Path, int, FileVisitOption...)
|
||||
* @since 1.8
|
||||
*/
|
||||
public static CloseableStream<Path> find(Path start,
|
||||
int maxDepth,
|
||||
BiPredicate<Path, BasicFileAttributes> matcher,
|
||||
FileVisitOption... options)
|
||||
throws IOException
|
||||
{
|
||||
public static Stream<Path> find(Path start,
|
||||
int maxDepth,
|
||||
BiPredicate<Path, BasicFileAttributes> matcher,
|
||||
FileVisitOption... options)
|
||||
throws IOException {
|
||||
FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options);
|
||||
|
||||
Stream<Path> s = StreamSupport.stream(
|
||||
Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT),
|
||||
false).
|
||||
filter(entry -> matcher.test(entry.file(), entry.attributes())).
|
||||
map(entry -> entry.file());
|
||||
return new DelegatingCloseableStream<>(iterator, s);
|
||||
try {
|
||||
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT), false)
|
||||
.onClose(iterator::close)
|
||||
.filter(entry -> matcher.test(entry.file(), entry.attributes()))
|
||||
.map(entry -> entry.file());
|
||||
} catch (Error|RuntimeException e) {
|
||||
iterator.close();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all lines from a file as a {@code CloseableStream}. Unlike {@link
|
||||
* Read all lines from a file as a {@code Stream}. Unlike {@link
|
||||
* #readAllLines(Path, Charset) readAllLines}, this method does not read
|
||||
* all lines into a {@code List}, but instead populates lazily as the stream
|
||||
* is consumed.
|
||||
|
@ -3528,22 +3573,24 @@ public final class Files {
|
|||
* <p> After this method returns, then any subsequent I/O exception that
|
||||
* occurs while reading from the file or when a malformed or unmappable byte
|
||||
* sequence is read, is wrapped in an {@link UncheckedIOException} that will
|
||||
* be thrown form the
|
||||
* be thrown from the
|
||||
* {@link java.util.stream.Stream} method that caused the read to take
|
||||
* place. In case an {@code IOException} is thrown when closing the file,
|
||||
* it is also wrapped as an {@code UncheckedIOException}.
|
||||
*
|
||||
* <p> When not using the try-with-resources construct, then stream's
|
||||
* {@link CloseableStream#close close} method should be invoked after
|
||||
* operation is completed so as to free any resources held for the open
|
||||
* file.
|
||||
* <p> The returned stream encapsulates a {@link Reader}. If timely
|
||||
* disposal of file system resources is required, the try-with-resources
|
||||
* construct should be used to ensure that the stream's
|
||||
* {@link Stream#close close} method is invoked after the stream operations
|
||||
* are completed.
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
* the path to the file
|
||||
* @param cs
|
||||
* the charset to use for decoding
|
||||
*
|
||||
* @return the lines from the file as a {@code CloseableStream}
|
||||
* @return the lines from the file as a {@code Stream}
|
||||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs opening the file
|
||||
|
@ -3557,10 +3604,19 @@ public final class Files {
|
|||
* @see java.io.BufferedReader#lines()
|
||||
* @since 1.8
|
||||
*/
|
||||
public static CloseableStream<String> lines(Path path, Charset cs)
|
||||
throws IOException
|
||||
{
|
||||
public static Stream<String> lines(Path path, Charset cs) throws IOException {
|
||||
BufferedReader br = Files.newBufferedReader(path, cs);
|
||||
return new DelegatingCloseableStream<>(br, br.lines());
|
||||
try {
|
||||
return br.lines().onClose(asUncheckedRunnable(br));
|
||||
} catch (Error|RuntimeException e) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
try {
|
||||
e.addSuppressed(ex);
|
||||
} catch (Throwable ignore) {}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -93,6 +93,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* @exception RemoteException if either of the following fails:
|
||||
* a) registering the object with the activation system or b) exporting
|
||||
* the object to the RMI runtime.
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation.
|
||||
* @since 1.2
|
||||
**/
|
||||
protected Activatable(String location,
|
||||
|
@ -143,6 +145,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* @exception RemoteException if either of the following fails:
|
||||
* a) registering the object with the activation system or b) exporting
|
||||
* the object to the RMI runtime.
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation.
|
||||
* @since 1.2
|
||||
**/
|
||||
protected Activatable(String location,
|
||||
|
@ -175,6 +179,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* @param port the port number on which the object is exported
|
||||
* @exception RemoteException if exporting the object to the RMI
|
||||
* runtime fails
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
protected Activatable(ActivationID id, int port)
|
||||
|
@ -206,6 +212,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* @param ssf the server-side socket factory for receiving remote calls
|
||||
* @exception RemoteException if exporting the object to the RMI
|
||||
* runtime fails
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
protected Activatable(ActivationID id, int port,
|
||||
|
@ -239,6 +247,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* is not registered with the activation system
|
||||
* @exception ActivationException if activation system is not running
|
||||
* @exception RemoteException if remote call fails
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public static Remote register(ActivationDesc desc)
|
||||
|
@ -273,6 +283,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* already be inactive)
|
||||
* @exception ActivationException if group is not active
|
||||
* @exception RemoteException if call informing monitor fails
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public static boolean inactive(ActivationID id)
|
||||
|
@ -290,6 +302,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* @exception UnknownObjectException if object (<code>id</code>) is unknown
|
||||
* @exception ActivationException if activation system is not running
|
||||
* @exception RemoteException if remote call to activation system fails
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public static void unregister(ActivationID id)
|
||||
|
@ -334,6 +348,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* the wrong group
|
||||
* @exception ActivationException if activation group is not active
|
||||
* @exception RemoteException if object registration or export fails
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
**/
|
||||
public static ActivationID exportObject(Remote obj,
|
||||
|
@ -407,6 +423,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* descriptor with the activation system
|
||||
* @exception ActivationException if activation group is not active
|
||||
* @exception RemoteException if object registration or export fails
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
**/
|
||||
public static ActivationID exportObject(Remote obj,
|
||||
|
@ -473,6 +491,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* @param port the port on which the object is exported (an anonymous
|
||||
* port is used if port=0)
|
||||
* @exception RemoteException if object export fails
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public static Remote exportObject(Remote obj,
|
||||
|
@ -503,6 +523,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* remote object
|
||||
* @param ssf the server-side socket factory for receiving remote calls
|
||||
* @exception RemoteException if object export fails
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public static Remote exportObject(Remote obj,
|
||||
|
@ -531,6 +553,8 @@ public abstract class Activatable extends RemoteServer {
|
|||
* @return true if operation is successful, false otherwise
|
||||
* @exception NoSuchObjectException if the remote object is not
|
||||
* currently exported
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public static boolean unexportObject(Remote obj, boolean force)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -105,6 +105,8 @@ public final class ActivationDesc implements Serializable {
|
|||
* @param data the object's initialization (activation) data contained
|
||||
* in marshalled form.
|
||||
* @exception ActivationException if the current group is nonexistent
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public ActivationDesc(String className,
|
||||
|
@ -142,6 +144,8 @@ public final class ActivationDesc implements Serializable {
|
|||
* <code>true</code> does not force an initial immediate activation of
|
||||
* a newly registered object; initial activation is lazy.
|
||||
* @exception ActivationException if the current group is nonexistent
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public ActivationDesc(String className,
|
||||
|
@ -176,6 +180,8 @@ public final class ActivationDesc implements Serializable {
|
|||
* @param data the object's initialization (activation) data contained
|
||||
* in marshalled form.
|
||||
* @exception IllegalArgumentException if <code>groupID</code> is null
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public ActivationDesc(ActivationGroupID groupID,
|
||||
|
@ -208,6 +214,8 @@ public final class ActivationDesc implements Serializable {
|
|||
* <code>true</code> does not force an initial immediate activation of
|
||||
* a newly registered object; initial activation is lazy.
|
||||
* @exception IllegalArgumentException if <code>groupID</code> is null
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public ActivationDesc(ActivationGroupID groupID,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -133,6 +133,8 @@ public abstract class ActivationGroup
|
|||
*
|
||||
* @param groupID the group's identifier
|
||||
* @throws RemoteException if this group could not be exported
|
||||
* @throws UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
protected ActivationGroup(ActivationGroupID groupID)
|
||||
|
@ -267,6 +269,8 @@ public abstract class ActivationGroup
|
|||
* (Note: The default implementation of the security manager
|
||||
* <code>checkSetFactory</code>
|
||||
* method requires the RuntimePermission "setFactory")
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @see SecurityManager#checkSetFactory
|
||||
* @since 1.2
|
||||
*/
|
||||
|
@ -345,6 +349,8 @@ public abstract class ActivationGroup
|
|||
/**
|
||||
* Returns the current activation group's identifier. Returns null
|
||||
* if no group is currently active for this VM.
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @return the activation group's identifier
|
||||
* @since 1.2
|
||||
*/
|
||||
|
@ -394,6 +400,8 @@ public abstract class ActivationGroup
|
|||
* (Note: The default implementation of the security manager
|
||||
* <code>checkSetFactory</code>
|
||||
* method requires the RuntimePermission "setFactory")
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @see #getSystem
|
||||
* @see SecurityManager#checkSetFactory
|
||||
* @since 1.2
|
||||
|
@ -428,6 +436,8 @@ public abstract class ActivationGroup
|
|||
* @exception ActivationException if activation system cannot be
|
||||
* obtained or is not bound
|
||||
* (means that it is not running)
|
||||
* @exception UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @see #setSystem
|
||||
* @since 1.2
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -63,6 +63,8 @@ public class ActivationGroupID implements java.io.Serializable {
|
|||
* Constructs a unique group id.
|
||||
*
|
||||
* @param system the group's activation system
|
||||
* @throws UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public ActivationGroupID(ActivationSystem system) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -90,6 +90,8 @@ public class ActivationID implements Serializable {
|
|||
*
|
||||
* @param activator reference to the activator responsible for
|
||||
* activating the object
|
||||
* @throws UnsupportedOperationException if and only if activation is
|
||||
* not supported by this implementation
|
||||
* @since 1.2
|
||||
*/
|
||||
public ActivationID(Activator activator) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!--
|
||||
Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
|
||||
This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -31,6 +31,15 @@ Provides support for RMI Object Activation. A remote
|
|||
object's reference can be made ``persistent'' and later activated into a
|
||||
``live'' object using the RMI activation mechanism.
|
||||
|
||||
<p>Implementations are not required to support the activation
|
||||
mechanism. If activation is not supported by this implementation,
|
||||
several specific activation API methods are all required to throw
|
||||
{@code UnsupportedOperationException}. If activation is supported by this
|
||||
implementation, these methods must never throw {@code
|
||||
UnsupportedOperationException}. These methods are denoted by the
|
||||
presence of an entry for {@code UnsupportedOperationException} in the
|
||||
<strong>Throws</strong> section of each method's specification.
|
||||
|
||||
<!--
|
||||
<h2>Package Specification</h2>
|
||||
|
||||
|
|
|
@ -279,6 +279,9 @@ public final class AccessController {
|
|||
* <p> Note that any DomainCombiner associated with the current
|
||||
* AccessControlContext will be ignored while the action is performed.
|
||||
*
|
||||
* @param <T> the type of the value returned by the PrivilegedAction's
|
||||
* {@code run} method.
|
||||
*
|
||||
* @param action the action to be performed.
|
||||
*
|
||||
* @return the value returned by the action's {@code run} method.
|
||||
|
@ -305,6 +308,9 @@ public final class AccessController {
|
|||
* <p> This method preserves the current AccessControlContext's
|
||||
* DomainCombiner (which may be null) while the action is performed.
|
||||
*
|
||||
* @param <T> the type of the value returned by the PrivilegedAction's
|
||||
* {@code run} method.
|
||||
*
|
||||
* @param action the action to be performed.
|
||||
*
|
||||
* @return the value returned by the action's {@code run} method.
|
||||
|
@ -344,6 +350,8 @@ public final class AccessController {
|
|||
* {@link java.security.SecurityPermission}, then the action is performed
|
||||
* with no permissions.
|
||||
*
|
||||
* @param <T> the type of the value returned by the PrivilegedAction's
|
||||
* {@code run} method.
|
||||
* @param action the action to be performed.
|
||||
* @param context an <i>access control context</i>
|
||||
* representing the restriction to be applied to the
|
||||
|
@ -377,6 +385,8 @@ public final class AccessController {
|
|||
* If the action's {@code run} method throws an (unchecked) exception,
|
||||
* it will propagate through this method.
|
||||
*
|
||||
* @param <T> the type of the value returned by the PrivilegedAction's
|
||||
* {@code run} method.
|
||||
* @param action the action to be performed.
|
||||
* @param context an <i>access control context</i>
|
||||
* representing the restriction to be applied to the
|
||||
|
@ -429,6 +439,8 @@ public final class AccessController {
|
|||
* <p> This method preserves the current AccessControlContext's
|
||||
* DomainCombiner (which may be null) while the action is performed.
|
||||
*
|
||||
* @param <T> the type of the value returned by the PrivilegedAction's
|
||||
* {@code run} method.
|
||||
* @param action the action to be performed.
|
||||
* @param context an <i>access control context</i>
|
||||
* representing the restriction to be applied to the
|
||||
|
@ -479,6 +491,9 @@ public final class AccessController {
|
|||
* <p> Note that any DomainCombiner associated with the current
|
||||
* AccessControlContext will be ignored while the action is performed.
|
||||
*
|
||||
* @param <T> the type of the value returned by the
|
||||
* PrivilegedExceptionAction's {@code run} method.
|
||||
*
|
||||
* @param action the action to be performed
|
||||
*
|
||||
* @return the value returned by the action's {@code run} method
|
||||
|
@ -509,6 +524,9 @@ public final class AccessController {
|
|||
* <p> This method preserves the current AccessControlContext's
|
||||
* DomainCombiner (which may be null) while the action is performed.
|
||||
*
|
||||
* @param <T> the type of the value returned by the
|
||||
* PrivilegedExceptionAction's {@code run} method.
|
||||
*
|
||||
* @param action the action to be performed.
|
||||
*
|
||||
* @return the value returned by the action's {@code run} method
|
||||
|
@ -585,6 +603,8 @@ public final class AccessController {
|
|||
* {@link java.security.SecurityPermission}, then the action is performed
|
||||
* with no permissions.
|
||||
*
|
||||
* @param <T> the type of the value returned by the
|
||||
* PrivilegedExceptionAction's {@code run} method.
|
||||
* @param action the action to be performed
|
||||
* @param context an <i>access control context</i>
|
||||
* representing the restriction to be applied to the
|
||||
|
@ -622,6 +642,8 @@ public final class AccessController {
|
|||
* If the action's {@code run} method throws an (unchecked) exception,
|
||||
* it will propagate through this method.
|
||||
*
|
||||
* @param <T> the type of the value returned by the
|
||||
* PrivilegedExceptionAction's {@code run} method.
|
||||
* @param action the action to be performed.
|
||||
* @param context an <i>access control context</i>
|
||||
* representing the restriction to be applied to the
|
||||
|
@ -676,6 +698,8 @@ public final class AccessController {
|
|||
* <p> This method preserves the current AccessControlContext's
|
||||
* DomainCombiner (which may be null) while the action is performed.
|
||||
*
|
||||
* @param <T> the type of the value returned by the
|
||||
* PrivilegedExceptionAction's {@code run} method.
|
||||
* @param action the action to be performed.
|
||||
* @param context an <i>access control context</i>
|
||||
* representing the restriction to be applied to the
|
||||
|
|
|
@ -324,6 +324,7 @@ public class AlgorithmParameters {
|
|||
* parameters should be returned in an instance of the
|
||||
* {@code DSAParameterSpec} class.
|
||||
*
|
||||
* @param <T> the type of the parameter specification to be returrned
|
||||
* @param paramSpec the specification class in which
|
||||
* the parameters should be returned.
|
||||
*
|
||||
|
|
|
@ -102,6 +102,8 @@ public abstract class AlgorithmParametersSpi {
|
|||
* parameters should be returned in an instance of the
|
||||
* {@code DSAParameterSpec} class.
|
||||
*
|
||||
* @param <T> the type of the parameter specification to be returned
|
||||
*
|
||||
* @param paramSpec the specification class in which
|
||||
* the parameters should be returned.
|
||||
*
|
||||
|
|
|
@ -395,6 +395,8 @@ public class KeyFactory {
|
|||
* key material should be returned in an instance of the
|
||||
* {@code DSAPublicKeySpec} class.
|
||||
*
|
||||
* @param <T> the type of the key specification to be returned
|
||||
*
|
||||
* @param key the key.
|
||||
*
|
||||
* @param keySpec the specification class in which
|
||||
|
|
|
@ -106,6 +106,8 @@ public abstract class KeyFactorySpi {
|
|||
* key material should be returned in an instance of the
|
||||
* {@code DSAPublicKeySpec} class.
|
||||
*
|
||||
* @param <T> the type of the key specification to be returned
|
||||
*
|
||||
* @param key the key.
|
||||
*
|
||||
* @param keySpec the specification class in which
|
||||
|
|
|
@ -1753,6 +1753,7 @@ public class KeyStore {
|
|||
/**
|
||||
* Returns the KeyStore described by this object.
|
||||
*
|
||||
* @return the {@code KeyStore} described by this object
|
||||
* @exception KeyStoreException if an error occured during the
|
||||
* operation, for example if the KeyStore could not be
|
||||
* instantiated or loaded
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -81,6 +81,7 @@ public interface Principal {
|
|||
* <p>Subclasses may override this with a different implementation, if
|
||||
* necessary.
|
||||
*
|
||||
* @param subject the {@code Subject}
|
||||
* @return true if {@code subject} is non-null and is
|
||||
* implied by this principal, or false otherwise.
|
||||
* @since 1.8
|
||||
|
|
|
@ -87,6 +87,8 @@ public abstract class CertPathBuilderSpi {
|
|||
* service providers, this method cannot be abstract and by default throws
|
||||
* an {@code UnsupportedOperationException}.
|
||||
*
|
||||
* @return a {@code CertPathChecker} that this implementation uses to
|
||||
* check the revocation status of certificates
|
||||
* @throws UnsupportedOperationException if this method is not supported
|
||||
* @since 1.8
|
||||
*/
|
||||
|
|
|
@ -97,6 +97,8 @@ public abstract class CertPathValidatorSpi {
|
|||
* service providers, this method cannot be abstract and by default throws
|
||||
* an {@code UnsupportedOperationException}.
|
||||
*
|
||||
* @return a {@code CertPathChecker} that this implementation uses to
|
||||
* check the revocation status of certificates
|
||||
* @throws UnsupportedOperationException if this method is not supported
|
||||
* @since 1.8
|
||||
*/
|
||||
|
|
|
@ -103,6 +103,9 @@ public abstract class PKIXRevocationChecker extends PKIXCertPathChecker {
|
|||
private Map<X509Certificate, byte[]> ocspResponses = Collections.emptyMap();
|
||||
private Set<Option> options = Collections.emptySet();
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
protected PKIXRevocationChecker() {}
|
||||
|
||||
/**
|
||||
|
@ -300,8 +303,7 @@ public abstract class PKIXRevocationChecker extends PKIXCertPathChecker {
|
|||
* <li>The CRL or OCSP response cannot be obtained because of a
|
||||
* network error.
|
||||
* <li>The OCSP responder returns one of the following errors
|
||||
* specified in section 2.3 of RFC 2560: internalError, tryLater,
|
||||
* or unauthorized.
|
||||
* specified in section 2.3 of RFC 2560: internalError or tryLater.
|
||||
* </ul><br>
|
||||
* Note that these conditions apply to both OCSP and CRLs, and unless
|
||||
* the {@code NO_FALLBACK} option is set, the revocation check is
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -46,6 +46,11 @@ import java.security.spec.RSAOtherPrimeInfo;
|
|||
|
||||
public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey {
|
||||
|
||||
/**
|
||||
* The type fingerprint that is set to indicate
|
||||
* serialization compatibility with a previous
|
||||
* version of the type.
|
||||
*/
|
||||
static final long serialVersionUID = 618058533534628008L;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -39,6 +39,11 @@ import java.math.BigInteger;
|
|||
|
||||
public interface RSAPrivateCrtKey extends RSAPrivateKey {
|
||||
|
||||
/**
|
||||
* The type fingerprint that is set to indicate
|
||||
* serialization compatibility with a previous
|
||||
* version of the type.
|
||||
*/
|
||||
static final long serialVersionUID = -5682214253527700368L;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -39,6 +39,11 @@ import java.math.BigInteger;
|
|||
public interface RSAPrivateKey extends java.security.PrivateKey, RSAKey
|
||||
{
|
||||
|
||||
/**
|
||||
* The type fingerprint that is set to indicate
|
||||
* serialization compatibility with a previous
|
||||
* version of the type.
|
||||
*/
|
||||
static final long serialVersionUID = 5187144804936595022L;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -36,6 +36,11 @@ import java.math.BigInteger;
|
|||
|
||||
public interface RSAPublicKey extends java.security.PublicKey, RSAKey
|
||||
{
|
||||
/**
|
||||
* The type fingerprint that is set to indicate
|
||||
* serialization compatibility with a previous
|
||||
* version of the type.
|
||||
*/
|
||||
static final long serialVersionUID = -8727434096241101194L;
|
||||
|
||||
/**
|
||||
|
|
|
@ -326,6 +326,7 @@ public class DriverManager {
|
|||
* @param driver the new JDBC Driver that is to be registered with the
|
||||
* {@code DriverManager}
|
||||
* @exception SQLException if a database access error occurs
|
||||
* @exception NullPointerException if {@code driver} is null
|
||||
*/
|
||||
public static synchronized void registerDriver(java.sql.Driver driver)
|
||||
throws SQLException {
|
||||
|
@ -345,6 +346,7 @@ public class DriverManager {
|
|||
* @param da the {@code DriverAction} implementation to be used when
|
||||
* {@code DriverManager#deregisterDriver} is called
|
||||
* @exception SQLException if a database access error occurs
|
||||
* @exception NullPointerException if {@code driver} is null
|
||||
*/
|
||||
public static synchronized void registerDriver(java.sql.Driver driver,
|
||||
DriverAction da)
|
||||
|
|
|
@ -954,7 +954,6 @@ public interface PreparedStatement extends Statement {
|
|||
* the JDBC driver does not support this data type
|
||||
* @see Types
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength)
|
||||
throws SQLException;
|
||||
|
|
|
@ -74,7 +74,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
@ -1299,8 +1299,9 @@ public final class Duration
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(1); // identifies this as a Duration
|
||||
* out.writeByte(1); // identifies a Duration
|
||||
* out.writeLong(seconds);
|
||||
* out.writeInt(nanos);
|
||||
* </pre>
|
||||
|
@ -1316,7 +1317,7 @@ public final class Duration
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
@ -1317,8 +1317,9 @@ public final class Instant
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(2); // identifies this as an Instant
|
||||
* out.writeByte(2); // identifies an Instant
|
||||
* out.writeLong(seconds);
|
||||
* out.writeInt(nanos);
|
||||
* </pre>
|
||||
|
@ -1334,7 +1335,7 @@ public final class Instant
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.chrono.ChronoLocalDate;
|
||||
import java.time.chrono.Era;
|
||||
|
@ -2019,8 +2019,9 @@ public final class LocalDate
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(3); // identifies this as a LocalDate
|
||||
* out.writeByte(3); // identifies a LocalDate
|
||||
* out.writeInt(year);
|
||||
* out.writeByte(month);
|
||||
* out.writeByte(day);
|
||||
|
@ -2037,7 +2038,7 @@ public final class LocalDate
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.chrono.ChronoLocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -1953,8 +1953,9 @@ public final class LocalDateTime
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(5); // identifies this as a LocalDateTime
|
||||
* out.writeByte(5); // identifies a LocalDateTime
|
||||
* // the <a href="../../serialized-form.html#java.time.LocalDate">date</a> excluding the one byte header
|
||||
* // the <a href="../../serialized-form.html#java.time.LocalTime">time</a> excluding the one byte header
|
||||
* </pre>
|
||||
|
@ -1970,7 +1971,7 @@ public final class LocalDateTime
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
@ -1595,8 +1595,11 @@ public final class LocalTime
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* A twos-complement value indicates the remaining values are not in the stream
|
||||
* and should be set to zero.
|
||||
* <pre>
|
||||
* out.writeByte(4); // identifies this as a LocalTime
|
||||
* out.writeByte(4); // identifies a LocalTime
|
||||
* if (nano == 0) {
|
||||
* if (second == 0) {
|
||||
* if (minute == 0) {
|
||||
|
@ -1629,7 +1632,7 @@ public final class LocalTime
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.chrono.Chronology;
|
||||
import java.time.chrono.IsoChronology;
|
||||
|
@ -744,9 +744,10 @@ public final class MonthDay
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../../serialized-form.html#java.time.temporal.Ser">dedicated serialized form</a>.
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(13); // identifies this as a MonthDay
|
||||
* out.writeByte(13); // identifies a MonthDay
|
||||
* out.writeByte(month);
|
||||
* out.writeByte(day);
|
||||
* </pre>
|
||||
|
@ -762,7 +763,7 @@ public final class MonthDay
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ import java.io.IOException;
|
|||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.chrono.IsoChronology;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -1901,9 +1901,10 @@ public final class OffsetDateTime
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../../serialized-form.html#java.time.temporal.Ser">dedicated serialized form</a>.
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(10); // identifies this as a OffsetDateTime
|
||||
* out.writeByte(10); // identifies a OffsetDateTime
|
||||
* out.writeObject(dateTime);
|
||||
* out.writeObject(offset);
|
||||
* </pre>
|
||||
|
@ -1919,7 +1920,7 @@ public final class OffsetDateTime
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ import java.io.IOException;
|
|||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
@ -1372,9 +1372,10 @@ public final class OffsetTime
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../../serialized-form.html#java.time.temporal.Ser">dedicated serialized form</a>.
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(9); // identifies this as a OffsetTime
|
||||
* out.writeByte(9); // identifies a OffsetTime
|
||||
* out.writeObject(time);
|
||||
* out.writeObject(offset);
|
||||
* </pre>
|
||||
|
@ -1390,7 +1391,7 @@ public final class OffsetTime
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.chrono.ChronoLocalDate;
|
||||
import java.time.chrono.Chronology;
|
||||
|
@ -993,11 +993,12 @@ public final class Period
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(14); // identifies this as a Period
|
||||
* out.writeByte(14); // identifies a Period
|
||||
* out.writeInt(years);
|
||||
* out.writeInt(months);
|
||||
* out.writeInt(seconds);
|
||||
* out.writeInt(days);
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
|
@ -1011,7 +1012,7 @@ public final class Period
|
|||
* @return never
|
||||
* @throws java.io.InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -72,14 +72,14 @@ import java.io.StreamCorruptedException;
|
|||
* byte flag would be used in order to specify an alternative version of the type format.
|
||||
* For example {@code LOCAL_DATE_TYPE_VERSION_2 = 21}.
|
||||
* <p>
|
||||
* In order to serialise the object it writes its byte and then calls back to the appropriate class where
|
||||
* the serialisation is performed. In order to deserialise the object it read in the type byte, switching
|
||||
* In order to serialize the object it writes its byte and then calls back to the appropriate class where
|
||||
* the serialization is performed. In order to deserialize the object it read in the type byte, switching
|
||||
* in order to select which class to call back into.
|
||||
* <p>
|
||||
* The serialisation format is determined on a per class basis. In the case of field based classes each
|
||||
* The serialization format is determined on a per class basis. In the case of field based classes each
|
||||
* of the fields is written out with an appropriate size format in descending order of the field's size. For
|
||||
* example in the case of {@link LocalDate} year is written before month. Composite classes, such as
|
||||
* {@link LocalDateTime} are serialised as one object.
|
||||
* {@link LocalDateTime} are serialized as one object.
|
||||
* <p>
|
||||
* This class is mutable and should be created once per serialization.
|
||||
*
|
||||
|
@ -133,6 +133,27 @@ final class Ser implements Externalizable {
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Implements the {@code Externalizable} interface to write the object.
|
||||
* @serialData
|
||||
*
|
||||
* Each serializable class is mapped to a type that is the first byte
|
||||
* in the stream. Refer to each class {@code writeReplace}
|
||||
* serialized form for the value of the type and sequence of values for the type.
|
||||
* <ul>
|
||||
* <li><a href="../../serialized-form.html#java.time.Duration">Duration.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.Instant">Instant.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.LocalDate">LocalDate.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.LocalDateTime">LocalDateTime.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.LocalTime">LocalTime.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.MonthDay">MonthDay.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.OffsetTime">OffsetTime.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.OffsetDateTime">OffsetDateTime.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.Period">Period.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.Year">Year.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.YearMonth">YearMonth.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.ZoneId">ZoneId.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.ZoneOffset">ZoneOffset.writeReplace</a>
|
||||
* <li><a href="../../serialized-form.html#java.time.ZonedDateTime">ZonedDateTime.writeReplace</a>
|
||||
* </ul>
|
||||
*
|
||||
* @param out the data stream to write to, not null
|
||||
*/
|
||||
|
@ -194,6 +215,29 @@ final class Ser implements Externalizable {
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Implements the {@code Externalizable} interface to read the object.
|
||||
* @serialData
|
||||
*
|
||||
* The streamed type and parameters defined by the type's {@code writeReplace}
|
||||
* method are read and passed to the corresponding static factory for the type
|
||||
* to create a new instance. That instance is returned as the de-serialized
|
||||
* {@code Ser} object.
|
||||
*
|
||||
* <ul>
|
||||
* <li><a href="../../serialized-form.html#java.time.Duration">Duration</a> - {@code Duration.ofSeconds(seconds, nanos);}
|
||||
* <li><a href="../../serialized-form.html#java.time.Instant">Instant</a> - {@code Instant.ofEpochSecond(seconds, nanos);}
|
||||
* <li><a href="../../serialized-form.html#java.time.LocalDate">LocalDate</a> - {@code LocalDate.of(year, month, day);}
|
||||
* <li><a href="../../serialized-form.html#java.time.LocalDateTime">LocalDateTime</a> - {@code LocalDateTime.of(date, time);}
|
||||
* <li><a href="../../serialized-form.html#java.time.LocalTime">LocalTime</a> - {@code LocalTime.of(hour, minute, second, nano);}
|
||||
* <li><a href="../../serialized-form.html#java.time.MonthDay">MonthDay</a> - {@code MonthDay.of(month, day);}
|
||||
* <li><a href="../../serialized-form.html#java.time.OffsetTime">OffsetTime</a> - {@code OffsetTime.of(time, offset);}
|
||||
* <li><a href="../../serialized-form.html#java.time.OffsetDateTime">OffsetDateTime</a> - {@code OffsetDateTime.of(dateTime, offset);}
|
||||
* <li><a href="../../serialized-form.html#java.time.Period">Period</a> - {@code Period.of(years, months, days);}
|
||||
* <li><a href="../../serialized-form.html#java.time.Year">Year</a> - {@code Year.of(year);}
|
||||
* <li><a href="../../serialized-form.html#java.time.YearMonth">YearMonth</a> - {@code YearMonth.of(year, month);}
|
||||
* <li><a href="../../serialized-form.html#java.time.ZonedDateTime">ZonedDateTime</a> - {@code ZonedDateTime.ofLenient(dateTime, offset, zone);}
|
||||
* <li><a href="../../serialized-form.html#java.time.ZoneId">ZoneId</a> - {@code ZoneId.of(id);}
|
||||
* <li><a href="../../serialized-form.html#java.time.ZoneOffset">ZoneOffset</a> - {@code (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900));}
|
||||
* </ul>
|
||||
*
|
||||
* @param in the data to read, not null
|
||||
*/
|
||||
|
|
|
@ -74,7 +74,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.chrono.Chronology;
|
||||
import java.time.chrono.IsoChronology;
|
||||
|
@ -1080,9 +1080,10 @@ public final class Year
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../../serialized-form.html#java.time.temporal.Ser">dedicated serialized form</a>.
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(11); // identifies this as a Year
|
||||
* out.writeByte(11); // identifies a Year
|
||||
* out.writeInt(year);
|
||||
* </pre>
|
||||
*
|
||||
|
@ -1097,7 +1098,7 @@ public final class Year
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.chrono.Chronology;
|
||||
import java.time.chrono.IsoChronology;
|
||||
|
@ -1205,9 +1205,10 @@ public final class YearMonth
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../../serialized-form.html#java.time.temporal.Ser">dedicated serialized form</a>.
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(12); // identifies this as a YearMonth
|
||||
* out.writeByte(12); // identifies a YearMonth
|
||||
* out.writeInt(year);
|
||||
* out.writeByte(month);
|
||||
* </pre>
|
||||
|
@ -1223,7 +1224,7 @@ public final class YearMonth
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ package java.time;
|
|||
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.format.DateTimeFormatterBuilder;
|
||||
import java.time.format.TextStyle;
|
||||
|
@ -661,6 +662,15 @@ public abstract class ZoneId implements Serializable {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Defend against malicious streams.
|
||||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs this zone as a {@code String}, using the ID.
|
||||
*
|
||||
|
@ -675,9 +685,10 @@ public abstract class ZoneId implements Serializable {
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(7); // identifies this as a ZoneId (not ZoneOffset)
|
||||
* out.writeUTF(zoneId);
|
||||
* out.writeByte(7); // identifies a ZoneId (not ZoneOffset)
|
||||
* out.writeUTF(getId());
|
||||
* </pre>
|
||||
* <p>
|
||||
* When read back in, the {@code ZoneId} will be created as though using
|
||||
|
|
|
@ -70,7 +70,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.temporal.ChronoField;
|
||||
import java.time.temporal.Temporal;
|
||||
|
@ -740,12 +740,13 @@ public final class ZoneOffset
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(8); // identifies this as a ZoneOffset
|
||||
* out.writeByte(8); // identifies a ZoneOffset
|
||||
* int offsetByte = totalSeconds % 900 == 0 ? totalSeconds / 900 : 127;
|
||||
* out.writeByte(offsetByte);
|
||||
* if (offsetByte == 127) {
|
||||
* out.writeInt(totalSeconds);
|
||||
* out.writeInt(totalSeconds);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
|
@ -760,7 +761,7 @@ public final class ZoneOffset
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.zone.ZoneRules;
|
||||
import java.time.zone.ZoneRulesException;
|
||||
|
@ -181,8 +181,9 @@ final class ZoneRegion extends ZoneId implements Serializable {
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(7); // identifies this as a ZoneId (not ZoneOffset)
|
||||
* out.writeByte(7); // identifies a ZoneId (not ZoneOffset)
|
||||
* out.writeUTF(zoneId);
|
||||
* </pre>
|
||||
*
|
||||
|
@ -197,7 +198,7 @@ final class ZoneRegion extends ZoneId implements Serializable {
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ import java.io.DataOutput;
|
|||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.chrono.ChronoZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -2192,9 +2192,10 @@ public final class ZonedDateTime
|
|||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../serialized-form.html#java.time.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(6); // identifies this as a ZonedDateTime
|
||||
* // the <a href="../../serialized-form.html#java.time.LocalDateTime">date-time</a> excluding the one byte header
|
||||
* out.writeByte(6); // identifies a ZonedDateTime
|
||||
* // the <a href="../../serialized-form.html#java.time.LocalDateTime">dateTime</a> excluding the one byte header
|
||||
* // the <a href="../../serialized-form.html#java.time.ZoneOffset">offset</a> excluding the one byte header
|
||||
* // the <a href="../../serialized-form.html#java.time.ZoneId">zone ID</a> excluding the one byte header
|
||||
* </pre>
|
||||
|
@ -2210,7 +2211,7 @@ public final class ZonedDateTime
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ import java.util.Objects;
|
|||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @serial
|
||||
* @param <D> the concrete type for the date of this date-time
|
||||
* @since 1.8
|
||||
*/
|
||||
|
@ -157,11 +157,11 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
|
|||
/**
|
||||
* The date part.
|
||||
*/
|
||||
private final D date;
|
||||
private final transient D date;
|
||||
/**
|
||||
* The time part.
|
||||
*/
|
||||
private final LocalTime time;
|
||||
private final transient LocalTime time;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -402,6 +402,18 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the ChronoLocalDateTime using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(2); // identifies a ChronoLocalDateTime
|
||||
* out.writeObject(toLocalDate());
|
||||
* out.witeObject(toLocalTime());
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
private Object writeReplace() {
|
||||
return new Ser(Ser.CHRONO_LOCAL_DATE_TIME_TYPE, this);
|
||||
}
|
||||
|
@ -411,7 +423,7 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ import java.util.Objects;
|
|||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
* @serial Document the delegation of this class in the serialized-form specification.
|
||||
* @param <D> the concrete type for the date of this date-time
|
||||
* @since 1.8
|
||||
*/
|
||||
|
@ -112,15 +113,15 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
|
|||
/**
|
||||
* The local date-time.
|
||||
*/
|
||||
private final ChronoLocalDateTimeImpl<D> dateTime;
|
||||
private final transient ChronoLocalDateTimeImpl<D> dateTime;
|
||||
/**
|
||||
* The zone offset.
|
||||
*/
|
||||
private final ZoneOffset offset;
|
||||
private final transient ZoneOffset offset;
|
||||
/**
|
||||
* The zone ID.
|
||||
*/
|
||||
private final ZoneId zone;
|
||||
private final transient ZoneId zone;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -222,6 +223,7 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public ZoneOffset getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
@ -256,10 +258,12 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
|
|||
return dateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZoneId getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChronoZonedDateTime<D> withZoneSameLocal(ZoneId zone) {
|
||||
return ofBest(dateTime, zone, offset);
|
||||
}
|
||||
|
@ -321,6 +325,19 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the ChronoZonedDateTime using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(3); // identifies a ChronoZonedDateTime
|
||||
* out.writeObject(toLocalDateTime());
|
||||
* out.writeObject(getOffset());
|
||||
* out.writeObject(getZone());
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
private Object writeReplace() {
|
||||
return new Ser(Ser.CHRONO_ZONE_DATE_TIME_TYPE, this);
|
||||
}
|
||||
|
@ -330,7 +347,7 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
|
|
|
@ -1258,14 +1258,15 @@ public abstract class Chronology implements Comparable<Chronology> {
|
|||
/**
|
||||
* Writes the Chronology using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(1); // identifies this as a Chronology
|
||||
* out.writeByte(1); // identifies a Chronology
|
||||
* out.writeUTF(getId());
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
protected Object writeReplace() {
|
||||
Object writeReplace() {
|
||||
return new Ser(Ser.CHRONO_TYPE, this);
|
||||
}
|
||||
|
||||
|
@ -1274,14 +1275,26 @@ public abstract class Chronology implements Comparable<Chronology> {
|
|||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the Chronology id to the stream.
|
||||
* @param out the output stream
|
||||
* @throws IOException on any error during the write
|
||||
*/
|
||||
void writeExternal(DataOutput out) throws IOException {
|
||||
out.writeUTF(getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the Chronology id and creates the Chronology.
|
||||
* @param in the input stream
|
||||
* @return the Chronology
|
||||
* @throws IOException on errors during the read
|
||||
* @throws DateTimeException if the Chronology cannot be returned
|
||||
*/
|
||||
static Chronology readExternal(DataInput in) throws IOException {
|
||||
String id = in.readUTF();
|
||||
return Chronology.of(id);
|
||||
|
|
|
@ -63,6 +63,8 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
|
@ -217,11 +219,11 @@ public final class HijrahChronology extends Chronology implements Serializable {
|
|||
/**
|
||||
* The Hijrah Calendar id.
|
||||
*/
|
||||
private final String typeId;
|
||||
private final transient String typeId;
|
||||
/**
|
||||
* The Hijrah calendarType.
|
||||
*/
|
||||
private transient final String calendarType;
|
||||
private final transient String calendarType;
|
||||
/**
|
||||
* Serialization version.
|
||||
*/
|
||||
|
@ -236,7 +238,7 @@ public final class HijrahChronology extends Chronology implements Serializable {
|
|||
* Flag to indicate the initialization of configuration data is complete.
|
||||
* @see #checkCalendarInit()
|
||||
*/
|
||||
private volatile boolean initComplete;
|
||||
private transient volatile boolean initComplete;
|
||||
/**
|
||||
* Array of epoch days indexed by Hijrah Epoch month.
|
||||
* Computed by {@link #loadCalendarData}.
|
||||
|
@ -281,7 +283,7 @@ public final class HijrahChronology extends Chronology implements Serializable {
|
|||
* A reference to the properties stored in
|
||||
* ${java.home}/lib/calendars.properties
|
||||
*/
|
||||
private transient final static Properties calendarProperties;
|
||||
private final transient static Properties calendarProperties;
|
||||
|
||||
/**
|
||||
* Prefix of property names for Hijrah calendar variants.
|
||||
|
@ -1073,4 +1075,30 @@ public final class HijrahChronology extends Chronology implements Serializable {
|
|||
throw new IllegalArgumentException("date must be yyyy-MM-dd", ex);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the Chronology using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(1); // identifies a Chronology
|
||||
* out.writeUTF(getId());
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
@Override
|
||||
Object writeReplace() {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defend against malicious streams.
|
||||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
|
|||
import static java.time.temporal.ChronoField.YEAR;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.Serializable;
|
||||
|
@ -118,7 +119,7 @@ public final class HijrahDate
|
|||
/**
|
||||
* The Chronology of this HijrahDate.
|
||||
*/
|
||||
private final HijrahChronology chrono;
|
||||
private final transient HijrahChronology chrono;
|
||||
/**
|
||||
* The proleptic year.
|
||||
*/
|
||||
|
@ -600,29 +601,41 @@ public final class HijrahDate
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Defend against malicious streams.
|
||||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(6); // identifies a HijrahDate
|
||||
* out.writeObject(chrono); // the HijrahChronology variant
|
||||
* out.writeInt(get(YEAR));
|
||||
* out.writeByte(get(MONTH_OF_YEAR));
|
||||
* out.writeByte(get(DAY_OF_MONTH));
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
private Object writeReplace() {
|
||||
return new Ser(Ser.HIJRAH_DATE_TYPE, this);
|
||||
}
|
||||
|
||||
void writeExternal(ObjectOutput out) throws IOException {
|
||||
// HijrahChronology is implicit in the Hijrah_DATE_TYPE
|
||||
out.writeObject(chrono);
|
||||
out.writeObject(getChronology());
|
||||
out.writeInt(get(YEAR));
|
||||
out.writeByte(get(MONTH_OF_YEAR));
|
||||
out.writeByte(get(DAY_OF_MONTH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the date instance from the stream with a valid one.
|
||||
* ReadExternal has already read the fields and created a new instance
|
||||
* from the data.
|
||||
*
|
||||
* @return the resolved date, never null
|
||||
*/
|
||||
private Object readResolve() {
|
||||
return this;
|
||||
}
|
||||
|
||||
static HijrahDate readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
||||
HijrahChronology chrono = (HijrahChronology) in.readObject();
|
||||
int year = in.readInt();
|
||||
|
|
|
@ -63,9 +63,6 @@ package java.time.chrono;
|
|||
|
||||
import static java.time.temporal.ChronoField.ERA;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.time.DateTimeException;
|
||||
import java.time.temporal.ChronoField;
|
||||
import java.time.temporal.TemporalField;
|
||||
|
@ -158,18 +155,4 @@ public enum HijrahEra implements Era {
|
|||
return Era.super.range(field);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
private Object writeReplace() {
|
||||
return new Ser(Ser.HIJRAH_ERA_TYPE, this);
|
||||
}
|
||||
|
||||
void writeExternal(DataOutput out) throws IOException {
|
||||
out.writeByte(this.getValue());
|
||||
}
|
||||
|
||||
static HijrahEra readExternal(DataInput in) throws IOException {
|
||||
byte eraValue = in.readByte();
|
||||
return HijrahEra.of(eraValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@
|
|||
*/
|
||||
package java.time.chrono;
|
||||
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import static java.time.temporal.ChronoField.DAY_OF_MONTH;
|
||||
import static java.time.temporal.ChronoField.ERA;
|
||||
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
|
||||
|
@ -563,4 +565,29 @@ public final class IsoChronology extends Chronology implements Serializable {
|
|||
return field.range();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the Chronology using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(1); // identifies a Chronology
|
||||
* out.writeUTF(getId());
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
@Override
|
||||
Object writeReplace() {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defend against malicious streams.
|
||||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
*/
|
||||
package java.time.chrono;
|
||||
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import static java.time.temporal.ChronoField.DAY_OF_MONTH;
|
||||
import static java.time.temporal.ChronoField.DAY_OF_YEAR;
|
||||
import static java.time.temporal.ChronoField.ERA;
|
||||
|
@ -503,4 +505,29 @@ public final class JapaneseChronology extends Chronology implements Serializable
|
|||
return dateYearDay(era, yoe, doy); // smart is same as strict
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the Chronology using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(1); // identifies a Chronology
|
||||
* out.writeUTF(getId());
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
@Override
|
||||
Object writeReplace() {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defend against malicious streams.
|
||||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ import static java.time.temporal.ChronoField.YEAR_OF_ERA;
|
|||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.Serializable;
|
||||
import java.time.Clock;
|
||||
import java.time.DateTimeException;
|
||||
|
@ -129,7 +130,7 @@ public final class JapaneseDate
|
|||
/**
|
||||
* The underlying ISO local date.
|
||||
*/
|
||||
private transient final LocalDate isoDate;
|
||||
private final transient LocalDate isoDate;
|
||||
/**
|
||||
* The JapaneseEra of this date.
|
||||
*/
|
||||
|
@ -689,6 +690,28 @@ public final class JapaneseDate
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Defend against malicious streams.
|
||||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(4); // identifies a JapaneseDate
|
||||
* out.writeInt(get(YEAR));
|
||||
* out.writeByte(get(MONTH_OF_YEAR));
|
||||
* out.writeByte(get(DAY_OF_MONTH));
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
private Object writeReplace() {
|
||||
return new Ser(Ser.JAPANESE_DATE_TYPE, this);
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public final class JapaneseEra
|
|||
static final sun.util.calendar.Era[] ERA_CONFIG;
|
||||
|
||||
/**
|
||||
* The singleton instance for the 'Meiji' era (1868-09-08 - 1912-07-29)
|
||||
* The singleton instance for the 'Meiji' era (1868-01-01 - 1912-07-29)
|
||||
* which has the value -1.
|
||||
*/
|
||||
public static final JapaneseEra MEIJI = new JapaneseEra(-1, LocalDate.of(1868, 1, 1));
|
||||
|
@ -155,7 +155,7 @@ public final class JapaneseEra
|
|||
* The era value.
|
||||
* @serial
|
||||
*/
|
||||
private final int eraValue;
|
||||
private final transient int eraValue;
|
||||
|
||||
// the first day of the era
|
||||
private final transient LocalDate since;
|
||||
|
@ -371,6 +371,17 @@ public final class JapaneseEra
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the object using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(5); // identifies a JapaneseEra
|
||||
* out.writeInt(getValue());
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
private Object writeReplace() {
|
||||
return new Ser(Ser.JAPANESE_ERA_TYPE, this);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
*/
|
||||
package java.time.chrono;
|
||||
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
|
||||
import static java.time.temporal.ChronoField.YEAR;
|
||||
|
||||
|
@ -333,4 +335,29 @@ public final class MinguoChronology extends Chronology implements Serializable {
|
|||
return (MinguoDate) super.resolveDate(fieldValues, resolverStyle);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Writes the Chronology using a
|
||||
* <a href="../../../serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
|
||||
* @serialData
|
||||
* <pre>
|
||||
* out.writeByte(1); // identifies a Chronology
|
||||
* out.writeUTF(getId());
|
||||
* </pre>
|
||||
*
|
||||
* @return the instance of {@code Ser}, not null
|
||||
*/
|
||||
@Override
|
||||
Object writeReplace() {
|
||||
return super.writeReplace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defend against malicious streams.
|
||||
* @return never
|
||||
* @throws InvalidObjectException always
|
||||
*/
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue