提交 eceb31dc 编写于 作者: L lana

Merge

......@@ -100,3 +100,6 @@ ac311eb325bfc763698219252bf3cee9e091f3af jdk7-b122
869190935eedee7750d955019ab2a1b80f0a13a8 jdk7-b123
1c72adc9d5f331cb882cf5354ba0dcb118a60b23 jdk7-b124
0a56bdd709d01c1663047e55201d19152ffd3d69 jdk7-b125
8361ef97a0f90086c9048beaf7cea1a37216c4cd jdk7-b126
29e09de1d0b4f84faea114cf10b3ec08b59acc4e jdk7-b127
f08682e23279d6cccbdcafda1eb0647ba4900874 jdk7-b128
......@@ -100,7 +100,6 @@ CACERTS_FILE.desc = Location of certificates file
DEVTOOLS_PATH.desc = Directory containing zip and unzip
CUPS_HEADERS_PATH.desc = Include directory location for CUPS header files
DXSDK_PATH.desc = Root directory of DirectX SDK
MSVCRT_DLL_PATH.desc = Directory containing mscvrt.dll
# Make variables to print out (description and value)
VARIABLE_PRINTVAL_LIST += \
......@@ -133,12 +132,10 @@ VARIABLE_CHECKFIL_LIST += \
ifeq ($(PLATFORM), windows)
VARIABLE_PRINTVAL_LIST += \
DXSDK_PATH \
MSVCRT_DLL_PATH
DXSDK_PATH
VARIABLE_CHECKDIR_LIST += \
DXSDK_PATH \
MSVCRT_DLL_PATH
DXSDK_PATH
endif
......
......@@ -155,6 +155,7 @@ ifdef MT
$(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
endif
$(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE)
@$(call binary_file_verification,$@)
$(install-module-file)
ifeq ($(PLATFORM), windows)
......
......@@ -74,15 +74,6 @@ SCRIPT_SUFFIX =
CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
#
# Default HPI libraries. Build will build only native, unless
# overriden at the make command line. This makes it convenient for
# people doing, say, a pthreads port -- they can create a posix
# directory here, and say "gnumake HPIS=posix" at the top
# level.
#
HPIS = native
#
# Default optimization
#
......
......@@ -74,15 +74,6 @@ SCRIPT_SUFFIX =
CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
#
# Default HPI libraries. Build will build only native unless
# overriden at the make command line. This makes it convenient for
# people doing, say, a pthreads port -- they can create a posix
# directory here, and say "gnumake HPIS=posix" at the top
# level.
#
HPIS = native
#
# Java default optimization (-x04/-O2) etc. Applies to the VM.
#
......
......@@ -43,7 +43,6 @@ FDDLIBM_SUFFIX = lib
# The suffix applied to scripts (.bat for windows, nothing for unix)
SCRIPT_SUFFIX = .bat
HPIS = windows
# LIB_LOCATION, which for windows identifies where .exe files go, may be
# set by each GNUmakefile. The default is BINDIR.
ifndef LIB_LOCATION
......@@ -68,28 +67,27 @@ PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
# The following DLL's are considered MS runtime libraries and should
# not to be REBASEd, see deploy/make/common/Release.gmk.
# msvcrt.dll, msvcrnn.dll [msvcr71 or msvcr80 or msvcr90] : Microsoft runtimes
MS_RUNTIME_LIBRARIES = msvcrt.dll
# msvcr*.dll: Microsoft runtimes
ifeq ($(ARCH_DATA_MODEL), 32)
ifeq ($(COMPILER_VERSION), VS2003)
MSVCRNN_DLL = msvcr71.dll
MSVCPNN_DLL = msvcp71.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL)
endif
ifeq ($(COMPILER_VERSION), VS2005)
MSVCRNN_DLL = msvcr80.dll
MSVCPNN_DLL = msvcp80.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL)
endif
ifeq ($(COMPILER_VERSION), VS2008)
MSVCRNN_DLL = msvcr90.dll
MSVCPNN_DLL = msvcp90.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL)
endif
ifeq ($(COMPILER_VERSION), VS2010)
MSVCRNN_DLL = msvcr100.dll
MSVCPNN_DLL = msvcp100.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL)
endif
endif
......@@ -97,12 +95,12 @@ ifeq ($(ARCH_DATA_MODEL), 64)
ifeq ($(COMPILER_VERSION), VS2008)
MSVCRNN_DLL = msvcr90.dll
MSVCPNN_DLL = msvcp90.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL)
endif
ifeq ($(COMPILER_VERSION), VS2010)
MSVCRNN_DLL = msvcr100.dll
MSVCPNN_DLL = msvcp100.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL)
endif
endif
......@@ -284,7 +282,7 @@ ifeq ($(MFC_DEBUG), true)
MS_RUNTIME_OPTION=-MTd
else
# This MS debugging flag forces a dependence on the debug
# version of the runtime library (MSVCRTD.DLL), as does -MDd.
# version of the runtime library (MSVCR*D.DLL), as does -MDd.
# We cannot re-distribute this debug runtime.
MS_RUNTIME_OPTION=-MDd
endif
......
......@@ -271,10 +271,9 @@ DEMOSRCDIR = $(SHARE_SRC)/demo
# An attempt is made to generate unique enough directories for the
# generated files to not have name collisisons. Most build units
# defines PRODUCT (except Release.gmk), but then they may or may
# not define PACKAGE, THREADIR (only HPI uses this), PROGRAM, and
# LIBRARY. This code chunk attempts to generate a unique
# OBJDIR/CLASSHDRDIR for each build unit based on which of those
# values are set within each build unit.
# not define PACKAGE, PROGRAM, and LIBRARY. This code attempts to
# generate a unique OBJDIR/CLASSHDRDIR for each build unit based
# on which of those values are set within each build unit.
UNIQUE_LOCATION_STRING = tmp
......@@ -298,10 +297,6 @@ ifneq ($(LIBRARY),)
endif
endif
ifneq ($(THREADDIR),)
UNIQUE_LOCATION_STRING += /$(THREADDIR)
endif
#
# Build units may or may not define MODULE. Default to "other".
#
......
......@@ -73,8 +73,11 @@ DEMO_BUILD_AREA = $(DEMOCLASSDIR)/$(PRODUCT)/$(DEMONAME)
# Destination "src" directory
DEMO_BUILD_SRCDIR = $(DEMO_BUILD_AREA)/src
DEMO_BUILD_SRCZIP = $(DEMO_BUILD_AREA)/src.zip
DEMO_SOURCE_ZIP = $(DEMO_DESTDIR)/src.zip
ifndef DEMO_SKIP_SRCZIP
DEMO_BUILD_SRCZIP = $(DEMO_BUILD_AREA)/src.zip
DEMO_SOURCE_ZIP = $(DEMO_DESTDIR)/src.zip
endif
# Place to hold the jar image we are creating
DEMO_JAR_IMAGE = $(DEMO_BUILD_AREA)/jar_image
......@@ -258,14 +261,16 @@ $(DEMO_JAR): \
endif
# Create a src.zip file
$(DEMO_BUILD_SRCZIP): $(DEMO_FULL_SOURCES)
ifndef DEMO_SKIP_SRCZIP
# Create a src.zip file
$(DEMO_BUILD_SRCZIP): $(DEMO_FULL_SOURCES)
@$(prep-target)
$(CD) $(DEMO_BUILD_AREA)/src && $(ZIPEXE) -q -r ../$(@F) .
# Install the destination src.zip file and create the src tree
$(DEMO_SOURCE_ZIP): $(DEMO_BUILD_SRCZIP)
# Install the destination src.zip file and create the src tree
$(DEMO_SOURCE_ZIP): $(DEMO_BUILD_SRCZIP)
$(install-file)
endif
# Native library building
ifdef DEMO_LIBRARY
......@@ -289,6 +294,7 @@ $(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS)
@$(prep-target)
$(LINK.demo) $(SHARED_LIBRARY_FLAG) $(CC_PROGRAM_OUTPUT_FLAG)$@ \
$(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
@$(call binary_file_verification,$@)
# Generation of any javah include file, make sure objects are dependent on it
ifdef DEMO_NATIVECLASS
......@@ -362,7 +368,7 @@ clean clobber:
$(RM) -r $(DEMO_BUILD_AREA)
$(RM) -r $(DEMO_DESTDIR)
# This should not be needed, but some versions of GNU amke have a bug that
# This should not be needed, but some versions of GNU make have a bug that
# sometimes deleted these files for some strange and unknown reason
# (GNU make version 3.78.1 has the problem, GNU make version 3.80 doesn't?)
.PRECIOUS: $(DEMO_FULL_SOURCES) $(DEMO_BUILD_SRCZIP) $(DEMO_SOURCE_ZIP)
......
......@@ -167,6 +167,7 @@ $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
$(LFLAGS) @$(OBJDIR)/$(LIBRARY).lcf \
$(OTHER_LCF) $(JAVALIB) $(LDLIBS)
$(CP) $(OBJDIR)/$(@F) $@
@$(call binary_file_verification,$@)
$(install-module-file)
$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
......@@ -233,6 +234,7 @@ ifeq ($(LIBRARY), fdlibm)
$(AR) -r $@ $(FILES_o)
else # LIBRARY
$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
@$(call binary_file_verification,$@)
$(install-module-file)
ifeq ($(WRITE_LIBVERSION),true)
$(MCS) -d -a "$(FULL_VERSION)" $@
......
......@@ -73,47 +73,20 @@ module-image-jdk:: initial-module-image-jdk trim-module-image-jdk process-module
#
# Paths to these files we need
JDK_MODULE_LICENSES = $(LICENSE_DOCLIST_JDK:%=$(JDK_MODULE_IMAGE_DIR)/%)
JDK_MODULE_64_LICENSES = $(LICENSE_DOCLIST_JDK:%=$(JDK_MODULE_IMAGE_DIR)/%64)
JDK_MODULE_DOCFILES = $(OTHER_DOCLIST_JDK:%=$(JDK_MODULE_IMAGE_DIR)/%)
JRE_MODULE_LICENSES = $(LICENSE_DOCLIST_JRE:%=$(JRE_MODULE_IMAGE_DIR)/%)
JRE_MODULE_64_LICENSES = $(LICENSE_DOCLIST_JRE:%=$(JRE_MODULE_IMAGE_DIR)/%64)
JRE_MODULE_DOCFILES = $(OTHER_DOCLIST_JRE:%=$(JRE_MODULE_IMAGE_DIR)/%)
JRE_MODULE_DOCFILES += $(JRE_NAMECHANGE_DOCLIST:%=$(JRE_MODULE_IMAGE_DIR)/%$(TEXT_SUFFIX))
JDK_MODULE_DOCFILES = $(IMAGE_DOCLIST_JDK:%=$(JDK_MODULE_IMAGE_DIR)/%)
JRE_MODULE_DOCFILES = $(IMAGE_DOCLIST_JRE:%=$(JRE_MODULE_IMAGE_DIR)/%)
###### RULES
# JDK files
$(JDK_MODULE_IMAGE_DIR)/%: $(SHARE_JDK_DOC_SRC)/%
$(process-doc-file)
# Removes LICENSE_VERSION or not
ifdef LICENSE_VERSION
$(JDK_MODULE_IMAGE_DIR)/%: $(SHARE_JDK_DOC_SRC)/%$(LICENSE_VERSION)
$(process-doc-file)
$(JDK_MODULE_IMAGE_DIR)/%64: $(SHARE_JDK_DOC_SRC)/%$(LICENSE_VERSION)
$(process-doc-file)
else
$(JDK_MODULE_IMAGE_DIR)/%64: $(SHARE_JDK_DOC_SRC)/%
$(process-doc-file)
endif
# JRE files
$(JRE_MODULE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/%
$(process-doc-file)
# Add $(TEXT_SUFFIX) suffix
ifdef TEXT_SUFFIX
$(JRE_MODULE_IMAGE_DIR)/%$(TEXT_SUFFIX): $(SHARE_JRE_DOC_SRC)/%
$(process-doc-file)
endif
# Removes LICENSE_VERSION or not
ifdef LICENSE_VERSION
$(JRE_MODULE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/%$(LICENSE_VERSION)
$(process-doc-file)
$(JRE_MODULE_IMAGE_DIR)/%64: $(SHARE_JRE_DOC_SRC)/%$(LICENSE_VERSION)
$(process-doc-file)
else
$(JRE_MODULE_IMAGE_DIR)/%64: $(SHARE_JRE_DOC_SRC)/%
ifeq ($(PLATFORM), windows)
$(JRE_MODULE_IMAGE_DIR)/README.txt: $(SHARE_JRE_DOC_SRC)/README
$(process-doc-file)
endif
......@@ -157,8 +130,7 @@ initial-module-image-jre-setup:
$(MKDIR) -p $(JRE_MODULE_IMAGE_DIR)
# 64-bit solaris jre image contains only the 64-bit add-on files.
initial-module-image-jre-sol64:: initial-module-image-jre-setup \
$(JRE_MODULE_LICENSES) $(JRE_MODULE_64_LICENSES)
initial-module-image-jre-sol64:: initial-module-image-jre-setup
@# Use tar instead of cp to preserve the symbolic links
for dir in bin lib ; do \
( $(CD) $(OUTPUTDIR) && \
......@@ -174,7 +146,7 @@ initial-module-image-jre-sol64:: initial-module-image-jre-setup \
# Construct an initial jre image (initial jdk jre) no trimming or stripping
initial-module-image-jre:: initial-module-image-jre-setup \
$(JRE_LICENSES) $(JRE_MODULE_DOCFILES) \
$(JRE_MODULE_DOCFILES) \
$(BUILDMETAINDEX_JARFILE)
@# Copy in bin directory
$(CD) $(OUTPUTDIR) && $(FIND) bin -depth | $(CPIO) -pdum $(JRE_MODULE_IMAGE_DIR)
......@@ -222,7 +194,7 @@ ifeq ($(PLATFORM), windows)
@# Remove certain *.lib files
$(CD) $(JRE_MODULE_IMAGE_DIR)/lib && \
$(RM) java.$(LIB_SUFFIX) jvm.$(LIB_SUFFIX) \
hpi.$(LIB_SUFFIX) awt.$(LIB_SUFFIX) jawt.$(LIB_SUFFIX)
awt.$(LIB_SUFFIX) jawt.$(LIB_SUFFIX)
ifeq ($(ARCH_DATA_MODEL), 32)
@# The Java Kernel JRE image ships with a special VM. It is not included
@# in the full JRE image, so remove it. Also, is it only for 32-bit windows.
......@@ -310,8 +282,7 @@ initial-module-image-jdk64-bindemos:
# Solaris 64 bit image is special
initial-module-image-jdk-sol64:: initial-module-image-jdk-setup \
initial-module-image-jdk64-bindemos \
$(JDK_MODULE_LICENSES) $(JDK_MODULARLIZED_64_LICENSES)
initial-module-image-jdk64-bindemos
# DB files to add
ifeq ($(OPENJDK),true)
......@@ -335,7 +306,7 @@ endif
# Standard jdk image
initial-module-image-jdk:: initial-module-image-jdk-setup \
initial-module-image-jdk-db \
$(JDK_MODULE_LICENSES) $(JDK_MODULE_DOCFILES)
$(JDK_MODULE_DOCFILES)
$(MKDIR) $(JDK_MODULE_IMAGE_DIR)/lib
@#
@# copy jdk modules to jdk/lib
......@@ -415,8 +386,7 @@ endif # !windows
trim-module-image-jdk::
@# Remove tools that should not be part of SDK.
for t in $(NOTJDKTOOLS); do \
$(RM) $(JDK_MODULE_IMAGE_DIR)/bin/$${t}$(EXE_SUFFIX) \
$(JDK_MODULE_IMAGE_DIR)/bin/*/native_threads/$${t}$(EXE_SUFFIX); \
$(RM) $(JDK_MODULE_IMAGE_DIR)/bin/$${t}$(EXE_SUFFIX); \
done
# Get list of Elf files in the jdk
......
......@@ -160,6 +160,7 @@ $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX):: $(OBJDIR)/$(PROGRAM).lcf $(FILES_o) $(JLI_LC
ifdef MT
$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
endif
@$(call binary_file_verification,$@)
else # PLATFORM
......@@ -184,6 +185,7 @@ $(ACTUAL_PROGRAM):: $(FILES_o)
@$(MKDIR) -p $(TEMPDIR)
$(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
$(FILES_o) $(THREADLIBS) $(LDLIBS)
@$(call binary_file_verification,$@)
$(install-module-file)
endif # PLATFORM
......
......@@ -26,6 +26,9 @@
include $(JDK_TOPDIR)/make/docs/CORE_PKGS.gmk
include $(JDK_TOPDIR)/make/docs/NON_CORE_PKGS.gmk
# What jdk version are we building
THIS_JDK_VERSION := $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
#
# Perform release engineering tasks.
#
......@@ -72,14 +75,6 @@ endif
JTG_DOCS = $(JDK_TOPDIR)/src/solaris/doc
#We use this for man page header
jdkversion := $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
# Text documents on windows use this suffix
ifeq ($(PLATFORM), windows)
TEXT_SUFFIX = .txt
endif
# The base names of all the license and document files for the jdk and jre
# (These files get placed in the jdk and jre install images)
ifdef OPENJDK
......@@ -87,53 +82,28 @@ ifdef OPENJDK
SHARE_JDK_DOC_SRC = $(JDK_TOPDIR)
SHARE_JRE_DOC_SRC = $(JDK_TOPDIR)
# Same files for jdk and jre, no name changes
LICENSE_DOCLIST_JDK = LICENSE ASSEMBLY_EXCEPTION
LICENSE_DOCLIST_JRE = LICENSE ASSEMBLY_EXCEPTION
OTHER_DOCLIST_JDK = THIRD_PARTY_README
OTHER_DOCLIST_JRE = THIRD_PARTY_README
IMAGE_DOCLIST_JDK = LICENSE ASSEMBLY_EXCEPTION THIRD_PARTY_README
IMAGE_DOCLIST_JRE = LICENSE ASSEMBLY_EXCEPTION THIRD_PARTY_README
else
# Where to find these files
SHARE_JDK_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jdk
SHARE_JRE_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jre
# Select the pre-release or FCS license version based on the build milestone.
LICENSE_VERSION=.pre
ifeq ($(MILESTONE), fcs)
LICENSE_VERSION=.fcs
endif
IMAGE_DOCLIST_JDK = COPYRIGHT README.html THIRDPARTYLICENSEREADME.txt
IMAGE_DOCLIST_JRE = COPYRIGHT Welcome.html THIRDPARTYLICENSEREADME.txt
ifeq ($(PLATFORM), windows)
LICENSE_DOCLIST_JDK = $(subst $(LICENSE_VERSION),,\
$(shell $(CD) $(SHARE_JDK_DOC_SRC) && \
$(LS) *LICENSE*$(LICENSE_VERSION)))
LICENSE_DOCLIST_JRE = $(subst $(LICENSE_VERSION),,\
$(shell $(CD) $(SHARE_JRE_DOC_SRC) && \
$(LS) *LICENSE*$(LICENSE_VERSION)))
IMAGE_DOCLIST_JRE += README.txt
else
LICENSE_DOCLIST_JDK = $(subst $(LICENSE_VERSION),,\
$(shell $(CD) $(SHARE_JDK_DOC_SRC) && \
$(LS) *LICENSE*$(LICENSE_VERSION) | $(GREP) -v rtf))
LICENSE_DOCLIST_JRE = $(subst $(LICENSE_VERSION),,\
$(shell $(CD) $(SHARE_JRE_DOC_SRC) && \
$(LS) *LICENSE*$(LICENSE_VERSION) | $(GREP) -v rtf))
IMAGE_DOCLIST_JRE += README
endif
OTHER_DOCLIST_JDK = COPYRIGHT README.html README_ja.html README_zh_CN.html
OTHER_DOCLIST_JRE = COPYRIGHT Welcome.html
JRE_NAMECHANGE_DOCLIST = README
endif
# Paths to these files we need
JDK_LICENSES = $(LICENSE_DOCLIST_JDK:%=$(JDK_IMAGE_DIR)/%)
JDK64_LICENSES = $(LICENSE_DOCLIST_JDK:%=$(JDK_IMAGE_DIR)/%64)
JDK_DOCFILES = $(OTHER_DOCLIST_JDK:%=$(JDK_IMAGE_DIR)/%)
JRE_LICENSES = $(LICENSE_DOCLIST_JRE:%=$(JRE_IMAGE_DIR)/%)
JRE64_LICENSES = $(LICENSE_DOCLIST_JRE:%=$(JRE_IMAGE_DIR)/%64)
JRE_DOCFILES = $(OTHER_DOCLIST_JRE:%=$(JRE_IMAGE_DIR)/%)
JRE_DOCFILES += $(JRE_NAMECHANGE_DOCLIST:%=$(JRE_IMAGE_DIR)/%$(TEXT_SUFFIX))
JDK_DOCFILES = $(IMAGE_DOCLIST_JDK:%=$(JDK_IMAGE_DIR)/%)
JRE_DOCFILES = $(IMAGE_DOCLIST_JRE:%=$(JRE_IMAGE_DIR)/%)
# absolute directory names: note, these must exist prior to build
# time - they are created in the main Makefile.
JRE_IMAGE_BINDIR = $(JRE_IMAGE_DIR)/bin
JRE_IMAGE_THREADIR = $(JRE_IMAGE_DIR)/bin/*/native_threads
MAINMANIFEST = $(JDK_TOPDIR)/make/tools/manifest.mf
BEANMANIFEST = $(JDK_TOPDIR)/make/javax/swing/beaninfo/manifest
......@@ -214,7 +184,7 @@ for manbase in $(MANBASEDIRS:%=%/$(MAN1SUBDIR)) ; do \
$(MKDIR) -p $1/man/$${ja_dir}/man1; \
$(CAT) $${manbase}/ja/$${manpage} \
| $(NATIVE2ASCII) -encoding $(JA_SOURCE_ENCODING) \
| $(SED) 's/@@VERSION@@/$(jdkversion)/g' \
| $(SED) 's/@@VERSION@@/$(THIS_JDK_VERSION)/g' \
| $(NATIVE2ASCII) -reverse -encoding $${ja_encoding} \
> $1/man/$${ja_dir}/man1/$${manpage}; \
done; \
......@@ -244,6 +214,7 @@ images images-clobber \
initial-image-jre initial-image-jdk \
initial-image-jre-sol64 initial-image-jdk-sol64 \
trim-image-jre trim-image-jdk \
identify-image-jre identify-image-jdk \
process-image-jre process-image-jdk \
compare-image \
sec-files sec-files-win jgss-files ::
......@@ -253,11 +224,12 @@ sec-files sec-files-win jgss-files ::
images:: sanity-images post-sanity-images \
$(INITIAL_IMAGE_JRE) $(INITIAL_IMAGE_JDK) \
trim-image-jre trim-image-jdk \
identify-image-jre identify-image-jdk \
process-image-jre process-image-jdk sec-files sec-files-win jgss-files
# Don't use these
image-jre:: initial-image-jre trim-image-jre process-image-jre
image-jdk:: initial-image-jdk trim-image-jdk process-image-jdk
image-jre:: initial-image-jre trim-image-jre identify-image-jre process-image-jre
image-jdk:: initial-image-jdk trim-image-jdk identify-image-jdk process-image-jdk
#
# Sources we ship in the SDK.
......@@ -504,33 +476,12 @@ endef
# JDK files
$(JDK_IMAGE_DIR)/%: $(SHARE_JDK_DOC_SRC)/%
$(process-doc-file)
# Removes LICENSE_VERSION or not
ifdef LICENSE_VERSION
$(JDK_IMAGE_DIR)/%: $(SHARE_JDK_DOC_SRC)/%$(LICENSE_VERSION)
$(process-doc-file)
$(JDK_IMAGE_DIR)/%64: $(SHARE_JDK_DOC_SRC)/%$(LICENSE_VERSION)
$(process-doc-file)
else
$(JDK_IMAGE_DIR)/%64: $(SHARE_JDK_DOC_SRC)/%
$(process-doc-file)
endif
# JRE files
$(JRE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/%
$(process-doc-file)
# Add $(TEXT_SUFFIX) suffix
ifdef TEXT_SUFFIX
$(JRE_IMAGE_DIR)/%$(TEXT_SUFFIX): $(SHARE_JRE_DOC_SRC)/%
$(process-doc-file)
endif
# Removes LICENSE_VERSION or not
ifdef LICENSE_VERSION
$(JRE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/%$(LICENSE_VERSION)
$(process-doc-file)
$(JRE_IMAGE_DIR)/%64: $(SHARE_JRE_DOC_SRC)/%$(LICENSE_VERSION)
$(process-doc-file)
else
$(JRE_IMAGE_DIR)/%64: $(SHARE_JRE_DOC_SRC)/%
ifeq ($(PLATFORM), windows)
$(JRE_IMAGE_DIR)/README.txt: $(SHARE_JRE_DOC_SRC)/README
$(process-doc-file)
endif
......@@ -738,8 +689,7 @@ initial-image-jre-setup:
$(MKDIR) -p $(JRE_IMAGE_DIR)
# 64-bit solaris jre image contains only the 64-bit add-on files.
initial-image-jre-sol64:: initial-image-jre-setup \
$(JRE_LICENSES) $(JRE64_LICENSES)
initial-image-jre-sol64:: initial-image-jre-setup
@# Use tar instead of cp to preserve the symbolic links
for dir in bin lib ; do \
( $(CD) $(OUTPUTDIR) && \
......@@ -760,7 +710,7 @@ initial-image-jre-sol64:: initial-image-jre-setup \
# See "initial-image-jdk-setup" for an explanation of the rm of
# drive names like C:
initial-image-jre:: initial-image-jre-setup \
$(JRE_LICENSES) $(JRE_DOCFILES) \
$(JRE_DOCFILES) \
$(RT_JAR) $(RESOURCES_JAR) $(JSSE_JAR) \
$(BUILDMETAINDEX_JARFILE)
@# Copy in bin directory
......@@ -802,7 +752,7 @@ ifeq ($(PLATFORM), windows)
@# Remove certain *.lib files
$(CD) $(JRE_IMAGE_DIR)/lib && \
$(RM) java.$(LIB_SUFFIX) jvm.$(LIB_SUFFIX) \
hpi.$(LIB_SUFFIX) awt.$(LIB_SUFFIX) jawt.$(LIB_SUFFIX)
awt.$(LIB_SUFFIX) jawt.$(LIB_SUFFIX)
ifeq ($(ARCH_DATA_MODEL), 32)
@# The Java Kernel JRE image ships with a special VM. It is not included
@# in the full JRE image, so remove it. Also, is it only for 32-bit windows.
......@@ -836,11 +786,14 @@ else # PLATFORM
endif
endif # PLATFORM
# Get list of all Elf files in the jre
JRE_ELF_LIST=$(TEMPDIR)/jre-elf-files.list
$(JRE_ELF_LIST):
ifneq ($(PLATFORM), windows)
# Get list of all binary (COFF or Elf) files in the jre
JRE_BIN_LIST=$(TEMPDIR)/jre-bin-files.list
$(JRE_BIN_LIST):
$(RM) $@
ifeq ($(PLATFORM), windows)
$(FIND) $(JRE_IMAGE_DIR)/bin -type f -name \*.exe \
-o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" > $@
else
$(FIND) $(JRE_IMAGE_DIR)/lib -type f -name \*.$(LIB_SUFFIX) >> $@
$(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
......@@ -848,9 +801,9 @@ endif
# Post process the image (strips and mcs on Elf files we are shipping)
# (Note the jdk WILL want the jre image before this processing)
process-image-jre:: $(JRE_ELF_LIST)
process-image-jre:: $(JRE_BIN_LIST)
ifneq ($(POST_STRIP_PROCESS), )
for f in `$(CAT) $(JRE_ELF_LIST)`; do \
@for f in `$(CAT) $(JRE_BIN_LIST)`; do \
$(CHMOD) u+w $${f}; \
$(ECHO) $(POST_STRIP_PROCESS) $${f}; \
$(POST_STRIP_PROCESS) $${f}; \
......@@ -858,14 +811,17 @@ ifneq ($(POST_STRIP_PROCESS), )
done
endif
ifneq ($(POST_MCS_PROCESS), )
for f in `$(CAT) $(JRE_ELF_LIST)`; do \
@for f in `$(CAT) $(JRE_BIN_LIST)`; do \
$(CHMOD) u+w $${f}; \
$(ECHO) $(POST_MCS_PROCESS) $${f}; \
$(POST_MCS_PROCESS) $${f}; \
$(CHMOD) go-w $${f}; \
done
endif
$(RM) $(JRE_ELF_LIST)
@for f in `$(CAT) $(JRE_BIN_LIST)`; do \
$(call binary_file_verification,$${f}); \
done
$(RM) $(JRE_BIN_LIST)
######################################################
# JDK Image
......@@ -905,8 +861,7 @@ initial-image-jdk64-bindemos:
# Solaris 64 bit image is special
initial-image-jdk-sol64:: initial-image-jdk-setup \
initial-image-jdk64-bindemos \
$(JDK_LICENSES) $(JDK64_LICENSES)
initial-image-jdk64-bindemos
# DB files to add
ifdef OPENJDK
......@@ -930,7 +885,7 @@ endif
# Standard jdk image
initial-image-jdk:: initial-image-jdk-setup \
initial-image-jdk-db \
$(JDK_LICENSES) $(JDK_DOCFILES)
$(JDK_DOCFILES)
$(MKDIR) $(JDK_IMAGE_DIR)/lib
@#
@# Copy in the jars in lib that only belong in the JDK
......@@ -1089,14 +1044,18 @@ endif # !windows
trim-image-jdk::
@# Remove tools that should not be part of SDK.
for t in $(NOTJDKTOOLS); do \
$(RM) $(JDK_IMAGE_DIR)/bin/$${t}$(EXE_SUFFIX) \
$(JDK_IMAGE_DIR)/bin/*/native_threads/$${t}$(EXE_SUFFIX); \
$(RM) $(JDK_IMAGE_DIR)/bin/$${t}$(EXE_SUFFIX); \
done
# Get list of Elf files in the jdk
JDK_ELF_LIST=$(TEMPDIR)/jdk-elf-files.list
$(JDK_ELF_LIST):
ifneq ($(PLATFORM), windows)
# Get list of binary (COFF or Elf) files in the jdk
JDK_BIN_LIST=$(TEMPDIR)/jdk-bin-files.list
$(JDK_BIN_LIST):
ifeq ($(PLATFORM), windows)
$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f -name \*.exe \
-o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" > $@
$(FIND) $(JDK_IMAGE_DIR)/bin -type f -name \*.exe \
-o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" >> $@
else
$(RM) $@
$(FIND) $(JDK_IMAGE_DIR)/jre/lib -type f -name \*.$(LIB_SUFFIX) >> $@
$(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f -name \*$(EXE_SUFFIX)` \
......@@ -1106,9 +1065,9 @@ ifneq ($(PLATFORM), windows)
endif
# Post process the image (strips and mcs on files we are shipping)
process-image-jdk:: $(JDK_ELF_LIST)
process-image-jdk:: $(JDK_BIN_LIST)
ifneq ($(POST_STRIP_PROCESS), )
for f in `$(CAT) $(JDK_ELF_LIST)`; do \
@for f in `$(CAT) $(JDK_BIN_LIST)`; do \
$(CHMOD) u+w $${f}; \
$(ECHO) $(POST_STRIP_PROCESS) $${f}; \
$(POST_STRIP_PROCESS) $${f}; \
......@@ -1116,14 +1075,56 @@ ifneq ($(POST_STRIP_PROCESS), )
done
endif
ifneq ($(POST_MCS_PROCESS), )
for f in `$(CAT) $(JDK_ELF_LIST)`; do \
@for f in `$(CAT) $(JDK_BIN_LIST)`; do \
$(CHMOD) u+w $${f}; \
$(ECHO) $(POST_MCS_PROCESS) $${f}; \
$(POST_MCS_PROCESS) $${f}; \
$(CHMOD) go-w $${f}; \
done
endif
$(RM) $(JDK_ELF_LIST)
@for f in `$(CAT) $(JDK_BIN_LIST)`; do \
$(call binary_file_verification,$${f}); \
done
$(RM) $(JDK_BIN_LIST)
###################################################################
# What did we build
###################################################################
# The jdk text info file that lives at the root of the install image.
JDK_INFO_FILE = $(JDK_IMAGE_DIR)/release
JRE_INFO_FILE = $(JRE_IMAGE_DIR)/release
# Common way to emit a line into the release or info file
define info-file-item # name value
$(PRINTF) "%s=\"%s\"\n" $1 $2 >> $@
endef
# Values to emit
MINIMUM_OS_NAME := $(REQUIRED_OS_NAME)
MINIMUM_OS_VERSION := $(REQUIRED_OS_VERSION)
MINIMUM_OS_ARCH := $(ARCH)
$(JDK_INFO_FILE): FRC
$(prep-target)
$(call info-file-item, "JAVA_VERSION", "$(THIS_JDK_VERSION)")
$(call info-file-item, "OS_NAME", "$(MINIMUM_OS_NAME)")
$(call info-file-item, "OS_VERSION", "$(MINIMUM_OS_VERSION)")
$(call info-file-item, "OS_ARCH", "$(MINIMUM_OS_ARCH)")
# Create release file to identify this image
identify-image-jdk:: $(JDK_INFO_FILE)
$(JRE_INFO_FILE): FRC
$(prep-target)
$(call info-file-item, "JAVA_VERSION", "$(THIS_JDK_VERSION)")
$(call info-file-item, "OS_NAME", "$(MINIMUM_OS_NAME)")
$(call info-file-item, "OS_VERSION", "$(MINIMUM_OS_VERSION)")
$(call info-file-item, "OS_ARCH", "$(MINIMUM_OS_ARCH)")
# Create release file to identify this image
identify-image-jre:: $(JRE_INFO_FILE)
###################################################################
# What do we compare against
......@@ -1278,6 +1279,7 @@ images images-clobber::
initial-image-jre-setup \
trim-image-jre trim-image-jdk \
process-image-jre process-image-jdk \
identify-image-jre identify-image-jdk \
install-previous-jre install-previous-jdk \
compare-image-jre compare-image-jdk \
compare-image compare-image-clobber \
......
......@@ -35,6 +35,7 @@ ifeq ($(PLATFORM), windows)
LIBEXE = $(COMPILER_PATH)lib
LINK = $(COMPILER_PATH)link
LINK32 = $(LINK)
DUMPBIN = $(COMPILER_PATH)dumpbin.exe
# Fill in unknown values
COMPILER_NAME=Unknown MSVC Compiler
......@@ -139,8 +140,8 @@ ifeq ($(PLATFORM), windows)
_OTHER_TOOLS_BIN = $(WINDOWSSDKDIR)/Bin/x64
endif
endif
RC = $(_OTHER_TOOLS_BIN)/rc.exe
REBASE = $(_OTHER_TOOLS_BIN)/rebase.exe
RC = $(_OTHER_TOOLS_BIN)/RC.Exe
REBASE = $(_OTHER_TOOLS_BIN)/ReBase.Exe
MT = $(_OTHER_TOOLS_BIN)/mt.exe
MTL = $(_OTHER_TOOLS_BIN)/midl.exe
endif
......
......@@ -76,12 +76,9 @@ SRC_BUNDLEDIR = $(OUTPUTDIR)/source-bundles
ABS_SRC_BUNDLEDIR = $(ABS_OUTPUTDIR)/source-bundles
BIN_BUNDLEDIR = $(OUTPUTDIR)/bundles
ABS_BIN_BUNDLEDIR = $(ABS_OUTPUTDIR)/bundles
JRL_BUNDLEDIR = $(OUTPUTDIR)/java.net
ABS_JRL_BUNDLEDIR = $(ABS_OUTPUTDIR)/java.net
dummy := $(shell $(MKDIR) -p $(BIN_BUNDLEDIR))
dummy := $(shell $(MKDIR) -p $(SRC_BUNDLEDIR) )
dummy := $(shell $(MKDIR) -p $(JRL_BUNDLEDIR) )
TEMP_DIR = $(OUTPUTDIR)/tmp
ABS_TEMP_DIR = $(ABS_OUTPUTDIR)/tmp
......
......@@ -177,3 +177,20 @@ else
endif
HOTSPOT_SERVER_PATH:=$(call AltCheckValue,HOTSPOT_SERVER_PATH)
# Special define for checking the binaries
# Macro to check it's input file for banned dependencies and verify the
# binary built properly. Relies on process exit code.
define binary_file_verification # binary_file
( \
$(ECHO) "Checking for mapfile use in: $1" && \
if [ "`$(NM) -D -g --defined-only $1 | $(EGREP) 'SUNWprivate'`" = "" ] ; then \
$(ECHO) "WARNING: File was not built with a mapfile: $1"; \
fi && \
$(ECHO) "Library loads for: $1" && \
$(LDD) $1 && \
$(ECHO) "RUNPATH for: $1" && \
( $(READELF) -d $1 | $(EGREP) 'NEEDED|RUNPATH|RPATH' ) \
)
endef
......@@ -186,3 +186,20 @@ else
endif
HOTSPOT_SERVER_PATH:=$(call AltCheckValue,HOTSPOT_SERVER_PATH)
# Special define for checking the binaries
# Macro to check it's input file for banned dependencies and verify the
# binary built properly. Relies on process exit code.
define binary_file_verification # binary_file
( \
$(ECHO) "Checking for mapfile use in: $1" && \
if [ "`$(NM) -g -D $1 | $(EGREP) -v 'UNDEF' | $(EGREP) 'SUNWprivate'`" = "" ] ; then \
$(ECHO) "WARNING: File was not built with a mapfile: $1"; \
fi && \
$(ECHO) "Library loads for: $1" && \
$(LDD) $1 && \
$(ECHO) "RUNPATH for: $1" && \
( $(DUMP) -L -v $1 | $(EGREP) 'NEEDED|RUNPATH|RPATH' ) \
)
endef
......@@ -85,6 +85,7 @@ DATE = $(UTILS_COMMAND_PATH)date
DF = $(UTILS_COMMAND_PATH)df
DIFF = $(UTILS_USR_BIN_PATH)diff
DIRNAME = $(UTILS_USR_BIN_PATH)dirname
DUMP = $(UTILS_CCS_BIN_PATH)dump
ECHO = $(UTILS_COMMAND_PATH)echo
EGREP = $(UTILS_COMMAND_PATH)egrep
EXPR = $(UTILS_USR_BIN_PATH)expr
......@@ -99,6 +100,7 @@ ID = $(UTILS_COMMAND_PATH)id
ISAINFO = $(UTILS_COMMAND_PATH)isainfo
KSH = $(UTILS_COMMAND_PATH)ksh
LD = $(UTILS_CCS_BIN_PATH)ld
LDD = $(UTILS_USR_BIN_PATH)ldd
LEX = $(UTILS_CCS_BIN_PATH)lex
LN = $(UTILS_COMMAND_PATH)ln
LS = $(UTILS_COMMAND_PATH)ls
......@@ -114,6 +116,7 @@ PKGMK = $(UTILS_COMMAND_PATH)pkgmk
PRINTF = $(UTILS_USR_BIN_PATH)printf
PWD = $(UTILS_COMMAND_PATH)pwd
RC = $(UTILS_COMMAND_PATH)rc
READELF = $(UTILS_USR_BIN_PATH)readelf
RMDIR = $(UTILS_COMMAND_PATH)rmdir
RPM = $(UTILS_COMMAND_PATH)rpm
RPMBUILD = $(UTILS_COMMAND_PATH)rpmbuild
......
......@@ -127,6 +127,7 @@ endif
# Solaris specific
ifeq ($(PLATFORM), solaris)
REQUIRED_OS_NAME = SunOS
REQUIRED_OS_VERSION = 5.10
REQUIRED_OS_VARIANT_NAME = Solaris
REQUIRED_OS_VARIANT_VERSION = $(REQUIRED_OS_VERSION)
......@@ -148,6 +149,7 @@ endif
# Linux specific
ifeq ($(PLATFORM), linux)
REQUIRED_OS_NAME = Linux
REQUIRED_OS_VERSION = 2.6
REQUIRED_OS_VARIANT_NAME = Fedora
REQUIRED_OS_VARIANT_VERSION = 9
......@@ -166,6 +168,7 @@ endif
# Windows specific
ifeq ($(PLATFORM), windows)
REQUIRED_OS_NAME = Windows
ifeq ($(ARCH_DATA_MODEL),64)
REQUIRED_OS_VERSION = 5.2
REQUIRED_OS_VARIANT_NAME = Windows2003
......
......@@ -288,8 +288,8 @@ ifndef VS2010_EXISTS
xVS100COMNTOOLS :="$(_program_files32)/Microsoft Visual Studio 10.0/Common7/Tools/"
fVS100COMNTOOLS :=$(call FullPath,$(xVS100COMNTOOLS))
else
xVS100COMNTOOLS :="$(subst \,/,$(VS100COMNTOOLS))"
ifneq ($(word 2,$(VS100COMNTOOLS)),)
xVS100COMNTOOLS :="$(subst \,/,$(VS100COMNTOOLS))"
fVS100COMNTOOLS :=$(call FullPath,$(xVS100COMNTOOLS))
else
fVS100COMNTOOLS :=$(xVS100COMNTOOLS)
......@@ -551,18 +551,6 @@ ifndef ALT_BOOTDIR
_BOOTDIR3 =$(SLASH_JAVA)/re/jdk/$(PREVIOUS_JDK_VERSION)/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
endif
# 32 bit always needs 2 runtimes, 64 bit usually does too
# MSVCRT_DLL_PATH: location of msvcrt.dll that will be re-distributed
ifdef ALT_MSVCRT_DLL_PATH
xALT_MSVCRT_DLL_PATH :="$(subst \,/,$(ALT_MSVCRT_DLL_PATH))"
MSVCRT_DLL_PATH :=$(call FullPath,$(xALT_MSVCRT_DLL_PATH))
else
MSVCRT_DLL_PATH :=$(call FullPath,$(_system_root)/system32/)
endif
MSVCRT_DLL_PATH:=$(call AltCheckSpaces,MSVCRT_DLL_PATH)
MSVCRT_DLL_PATH:=$(call AltCheckValue,MSVCRT_DLL_PATH)
# 32bit always needs the MSVCRNN runtime, 64bit does when using VS2008
ifeq ($(ARCH_DATA_MODEL), 32)
_NEEDS_MSVCRNN = true
......@@ -641,15 +629,6 @@ else
endif
INSTALL_MSSDK:=$(call AltCheckSpaces,INSTALL_MSSDK)
# INSTALL_MSIVAL2: Installation of MsiVal2 for this platform (for install)
ifdef ALT_INSTALL_MSIVAL2
xALT_INSTALL_MSIVAL2 :="$(subst \,/,$(ALT_INSTALL_MSIVAL2))"
INSTALL_MSIVAL2 :=$(call FullPath,$(xALT_INSTALL_MSIVAL2))
else
INSTALL_MSIVAL2 :=$(_program_files32)/MsiVal2
endif
INSTALL_MSIVAL2:=$(call AltCheckSpaces,INSTALL_MSIVAL2)
# WSCRIPT: path to wscript.exe (used in creating install bundles)
ifdef ALT_WSCRIPT
xALT_WSCRIPT :="$(subst \,/,$(ALT_WSCRIPT))"
......@@ -685,43 +664,6 @@ else
endif
CABARC:=$(call AltCheckSpaces,CABARC)
# MSIVAL2: path to msival2.exe (used in validating install msi files)
ifdef ALT_MSIVAL2
xALT_MSIVAL2 :="$(subst \,/,$(ALT_MSIVAL2))"
MSIVAL2 =$(xALT_MSIVAL2)
else
_MSIVAL2_1 :=$(INSTALL_MSIVAL2)/msival2.exe
_MSIVAL2_2 :=$(DEVTOOLS_PATH)msival2.exe
MSIVAL2 :=$(call FileExists,$(_MSIVAL2_1),$(_MSIVAL2_2))
endif
MSIVAL2:=$(call AltCheckSpaces,MSIVAL2)
# suppress msival2 checks, as it hangs jprt builds
ifdef SKIP_MSIVAL2
MSIVAL2 := $(ECHO)
endif
# LOGOCUB: path to cub file for (used in validating install msi files)
ifdef ALT_LOGOCUB
xALT_LOGOCUB :="$(subst \,/,$(ALT_LOGOCUB))"
LOGOCUB =$(xALT_LOGOCUB)
else
_LOGOCUB1 :=$(INSTALL_MSIVAL2)/logo.cub
_LOGOCUB2 :=$(DEVTOOLS_PATH)logo.cub
LOGOCUB :=$(call FileExists,$(_LOGOCUB1),$(_LOGOCUB2))
endif
LOGOCUB:=$(call AltCheckSpaces,LOGOCUB)
# MSITRAN: path to msitran.exe (used in creating install bundles and sponsors)
ifdef ALT_MSITRAN
xALT_MSITRAN :="$(subst \,/,$(ALT_MSITRAN))"
MSITRAN =$(xALT_MSITRAN)
else
_MSITRAN1 :=$(INSTALL_MSSDK)/Bin/msitran.exe
_MSITRAN2 :=$(DEVTOOLS_PATH)msitran.exe
MSITRAN :=$(call FileExists,$(_MSITRAN1),$(_MSITRAN2))
endif
MSITRAN:=$(call AltCheckSpaces,MSITRAN)
# MSICERT: path to msicert.exe (used in creating install bundles)
ifdef ALT_MSICERT
xALT_MSICERT :="$(subst \,/,$(ALT_MSICERT))"
......@@ -798,3 +740,50 @@ else
endif
HOTSPOT_LIB_PATH:=$(call AltCheckSpaces,HOTSPOT_LIB_PATH)
HOTSPOT_LIB_PATH:=$(call AltCheckValue,HOTSPOT_LIB_PATH)
# Special define for checking the binaries
ifeq ($(VS2010_EXISTS),true)
# All windows dll and exe files should have been built with /NXCOMPAT
# and be setup for dynamic base addresses.
# In addition, we should not be dependent on certain dll files that
# we do not or cannot redistribute.
# List of filenames we should NOT be dependent on
BANNED_DLLS=msvcp100[.]dll|msvcr100d[.]dll|msvcrtd[.]dll
# Macro to check it's input file for banned dependencies and verify the
# binary was built properly. Relies on process exit code.
define binary_file_verification # binary_file
( \
$(ECHO) "Checking for /NXCOMPAT usage in: $1" && \
if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \
$(ECHO) "ERROR: Did not find 'NX compatible' in headers: $1" ; \
$(DUMPBIN) /headers $1 ; \
exit 7 ; \
fi ; \
$(ECHO) "Checking for /DYNAMICBASE usage in: $1" && \
if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \
$(ECHO) "ERROR: Did not find 'Dynamic base' in headers: $1" ; \
$(DUMPBIN) /headers $1 ; \
exit 8 ; \
fi ; \
$(ECHO) "Checking for banned dependencies in: $1" && \
if [ "`$(DUMPBIN) /dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \
$(ECHO) "ERROR: Found us of $(BANNED_DLLS)"; \
$(DUMPBIN) /dependents $1 ; \
exit 9 ; \
fi ; \
)
endef
else
# Macro to check it's input file for banned dependencies and verify the
# binary was built properly. Relies on process exit code.
define binary_file_verification # binary_file
endef
endif
......@@ -96,7 +96,6 @@ ifeq ($(PLATFORM),solaris)
endif
endif
ifeq ($(PLATFORM),windows)
ALL_SETTINGS+=$(call addAltSetting,MSVCRT_DLL_PATH)
ifneq ($(MSVCRNN_DLL),)
ALL_SETTINGS+=$(call addAltSetting,MSVCRNN_DLL_PATH)
endif
......@@ -117,6 +116,9 @@ ALL_SETTINGS+=$(call addRequiredVersionSetting,ZIP_VER)
ALL_SETTINGS+=$(call addRequiredVersionSetting,UNZIP_VER)
ifeq ($(PLATFORM),windows)
ALL_SETTINGS+=$(call addRequiredVersionSetting,LINK_VER)
ALL_SETTINGS+=$(call addRequiredSetting,CC)
ALL_SETTINGS+=$(call addRequiredSetting,LINK)
ALL_SETTINGS+=$(call addRequiredSetting,DUMPBIN)
endif
ALL_SETTINGS+=$(call addRequiredVersionSetting,ANT_VER)
ALL_SETTINGS+=$(call addRequiredSetting,TEMPDIR)
......@@ -226,13 +228,13 @@ ifeq ($(PLATFORM),windows)
ALL_SETTINGS+=$(call addAltSetting,DXSDK_INCLUDE_PATH)
ALL_SETTINGS+=$(call addAltSetting,DXSDK_LIB_PATH)
ALL_SETTINGS+=$(call addAltSetting,WINDOWSSDKDIR)
ALL_SETTINGS+=$(call addRequiredSetting,RC)
ALL_SETTINGS+=$(call addRequiredSetting,REBASE)
ifndef OPENJDK
ALL_SETTINGS+=$(call addAltSetting,DEPLOY_MSSDK)
ALL_SETTINGS+=$(call addAltSetting,INSTALL_MSSDK)
ALL_SETTINGS+=$(call addAltSetting,WSCRIPT)
ALL_SETTINGS+=$(call addAltSetting,MSICERT)
ALL_SETTINGS+=$(call addAltSetting,MSITRAN)
ALL_SETTINGS+=$(call addAltSetting,MSIVAL2)
endif
endif
ALL_SETTINGS+=$(call addAltSetting,CACERTS_FILE)
......
......@@ -879,13 +879,6 @@ sane-devtools_path:
######################################################
sane-msvcrt_path:
ifeq ($(PLATFORM), windows)
@if [ ! -r "$(MSVCRT_DLL_PATH)/msvcrt.dll" ]; then \
$(ECHO) "ERROR: You do not have access to msvcrt.dll. \n" \
" Please check your access to \n" \
" $(MSVCRT_DLL_PATH) \n" \
" and/or check your value of ALT_MSVCRT_DLL_PATH. \n" \
"" >> $(ERROR_FILE) ; \
fi
ifneq ($(MSVCRNN_DLL),)
@if [ ! -r "$(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL)" ]; then \
$(ECHO) "ERROR: You do not have access to $(MSVCRNN_DLL). \n" \
......@@ -1018,6 +1011,22 @@ ifeq ($(PLATFORM), windows)
" and/or check your value of ALT_MSDEVTOOLS_PATH. \n" \
"" >> $(ERROR_FILE) ; \
fi
else
ifeq ($(wildcard $(REBASE)),)
@$(ECHO) "ERROR: Cannot find the REBASE utility from path: $(REBASE)\n" \
" This is normally obtained from the WINDOWSSDKDIR." \
"" >> $(ERROR_FILE)
endif
ifeq ($(wildcard $(RC)),)
@$(ECHO) "ERROR: Cannot find the RC utility from path: $(RC)\n" \
" This is normally obtained from the WINDOWSSDKDIR." \
"" >> $(ERROR_FILE)
endif
ifeq ($(wildcard $(DUMPBIN)),)
@$(ECHO) "ERROR: Cannot find the DUMPBIN utility from path: $(DUMPBIN)\n" \
" This is normally obtained from the WINDOWSSDKDIR." \
"" >> $(ERROR_FILE)
endif
endif
endif
......@@ -1459,25 +1468,6 @@ ifeq ($(PLATFORM), windows)
fi
endif
######################################################
# Check for existence of INSTALL_MSIVAL2 on windows
######################################################
sane-install-msival2_path:
ifeq ($(PLATFORM), windows)
@if [ -z "$(INSTALL_MSIVAL2)" ]; then \
$(ECHO) "WARNING: Your INSTALL_MSIVAL2 setting is empty.\n" \
" It is recommended to set ALT_INSTALL_MSIVAL2.\n" \
"" >> $(WARNING_FILE) ; \
fi
@if [ ! -r "$(INSTALL_MSIVAL2)" ]; then \
$(ECHO) "ERROR: You do not have a valid INSTALL_MSIVAL2 setting. \n" \
" Please check your access to \n" \
" $(INSTALL_MSIVAL2) \n" \
" and/or check your value of ALT_INSTALL_MSIVAL2. \n" \
"" >> $(ERROR_FILE) ; \
fi
endif
######################################################
# Check the GNU C++ compiler for OJI plugin
######################################################
......
......@@ -34,7 +34,7 @@ include $(BUILDDIR)/common/Defs.gmk
#
# The order of subdirs here is important
#
SUBDIRS += hpi version jvm redist verify fdlibm java sun_nio jli main zip
SUBDIRS += version jvm redist verify fdlibm java sun_nio jli main zip
# Others
# Note: java_crw_demo java_hprof_demo are demos but must be delivered built in sdk
......
......@@ -24,7 +24,7 @@
#
#
# Makefile for native threads HPI.
# Makefile for fdlibm
#
# Note:
# The fdlibm libraries are built using special rules in Library.gmk.
......
#
# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Shared files between the different threads types on Solaris. Be
# careful when including this, you must get your variables right.
#
#
# Common files on Solaris.
#
ifneq ($(PLATFORM), windows)
FILES_c += \
interrupt.c \
linker_md.c \
memory_md.c \
system_md.c \
hpi.c
endif
#
# Include paths can also be shared.
#
ifneq ($(PLATFORM), windows)
OTHER_INCLUDES += \
-I$(PLATFORM_SRC)/hpi/$(THREADDIR)/include \
-I$(PLATFORM_SRC)/hpi/include \
-I$(PLATFORM_SRC)/hpi/export \
-I$(SHARE_SRC)/hpi/include \
-I$(SHARE_SRC)/hpi/export
else
OTHER_INCLUDES += \
-I$(PLATFORM_SRC)/hpi/include \
-I$(PLATFORM_SRC)/hpi/export \
-I$(SHARE_SRC)/hpi/include \
-I$(SHARE_SRC)/hpi/export
endif
#
# Add to the default C and assembly file search paths. Clear any initial
# vpath settings to ensure that we don't look in unexpected places for HPI
# files.
#
vpath %.c
vpath %.c $(PLATFORM_SRC)/hpi/$(THREADDIR)/src
vpath %.c $(PLATFORM_SRC)/hpi/src
vpath %.c $(SHARE_SRC)/hpi/src
vpath %.s
vpath %.s $(PLATFORM_SRC)/hpi/$(THREADDIR)/src
vpath %.s $(PLATFORM_SRC)/hpi/src
#
# By default leave out locking statistics
#
ifneq ($(PLATFORM), windows)
LOCKSTATS = false
ifeq ($(LOCKSTATS), true)
CFLAGS_COMMON += -DLOCKSTATS
endif
endif
#
# Things that must be linked in.
#
ifneq ($(PLATFORM), windows)
OTHER_LDLIBS += $(LIBSOCKET) $(LIBNSL) $(LIBM) -ldl
endif
data = R0x2000;
text = LOAD ?RXO;
# Test Null
text: .text%_init;
text: .text%checkForCorrectLibthread: OUTPUTDIR/tmp/java/hpi/native_threads/obj/threads_solaris.o;
text: .text%init64IO: OUTPUTDIR/tmp/java/hpi/native_threads/obj/system_md.o;
text: .text%DLL_Initialize;
text: .text%GetInterface: OUTPUTDIR/tmp/java/hpi/native_threads/obj/hpi.o;
text: .text%sysBuildLibName;
text: .text%sysLoadLibrary;
text: .text%sysFindLibraryEntry;
text: .text%sysNativePath;
text: .text%sysOpen;
text: .text%sysSeek;
text: .text%lseek64_w;
# Test Exit
# Test Hello
# Test Sleep
# Test IntToString
# Test LoadToolkit
text: .text%sysAvailable;
text: .text%sysFfileMode;
text: .text%sysGetLastErrorString;
# Test LoadFrame
# Test LoadJFrame
# Test JHello
# SwingSet
data = R0x2000;
text = LOAD ?RXO;
# Test Null
text: .text%checkForCorrectLibthread: OUTPUTDIR/tmp/java/hpi/native_threads/obj/threads_solaris.o;
text: .text%init64IO: OUTPUTDIR/tmp/java/hpi/native_threads/obj/system_md.o;
text: .text%DLL_Initialize;
text: .text%GetInterface: OUTPUTDIR/tmp/java/hpi/native_threads/obj/hpi.o;
text: .text%sysBuildLibName;
text: .text%sysLoadLibrary;
text: .text%sysFindLibraryEntry;
text: .text%sysNativePath;
text: .text%sysOpen;
text: .text%sysFfileMode;
text: .text%sysSeek;
text: .text%lseek64_w;
text: .text%sysAvailable;
# Test Exit
# Test Hello
# Test Sleep
# Test IntToString
# Test LoadToolkit
text: .text%sysGetLastErrorString;
# Test LoadFrame
# Test LoadJFrame
# Test JHello
# SwingSet
data = R0x2000;
text = LOAD ?RXO;
# Test Null
text: .text%checkForCorrectLibthread: OUTPUTDIR/tmp/java/hpi/native_threads/obj64/threads_solaris.o;
text: .text%init64IO: OUTPUTDIR/tmp/java/hpi/native_threads/obj64/system_md.o;
text: .text%DLL_Initialize;
text: .text%GetInterface: OUTPUTDIR/tmp/java/hpi/native_threads/obj64/hpi.o;
text: .text%sysBuildLibName;
text: .text%sysLoadLibrary;
text: .text%sysFindLibraryEntry;
text: .text%sysNativePath;
text: .text%sysOpen;
text: .text%sysFfileMode;
text: .text%sysSeek;
text: .text%lseek64_w;
text: .text%sysAvailable;
# Test Exit
# Test Hello
# Test Sleep
# Test IntToString
# Test LoadToolkit
text: .text%sysGetLastErrorString;
# Test LoadFrame
# Test LoadJFrame
# Test JHello
# SwingSet
#
# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -70,14 +70,18 @@ SUNWprivate_1.1 {
Java_sun_management_ThreadImpl_dumpThreads0;
Java_sun_management_ThreadImpl_findDeadlockedThreads0;
Java_sun_management_ThreadImpl_findMonitorDeadlockedThreads0;
Java_sun_management_ThreadImpl_getThreadInfo0;
Java_sun_management_ThreadImpl_getThreadInfo1;
Java_sun_management_ThreadImpl_getThreads;
Java_sun_management_ThreadImpl_getThreadTotalCpuTime0;
Java_sun_management_ThreadImpl_getThreadTotalCpuTime1;
Java_sun_management_ThreadImpl_getThreadUserCpuTime0;
Java_sun_management_ThreadImpl_getThreadUserCpuTime1;
Java_sun_management_ThreadImpl_getThreadAllocatedMemory1;
Java_sun_management_ThreadImpl_resetContentionTimes0;
Java_sun_management_ThreadImpl_resetPeakThreadCount0;
Java_sun_management_ThreadImpl_setThreadContentionMonitoringEnabled0;
Java_sun_management_ThreadImpl_setThreadCpuTimeEnabled0;
Java_sun_management_ThreadImpl_setThreadAllocatedMemoryEnabled0;
Java_sun_management_VMManagementImpl_getAvailableProcessors;
Java_sun_management_VMManagementImpl_getClassInitializationTime;
Java_sun_management_VMManagementImpl_getClassLoadingTime;
......@@ -106,6 +110,7 @@ SUNWprivate_1.1 {
Java_sun_management_VMManagementImpl_initOptionalSupportFields;
Java_sun_management_VMManagementImpl_isThreadContentionMonitoringEnabled;
Java_sun_management_VMManagementImpl_isThreadCpuTimeEnabled;
Java_sun_management_VMManagementImpl_isThreadAllocatedMemoryEnabled;
JNI_OnLoad;
local:
*;
......
......@@ -296,7 +296,7 @@ ifeq ($(PLATFORM), linux)
OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -lpthread -ldl
endif
ifeq ($(PLATFORM), solaris)
OTHER_LDLIBS += $(JVMLIB) $(LIBSOCKET) -lposix4 -ldl \
OTHER_LDLIBS += $(JVMLIB) $(LIBSOCKET) -lposix4 -ldl -lsendfile \
-L$(LIBDIR)/$(LIBARCH) -ljava -lnet
endif # PLATFORM
......
......@@ -93,10 +93,6 @@ ifeq ($(PLATFORM), windows)
IMPORT_LIST += $(MS_RUNTIME_LIBRARIES:%=$(BINDIR)/%)
# NOTE: These might actually come from BUILDDIR, depends on the settings.
$(BINDIR)/msvcrt.dll: $(MSVCRT_DLL_PATH)/msvcrt.dll
$(install-import-file)
$(call chmod-file, a+x)
$(BINDIR)/$(MSVCRNN_DLL): $(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL)
$(install-import-file)
$(call chmod-file, a+x)
......@@ -223,12 +219,15 @@ endif # PLATFORM
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVM_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVM_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVM_NAME): $(HOTSPOT_KERNEL_PATH)/$(JVM_NAME)
$(install-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(LIBJSIG_NAME): $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME):
......@@ -237,30 +236,39 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME):
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDB_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_CLIENT_PATH)/64/$(JVMDB_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/64/$(JVMDTRACE_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME): $(HOTSPOT_SERVER_PATH)/$(JVM_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
$(LIB_LOCATION)/$(SERVER_LOCATION)/Xusage.txt : $(HOTSPOT_SERVER_PATH)/Xusage.txt
$(install-import-file)
......
......@@ -50,7 +50,7 @@
#
# Assumes basic unix utilities are in the PATH already (uname, hostname, etc.).
#
# On Windows, assumes PROCESSOR_IDENTIFIER, VS71COMNTOOLS,
# On Windows, assumes PROCESSOR_IDENTIFIER, VS100COMNTOOLS,
# SYSTEMROOT (or SystemRoot), COMPUTERNAME (or hostname works), and
# USERNAME is defined in the environment.
# This profile does not rely on using vcvars32.bat and 64bit Setup.bat.
......@@ -81,8 +81,7 @@
# Windows Only:
# ALT_UNIXCOMMAND_PATH
# ALT_DXSDK_PATH
# ALT_MSVCRT_DLL_PATH
# ALT_MSVCR71_DLL_PATH
# ALT_MSVCRNN_DLL_PATH
#
#############################################################################
#
......@@ -213,78 +212,17 @@ else
# Compiler setup (nasty part)
# NOTE: You can use vcvars32.bat to set PATH, LIB, and INCLUDE.
# NOTE: CYGWIN has a link.exe too, make sure the compilers are first
if [ "${windows_arch}" = i586 ] ; then
# 32bit Windows compiler settings
# VisualStudio .NET 2003 VC++ 7.1 (VS71COMNTOOLS should be defined)
vs_root=$(${cygpath} "${VS71COMNTOOLS}/../..")
# Fill in PATH, LIB, and INCLUDE (unset all others to make sure)
vc7_root="${vs_root}/Vc7"
compiler_path="${vc7_root}/bin"
platform_sdk="${vc7_root}/PlatformSDK"
# LIB and INCLUDE must use ; as a separator
include4sdk="${vc7_root}/atlmfc/include"
include4sdk="${include4sdk};${vc7_root}/include"
include4sdk="${include4sdk};${platform_sdk}/include/prerelease"
include4sdk="${include4sdk};${platform_sdk}/include"
include4sdk="${include4sdk};${vs_root}/SDK/v1.1/include"
lib4sdk="${lib4sdk};${vc7_root}/lib"
lib4sdk="${lib4sdk};${platform_sdk}/lib/prerelease"
lib4sdk="${lib4sdk};${platform_sdk}/lib"
lib4sdk="${lib4sdk};${vs_root}/SDK/v1.1/lib"
# Search path and DLL locating path
# WARNING: CYGWIN has a link.exe too, make sure compilers are first
path4sdk="${vs_root}/Common7/Tools/bin;${path4sdk}"
path4sdk="${vs_root}/SDK/v1.1/bin;${path4sdk}"
path4sdk="${vs_root}/Common7/Tools;${path4sdk}"
path4sdk="${vs_root}/Common7/Tools/bin/prerelease;${path4sdk}"
path4sdk="${vs_root}/Common7/IDE;${path4sdk}"
path4sdk="${compiler_path};${path4sdk}"
elif [ "${windows_arch}" = amd64 ] ; then
# AMD64 64bit Windows compiler settings
if [ "${ALT_DEPLOY_MSSDK}" != "" ] ; then
platform_sdk=${ALT_DEPLOY_MSSDK}
else
platform_sdk=$(${cygpath} "C:/Program Files/Microsoft Platform SDK/")
fi
if [ "${ALT_COMPILER_PATH}" != "" ] ; then
compiler_path=${ALT_COMPILER_PATH}
if [ "${ALT_DEPLOY_MSSDK}" = "" ] ; then
platform_sdk=${ALT_COMPILER_PATH}/../../../..
fi
else
compiler_path="${platform_sdk}/Bin/win64/x86/AMD64"
fi
# LIB and INCLUDE must use ; as a separator
include4sdk="${platform_sdk}/Include"
include4sdk="${include4sdk};${platform_sdk}/Include/crt/sys"
include4sdk="${include4sdk};${platform_sdk}/Include/mfc"
include4sdk="${include4sdk};${platform_sdk}/Include/atl"
include4sdk="${include4sdk};${platform_sdk}/Include/crt"
lib4sdk="${platform_sdk}/Lib/AMD64"
lib4sdk="${lib4sdk};${platform_sdk}/Lib/AMD64/atlmfc"
# Search path and DLL locating path
# WARNING: CYGWIN has a link.exe too, make sure compilers are first
path4sdk="${platform_sdk}/bin;${path4sdk}"
path4sdk="${compiler_path};${path4sdk}"
# Use supplied vsvars.sh
repo=`hg root`
if [ -f "${repo}/make/scripts/vsvars.sh" ] ; then
eval `sh ${repo}/make/scripts/vsvars.sh -v10`
elif [ -f "${repo}/../make/scripts/vsvars.sh" ] ; then
eval `sh ${repo}/../make/scripts/vsvars.sh -v10`
else
echo "WARNING: No make/scripts/vsvars.sh file found"
fi
# Export LIB and INCLUDE
unset lib
unset Lib
LIB="${lib4sdk}"
export LIB
unset include
unset Include
INCLUDE="${include4sdk}"
export INCLUDE
# Turn all \\ into /, remove duplicates and trailing /
slash_path="$(echo ${path4sdk} | sed -e 's@\\\\@/@g' -e 's@//@/@g' -e 's@/$@@' -e 's@/;@;@g')"
path4sdk="${slash_path}"
# Convert path4sdk to cygwin style
path4sdk="$(/usr/bin/cygpath -p ${path4sdk})"
fi
# Get the previous JDK to be used to bootstrap the build
......
......@@ -43,7 +43,7 @@ SUBDIRS = \
# Some demos aren't currently included in OpenJDK
ifndef OPENJDK
SUBDIRS += Java2D SwingSet2 Stylepad
SUBDIRS += Java2D SwingSet2 SwingSet3 Stylepad
endif
include $(BUILDDIR)/common/Subdirs.gmk
......
#
# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -24,18 +24,20 @@
#
#
# Build HPI (Host Porting Interface) libraries
# Makefile to build the SwingSet3 demo.
#
BUILDDIR = ../..
BUILDDIR = ../../..
PRODUCT = demo/jfc
DEMONAME = SwingSet3
include $(BUILDDIR)/common/Defs.gmk
DEMO_ROOT = $(CLOSED_SRC)/share/demo/jfc/$(DEMONAME)
DEMO_DESTDIR = $(DEMODIR)/jfc/$(DEMONAME)
DEMO_TOPFILES = ./readme.html ./swingset3.png
DEMO_SKIP_SRCZIP = true
#
# Build specified the HPI implementations
# Demo jar building rules.
#
SUBDIRS = $(HPIS)
include $(BUILDDIR)/common/Subdirs.gmk
all build clean clobber::
$(SUBDIRS-loop)
include $(BUILDDIR)/common/Demo.gmk
......@@ -33,6 +33,7 @@ FILES_java = \
sun/net/ProgressEvent.java \
sun/net/ProgressListener.java \
sun/net/ProgressMeteringPolicy.java \
sun/net/SocksProxy.java \
sun/net/TelnetInputStream.java \
sun/net/TelnetOutputStream.java \
sun/net/TelnetProtocolException.java \
......
......@@ -85,7 +85,6 @@ reorder.jar : $(REORDER_JAR)
libs.reorder :
ifeq ($(PLATFORM), solaris)
$(MAKE) LIBBLDDIR=java/zip LIBTMPDIR=sun/java.util.zip/zip reorder.lib
$(MAKE) LIBBLDDIR=java/hpi/native LIBTMPDIR=java/hpi/native_threads reorder.lib
$(MAKE) LIBBLDDIR=java/java LIBTMPDIR=java/java.lang/java reorder.lib
$(MAKE) LIBBLDDIR=java/nio LIBTMPDIR=java/java.nio/nio reorder.lib
$(MAKE) LIBBLDDIR=sun/font LIBTMPDIR=sun/sun.awt.font/fontmanager reorder.lib
......@@ -96,7 +95,6 @@ endif
libs.copy:
ifeq ($(PLATFORM), solaris)
$(CP) $(OUTDIR)/reorder_java_zip-$(ARCH) ../../java/zip/reorder-$(ARCH)
$(CP) $(OUTDIR)/reorder_java_hpi_native-$(ARCH) ../../java/hpi/native/reorder-$(ARCH)
$(CP) $(OUTDIR)/reorder_java_java-$(ARCH) ../../java/java/reorder-$(ARCH)
$(CP) $(OUTDIR)/reorder_sun_font-$(ARCH) ../../sun/font/reorder-$(ARCH)
$(CP) $(OUTDIR)/reorder_sun_jpeg-$(ARCH) ../../sun/jpeg/reorder-$(ARCH)
......
/*
* Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -133,27 +133,60 @@ set_event_notification(jvmtiEventMode mode, EventIndex ei)
return error;
}
typedef struct {
int major;
int minor;
} version_type;
typedef struct {
version_type runtime;
version_type compiletime;
} compatible_versions_type;
/*
* List of explicitly compatible JVMTI versions, specified as
* { runtime version, compile-time version } pairs. -1 is a wildcard.
*/
static int nof_compatible_versions = 3;
static compatible_versions_type compatible_versions_list[] = {
/*
* FIXUP: Allow version 0 to be compatible with anything
* Special check for FCS of 1.0.
*/
{ { 0, -1 }, { -1, -1 } },
{ { -1, -1 }, { 0, -1 } },
/*
* 1.2 is runtime compatible with 1.1 -- just make sure to check the
* version before using any new 1.2 features
*/
{ { 1, 1 }, { 1, 2 } }
};
/* Logic to determine JVMTI version compatibility */
static jboolean
compatible_versions(jint major_runtime, jint minor_runtime,
jint major_compiletime, jint minor_compiletime)
{
#if 1 /* FIXUP: We allow version 0 to be compatible with anything */
/* Special check for FCS of 1.0. */
if ( major_runtime == 0 || major_compiletime == 0 ) {
return JNI_TRUE;
}
#endif
/* Runtime major version must match. */
if ( major_runtime != major_compiletime ) {
return JNI_FALSE;
}
/* Runtime minor version must be >= the version compiled with. */
if ( minor_runtime < minor_compiletime ) {
return JNI_FALSE;
/*
* First check to see if versions are explicitly compatible via the
* list specified above.
*/
int i;
for (i = 0; i < nof_compatible_versions; ++i) {
version_type runtime = compatible_versions_list[i].runtime;
version_type comptime = compatible_versions_list[i].compiletime;
if ((major_runtime == runtime.major || runtime.major == -1) &&
(minor_runtime == runtime.minor || runtime.minor == -1) &&
(major_compiletime == comptime.major || comptime.major == -1) &&
(minor_compiletime == comptime.minor || comptime.minor == -1)) {
return JNI_TRUE;
}
}
/* Assumed compatible */
return JNI_TRUE;
return major_runtime == major_compiletime &&
minor_runtime >= minor_compiletime;
}
/* OnLoad startup:
......
/*
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -39,6 +39,7 @@
#include "stepControl.h"
#include "threadControl.h"
#include "SDE.h"
#include "jvmti.h"
typedef struct ClassFilter {
jclass clazz;
......@@ -275,6 +276,24 @@ patternStringMatch(char *classname, const char *pattern)
}
}
static jboolean isVersionGte12x() {
jint version;
jvmtiError err =
JVMTI_FUNC_PTR(gdata->jvmti,GetVersionNumber)(gdata->jvmti, &version);
if (err == JVMTI_ERROR_NONE) {
jint major, minor;
major = (version & JVMTI_VERSION_MASK_MAJOR)
>> JVMTI_VERSION_SHIFT_MAJOR;
minor = (version & JVMTI_VERSION_MASK_MINOR)
>> JVMTI_VERSION_SHIFT_MINOR;
return (major > 1 || major == 1 && minor >= 2);
} else {
return JNI_FALSE;
}
}
/* Return the object instance in which the event occurred */
/* Return NULL if static or if an error occurs */
static jobject
......@@ -286,6 +305,14 @@ eventInstance(EventInfo *evinfo)
jint modifiers = 0;
jvmtiError error;
static jboolean got_version = JNI_FALSE;
static jboolean is_version_gte_12x = JNI_FALSE;
if (!got_version) {
is_version_gte_12x = isVersionGte12x();
got_version = JNI_TRUE;
}
switch (evinfo->ei) {
case EI_SINGLE_STEP:
case EI_BREAKPOINT:
......@@ -314,11 +341,18 @@ eventInstance(EventInfo *evinfo)
/* fail if error or static (0x8) */
if (error == JVMTI_ERROR_NONE && thread!=NULL && (modifiers & 0x8) == 0) {
FrameNumber fnum = 0;
/* get slot zero object "this" */
error = JVMTI_FUNC_PTR(gdata->jvmti,GetLocalObject)
(gdata->jvmti, thread, fnum, 0, &object);
if (error != JVMTI_ERROR_NONE)
if (is_version_gte_12x) {
/* Use new 1.2.x function, GetLocalInstance */
error = JVMTI_FUNC_PTR(gdata->jvmti,GetLocalInstance)
(gdata->jvmti, thread, fnum, &object);
} else {
/* get slot zero object "this" */
error = JVMTI_FUNC_PTR(gdata->jvmti,GetLocalObject)
(gdata->jvmti, thread, fnum, 0, &object);
}
if (error != JVMTI_ERROR_NONE) {
object = NULL;
}
}
return object;
......
......@@ -94,15 +94,15 @@ static int numOptions, maxOptions;
* Prototypes for functions internal to launcher.
*/
static void SetClassPath(const char *s);
static void SetModulesBootClassPath(const char *s);
static void SelectVersion(int argc, char **argv, char **main_class);
static jboolean ParseArguments(int *pargc, char ***pargv, char **pjarfile,
char **pclassname, int *pret, const char *jvmpath);
static jboolean ParseArguments(int *pargc, char ***pargv,
int *pmode, char **pwhat,
int *pret, const char *jrepath);
static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv,
InvocationFunctions *ifn);
static jstring NewPlatformString(JNIEnv *env, char *s);
static jobjectArray NewPlatformStringArray(JNIEnv *env, char **strv, int strc);
static jclass LoadMainClass(JNIEnv *env, jboolean isJar, char *name);
static jclass LoadMainClass(JNIEnv *env, int mode, char *name);
static void TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv);
static jboolean AddApplicationOptions(int cpathc, const char **cpathv);
......@@ -158,18 +158,27 @@ static jboolean IsWildCardEnabled();
* Running Java code in primordial thread caused many problems. We will
* create a new thread to invoke JVM. See 6316197 for more information.
*/
static jlong threadStackSize = 0; /* stack size of the new thread */
static jlong threadStackSize = 0; /* stack size of the new thread */
static jlong maxHeapSize = 0; /* max heap size */
static jlong initialHeapSize = 0; /* inital heap size */
int JNICALL JavaMain(void * args); /* entry point */
enum LaunchMode { // cf. sun.launcher.LauncherHelper
LM_UNKNOWN = 0,
LM_CLASS,
LM_JAR
};
static const char *launchModeNames[]
= { "Unknown", "Main class", "JAR file" };
typedef struct {
int argc;
char ** argv;
char * jarfile;
char * classname;
InvocationFunctions ifn;
int argc;
char **argv;
int mode;
char *what;
InvocationFunctions ifn;
} JavaMainArgs;
/*
......@@ -189,8 +198,8 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
jint ergo /* ergonomics class policy */
)
{
char *jarfile = 0;
char *classname = 0;
int mode = LM_UNKNOWN;
char *what = NULL;
char *cpath = 0;
char *main_class = NULL;
int ret;
......@@ -277,24 +286,21 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
SetClassPath(cpath);
}
/*
* Parse command line options; if the return value of
* ParseArguments is false, the program should exit.
/* Parse command line options; if the return value of
* ParseArguments is false, the program should exit.
*/
if (!ParseArguments(&argc, &argv, &jarfile, &classname, &ret, jvmpath)) {
if (!ParseArguments(&argc, &argv, &mode, &what, &ret, jrepath))
{
return(ret);
}
/* Set bootclasspath for modules */
SetModulesBootClassPath(jrepath);
/* Override class path if -jar flag was specified */
if (jarfile != 0) {
SetClassPath(jarfile);
if (mode == LM_JAR) {
SetClassPath(what); /* Override class path */
}
/* set the -Dsun.java.command pseudo property */
SetJavaCommandLineProp(classname, jarfile, argc, argv);
SetJavaCommandLineProp(what, argc, argv);
/* Set the -Dsun.java.launcher pseudo property */
SetJavaLauncherProp();
......@@ -305,7 +311,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
/* Show the splash screen if needed */
ShowSplashScreen();
return ContinueInNewThread(&ifn, argc, argv, jarfile, classname, ret);
return ContinueInNewThread(&ifn, argc, argv, mode, what, ret);
}
/*
......@@ -353,13 +359,13 @@ JavaMain(void * _args)
JavaMainArgs *args = (JavaMainArgs *)_args;
int argc = args->argc;
char **argv = args->argv;
char *jarfile = args->jarfile;
char *classname = args->classname;
int mode = args->mode;
char *what = args->what;
InvocationFunctions ifn = args->ifn;
JavaVM *vm = 0;
JNIEnv *env = 0;
jclass mainClass;
jclass mainClass = NULL;
jmethodID mainID;
jobjectArray mainArgs;
int ret = 0;
......@@ -385,7 +391,7 @@ JavaMain(void * _args)
CHECK_EXCEPTION_LEAVE(1);
}
/* If the user specified neither a class name nor a JAR file */
if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) {
if (printXUsage || printUsage || what == 0 || mode == LM_UNKNOWN) {
PrintUsage(env, printXUsage);
CHECK_EXCEPTION_LEAVE(1);
LEAVE();
......@@ -399,11 +405,11 @@ JavaMain(void * _args)
(long)(jint)Counter2Micros(end-start));
}
/* At this stage, argc/argv have the applications' arguments */
/* At this stage, argc/argv have the application's arguments */
if (JLI_IsTraceLauncher()){
int i;
printf("Main-Class is '%s'\n", classname ? classname : "");
printf("Apps' argc is %d\n", argc);
printf("%s is '%s'\n", launchModeNames[mode], what);
printf("App's argc is %d\n", argc);
for (i=0; i < argc; i++) {
printf(" argv[%2d] = '%s'\n", i, argv[i]);
}
......@@ -431,11 +437,7 @@ JavaMain(void * _args)
* 2) Remove the vestages of maintaining main_class through
* the environment (and remove these comments).
*/
if (jarfile != 0) {
mainClass = LoadMainClass(env, JNI_TRUE, jarfile);
} else {
mainClass = LoadMainClass(env, JNI_FALSE, classname);
}
mainClass = LoadMainClass(env, mode, what);
CHECK_EXCEPTION_NULL_LEAVE(mainClass);
/*
......@@ -697,7 +699,7 @@ AddOption(char *str, void *info)
if (JLI_StrCCmp(str, "-Xms") == 0) {
jlong tmp;
if (parse_size(str + 4, &tmp)) {
initialHeapSize = tmp;
initialHeapSize = tmp;
}
}
}
......@@ -718,44 +720,6 @@ SetClassPath(const char *s)
JLI_MemFree((char *) s);
}
/*
* Set the bootclasspath for modules.
* A temporary workaround until jigsaw is integrated into JDK 7.
*/
static void
SetModulesBootClassPath(const char *jrepath)
{
char *def, *s;
char pathname[MAXPATHLEN];
const char separator[] = { FILE_SEPARATOR, '\0' };
const char *orig = jrepath;
static const char format[] = "-Xbootclasspath/p:%s";
struct stat statbuf;
/* return if jre/lib/rt.jar exists */
JLI_Snprintf(pathname, sizeof(pathname), "%s%slib%srt.jar", jrepath, separator, separator);
if (stat(pathname, &statbuf) == 0) {
return;
}
/* return if jre/classes exists */
JLI_Snprintf(pathname, sizeof(pathname), "%s%sclasses", jrepath, separator);
if (stat(pathname, &statbuf) == 0) {
return;
}
/* modularized jre */
JLI_Snprintf(pathname, sizeof(pathname), "%s%slib%s*", jrepath, separator, separator);
s = (char *) JLI_WildcardExpandClasspath(pathname);
def = JLI_MemAlloc(sizeof(format)
- 2 /* strlen("%s") */
+ JLI_StrLen(s));
sprintf(def, format, s);
AddOption(def, NULL);
if (s != orig)
JLI_MemFree((char *) s);
}
/*
* The SelectVersion() routine ensures that an appropriate version of
* the JRE is running. The specification for the appropriate version
......@@ -1000,16 +964,17 @@ SelectVersion(int argc, char **argv, char **main_class)
/*
* Parses command line arguments. Returns JNI_FALSE if launcher
* should exit without starting vm, returns JNI_TRUE if vm needs
* to be started to process given options. *pret (the launcher
* to be started to process given options. *pret (the launcher
* process return value) is set to 0 for a normal exit.
*/
static jboolean
ParseArguments(int *pargc, char ***pargv, char **pjarfile,
char **pclassname, int *pret, const char *jvmpath)
ParseArguments(int *pargc, char ***pargv,
int *pmode, char **pwhat,
int *pret, const char *jrepath)
{
int argc = *pargc;
char **argv = *pargv;
jboolean jarflag = JNI_FALSE;
int mode = LM_UNKNOWN;
char *arg;
*pret = 0;
......@@ -1019,10 +984,11 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile,
if (JLI_StrCmp(arg, "-classpath") == 0 || JLI_StrCmp(arg, "-cp") == 0) {
ARG_CHECK (argc, ARG_ERROR1, arg);
SetClassPath(*argv);
mode = LM_CLASS;
argv++; --argc;
} else if (JLI_StrCmp(arg, "-jar") == 0) {
ARG_CHECK (argc, ARG_ERROR2, arg);
jarflag = JNI_TRUE;
mode = LM_JAR;
} else if (JLI_StrCmp(arg, "-help") == 0 ||
JLI_StrCmp(arg, "-h") == 0 ||
JLI_StrCmp(arg, "-?") == 0) {
......@@ -1102,19 +1068,24 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile,
}
if (--argc >= 0) {
if (jarflag) {
*pjarfile = *argv++;
*pclassname = NULL;
} else {
*pjarfile = NULL;
*pclassname = *argv++;
}
*pargc = argc;
*pargv = argv;
*pwhat = *argv++;
}
if (*pjarfile == NULL && *pclassname == NULL) {
if (*pwhat == NULL) {
*pret = 1;
} else if (mode == LM_UNKNOWN) {
/* default to LM_CLASS if -jar and -cp option are
* not specified */
mode = LM_CLASS;
}
if (argc >= 0) {
*pargc = argc;
*pargv = argv;
}
*pmode = mode;
return JNI_TRUE;
}
......@@ -1263,7 +1234,7 @@ NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
* call it for more details refer to the java implementation.
*/
static jclass
LoadMainClass(JNIEnv *env, jboolean isJar, char *name)
LoadMainClass(JNIEnv *env, int mode, char *name)
{
jclass cls;
jmethodID mid;
......@@ -1276,9 +1247,9 @@ LoadMainClass(JNIEnv *env, jboolean isJar, char *name)
}
NULL_CHECK0(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, "checkAndLoadMain",
"(ZZLjava/lang/String;)Ljava/lang/Object;"));
"(ZILjava/lang/String;)Ljava/lang/Class;"));
str = (*env)->NewStringUTF(env, name);
result = (*env)->CallStaticObjectMethod(env, cls, mid, JNI_TRUE, isJar, str);
result = (*env)->CallStaticObjectMethod(env, cls, mid, JNI_TRUE, mode, str);
if (JLI_IsTraceLauncher()) {
end = CounterGet();
......@@ -1424,8 +1395,7 @@ AddApplicationOptions(int cpathc, const char **cpathv)
* property is not exported by HotSpot to the Java layer.
*/
void
SetJavaCommandLineProp(char *classname, char *jarfile,
int argc, char **argv)
SetJavaCommandLineProp(char *what, int argc, char **argv)
{
int i = 0;
......@@ -1433,22 +1403,17 @@ SetJavaCommandLineProp(char *classname, char *jarfile,
char* javaCommand = NULL;
char* dashDstr = "-Dsun.java.command=";
if (classname == NULL && jarfile == NULL) {
if (what == NULL) {
/* unexpected, one of these should be set. just return without
* setting the property
*/
return;
}
/* if the class name is not set, then use the jarfile name */
if (classname == NULL) {
classname = jarfile;
}
/* determine the amount of memory to allocate assuming
* the individual components will be space separated
*/
len = JLI_StrLen(classname);
len = JLI_StrLen(what);
for (i = 0; i < argc; i++) {
len += JLI_StrLen(argv[i]) + 1;
}
......@@ -1459,7 +1424,7 @@ SetJavaCommandLineProp(char *classname, char *jarfile,
/* build the -D string */
*javaCommand = '\0';
JLI_StrCat(javaCommand, dashDstr);
JLI_StrCat(javaCommand, classname);
JLI_StrCat(javaCommand, what);
for (i = 0; i < argc; i++) {
/* the components of the string are space separated. In
......@@ -1479,7 +1444,8 @@ SetJavaCommandLineProp(char *classname, char *jarfile,
* JVM would like to know if it's created by a standard Sun launcher, or by
* user native application, the following property indicates the former.
*/
void SetJavaLauncherProp() {
void
SetJavaLauncherProp() {
AddOption("-Dsun.java.launcher=SUN_STANDARD", NULL);
}
......@@ -1913,8 +1879,8 @@ IsWildCardEnabled()
}
static int
ContinueInNewThread(InvocationFunctions* ifn, int argc,
char **argv, char *jarfile, char *classname, int ret)
ContinueInNewThread(InvocationFunctions* ifn, int argc, char **argv,
int mode, char *what, int ret)
{
/*
......@@ -1938,8 +1904,8 @@ ContinueInNewThread(InvocationFunctions* ifn, int argc,
args.argc = argc;
args.argv = argv;
args.jarfile = jarfile;
args.classname = classname;
args.mode = mode;
args.what = what;
args.ifn = *ifn;
rslt = ContinueInNewThread0(JavaMain, threadStackSize, (void*)&args);
......
......@@ -153,7 +153,7 @@ int ContinueInNewThread0(int (JNICALL *continuation)(void *),
/* sun.java.launcher.* platform properties. */
void SetJavaLauncherPlatformProps(void);
void SetJavaCommandLineProp(char* classname, char* jarfile, int argc, char** argv);
void SetJavaCommandLineProp(char* what, int argc, char** argv);
void SetJavaLauncherProp(void);
/*
......@@ -178,8 +178,9 @@ jint GetErgoPolicy();
jboolean ServerClassMachine();
static int ContinueInNewThread(InvocationFunctions* ifn, int argc, char** argv,
char* jarfile, char* classname, int ret);
static int ContinueInNewThread(InvocationFunctions* ifn,
int argc, char** argv,
int mode, char *what, int ret);
/*
* Initialize platform specific settings
......
......@@ -1704,7 +1704,7 @@ class BandStructure {
for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
assert(attrIndexLimit[i] == 0);
attrIndexLimit[i] = 32; // just for the sake of predefs.
attrDefs.set(i, new ArrayList<>(Collections.nCopies(
attrDefs.set(i, new ArrayList<Attribute.Layout>(Collections.nCopies(
attrIndexLimit[i], (Attribute.Layout)null)));
}
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
import java.util.Map;
/**
* Platform-specific management interface for the thread system
* of the Java virtual machine.
* <p>
* This platform extension is only available to a thread
* implementation that supports this extension.
*
* @author Paul Hohensee
* @since 6u25
*/
public interface ThreadMXBean extends java.lang.management.ThreadMXBean {
/**
* Returns the total CPU time for each thread whose ID is
* in the input array {@code ids} in nanoseconds.
* The returned values are of nanoseconds precision but
* not necessarily nanoseconds accuracy.
* <p>
* This method is equivalent to calling the
* {@link ThreadMXBean#getThreadCpuTime(long)}
* method for each thread ID in the input array {@code ids} and setting the
* returned value in the corresponding element of the returned array.
*
* @param ids an array of thread IDs.
* @return an array of long values, each of which is the amount of CPU
* time the thread whose ID is in the corresponding element of the input
* array of IDs has used,
* if the thread of a specified ID exists, the thread is alive,
* and CPU time measurement is enabled;
* {@code -1} otherwise.
*
* @throws NullPointerException if {@code ids} is {@code null}
* @throws IllegalArgumentException if any element in the input array
* {@code ids} is {@code <=} {@code 0}.
* @throws java.lang.UnsupportedOperationException if the Java
* virtual machine implementation does not support CPU time
* measurement.
*
* @see ThreadMXBean#getThreadCpuTime(long)
* @see #getThreadUserTime
* @see ThreadMXBean#isThreadCpuTimeSupported
* @see ThreadMXBean#isThreadCpuTimeEnabled
* @see ThreadMXBean#setThreadCpuTimeEnabled
*/
public long[] getThreadCpuTime(long[] ids);
/**
* Returns the CPU time that each thread whose ID is in the input array
* {@code ids} has executed in user mode in nanoseconds.
* The returned values are of nanoseconds precision but
* not necessarily nanoseconds accuracy.
* <p>
* This method is equivalent to calling the
* {@link ThreadMXBean#getThreadUserTime(long)}
* method for each thread ID in the input array {@code ids} and setting the
* returned value in the corresponding element of the returned array.
*
* @param ids an array of thread IDs.
* @return an array of long values, each of which is the amount of user
* mode CPU time the thread whose ID is in the corresponding element of
* the input array of IDs has used,
* if the thread of a specified ID exists, the thread is alive,
* and CPU time measurement is enabled;
* {@code -1} otherwise.
*
* @throws NullPointerException if {@code ids} is {@code null}
* @throws IllegalArgumentException if any element in the input array
* {@code ids} is {@code <=} {@code 0}.
* @throws java.lang.UnsupportedOperationException if the Java
* virtual machine implementation does not support CPU time
* measurement.
*
* @see ThreadMXBean#getThreadUserTime(long)
* @see #getThreadCpuTime
* @see ThreadMXBean#isThreadCpuTimeSupported
* @see ThreadMXBean#isThreadCpuTimeEnabled
* @see ThreadMXBean#setThreadCpuTimeEnabled
*/
public long[] getThreadUserTime(long[] ids);
/**
* Returns an approximation of the total amount of memory, in bytes,
* allocated in heap memory for the thread of the specified ID.
* The returned value is an approximation because some Java virtual machine
* implementations may use object allocation mechanisms that result in a
* delay between the time an object is allocated and the time its size is
* recorded.
* <p>
* If the thread of the specified ID is not alive or does not exist,
* this method returns {@code -1}. If thread memory allocation measurement
* is disabled, this method returns {@code -1}.
* A thread is alive if it has been started and has not yet died.
* <p>
* If thread memory allocation measurement is enabled after the thread has
* started, the Java virtual machine implementation may choose any time up
* to and including the time that the capability is enabled as the point
* where thread memory allocation measurement starts.
*
* @param id the thread ID of a thread
* @return an approximation of the total memory allocated, in bytes, in
* heap memory for a thread of the specified ID
* if the thread of the specified ID exists, the thread is alive,
* and thread memory allocation measurement is enabled;
* {@code -1} otherwise.
*
* @throws IllegalArgumentException if {@code id} {@code <=} {@code 0}.
* @throws java.lang.UnsupportedOperationException if the Java virtual
* machine implementation does not support thread memory allocation
* measurement.
*
* @see #isThreadAllocatedMemorySupported
* @see #isThreadAllocatedMemoryEnabled
* @see #setThreadAllocatedMemoryEnabled
*/
public long getThreadAllocatedBytes(long id);
/**
* Returns an approximation of the total amount of memory, in bytes,
* allocated in heap memory for each thread whose ID is in the input
* array {@code ids}.
* The returned values are approximations because some Java virtual machine
* implementations may use object allocation mechanisms that result in a
* delay between the time an object is allocated and the time its size is
* recorded.
* <p>
* This method is equivalent to calling the
* {@link #getThreadAllocatedBytes(long)}
* method for each thread ID in the input array {@code ids} and setting the
* returned value in the corresponding element of the returned array.
*
* @param ids an array of thread IDs.
* @return an array of long values, each of which is an approximation of
* the total memory allocated, in bytes, in heap memory for the thread
* whose ID is in the corresponding element of the input array of IDs.
*
* @throws NullPointerException if {@code ids} is {@code null}
* @throws IllegalArgumentException if any element in the input array
* {@code ids} is {@code <=} {@code 0}.
* @throws java.lang.UnsupportedOperationException if the Java virtual
* machine implementation does not support thread memory allocation
* measurement.
*
* @see #getThreadAllocatedBytes(long)
* @see #isThreadAllocatedMemorySupported
* @see #isThreadAllocatedMemoryEnabled
* @see #setThreadAllocatedMemoryEnabled
*/
public long[] getThreadAllocatedBytes(long[] ids);
/**
* Tests if the Java virtual machine implementation supports thread memory
* allocation measurement.
*
* @return
* {@code true}
* if the Java virtual machine implementation supports thread memory
* allocation measurement;
* {@code false} otherwise.
*/
public boolean isThreadAllocatedMemorySupported();
/**
* Tests if thread memory allocation measurement is enabled.
*
* @return {@code true} if thread memory allocation measurement is enabled;
* {@code false} otherwise.
*
* @throws java.lang.UnsupportedOperationException if the Java virtual
* machine does not support thread memory allocation measurement.
*
* @see #isThreadAllocatedMemorySupported
*/
public boolean isThreadAllocatedMemoryEnabled();
/**
* Enables or disables thread memory allocation measurement. The default
* is platform dependent.
*
* @param enable {@code true} to enable;
* {@code false} to disable.
*
* @throws java.lang.UnsupportedOperationException if the Java virtual
* machine does not support thread memory allocation measurement.
*
* @throws java.lang.SecurityException if a security manager
* exists and the caller does not have
* ManagementPermission("control").
*
* @see #isThreadAllocatedMemorySupported
*/
public void setThreadAllocatedMemoryEnabled(boolean enable);
}
......@@ -223,7 +223,9 @@ public final class RhinoScriptEngine extends AbstractScriptEngine
} catch (RhinoException re) {
if (DEBUG) re.printStackTrace();
int line = (line = re.lineNumber()) == 0 ? -1 : line;
throw new ScriptException(re.toString(), re.sourceName(), line);
ScriptException se = new ScriptException(re.toString(), re.sourceName(), line);
se.initCause(re);
throw se;
} finally {
cx.exit();
}
......@@ -257,6 +259,8 @@ public final class RhinoScriptEngine extends AbstractScriptEngine
" str = 'null'; \n" +
" } \n" +
" var out = context.getWriter(); \n" +
" if (!(out instanceof java.io.PrintWriter))\n" +
" out = new java.io.PrintWriter(out); \n" +
" out.print(String(str)); \n" +
" if (newline) out.print('\\n'); \n" +
" out.flush(); \n" +
......
......@@ -1180,7 +1180,7 @@ public class PolicyFile extends javax.security.auth.Policy {
// Done
return certs;
ArrayList<Certificate> userCertList = new ArrayList<Certificate>();
ArrayList<Certificate> userCertList = new ArrayList<>();
i = 0;
while (i < certs.length) {
userCertList.add(certs[i]);
......
......@@ -99,10 +99,10 @@ public class DialogCallbackHandler implements CallbackHandler {
throws UnsupportedCallbackException
{
/* Collect messages to display in the dialog */
final List<Object> messages = new ArrayList<Object>(3);
final List<Object> messages = new ArrayList<>(3);
/* Collection actions to perform if the user clicks OK */
final List<Action> okActions = new ArrayList<Action>(2);
final List<Action> okActions = new ArrayList<>(2);
ConfirmationInfo confirmation = new ConfirmationInfo();
......
......@@ -152,7 +152,7 @@ public class ConfigFile extends javax.security.auth.login.Configuration {
// new configuration
HashMap<String, LinkedList<AppConfigurationEntry>> newConfig =
new HashMap<String, LinkedList<AppConfigurationEntry>>();
new HashMap<>();
if (url != null) {
......@@ -392,8 +392,7 @@ public class ConfigFile extends javax.security.auth.login.Configuration {
String moduleClass;
String sflag;
AppConfigurationEntry.LoginModuleControlFlag controlFlag;
LinkedList<AppConfigurationEntry> configEntries =
new LinkedList<AppConfigurationEntry>();
LinkedList<AppConfigurationEntry> configEntries = new LinkedList<>();
// application name
appName = st.sval;
......@@ -433,7 +432,7 @@ public class ConfigFile extends javax.security.auth.login.Configuration {
}
// get the args
HashMap<String, String> options = new HashMap<String, String>();
HashMap<String, String> options = new HashMap<>();
String key;
String value;
while (peek(";") == false) {
......
......@@ -184,7 +184,7 @@ public class JndiLoginModule implements LoginModule {
private UnixNumericUserPrincipal UIDPrincipal;
private UnixNumericGroupPrincipal GIDPrincipal;
private LinkedList<UnixNumericGroupPrincipal> supplementaryGroups =
new LinkedList<UnixNumericGroupPrincipal>();
new LinkedList<>();
// initial state
private Subject subject;
......
......@@ -658,8 +658,7 @@ public class KeyStoreLoginModule implements LoginModule {
throw new FailedLoginException(
"Unable to find X.509 certificate chain in keystore");
} else {
LinkedList<Certificate> certList =
new LinkedList<Certificate>();
LinkedList<Certificate> certList = new LinkedList<>();
for (int i=0; i < fromKeyStore.length; i++) {
certList.add(fromKeyStore[i]);
}
......
......@@ -76,7 +76,7 @@ public class SolarisLoginModule implements LoginModule {
private SolarisNumericUserPrincipal UIDPrincipal;
private SolarisNumericGroupPrincipal GIDPrincipal;
private LinkedList<SolarisNumericGroupPrincipal> supplementaryGroups =
new LinkedList<SolarisNumericGroupPrincipal>();
new LinkedList<>();
/**
* Initialize this <code>LoginModule</code>.
......
......@@ -70,7 +70,7 @@ public class UnixLoginModule implements LoginModule {
private UnixNumericUserPrincipal UIDPrincipal;
private UnixNumericGroupPrincipal GIDPrincipal;
private LinkedList<UnixNumericGroupPrincipal> supplementaryGroups =
new LinkedList<UnixNumericGroupPrincipal>();
new LinkedList<>();
/**
* Initialize this <code>LoginModule</code>.
......
......@@ -329,7 +329,7 @@ public class ObjectStreamClass implements Serializable {
entry = th;
}
if (future.set(entry)) {
Caches.localDescs.put(key, new SoftReference<>(entry));
Caches.localDescs.put(key, new SoftReference<Object>(entry));
} else {
// nested lookup call already set future
entry = future.get();
......@@ -2118,7 +2118,7 @@ public class ObjectStreamClass implements Serializable {
entry = th;
}
future.set(entry);
Caches.reflectors.put(key, new SoftReference<>(entry));
Caches.reflectors.put(key, new SoftReference<Object>(entry));
}
if (entry instanceof FieldReflector) {
......
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -27,7 +27,9 @@ package java.io;
import java.util.Formatter;
import java.util.Locale;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
/**
* A <code>PrintStream</code> adds functionality to another output stream,
......@@ -56,7 +58,7 @@ public class PrintStream extends FilterOutputStream
implements Appendable, Closeable
{
private boolean autoFlush = false;
private final boolean autoFlush;
private boolean trouble = false;
private Formatter formatter;
......@@ -68,36 +70,69 @@ public class PrintStream extends FilterOutputStream
private OutputStreamWriter charOut;
/**
* Creates a new print stream. This stream will not flush automatically.
*
* @param out The output stream to which values and objects will be
* printed
*
* @see java.io.PrintWriter#PrintWriter(java.io.OutputStream)
* nonNull is explicitly declared here so as not to create an extra
* dependency on java.util.Objects.nonNull. PrintStream is loaded
* early during system initialization.
*/
public PrintStream(OutputStream out) {
this(out, false);
private static <T> T nonNull(T obj, String message) {
if (obj == null)
throw new NullPointerException(message);
return obj;
}
/* Initialization is factored into a private constructor (note the swapped
* parameters so that this one isn't confused with the public one) and a
* separate init method so that the following two public constructors can
* share code. We use a separate init method so that the constructor that
* takes an encoding will throw an NPE for a null stream before it throws
* an UnsupportedEncodingException for an unsupported encoding.
/**
* Returns a charset object for the given charset name.
* @throws NullPointerException is csn is null
* @throws UnsupportedEncodingException if the charset is not supported
*/
private PrintStream(boolean autoFlush, OutputStream out)
private static Charset toCharset(String csn)
throws UnsupportedEncodingException
{
nonNull(csn, "charsetName");
try {
return Charset.forName(csn);
} catch (IllegalCharsetNameException|UnsupportedCharsetException unused) {
// UnsupportedEncodingException should be thrown
throw new UnsupportedEncodingException(csn);
}
}
/* Private constructors */
private PrintStream(boolean autoFlush, OutputStream out) {
super(out);
this.autoFlush = autoFlush;
this.charOut = new OutputStreamWriter(this);
this.textOut = new BufferedWriter(charOut);
}
private PrintStream(boolean autoFlush, OutputStream out, Charset charset) {
super(out);
if (out == null)
throw new NullPointerException("Null output stream");
this.autoFlush = autoFlush;
this.charOut = new OutputStreamWriter(this, charset);
this.textOut = new BufferedWriter(charOut);
}
private void init(OutputStreamWriter osw) {
this.charOut = osw;
this.textOut = new BufferedWriter(osw);
/* Variant of the private constructor so that the given charset name
* can be verified before evaluating the OutputStream argument. Used
* by constructors creating a FileOutputStream that also take a
* charset name.
*/
private PrintStream(boolean autoFlush, Charset charset, OutputStream out)
throws UnsupportedEncodingException
{
this(autoFlush, out, charset);
}
/**
* Creates a new print stream. This stream will not flush automatically.
*
* @param out The output stream to which values and objects will be
* printed
*
* @see java.io.PrintWriter#PrintWriter(java.io.OutputStream)
*/
public PrintStream(OutputStream out) {
this(out, false);
}
/**
......@@ -113,8 +148,7 @@ public class PrintStream extends FilterOutputStream
* @see java.io.PrintWriter#PrintWriter(java.io.OutputStream, boolean)
*/
public PrintStream(OutputStream out, boolean autoFlush) {
this(autoFlush, out);
init(new OutputStreamWriter(this));
this(autoFlush, nonNull(out, "Null output stream"));
}
/**
......@@ -138,8 +172,9 @@ public class PrintStream extends FilterOutputStream
public PrintStream(OutputStream out, boolean autoFlush, String encoding)
throws UnsupportedEncodingException
{
this(autoFlush, out);
init(new OutputStreamWriter(this, encoding));
this(autoFlush,
nonNull(out, "Null output stream"),
toCharset(encoding));
}
/**
......@@ -171,7 +206,6 @@ public class PrintStream extends FilterOutputStream
*/
public PrintStream(String fileName) throws FileNotFoundException {
this(false, new FileOutputStream(fileName));
init(new OutputStreamWriter(this));
}
/**
......@@ -210,8 +244,8 @@ public class PrintStream extends FilterOutputStream
public PrintStream(String fileName, String csn)
throws FileNotFoundException, UnsupportedEncodingException
{
this(false, new FileOutputStream(fileName));
init(new OutputStreamWriter(this, csn));
// ensure charset is checked before the file is opened
this(false, toCharset(csn), new FileOutputStream(fileName));
}
/**
......@@ -243,7 +277,6 @@ public class PrintStream extends FilterOutputStream
*/
public PrintStream(File file) throws FileNotFoundException {
this(false, new FileOutputStream(file));
init(new OutputStreamWriter(this));
}
/**
......@@ -282,8 +315,8 @@ public class PrintStream extends FilterOutputStream
public PrintStream(File file, String csn)
throws FileNotFoundException, UnsupportedEncodingException
{
this(false, new FileOutputStream(file));
init(new OutputStreamWriter(this, csn));
// ensure charset is checked before the file is opened
this(false, toCharset(csn), new FileOutputStream(file));
}
/** Check to make sure that the stream has not been closed */
......
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,8 +25,12 @@
package java.io;
import java.util.Objects;
import java.util.Formatter;
import java.util.Locale;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
/**
* Prints formatted representations of objects to a text-output stream. This
......@@ -59,7 +63,7 @@ public class PrintWriter extends Writer {
*/
protected Writer out;
private boolean autoFlush = false;
private final boolean autoFlush;
private boolean trouble = false;
private Formatter formatter;
private PrintStream psOut = null;
......@@ -68,7 +72,24 @@ public class PrintWriter extends Writer {
* Line separator string. This is the value of the line.separator
* property at the moment that the stream was created.
*/
private String lineSeparator;
private final String lineSeparator;
/**
* Returns a charset object for the given charset name.
* @throws NullPointerException is csn is null
* @throws UnsupportedEncodingException if the charset is not supported
*/
private static Charset toCharset(String csn)
throws UnsupportedEncodingException
{
Objects.nonNull(csn, "charsetName");
try {
return Charset.forName(csn);
} catch (IllegalCharsetNameException|UnsupportedCharsetException unused) {
// UnsupportedEncodingException should be thrown
throw new UnsupportedEncodingException(csn);
}
}
/**
* Creates a new PrintWriter, without automatic line flushing.
......@@ -164,6 +185,14 @@ public class PrintWriter extends Writer {
false);
}
/* Private constructor */
private PrintWriter(Charset charset, File file)
throws FileNotFoundException
{
this(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)),
false);
}
/**
* Creates a new PrintWriter, without automatic line flushing, with the
* specified file name and charset. This convenience constructor creates
......@@ -200,8 +229,7 @@ public class PrintWriter extends Writer {
public PrintWriter(String fileName, String csn)
throws FileNotFoundException, UnsupportedEncodingException
{
this(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), csn)),
false);
this(toCharset(csn), new File(fileName));
}
/**
......@@ -272,8 +300,7 @@ public class PrintWriter extends Writer {
public PrintWriter(File file, String csn)
throws FileNotFoundException, UnsupportedEncodingException
{
this(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), csn)),
false);
this(toCharset(csn), file);
}
/** Checks to make sure that the stream has not been closed */
......
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -33,7 +33,7 @@ package java.lang;
*/
public interface AutoCloseable {
/**
* Close this resource, relinquishing any underlying resources.
* Closes this resource, relinquishing any underlying resources.
* This method is invoked automatically by the {@code
* try}-with-resources statement.
*
......@@ -48,6 +48,10 @@ public interface AutoCloseable {
* visible side effect, unlike {@code Closeable.close} which is
* required to have no effect if called more than once.
*
* However, while not required to be idempotent, implementers of
* this interface are strongly encouraged to make their {@code
* close} methods idempotent.
*
* @throws Exception if this resource cannot be closed
*/
void close() throws Exception;
......
......@@ -67,7 +67,7 @@ class StringCoding {
}
private static <T> void set(ThreadLocal<SoftReference<T>> tl, T ob) {
tl.set(new SoftReference<>(ob));
tl.set(new SoftReference<T>(ob));
}
// Trim the given byte array to the given length
......
/*
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -809,7 +809,7 @@ public class Throwable implements Serializable {
native StackTraceElement getStackTraceElement(int index);
/**
* Read a {@code Throwable} from a stream, enforcing
* Reads a {@code Throwable} from a stream, enforcing
* well-formedness constraints on fields. Null entries and
* self-pointers are not allowed in the list of {@code
* suppressedExceptions}. Null entries are not allowed for stack
......@@ -865,9 +865,10 @@ public class Throwable implements Serializable {
}
/**
* Adds the specified exception to the list of exceptions that
* were suppressed, typically by the {@code try}-with-resources
* statement, in order to deliver this exception.
* Appends the specified exception to the exceptions that were
* suppressed in order to deliver this exception. This method is
* typically called (automatically and implicitly) by the {@code
* try}-with-resources statement.
*
* If the first exception to be suppressed is {@code null}, that
* indicates suppressed exception information will <em>not</em> be
......
......@@ -677,8 +677,7 @@ class InetAddress implements java.io.Serializable {
static InetAddressImpl impl;
private static HashMap<String, InetAddress[]> lookupTable
= new HashMap<String, InetAddress[]>();
private static final HashMap<String, Void> lookupTable = new HashMap<>();
/**
* Represents a cache entry
......@@ -737,7 +736,7 @@ class InetAddress implements java.io.Serializable {
// As we iterate in insertion order we can
// terminate when a non-expired entry is found.
LinkedList<String> expired = new LinkedList<String>();
LinkedList<String> expired = new LinkedList<>();
long now = System.currentTimeMillis();
for (String key : cache.keySet()) {
CacheEntry entry = cache.get(key);
......@@ -1227,43 +1226,45 @@ class InetAddress implements java.io.Serializable {
// lookupTable and return null so the
// following code would do a lookup itself.
if ((addresses = checkLookupTable(host)) == null) {
// This is the first thread which looks up the addresses
// this host or the cache entry for this host has been
// expired so this thread should do the lookup.
for (NameService nameService : nameServices) {
try {
/*
* Do not put the call to lookup() inside the
* constructor. if you do you will still be
* allocating space when the lookup fails.
*/
addresses = nameService.lookupAllHostAddr(host);
success = true;
break;
} catch (UnknownHostException uhe) {
if (host.equalsIgnoreCase("localhost")) {
InetAddress[] local = new InetAddress[] { impl.loopbackAddress() };
addresses = local;
try {
// This is the first thread which looks up the addresses
// this host or the cache entry for this host has been
// expired so this thread should do the lookup.
for (NameService nameService : nameServices) {
try {
/*
* Do not put the call to lookup() inside the
* constructor. if you do you will still be
* allocating space when the lookup fails.
*/
addresses = nameService.lookupAllHostAddr(host);
success = true;
break;
}
else {
addresses = unknown_array;
success = false;
ex = uhe;
} catch (UnknownHostException uhe) {
if (host.equalsIgnoreCase("localhost")) {
InetAddress[] local = new InetAddress[] { impl.loopbackAddress() };
addresses = local;
success = true;
break;
}
else {
addresses = unknown_array;
success = false;
ex = uhe;
}
}
}
}
// Cache the addresses.
cacheAddresses(host, addresses, success);
// Delete the host from the lookupTable, and
// notify all threads waiting for the monitor
// for lookupTable.
updateLookupTable(host);
if (!success && ex != null)
throw ex;
// Cache the addresses.
cacheAddresses(host, addresses, success);
if (!success && ex != null)
throw ex;
} finally {
// Delete host from the lookupTable and notify
// all threads waiting on the lookupTable monitor.
updateLookupTable(host);
}
}
return addresses;
......@@ -1271,16 +1272,13 @@ class InetAddress implements java.io.Serializable {
private static InetAddress[] checkLookupTable(String host) {
// make sure addresses is null.
InetAddress[] addresses = null;
synchronized (lookupTable) {
// If the host isn't in the lookupTable, add it in the
// lookuptable and return null. The caller should do
// the lookup.
if (lookupTable.containsKey(host) == false) {
lookupTable.put(host, null);
return addresses;
return null;
}
// If the host is in the lookupTable, it means that another
......@@ -1298,10 +1296,11 @@ class InetAddress implements java.io.Serializable {
// the host. This thread should retry to get the addresses
// from the addressCache. If it doesn't get the addresses from
// the cache, it will try to look up the addresses itself.
addresses = getCachedAddresses(host);
InetAddress[] addresses = getCachedAddresses(host);
if (addresses == null) {
synchronized (lookupTable) {
lookupTable.put(host, null);
return null;
}
}
......
......@@ -493,55 +493,44 @@ public final class NetworkInterface {
* @see java.net.InetAddress#getAddress()
*/
public boolean equals(Object obj) {
if ((obj == null) || !(obj instanceof NetworkInterface)) {
if (!(obj instanceof NetworkInterface)) {
return false;
}
NetworkInterface netIF = (NetworkInterface)obj;
if (name != null ) {
if (netIF.getName() != null) {
if (!name.equals(netIF.getName())) {
return false;
}
} else {
NetworkInterface that = (NetworkInterface)obj;
if (this.name != null ) {
if (!this.name.equals(that.name)) {
return false;
}
} else {
if (netIF.getName() != null) {
if (that.name != null) {
return false;
}
}
Enumeration newAddrs = netIF.getInetAddresses();
int i = 0;
for (i = 0; newAddrs.hasMoreElements();newAddrs.nextElement(), i++);
if (addrs == null) {
if (i != 0) {
return false;
}
} else {
/*
* Compare number of addresses (in the checked subset)
*/
int count = 0;
Enumeration e = getInetAddresses();
for (; e.hasMoreElements(); count++) {
e.nextElement();
}
if (i != count) {
return false;
}
if (this.addrs == null) {
return that.addrs == null;
} else if (that.addrs == null) {
return false;
}
/* Both addrs not null. Compare number of addresses */
if (this.addrs.length != that.addrs.length) {
return false;
}
newAddrs = netIF.getInetAddresses();
for (; newAddrs.hasMoreElements();) {
boolean equal = false;
Enumeration thisAddrs = getInetAddresses();
InetAddress newAddr = (InetAddress)newAddrs.nextElement();
for (; thisAddrs.hasMoreElements();) {
InetAddress thisAddr = (InetAddress)thisAddrs.nextElement();
if (thisAddr.equals(newAddr)) {
equal = true;
InetAddress[] thatAddrs = that.addrs;
int count = thatAddrs.length;
for (int i=0; i<count; i++) {
boolean found = false;
for (int j=0; j<count; j++) {
if (addrs[i].equals(thatAddrs[j])) {
found = true;
break;
}
}
if (!equal) {
if (!found) {
return false;
}
}
......@@ -549,12 +538,7 @@ public final class NetworkInterface {
}
public int hashCode() {
int count = name == null? 0: name.hashCode();
Enumeration<InetAddress> addrs = getInetAddresses();
while (addrs.hasMoreElements()) {
count += addrs.nextElement().hashCode();
}
return count;
return name == null? 0: name.hashCode();
}
public String toString() {
......
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -29,6 +29,7 @@ import java.io.OutputStream;
import java.io.BufferedOutputStream;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import sun.net.SocksProxy;
import sun.net.www.ParseUtil;
/* import org.ietf.jgss.*; */
......@@ -397,6 +398,11 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
// Use getHostString() to avoid reverse lookups
server = ((InetSocketAddress) p.address()).getHostString();
serverPort = ((InetSocketAddress) p.address()).getPort();
if (p instanceof SocksProxy) {
if (((SocksProxy)p).protocolVersion() == 4) {
useV4 = true;
}
}
// Connects to the SOCKS server
try {
......@@ -700,6 +706,11 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
// Use getHostString() to avoid reverse lookups
server = ((InetSocketAddress) p.address()).getHostString();
serverPort = ((InetSocketAddress) p.address()).getPort();
if (p instanceof SocksProxy) {
if (((SocksProxy)p).protocolVersion() == 4) {
useV4 = true;
}
}
// Connects to the SOCKS server
try {
......
......@@ -27,19 +27,15 @@ package java.net;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.io.File;
import java.io.FilePermission;
import java.io.InputStream;
import java.io.IOException;
import java.io.Closeable;
import java.lang.ref.*;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandlerFactory;
import java.util.Enumeration;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.*;
import java.util.jar.Manifest;
import java.util.jar.JarFile;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
import java.security.CodeSigner;
......@@ -194,6 +190,65 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
acc = AccessController.getContext();
}
/* A map (used as a set) to keep track of closeable local resources
* (either JarFiles or FileInputStreams). We don't care about
* Http resources since they don't need to be closed.
*
* If the resource is coming from a jar file
* we keep a (weak) reference to the JarFile object which can
* be closed if URLClassLoader.close() called. Due to jar file
* caching there will typically be only one JarFile object
* per underlying jar file.
*
* For file resources, which is probably a less common situation
* we have to keep a weak reference to each stream.
*/
private WeakHashMap<Closeable,Void>
closeables = new WeakHashMap<>();
/**
* Returns an input stream for reading the specified resource.
* If this loader is closed, then any resources opened by this method
* will be closed.
*
* <p> The search order is described in the documentation for {@link
* #getResource(String)}. </p>
*
* @param name
* The resource name
*
* @return An input stream for reading the resource, or <tt>null</tt>
* if the resource could not be found
*
* @since 1.7
*/
public InputStream getResourceAsStream(String name) {
URL url = getResource(name);
try {
if (url == null) {
return null;
}
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream();
if (urlc instanceof JarURLConnection) {
JarURLConnection juc = (JarURLConnection)urlc;
JarFile jar = juc.getJarFile();
synchronized (closeables) {
if (!closeables.containsKey(jar)) {
closeables.put(jar, null);
}
}
} else if (urlc instanceof sun.net.www.protocol.file.FileURLConnection) {
synchronized (closeables) {
closeables.put(is, null);
}
}
return is;
} catch (IOException e) {
return null;
}
}
/**
* Closes this URLClassLoader, so that it can no longer be used to load
......@@ -202,8 +257,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* delegation hierarchy are still accessible. Also, any classes or resources
* that are already loaded, are still accessible.
* <p>
* In the case of jar: and file: URLs, it also closes any class files,
* or JAR files that were opened by it. If another thread is loading a
* In the case of jar: and file: URLs, it also closes any files
* that were opened by it. If another thread is loading a
* class when the {@code close} method is invoked, then the result of
* that load is undefined.
* <p>
......@@ -213,10 +268,10 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* loader has no effect.
* <p>
* @throws IOException if closing any file opened by this class loader
* resulted in an IOException. Any such exceptions are caught, and a
* single IOException is thrown after the last file has been closed.
* If only one exception was thrown, it will be set as the <i>cause</i>
* of this IOException.
* resulted in an IOException. Any such exceptions are caught internally.
* If only one is caught, then it is re-thrown. If more than one exception
* is caught, then the second and following exceptions are added
* as suppressed exceptions of the first one caught, which is then re-thrown.
*
* @throws SecurityException if a security manager is set, and it denies
* {@link RuntimePermission}<tt>("closeClassLoader")</tt>
......@@ -229,21 +284,33 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
security.checkPermission(new RuntimePermission("closeClassLoader"));
}
List<IOException> errors = ucp.closeLoaders();
// now close any remaining streams.
synchronized (closeables) {
Set<Closeable> keys = closeables.keySet();
for (Closeable c : keys) {
try {
c.close();
} catch (IOException ioex) {
errors.add(ioex);
}
}
closeables.clear();
}
if (errors.isEmpty()) {
return;
}
if (errors.size() == 1) {
throw new IOException (
"Error closing URLClassLoader resource",
errors.get(0)
);
}
// Several exceptions. So, just combine the error messages
String errormsg = "Error closing resources: ";
IOException firstex = errors.remove(0);
// Suppress any remaining exceptions
for (IOException error: errors) {
errormsg = errormsg + "[" + error.toString() + "] ";
firstex.addSuppressed(error);
}
throw new IOException (errormsg);
throw firstex;
}
/**
......
......@@ -127,10 +127,15 @@ of proxies.</P>
are specified. If SOCKS is supported by a Java SE implementation, the
following properties will be used:</P>
<UL>
<LI><P><B>socksProxyHost</B> (default: &lt;non&gt;)<BR>
<LI><P><B>socksProxyHost</B> (default: &lt;none&gt;)<BR>
The hostname, or address, of the proxy server.</P>
<LI><P><B>socksProxyPort</B> (default: 1080)<BR>
The port number of the proxy server.</P>
<LI><P><B>socksProxyVersion</B> (default: 5)<BR>
The version of the SOCKS protocol supported by the server. The
default is <code>5</code> indicating SOCKS V5, alternatively
<code>4</code> can be specified for SOCKS V4. Setting the property
to values other than these leads to unspecified behavior.</P>
<LI><P><B>java.net.socks.username</B> (default: &lt;none&gt;)<BR>
Username to use if the SOCKSv5 server asks for authentication
and no java.net.Authenticator instance was found.</P>
......
......@@ -121,7 +121,7 @@ public final class AccessControlContext {
this.context = null;
}
} else {
List<ProtectionDomain> v = new ArrayList<ProtectionDomain>(context.length);
List<ProtectionDomain> v = new ArrayList<>(context.length);
for (int i =0; i< context.length; i++) {
if ((context[i] != null) && (!v.contains(context[i])))
v.add(context[i]);
......
......@@ -515,7 +515,7 @@ implements java.io.Serializable
// Copy perms into a Hashtable
Hashtable<String, Permission> permissions =
new Hashtable<String, Permission>(perms.size()*2);
new Hashtable<>(perms.size()*2);
synchronized (this) {
permissions.putAll(perms);
......
......@@ -188,7 +188,7 @@ public class CodeSource implements java.io.Serializable {
} else if (signers != null) {
// Convert the code signers to certs
ArrayList<java.security.cert.Certificate> certChains =
new ArrayList<java.security.cert.Certificate>();
new ArrayList<>();
for (int i = 0; i < signers.length; i++) {
certChains.addAll(
signers[i].getSignerCertPath().getCertificates());
......@@ -606,10 +606,10 @@ public class CodeSource implements java.io.Serializable {
// Iterate through all the certificates
int i = 0;
List<CodeSigner> signers = new ArrayList<CodeSigner>();
List<CodeSigner> signers = new ArrayList<>();
while (i < certs.length) {
List<java.security.cert.Certificate> certChain =
new ArrayList<java.security.cert.Certificate>();
new ArrayList<>();
certChain.add(certs[i++]); // first cert is an end-entity cert
int j = i;
......
......@@ -362,7 +362,7 @@ implements Serializable
// Copy perms into a Hashtable
Hashtable<Class<?>, PermissionCollection> perms =
new Hashtable<Class<?>, PermissionCollection>(permsMap.size()*2); // no sync; estimate
new Hashtable<>(permsMap.size()*2); // no sync; estimate
synchronized (this) {
perms.putAll(permsMap);
}
......@@ -567,7 +567,7 @@ implements Serializable
// Copy perms into a Hashtable
Hashtable<Permission, Permission> perms =
new Hashtable<Permission, Permission>(permsMap.size()*2);
new Hashtable<>(permsMap.size()*2);
synchronized (this) {
perms.putAll(permsMap);
}
......
......@@ -336,8 +336,8 @@ public class ProtectionDomain {
int swag = 32;
int vcap = 8;
Enumeration<Permission> e;
List<Permission> pdVector = new ArrayList<Permission>(vcap);
List<Permission> plVector = new ArrayList<Permission>(swag);
List<Permission> pdVector = new ArrayList<>(vcap);
List<Permission> plVector = new ArrayList<>(swag);
//
// Build a vector of domain permissions for subsequent merge
......
......@@ -437,7 +437,7 @@ public abstract class Provider extends Properties {
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
Map<Object,Object> copy = new HashMap<Object,Object>();
Map<Object,Object> copy = new HashMap<>();
for (Map.Entry<Object,Object> entry : super.entrySet()) {
copy.put(entry.getKey(), entry.getValue());
}
......@@ -719,7 +719,7 @@ public abstract class Provider extends Properties {
}
if (serviceSet == null) {
ensureLegacyParsed();
Set<Service> set = new LinkedHashSet<Service>();
Set<Service> set = new LinkedHashSet<>();
if (serviceMap != null) {
set.addAll(serviceMap.values());
}
......@@ -1395,7 +1395,7 @@ public abstract class Provider extends Properties {
if (s != null) {
String[] classNames = s.split("\\|");
List<Class> classList =
new ArrayList<Class>(classNames.length);
new ArrayList<>(classNames.length);
for (String className : classNames) {
Class clazz = getKeyClass(className);
if (clazz != null) {
......
......@@ -50,7 +50,7 @@ public class SecureClassLoader extends ClassLoader {
// HashMap that maps CodeSource to ProtectionDomain
// @GuardedBy("pdcache")
private final HashMap<CodeSource, ProtectionDomain> pdcache =
new HashMap<CodeSource, ProtectionDomain>(11);
new HashMap<>(11);
private static final Debug debug = Debug.getInstance("scl");
......
......@@ -545,8 +545,7 @@ public final class Security {
value = filter.substring(index + 1);
}
Hashtable<String, String> hashtableFilter =
new Hashtable<String, String>(1);
Hashtable<String, String> hashtableFilter = new Hashtable<>(1);
hashtableFilter.put(key, value);
return (getProviders(hashtableFilter));
......@@ -606,7 +605,7 @@ public final class Security {
// Then only return those providers who satisfy the selection criteria.
Provider[] allProviders = Security.getProviders();
Set<String> keySet = filter.keySet();
LinkedHashSet<Provider> candidates = new LinkedHashSet<Provider>(5);
LinkedHashSet<Provider> candidates = new LinkedHashSet<>(5);
// Returns all installed providers
// if the selection criteria is null.
......@@ -660,8 +659,7 @@ public final class Security {
}
// Map containing cached Spi Class objects of the specified type
private static final Map<String,Class> spiMap =
new ConcurrentHashMap<String,Class>();
private static final Map<String, Class> spiMap = new ConcurrentHashMap<>();
/**
* Return the Class object for the given engine type
......@@ -885,7 +883,7 @@ public final class Security {
String attrName,
String filterValue,
Provider[] allProviders) {
LinkedHashSet<Provider> candidates = new LinkedHashSet<Provider>(5);
LinkedHashSet<Provider> candidates = new LinkedHashSet<>(5);
for (int i = 0; i < allProviders.length; i++) {
if (isCriterionSatisfied(allProviders[i], serviceName,
algName,
......@@ -1082,7 +1080,7 @@ public final class Security {
return Collections.EMPTY_SET;
}
HashSet<String> result = new HashSet<String>();
HashSet<String> result = new HashSet<>();
Provider[] providers = Security.getProviders();
for (int i = 0; i < providers.length; i++) {
......
......@@ -198,7 +198,7 @@ implements java.io.Serializable
if (this.certs == null) {
// extract the signer certs
ArrayList<java.security.cert.Certificate> signerCerts =
new ArrayList<java.security.cert.Certificate>();
new ArrayList<>();
i = 0;
while (i < certs.length) {
signerCerts.add(certs[i]);
......
......@@ -119,7 +119,7 @@ implements java.io.Serializable
public Enumeration<Permission> elements() {
List<Permission> results =
new ArrayList<Permission>(); // where results are stored
new ArrayList<>(); // where results are stored
// Get iterator of Map values (which are lists of permissions)
synchronized (this) {
......@@ -161,7 +161,7 @@ implements java.io.Serializable
// Copy perms into a Hashtable
Hashtable<String, Vector<UnresolvedPermission>> permissions =
new Hashtable<String, Vector<UnresolvedPermission>>(perms.size()*2);
new Hashtable<>(perms.size()*2);
// Convert each entry (List) into a Vector
synchronized (this) {
......@@ -169,8 +169,7 @@ implements java.io.Serializable
for (Map.Entry<String, List<UnresolvedPermission>> e : set) {
// Convert list into Vector
List<UnresolvedPermission> list = e.getValue();
Vector<UnresolvedPermission> vec =
new Vector<UnresolvedPermission>(list.size());
Vector<UnresolvedPermission> vec = new Vector<>(list.size());
synchronized (list) {
vec.addAll(list);
}
......@@ -207,8 +206,7 @@ implements java.io.Serializable
for (Map.Entry<String, Vector<UnresolvedPermission>> e : set) {
// Convert Vector into ArrayList
Vector<UnresolvedPermission> vec = e.getValue();
List<UnresolvedPermission> list =
new ArrayList<UnresolvedPermission>(vec.size());
List<UnresolvedPermission> list = new ArrayList<>(vec.size());
list.addAll(vec);
// Add to Hashtable being serialized
......
......@@ -473,7 +473,9 @@ public class Timestamp extends java.util.Date {
* @since 1.4
*/
public int compareTo(Timestamp ts) {
int i = super.compareTo(ts);
long thisTime = this.getTime();
long anotherTime = ts.getTime();
int i = (thisTime<anotherTime ? -1 :(thisTime==anotherTime?0 :1));
if (i == 0) {
if (nanos > ts.nanos) {
return 1;
......
......@@ -1452,10 +1452,10 @@ public class Collections {
* when o is a Map.Entry, and calls o.setValue.
*/
public boolean containsAll(Collection<?> coll) {
Iterator<?> it = coll.iterator();
while (it.hasNext())
if (!contains(it.next())) // Invokes safe contains() above
for (Object e : coll) {
if (!contains(e)) // Invokes safe contains() above
return false;
}
return true;
}
public boolean equals(Object o) {
......@@ -3713,45 +3713,91 @@ public class Collections {
}
/**
* Returns <tt>true</tt> if the two specified collections have no
* Returns {@code true} if the two specified collections have no
* elements in common.
*
* <p>Care must be exercised if this method is used on collections that
* do not comply with the general contract for <tt>Collection</tt>.
* do not comply with the general contract for {@code Collection}.
* Implementations may elect to iterate over either collection and test
* for containment in the other collection (or to perform any equivalent
* computation). If either collection uses a nonstandard equality test
* (as does a {@link SortedSet} whose ordering is not <i>compatible with
* equals</i>, or the key set of an {@link IdentityHashMap}), both
* (as does a {@link SortedSet} whose ordering is not <em>compatible with
* equals</em>, or the key set of an {@link IdentityHashMap}), both
* collections must use the same nonstandard equality test, or the
* result of this method is undefined.
*
* <p>Care must also be exercised when using collections that have
* restrictions on the elements that they may contain. Collection
* implementations are allowed to throw exceptions for any operation
* involving elements they deem ineligible. For absolute safety the
* specified collections should contain only elements which are
* eligible elements for both collections.
*
* <p>Note that it is permissible to pass the same collection in both
* parameters, in which case the method will return true if and only if
* the collection is empty.
* parameters, in which case the method will return {@code true} if and
* only if the collection is empty.
*
* @param c1 a collection
* @param c2 a collection
* @throws NullPointerException if either collection is null
* @return {@code true} if the two specified collections have no
* elements in common.
* @throws NullPointerException if either collection is {@code null}.
* @throws NullPointerException if one collection contains a {@code null}
* element and {@code null} is not an eligible element for the other collection.
* (optional)
* @throws ClassCastException if one collection contains an element that is
* of a type which is ineligible for the other collection. (optional)
* @since 1.5
*/
public static boolean disjoint(Collection<?> c1, Collection<?> c2) {
/*
* We're going to iterate through c1 and test for inclusion in c2.
* If c1 is a Set and c2 isn't, swap the collections. Otherwise,
* place the shorter collection in c1. Hopefully this heuristic
* will minimize the cost of the operation.
*/
if ((c1 instanceof Set) && !(c2 instanceof Set) ||
(c1.size() > c2.size())) {
Collection<?> tmp = c1;
c1 = c2;
c2 = tmp;
// The collection to be used for contains(). Preference is given to
// the collection who's contains() has lower O() complexity.
Collection<?> contains = c2;
// The collection to be iterated. If the collections' contains() impl
// are of different O() complexity, the collection with slower
// contains() will be used for iteration. For collections who's
// contains() are of the same complexity then best performance is
// achieved by iterating the smaller collection.
Collection<?> iterate = c1;
// Performance optimization cases. The heuristics:
// 1. Generally iterate over c1.
// 2. If c1 is a Set then iterate over c2.
// 3. If either collection is empty then result is always true.
// 4. Iterate over the smaller Collection.
if (c1 instanceof Set) {
// Use c1 for contains as a Set's contains() is expected to perform
// better than O(N/2)
iterate = c2;
contains = c1;
} else if (!(c2 instanceof Set)) {
// Both are mere Collections. Iterate over smaller collection.
// Example: If c1 contains 3 elements and c2 contains 50 elements and
// assuming contains() requires ceiling(N/2) comparisons then
// checking for all c1 elements in c2 would require 75 comparisons
// (3 * ceiling(50/2)) vs. checking all c2 elements in c1 requiring
// 100 comparisons (50 * ceiling(3/2)).
int c1size = c1.size();
int c2size = c2.size();
if (c1size == 0 || c2size == 0) {
// At least one collection is empty. Nothing will match.
return true;
}
if (c1size > c2size) {
iterate = c2;
contains = c1;
}
}
for (Object e : c1)
if (c2.contains(e))
for (Object e : iterate) {
if (contains.contains(e)) {
// Found a common element. Collections are not disjoint.
return false;
}
}
// No common elements were found.
return true;
}
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -41,6 +41,8 @@ import java.math.BigInteger;
import java.math.MathContext;
import java.math.RoundingMode;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.text.DateFormatSymbols;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
......@@ -1838,22 +1840,53 @@ import sun.misc.FormattedFloatingDecimal;
*/
public final class Formatter implements Closeable, Flushable {
private Appendable a;
private Locale l;
private final Locale l;
private IOException lastException;
private char zero = '0';
private final char zero;
private static double scaleUp;
// 1 (sign) + 19 (max # sig digits) + 1 ('.') + 1 ('e') + 1 (sign)
// + 3 (max # exp digits) + 4 (error) = 30
private static final int MAX_FD_CHARS = 30;
// Initialize internal data.
private void init(Appendable a, Locale l) {
/**
* Returns a charset object for the given charset name.
* @throws NullPointerException is csn is null
* @throws UnsupportedEncodingException if the charset is not supported
*/
private static Charset toCharset(String csn)
throws UnsupportedEncodingException
{
Objects.nonNull(csn, "charsetName");
try {
return Charset.forName(csn);
} catch (IllegalCharsetNameException|UnsupportedCharsetException unused) {
// UnsupportedEncodingException should be thrown
throw new UnsupportedEncodingException(csn);
}
}
private static final Appendable nonNullAppendable(Appendable a) {
if (a == null)
return new StringBuilder();
return a;
}
/* Private constructors */
private Formatter(Locale l, Appendable a) {
this.a = a;
this.l = l;
setZero();
this.zero = getZero(l);
}
private Formatter(Charset charset, Locale l, File file)
throws FileNotFoundException
{
this(l,
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)));
}
/**
......@@ -1867,7 +1900,7 @@ public final class Formatter implements Closeable, Flushable {
* virtual machine.
*/
public Formatter() {
init(new StringBuilder(), Locale.getDefault(Locale.Category.FORMAT));
this(Locale.getDefault(Locale.Category.FORMAT), new StringBuilder());
}
/**
......@@ -1881,9 +1914,7 @@ public final class Formatter implements Closeable, Flushable {
* {@code null} then a {@link StringBuilder} will be created.
*/
public Formatter(Appendable a) {
if (a == null)
a = new StringBuilder();
init(a, Locale.getDefault(Locale.Category.FORMAT));
this(Locale.getDefault(Locale.Category.FORMAT), nonNullAppendable(a));
}
/**
......@@ -1900,7 +1931,7 @@ public final class Formatter implements Closeable, Flushable {
* is applied.
*/
public Formatter(Locale l) {
init(new StringBuilder(), l);
this(l, new StringBuilder());
}
/**
......@@ -1916,9 +1947,7 @@ public final class Formatter implements Closeable, Flushable {
* is applied.
*/
public Formatter(Appendable a, Locale l) {
if (a == null)
a = new StringBuilder();
init(a, l);
this(l, nonNullAppendable(a));
}
/**
......@@ -1949,8 +1978,8 @@ public final class Formatter implements Closeable, Flushable {
* creating the file
*/
public Formatter(String fileName) throws FileNotFoundException {
init(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName))),
Locale.getDefault(Locale.Category.FORMAT));
this(Locale.getDefault(Locale.Category.FORMAT),
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName))));
}
/**
......@@ -2025,8 +2054,7 @@ public final class Formatter implements Closeable, Flushable {
public Formatter(String fileName, String csn, Locale l)
throws FileNotFoundException, UnsupportedEncodingException
{
init(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), csn)),
l);
this(toCharset(csn), l, new File(fileName));
}
/**
......@@ -2057,8 +2085,8 @@ public final class Formatter implements Closeable, Flushable {
* creating the file
*/
public Formatter(File file) throws FileNotFoundException {
init(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))),
Locale.getDefault(Locale.Category.FORMAT));
this(Locale.getDefault(Locale.Category.FORMAT),
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))));
}
/**
......@@ -2133,8 +2161,7 @@ public final class Formatter implements Closeable, Flushable {
public Formatter(File file, String csn, Locale l)
throws FileNotFoundException, UnsupportedEncodingException
{
init(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), csn)),
l);
this(toCharset(csn), l, file);
}
/**
......@@ -2151,9 +2178,8 @@ public final class Formatter implements Closeable, Flushable {
* The stream to use as the destination of this formatter.
*/
public Formatter(PrintStream ps) {
if (ps == null)
throw new NullPointerException();
init((Appendable)ps, Locale.getDefault(Locale.Category.FORMAT));
this(Locale.getDefault(Locale.Category.FORMAT),
(Appendable)Objects.nonNull(ps));
}
/**
......@@ -2171,8 +2197,8 @@ public final class Formatter implements Closeable, Flushable {
* The output will be buffered.
*/
public Formatter(OutputStream os) {
init(new BufferedWriter(new OutputStreamWriter(os)),
Locale.getDefault(Locale.Category.FORMAT));
this(Locale.getDefault(Locale.Category.FORMAT),
new BufferedWriter(new OutputStreamWriter(os)));
}
/**
......@@ -2222,13 +2248,15 @@ public final class Formatter implements Closeable, Flushable {
public Formatter(OutputStream os, String csn, Locale l)
throws UnsupportedEncodingException
{
init(new BufferedWriter(new OutputStreamWriter(os, csn)), l);
this(l, new BufferedWriter(new OutputStreamWriter(os, csn)));
}
private void setZero() {
private static char getZero(Locale l) {
if ((l != null) && !l.equals(Locale.US)) {
DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(l);
zero = dfs.getZeroDigit();
return dfs.getZeroDigit();
} else {
return '0';
}
}
......
......@@ -26,9 +26,9 @@
package java.util;
/**
* Linked list implementation of the {@link List} and {@link Deque} interfaces.
* Implements all optional operations, and permits all elements (including
* {@code null}).
* Doubly-linked list implementation of the {@code List} and {@code Deque}
* interfaces. Implements all optional list operations, and permits all
* elements (including {@code null}).
*
* <p>All of the operations perform as could be expected for a doubly-linked
* list. Operations that index into the list will traverse the list from
......@@ -249,7 +249,7 @@ public class LinkedList<E>
* @return the last element in this list
* @throws NoSuchElementException if this list is empty
*/
public E getLast() {
public E getLast() {
final Node<E> l = last;
if (l == null)
throw new NoSuchElementException();
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -571,10 +571,8 @@ public final class Scanner implements Iterator<String>, Closeable {
* @return A scanner with the specified source and pattern
*/
private Scanner(Readable source, Pattern pattern) {
if (source == null)
throw new NullPointerException("source");
if (pattern == null)
throw new NullPointerException("pattern");
assert source != null : "source should not be null";
assert pattern != null : "pattern should not be null";
this.source = source;
delimPattern = pattern;
buf = CharBuffer.allocate(BUFFER_SIZE);
......@@ -593,7 +591,7 @@ public final class Scanner implements Iterator<String>, Closeable {
* interface
*/
public Scanner(Readable source) {
this(source, WHITESPACE_PATTERN);
this(Objects.nonNull(source, "source"), WHITESPACE_PATTERN);
}
/**
......@@ -620,23 +618,27 @@ public final class Scanner implements Iterator<String>, Closeable {
* does not exist
*/
public Scanner(InputStream source, String charsetName) {
this(makeReadable(source, charsetName), WHITESPACE_PATTERN);
this(makeReadable(Objects.nonNull(source, "source"), toCharset(charsetName)),
WHITESPACE_PATTERN);
}
private static Readable makeReadable(InputStream source,
String charsetName)
{
if (source == null)
throw new NullPointerException("source");
InputStreamReader isr = null;
/**
* Returns a charset object for the given charset name.
* @throws NullPointerException is csn is null
* @throws IllegalArgumentException if the charset is not supported
*/
private static Charset toCharset(String csn) {
Objects.nonNull(csn, "charsetName");
try {
isr = new InputStreamReader(source, charsetName);
} catch (UnsupportedEncodingException uee) {
IllegalArgumentException iae = new IllegalArgumentException();
iae.initCause(uee);
throw iae;
return Charset.forName(csn);
} catch (IllegalCharsetNameException|UnsupportedCharsetException e) {
// IllegalArgumentException should be thrown
throw new IllegalArgumentException(e);
}
return isr;
}
private static Readable makeReadable(InputStream source, Charset charset) {
return new InputStreamReader(source, charset);
}
/**
......@@ -648,9 +650,7 @@ public final class Scanner implements Iterator<String>, Closeable {
* @param source A file to be scanned
* @throws FileNotFoundException if source is not found
*/
public Scanner(File source)
throws FileNotFoundException
{
public Scanner(File source) throws FileNotFoundException {
this((ReadableByteChannel)(new FileInputStream(source).getChannel()));
}
......@@ -669,8 +669,27 @@ public final class Scanner implements Iterator<String>, Closeable {
public Scanner(File source, String charsetName)
throws FileNotFoundException
{
this((ReadableByteChannel)(new FileInputStream(source).getChannel()),
charsetName);
this(Objects.nonNull(source), toDecoder(charsetName));
}
private Scanner(File source, CharsetDecoder dec)
throws FileNotFoundException
{
this(makeReadable((ReadableByteChannel)(new FileInputStream(source).getChannel()), dec));
}
private static CharsetDecoder toDecoder(String charsetName) {
Objects.nonNull(charsetName, "charsetName");
try {
return Charset.forName(charsetName).newDecoder();
} catch (IllegalCharsetNameException|UnsupportedCharsetException unused) {
throw new IllegalArgumentException(charsetName);
}
}
private static Readable makeReadable(ReadableByteChannel source,
CharsetDecoder dec) {
return Channels.newReader(source, dec, -1);
}
/**
......@@ -708,10 +727,12 @@ public final class Scanner implements Iterator<String>, Closeable {
* if the specified encoding is not found
* @since 1.7
*/
public Scanner(FileRef source, String charsetName)
throws IOException
{
this(source.newInputStream(), charsetName);
public Scanner(FileRef source, String charsetName) throws IOException {
this(Objects.nonNull(source), toCharset(charsetName));
}
private Scanner(FileRef source, Charset charset) throws IOException {
this(makeReadable(source.newInputStream(), charset));
}
/**
......@@ -733,16 +754,12 @@ public final class Scanner implements Iterator<String>, Closeable {
* @param source A channel to scan
*/
public Scanner(ReadableByteChannel source) {
this(makeReadable(source), WHITESPACE_PATTERN);
this(makeReadable(Objects.nonNull(source, "source")),
WHITESPACE_PATTERN);
}
private static Readable makeReadable(ReadableByteChannel source) {
if (source == null)
throw new NullPointerException("source");
String defaultCharsetName =
java.nio.charset.Charset.defaultCharset().name();
return Channels.newReader(source,
java.nio.charset.Charset.defaultCharset().name());
return makeReadable(source, Charset.defaultCharset().newDecoder());
}
/**
......@@ -757,17 +774,8 @@ public final class Scanner implements Iterator<String>, Closeable {
* does not exist
*/
public Scanner(ReadableByteChannel source, String charsetName) {
this(makeReadable(source, charsetName), WHITESPACE_PATTERN);
}
private static Readable makeReadable(ReadableByteChannel source,
String charsetName)
{
if (source == null)
throw new NullPointerException("source");
if (!Charset.isSupported(charsetName))
throw new IllegalArgumentException(charsetName);
return Channels.newReader(source, charsetName);
this(makeReadable(Objects.nonNull(source, "source"), toDecoder(charsetName)),
WHITESPACE_PATTERN);
}
// Private primitives used to support scanning
......
......@@ -869,6 +869,8 @@ public class ConcurrentLinkedDeque<E>
/**
* Inserts the specified element at the front of this deque.
* As the deque is unbounded, this method will never throw
* {@link IllegalStateException}.
*
* @throws NullPointerException if the specified element is null
*/
......@@ -878,6 +880,8 @@ public class ConcurrentLinkedDeque<E>
/**
* Inserts the specified element at the end of this deque.
* As the deque is unbounded, this method will never throw
* {@link IllegalStateException}.
*
* <p>This method is equivalent to {@link #add}.
*
......@@ -889,8 +893,9 @@ public class ConcurrentLinkedDeque<E>
/**
* Inserts the specified element at the front of this deque.
* As the deque is unbounded, this method will never return {@code false}.
*
* @return {@code true} always
* @return {@code true} (as specified by {@link Deque#offerFirst})
* @throws NullPointerException if the specified element is null
*/
public boolean offerFirst(E e) {
......@@ -900,10 +905,11 @@ public class ConcurrentLinkedDeque<E>
/**
* Inserts the specified element at the end of this deque.
* As the deque is unbounded, this method will never return {@code false}.
*
* <p>This method is equivalent to {@link #add}.
*
* @return {@code true} always
* @return {@code true} (as specified by {@link Deque#offerLast})
* @throws NullPointerException if the specified element is null
*/
public boolean offerLast(E e) {
......@@ -983,6 +989,7 @@ public class ConcurrentLinkedDeque<E>
/**
* Inserts the specified element at the tail of this deque.
* As the deque is unbounded, this method will never return {@code false}.
*
* @return {@code true} (as specified by {@link Queue#offer})
* @throws NullPointerException if the specified element is null
......@@ -993,6 +1000,8 @@ public class ConcurrentLinkedDeque<E>
/**
* Inserts the specified element at the tail of this deque.
* As the deque is unbounded, this method will never throw
* {@link IllegalStateException} or return {@code false}.
*
* @return {@code true} (as specified by {@link Collection#add})
* @throws NullPointerException if the specified element is null
......
......@@ -269,6 +269,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
/**
* Inserts the specified element at the tail of this queue.
* As the queue is unbounded, this method will never throw
* {@link IllegalStateException} or return {@code false}.
*
* @return {@code true} (as specified by {@link Collection#add})
* @throws NullPointerException if the specified element is null
......@@ -298,6 +300,7 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
/**
* Inserts the specified element at the tail of this queue.
* As the queue is unbounded, this method will never return {@code false}.
*
* @return {@code true} (as specified by {@link Queue#offer})
* @throws NullPointerException if the specified element is null
......
......@@ -374,17 +374,11 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
null, null, 1);
}
/** Updater for casHead */
private static final
AtomicReferenceFieldUpdater<ConcurrentSkipListMap, HeadIndex>
headUpdater = AtomicReferenceFieldUpdater.newUpdater
(ConcurrentSkipListMap.class, HeadIndex.class, "head");
/**
* compareAndSet head node
*/
private boolean casHead(HeadIndex<K,V> cmp, HeadIndex<K,V> val) {
return headUpdater.compareAndSet(this, cmp, val);
return UNSAFE.compareAndSwapObject(this, headOffset, cmp, val);
}
/* ---------------- Nodes -------------- */
......@@ -423,28 +417,18 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
this.next = next;
}
/** Updater for casNext */
static final AtomicReferenceFieldUpdater<Node, Node>
nextUpdater = AtomicReferenceFieldUpdater.newUpdater
(Node.class, Node.class, "next");
/** Updater for casValue */
static final AtomicReferenceFieldUpdater<Node, Object>
valueUpdater = AtomicReferenceFieldUpdater.newUpdater
(Node.class, Object.class, "value");
/**
* compareAndSet value field
*/
boolean casValue(Object cmp, Object val) {
return valueUpdater.compareAndSet(this, cmp, val);
return UNSAFE.compareAndSwapObject(this, valueOffset, cmp, val);
}
/**
* compareAndSet next field
*/
boolean casNext(Node<K,V> cmp, Node<K,V> val) {
return nextUpdater.compareAndSet(this, cmp, val);
return UNSAFE.compareAndSwapObject(this, nextOffset, cmp, val);
}
/**
......@@ -522,6 +506,14 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
return null;
return new AbstractMap.SimpleImmutableEntry<K,V>(key, v);
}
// Unsafe mechanics
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
private static final long valueOffset =
objectFieldOffset(UNSAFE, "value", Node.class);
private static final long nextOffset =
objectFieldOffset(UNSAFE, "next", Node.class);
}
/* ---------------- Indexing -------------- */
......@@ -547,16 +539,11 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
this.right = right;
}
/** Updater for casRight */
static final AtomicReferenceFieldUpdater<Index, Index>
rightUpdater = AtomicReferenceFieldUpdater.newUpdater
(Index.class, Index.class, "right");
/**
* compareAndSet right field
*/
final boolean casRight(Index<K,V> cmp, Index<K,V> val) {
return rightUpdater.compareAndSet(this, cmp, val);
return UNSAFE.compareAndSwapObject(this, rightOffset, cmp, val);
}
/**
......@@ -591,6 +578,12 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
final boolean unlink(Index<K,V> succ) {
return !indexesDeletedNode() && casRight(succ, succ.right);
}
// Unsafe mechanics
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
private static final long rightOffset =
objectFieldOffset(UNSAFE, "right", Index.class);
}
/* ---------------- Head nodes -------------- */
......@@ -640,7 +633,8 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
* cast key as Comparable, which may cause ClassCastException,
* which is propagated back to caller.
*/
private Comparable<? super K> comparable(Object key) throws ClassCastException {
private Comparable<? super K> comparable(Object key)
throws ClassCastException {
if (key == null)
throw new NullPointerException();
if (comparator != null)
......@@ -799,68 +793,12 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
}
/**
* Specialized variant of findNode to perform Map.get. Does a weak
* traversal, not bothering to fix any deleted index nodes,
* returning early if it happens to see key in index, and passing
* over any deleted base nodes, falling back to getUsingFindNode
* only if it would otherwise return value from an ongoing
* deletion. Also uses "bound" to eliminate need for some
* comparisons (see Pugh Cookbook). Also folds uses of null checks
* and node-skipping because markers have null keys.
* Gets value for key using findNode.
* @param okey the key
* @return the value, or null if absent
*/
private V doGet(Object okey) {
Comparable<? super K> key = comparable(okey);
Node<K,V> bound = null;
Index<K,V> q = head;
Index<K,V> r = q.right;
Node<K,V> n;
K k;
int c;
for (;;) {
Index<K,V> d;
// Traverse rights
if (r != null && (n = r.node) != bound && (k = n.key) != null) {
if ((c = key.compareTo(k)) > 0) {
q = r;
r = r.right;
continue;
} else if (c == 0) {
Object v = n.value;
return (v != null)? (V)v : getUsingFindNode(key);
} else
bound = n;
}
// Traverse down
if ((d = q.down) != null) {
q = d;
r = d.right;
} else
break;
}
// Traverse nexts
for (n = q.node.next; n != null; n = n.next) {
if ((k = n.key) != null) {
if ((c = key.compareTo(k)) == 0) {
Object v = n.value;
return (v != null)? (V)v : getUsingFindNode(key);
} else if (c < 0)
break;
}
}
return null;
}
/**
* Performs map.get via findNode. Used as a backup if doGet
* encounters an in-progress deletion.
* @param key the key
* @return the value, or null if absent
*/
private V getUsingFindNode(Comparable<? super K> key) {
/*
* Loop needed here and elsewhere in case value field goes
* null just as it is about to be returned, in which case we
......@@ -943,7 +881,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
x ^= x << 13;
x ^= x >>> 17;
randomSeed = x ^= x << 5;
if ((x & 0x8001) != 0) // test highest and lowest bits
if ((x & 0x80000001) != 0) // test highest and lowest bits
return 0;
int level = 1;
while (((x >>>= 1) & 1) != 0) ++level;
......@@ -1256,7 +1194,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
Node<K,V> n = b.next;
for (;;) {
if (n == null)
return (b.isBaseHeader())? null : b;
return b.isBaseHeader() ? null : b;
Node<K,V> f = n.next; // inconsistent read
if (n != b.next)
break;
......@@ -1374,7 +1312,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
Node<K,V> n = b.next;
for (;;) {
if (n == null)
return ((rel & LT) == 0 || b.isBaseHeader())? null : b;
return ((rel & LT) == 0 || b.isBaseHeader()) ? null : b;
Node<K,V> f = n.next;
if (n != b.next) // inconsistent read
break;
......@@ -1390,7 +1328,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
(c < 0 && (rel & LT) == 0))
return n;
if ( c <= 0 && (rel & LT) != 0)
return (b.isBaseHeader())? null : b;
return b.isBaseHeader() ? null : b;
b = n;
n = f;
}
......@@ -1744,7 +1682,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
if (n.getValidValue() != null)
++count;
}
return (count >= Integer.MAX_VALUE)? Integer.MAX_VALUE : (int)count;
return (count >= Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) count;
}
/**
......@@ -2099,7 +2037,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
*/
public K lowerKey(K key) {
Node<K,V> n = findNear(key, LT);
return (n == null)? null : n.key;
return (n == null) ? null : n.key;
}
/**
......@@ -2123,7 +2061,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
*/
public K floorKey(K key) {
Node<K,V> n = findNear(key, LT|EQ);
return (n == null)? null : n.key;
return (n == null) ? null : n.key;
}
/**
......@@ -2145,7 +2083,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
*/
public K ceilingKey(K key) {
Node<K,V> n = findNear(key, GT|EQ);
return (n == null)? null : n.key;
return (n == null) ? null : n.key;
}
/**
......@@ -2169,7 +2107,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
*/
public K higherKey(K key) {
Node<K,V> n = findNear(key, GT);
return (n == null)? null : n.key;
return (n == null) ? null : n.key;
}
/**
......@@ -2342,7 +2280,8 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
return list;
}
static final class KeySet<E> extends AbstractSet<E> implements NavigableSet<E> {
static final class KeySet<E>
extends AbstractSet<E> implements NavigableSet<E> {
private final ConcurrentNavigableMap<E,Object> m;
KeySet(ConcurrentNavigableMap<E,Object> map) { m = map; }
public int size() { return m.size(); }
......@@ -2359,11 +2298,11 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
public E last() { return m.lastKey(); }
public E pollFirst() {
Map.Entry<E,Object> e = m.pollFirstEntry();
return e == null? null : e.getKey();
return (e == null) ? null : e.getKey();
}
public E pollLast() {
Map.Entry<E,Object> e = m.pollLastEntry();
return e == null? null : e.getKey();
return (e == null) ? null : e.getKey();
}
public Iterator<E> iterator() {
if (m instanceof ConcurrentSkipListMap)
......@@ -2710,9 +2649,9 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
rel &= ~m.LT;
}
if (tooLow(key))
return ((rel & m.LT) != 0)? null : lowestEntry();
return ((rel & m.LT) != 0) ? null : lowestEntry();
if (tooHigh(key))
return ((rel & m.LT) != 0)? highestEntry() : null;
return ((rel & m.LT) != 0) ? highestEntry() : null;
for (;;) {
Node<K,V> n = m.findNear(key, rel);
if (n == null || !inBounds(n.key))
......@@ -2783,7 +2722,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
public V remove(Object key) {
K k = (K)key;
return (!inBounds(k))? null : m.remove(k);
return (!inBounds(k)) ? null : m.remove(k);
}
public int size() {
......@@ -2794,7 +2733,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
if (n.getValidValue() != null)
++count;
}
return count >= Integer.MAX_VALUE? Integer.MAX_VALUE : (int)count;
return count >= Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)count;
}
public boolean isEmpty() {
......@@ -2972,27 +2911,27 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
}
public K firstKey() {
return isDescending? highestKey() : lowestKey();
return isDescending ? highestKey() : lowestKey();
}
public K lastKey() {
return isDescending? lowestKey() : highestKey();
return isDescending ? lowestKey() : highestKey();
}
public Map.Entry<K,V> firstEntry() {
return isDescending? highestEntry() : lowestEntry();
return isDescending ? highestEntry() : lowestEntry();
}
public Map.Entry<K,V> lastEntry() {
return isDescending? lowestEntry() : highestEntry();
return isDescending ? lowestEntry() : highestEntry();
}
public Map.Entry<K,V> pollFirstEntry() {
return isDescending? removeHighest() : removeLowest();
return isDescending ? removeHighest() : removeLowest();
}
public Map.Entry<K,V> pollLastEntry() {
return isDescending? removeLowest() : removeHighest();
return isDescending ? removeLowest() : removeHighest();
}
/* ---------------- Submap Views -------------- */
......@@ -3141,4 +3080,22 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
}
}
}
// Unsafe mechanics
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
private static final long headOffset =
objectFieldOffset(UNSAFE, "head", ConcurrentSkipListMap.class);
static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
String field, Class<?> klazz) {
try {
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
} catch (NoSuchFieldException e) {
// Convert Exception to corresponding Error
NoSuchFieldError error = new NoSuchFieldError(field);
error.initCause(e);
throw error;
}
}
}
......@@ -832,7 +832,7 @@ public class CopyOnWriteArrayList<E>
}
/**
* Save the state of the list to a stream (i.e., serialize it).
* Saves the state of the list to a stream (that is, serializes it).
*
* @serialData The length of the array backing the list is emitted
* (int), followed by all of its elements (each an Object)
......@@ -842,27 +842,25 @@ public class CopyOnWriteArrayList<E>
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException{
// Write out element count, and any hidden stuff
s.defaultWriteObject();
Object[] elements = getArray();
int len = elements.length;
// Write out array length
s.writeInt(len);
s.writeInt(elements.length);
// Write out all elements in the proper order.
for (int i = 0; i < len; i++)
s.writeObject(elements[i]);
for (Object element : elements)
s.writeObject(element);
}
/**
* Reconstitute the list from a stream (i.e., deserialize it).
* Reconstitutes the list from a stream (that is, deserializes it).
*
* @param s the stream
*/
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException {
// Read in size, and any hidden stuff
s.defaultReadObject();
// bind to new lock
......
......@@ -1029,6 +1029,8 @@ public class LinkedBlockingDeque<E>
* elements as they existed upon construction of the iterator, and
* may (but is not guaranteed to) reflect any modifications
* subsequent to construction.
*
* @return an iterator over the elements in this deque in reverse order
*/
public Iterator<E> descendingIterator() {
return new DescendingItr();
......
......@@ -360,8 +360,12 @@ public class ScheduledThreadPoolExecutor
getExecuteExistingDelayedTasksAfterShutdownPolicy();
boolean keepPeriodic =
getContinueExistingPeriodicTasksAfterShutdownPolicy();
if (!keepDelayed && !keepPeriodic)
if (!keepDelayed && !keepPeriodic) {
for (Object e : q.toArray())
if (e instanceof RunnableScheduledFuture<?>)
((RunnableScheduledFuture<?>) e).cancel(false);
q.clear();
}
else {
// Traverse snapshot to avoid iterator exceptions
for (Object e : q.toArray()) {
......
......@@ -1426,7 +1426,7 @@ public class Logger {
// we didn't have a previous parent
ref = manager.new LoggerWeakRef(this);
}
ref.setParentRef(new WeakReference<>(parent));
ref.setParentRef(new WeakReference<Logger>(parent));
parent.kids.add(ref);
// As a result of the reparenting, the effective level
......
......@@ -107,7 +107,7 @@ public abstract class CompiledScript {
}
/**
* Returns the <code>ScriptEngine</code> wbose <code>compile</code> method created this <code>CompiledScript</code>.
* Returns the <code>ScriptEngine</code> whose <code>compile</code> method created this <code>CompiledScript</code>.
* The <code>CompiledScript</code> will execute in this engine.
*
* @return The <code>ScriptEngine</code> that created this <code>CompiledScript</code>
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册