This commit is contained in:
Lana Steuck 2011-03-21 16:57:18 -07:00
commit 99bae3bd28
126 changed files with 23886 additions and 4126 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 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
@ -44,7 +44,7 @@ SUBDIRS = java security net/ssl jarsigner
SUBDIRS_management = jmx
SUBDIRS_desktop = image
SUBDIRS_enterprise = crypto/provider jndi \
org xml rowset net/httpserver
org rowset net/httpserver
SUBDIRS_misc = $(SCRIPT_SUBDIR) tracing servicetag nio demo
# Omit mirror since it's built with the apt tool.

View File

@ -1,44 +0,0 @@
#
# Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building packages under javax.xml
#
BUILDDIR = ../../..
PACKAGE = com.sun.xml
PRODUCT = xml
include $(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_FILES_JAVA_DIRS = com/sun/activation \
org/relaxng/datatype
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1999, 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
@ -107,6 +107,8 @@ CFLAGS_REQUIRED_sparcv9 += -m64 -mcpu=v9
LDFLAGS_COMMON_sparcv9 += -m64 -mcpu=v9
CFLAGS_REQUIRED_sparc += -m32 -mcpu=v9
LDFLAGS_COMMON_sparc += -m32 -mcpu=v9
CFLAGS_REQUIRED_arm += -fsigned-char -D_LITTLE_ENDIAN
CFLAGS_REQUIRED_ppc += -fsigned-char -D_BIG_ENDIAN
ifeq ($(ZERO_BUILD), true)
CFLAGS_REQUIRED = $(ZERO_ARCHFLAG)
ifeq ($(ZERO_ENDIANNESS), little)
@ -143,11 +145,9 @@ endif
#
# Misc compiler options
#
ifeq ($(ARCH),ppc)
CFLAGS_COMMON = -fsigned-char
else # ARCH
ifneq ($(ARCH),ppc)
CFLAGS_COMMON = -fno-strict-aliasing
endif # ARCH
endif
PIC_CODE_LARGE = -fPIC
PIC_CODE_SMALL = -fpic
GLOBAL_KPIC = $(PIC_CODE_LARGE)
@ -219,8 +219,19 @@ ifdef LIBRARY
# The environment variable LD_LIBRARY_PATH will over-ride these runpaths.
# Try: 'readelf -d lib*.so' to see these settings in a library.
#
LDFLAGS_COMMON += -Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$ORIGIN
LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=-Xlinker -z -Xlinker origin -Xlinker -rpath -Xlinker \$$ORIGIN/%)
Z_ORIGIN_FLAG/sparc = -Xlinker -z -Xlinker origin
Z_ORIGIN_FLAG/i586 = -Xlinker -z -Xlinker origin
Z_ORIGIN_FLAG/amd64 = -Xlinker -z -Xlinker origin
Z_ORIGIN_FLAG/ia64 = -Xlinker -z -Xlinker origin
Z_ORIGIN_FLAG/arm =
Z_ORIGIN_FLAG/ppc =
Z_ORIGIN_FLAG/zero = -Xlinker -z -Xlinker origin
LDFLAG_Z_ORIGIN = $(Z_ORIGIN_FLAG/$(ARCH_FAMILY))
LDFLAGS_COMMON += $(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN
LDFLAGS_COMMON += $(LD_RUNPATH_EXTRAS:%=$(LDFLAG_Z_ORIGIN) -Xlinker -rpath -Xlinker \$$ORIGIN/%)
endif
EXTRA_LIBS += -lc
@ -315,7 +326,6 @@ override LIBNSL =
override LIBTHREAD =
override MOOT_PRIORITIES = true
override NO_INTERRUPTIBLE_IO = true
override OPENWIN_HOME = /usr/X11R6
ifeq ($(ARCH), amd64)
override OPENWIN_LIB = $(OPENWIN_HOME)/lib64
else
@ -359,3 +369,9 @@ else
INCLUDE_SA = true
endif
ifdef CROSS_COMPILE_ARCH
# X11 headers are not under /usr/include
OTHER_CFLAGS += -I$(OPENWIN_HOME)/include
OTHER_CXXFLAGS += -I$(OPENWIN_HOME)/include
OTHER_CPPFLAGS += -I$(OPENWIN_HOME)/include
endif

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1995, 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
@ -115,6 +115,36 @@ endif
include $(JDK_TOPDIR)/make/common/Defs-$(PLATFORM).gmk
#
# Cross-compilation Settings
#
ifdef CROSS_COMPILE_ARCH
# Can't run the tools we just built
USE_ONLY_BOOTDIR_TOOLS = true
# When cross-compiling CC generates code for the target, but
# some parts of the build generate C code that has to be compiled
# and executed on the build host - HOST_CC is the 'local' compiler.
# For linux the default is /usr/bin/gcc; other platforms need to
# set it explicitly
ifeq ($(PLATFORM), linux)
ifndef HOST_CC
HOST_CC = $(USRBIN_PATH)gcc
endif
endif
else
# Must set HOST_CC if not already set
ifndef HOST_CC
HOST_CC = $(CC)
endif
endif
# Reset the VM name for client-only builds
ifdef BUILD_CLIENT_ONLY
VM_NAME = client
endif
#
# Freetype logic is applicable to OpenJDK only
#
@ -334,8 +364,7 @@ endif
INCLUDES = -I. -I$(CLASSHDRDIR) \
$(patsubst %,-I%,$(subst $(CLASSPATH_SEPARATOR), ,$(VPATH.h))) $(OTHER_INCLUDES)
OTHER_CPPFLAGS = $(INCLUDES)
OTHER_CPPFLAGS += $(INCLUDES)
#
# vpaths. These are the default locations searched for source files.
@ -466,9 +495,11 @@ CXXFLAGS_$(VARIANT)/BYFILE = $(CXXFLAGS_$(VARIANT)/$(@F)) \
#
# Tool flags
#
# EXTRA_CFLAGS are used to define cross-compilation options
#
ASFLAGS = $(ASFLAGS_$(VARIANT)) $(ASFLAGS_COMMON) $(OTHER_ASFLAGS)
CFLAGS = $(CFLAGS_$(VARIANT)/BYFILE) $(CFLAGS_COMMON) $(OTHER_CFLAGS)
CXXFLAGS = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS)
CFLAGS = $(CFLAGS_$(VARIANT)/BYFILE) $(CFLAGS_COMMON) $(OTHER_CFLAGS) $(EXTRA_CFLAGS)
CXXFLAGS = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS) $(EXTRA_CFLAGS)
CPPFLAGS = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
$(DEFINES) $(OPTIONS:%=-D%)
LDFLAGS = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)

View File

@ -83,7 +83,7 @@ ifneq (,$(findstring $(PLATFORM), linux solaris)) # UNIX systems
endif
endif
ifeq ($(PLATFORM), linux)
LDFLAGS += -Wl,-z -Wl,origin
LDFLAGS += $(LDFLAG_Z_ORIGIN)
LDFLAGS += -Wl,--allow-shlib-undefined
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 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
@ -55,6 +55,7 @@ IMPORT_TOOLS_PACKAGES += \
com/sun/tools/internal/xjc \
com/sun/tools/internal/ws \
com/sun/tools/internal/jxc \
org/relaxng \
META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory \
META-INF/services/com.sun.tools.xjc.Plugin
META-INF/services/com.sun.tools.internal.xjc.Plugin

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2010, 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
@ -102,6 +102,14 @@ else
COMPILER_PATH =/usr/bin/
endif
# OPENWIN_HOME: path to where the X11 environment is installed.
# NOTE: Must end with / so that it could be empty, allowing PATH usage.
ifneq ($(ALT_OPENWIN_HOME),)
OPENWIN_HOME :=$(call PrefixPath,$(ALT_OPENWIN_HOME))
else
OPENWIN_HOME =/usr/X11R6/
endif
# DEVTOOLS_PATH: for other tools required for building (such as zip, etc.)
# NOTE: Must end with / so that it could be empty, allowing PATH usage.
ifneq "$(origin ALT_DEVTOOLS_PATH)" "undefined"
@ -181,6 +189,7 @@ HOTSPOT_SERVER_PATH:=$(call AltCheckValue,HOTSPOT_SERVER_PATH)
# Macro to check it's input file for banned dependencies and verify the
# binary built properly. Relies on process exit code.
ifndef CROSS_COMPILE_ARCH
define binary_file_verification # binary_file
( \
$(ECHO) "Checking for mapfile use in: $1" && \
@ -193,4 +202,10 @@ define binary_file_verification # binary_file
( $(READELF) -d $1 | $(EGREP) 'NEEDED|RUNPATH|RPATH' ) \
)
endef
else
define binary_file_verification
( \
$(ECHO) "Skipping binary file verification for cross-compile build" \
)
endef
endif

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2010, 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
@ -190,6 +190,7 @@ HOTSPOT_SERVER_PATH:=$(call AltCheckValue,HOTSPOT_SERVER_PATH)
# Macro to check it's input file for banned dependencies and verify the
# binary built properly. Relies on process exit code.
ifndef CROSS_COMPILE_ARCH
define binary_file_verification # binary_file
( \
$(ECHO) "Checking for mapfile use in: $1" && \
@ -202,4 +203,10 @@ define binary_file_verification # binary_file
( $(DUMP) -L -v $1 | $(EGREP) 'NEEDED|RUNPATH|RPATH' ) \
)
endef
else
define binary_file_verification
( \
$(ECHO) "Skipping binary file verification for cross-compile build" \
)
endef
endif

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2010, 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
@ -68,9 +68,23 @@ ifeq ($(PLATFORM),windows)
endif
# Utilities
ifdef CROSS_COMPILE_ARCH
AR = $(COMPILER_PATH)ar
AS = $(COMPILER_PATH)as
LD = $(COMPILER_PATH)ld
MCS = $(COMPILER_PATH)mcs
NM = $(COMPILER_PATH)nm
STRIP = $(COMPILER_PATH)strip
else
AR = $(UTILS_CCS_BIN_PATH)ar
AS = $(UTILS_CCS_BIN_PATH)as
LD = $(UTILS_CCS_BIN_PATH)ld
MCS = $(UTILS_CCS_BIN_PATH)mcs
NM = $(UTILS_CCS_BIN_PATH)nm
STRIP = $(UTILS_CCS_BIN_PATH)strip
endif
ADB = $(UTILS_COMMAND_PATH)adb
AR = $(UTILS_CCS_BIN_PATH)ar
AS = $(UTILS_CCS_BIN_PATH)as
BASENAME = $(UTILS_COMMAND_PATH)basename
BZIP2 = $(UTILS_COMMAND_PATH)bzip2
CAT = $(UTILS_COMMAND_PATH)cat
@ -99,19 +113,16 @@ HEAD = $(UTILS_USR_BIN_PATH)head
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
MCS = $(UTILS_CCS_BIN_PATH)mcs
M4 = $(UTILS_CCS_BIN_PATH)m4
MKDIR = $(UTILS_COMMAND_PATH)mkdir
MKSINFO = $(UTILS_COMMAND_PATH)mksinfo
MSGFMT = $(UTILS_USR_BIN_PATH)msgfmt
MV = $(UTILS_COMMAND_PATH)mv
NAWK = $(UTILS_USR_BIN_PATH)nawk
NM = $(UTILS_CCS_BIN_PATH)nm
PKGMK = $(UTILS_COMMAND_PATH)pkgmk
PRINTF = $(UTILS_USR_BIN_PATH)printf
PWD = $(UTILS_COMMAND_PATH)pwd
@ -123,7 +134,6 @@ SED = $(UTILS_COMMAND_PATH)sed
SH = $(UTILS_COMMAND_PATH)sh
SHOWREV = $(UTILS_USR_BIN_PATH)showrev
SORT = $(UTILS_COMMAND_PATH)sort
STRIP = $(UTILS_CCS_BIN_PATH)strip
TAIL = $(UTILS_USR_BIN_PATH)tail
TAR = $(UTILS_COMMAND_PATH)tar
TEST = $(UTILS_USR_BIN_PATH)test
@ -186,14 +196,16 @@ ifeq ($(PLATFORM),linux)
# Intrinsic unix command, with backslash-escaped character interpretation
ECHO = /bin/echo -e
# These are really in UTILS_USR_BIN_PATH on Linux
AR = $(UTILS_USR_BIN_PATH)ar
AS = $(UTILS_USR_BIN_PATH)as
LD = $(UTILS_USR_BIN_PATH)ld
ifndef CROSS_COMPILE_ARCH
AR = $(UTILS_USR_BIN_PATH)ar
AS = $(UTILS_USR_BIN_PATH)as
LD = $(UTILS_USR_BIN_PATH)ld
MCS = $(UTILS_USR_BIN_PATH)mcs
NM = $(UTILS_USR_BIN_PATH)nm
STRIP = $(UTILS_USR_BIN_PATH)strip
endif
LEX = $(UTILS_USR_BIN_PATH)lex
MCS = $(UTILS_USR_BIN_PATH)mcs
M4 = $(UTILS_USR_BIN_PATH)m4
NM = $(UTILS_USR_BIN_PATH)nm
STRIP = $(UTILS_USR_BIN_PATH)strip
YACC = $(UTILS_USR_BIN_PATH)yacc
endif

View File

@ -1,5 +1,5 @@
#
# 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
@ -138,11 +138,15 @@ ifeq ($(PLATFORM), solaris)
endif
REQUIRED_COMPILER_NAME = Sun Studio 12 Update 1
REQUIRED_COMPILER_VERSION = SS12u1
ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.10
endif
ifeq ($(CC_VERSION),gcc)
REQUIRED_CC_VER = 3.4.3
# Cross-compilation compiler versions are target specific
# so don't set a required version if cross-compiling
ifndef CROSS_COMPILE_ARCH
ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.10
endif
ifeq ($(CC_VERSION),gcc)
REQUIRED_CC_VER = 3.4.3
endif
endif
REQUIRED_GCC_VER = 2.95.2
endif
@ -158,11 +162,15 @@ ifeq ($(PLATFORM), linux)
REQUIRED_COMPILER_NAME = GCC4
REQUIRED_COMPILER_VERSION = GCC4
REQUIRED_GCC_VER = 2.95
ifeq ($(CC_VERSION),gcc)
REQUIRED_CC_VER = 4.3.0
endif
ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.10
# Cross-compilation compiler versions are target specific
# so don't set a required version if cross-compiling
ifndef CROSS_COMPILE_ARCH
ifeq ($(CC_VERSION),gcc)
REQUIRED_CC_VER = 4.3.0
endif
ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.10
endif
endif
endif

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1997, 20010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 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
@ -155,7 +155,11 @@ endif
ifeq ($(SYSTEM_UNAME), Linux)
PLATFORM = linux
# Arch and OS name/version
mach := $(shell uname -m)
ifdef CROSS_COMPILE_ARCH
mach := $(CROSS_COMPILE_ARCH)
else
mach := $(shell uname -m)
endif
archExpr = case "$(mach)" in \
i[3-9]86) \
echo i586 \
@ -192,11 +196,13 @@ ifeq ($(SYSTEM_UNAME), Linux)
ARCH=sparcv9
endif
else
# i586 is 32-bit, amd64 is 64-bit
# Most archs are 32-bit
ifndef ARCH_DATA_MODEL
ifeq ($(ARCH), i586)
ARCH_DATA_MODEL=32
else
ARCH_DATA_MODEL=32
ifeq ($(ARCH), amd64)
ARCH_DATA_MODEL=64
endif
ifeq ($(ARCH), ia64)
ARCH_DATA_MODEL=64
endif
endif

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2010, 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
@ -104,7 +104,11 @@ ifeq ($(PLATFORM),windows)
endif
ALL_SETTINGS+=$(call addOptionalSetting,COMPILER_NAME)
ALL_SETTINGS+=$(call addOptionalSetting,COMPILER_VERSION)
ALL_SETTINGS+=$(call addRequiredVersionSetting,CC_VER)
ifdef REQUIRED_CC_VER
ALL_SETTINGS+=$(call addRequiredVersionSetting,CC_VER)
else
ALL_SETTINGS+=$(call addOptionalSetting,CC_VER)
endif
ifeq ($(PLATFORM),solaris)
ifeq ($(ARCH_DATA_MODEL), 32)
ifndef OPENJDK

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2010, 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
@ -220,7 +220,7 @@ include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk
sane-ant_version \
sane-zip_version \
sane-unzip_version \
sane-msvcrt_path \
sane-msvcrt_path \
sane-freetype
######################################################
@ -279,6 +279,12 @@ sane-arch_data_model:
" $(YOU_ARE_USING) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL). \n" \
"" >> $(ERROR_FILE) ; \
fi
ifdef BUILD_CLIENT_ONLY
@if [ "$(ARCH_DATA_MODEL)" != 32 ]; then \
$(ECHO) "WARNING: You have requested BUILD_CLIENT_ONLY in a 64-bit build.\n" \
"" >> $(WARNING_FILE) ; \
fi
endif
######################################################
# Check the OS version (windows and linux have release name checks)
@ -811,23 +817,26 @@ sane-cacerts:
######################################################
ifdef OPENJDK
# The freetypecheck Makefile prints out "Failed" if not good enough
$(TEMPDIR)/freetypeinfo: FRC
ifndef CROSS_COMPILE_ARCH
# The freetypecheck Makefile prints out "Failed" if not good enough
$(TEMPDIR)/freetypeinfo: FRC
@$(prep-target)
@(($(CD) $(BUILDDIR)/tools/freetypecheck && $(MAKE)) || \
$(ECHO) "Failed to build freetypecheck." ) > $@
sane-freetype: $(TEMPDIR)/freetypeinfo
sane-freetype: $(TEMPDIR)/freetypeinfo
@if [ "`$(CAT) $< | $(GREP) Fail`" != "" ]; then \
$(ECHO) "ERROR: FreeType version " $(REQUIRED_FREETYPE_VERSION) \
" or higher is required. \n" \
"`$(CAT) $<` \n" >> $(ERROR_FILE) ; \
fi
else
#do nothing (cross-compiling)
sane-freetype:
endif
else
#do nothing (not OpenJDK)
sane-freetype:
#do nothing (not OpenJDK)
sane-freetype:
endif
######################################################
@ -1306,7 +1315,7 @@ ifeq ($(PLATFORM), windows)
" Microsoft DirectX 9 SDK can be downloaded from the following location:\n" \
" http://msdn.microsoft.com/library/default.asp?url=/downloads/list/directx.asp\n" \
" Or http://www.microsoft.com/directx\n" \
"" >> $(WARNING_FILE) ; \
"" >> $(WARNING_FILE) ; \
fi \
fi \
fi \
@ -1337,13 +1346,16 @@ endif
######################################################
# Check the compiler version(s)
######################################################
CC_CHECK :=$(call CheckVersions,$(CC_VER),$(REQUIRED_CC_VER))
ifdef REQUIRED_CC_VER
CC_CHECK :=$(call CheckVersions,$(CC_VER),$(REQUIRED_CC_VER))
endif
sane-compiler: sane-link
ifdef REQUIRED_CC_VER
@if [ "$(CC_CHECK)" = "missing" ]; then \
$(ECHO) "ERROR: The Compiler version is undefined. \n" \
"" >> $(ERROR_FILE) ; \
fi
ifndef OPENJDK
ifndef OPENJDK
@if [ "$(CC_CHECK)" != "same" ]; then \
$(ECHO) "WARNING: The $(PLATFORM) compiler is not version $(REQUIRED_COMPILER_VERSION) $(REQUIRED_CC_VER) \n" \
" Specifically the $(REQUIRED_COMPILER_NAME) compiler. \n " \
@ -1352,6 +1364,7 @@ ifndef OPENJDK
" $(COMPILER_PATH) \n" \
"" >> $(WARNING_FILE) ; \
fi
endif
endif
######################################################

View File

@ -1,5 +1,5 @@
#
# 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
@ -109,7 +109,7 @@ else
LDFLAGS += -R \$$ORIGIN/jli
endif
ifeq ($(PLATFORM), linux)
LDFLAGS += -Wl,-z -Wl,origin
LDFLAGS += $(LDFLAG_Z_ORIGIN)
LDFLAGS += -Wl,--allow-shlib-undefined
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/jli
endif

View File

@ -78,13 +78,17 @@ FILES_c = \
zutil.c
ifneq ($(PLATFORM), windows)
FILES_c += \
$(CTARGDIR)ergo.c \
$(CTARGDIR)ergo_$(ERGO_FAMILY).c
FILES_c += ergo.c
ERGO_ARCH_FILE = ergo_$(ERGO_FAMILY).c
# if the architecture specific ergo file exists then
# use it, else use the generic definitions from ergo.c
ifneq ($(wildcard $(LAUNCHER_PLATFORM_SRC)/$(ERGO_ARCH_FILE)),)
FILES_c += $(ERGO_ARCH_FILE)
else
OTHER_CPPFLAGS += -DUSE_GENERIC_ERGO
endif
endif
# Names of arch directories
LIBARCH_DEFINES = -DLIBARCHNAME='"$(LIBARCH)"'
ifeq ($(PLATFORM), solaris)

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1995, 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
@ -43,7 +43,8 @@ $(INCLUDEDIR)/%.h: $(SHARE_SRC)/javavm/export/%.h
$(PLATFORM_INCLUDE)/%.h: $(PLATFORM_SRC)/javavm/export/%.h
$(install-file)
JVMCFG = $(LIBDIR)/$(LIBARCH)/jvm.cfg
JVMCFG_DIR = $(LIBDIR)/$(LIBARCH)
JVMCFG = $(JVMCFG_DIR)/jvm.cfg
#
# How to install jvm.cfg.
@ -54,8 +55,21 @@ else
JVMCFG_ARCH = $(ARCH)
endif
ifdef BUILD_CLIENT_ONLY
$(JVMCFG)::
$(MKDIR) -p $(JVMCFG_DIR)
@# Update jvm.cfg to use -client by default and alias -server to -client
$(RM) -f $(JVMCFG)
$(ECHO) "-client KNOWN">$(JVMCFG)
$(ECHO) "-server ALIASED_TO -client">>$(JVMCFG)
$(ECHO) "-hotspot ALIASED_TO -client">>$(JVMCFG)
$(ECHO) "-classic WARN">>$(JVMCFG)
$(ECHO) "-native ERROR">>$(JVMCFG)
$(ECHO) "-green ERROR">>$(JVMCFG)
else
$(JVMCFG): $(PLATFORM_SRC)/bin/$(JVMCFG_ARCH)/jvm.cfg
$(install-file)
endif
all: build

View File

@ -1,5 +1,5 @@
#
# 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
@ -820,7 +820,7 @@ $(TEMPDIR)/$(GENSOR_SRC) : $(GENSOR_SRC)
$(GENSOR_EXE) : $(TEMPDIR)/$(GENSOR_SRC)
$(prep-target)
($(CD) $(TEMPDIR); $(CC) $(CPPFLAGS) $(LDDFLAGS) \
($(CD) $(TEMPDIR); $(HOST_CC) $(CPPFLAGS) $(LDDFLAGS) \
-o genSocketOptionRegistry$(EXE_SUFFIX) $(GENSOR_SRC))
$(SCH_GEN)/SocketOptionRegistry.java: $(GENSOR_EXE)
@ -851,7 +851,7 @@ GENUC_COPYRIGHT_YEARS = $(shell $(CAT) $(GENUC_SRC) | \
$(GENUC_EXE) : $(GENUC_SRC)
$(prep-target)
$(CC) $(CPPFLAGS) -o $@ $(GENUC_SRC)
$(HOST_CC) $(CPPFLAGS) -o $@ $(GENUC_SRC)
$(SFS_GEN)/UnixConstants.java: $(GENUC_EXE)
$(prep-target)
@ -867,7 +867,7 @@ GENSC_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSC_SRC) | \
$(GENSC_EXE) : $(GENSC_SRC)
$(prep-target)
$(CC) $(CPPFLAGS) -o $@ $(GENSC_SRC)
$(HOST_CC) $(CPPFLAGS) -o $@ $(GENSC_SRC)
$(SFS_GEN)/SolarisConstants.java: $(GENSC_EXE)
$(prep-target)

View File

@ -95,6 +95,8 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_NativeThread_current;
Java_sun_nio_ch_NativeThread_init;
Java_sun_nio_ch_NativeThread_signal;
Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0;
Java_sun_nio_ch_Net_canJoin6WithIPv4Group0;
Java_sun_nio_ch_Net_socket0;
Java_sun_nio_ch_Net_bind0;
Java_sun_nio_ch_Net_connect0;

View File

@ -82,6 +82,8 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_NativeThread_current;
Java_sun_nio_ch_NativeThread_init;
Java_sun_nio_ch_NativeThread_signal;
Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0;
Java_sun_nio_ch_Net_canJoin6WithIPv4Group0;
Java_sun_nio_ch_Net_socket0;
Java_sun_nio_ch_Net_bind0;
Java_sun_nio_ch_Net_connect0;

View File

@ -76,8 +76,12 @@ all:: build
INTERNAL_IMPORT_LIST = $(LIBDIR)/classlist
# List of files coming from outside this workspace
IMPORT_LIST = $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/Xusage.txt
ifndef BUILD_CLIENT_ONLY
IMPORT_LIST = $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/Xusage.txt
else
IMPORT_LIST =
endif
# Hotspot client is only available on 32-bit non-Zero builds
ifneq ($(ZERO_BUILD), true)
@ -97,10 +101,12 @@ $(BINDIR)/$(MSVCRNN_DLL): $(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL)
$(call chmod-file, a+x)
# Get the hotspot .map and .pdb files for client and server
ifndef BUILD_CLIENT_ONLY
IMPORT_LIST += \
$(LIBDIR)/$(JVMLIB_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMMAP_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMPDB_NAME)
endif
# Add .map and .pdb files to the import path for client and kernel VMs.
# These are only available on 32-bit windows builds.
@ -126,9 +132,11 @@ $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMMAP_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_KERNEL_PATH)/$(JVMMAP_NAME) $@
ifndef BUILD_CLIENT_ONLY
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMMAP_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_SERVER_PATH)/$(JVMMAP_NAME) $@
endif
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMPDB_NAME):
@$(prep-target)
@ -138,27 +146,32 @@ $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMPDB_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_KERNEL_PATH)/$(JVMPDB_NAME) $@
ifndef BUILD_CLIENT_ONLY
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMPDB_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_SERVER_PATH)/$(JVMPDB_NAME) $@
endif
# Windows ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Windows
else # PLATFORM
# NOT Windows vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv NOT Windows
IMPORT_LIST += \
$(LIB_LOCATION)/$(LIBJSIG_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME)
IMPORT_LIST += $(LIB_LOCATION)/$(LIBJSIG_NAME)
ifndef BUILD_CLIENT_ONLY
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME)
endif
ifeq ($(PLATFORM), solaris)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME)
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/$(JVMDB_NAME) not found!)
endif
endif
ifndef BUILD_CLIENT_ONLY
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME)
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/$(JVMDB_NAME) not found!)
endif
endif
endif
ifneq ($(ZERO_BUILD), true)
ifeq ($(ARCH_DATA_MODEL), 32)
@ -179,18 +192,20 @@ else
$(warning WARNING: $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME) not found!)
endif
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME) not found!)
endif
ifndef BUILD_CLIENT_ONLY
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME) not found!)
endif
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME) not found!)
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME) not found!)
endif
endif
# For backwards compatability, make a link of the 32-bit client JVM to $(LIBDIR)
@ -222,10 +237,16 @@ $(LIB_LOCATION)/$(LIBJSIG_NAME): $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJ
$(install-import-file)
@$(call binary_file_verification,$@)
ifndef BUILD_CLIENT_ONLY
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME):
@$(prep-target)
$(call install-sym-link, ../$(LIBJSIG_NAME))
else
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME):
@$(prep-target)
$(call install-sym-link, ../$(LIBJSIG_NAME))
endif
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDB_NAME)
$(install-import-file)
@ -235,6 +256,7 @@ $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_CLIENT_PATH)/64/$
$(install-import-file)
@$(call binary_file_verification,$@)
ifndef BUILD_CLIENT_ONLY
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
@ -242,6 +264,7 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB
$(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
endif
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME)
$(install-import-file)
@ -251,6 +274,7 @@ $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/
$(install-import-file)
@$(call binary_file_verification,$@)
ifndef BUILD_CLIENT_ONLY
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)
$(install-import-file)
@$(call binary_file_verification,$@)
@ -265,6 +289,7 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME): $(HOTSPOT_SERVER_PATH)/$(JVM_NAM
$(LIB_LOCATION)/$(SERVER_LOCATION)/Xusage.txt : $(HOTSPOT_SERVER_PATH)/Xusage.txt
$(install-import-file)
endif
$(LIB_LOCATION)/$(CLIENT_LOCATION)/Xusage.txt : $(HOTSPOT_CLIENT_PATH)/Xusage.txt
$(install-import-file)

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 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
@ -73,6 +73,15 @@ else
ifeq ($(ARCH), amd64)
CPPFLAGS += -DX_ARCH=X_AMD64
endif # ARCH amd64
ifeq ($(ARCH), arm)
CPPFLAGS += -DX_ARCH=X_ARM
endif # ARCH arm
ifeq ($(ARCH), ppc)
CPPFLAGS += -DX_ARCH=X_PPC
endif # ARCH ppc
endif

View File

@ -61,7 +61,7 @@ ifneq ($(PLATFORM), windows)
# ODBC_LIBRARY_LOCATION, and delete the variable assignments below.
#
# Tell linker to ignore missing externals when building this shared library.
LDFLAGS_DEFS_OPTION = -z nodefs
LDFLAGS_DEFS_OPTION = -Xlinker -z -Xlinker nodefs
# Define a place to create the fake libraries and their names.
ODBC_LIBRARY_LOCATION = $(TEMPDIR)
ODBC_FAKE_LIBRARIES = $(ODBC_LIBRARY_LOCATION)/libodbcinst.so $(ODBC_LIBRARY_LOCATION)/libodbc.so

View File

@ -376,6 +376,7 @@ FILES_gen_extcs = \
sun/nio/cs/ext/HKSCSMapping.java \
sun/nio/cs/ext/HKSCS2001Mapping.java \
sun/nio/cs/ext/HKSCS_XPMapping.java \
sun/nio/cs/ext/IBM1364.java \
sun/nio/cs/ext/IBM1381.java \
sun/nio/cs/ext/IBM1383.java \
sun/nio/cs/ext/IBM930.java \

View File

@ -0,0 +1,22 @@
#
# Diff of
# b2c: cdctables.zip/Package2.zip/IBM-1364A.zip/055444B0.TPMAP110
# c2b: cdctables.zip/Package2.zip/IBM-1364A.zip/055444B0.UPMAP110
# shows there are 6 additional c->b entries in UPMAP110, they are
# listed below (in b->c form)
#
# UPMAP110 also defines
# <subchar> \xFE\xFE
# and commend out
# #<subchar1> \x3F
# with
#
# <UFFFD> \xFE\xFD # (SUB)
# <UFFFD> \xFE\xFE # (SUB)
#
4148 00AD
4143 00B7
4149 2015
42A1 223C
496F 2299
4954 FF5E

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@ MS936 x-mswin-936 MS936 basic sun.nio.cs.ext true 0x81 0xfe 0x
MS949 x-windows-949 MS949 basic sun.nio.cs.ext true 0x81 0xfe 0x41 0xfe
MS950 x-windows-950 MS950 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe
GBK GBK GBK basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe
IBM1364 x-IBM1364 Cp1364 ebcdic sun.nio.cs.ext false 0x40 0xde 0x40 0xfe
IBM1381 x-IBM1381 Cp1381 basic sun.nio.cs.ext true 0x8c 0xf7 0xa1 0xfe
IBM1383 x-IBM1383 Cp1383 euc_sim sun.nio.cs.ext true 0xa1 0xfe 0xa1 0xfe
IBM930 x-IBM930 Cp930 ebcdic sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1998, 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
@ -30,6 +30,7 @@
BUILDDIR = ..
include $(BUILDDIR)/common/Defs.gmk
# Note: freetypecheck is built by Sanity.gmk if needed
SUBDIRS = \
addjsum \
buildmetaindex \
@ -38,7 +39,6 @@ SUBDIRS = \
compile_properties \
dir_diff \
dtdbuilder \
freetypecheck \
generate_break_iterator \
GenerateCharacter \
generatecurrencydata \

View File

@ -61,6 +61,9 @@
* interfaces.
*/
/* we always print to stderr */
#define USE_STDERR JNI_TRUE
static jboolean printVersion = JNI_FALSE; /* print and exit */
static jboolean showVersion = JNI_FALSE; /* print but continue */
static jboolean printUsage = JNI_FALSE; /* print and exit*/
@ -1136,36 +1139,18 @@ InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn)
return; \
}
static jstring platformEncoding = NULL;
static jstring getPlatformEncoding(JNIEnv *env) {
if (platformEncoding == NULL) {
jstring propname = (*env)->NewStringUTF(env, "sun.jnu.encoding");
if (propname) {
jclass cls;
jmethodID mid;
NULL_CHECK0 (cls = FindBootStrapClass(env, "java/lang/System"));
NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
env, cls,
"getProperty",
"(Ljava/lang/String;)Ljava/lang/String;"));
platformEncoding = (*env)->CallStaticObjectMethod (
env, cls, mid, propname);
}
static jclass helperClass = NULL;
static jclass
GetLauncherHelperClass(JNIEnv *env) {
if (helperClass == NULL) {
NULL_CHECK0(helperClass = FindBootStrapClass(env,
"sun/launcher/LauncherHelper"));
}
return platformEncoding;
}
static jboolean isEncodingSupported(JNIEnv *env, jstring enc) {
jclass cls;
jmethodID mid;
NULL_CHECK0 (cls = FindBootStrapClass(env, "java/nio/charset/Charset"));
NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
env, cls,
"isSupported",
"(Ljava/lang/String;)Z"));
return (*env)->CallStaticBooleanMethod(env, cls, mid, enc);
return helperClass;
}
static jmethodID makePlatformStringMID = NULL;
/*
* Returns a new Java string object for the specified platform string.
*/
@ -1173,36 +1158,23 @@ static jstring
NewPlatformString(JNIEnv *env, char *s)
{
int len = (int)JLI_StrLen(s);
jclass cls;
jmethodID mid;
jbyteArray ary;
jstring enc;
jclass cls = GetLauncherHelperClass(env);
NULL_CHECK0(cls);
if (s == NULL)
return 0;
enc = getPlatformEncoding(env);
ary = (*env)->NewByteArray(env, len);
if (ary != 0) {
jstring str = 0;
(*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
if (!(*env)->ExceptionOccurred(env)) {
NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String"));
if (isEncodingSupported(env, enc) == JNI_TRUE) {
NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
"([BLjava/lang/String;)V"));
str = (*env)->NewObject(env, cls, mid, ary, enc);
} else {
/*If the encoding specified in sun.jnu.encoding is not
endorsed by "Charset.isSupported" we have to fall back
to use String(byte[]) explicitly here without specifying
the encoding name, in which the StringCoding class will
pickup the iso-8859-1 as the fallback converter for us.
*/
NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
"([B)V"));
str = (*env)->NewObject(env, cls, mid, ary);
if (makePlatformStringMID == NULL) {
NULL_CHECK0(makePlatformStringMID = (*env)->GetStaticMethodID(env,
cls, "makePlatformString", "(Z[B)Ljava/lang/String;"));
}
str = (*env)->CallStaticObjectMethod(env, cls,
makePlatformStringMID, USE_STDERR, ary);
(*env)->DeleteLocalRef(env, ary);
return str;
}
@ -1239,20 +1211,28 @@ NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
static jclass
LoadMainClass(JNIEnv *env, int mode, char *name)
{
jclass cls;
jmethodID mid;
jstring str;
jobject result;
jlong start, end;
jclass cls = GetLauncherHelperClass(env);
NULL_CHECK0(cls);
if (JLI_IsTraceLauncher()) {
start = CounterGet();
}
NULL_CHECK0(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, "checkAndLoadMain",
"(ZILjava/lang/String;)Ljava/lang/Class;"));
str = (*env)->NewStringUTF(env, name);
result = (*env)->CallStaticObjectMethod(env, cls, mid, JNI_TRUE, mode, str);
NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
"checkAndLoadMain",
"(ZILjava/lang/String;)Ljava/lang/Class;"));
switch (mode) {
case LM_CLASS:
str = NewPlatformString(env, name);
break;
default:
str = (*env)->NewStringUTF(env, name);
break;
}
result = (*env)->CallStaticObjectMethod(env, cls, mid, USE_STDERR, mode, str);
if (JLI_IsTraceLauncher()) {
end = CounterGet();
@ -1478,15 +1458,15 @@ PrintJavaVersion(JNIEnv *env, jboolean extraLF)
static void
ShowSettings(JNIEnv *env, char *optString)
{
jclass cls;
jmethodID showSettingsID;
jstring joptString;
NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
jclass cls = GetLauncherHelperClass(env);
NULL_CHECK(cls);
NULL_CHECK(showSettingsID = (*env)->GetStaticMethodID(env, cls,
"showSettings", "(ZLjava/lang/String;JJJZ)V"));
joptString = (*env)->NewStringUTF(env, optString);
(*env)->CallStaticVoidMethod(env, cls, showSettingsID,
JNI_TRUE,
USE_STDERR,
joptString,
(jlong)initialHeapSize,
(jlong)maxHeapSize,
@ -1500,18 +1480,15 @@ ShowSettings(JNIEnv *env, char *optString)
static void
PrintUsage(JNIEnv* env, jboolean doXUsage)
{
jclass cls;
jmethodID initHelp, vmSelect, vmSynonym, vmErgo, printHelp, printXUsageMessage;
jstring jprogname, vm1, vm2;
int i;
NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
jclass cls = GetLauncherHelperClass(env);
NULL_CHECK(cls);
if (doXUsage) {
NULL_CHECK(printXUsageMessage = (*env)->GetStaticMethodID(env, cls,
"printXUsageMessage", "(Z)V"));
(*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, JNI_TRUE);
(*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, USE_STDERR);
} else {
NULL_CHECK(initHelp = (*env)->GetStaticMethodID(env, cls,
"initHelpMessage", "(Ljava/lang/String;)V"));
@ -1570,7 +1547,7 @@ PrintUsage(JNIEnv* env, jboolean doXUsage)
}
/* Complete the usage message and print to stderr*/
(*env)->CallStaticVoidMethod(env, cls, printHelp, JNI_TRUE);
(*env)->CallStaticVoidMethod(env, cls, printHelp, USE_STDERR);
}
return;
}

View File

@ -743,24 +743,24 @@ class BandStructure {
private void dumpBand() throws IOException {
assert(optDumpBands);
PrintStream ps = new PrintStream(getDumpStream(this, ".txt"));
String irr = (bandCoding == regularCoding) ? "" : " irregular";
ps.print("# length="+length+
" size="+outputSize()+
irr+" coding="+bandCoding);
if (metaCoding != noMetaCoding) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < metaCoding.length; i++) {
if (i == 1) sb.append(" /");
sb.append(" ").append(metaCoding[i] & 0xFF);
try (PrintStream ps = new PrintStream(getDumpStream(this, ".txt"))) {
String irr = (bandCoding == regularCoding) ? "" : " irregular";
ps.print("# length="+length+
" size="+outputSize()+
irr+" coding="+bandCoding);
if (metaCoding != noMetaCoding) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < metaCoding.length; i++) {
if (i == 1) sb.append(" /");
sb.append(" ").append(metaCoding[i] & 0xFF);
}
ps.print(" //header: "+sb);
}
ps.print(" //header: "+sb);
printArrayTo(ps, values, 0, length);
}
try (OutputStream ds = getDumpStream(this, ".bnd")) {
bandCoding.writeArrayTo(ds, values, 0, length);
}
printArrayTo(ps, values, 0, length);
ps.close();
OutputStream ds = getDumpStream(this, ".bnd");
bandCoding.writeArrayTo(ds, values, 0, length);
ds.close();
}
/** Disburse one value. */
@ -829,12 +829,12 @@ class BandStructure {
private void dumpBand() throws IOException {
assert(optDumpBands);
OutputStream ds = getDumpStream(this, ".bnd");
if (bytesForDump != null)
bytesForDump.writeTo(ds);
else
bytes.writeTo(ds);
ds.close();
try (OutputStream ds = getDumpStream(this, ".bnd")) {
if (bytesForDump != null)
bytesForDump.writeTo(ds);
else
bytes.writeTo(ds);
}
}
public void readDataFrom(InputStream in) throws IOException {

View File

@ -150,12 +150,12 @@ class Driver {
// See if there is any other action to take.
if ("--config-file=".equals(state)) {
String propFile = av.remove(0);
InputStream propIn = new FileInputStream(propFile);
Properties fileProps = new Properties();
fileProps.load(new BufferedInputStream(propIn));
try (InputStream propIn = new FileInputStream(propFile)) {
fileProps.load(propIn);
}
if (engProps.get(verboseProp) != null)
fileProps.list(System.out);
propIn.close();
for (Map.Entry<Object,Object> me : fileProps.entrySet()) {
engProps.put((String) me.getKey(), (String) me.getValue());
}
@ -348,10 +348,10 @@ class Driver {
else
fileOut = new FileOutputStream(outfile);
fileOut = new BufferedOutputStream(fileOut);
JarOutputStream out = new JarOutputStream(fileOut);
junpack.unpack(in, out);
//in.close(); // p200 closes in but not out
out.close();
try (JarOutputStream out = new JarOutputStream(fileOut)) {
junpack.unpack(in, out);
// p200 closes in but not out
}
// At this point, we have a good jarfile (or newfile, if -r)
}
@ -411,8 +411,7 @@ class Driver {
long filelen = new File(jarfile).length();
if (filelen <= 0) return "";
long skiplen = Math.max(0, filelen - tail.length);
InputStream in = new FileInputStream(new File(jarfile));
try {
try (InputStream in = new FileInputStream(new File(jarfile))) {
in.skip(skiplen);
in.read(tail);
for (int i = tail.length-4; i >= 0; i--) {
@ -426,8 +425,6 @@ class Driver {
}
}
return "";
} finally {
in.close();
}
}

View File

@ -241,9 +241,9 @@ class NativeUnpack {
void run(File inFile, JarOutputStream jstream) throws IOException {
// %%% maybe memory-map the file, and pass it straight into unpacker
ByteBuffer mappedFile = null;
FileInputStream fis = new FileInputStream(inFile);
run(fis, jstream, mappedFile);
fis.close();
try (FileInputStream fis = new FileInputStream(inFile)) {
run(fis, jstream, mappedFile);
}
// Note: caller is responsible to finish with jstream.
}

View File

@ -540,9 +540,9 @@ class PackageReader extends BandStructure {
Index index = initCPIndex(tag, cpMap);
if (optDumpBands) {
PrintStream ps = new PrintStream(getDumpStream(index, ".idx"));
printArrayTo(ps, index.cpMap, 0, index.cpMap.length);
ps.close();
try (PrintStream ps = new PrintStream(getDumpStream(index, ".idx"))) {
printArrayTo(ps, index.cpMap, 0, index.cpMap.length);
}
}
}
@ -828,26 +828,27 @@ class PackageReader extends BandStructure {
attr_definition_headers.readFrom(in);
attr_definition_name.readFrom(in);
attr_definition_layout.readFrom(in);
PrintStream dump = !optDumpBands ? null
: new PrintStream(getDumpStream(attr_definition_headers, ".def"));
for (int i = 0; i < numAttrDefs; i++) {
int header = attr_definition_headers.getByte();
Utf8Entry name = (Utf8Entry) attr_definition_name.getRef();
Utf8Entry layout = (Utf8Entry) attr_definition_layout.getRef();
int ctype = (header & ADH_CONTEXT_MASK);
int index = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB;
Attribute.Layout def = new Attribute.Layout(ctype,
name.stringValue(),
layout.stringValue());
// Check layout string for Java 6 extensions.
String pvLayout = def.layoutForPackageMajver(getPackageMajver());
if (!pvLayout.equals(def.layout())) {
throw new IOException("Bad attribute layout in version 150 archive: "+def.layout());
try (PrintStream dump = !optDumpBands ? null
: new PrintStream(getDumpStream(attr_definition_headers, ".def")))
{
for (int i = 0; i < numAttrDefs; i++) {
int header = attr_definition_headers.getByte();
Utf8Entry name = (Utf8Entry) attr_definition_name.getRef();
Utf8Entry layout = (Utf8Entry) attr_definition_layout.getRef();
int ctype = (header & ADH_CONTEXT_MASK);
int index = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB;
Attribute.Layout def = new Attribute.Layout(ctype,
name.stringValue(),
layout.stringValue());
// Check layout string for Java 6 extensions.
String pvLayout = def.layoutForPackageMajver(getPackageMajver());
if (!pvLayout.equals(def.layout())) {
throw new IOException("Bad attribute layout in version 150 archive: "+def.layout());
}
this.setAttributeLayoutIndex(def, index);
if (dump != null) dump.println(index+" "+def);
}
this.setAttributeLayoutIndex(def, index);
if (dump != null) dump.println(index+" "+def);
}
if (dump != null) dump.close();
attr_definition_headers.doneDisbursing();
attr_definition_name.doneDisbursing();
attr_definition_layout.doneDisbursing();

View File

@ -458,9 +458,9 @@ class PackageWriter extends BandStructure {
Utils.log.info("Writing "+cpMap.length+" "+ConstantPool.tagName(tag)+" entries...");
if (optDumpBands) {
PrintStream ps = new PrintStream(getDumpStream(index, ".idx"));
printArrayTo(ps, cpMap, 0, cpMap.length);
ps.close();
try (PrintStream ps = new PrintStream(getDumpStream(index, ".idx"))) {
printArrayTo(ps, cpMap, 0, cpMap.length);
}
}
switch (tag) {
@ -923,33 +923,34 @@ class PackageWriter extends BandStructure {
}
});
attrDefsWritten = new Attribute.Layout[numAttrDefs];
PrintStream dump = !optDumpBands ? null
: new PrintStream(getDumpStream(attr_definition_headers, ".def"));
int[] indexForDebug = Arrays.copyOf(attrIndexLimit, ATTR_CONTEXT_LIMIT);
for (int i = 0; i < defs.length; i++) {
int header = ((Integer)defs[i][0]).intValue();
Attribute.Layout def = (Attribute.Layout) defs[i][1];
attrDefsWritten[i] = def;
assert((header & ADH_CONTEXT_MASK) == def.ctype());
attr_definition_headers.putByte(header);
attr_definition_name.putRef(ConstantPool.getUtf8Entry(def.name()));
String layout = def.layoutForPackageMajver(getPackageMajver());
attr_definition_layout.putRef(ConstantPool.getUtf8Entry(layout));
// Check that we are transmitting that correct attribute index:
boolean debug = false;
assert(debug = true);
if (debug) {
int hdrIndex = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB;
if (hdrIndex < 0) hdrIndex = indexForDebug[def.ctype()]++;
int realIndex = (attrIndexTable.get(def)).intValue();
assert(hdrIndex == realIndex);
}
if (dump != null) {
int index = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB;
dump.println(index+" "+def);
try (PrintStream dump = !optDumpBands ? null
: new PrintStream(getDumpStream(attr_definition_headers, ".def")))
{
int[] indexForDebug = Arrays.copyOf(attrIndexLimit, ATTR_CONTEXT_LIMIT);
for (int i = 0; i < defs.length; i++) {
int header = ((Integer)defs[i][0]).intValue();
Attribute.Layout def = (Attribute.Layout) defs[i][1];
attrDefsWritten[i] = def;
assert((header & ADH_CONTEXT_MASK) == def.ctype());
attr_definition_headers.putByte(header);
attr_definition_name.putRef(ConstantPool.getUtf8Entry(def.name()));
String layout = def.layoutForPackageMajver(getPackageMajver());
attr_definition_layout.putRef(ConstantPool.getUtf8Entry(layout));
// Check that we are transmitting that correct attribute index:
boolean debug = false;
assert(debug = true);
if (debug) {
int hdrIndex = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB;
if (hdrIndex < 0) hdrIndex = indexForDebug[def.ctype()]++;
int realIndex = (attrIndexTable.get(def)).intValue();
assert(hdrIndex == realIndex);
}
if (dump != null) {
int index = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB;
dump.println(index+" "+def);
}
}
}
if (dump != null) dump.close();
}
void writeAttrCounts() throws IOException {

View File

@ -122,26 +122,23 @@ final class PropMap implements SortedMap<Object, Object> {
// Define certain attribute layouts by default.
// Do this after the previous props are put in place,
// to allow override if necessary.
InputStream propStr = null;
try {
String propFile = "intrinsic.properties";
propStr = PackerImpl.class.getResourceAsStream(propFile);
props.load(new BufferedInputStream(propStr));
for (Map.Entry<Object, Object> e : props.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
if (key.startsWith("attribute.")) {
e.setValue(Attribute.normalizeLayoutString(val));
}
String propFile = "intrinsic.properties";
try (InputStream propStr = PackerImpl.class.getResourceAsStream(propFile)) {
if (propStr == null) {
throw new RuntimeException(propFile + " cannot be loaded");
}
props.load(propStr);
} catch (IOException ee) {
throw new RuntimeException(ee);
} finally {
try {
if (propStr != null) {
propStr.close();
}
} catch (IOException ignore) {}
}
for (Map.Entry<Object, Object> e : props.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
if (key.startsWith("attribute.")) {
e.setValue(Attribute.normalizeLayoutString(val));
}
}
defaultProps = (new HashMap<>(props)); // shrink to fit

View File

@ -161,8 +161,9 @@ public class UnpackerImpl extends TLGlobals implements Pack200.Unpacker {
}
// Use the stream-based implementation.
// %%% Reconsider if native unpacker learns to memory-map the file.
FileInputStream instr = new FileInputStream(in);
unpack(instr, out);
try (FileInputStream instr = new FileInputStream(in)) {
unpack(instr, out);
}
if (props.getBoolean(Utils.UNPACK_REMOVE_PACKFILE)) {
in.delete();
}

View File

@ -268,18 +268,18 @@ class Utils {
// 4947205 : Peformance is slow when using pack-effort=0
out = new BufferedOutputStream(out);
out = new NonCloser(out); // protect from JarOutputStream.close()
JarOutputStream jout = new JarOutputStream(out);
copyJarFile(in, jout);
jout.close();
try (JarOutputStream jout = new JarOutputStream(out)) {
copyJarFile(in, jout);
}
}
static void copyJarFile(JarFile in, OutputStream out) throws IOException {
// 4947205 : Peformance is slow when using pack-effort=0
out = new BufferedOutputStream(out);
out = new NonCloser(out); // protect from JarOutputStream.close()
JarOutputStream jout = new JarOutputStream(out);
copyJarFile(in, jout);
jout.close();
try (JarOutputStream jout = new JarOutputStream(out)) {
copyJarFile(in, jout);
}
}
// Wrapper to prevent closing of client-supplied stream.
static private

View File

@ -115,6 +115,31 @@ public final class RhinoScriptEngine extends AbstractScriptEngine
//construct object used to implement getInterface
implementor = new InterfaceImplementor(this) {
protected boolean isImplemented(Object thiz, Class<?> iface) {
Context cx = enterContext();
try {
if (thiz != null && !(thiz instanceof Scriptable)) {
thiz = cx.toObject(thiz, topLevel);
}
Scriptable engineScope = getRuntimeScope(context);
Scriptable localScope = (thiz != null)? (Scriptable) thiz :
engineScope;
for (Method method : iface.getMethods()) {
// ignore methods of java.lang.Object class
if (method.getDeclaringClass() == Object.class) {
continue;
}
Object obj = ScriptableObject.getProperty(localScope, method.getName());
if (! (obj instanceof Function)) {
return false;
}
}
return true;
} finally {
cx.exit();
}
}
protected Object convertResult(Method method, Object res)
throws ScriptException {
Class desiredType = method.getReturnType();

View File

@ -82,12 +82,19 @@ public class InterfaceImplementor {
if (iface == null || !iface.isInterface()) {
throw new IllegalArgumentException("interface Class expected");
}
if (! isImplemented(thiz, iface)) {
return null;
}
AccessControlContext accCtxt = AccessController.getContext();
return iface.cast(Proxy.newProxyInstance(iface.getClassLoader(),
new Class[]{iface},
new InterfaceImplementorInvocationHandler(thiz, accCtxt)));
}
protected boolean isImplemented(Object thiz, Class<?> iface) {
return true;
}
// called to convert method result after invoke
protected Object convertResult(Method method, Object res)
throws ScriptException {

View File

@ -34,12 +34,27 @@ package java.lang;
public interface AutoCloseable {
/**
* Closes this resource, relinquishing any underlying resources.
* This method is invoked automatically by the {@code
* try}-with-resources statement.
* This method is invoked automatically on objects managed by the
* {@code try}-with-resources statement.
*
* <p>Classes implementing this method are strongly encouraged to
* be declared to throw more specific exceptions (or no exception
* at all, if the close cannot fail).
* <p>While this interface method is declared to throw {@code
* Exception}, implementers are <em>strongly</em> encouraged to
* declare concrete implementations of the {@code close} method to
* throw more specific exceptions, or to throw no exception at all
* if the close operation cannot fail.
*
* <p><em>Implementers of this interface are also strongly advised
* to not have the {@code close} method throw {@link
* InterruptedException}.</em>
*
* This exception interacts with a thread's interrupted status,
* and runtime misbehavior is likely to occur if an {@code
* InterruptedException} is {@linkplain Throwable#addSuppressed
* suppressed}.
*
* More generally, if it would cause problems for an
* exception to be suppressed, the {@code AutoCloseable.close}
* method should not throw it.
*
* <p>Note that unlike the {@link java.io.Closeable#close close}
* method of {@link java.io.Closeable}, this {@code close} method
@ -48,9 +63,8 @@ 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.
* However, implementers of this interface are strongly encouraged
* to make their {@code close} methods idempotent.
*
* @throws Exception if this resource cannot be closed
*/

View File

@ -1,5 +1,5 @@
/*
* 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
@ -1626,20 +1626,28 @@ public abstract class ClassLoader {
* @since 1.2
*/
protected Package getPackage(String name) {
Package pkg;
synchronized (packages) {
Package pkg = packages.get(name);
if (pkg == null) {
if (parent != null) {
pkg = parent.getPackage(name);
} else {
pkg = Package.getSystemPackage(name);
}
if (pkg != null) {
packages.put(name, pkg);
pkg = packages.get(name);
}
if (pkg == null) {
if (parent != null) {
pkg = parent.getPackage(name);
} else {
pkg = Package.getSystemPackage(name);
}
if (pkg != null) {
synchronized (packages) {
Package pkg2 = packages.get(name);
if (pkg2 == null) {
packages.put(name, pkg);
} else {
pkg = pkg2;
}
}
}
return pkg;
}
return pkg;
}
/**

View File

@ -1829,21 +1829,23 @@ public final class URI
} else if (authority != null) {
sb.append("//");
if (authority.startsWith("[")) {
// authority should (but may not) contain an embedded IPv6 address
int end = authority.indexOf("]");
if (end != -1 && authority.indexOf(":")!=-1) {
String doquote, dontquote;
String doquote = authority, dontquote = "";
if (end != -1 && authority.indexOf(":") != -1) {
// the authority contains an IPv6 address
if (end == authority.length()) {
dontquote = authority;
doquote = "";
} else {
dontquote = authority.substring(0,end+1);
doquote = authority.substring(end+1);
dontquote = authority.substring(0 , end + 1);
doquote = authority.substring(end + 1);
}
sb.append (dontquote);
sb.append(quote(doquote,
}
sb.append(dontquote);
sb.append(quote(doquote,
L_REG_NAME | L_SERVER,
H_REG_NAME | H_SERVER));
}
} else {
sb.append(quote(authority,
L_REG_NAME | L_SERVER,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
@ -1422,7 +1422,7 @@ public abstract class URLConnection {
if (!is.markSupported())
return null;
is.mark(12);
is.mark(16);
int c1 = is.read();
int c2 = is.read();
int c3 = is.read();
@ -1434,6 +1434,11 @@ public abstract class URLConnection {
int c9 = is.read();
int c10 = is.read();
int c11 = is.read();
int c12 = is.read();
int c13 = is.read();
int c14 = is.read();
int c15 = is.read();
int c16 = is.read();
is.reset();
if (c1 == 0xCA && c2 == 0xFE && c3 == 0xBA && c4 == 0xBE) {
@ -1461,6 +1466,13 @@ public abstract class URLConnection {
}
}
// big and little (identical) endian UTF-8 encodings, with BOM
if (c1 == 0xef && c2 == 0xbb && c3 == 0xbf) {
if (c4 == '<' && c5 == '?' && c6 == 'x') {
return "application/xml";
}
}
// big and little endian UTF-16 encodings, with byte order mark
if (c1 == 0xfe && c2 == 0xff) {
if (c3 == 0 && c4 == '<' && c5 == 0 && c6 == '?' &&
@ -1476,6 +1488,23 @@ public abstract class URLConnection {
}
}
// big and little endian UTF-32 encodings, with BOM
if (c1 == 0x00 && c2 == 0x00 && c3 == 0xfe && c4 == 0xff) {
if (c5 == 0 && c6 == 0 && c7 == 0 && c8 == '<' &&
c9 == 0 && c10 == 0 && c11 == 0 && c12 == '?' &&
c13 == 0 && c14 == 0 && c15 == 0 && c16 == 'x') {
return "application/xml";
}
}
if (c1 == 0xff && c2 == 0xfe && c3 == 0x00 && c4 == 0x00) {
if (c5 == '<' && c6 == 0 && c7 == 0 && c8 == 0 &&
c9 == '?' && c10 == 0 && c11 == 0 && c12 == 0 &&
c13 == 'x' && c14 == 0 && c15 == 0 && c16 == 0) {
return "application/xml";
}
}
if (c1 == 'G' && c2 == 'I' && c3 == 'F' && c4 == '8') {
return "image/gif";
}

View File

@ -1712,10 +1712,10 @@ public final class Files {
* @return the {@code path} parameter
*
* @throws UnsupportedOperationException
* if the attribute view is not available or it does not support
* updating the attribute
* if the attribute view is not available
* @throws IllegalArgumentException
* if the attribute value is of the correct type but has an
* if the attribute name is not specified, or is not recognized, or
* the attribute value is of the correct type but has an
* inappropriate value
* @throws ClassCastException
* if the attribute value is not of the expected type or is a
@ -1776,9 +1776,12 @@ public final class Files {
* @param options
* options indicating how symbolic links are handled
*
* @return the attribute value or {@code null} if the attribute view
* is not available or it does not support reading the attribute
* @return the attribute value
*
* @throws UnsupportedOperationException
* if the attribute view is not available
* @throws IllegalArgumentException
* if the attribute name is not specified or is not recognized
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
@ -1794,8 +1797,9 @@ public final class Files {
{
// only one attribute should be read
if (attribute.indexOf('*') >= 0 || attribute.indexOf(',') >= 0)
return null;
throw new IllegalArgumentException(attribute);
Map<String,Object> map = readAttributes(path, attribute, options);
assert map.size() == 1;
String name;
int pos = attribute.indexOf(':');
if (pos == -1) {
@ -1868,9 +1872,14 @@ public final class Files {
* @param options
* options indicating how symbolic links are handled
*
* @return a map of the attributes returned; may be empty. The map's keys
* are the attribute names, its values are the attribute values
* @return a map of the attributes returned; The map's keys are the
* attribute names, its values are the attribute values
*
* @throws UnsupportedOperationException
* if the attribute view is not available
* @throws IllegalArgumentException
* if no attributes are specified or an unrecognized attributes is
* specified
* @throws IOException
* if an I/O error occurs
* @throws SecurityException

View File

@ -228,6 +228,9 @@ public interface Path
* not have a root component and the given path has a root component then
* this path does not start with the given path.
*
* <p> If the given path is associated with a different {@code FileSystem}
* to this path then {@code false} is returned.
*
* @param other
* the given path
*
@ -270,6 +273,9 @@ public interface Path
* does not have a root component and the given path has a root component
* then this path does not end with the given path.
*
* <p> If the given path is associated with a different {@code FileSystem}
* to this path then {@code false} is returned.
*
* @param other
* the given path
*
@ -283,7 +289,10 @@ public interface Path
* the given path string, in exactly the manner specified by the {@link
* #endsWith(Path) endsWith(Path)} method. On UNIX for example, the path
* "{@code foo/bar}" ends with "{@code foo/bar}" and "{@code bar}". It does
* not end with "{@code r}" or "{@code /bar}".
* not end with "{@code r}" or "{@code /bar}". Note that trailing separators
* are not taken into account, and so invoking this method on the {@code
* Path}"{@code foo/bar}" with the {@code String} "{@code bar/}" returns
* {@code true}.
*
* @param other
* the given path string
@ -724,12 +733,18 @@ public interface Path
* provider, platform specific. This method does not access the file system
* and neither file is required to exist.
*
* <p> This method may not be used to compare paths that are associated
* with different file system providers.
*
* @param other the path compared to this path.
*
* @return zero if the argument is {@link #equals equal} to this path, a
* value less than zero if this path is lexicographically less than
* the argument, or a value greater than zero if this path is
* lexicographically greater than the argument
*
* @throws ClassCastException
* if the paths are associated with different providers
*/
@Override
int compareTo(Path other);
@ -738,7 +753,7 @@ public interface Path
* Tests this path for equality with the given object.
*
* <p> If the given object is not a Path, or is a Path associated with a
* different provider, then this method immediately returns {@code false}.
* different {@code FileSystem}, then this method returns {@code false}.
*
* <p> Whether or not two path are equal depends on the file system
* implementation. In some cases the paths are compared without regard

View File

@ -146,5 +146,5 @@ public interface WatchKey {
*
* @return the object for which this watch key was created
*/
//T watchable();
Watchable watchable();
}

View File

@ -216,12 +216,14 @@ public final class FileTime
* "2009-02-13T23:31:30Z"}, and {@code FileTime.fromMillis(1234567890123L).toString()}
* yields {@code "2009-02-13T23:31:30.123Z"}.
*
* <p> A {@code FileTime} is primarly intended to represent the value of a
* <p> A {@code FileTime} is primarily intended to represent the value of a
* file's time stamp. Where used to represent <i>extreme values</i>, where
* the year is less than "{@code 0001}" or greater than "{@code 9999}" then
* the year may be expanded to more than four digits and may be
* negative-signed. If more than four digits then leading zeros are not
* present. The year before "{@code 0001}" is "{@code -0001}".
* this method deviates from ISO 8601 in the same manner as the
* <a href="http://www.w3.org/TR/xmlschema-2/#deviantformats">XML Schema
* language</a>. That is, the year may be expanded to more than four digits
* and may be negative-signed. If more than four digits then leading zeros
* are not present. The year before "{@code 0001}" is "{@code -0001}".
*
* @return the string representation of this file time
*/

View File

@ -1037,6 +1037,11 @@ public abstract class FileSystemProvider {
* @return a map of the attributes returned; may be empty. The map's keys
* are the attribute names, its values are the attribute values
*
* @throws UnsupportedOperationException
* if the attribute view is not available
* @throws IllegalArgumentException
* if no attributes are specified or an unrecognized attributes is
* specified
* @throws IOException
* If an I/O error occurs
* @throws SecurityException
@ -1064,10 +1069,10 @@ public abstract class FileSystemProvider {
* options indicating how symbolic links are handled
*
* @throws UnsupportedOperationException
* if the attribute view is not available or it does not support
* updating the attribute
* if the attribute view is not available
* @throws IllegalArgumentException
* if the attribute value is of the correct type but has an
* if the attribute name is not specified, or is not recognized, or
* the attribute value is of the correct type but has an
* inappropriate value
* @throws ClassCastException
* If the attribute value is not of the expected type or is a

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -578,7 +578,7 @@ public class CodeSource implements java.io.Serializable {
// Deserialize array of code signers (if any)
try {
this.signers = (CodeSigner[])ois.readObject();
this.signers = ((CodeSigner[])ois.readObject()).clone();
} catch (IOException ioe) {
// no signers present
}

View File

@ -1,5 +1,5 @@
/*
* 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
@ -157,7 +157,8 @@ public final class Timestamp implements Serializable {
// Explicitly reset hash code value to -1
private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException {
ois.defaultReadObject();
myhash = -1;
ois.defaultReadObject();
myhash = -1;
timestamp = new Date(timestamp.getTime());
}
}

View File

@ -1,5 +1,5 @@
/*
* 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
@ -26,10 +26,10 @@
package java.sql;
import java.util.Iterator;
import java.sql.Driver;
import java.util.ServiceLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.CopyOnWriteArrayList;
/**
@ -79,6 +79,27 @@ import java.security.PrivilegedAction;
public class DriverManager {
// List of registered JDBC drivers
private final static CopyOnWriteArrayList<Driver> registeredDrivers = new CopyOnWriteArrayList<Driver>();
private static volatile int loginTimeout = 0;
private static volatile java.io.PrintWriter logWriter = null;
private static volatile java.io.PrintStream logStream = null;
// Used in println() to synchronize logWriter
private final static Object logSync = new Object();
/* Prevent the DriverManager class from being instantiated. */
private DriverManager(){}
/**
* Load the initial JDBC drivers by checking the System property
* jdbc.properties and then use the {@code ServiceLoader} mechanism
*/
static {
loadInitialDrivers();
println("JDBC DriverManager initialized");
}
/**
* The <code>SQLPermission</code> constant that allows the
* setting of the logging stream.
@ -235,44 +256,33 @@ public class DriverManager {
*/
public static Driver getDriver(String url)
throws SQLException {
java.util.Vector drivers = null;
println("DriverManager.getDriver(\"" + url + "\")");
if (!initialized) {
initialize();
}
synchronized (DriverManager.class){
// use the read copy of the drivers vector
drivers = readDrivers;
}
// Gets the classloader of the code that called this method, may
// be null.
ClassLoader callerCL = DriverManager.getCallerClassLoader();
// Walk through the loaded drivers attempting to locate someone
// Walk through the loaded registeredDrivers attempting to locate someone
// who understands the given URL.
for (int i = 0; i < drivers.size(); i++) {
DriverInfo di = (DriverInfo)drivers.elementAt(i);
for (Driver aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if ( getCallerClass(callerCL, di.driverClassName ) !=
di.driverClass ) {
println(" skipping: " + di);
continue;
}
try {
println(" trying " + di);
if (di.driver.acceptsURL(url)) {
// Success!
println("getDriver returning " + di);
return (di.driver);
if(isDriverAllowed(aDriver, callerCL)) {
try {
if(aDriver.acceptsURL(url)) {
// Success!
println("getDriver returning " + aDriver.getClass().getName());
return (aDriver);
}
} catch(SQLException sqe) {
// Drop through and try the next driver.
}
} catch (SQLException ex) {
// Drop through and try the next driver.
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
println("getDriver: no suitable driver");
@ -292,23 +302,16 @@ public class DriverManager {
*/
public static synchronized void registerDriver(java.sql.Driver driver)
throws SQLException {
if (!initialized) {
initialize();
/* Register the driver if it has not already been added to our list */
if(driver != null) {
registeredDrivers.addIfAbsent(driver);
} else {
// This is for compatibility with the original DriverManager
throw new NullPointerException();
}
DriverInfo di = new DriverInfo();
di.driver = driver;
di.driverClass = driver.getClass();
di.driverClassName = di.driverClass.getName();
// Not Required -- drivers.addElement(di);
writeDrivers.addElement(di);
println("registerDriver: " + di);
/* update the read copy of drivers vector */
readDrivers = (java.util.Vector) writeDrivers.clone();
println("registerDriver: " + driver);
}
@ -321,37 +324,26 @@ public class DriverManager {
*/
public static synchronized void deregisterDriver(Driver driver)
throws SQLException {
if (driver == null) {
return;
}
// Gets the classloader of the code that called this method,
// may be null.
ClassLoader callerCL = DriverManager.getCallerClassLoader();
println("DriverManager.deregisterDriver: " + driver);
// Walk through the loaded drivers.
int i;
DriverInfo di = null;
for (i = 0; i < writeDrivers.size(); i++) {
di = (DriverInfo)writeDrivers.elementAt(i);
if (di.driver == driver) {
break;
if(registeredDrivers.contains(driver)) {
if (isDriverAllowed(driver, callerCL)) {
registeredDrivers.remove(driver);
} else {
// If the caller does not have permission to load the driver then
// throw a SecurityException.
throw new SecurityException();
}
}
// If we can't find the driver just return.
if (i >= writeDrivers.size()) {
} else {
println(" couldn't find driver to unload");
return;
}
// If the caller does not have permission to load the driver then
// throw a security exception.
if (getCallerClass(callerCL, di.driverClassName ) != di.driverClass ) {
throw new SecurityException();
}
// Remove the driver. Other entries in drivers get shuffled down.
writeDrivers.removeElementAt(i);
/* update the read copy of drivers vector */
readDrivers = (java.util.Vector) writeDrivers.clone();
}
/**
@ -364,34 +356,22 @@ public class DriverManager {
* @return the list of JDBC Drivers loaded by the caller's class loader
*/
public static java.util.Enumeration<Driver> getDrivers() {
java.util.Vector<Driver> result = new java.util.Vector<>();
java.util.Vector drivers = null;
if (!initialized) {
initialize();
}
synchronized (DriverManager.class){
// use the readcopy of drivers
drivers = readDrivers;
}
java.util.Vector<Driver> result = new java.util.Vector<Driver>();
// Gets the classloader of the code that called this method, may
// be null.
ClassLoader callerCL = DriverManager.getCallerClassLoader();
// Walk through the loaded drivers.
for (int i = 0; i < drivers.size(); i++) {
DriverInfo di = (DriverInfo)drivers.elementAt(i);
// Walk through the loaded registeredDrivers.
for(Driver aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if ( getCallerClass(callerCL, di.driverClassName ) != di.driverClass ) {
println(" skipping: " + di);
continue;
if(isDriverAllowed(aDriver, callerCL)) {
result.addElement(aDriver);
} else {
println(" skipping: " + aDriver.getClass().getName());
}
result.addElement(di.driver);
}
return (result.elements());
}
@ -481,21 +461,22 @@ public class DriverManager {
//------------------------------------------------------------------------
// Returns the class object that would be created if the code calling the
// driver manager had loaded the driver class, or null if the class
// is inaccessible.
private static Class getCallerClass(ClassLoader callerClassLoader,
String driverClassName) {
Class callerC = null;
// Indicates whether the class object that would be created if the code calling
// DriverManager is accessible.
private static boolean isDriverAllowed(Driver driver, ClassLoader classLoader) {
boolean result = false;
if(driver != null) {
Class<?> aClass = null;
try {
aClass = Class.forName(driver.getClass().getName(), true, classLoader);
} catch (Exception ex) {
result = false;
}
try {
callerC = Class.forName(driverClassName, true, callerClassLoader);
}
catch (Exception ex) {
callerC = null; // being very careful
result = ( aClass == driver.getClass() ) ? true : false;
}
return callerC;
return result;
}
private static void loadInitialDrivers() {
@ -544,26 +525,17 @@ public class DriverManager {
});
println("DriverManager.initialize: jdbc.drivers = " + drivers);
if (drivers == null) {
if (drivers == null || drivers.equals("")) {
return;
}
while (drivers.length() != 0) {
int x = drivers.indexOf(':');
String driver;
if (x < 0) {
driver = drivers;
drivers = "";
} else {
driver = drivers.substring(0, x);
drivers = drivers.substring(x+1);
}
if (driver.length() == 0) {
continue;
}
String[] driversList = drivers.split(":");
println("number of Drivers:" + driversList.length);
for (String aDriver : driversList) {
try {
println("DriverManager.Initialize: loading " + driver);
Class.forName(driver, true,
ClassLoader.getSystemClassLoader());
println("DriverManager.Initialize: loading " + aDriver);
Class.forName(aDriver, true,
ClassLoader.getSystemClassLoader());
} catch (Exception ex) {
println("DriverManager.Initialize: load failed: " + ex);
}
@ -574,7 +546,6 @@ public class DriverManager {
// Worker method called by the public getConnection() methods.
private static Connection getConnection(
String url, java.util.Properties info, ClassLoader callerCL) throws SQLException {
java.util.Vector drivers = null;
/*
* When callerCl is null, we should check the application's
* (which is invoking this class indirectly)
@ -594,40 +565,32 @@ public class DriverManager {
println("DriverManager.getConnection(\"" + url + "\")");
if (!initialized) {
initialize();
}
synchronized (DriverManager.class){
// use the readcopy of drivers
drivers = readDrivers;
}
// Walk through the loaded drivers attempting to make a connection.
// Walk through the loaded registeredDrivers attempting to make a connection.
// Remember the first exception that gets raised so we can reraise it.
SQLException reason = null;
for (int i = 0; i < drivers.size(); i++) {
DriverInfo di = (DriverInfo)drivers.elementAt(i);
for(Driver aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if ( getCallerClass(callerCL, di.driverClassName ) != di.driverClass ) {
println(" skipping: " + di);
continue;
}
try {
println(" trying " + di);
Connection result = di.driver.connect(url, info);
if (result != null) {
// Success!
println("getConnection returning " + di);
return (result);
}
} catch (SQLException ex) {
if (reason == null) {
reason = ex;
if(isDriverAllowed(aDriver, callerCL)) {
try {
println(" trying " + aDriver.getClass().getName());
Connection con = aDriver.connect(url, info);
if (con != null) {
// Success!
println("getConnection returning " + aDriver.getClass().getName());
return (con);
}
} catch (SQLException ex) {
if (reason == null) {
reason = ex;
}
}
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
// if we got here nobody could connect.
@ -640,45 +603,7 @@ public class DriverManager {
throw new SQLException("No suitable driver found for "+ url, "08001");
}
// Class initialization.
static void initialize() {
if (initialized) {
return;
}
initialized = true;
loadInitialDrivers();
println("JDBC DriverManager initialized");
}
/* Prevent the DriverManager class from being instantiated. */
private DriverManager(){}
/* write copy of the drivers vector */
private static java.util.Vector writeDrivers = new java.util.Vector();
/* write copy of the drivers vector */
private static java.util.Vector readDrivers = new java.util.Vector();
private static int loginTimeout = 0;
private static java.io.PrintWriter logWriter = null;
private static java.io.PrintStream logStream = null;
private static boolean initialized = false;
private static Object logSync = new Object();
/* Returns the caller's class loader, or null if none */
private static native ClassLoader getCallerClassLoader();
}
// DriverInfo is a package-private support class.
class DriverInfo {
Driver driver;
Class driverClass;
String driverClassName;
public String toString() {
return ("driver[className=" + driverClassName + "," + driver + "]");
}
}

View File

@ -1401,10 +1401,9 @@ import sun.misc.FormattedFloatingDecimal;
* <p> The number of digits in the result for the fractional part of
* <i>m</i> or <i>a</i> is equal to the precision. If the precision is not
* specified then the default value is {@code 6}. If the precision is
* less than the number of digits which would appear after the decimal
* point in the string returned by {@link Float#toString(float)} or {@link
* Double#toString(double)} respectively, then the value will be rounded
* using the {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up
* less than the number of digits to the right of the decimal point then
* the value will be rounded using the
* {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up
* algorithm}. Otherwise, zeros may be appended to reach the precision.
* For a canonical representation of the value, use {@link
* BigDecimal#toString()}.
@ -1463,12 +1462,11 @@ import sun.misc.FormattedFloatingDecimal;
* more decimal digits representing the fractional part of <i>m</i>.
*
* <p> The number of digits in the result for the fractional part of
* <i>m</i> or <i>a</i> is equal to the precision. If the precision is not
* <i>m</i> or <i>a</i> is equal to the precision. If the precision is not
* specified then the default value is {@code 6}. If the precision is
* less than the number of digits which would appear after the decimal
* point in the string returned by {@link Float#toString(float)} or {@link
* Double#toString(double)} respectively, then the value will be rounded
* using the {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up
* less than the number of digits to the right of the decimal point
* then the value will be rounded using the
* {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up
* algorithm}. Otherwise, zeros may be appended to reach the precision.
* For a canonical representation of the value, use {@link
* BigDecimal#toString()}.
@ -3585,7 +3583,7 @@ public final class Formatter implements Closeable, Flushable {
int scale = value.scale();
if (scale > prec) {
// more "scale" digits than the requested "precision
// more "scale" digits than the requested "precision"
int compPrec = value.precision();
if (compPrec <= scale) {
// case of 0.xxxxxx

View File

@ -34,6 +34,8 @@ package java.util;
* @serial exclude
*/
class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
private static final long serialVersionUID = 334349849919042784L;
/**
* Bit vector representation of this set. The ith bit of the jth
* element of this array represents the presence of universe[64*j +i]
@ -138,8 +140,11 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
public void remove() {
if (lastReturned == 0)
throw new IllegalStateException();
elements[lastReturnedIndex] -= lastReturned;
size--;
final long oldElements = elements[lastReturnedIndex];
elements[lastReturnedIndex] &= ~lastReturned;
if (oldElements != elements[lastReturnedIndex]) {
size--;
}
lastReturned = 0;
}
}

View File

@ -1168,7 +1168,7 @@ public final class Locale implements Cloneable, Serializable {
boolean e = (_extensions.getID().length() != 0);
StringBuilder result = new StringBuilder(_baseLocale.getLanguage());
if (r || (l && v)) {
if (r || (l && (v || s || e))) {
result.append('_')
.append(_baseLocale.getRegion()); // This may just append '_'
}

View File

@ -34,6 +34,7 @@ package java.util;
* @serial exclude
*/
class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
private static final long serialVersionUID = 3411599620347842686L;
/**
* Bit vector representation of this set. The 2^k bit indicates the
* presence of universe[k] in this set.
@ -106,7 +107,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
public void remove() {
if (lastReturned == 0)
throw new IllegalStateException();
elements -= lastReturned;
elements &= ~lastReturned;
lastReturned = 0;
}
}

View File

@ -528,11 +528,8 @@ public class TreeMap<K,V>
public V put(K key, V value) {
Entry<K,V> t = root;
if (t == null) {
// TBD:
// 5045147: (coll) Adding null to an empty TreeSet should
// throw NullPointerException
//
// compare(key, key); // type check
compare(key, key); // type (and possibly null) check
root = new Entry<>(key, value, null);
size = 1;
modCount++;

View File

@ -26,8 +26,6 @@
package java.util;
import java.security.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
/**
* A class that represents an immutable universally unique identifier (UUID).
@ -90,36 +88,6 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
*/
private final long leastSigBits;
/*
* The version number associated with this UUID. Computed on demand.
*/
private transient int version = -1;
/*
* The variant number associated with this UUID. Computed on demand.
*/
private transient int variant = -1;
/*
* The timestamp associated with this UUID. Computed on demand.
*/
private transient volatile long timestamp = -1;
/*
* The clock sequence associated with this UUID. Computed on demand.
*/
private transient int sequence = -1;
/*
* The node number associated with this UUID. Computed on demand.
*/
private transient long node = -1;
/*
* The hashcode of this UUID. Computed on demand.
*/
private transient int hashCode = -1;
/*
* The random number generator used by this class to create random
* based UUIDs.
@ -134,7 +102,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
private UUID(byte[] data) {
long msb = 0;
long lsb = 0;
assert data.length == 16;
assert data.length == 16 : "data must be 16 bytes in length";
for (int i=0; i<8; i++)
msb = (msb << 8) | (data[i] & 0xff);
for (int i=8; i<16; i++)
@ -276,11 +244,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
* @return The version number of this {@code UUID}
*/
public int version() {
if (version < 0) {
// Version is bits masked by 0x000000000000F000 in MS long
version = (int)((mostSigBits >> 12) & 0x0f);
}
return version;
// Version is bits masked by 0x000000000000F000 in MS long
return (int)((mostSigBits >> 12) & 0x0f);
}
/**
@ -298,17 +263,13 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
* @return The variant number of this {@code UUID}
*/
public int variant() {
if (variant < 0) {
// This field is composed of a varying number of bits
if ((leastSigBits >>> 63) == 0) {
variant = 0;
} else if ((leastSigBits >>> 62) == 2) {
variant = 2;
} else {
variant = (int)(leastSigBits >>> 61);
}
}
return variant;
// This field is composed of a varying number of bits.
// 0 - - Reserved for NCS backward compatibility
// 1 0 - The Leach-Salz variant (used by this class)
// 1 1 0 Reserved, Microsoft backward compatibility
// 1 1 1 Reserved for future definition.
return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62)))
& (leastSigBits >> 63));
}
/**
@ -330,14 +291,10 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
long result = timestamp;
if (result < 0) {
result = (mostSigBits & 0x0000000000000FFFL) << 48;
result |= ((mostSigBits >> 16) & 0xFFFFL) << 32;
result |= mostSigBits >>> 32;
timestamp = result;
}
return result;
return (mostSigBits & 0x0FFFL) << 48
| ((mostSigBits >> 16) & 0x0FFFFL) << 32
| mostSigBits >>> 32;
}
/**
@ -360,10 +317,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
if (sequence < 0) {
sequence = (int)((leastSigBits & 0x3FFF000000000000L) >>> 48);
}
return sequence;
return (int)((leastSigBits & 0x3FFF000000000000L) >>> 48);
}
/**
@ -386,10 +341,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
if (node < 0) {
node = leastSigBits & 0x0000FFFFFFFFFFFFL;
}
return node;
return leastSigBits & 0x0000FFFFFFFFFFFFL;
}
// Object Inherited Methods
@ -438,13 +391,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
* @return A hash code value for this {@code UUID}
*/
public int hashCode() {
if (hashCode == -1) {
hashCode = (int)((mostSigBits >> 32) ^
mostSigBits ^
(leastSigBits >> 32) ^
leastSigBits);
}
return hashCode;
long hilo = mostSigBits ^ leastSigBits;
return ((int)(hilo >> 32)) ^ (int) hilo;
}
/**
@ -460,9 +408,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
* otherwise
*/
public boolean equals(Object obj) {
if (!(obj instanceof UUID))
return false;
if (((UUID)obj).variant() != this.variant())
if ((null == obj) || (obj.getClass() != UUID.class))
return false;
UUID id = (UUID)obj;
return (mostSigBits == id.mostSigBits &&
@ -494,23 +440,4 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
(this.leastSigBits > val.leastSigBits ? 1 :
0))));
}
/**
* Reconstitute the {@code UUID} instance from a stream (that is,
* deserialize it). This is necessary to set the transient fields to their
* correct uninitialized value so they will be recomputed on demand.
*/
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException, ClassNotFoundException {
in.defaultReadObject();
// Set "cached computation" fields to their initial values
version = -1;
variant = -1;
timestamp = -1;
sequence = -1;
node = -1;
hashCode = -1;
}
}

View File

@ -44,8 +44,8 @@ import java.util.concurrent.atomic.*;
* creation time, depending on which constructor is used.
*
* <p>This class implements a concurrent variant of <a
* href="http://www.cs.umd.edu/~pugh/">SkipLists</a> providing
* expected average <i>log(n)</i> time cost for the
* href="http://en.wikipedia.org/wiki/Skip_list" target="_top">SkipLists</a>
* providing expected average <i>log(n)</i> time cost for the
* <tt>containsKey</tt>, <tt>get</tt>, <tt>put</tt> and
* <tt>remove</tt> operations and their variants. Insertion, removal,
* update, and access operations safely execute concurrently by

View File

@ -164,8 +164,8 @@ public class Exchanger<V> {
* races between two threads or thread pre-emptions occurring
* between reading and CASing. Also, very transient peak
* contention can be much higher than the average sustainable
* levels. The max limit is decreased on average 50% of the times
* that a non-slot-zero wait elapses without being fulfilled.
* levels. An attempt to decrease the max limit is usually made
* when a non-slot-zero wait elapses without being fulfilled.
* Threads experiencing elapsed waits move closer to zero, so
* eventually find existing (or future) threads even if the table
* has been shrunk due to inactivity. The chosen mechanics and

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,8 @@ import java.util.Collections;
import java.util.List;
import java.util.RandomAccess;
import java.util.Map;
import java.util.WeakHashMap;
import java.lang.ref.WeakReference;
import java.lang.ref.ReferenceQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
@ -52,6 +53,8 @@ import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.ReentrantLock;
import java.lang.reflect.Constructor;
/**
* Abstract base class for tasks that run within a {@link ForkJoinPool}.
@ -95,7 +98,11 @@ import java.util.concurrent.TimeoutException;
* rethrown to callers attempting to join them. These exceptions may
* additionally include {@link RejectedExecutionException} stemming
* from internal resource exhaustion, such as failure to allocate
* internal task queues.
* internal task queues. Rethrown exceptions behave in the same way as
* regular exceptions, but, when possible, contain stack traces (as
* displayed for example using {@code ex.printStackTrace()}) of both
* the thread that initiated the computation as well as the thread
* actually encountering the exception; minimally only the latter.
*
* <p>The primary method for awaiting completion and extracting
* results of a task is {@link #join}, but there are several variants:
@ -192,8 +199,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
* status maintenance (2) execution and awaiting completion (3)
* user-level methods that additionally report results. This is
* sometimes hard to see because this file orders exported methods
* in a way that flows well in javadocs. In particular, most
* join mechanics are in method quietlyJoin, below.
* in a way that flows well in javadocs.
*/
/*
@ -215,91 +221,67 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
/** The run status of this task */
volatile int status; // accessed directly by pool and workers
private static final int NORMAL = -1;
private static final int CANCELLED = -2;
private static final int EXCEPTIONAL = -3;
private static final int SIGNAL = 1;
/**
* Table of exceptions thrown by tasks, to enable reporting by
* callers. Because exceptions are rare, we don't directly keep
* them with task objects, but instead use a weak ref table. Note
* that cancellation exceptions don't appear in the table, but are
* instead recorded as status values.
* TODO: Use ConcurrentReferenceHashMap
*/
static final Map<ForkJoinTask<?>, Throwable> exceptionMap =
Collections.synchronizedMap
(new WeakHashMap<ForkJoinTask<?>, Throwable>());
// Maintaining completion status
/**
* Marks completion and wakes up threads waiting to join this task,
* also clearing signal request bits.
*
* @param completion one of NORMAL, CANCELLED, EXCEPTIONAL
* @return completion status on exit
*/
private void setCompletion(int completion) {
int s;
while ((s = status) >= 0) {
private int setCompletion(int completion) {
for (int s;;) {
if ((s = status) < 0)
return s;
if (UNSAFE.compareAndSwapInt(this, statusOffset, s, completion)) {
if (s != 0)
synchronized (this) { notifyAll(); }
break;
return completion;
}
}
}
/**
* Records exception and sets exceptional completion.
* Tries to block a worker thread until completed or timed out.
* Uses Object.wait time argument conventions.
* May fail on contention or interrupt.
*
* @return status on exit
* @param millis if > 0, wait time.
*/
private void setExceptionalCompletion(Throwable rex) {
exceptionMap.put(this, rex);
setCompletion(EXCEPTIONAL);
}
/**
* Blocks a worker thread until completed or timed out. Called
* only by pool.
*/
final void internalAwaitDone(long millis, int nanos) {
int s = status;
if ((s == 0 &&
UNSAFE.compareAndSwapInt(this, statusOffset, 0, SIGNAL)) ||
s > 0) {
try { // the odd construction reduces lock bias effects
final void tryAwaitDone(long millis) {
int s;
try {
if (((s = status) > 0 ||
(s == 0 &&
UNSAFE.compareAndSwapInt(this, statusOffset, 0, SIGNAL))) &&
status > 0) {
synchronized (this) {
if (status > 0)
wait(millis, nanos);
else
notifyAll();
wait(millis);
}
} catch (InterruptedException ie) {
cancelIfTerminating();
}
} catch (InterruptedException ie) {
// caller must check termination
}
}
/**
* Blocks a non-worker-thread until completion.
* @return status upon completion
*/
private void externalAwaitDone() {
if (status >= 0) {
private int externalAwaitDone() {
int s;
if ((s = status) >= 0) {
boolean interrupted = false;
synchronized (this) {
for (;;) {
int s = status;
while ((s = status) >= 0) {
if (s == 0)
UNSAFE.compareAndSwapInt(this, statusOffset,
0, SIGNAL);
else if (s < 0) {
notifyAll();
break;
}
else {
try {
wait();
@ -312,53 +294,308 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
if (interrupted)
Thread.currentThread().interrupt();
}
return s;
}
/**
* Blocks a non-worker-thread until completion or interruption or timeout.
*/
private void externalInterruptibleAwaitDone(boolean timed, long nanos)
private int externalInterruptibleAwaitDone(long millis)
throws InterruptedException {
int s;
if (Thread.interrupted())
throw new InterruptedException();
if (status >= 0) {
long startTime = timed ? System.nanoTime() : 0L;
if ((s = status) >= 0) {
synchronized (this) {
for (;;) {
long nt;
int s = status;
while ((s = status) >= 0) {
if (s == 0)
UNSAFE.compareAndSwapInt(this, statusOffset,
0, SIGNAL);
else if (s < 0) {
notifyAll();
else {
wait(millis);
if (millis > 0L)
break;
}
}
}
}
return s;
}
/**
* Primary execution method for stolen tasks. Unless done, calls
* exec and records status if completed, but doesn't wait for
* completion otherwise.
*/
final void doExec() {
if (status >= 0) {
boolean completed;
try {
completed = exec();
} catch (Throwable rex) {
setExceptionalCompletion(rex);
return;
}
if (completed)
setCompletion(NORMAL); // must be outside try block
}
}
/**
* Primary mechanics for join, get, quietlyJoin.
* @return status upon completion
*/
private int doJoin() {
Thread t; ForkJoinWorkerThread w; int s; boolean completed;
if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) {
if ((s = status) < 0)
return s;
if ((w = (ForkJoinWorkerThread)t).unpushTask(this)) {
try {
completed = exec();
} catch (Throwable rex) {
return setExceptionalCompletion(rex);
}
if (completed)
return setCompletion(NORMAL);
}
return w.joinTask(this);
}
else
return externalAwaitDone();
}
/**
* Primary mechanics for invoke, quietlyInvoke.
* @return status upon completion
*/
private int doInvoke() {
int s; boolean completed;
if ((s = status) < 0)
return s;
try {
completed = exec();
} catch (Throwable rex) {
return setExceptionalCompletion(rex);
}
if (completed)
return setCompletion(NORMAL);
else
return doJoin();
}
// Exception table support
/**
* Table of exceptions thrown by tasks, to enable reporting by
* callers. Because exceptions are rare, we don't directly keep
* them with task objects, but instead use a weak ref table. Note
* that cancellation exceptions don't appear in the table, but are
* instead recorded as status values.
*
* Note: These statics are initialized below in static block.
*/
private static final ExceptionNode[] exceptionTable;
private static final ReentrantLock exceptionTableLock;
private static final ReferenceQueue<Object> exceptionTableRefQueue;
/**
* Fixed capacity for exceptionTable.
*/
private static final int EXCEPTION_MAP_CAPACITY = 32;
/**
* Key-value nodes for exception table. The chained hash table
* uses identity comparisons, full locking, and weak references
* for keys. The table has a fixed capacity because it only
* maintains task exceptions long enough for joiners to access
* them, so should never become very large for sustained
* periods. However, since we do not know when the last joiner
* completes, we must use weak references and expunge them. We do
* so on each operation (hence full locking). Also, some thread in
* any ForkJoinPool will call helpExpungeStaleExceptions when its
* pool becomes isQuiescent.
*/
static final class ExceptionNode extends WeakReference<ForkJoinTask<?>>{
final Throwable ex;
ExceptionNode next;
final long thrower; // use id not ref to avoid weak cycles
ExceptionNode(ForkJoinTask<?> task, Throwable ex, ExceptionNode next) {
super(task, exceptionTableRefQueue);
this.ex = ex;
this.next = next;
this.thrower = Thread.currentThread().getId();
}
}
/**
* Records exception and sets exceptional completion.
*
* @return status on exit
*/
private int setExceptionalCompletion(Throwable ex) {
int h = System.identityHashCode(this);
final ReentrantLock lock = exceptionTableLock;
lock.lock();
try {
expungeStaleExceptions();
ExceptionNode[] t = exceptionTable;
int i = h & (t.length - 1);
for (ExceptionNode e = t[i]; ; e = e.next) {
if (e == null) {
t[i] = new ExceptionNode(this, ex, t[i]);
break;
}
if (e.get() == this) // already present
break;
}
} finally {
lock.unlock();
}
return setCompletion(EXCEPTIONAL);
}
/**
* Removes exception node and clears status
*/
private void clearExceptionalCompletion() {
int h = System.identityHashCode(this);
final ReentrantLock lock = exceptionTableLock;
lock.lock();
try {
ExceptionNode[] t = exceptionTable;
int i = h & (t.length - 1);
ExceptionNode e = t[i];
ExceptionNode pred = null;
while (e != null) {
ExceptionNode next = e.next;
if (e.get() == this) {
if (pred == null)
t[i] = next;
else
pred.next = next;
break;
}
pred = e;
e = next;
}
expungeStaleExceptions();
status = 0;
} finally {
lock.unlock();
}
}
/**
* Returns a rethrowable exception for the given task, if
* available. To provide accurate stack traces, if the exception
* was not thrown by the current thread, we try to create a new
* exception of the same type as the one thrown, but with the
* recorded exception as its cause. If there is no such
* constructor, we instead try to use a no-arg constructor,
* followed by initCause, to the same effect. If none of these
* apply, or any fail due to other exceptions, we return the
* recorded exception, which is still correct, although it may
* contain a misleading stack trace.
*
* @return the exception, or null if none
*/
private Throwable getThrowableException() {
if (status != EXCEPTIONAL)
return null;
int h = System.identityHashCode(this);
ExceptionNode e;
final ReentrantLock lock = exceptionTableLock;
lock.lock();
try {
expungeStaleExceptions();
ExceptionNode[] t = exceptionTable;
e = t[h & (t.length - 1)];
while (e != null && e.get() != this)
e = e.next;
} finally {
lock.unlock();
}
Throwable ex;
if (e == null || (ex = e.ex) == null)
return null;
if (e.thrower != Thread.currentThread().getId()) {
Class ec = ex.getClass();
try {
Constructor<?> noArgCtor = null;
Constructor<?>[] cs = ec.getConstructors();// public ctors only
for (int i = 0; i < cs.length; ++i) {
Constructor<?> c = cs[i];
Class<?>[] ps = c.getParameterTypes();
if (ps.length == 0)
noArgCtor = c;
else if (ps.length == 1 && ps[0] == Throwable.class)
return (Throwable)(c.newInstance(ex));
}
if (noArgCtor != null) {
Throwable wx = (Throwable)(noArgCtor.newInstance());
wx.initCause(ex);
return wx;
}
} catch (Exception ignore) {
}
}
return ex;
}
/**
* Poll stale refs and remove them. Call only while holding lock.
*/
private static void expungeStaleExceptions() {
for (Object x; (x = exceptionTableRefQueue.poll()) != null;) {
if (x instanceof ExceptionNode) {
ForkJoinTask<?> key = ((ExceptionNode)x).get();
ExceptionNode[] t = exceptionTable;
int i = System.identityHashCode(key) & (t.length - 1);
ExceptionNode e = t[i];
ExceptionNode pred = null;
while (e != null) {
ExceptionNode next = e.next;
if (e == x) {
if (pred == null)
t[i] = next;
else
pred.next = next;
break;
}
else if (!timed)
wait();
else if ((nt = nanos - (System.nanoTime()-startTime)) > 0L)
wait(nt / 1000000, (int)(nt % 1000000));
else
break;
pred = e;
e = next;
}
}
}
}
/**
* Unless done, calls exec and records status if completed, but
* doesn't wait for completion otherwise. Primary execution method
* for ForkJoinWorkerThread.
* If lock is available, poll stale refs and remove them.
* Called from ForkJoinPool when pools become quiescent.
*/
final void quietlyExec() {
try {
if (status < 0 || !exec())
return;
} catch (Throwable rex) {
setExceptionalCompletion(rex);
return;
static final void helpExpungeStaleExceptions() {
final ReentrantLock lock = exceptionTableLock;
if (lock.tryLock()) {
try {
expungeStaleExceptions();
} finally {
lock.unlock();
}
}
setCompletion(NORMAL); // must be outside try block
}
/**
* Report the result of invoke or join; called only upon
* non-normal return of internal versions.
*/
private V reportResult() {
int s; Throwable ex;
if ((s = status) == CANCELLED)
throw new CancellationException();
if (s == EXCEPTIONAL && (ex = getThrowableException()) != null)
UNSAFE.throwException(ex);
return getRawResult();
}
// public methods
@ -399,11 +636,10 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
* @return the computed result
*/
public final V join() {
quietlyJoin();
Throwable ex;
if (status < NORMAL && (ex = getException()) != null)
UNSAFE.throwException(ex);
return getRawResult();
if (doJoin() != NORMAL)
return reportResult();
else
return getRawResult();
}
/**
@ -415,11 +651,10 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
* @return the computed result
*/
public final V invoke() {
quietlyInvoke();
Throwable ex;
if (status < NORMAL && (ex = getException()) != null)
UNSAFE.throwException(ex);
return getRawResult();
if (doInvoke() != NORMAL)
return reportResult();
else
return getRawResult();
}
/**
@ -483,22 +718,16 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
}
else if (i != 0)
t.fork();
else {
t.quietlyInvoke();
if (ex == null && t.status < NORMAL)
ex = t.getException();
}
else if (t.doInvoke() < NORMAL && ex == null)
ex = t.getException();
}
for (int i = 1; i <= last; ++i) {
ForkJoinTask<?> t = tasks[i];
if (t != null) {
if (ex != null)
t.cancel(false);
else {
t.quietlyJoin();
if (ex == null && t.status < NORMAL)
ex = t.getException();
}
else if (t.doJoin() < NORMAL && ex == null)
ex = t.getException();
}
}
if (ex != null)
@ -546,22 +775,16 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
}
else if (i != 0)
t.fork();
else {
t.quietlyInvoke();
if (ex == null && t.status < NORMAL)
ex = t.getException();
}
else if (t.doInvoke() < NORMAL && ex == null)
ex = t.getException();
}
for (int i = 1; i <= last; ++i) {
ForkJoinTask<?> t = ts.get(i);
if (t != null) {
if (ex != null)
t.cancel(false);
else {
t.quietlyJoin();
if (ex == null && t.status < NORMAL)
ex = t.getException();
}
else if (t.doJoin() < NORMAL && ex == null)
ex = t.getException();
}
}
if (ex != null)
@ -597,8 +820,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
* @return {@code true} if this task is now cancelled
*/
public boolean cancel(boolean mayInterruptIfRunning) {
setCompletion(CANCELLED);
return status == CANCELLED;
return setCompletion(CANCELLED) == CANCELLED;
}
/**
@ -614,21 +836,6 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
}
}
/**
* Cancels if current thread is a terminating worker thread,
* ignoring any exceptions thrown by cancel.
*/
final void cancelIfTerminating() {
Thread t = Thread.currentThread();
if ((t instanceof ForkJoinWorkerThread) &&
((ForkJoinWorkerThread) t).isTerminating()) {
try {
cancel(false);
} catch (Throwable ignore) {
}
}
}
public final boolean isDone() {
return status < 0;
}
@ -668,7 +875,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
int s = status;
return ((s >= NORMAL) ? null :
(s == CANCELLED) ? new CancellationException() :
exceptionMap.get(this));
getThrowableException());
}
/**
@ -726,19 +933,13 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
* member of a ForkJoinPool and was interrupted while waiting
*/
public final V get() throws InterruptedException, ExecutionException {
Thread t = Thread.currentThread();
if (t instanceof ForkJoinWorkerThread)
quietlyJoin();
else
externalInterruptibleAwaitDone(false, 0L);
int s = status;
if (s != NORMAL) {
Throwable ex;
if (s == CANCELLED)
throw new CancellationException();
if (s == EXCEPTIONAL && (ex = exceptionMap.get(this)) != null)
throw new ExecutionException(ex);
}
int s = (Thread.currentThread() instanceof ForkJoinWorkerThread) ?
doJoin() : externalInterruptibleAwaitDone(0L);
Throwable ex;
if (s == CANCELLED)
throw new CancellationException();
if (s == EXCEPTIONAL && (ex = getThrowableException()) != null)
throw new ExecutionException(ex);
return getRawResult();
}
@ -758,20 +959,39 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
*/
public final V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
long nanos = unit.toNanos(timeout);
Thread t = Thread.currentThread();
if (t instanceof ForkJoinWorkerThread)
((ForkJoinWorkerThread)t).joinTask(this, true, nanos);
else
externalInterruptibleAwaitDone(true, nanos);
if (t instanceof ForkJoinWorkerThread) {
ForkJoinWorkerThread w = (ForkJoinWorkerThread) t;
long nanos = unit.toNanos(timeout);
if (status >= 0) {
boolean completed = false;
if (w.unpushTask(this)) {
try {
completed = exec();
} catch (Throwable rex) {
setExceptionalCompletion(rex);
}
}
if (completed)
setCompletion(NORMAL);
else if (status >= 0 && nanos > 0)
w.pool.timedAwaitJoin(this, nanos);
}
}
else {
long millis = unit.toMillis(timeout);
if (millis > 0)
externalInterruptibleAwaitDone(millis);
}
int s = status;
if (s != NORMAL) {
Throwable ex;
if (s == CANCELLED)
throw new CancellationException();
if (s == EXCEPTIONAL && (ex = exceptionMap.get(this)) != null)
if (s != EXCEPTIONAL)
throw new TimeoutException();
if ((ex = getThrowableException()) != null)
throw new ExecutionException(ex);
throw new TimeoutException();
}
return getRawResult();
}
@ -783,28 +1003,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
* known to have aborted.
*/
public final void quietlyJoin() {
Thread t;
if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) {
ForkJoinWorkerThread w = (ForkJoinWorkerThread) t;
if (status >= 0) {
if (w.unpushTask(this)) {
boolean completed;
try {
completed = exec();
} catch (Throwable rex) {
setExceptionalCompletion(rex);
return;
}
if (completed) {
setCompletion(NORMAL);
return;
}
}
w.joinTask(this, false, 0L);
}
}
else
externalAwaitDone();
doJoin();
}
/**
@ -813,19 +1012,7 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
* exception.
*/
public final void quietlyInvoke() {
if (status >= 0) {
boolean completed;
try {
completed = exec();
} catch (Throwable rex) {
setExceptionalCompletion(rex);
return;
}
if (completed)
setCompletion(NORMAL);
else
quietlyJoin();
}
doInvoke();
}
/**
@ -864,8 +1051,9 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
*/
public void reinitialize() {
if (status == EXCEPTIONAL)
exceptionMap.remove(this);
status = 0;
clearExceptionalCompletion();
else
status = 0;
}
/**
@ -1176,23 +1364,23 @@ public abstract class ForkJoinTask<V> implements Future<V>, Serializable {
s.defaultReadObject();
Object ex = s.readObject();
if (ex != null)
setExceptionalCompletion((Throwable) ex);
setExceptionalCompletion((Throwable)ex);
}
// Unsafe mechanics
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
private static final long statusOffset =
objectFieldOffset("status", ForkJoinTask.class);
private static long objectFieldOffset(String field, Class<?> klazz) {
private static final sun.misc.Unsafe UNSAFE;
private static final long statusOffset;
static {
exceptionTableLock = new ReentrantLock();
exceptionTableRefQueue = new ReferenceQueue<Object>();
exceptionTable = new ExceptionNode[EXCEPTION_MAP_CAPACITY];
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;
UNSAFE = sun.misc.Unsafe.getUnsafe();
statusOffset = UNSAFE.objectFieldOffset
(ForkJoinTask.class.getDeclaredField("status"));
} catch (Exception e) {
throw new Error(e);
}
}
}

View File

@ -1,262 +0,0 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.relaxng.datatype;
/**
* Datatype object.
*
* This object has the following functionality:
*
* <ol>
* <li> functionality to identify a class of character sequences. This is
* done through the isValid method.
*
* <li> functionality to produce a "value object" from a character sequence and
* context information.
*
* <li> functionality to test the equality of two value objects.
* </ol>
*
* This interface also defines the createStreamingValidator method,
* which is intended to efficiently support the validation of
* large character sequences.
*
* @author <a href="mailto:jjc@jclark.com">James Clark</a>
* @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
*/
public interface Datatype {
/**
* Checks if the specified 'literal' matches this Datatype
* with respect to the current context.
*
* @param literal
* the lexical representation to be checked.
* @param context
* If this datatype is context-dependent
* (i.e. the {@link #isContextDependent} method returns true),
* then the caller must provide a non-null valid context object.
* Otherwise, the caller can pass null.
*
* @return
* true if the 'literal' is a member of this Datatype;
* false if it's not a member of this Datatype.
*/
boolean isValid( String literal, ValidationContext context );
/**
* Similar to the isValid method but throws an exception with diagnosis
* in case of errors.
*
* <p>
* If the specified 'literal' is a valid lexical representation for this
* datatype, then this method must return without throwing any exception.
* If not, the callee must throw an exception (with diagnosis message,
* if possible.)
*
* <p>
* The application can use this method to provide detailed error message
* to users. This method is kept separate from the isValid method to
* achieve higher performance during normal validation.
*
* @exception DatatypeException
* If the given literal is invalid, then this exception is thrown.
* If the callee supports error diagnosis, then the exception should
* contain a diagnosis message.
*/
void checkValid( String literal, ValidationContext context )
throws DatatypeException;
/**
* Creates an instance of a streaming validator for this type.
*
* <p>
* By using streaming validators instead of the isValid method,
* the caller can avoid keeping the entire string, which is
* sometimes quite big, in memory.
*
* @param context
* If this datatype is context-dependent
* (i.e. the {@link #isContextDependent} method returns true),
* then the caller must provide a non-null valid context object.
* Otherwise, the caller can pass null.
* The callee may keep a reference to this context object
* only while the returned streaming validator is being used.
*/
DatatypeStreamingValidator createStreamingValidator( ValidationContext context );
/**
* Converts lexcial value and the current context to the corresponding
* value object.
*
* <p>
* The caller cannot generally assume that the value object is
* a meaningful Java object. For example, the caller cannot expect
* this method to return <code>java.lang.Number</code> type for
* the "integer" type of XML Schema Part 2.
*
* <p>
* Also, the caller cannot assume that the equals method and
* the hashCode method of the value object are consistent with
* the semantics of the datatype. For that purpose, the sameValue
* method and the valueHashCode method have to be used. Note that
* this means you cannot use classes like
* <code>java.util.Hashtable</code> to store the value objects.
*
* <p>
* The returned value object should be used solely for the sameValue
* and valueHashCode methods.
*
* @param context
* If this datatype is context-dependent
* (when the {@link #isContextDependent} method returns true),
* then the caller must provide a non-null valid context object.
* Otherwise, the caller can pass null.
*
* @return null
* when the given lexical value is not a valid lexical
* value for this type.
*/
Object createValue( String literal, ValidationContext context );
/**
* Tests the equality of two value objects which were originally
* created by the createValue method of this object.
*
* The behavior is undefined if objects not created by this type
* are passed. It is the caller's responsibility to ensure that
* value objects belong to this type.
*
* @return
* true if two value objects are considered equal according to
* the definition of this datatype; false if otherwise.
*/
boolean sameValue( Object value1, Object value2 );
/**
* Computes the hash code for a value object,
* which is consistent with the sameValue method.
*
* @return
* hash code for the specified value object.
*/
int valueHashCode( Object value );
/**
* Indicates that the datatype doesn't have ID/IDREF semantics.
*
* This value is one of the possible return values of the
* {@link #getIdType} method.
*/
public static final int ID_TYPE_NULL = 0;
/**
* Indicates that RELAX NG compatibility processors should
* treat this datatype as having ID semantics.
*
* This value is one of the possible return values of the
* {@link #getIdType} method.
*/
public static final int ID_TYPE_ID = 1;
/**
* Indicates that RELAX NG compatibility processors should
* treat this datatype as having IDREF semantics.
*
* This value is one of the possible return values of the
* {@link #getIdType} method.
*/
public static final int ID_TYPE_IDREF = 2;
/**
* Indicates that RELAX NG compatibility processors should
* treat this datatype as having IDREFS semantics.
*
* This value is one of the possible return values of the
* {@link #getIdType} method.
*/
public static final int ID_TYPE_IDREFS = 3;
/**
* Checks if the ID/IDREF semantics is associated with this
* datatype.
*
* <p>
* This method is introduced to support the RELAX NG DTD
* compatibility spec. (Of course it's always free to use
* this method for other purposes.)
*
* <p>
* If you are implementing a datatype library and have no idea about
* the "RELAX NG DTD compatibility" thing, just return
* <code>ID_TYPE_NULL</code> is fine.
*
* @return
* If this datatype doesn't have any ID/IDREF semantics,
* it returns {@link #ID_TYPE_NULL}. If it has such a semantics
* (for example, XSD:ID, XSD:IDREF and comp:ID type), then
* it returns {@link #ID_TYPE_ID}, {@link #ID_TYPE_IDREF} or
* {@link #ID_TYPE_IDREFS}.
*/
public int getIdType();
/**
* Checks if this datatype may need a context object for
* the validation.
*
* <p>
* The callee must return true even when the context
* is not always necessary. (For example, the "QName" type
* doesn't need a context object when validating unprefixed
* string. But nonetheless QName must return true.)
*
* <p>
* XSD's <code>string</code> and <code>short</code> types
* are examples of context-independent datatypes.
* Its <code>QName</code> and <code>ENTITY</code> types
* are examples of context-dependent datatypes.
*
* <p>
* When a datatype is context-independent, then
* the {@link #isValid} method, the {@link #checkValid} method,
* the {@link #createStreamingValidator} method and
* the {@link #createValue} method can be called without
* providing a context object.
*
* @return
* <b>true</b> if this datatype is context-dependent
* (it needs a context object sometimes);
*
* <b>false</b> if this datatype is context-<b>in</b>dependent
* (it never needs a context object).
*/
public boolean isContextDependent();
}

View File

@ -1,70 +0,0 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.relaxng.datatype;
/**
* Creates a user-defined type by adding parameters to
* the pre-defined type.
*
* @author <a href="mailto:jjc@jclark.com">James Clark</a>
* @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
*/
public interface DatatypeBuilder {
/**
* Adds a new parameter.
*
* @param name
* The name of the parameter to be added.
* @param strValue
* The raw value of the parameter. Caller may not normalize
* this value because any white space is potentially significant.
* @param context
* The context information which can be used by the callee to
* acquire additional information. This context object is
* valid only during this method call. The callee may not
* keep a reference to this object.
* @exception DatatypeException
* When the given parameter is inappropriate for some reason.
* The callee is responsible to recover from this error.
* That is, the object should behave as if no such error
* was occured.
*/
void addParameter( String name, String strValue, ValidationContext context )
throws DatatypeException;
/**
* Derives a new Datatype from a Datatype by parameters that
* were already set through the addParameter method.
*
* @exception DatatypeException
* DatatypeException must be thrown if the derivation is
* somehow invalid. For example, a required parameter is missing,
* etc. The exception should contain a diagnosis message
* if possible.
*/
Datatype createDatatype() throws DatatypeException;
}

View File

@ -1,64 +0,0 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.relaxng.datatype;
/**
* Signals Datatype related exceptions.
*
* @author <a href="mailto:jjc@jclark.com">James Clark</a>
* @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
*/
public class DatatypeException extends Exception {
public DatatypeException( int index, String msg ) {
super(msg);
this.index = index;
}
public DatatypeException( String msg ) {
this(UNKNOWN,msg);
}
/**
* A constructor for those datatype libraries which don't support any
* diagnostic information at all.
*/
public DatatypeException() {
this(UNKNOWN,null);
}
private final int index;
public static final int UNKNOWN = -1;
/**
* Gets the index of the content where the error occured.
* UNKNOWN can be returned to indicate that no index information
* is available.
*/
public int getIndex() {
return index;
}
}

View File

@ -1,62 +0,0 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.relaxng.datatype;
/**
* A Datatype library
*
* @author <a href="mailto:jjc@jclark.com">James Clark</a>
* @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
*/
public interface DatatypeLibrary {
/**
* Creates a new instance of DatatypeBuilder.
*
* The callee should throw a DatatypeException in case of an error.
*
* @param baseTypeLocalName
* The local name of the base type.
*
* @return
* A non-null valid datatype object.
*/
DatatypeBuilder createDatatypeBuilder( String baseTypeLocalName )
throws DatatypeException;
/**
* Gets or creates a pre-defined type.
*
* This is just a short-cut of
* <code>createDatatypeBuilder(typeLocalName).createDatatype();</code>
*
* The callee should throw a DatatypeException in case of an error.
*
* @return
* A non-null valid datatype object.
*/
Datatype createDatatype( String typeLocalName ) throws DatatypeException;
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.relaxng.datatype;
/**
* Factory class for the DatatypeLibrary class.
*
* <p>
* The datatype library should provide the implementation of
* this interface if it wants to be found by the schema processors.
* The implementor also have to place a file in your jar file.
* See the reference datatype library implementation for detail.
*
* @author <a href="mailto:jjc@jclark.com">James Clark</a>
* @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
*/
public interface DatatypeLibraryFactory
{
/**
* Creates a new instance of a DatatypeLibrary that supports
* the specified namespace URI.
*
* @return
* <code>null</code> if the specified namespace URI is not
* supported.
*/
DatatypeLibrary createDatatypeLibrary( String namespaceURI );
}

View File

@ -1,71 +0,0 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.relaxng.datatype;
/**
* Datatype streaming validator.
*
* <p>
* The streaming validator is an optional feature that is useful for
* certain Datatypes. It allows the caller to incrementally provide
* the literal.
*
* @author <a href="mailto:jjc@jclark.com">James Clark</a>
* @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
*/
public interface DatatypeStreamingValidator {
/**
* Passes an additional fragment of the literal.
*
* <p>
* The application can call this method several times, then call
* the isValid method (or the checkValid method) to check the validity
* of the accumulated characters.
*/
void addCharacters( char[] buf, int start, int len );
/**
* Tells if the accumulated literal is valid with respect to
* the underlying Datatype.
*
* @return
* True if it is valid. False if otherwise.
*/
boolean isValid();
/**
* Similar to the isValid method, but this method throws
* Exception (with possibly diagnostic information), instead of
* returning false.
*
* @exception DatatypeException
* If the callee supports the diagnosis and the accumulated
* literal is invalid, then this exception that possibly
* contains diagnosis information is thrown.
*/
void checkValid() throws DatatypeException;
}

View File

@ -1,91 +0,0 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.relaxng.datatype;
/**
* An interface that must be implemented by caller to
* provide context information that is necessary to
* perform validation of some Datatypes.
*
* @author <a href="mailto:jjc@jclark.com">James Clark</a>
* @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
*/
public interface ValidationContext {
/**
* Resolves a namespace prefix to the corresponding namespace URI.
*
* This method is used for validating the QName type, for example.
*
* <p>
* If the prefix is "" (empty string), it indicates
* an unprefixed value. The callee
* should resolve it as for an unprefixed
* element, rather than for an unprefixed attribute.
*
* <p>
* If the prefix is "xml", then the callee must resolve
* this prefix into "http://www.w3.org/XML/1998/namespace",
* as defined in the XML Namespaces Recommendation.
*
* @return
* namespace URI of this prefix.
* If the specified prefix is not declared,
* the implementation must return null.
*/
String resolveNamespacePrefix( String prefix );
/**
* Returns the base URI of the context. The null string may be returned
* if no base URI is known.
*/
String getBaseUri();
/**
* Checks if an unparsed entity is declared with the
* specified name.
*
* @return
* true
* if the DTD has an unparsed entity declaration for
* the specified name.
* false
* otherwise.
*/
boolean isUnparsedEntity( String entityName );
/**
* Checks if a notation is declared with the
* specified name.
*
* @return
* true
* if the DTD has a notation declaration for the specified name.
* false
* otherwise.
*/
boolean isNotation( String notationName );
}

View File

@ -1,262 +0,0 @@
/**
* Copyright (c) 2001, Thai Open Source Software Center Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of the Thai Open Source Software Center Ltd nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.relaxng.datatype.helpers;
import org.relaxng.datatype.DatatypeLibraryFactory;
import org.relaxng.datatype.DatatypeLibrary;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Vector;
import java.io.Reader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
/**
* Discovers the datatype library implementation from the classpath.
*
* <p>
* The call of the createDatatypeLibrary method finds an implementation
* from a given datatype library URI at run-time.
*/
public class DatatypeLibraryLoader implements DatatypeLibraryFactory {
private final Service service = new Service(DatatypeLibraryFactory.class);
public DatatypeLibrary createDatatypeLibrary(String uri) {
for (Enumeration e = service.getProviders();
e.hasMoreElements();) {
DatatypeLibraryFactory factory
= (DatatypeLibraryFactory)e.nextElement();
DatatypeLibrary library = factory.createDatatypeLibrary(uri);
if (library != null)
return library;
}
return null;
}
private static class Service {
private final Class serviceClass;
private final Enumeration configFiles;
private Enumeration classNames = null;
private final Vector providers = new Vector();
private Loader loader;
private class ProviderEnumeration implements Enumeration {
private int nextIndex = 0;
public boolean hasMoreElements() {
return nextIndex < providers.size() || moreProviders();
}
public Object nextElement() {
try {
return providers.elementAt(nextIndex++);
}
catch (ArrayIndexOutOfBoundsException e) {
throw new NoSuchElementException();
}
}
}
private static class Singleton implements Enumeration {
private Object obj;
private Singleton(Object obj) {
this.obj = obj;
}
public boolean hasMoreElements() {
return obj != null;
}
public Object nextElement() {
if (obj == null)
throw new NoSuchElementException();
Object tem = obj;
obj = null;
return tem;
}
}
// JDK 1.1
private static class Loader {
Enumeration getResources(String resName) {
ClassLoader cl = Loader.class.getClassLoader();
URL url;
if (cl == null)
url = ClassLoader.getSystemResource(resName);
else
url = cl.getResource(resName);
return new Singleton(url);
}
Class loadClass(String name) throws ClassNotFoundException {
return Class.forName(name);
}
}
// JDK 1.2+
private static class Loader2 extends Loader {
private ClassLoader cl;
Loader2() {
cl = Loader2.class.getClassLoader();
// If the thread context class loader has the class loader
// of this class as an ancestor, use the thread context class
// loader. Otherwise, the thread context class loader
// probably hasn't been set up properly, so don't use it.
ClassLoader clt = Thread.currentThread().getContextClassLoader();
for (ClassLoader tem = clt; tem != null; tem = tem.getParent())
if (tem == cl) {
cl = clt;
break;
}
}
Enumeration getResources(String resName) {
try {
return cl.getResources(resName);
}
catch (IOException e) {
return new Singleton(null);
}
}
Class loadClass(String name) throws ClassNotFoundException {
return Class.forName(name, true, cl);
}
}
public Service(Class cls) {
try {
loader = new Loader2();
}
catch (NoSuchMethodError e) {
loader = new Loader();
}
serviceClass = cls;
String resName = "META-INF/services/" + serviceClass.getName();
configFiles = loader.getResources(resName);
}
public Enumeration getProviders() {
return new ProviderEnumeration();
}
synchronized private boolean moreProviders() {
for (;;) {
while (classNames == null) {
if (!configFiles.hasMoreElements())
return false;
classNames = parseConfigFile((URL)configFiles.nextElement());
}
while (classNames.hasMoreElements()) {
String className = (String)classNames.nextElement();
try {
Class cls = loader.loadClass(className);
Object obj = cls.newInstance();
if (serviceClass.isInstance(obj)) {
providers.addElement(obj);
return true;
}
}
catch (ClassNotFoundException e) { }
catch (InstantiationException e) { }
catch (IllegalAccessException e) { }
catch (LinkageError e) { }
}
classNames = null;
}
}
private static final int START = 0;
private static final int IN_NAME = 1;
private static final int IN_COMMENT = 2;
private static Enumeration parseConfigFile(URL url) {
try {
InputStream in = url.openStream();
Reader r;
try {
r = new InputStreamReader(in, "UTF-8");
}
catch (UnsupportedEncodingException e) {
r = new InputStreamReader(in, "UTF8");
}
r = new BufferedReader(r);
Vector tokens = new Vector();
StringBuffer tokenBuf = new StringBuffer();
int state = START;
for (;;) {
int n = r.read();
if (n < 0)
break;
char c = (char)n;
switch (c) {
case '\r':
case '\n':
state = START;
break;
case ' ':
case '\t':
break;
case '#':
state = IN_COMMENT;
break;
default:
if (state != IN_COMMENT) {
state = IN_NAME;
tokenBuf.append(c);
}
break;
}
if (tokenBuf.length() != 0 && state != IN_NAME) {
tokens.addElement(tokenBuf.toString());
tokenBuf.setLength(0);
}
}
if (tokenBuf.length() != 0)
tokens.addElement(tokenBuf.toString());
return tokens.elements();
}
catch (IOException e) {
return null;
}
}
}
}

View File

@ -1,67 +0,0 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.relaxng.datatype.helpers;
import org.relaxng.datatype.*;
/**
* Dummy implementation of {@link DatatypeBuilder}.
*
* This implementation can be used for Datatypes which have no parameters.
* Any attempt to add parameters will be rejected.
*
* <p>
* Typical usage would be:
* <PRE><XMP>
* class MyDatatypeLibrary implements DatatypeLibrary {
* ....
* DatatypeBuilder createDatatypeBuilder( String typeName ) {
* return new ParameterleessDatatypeBuilder(createDatatype(typeName));
* }
* ....
* }
* </XMP></PRE>
*
* @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
*/
public final class ParameterlessDatatypeBuilder implements DatatypeBuilder {
/** This type object is returned for the derive method. */
private final Datatype baseType;
public ParameterlessDatatypeBuilder( Datatype baseType ) {
this.baseType = baseType;
}
public void addParameter( String name, String strValue, ValidationContext context )
throws DatatypeException {
throw new DatatypeException();
}
public Datatype createDatatype() throws DatatypeException {
return baseType;
}
}

View File

@ -1,80 +0,0 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.relaxng.datatype.helpers;
import org.relaxng.datatype.*;
/**
* Dummy implementation of {@link DatatypeStreamingValidator}.
*
* <p>
* This implementation can be used as a quick hack when the performance
* of streaming validation is not important. And this implementation
* also shows you how to implement the DatatypeStreamingValidator interface.
*
* <p>
* Typical usage would be:
* <PRE><XMP>
* class MyDatatype implements Datatype {
* ....
* public DatatypeStreamingValidator createStreamingValidator( ValidationContext context ) {
* return new StreamingValidatorImpl(this,context);
* }
* ....
* }
* </XMP></PRE>
*
* @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
*/
public final class StreamingValidatorImpl implements DatatypeStreamingValidator {
/** This buffer accumulates characters. */
private final StringBuffer buffer = new StringBuffer();
/** Datatype obejct that creates this streaming validator. */
private final Datatype baseType;
/** The current context. */
private final ValidationContext context;
public void addCharacters( char[] buf, int start, int len ) {
// append characters to the current buffer.
buffer.append(buf,start,len);
}
public boolean isValid() {
return baseType.isValid(buffer.toString(),context);
}
public void checkValid() throws DatatypeException {
baseType.checkValid(buffer.toString(),context);
}
public StreamingValidatorImpl( Datatype baseType, ValidationContext context ) {
this.baseType = baseType;
this.context = context;
}
}

View File

@ -42,10 +42,12 @@ package sun.launcher;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.Charset;
import java.util.ResourceBundle;
import java.text.MessageFormat;
import java.util.ArrayList;
@ -471,11 +473,11 @@ public enum LauncherHelper {
} catch (ClassNotFoundException cnfe) {
abort(ostream, cnfe, "java.launcher.cls.error1", cn);
}
signatureDiagnostic(ostream, c);
getMainMethod(ostream, c);
return c;
}
static void signatureDiagnostic(PrintStream ostream, Class<?> clazz) {
static Method getMainMethod(PrintStream ostream, Class<?> clazz) {
String classname = clazz.getName();
Method method = null;
try {
@ -495,6 +497,31 @@ public enum LauncherHelper {
if (method.getReturnType() != java.lang.Void.TYPE) {
abort(ostream, null, "java.launcher.cls.error3", classname);
}
return;
return method;
}
private static final String encprop = "sun.jnu.encoding";
private static String encoding = null;
private static boolean isCharsetSupported = false;
/*
* converts a c or a byte array to a platform specific string,
* previously implemented as a native method in the launcher.
*/
static String makePlatformString(boolean printToStderr, byte[] inArray) {
final PrintStream ostream = (printToStderr) ? System.err : System.out;
if (encoding == null) {
encoding = System.getProperty(encprop);
isCharsetSupported = Charset.isSupported(encoding);
}
try {
String out = isCharsetSupported
? new String(inArray, encoding)
: new String(inArray);
return out;
} catch (UnsupportedEncodingException uee) {
abort(ostream, uee, null);
}
return null; // keep the compiler happy
}
}

View File

@ -755,11 +755,14 @@ class DatagramChannelImpl
throw new IllegalArgumentException("Group not a multicast address");
// check multicast address is compatible with this socket
if (!(group instanceof Inet4Address)) {
if (family == StandardProtocolFamily.INET)
throw new IllegalArgumentException("Group is not IPv4 address");
if (!(group instanceof Inet6Address))
throw new IllegalArgumentException("Address type not supported");
if (group instanceof Inet4Address) {
if (family == StandardProtocolFamily.INET6 && !Net.canIPv6SocketJoinIPv4Group())
throw new IllegalArgumentException("Group is not IPv4 multicast address");
} else if (group instanceof Inet6Address) {
if (family != StandardProtocolFamily.INET6)
throw new IllegalArgumentException("Group is not IPv6 multicast address");
} else {
throw new IllegalArgumentException("Address type not supported");
}
// check source address
@ -791,7 +794,9 @@ class DatagramChannelImpl
}
MembershipKeyImpl key;
if (family == StandardProtocolFamily.INET6) {
if ((family == StandardProtocolFamily.INET6) &&
((group instanceof Inet6Address) || Net.canJoin6WithIPv4Group()))
{
int index = interf.getIndex();
if (index == -1)
throw new IOException("Network interface cannot be identified");
@ -861,7 +866,7 @@ class DatagramChannelImpl
return;
try {
if (family == StandardProtocolFamily.INET6) {
if (key instanceof MembershipKeyImpl.Type6) {
MembershipKeyImpl.Type6 key6 =
(MembershipKeyImpl.Type6)key;
Net.drop6(fd, key6.groupAddress(), key6.index(), key6.source());
@ -901,7 +906,7 @@ class DatagramChannelImpl
throw new IllegalArgumentException("Source address is different type to group");
int n;
if (family == StandardProtocolFamily.INET6) {
if (key instanceof MembershipKeyImpl.Type6) {
MembershipKeyImpl.Type6 key6 =
(MembershipKeyImpl.Type6)key;
n = Net.block6(fd, key6.groupAddress(), key6.index(),
@ -931,7 +936,7 @@ class DatagramChannelImpl
throw new IllegalStateException("key is no longer valid");
try {
if (family == StandardProtocolFamily.INET6) {
if (key instanceof MembershipKeyImpl.Type6) {
MembershipKeyImpl.Type6 key6 =
(MembershipKeyImpl.Type6)key;
Net.unblock6(fd, key6.groupAddress(), key6.index(),

View File

@ -60,6 +60,21 @@ class Net { // package-private
return isIPv6Available;
}
/**
* Tells whether IPv6 sockets can join IPv4 multicast groups
*/
static boolean canIPv6SocketJoinIPv4Group() {
return canIPv6SocketJoinIPv4Group0();
}
/**
* Tells whether {@link #join6} can be used to join an IPv4
* multicast group (IPv4 group as IPv4-mapped IPv6 address)
*/
static boolean canJoin6WithIPv4Group() {
return canJoin6WithIPv4Group0();
}
static InetSocketAddress checkAddress(SocketAddress sa) {
if (sa == null)
throw new NullPointerException();
@ -291,7 +306,11 @@ class Net { // package-private
// -- Socket operations --
static native boolean isIPv6Available0();
private static native boolean isIPv6Available0();
private static native boolean canIPv6SocketJoinIPv4Group0();
private static native boolean canJoin6WithIPv4Group0();
static FileDescriptor socket(boolean stream) {
return socket(UNSPEC, stream);

View File

@ -679,6 +679,14 @@ public class ExtendedCharsets
"1124"
});
charset("x-IBM1364", "IBM1364",
new String[] {
"cp1364",
"ibm1364",
"ibm-1364",
"1364"
});
charset("IBM273", "IBM273",
new String[] {
"cp273", // JDK historical

View File

@ -57,8 +57,8 @@ abstract class AbstractAclFileAttributeView
setAcl((List<AclEntry>)value);
return;
}
throw new UnsupportedOperationException("'" + name() + ":" +
attribute + "' not supported");
throw new IllegalArgumentException("'" + name() + ":" +
attribute + "' not recognized");
}
@Override
@ -81,6 +81,8 @@ abstract class AbstractAclFileAttributeView
owner = true;
continue;
}
throw new IllegalArgumentException("'" + name() + ":" +
attribute + "' not recognized");
}
Map<String,Object> result = new HashMap<>(2);
if (acl)

View File

@ -46,6 +46,18 @@ abstract class AbstractBasicFileAttributeView
private static final String IS_SYMBOLIC_LINK_NAME = "isSymbolicLink";
private static final String IS_OTHER_NAME = "isOther";
// the names of the basic attributes
static final Set<String> basicAttributeNames =
Util.newSet(SIZE_NAME,
CREATION_TIME_NAME,
LAST_ACCESS_TIME_NAME,
LAST_MODIFIED_TIME_NAME,
FILE_KEY_NAME,
IS_DIRECTORY_NAME,
IS_REGULAR_FILE_NAME,
IS_SYMBOLIC_LINK_NAME,
IS_OTHER_NAME);
protected AbstractBasicFileAttributeView() { }
@Override
@ -69,24 +81,26 @@ abstract class AbstractBasicFileAttributeView
setTimes(null, null, (FileTime)value);
return;
}
throw new UnsupportedOperationException("'" + attribute +
"' is unknown or read-only attribute");
throw new IllegalArgumentException("'" + name() + ":" +
attribute + "' not recognized");
}
/**
* Used to build a map of attribute name/values.
*/
static class AttributesBuilder {
private Set<String> set = new HashSet<>();
private Set<String> names = new HashSet<>();
private Map<String,Object> map = new HashMap<>();
private boolean copyAll;
private AttributesBuilder(String[] attributes) {
for (String attribute: attributes) {
if (attribute.equals("*")) {
private AttributesBuilder(Set<String> allowed, String[] requested) {
for (String name: requested) {
if (name.equals("*")) {
copyAll = true;
} else {
set.add(attribute);
if (!allowed.contains(name))
throw new IllegalArgumentException("'" + name + "' not recognized");
names.add(name);
}
}
}
@ -94,21 +108,19 @@ abstract class AbstractBasicFileAttributeView
/**
* Creates builder to build up a map of the matching attributes
*/
static AttributesBuilder create(String[] attributes) {
return new AttributesBuilder(attributes);
static AttributesBuilder create(Set<String> allowed, String[] requested) {
return new AttributesBuilder(allowed, requested);
}
/**
* Returns true if the attribute should be returned in the map
*/
boolean match(String attribute) {
if (copyAll)
return true;
return set.contains(attribute);
boolean match(String name) {
return copyAll || names.contains(name);
}
void add(String attribute, Object value) {
map.put(attribute, value);
void add(String name, Object value) {
map.put(name, value);
}
/**
@ -124,7 +136,7 @@ abstract class AbstractBasicFileAttributeView
* Invoked by readAttributes or sub-classes to add all matching basic
* attributes to the builder
*/
final void addBasicAttributesToBuilder(BasicFileAttributes attrs,
final void addRequestedBasicAttributes(BasicFileAttributes attrs,
AttributesBuilder builder)
{
if (builder.match(SIZE_NAME))
@ -148,9 +160,12 @@ abstract class AbstractBasicFileAttributeView
}
@Override
public Map<String,Object> readAttributes(String[] attributes) throws IOException {
AttributesBuilder builder = AttributesBuilder.create(attributes);
addBasicAttributesToBuilder(readAttributes(), builder);
public Map<String,Object> readAttributes(String[] requested)
throws IOException
{
AttributesBuilder builder =
AttributesBuilder.create(basicAttributeNames, requested);
addRequestedBasicAttributes(readAttributes(), builder);
return builder.unmodifiableMap();
}
}

View File

@ -29,7 +29,6 @@ import java.nio.file.*;
import java.nio.file.spi.FileSystemProvider;
import java.io.IOException;
import java.util.Map;
import java.util.Collections;
/**
* Base implementation class of FileSystemProvider
@ -72,6 +71,8 @@ abstract class AbstractFileSystemProvider extends FileSystemProvider {
throws IOException
{
String[] s = split(attribute);
if (s[0].length() == 0)
throw new IllegalArgumentException(attribute);
DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
if (view == null)
throw new UnsupportedOperationException("View '" + s[0] + "' not available");
@ -83,9 +84,11 @@ abstract class AbstractFileSystemProvider extends FileSystemProvider {
throws IOException
{
String[] s = split(attributes);
if (s[0].length() == 0)
throw new IllegalArgumentException(attributes);
DynamicFileAttributeView view = getFileAttributeView(file, s[0], options);
if (view == null)
return Collections.emptyMap();
throw new UnsupportedOperationException("View '" + s[0] + "' not available");
return view.readAttributes(s[1].split(","));
}

View File

@ -59,22 +59,6 @@ abstract class AbstractUserDefinedFileAttributeView
return "user";
}
private Object getAttribute(String attribute) throws IOException {
int size;
try {
size = size(attribute);
} catch (IOException e) {
// not found or some other I/O error
if (list().contains(attribute))
throw e;
return null;
}
byte[] buf = new byte[size];
int n = read(attribute, ByteBuffer.wrap(buf));
return (n == size) ? buf : Arrays.copyOf(buf, n);
}
@Override
public final void setAttribute(String attribute, Object value)
throws IOException
@ -94,12 +78,13 @@ abstract class AbstractUserDefinedFileAttributeView
{
// names of attributes to return
List<String> names = new ArrayList<>();
for (String name: attributes) {
if (name.equals("*")) {
names = list();
break;
} else {
if (name.length() == 0)
throw new IllegalArgumentException();
names.add(name);
}
}
@ -107,11 +92,12 @@ abstract class AbstractUserDefinedFileAttributeView
// read each value and return in map
Map<String,Object> result = new HashMap<>();
for (String name: names) {
Object value = getAttribute(name);
if (value != null)
result.put(name, value);
int size = size(name);
byte[] buf = new byte[size];
int n = read(name, ByteBuffer.wrap(buf));
byte[] value = (n == size) ? buf : Arrays.copyOf(buf, n);
result.put(name, value);
}
return result;
}
}

View File

@ -81,7 +81,8 @@ abstract class AbstractWatchKey implements WatchKey {
/**
* Return the original watchable (Path)
*/
Path watchable() {
@Override
public Path watchable() {
return dir;
}

View File

@ -63,10 +63,10 @@ final class FileOwnerAttributeViewImpl
{
if (attribute.equals(OWNER_NAME)) {
setOwner((UserPrincipal)value);
return;
} else {
throw new IllegalArgumentException("'" + name() + ":" +
attribute + "' not recognized");
}
throw new UnsupportedOperationException("'" + name() + ":" +
attribute + "' not supported");
}
@Override
@ -75,6 +75,9 @@ final class FileOwnerAttributeViewImpl
for (String attribute: attributes) {
if (attribute.equals("*") || attribute.equals(OWNER_NAME)) {
result.put(OWNER_NAME, getOwner());
} else {
throw new IllegalArgumentException("'" + name() + ":" +
attribute + "' not recognized");
}
}
return result;

View File

@ -25,6 +25,8 @@
package sun.nio.fs;
import java.util.*;
/**
* Utility methods
*/
@ -54,6 +56,28 @@ class Util {
}
result[n] = s.substring(last, s.length());
return result;
}
/**
* Returns a Set containing the given elements.
*/
static <E> Set<E> newSet(E... elements) {
HashSet<E> set = new HashSet<>();
for (E e: elements) {
set.add(e);
}
return set;
}
/**
* Returns a Set containing all the elements of the given Set plus
* the given elements.
*/
static <E> Set<E> newSet(Set<E> other, E... elements) {
HashSet<E> set = new HashSet<>(other);
for (E e: elements) {
set.add(e);
}
return set;
}
}

View File

@ -999,18 +999,34 @@ abstract class P11Key implements Key {
new CK_ATTRIBUTE(CKA_EC_PARAMS),
};
fetchAttributes(attributes);
try {
params = P11ECKeyFactory.decodeParameters
(attributes[1].getByteArray());
DerValue wECPoint = new DerValue(attributes[0].getByteArray());
if (wECPoint.getTag() != DerValue.tag_OctetString)
throw new IOException("Unexpected tag: " +
wECPoint.getTag());
params = P11ECKeyFactory.decodeParameters
(attributes[1].getByteArray());
w = P11ECKeyFactory.decodePoint
(wECPoint.getDataBytes(), params.getCurve());
/*
* An uncompressed EC point may be in either of two formats.
* First try the OCTET STRING encoding:
* 04 <length> 04 <X-coordinate> <Y-coordinate>
*
* Otherwise try the raw encoding:
* 04 <X-coordinate> <Y-coordinate>
*/
byte[] ecKey = attributes[0].getByteArray();
try {
DerValue wECPoint = new DerValue(ecKey);
if (wECPoint.getTag() != DerValue.tag_OctetString)
throw new IOException("Unexpected tag: " +
wECPoint.getTag());
w = P11ECKeyFactory.decodePoint
(wECPoint.getDataBytes(), params.getCurve());
} catch (IOException e) {
// Failover
w = P11ECKeyFactory.decodePoint(ecKey, params.getCurve());
}
} catch (Exception e) {
throw new RuntimeException("Could not parse key values", e);

View File

@ -46,10 +46,16 @@ import sun.security.x509.AuthorityKeyIdentifierExtension;
*/
class AdaptableX509CertSelector extends X509CertSelector {
// The start date of a validity period.
private Date startDate = null;
private Date startDate;
// The end date of a validity period.
private Date endDate = null;
private Date endDate;
// Is subject key identifier sensitive?
private boolean isSKIDSensitive = false;
// Is serial number sensitive?
private boolean isSNSensitive = false;
AdaptableX509CertSelector() {
super();
@ -97,15 +103,24 @@ class AdaptableX509CertSelector extends X509CertSelector {
if (akidext != null) {
KeyIdentifier akid = (KeyIdentifier)akidext.get(akidext.KEY_ID);
if (akid != null) {
DerOutputStream derout = new DerOutputStream();
derout.putOctetString(akid.getIdentifier());
super.setSubjectKeyIdentifier(derout.toByteArray());
// Do not override the previous setting for initial selection.
if (isSKIDSensitive || getSubjectKeyIdentifier() == null) {
DerOutputStream derout = new DerOutputStream();
derout.putOctetString(akid.getIdentifier());
super.setSubjectKeyIdentifier(derout.toByteArray());
isSKIDSensitive = true;
}
}
SerialNumber asn =
(SerialNumber)akidext.get(akidext.SERIAL_NUMBER);
if (asn != null) {
super.setSerialNumber(asn.getNumber());
// Do not override the previous setting for initial selection.
if (isSNSensitive || getSerialNumber() == null) {
super.setSerialNumber(asn.getNumber());
isSNSensitive = true;
}
}
// the subject criterion should be set by the caller.
@ -148,11 +163,25 @@ class AdaptableX509CertSelector extends X509CertSelector {
}
}
if (version < 3 || xcert.getExtensionValue("2.5.29.14") == null) {
// If no SubjectKeyIdentifier extension, don't bother to check it.
// If no SubjectKeyIdentifier extension, don't bother to check it.
if (isSKIDSensitive &&
(version < 3 || xcert.getExtensionValue("2.5.29.14") == null)) {
setSubjectKeyIdentifier(null);
}
// In practice, a CA may replace its root certificate and require that
// the existing certificate is still valid, even if the AKID extension
// does not match the replacement root certificate fields.
//
// Conservatively, we only support the replacement for version 1 and
// version 2 certificate. As for version 2, the certificate extension
// may contain sensitive information (for example, policies), the
// AKID need to be respected to seek the exact certificate in case
// of key or certificate abuse.
if (isSNSensitive && version < 3) {
setSerialNumber(null);
}
return super.match(cert);
}

View File

@ -243,12 +243,6 @@ class ForwardBuilder extends Builder {
caTargetSelector.setPolicy(getMatchingPolicies());
}
/*
* Require CA certs with a pathLenConstraint that allows
* at least as many CA certs that have already been traversed
*/
caTargetSelector.setBasicConstraints(currentState.traversedCACerts);
sel = caTargetSelector;
} else {
@ -282,12 +276,6 @@ class ForwardBuilder extends Builder {
CertPathHelper.setPathToNames
(caSelector, currentState.subjectNamesTraversed);
/*
* Require CA certs with a pathLenConstraint that allows
* at least as many CA certs that have already been traversed
*/
caSelector.setBasicConstraints(currentState.traversedCACerts);
/*
* Facilitate certification path construction with authority
* key identifier and subject key identifier.
@ -305,6 +293,14 @@ class ForwardBuilder extends Builder {
sel = caSelector;
}
/*
* For compatibility, conservatively, we don't check the path
* length constraint of trusted anchors. Please don't set the
* basic constraints criterion unless the trusted certificate
* matching is completed.
*/
sel.setBasicConstraints(-1);
for (X509Certificate trustedCert : trustedCerts) {
if (sel.match(trustedCert)) {
if (debug != null) {
@ -323,6 +319,12 @@ class ForwardBuilder extends Builder {
*/
sel.setCertificateValid(date);
/*
* Require CA certs with a pathLenConstraint that allows
* at least as many CA certs that have already been traversed
*/
sel.setBasicConstraints(currentState.traversedCACerts);
/*
* If we have already traversed as many CA certs as the maxPathLength
* will allow us to, then we don't bother looking through these

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2010, 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
@ -377,8 +377,9 @@ final class ClientHandshaker extends Handshaker {
ProtocolVersion mesgVersion = mesg.protocolVersion;
if (!isNegotiable(mesgVersion)) {
throw new SSLHandshakeException(
"Server chose unsupported or disabled protocol: " +
mesgVersion);
"Server chose " + mesgVersion +
", but that protocol version is not enabled or not supported " +
"by the client.");
}
handshakeHash.protocolDetermined(mesgVersion);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@ -195,6 +195,8 @@ public abstract class SunJSSE extends java.security.Provider {
"sun.security.ssl.KeyManagerFactoryImpl$SunX509");
put("KeyManagerFactory.NewSunX509",
"sun.security.ssl.KeyManagerFactoryImpl$X509");
put("Alg.Alias.KeyManagerFactory.PKIX", "NewSunX509");
put("TrustManagerFactory.SunX509",
"sun.security.ssl.TrustManagerFactoryImpl$SimpleFactory");
put("TrustManagerFactory.PKIX",

View File

@ -123,7 +123,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,com.sun.imageio.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
#
# List of comma-separated packages that start with or equal this string

View File

@ -124,7 +124,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,com.sun.imageio.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
#
# List of comma-separated packages that start with or equal this string

View File

@ -124,7 +124,7 @@ keystore.type=jks
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
package.access=sun.,com.sun.imageio.
package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
#
# List of comma-separated packages that start with or equal this string

View File

@ -489,7 +489,6 @@ enum { CHUNK = (1 << 14), SMALL = (1 << 9) };
// Call malloc. Try to combine small blocks and free much later.
void* unpacker::alloc_heap(size_t size, bool smallOK, bool temp) {
CHECK_0;
if (!smallOK || size > SMALL) {
void* res = must_malloc((int)size);
(temp ? &tmallocs : &mallocs)->add(res);
@ -2560,6 +2559,10 @@ void unpacker::putlayout(band** body) {
int i;
int prevBII = -1;
int prevBCI = -1;
if (body == NULL) {
abort("putlayout: unexpected NULL for body");
return;
}
for (i = 0; body[i] != null; i++) {
band& b = *body[i];
byte le_kind = b.le_kind;
@ -4767,7 +4770,9 @@ void unpacker::redirect_stdio() {
}
char *tname = tempnam(tmpdir,"#upkg");
if (tname == NULL) return;
sprintf(log_file_name, "%s", tname);
::free(tname);
if ((errstrm = fopen(log_file_name, "a+")) != NULL) {
log_file = errstrm_name = saveStr(log_file_name);
return ;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
@ -39,6 +39,8 @@
#define X_IA64 4
#define X_AMD64 5
#define X_ZERO 6
#define X_ARM 7
#define X_PPC 8
// **********************************
// Make sure you set X_PLATFORM and X_ARCH defines correctly.

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -28,8 +28,8 @@
#ifdef __NEWVALID /* special setup for Sun test regime */
#if defined(i386) || defined(i486) || \
defined(intel) || defined(x86) || \
defined(i86pc) || defined(_M_IA64) || defined(ia64)
defined(intel) || defined(x86) || defined(arm) || \
defined(i86pc) || defined(_M_IA64) || defined(ia64)
#define _LITTLE_ENDIAN
#endif
#endif

View File

@ -33,8 +33,7 @@ import java.nio.file.*;
import static java.nio.file.StandardWatchEventKind.*;
import static java.nio.file.LinkOption.*;
import java.nio.file.attribute.*;
import java.io.*;
import java.util.*;
import java.io.IOException;
/**
* Example to watch a directory (or tree) for changes to files.
@ -43,9 +42,9 @@ import java.util.*;
public class WatchDir {
private final WatchService watcher;
private final Map<WatchKey,Path> keys;
private final boolean recursive;
private boolean trace = false;
private int count;
@SuppressWarnings("unchecked")
static <T> WatchEvent<T> cast(WatchEvent<?> event) {
@ -57,17 +56,9 @@ public class WatchDir {
*/
private void register(Path dir) throws IOException {
WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
if (trace) {
Path prev = keys.get(key);
if (prev == null) {
System.out.format("register: %s\n", dir);
} else {
if (!dir.equals(prev)) {
System.out.format("update: %s -> %s\n", prev, dir);
}
}
}
keys.put(key, dir);
count++;
if (trace)
System.out.format("register: %s\n", dir);
}
/**
@ -92,7 +83,6 @@ public class WatchDir {
*/
WatchDir(Path dir, boolean recursive) throws IOException {
this.watcher = FileSystems.getDefault().newWatchService();
this.keys = new HashMap<WatchKey,Path>();
this.recursive = recursive;
if (recursive) {
@ -121,12 +111,6 @@ public class WatchDir {
return;
}
Path dir = keys.get(key);
if (dir == null) {
System.err.println("WatchKey not recognized!!");
continue;
}
for (WatchEvent<?> event: key.pollEvents()) {
WatchEvent.Kind kind = event.kind();
@ -138,7 +122,7 @@ public class WatchDir {
// Context for directory entry event is the file name of entry
WatchEvent<Path> ev = cast(event);
Path name = ev.context();
Path child = dir.resolve(name);
Path child = ((Path)key.watchable()).resolve(name);
// print out event
System.out.format("%s: %s\n", event.kind().name(), child);
@ -156,15 +140,13 @@ public class WatchDir {
}
}
// reset key and remove from set if directory no longer accessible
// reset key
boolean valid = key.reset();
if (!valid) {
keys.remove(key);
// all directories are inaccessible
if (keys.isEmpty()) {
// directory no longer accessible
count--;
if (count == 0)
break;
}
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -67,6 +67,35 @@ ServerClassMachine(void) {
}
}
#ifdef USE_GENERIC_ERGO
/* Ask the OS how many processors there are. */
static unsigned long
physical_processors(void) {
const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
JLI_TraceLauncher("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors);
return sys_processors;
}
jboolean
ServerClassMachineImpl(void) {
jboolean result = JNI_FALSE;
/* How big is a server class machine? */
const unsigned long server_processors = 2UL;
const uint64_t server_memory = 2UL * GB;
const uint64_t actual_memory = physical_memory();
/* Is this a server class machine? */
if (actual_memory >= server_memory) {
const unsigned long actual_processors = physical_processors();
if (actual_processors >= server_processors) {
result = JNI_TRUE;
}
}
JLI_TraceLauncher("unix_" LIBARCHNAME "_ServerClassMachine: %s\n",
(result == JNI_TRUE ? "JNI_TRUE" : "JNI_FALSE"));
return result;
}
#endif
/* Compute physical memory by asking the OS */
uint64_t

View File

@ -1,58 +0,0 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "ergo.h"
/* Methods for solaris-sparc and linux-sparc: these are easy. */
/* Ask the OS how many processors there are. */
static unsigned long
physical_processors(void) {
const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
JLI_TraceLauncher("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors);
return sys_processors;
}
/* The sparc version of the "server-class" predicate. */
jboolean
ServerClassMachineImpl(void) {
jboolean result = JNI_FALSE;
/* How big is a server class machine? */
const unsigned long server_processors = 2UL;
const uint64_t server_memory = 2UL * GB;
const uint64_t actual_memory = physical_memory();
/* Is this a server class machine? */
if (actual_memory >= server_memory) {
const unsigned long actual_processors = physical_processors();
if (actual_processors >= server_processors) {
result = JNI_TRUE;
}
}
JLI_TraceLauncher("unix_" LIBARCHNAME "_ServerClassMachine: %s\n",
(result == JNI_TRUE ? "JNI_TRUE" : "JNI_FALSE"));
return result;
}

View File

@ -1,58 +0,0 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "ergo.h"
/* Methods for solaris-sparc and linux-sparc: these are easy. */
/* Ask the OS how many processors there are. */
static unsigned long
physical_processors(void) {
const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
JLI_TraceLauncher("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors);
return sys_processors;
}
/* The sparc version of the "server-class" predicate. */
jboolean
ServerClassMachineImpl(void) {
jboolean result = JNI_FALSE;
/* How big is a server class machine? */
const unsigned long server_processors = 2UL;
const uint64_t server_memory = 2UL * GB;
const uint64_t actual_memory = physical_memory();
/* Is this a server class machine? */
if (actual_memory >= server_memory) {
const unsigned long actual_processors = physical_processors();
if (actual_processors >= server_processors) {
result = JNI_TRUE;
}
}
JLI_TraceLauncher("unix_" LIBARCHNAME "_ServerClassMachine: %s\n",
(result == JNI_TRUE ? "JNI_TRUE" : "JNI_FALSE"));
return result;
}

View File

@ -27,6 +27,7 @@ package sun.nio.fs;
import java.nio.file.attribute.*;
import java.util.Map;
import java.util.Set;
import java.io.IOException;
import sun.misc.Unsafe;
@ -57,6 +58,10 @@ class LinuxDosFileAttributeView
private static final int DOS_XATTR_SYSTEM = 0x04;
private static final int DOS_XATTR_ARCHIVE = 0x20;
// the names of the DOS attributes (includes basic)
private static final Set<String> dosAttributeNames =
Util.newSet(basicAttributeNames, READONLY_NAME, ARCHIVE_NAME, SYSTEM_NAME, HIDDEN_NAME);
LinuxDosFileAttributeView(UnixPath file, boolean followLinks) {
super(file, followLinks);
}
@ -93,9 +98,10 @@ class LinuxDosFileAttributeView
public Map<String,Object> readAttributes(String[] attributes)
throws IOException
{
AttributesBuilder builder = AttributesBuilder.create(attributes);
AttributesBuilder builder =
AttributesBuilder.create(dosAttributeNames, attributes);
DosFileAttributes attrs = readAttributes();
addBasicAttributesToBuilder(attrs, builder);
addRequestedBasicAttributes(attrs, builder);
if (builder.match(READONLY_NAME))
builder.add(READONLY_NAME, attrs.isReadOnly());
if (builder.match(ARCHIVE_NAME))

View File

@ -28,8 +28,6 @@ package sun.nio.fs;
import java.nio.file.*;
import java.io.IOException;
import java.util.*;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
import static sun.nio.fs.LinuxNativeDispatcher.*;
/**
@ -37,42 +35,16 @@ import static sun.nio.fs.LinuxNativeDispatcher.*;
*/
class LinuxFileSystem extends UnixFileSystem {
private final boolean hasInotify;
LinuxFileSystem(UnixFileSystemProvider provider, String dir) {
super(provider, dir);
// assume X.Y[-Z] format
String osversion = AccessController
.doPrivileged(new GetPropertyAction("os.version"));
String[] vers = Util.split(osversion, '.');
assert vers.length >= 2;
int majorVersion = Integer.parseInt(vers[0]);
int minorVersion = Integer.parseInt(vers[1]);
int microVersion = 0;
if (vers.length > 2) {
String[] microVers = Util.split(vers[2], '-');
microVersion = (microVers.length > 0) ?
Integer.parseInt(microVers[0]) : 0;
}
// inotify available since 2.6.13
this.hasInotify = ((majorVersion > 2) ||
(majorVersion == 2 && minorVersion > 6) ||
((majorVersion == 2) && (minorVersion == 6) && (microVersion >= 13)));
}
@Override
public WatchService newWatchService()
throws IOException
{
if (hasInotify) {
return new LinuxWatchService(this);
} else {
// use polling implementation on older kernels
return new PollingWatchService();
}
// assume 2.6.13 or newer
return new LinuxWatchService(this);
}

View File

@ -123,6 +123,10 @@ class UnixFileAttributeViews {
private static final String OWNER_NAME = "owner";
private static final String GROUP_NAME = "group";
// the names of the posix attributes (incudes basic)
static final Set<String> posixAttributeNames =
Util.newSet(basicAttributeNames, PERMISSIONS_NAME, OWNER_NAME, GROUP_NAME);
Posix(UnixPath file, boolean followLinks) {
super(file, followLinks);
}
@ -172,9 +176,10 @@ class UnixFileAttributeViews {
* Invoked by readAttributes or sub-classes to add all matching posix
* attributes to the builder
*/
final void addPosixAttributesToBuilder(PosixFileAttributes attrs,
final void addRequestedPosixAttributes(PosixFileAttributes attrs,
AttributesBuilder builder)
{
addRequestedBasicAttributes(attrs, builder);
if (builder.match(PERMISSIONS_NAME))
builder.add(PERMISSIONS_NAME, attrs.permissions());
if (builder.match(OWNER_NAME))
@ -184,13 +189,13 @@ class UnixFileAttributeViews {
}
@Override
public Map<String,Object> readAttributes(String[] attributes)
public Map<String,Object> readAttributes(String[] requested)
throws IOException
{
AttributesBuilder builder = AttributesBuilder.create(attributes);
AttributesBuilder builder =
AttributesBuilder.create(posixAttributeNames, requested);
PosixFileAttributes attrs = readAttributes();
addBasicAttributesToBuilder(attrs, builder);
addPosixAttributesToBuilder(attrs, builder);
addRequestedPosixAttributes(attrs, builder);
return builder.unmodifiableMap();
}
@ -287,6 +292,12 @@ class UnixFileAttributeViews {
private static final String GID_NAME = "gid";
private static final String CTIME_NAME = "ctime";
// the names of the unix attributes (including posix)
static final Set<String> unixAttributeNames =
Util.newSet(posixAttributeNames,
MODE_NAME, INO_NAME, DEV_NAME, RDEV_NAME,
NLINK_NAME, UID_NAME, GID_NAME, CTIME_NAME);
Unix(UnixPath file, boolean followLinks) {
super(file, followLinks);
}
@ -316,13 +327,13 @@ class UnixFileAttributeViews {
}
@Override
public Map<String,Object> readAttributes(String[] attributes)
public Map<String,Object> readAttributes(String[] requested)
throws IOException
{
AttributesBuilder builder = AttributesBuilder.create(attributes);
AttributesBuilder builder =
AttributesBuilder.create(unixAttributeNames, requested);
UnixFileAttributes attrs = readAttributes();
addBasicAttributesToBuilder(attrs, builder);
addPosixAttributesToBuilder(attrs, builder);
addRequestedPosixAttributes(attrs, builder);
if (builder.match(MODE_NAME))
builder.add(MODE_NAME, attrs.mode());
if (builder.match(INO_NAME))

Some files were not shown because too many files have changed in this diff Show More