This commit is contained in:
Vinnie Ryan 2009-11-12 23:04:42 +00:00
commit 2a073650dc
187 changed files with 17791 additions and 2762 deletions

View File

@ -49,3 +49,4 @@ b3f3240135f0c10b9f2481c174b81b7fcf0daa60 jdk7-b71
460639b036f327282832a4fe52b7aa45688afd50 jdk7-b72
f708138c9aca4b389872838fe6773872fce3609e jdk7-b73
eacb36e30327e7ae33baa068e82ddccbd91eaae2 jdk7-b74
8885b22565077236a927e824ef450742e434a230 jdk7-b75

View File

@ -116,8 +116,16 @@ 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 = $(CFLAGS_REQUIRED_$(ARCH))
LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH))
ifeq ($(ZERO_BUILD), true)
CFLAGS_REQUIRED = $(ZERO_ARCHFLAG)
ifeq ($(ZERO_ENDIANNESS), little)
CFLAGS_REQUIRED += -D_LITTLE_ENDIAN
endif
LDFLAGS_COMMON += $(ZERO_ARCHFLAG)
else
CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH))
endif
# If this is a --hash-style=gnu system, use --hash-style=both
# The gnu .hash section won't work on some Linux systems like SuSE 10.
@ -217,7 +225,7 @@ endif
EXTRA_LIBS += -lc
LDFLAGS_DEFS_OPTION = -z defs
LDFLAGS_DEFS_OPTION = -Xlinker -z -Xlinker defs
LDFLAGS_COMMON += $(LDFLAGS_DEFS_OPTION)
#

View File

@ -667,12 +667,7 @@ LDLIBS = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
LINTFLAGS = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
$(OTHER_LINTFLAGS)
# this should be moved into Defs-<platform>.gmk.....
ifeq ($(PLATFORM), windows)
VERSION_DEFINES = -DRELEASE="\"$(RELEASE)\""
else
VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
endif
VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
# Note: As a rule, GNU Make rules should not appear in any of the
# Defs*.gmk files. These were added for Kestrel-Solaris and do address

View File

@ -85,7 +85,7 @@ ifneq (,$(findstring $(PLATFORM), linux solaris)) # UNIX systems
endif
endif
ifeq ($(PLATFORM), linux)
LDFLAGS += -z origin
LDFLAGS += -Wl,-z -Wl,origin
LDFLAGS += -Wl,--allow-shlib-undefined
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli
@ -236,13 +236,13 @@ endif # files
endif # INCREMENTAL_BUILD
ifdef JAVA_ARGS
OTHER_CPPFLAGS += -DJAVA_ARGS=$(JAVA_ARGS)
OTHER_CPPFLAGS += -DLAUNCHER_NAME=\"$(LAUNCHER_NAME)\"
OTHER_CPPFLAGS += -DJAVA_ARGS='$(JAVA_ARGS)'
OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"'
endif
ifeq ($(PLATFORM), windows)
ifdef RELEASE
OTHER_CPPFLAGS += -DVERSION="$(RELEASE)"
OTHER_CPPFLAGS += -DVERSION='"$(RELEASE)"'
endif
endif
@ -258,14 +258,8 @@ endif
OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)/bin -I$(LAUNCHER_PLATFORM_SRC)/bin
OTHER_INCLUDES += -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
# this may not be necessary...
ifeq ($(PLATFORM), windows)
OTHER_CPPFLAGS += -DPROGNAME="\"$(PROGRAM)\""
VERSION_DEFINES += -DFULL_VERSION="\"$(FULL_VERSION)\""
else
OTHER_CPPFLAGS += -DPROGNAME='"$(PROGRAM)"'
VERSION_DEFINES += -DFULL_VERSION='"$(FULL_VERSION)"'
endif
VERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
-DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"'
@ -279,8 +273,14 @@ $(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c
#
# How to install jvm.cfg.
#
$(JVMCFG): $(LAUNCHER_PLATFORM_SRC)/bin/$(ARCH)/jvm.cfg
#
ifeq ($(ZERO_BUILD), true)
JVMCFG_ARCH = zero
else
JVMCFG_ARCH = $(ARCH)
endif
$(JVMCFG): $(LAUNCHER_PLATFORM_SRC)/bin/$(JVMCFG_ARCH)/jvm.cfg
$(install-file)
#

View File

@ -330,7 +330,7 @@ endif
#
# Specific files and directories that will be filtered out from above areas.
#
SOURCE_FILTERs = $(SCM_DIRs) 'X-*' '*-X-*' '*-template.java' ',*'
SOURCE_FILTERs = $(SCM_DIRs) ',*'
SOURCE_FILES_filter = $(SOURCE_FILTERs:%=-name % -prune -o)
#

View File

@ -63,7 +63,7 @@ endif
# If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files
#
ifdef AUTO_FILES_PROPERTIES_DIRS
AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' ',*'
AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) ',*'
AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE)
FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o)
FILES_properties_auto1 := \
@ -111,7 +111,7 @@ include $(JDK_TOPDIR)/make/common/internal/Resources.gmk
ifdef AUTO_FILES_JAVA_DIRS
# Filter out these files or directories
AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' '*-template.java' ',*'
AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) ',*'
AUTO_FILES_JAVA_SOURCE_FILTERS2 =
AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE)
AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE)

View File

@ -109,7 +109,7 @@ else
LDFLAGS += -R \$$ORIGIN/jli
endif
ifeq ($(PLATFORM), linux)
LDFLAGS += -z origin
LDFLAGS += -Wl,-z -Wl,origin
LDFLAGS += -Wl,--allow-shlib-undefined
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/jli
endif

View File

@ -287,11 +287,18 @@ JAVA_JAVA_java = \
java/util/concurrent/ExecutorService.java \
java/util/concurrent/ExecutorCompletionService.java \
java/util/concurrent/Executors.java \
java/util/concurrent/ForkJoinPool.java \
java/util/concurrent/ForkJoinTask.java \
java/util/concurrent/ForkJoinWorkerThread.java \
java/util/concurrent/Future.java \
java/util/concurrent/FutureTask.java \
java/util/concurrent/LinkedBlockingDeque.java \
java/util/concurrent/LinkedBlockingQueue.java \
java/util/concurrent/LinkedTransferQueue.java \
java/util/concurrent/Phaser.java \
java/util/concurrent/PriorityBlockingQueue.java \
java/util/concurrent/RecursiveAction.java \
java/util/concurrent/RecursiveTask.java \
java/util/concurrent/RejectedExecutionException.java \
java/util/concurrent/RejectedExecutionHandler.java \
java/util/concurrent/RunnableFuture.java \
@ -302,9 +309,11 @@ JAVA_JAVA_java = \
java/util/concurrent/Semaphore.java \
java/util/concurrent/SynchronousQueue.java \
java/util/concurrent/ThreadFactory.java \
java/util/concurrent/ThreadLocalRandom.java \
java/util/concurrent/ThreadPoolExecutor.java \
java/util/concurrent/TimeUnit.java \
java/util/concurrent/TimeoutException.java \
java/util/concurrent/TransferQueue.java \
java/util/concurrent/atomic/AtomicBoolean.java \
java/util/concurrent/atomic/AtomicInteger.java \
java/util/concurrent/atomic/AtomicIntegerArray.java \

View File

@ -48,11 +48,15 @@ ZIP_SRC = $(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
LAUNCHER_SHARE_SRC = $(SHARE_SRC)/bin
LAUNCHER_PLATFORM_SRC = $(PLATFORM_SRC)/bin
ifeq ($(ZERO_BUILD), true)
ERGO_FAMILY=zero
else
ifeq ($(ARCH_FAMILY), amd64)
ERGO_FAMILY=i586
else
ERGO_FAMILY=$(ARCH_FAMILY)
endif
endif
#

View File

@ -57,7 +57,7 @@ endif
#
include $(BUILDDIR)/common/Program.gmk
OTHER_CPPFLAGS += -DEXPAND_CLASSPATH_WILDCARDS
OTHER_CPPFLAGS += -DLAUNCHER_NAME=\"$(LAUNCHER_NAME)\"
OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"'
ifeq ($(PLATFORM), solaris)
LDFLAGS += -R$(OPENWIN_LIB)

View File

@ -62,4 +62,5 @@ endif
#
include $(BUILDDIR)/common/Program.gmk
OTHER_CPPFLAGS += -DEXPAND_CLASSPATH_WILDCARDS
OTHER_CPPFLAGS += -DLAUNCHER_NAME=\"$(LAUNCHER_NAME)\"
OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"'

View File

@ -335,6 +335,15 @@ SCH_SRC=$(SNIO_SRC)/ch
SCS_SRC=$(SNIO_SRC)/cs
SFS_SRC=$(SNIO_SRC)/fs
# Template files
HEAP_X_BUF_TEMPLATE=$(BUF_SRC)/Heap-X-Buffer.java.template
BYTE_X_BUF_TEMPLATE=$(BUF_SRC)/ByteBufferAs-X-Buffer.java.template
X_BUF_TEMPLATE=$(BUF_SRC)/X-Buffer.java.template
X_BUF_BIN_TEMPLATE=$(BUF_SRC)/X-Buffer-bin.java.template
DIRECT_X_BUF_TEMPLATE=$(BUF_SRC)/Direct-X-Buffer.java.template
DIRECT_X_BUF_BIN_TEMPLATE=$(BUF_SRC)/Direct-X-Buffer-bin.java.template
CHARSET_X_CODER_TEMPLATE=$(CS_SRC)/Charset-X-Coder.java.template
BUF_GEN=$(NIO_GEN)
CH_GEN=$(NIO_GEN)/channels
CS_GEN=$(NIO_GEN)/charset
@ -357,39 +366,39 @@ GEN_BUFFER_CMD = SPP="$(SPP_CMD)" NAWK="$(NAWK)" SED="$(SED)" SH="$(SH)" \
# Public abstract buffer classes
#
$(BUF_GEN)/ByteBuffer.java: $(BUF_SRC)/X-Buffer.java \
$(BUF_SRC)/X-Buffer-bin.java \
$(BUF_GEN)/ByteBuffer.java: $(X_BUF_TEMPLATE) \
$(X_BUF_BIN_TEMPLATE) \
$(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=byte BIN=1 SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/CharBuffer.java: $(BUF_SRC)/X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/CharBuffer.java: $(X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ShortBuffer.java: $(BUF_SRC)/X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ShortBuffer.java: $(X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/IntBuffer.java: $(BUF_SRC)/X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/IntBuffer.java: $(X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/LongBuffer.java: $(BUF_SRC)/X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/LongBuffer.java: $(X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/FloatBuffer.java: $(BUF_SRC)/X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/FloatBuffer.java: $(X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DoubleBuffer.java: $(BUF_SRC)/X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DoubleBuffer.java: $(X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
@ -397,72 +406,72 @@ $(BUF_GEN)/DoubleBuffer.java: $(BUF_SRC)/X-Buffer.java $(GEN_BUFFER_SH)
# Buffers whose contents are heap-allocated
#
$(BUF_GEN)/HeapByteBuffer.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapByteBuffer.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=byte SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapByteBuffer%.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapByteBuffer%.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=byte RW=$* SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapCharBuffer.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapCharBuffer.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapCharBuffer%.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapCharBuffer%.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char RW=$* SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapShortBuffer.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapShortBuffer.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapShortBuffer%.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapShortBuffer%.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short RW=$* SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapIntBuffer.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapIntBuffer.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapIntBuffer%.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapIntBuffer%.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int RW=$* SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapLongBuffer.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapLongBuffer.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapLongBuffer%.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapLongBuffer%.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long RW=$* SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapFloatBuffer.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapFloatBuffer.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapFloatBuffer%.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapFloatBuffer%.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float RW=$* SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapDoubleBuffer.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapDoubleBuffer.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/HeapDoubleBuffer%.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/HeapDoubleBuffer%.java: $(HEAP_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double RW=$* SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
@ -470,15 +479,15 @@ $(BUF_GEN)/HeapDoubleBuffer%.java: $(BUF_SRC)/Heap-X-Buffer.java $(GEN_BUFFER_SH
# Direct byte buffer
#
$(BUF_GEN)/DirectByteBuffer.java: $(BUF_SRC)/Direct-X-Buffer.java \
$(BUF_SRC)/Direct-X-Buffer.java \
$(BUF_GEN)/DirectByteBuffer.java: $(DIRECT_X_BUF_TEMPLATE) \
$(DIRECT_X_BUF_TEMPLATE) \
$(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=byte BIN=1 SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectByteBuffer%.java: $(BUF_SRC)/Direct-X-Buffer.java \
$(BUF_SRC)/Direct-X-Buffer.java \
$(BUF_GEN)/DirectByteBuffer%.java: $(DIRECT_X_BUF_TEMPLATE) \
$(DIRECT_X_BUF_TEMPLATE) \
$(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
@ -487,62 +496,62 @@ $(BUF_GEN)/DirectByteBuffer%.java: $(BUF_SRC)/Direct-X-Buffer.java \
# Unswapped views of direct byte buffers
#
$(BUF_GEN)/DirectCharBufferU.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectCharBufferU.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectCharBuffer%U.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectCharBuffer%U.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char RW=$* BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectShortBufferU.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectShortBufferU.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectShortBuffer%U.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectShortBuffer%U.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short RW=$* BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectIntBufferU.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectIntBufferU.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectIntBuffer%U.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectIntBuffer%U.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int RW=$* BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectLongBufferU.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectLongBufferU.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectLongBuffer%U.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectLongBuffer%U.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long RW=$* BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectFloatBufferU.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectFloatBufferU.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectFloatBuffer%U.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectFloatBuffer%U.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float RW=$* BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectDoubleBufferU.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectDoubleBufferU.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectDoubleBuffer%U.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectDoubleBuffer%U.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double RW=$* BO=U SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
@ -550,62 +559,62 @@ $(BUF_GEN)/DirectDoubleBuffer%U.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFF
# Swapped views of direct byte buffers
#
$(BUF_GEN)/DirectCharBufferS.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectCharBufferS.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectCharBuffer%S.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectCharBuffer%S.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char RW=$* BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectShortBufferS.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectShortBufferS.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectShortBuffer%S.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectShortBuffer%S.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short RW=$* BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectIntBufferS.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectIntBufferS.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectIntBuffer%S.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectIntBuffer%S.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int RW=$* BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectLongBufferS.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectLongBufferS.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectLongBuffer%S.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectLongBuffer%S.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long RW=$* BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectFloatBufferS.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectFloatBufferS.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectFloatBuffer%S.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectFloatBuffer%S.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float RW=$* BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectDoubleBufferS.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectDoubleBufferS.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/DirectDoubleBuffer%S.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/DirectDoubleBuffer%S.java: $(DIRECT_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double RW=$* BO=S SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
@ -613,62 +622,62 @@ $(BUF_GEN)/DirectDoubleBuffer%S.java: $(BUF_SRC)/Direct-X-Buffer.java $(GEN_BUFF
# Big-endian views of byte buffers
#
$(BUF_GEN)/ByteBufferAsCharBufferB.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsCharBufferB.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsCharBuffer%B.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsCharBuffer%B.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char RW=$* BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsShortBufferB.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsShortBufferB.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsShortBuffer%B.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsShortBuffer%B.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short RW=$* BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsIntBufferB.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsIntBufferB.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsIntBuffer%B.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsIntBuffer%B.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int RW=$* BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsLongBufferB.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsLongBufferB.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsLongBuffer%B.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsLongBuffer%B.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long RW=$* BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsFloatBufferB.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsFloatBufferB.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsFloatBuffer%B.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsFloatBuffer%B.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float RW=$* BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsDoubleBufferB.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsDoubleBufferB.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsDoubleBuffer%B.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsDoubleBuffer%B.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double RW=$* BO=B SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
@ -676,62 +685,62 @@ $(BUF_GEN)/ByteBufferAsDoubleBuffer%B.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.jav
# Little-endian views of byte buffers
#
$(BUF_GEN)/ByteBufferAsCharBufferL.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsCharBufferL.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsCharBuffer%L.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsCharBuffer%L.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=char RW=$* BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsShortBufferL.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsShortBufferL.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsShortBuffer%L.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsShortBuffer%L.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=short RW=$* BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsIntBufferL.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsIntBufferL.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsIntBuffer%L.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsIntBuffer%L.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=int RW=$* BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsLongBufferL.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsLongBufferL.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsLongBuffer%L.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsLongBuffer%L.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=long RW=$* BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsFloatBufferL.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsFloatBufferL.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsFloatBuffer%L.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsFloatBuffer%L.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=float RW=$* BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsDoubleBufferL.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsDoubleBufferL.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
$(MV) $@.temp $@
$(BUF_GEN)/ByteBufferAsDoubleBuffer%L.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.java $(GEN_BUFFER_SH)
$(BUF_GEN)/ByteBufferAsDoubleBuffer%L.java: $(BYTE_X_BUF_TEMPLATE) $(GEN_BUFFER_SH)
$(prep-target)
@$(RM) $@.temp
TYPE=double RW=$* BO=L SRC=$< DST=$@.temp $(GEN_BUFFER_CMD)
@ -745,13 +754,13 @@ GEN_CODER_SH = genCoder.sh
GEN_CODER_CMD = SPP="$(SPP_CMD)" SED="$(SED)" NAWK="$(NAWK)" SH="$(SH)" $(SH) $(GEN_CODER_SH)
$(CS_GEN)/CharsetDecoder.java: $(CS_SRC)/Charset-X-Coder.java $(GEN_CODER_SH)
$(CS_GEN)/CharsetDecoder.java: $(CHARSET_X_CODER_TEMPLATE) $(GEN_CODER_SH)
$(prep-target)
@$(RM) $@.temp
$(GEN_CODER_CMD) decoder $< $@.temp
$(MV) $@.temp $@
$(CS_GEN)/CharsetEncoder.java: $(CS_SRC)/Charset-X-Coder.java $(GEN_CODER_SH)
$(CS_GEN)/CharsetEncoder.java: $(CHARSET_X_CODER_TEMPLATE) $(GEN_CODER_SH)
$(prep-target)
@$(RM) $@.temp
$(GEN_CODER_CMD) encoder $< $@.temp

View File

@ -154,7 +154,7 @@ if [ $BIN ]; then
mv $DST $DST.tmp
sed -e '/#BIN/,$d' <$DST.tmp >$DST
rm -f $DST.tmp
binops=`dirname $SRC`/`basename $SRC .java`-bin.java
binops=`dirname $SRC`/`basename $SRC .java.template`-bin.java.template
genBinOps char character 1 two one $binops >>$DST
genBinOps short short 1 two one $binops >>$DST
genBinOps int integer 2 four three $binops >>$DST

View File

@ -94,11 +94,13 @@ ifeq ($(INCLUDE_SA), true)
endif
endif # INCLUDE_SA
# Hotspot client is only available on 32-bit builds
# Hotspot client is only available on 32-bit non-Zero builds
ifneq ($(ZERO_BUILD), true)
ifeq ($(ARCH_DATA_MODEL), 32)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVM_NAME) \
$(LIB_LOCATION)/$(CLIENT_LOCATION)/Xusage.txt
endif
endif
ifeq ($(PLATFORM), windows)
# Windows vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Windows
@ -171,6 +173,7 @@ ifeq ($(PLATFORM), solaris)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME)
endif
ifneq ($(ZERO_BUILD), true)
ifeq ($(ARCH_DATA_MODEL), 32)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME)
@ -201,6 +204,8 @@ endif # 32bit solaris
endif # 32bit
endif # ZERO_BUILD
# NOT Windows ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NOT Windows
endif # PLATFORM

View File

@ -33,7 +33,7 @@ include $(BUILDDIR)/common/Defs.gmk
all build: $(GENSRCDIR)/sun/misc/Version.java
$(GENSRCDIR)/sun/misc/Version.java: \
$(SHARE_SRC)/classes/sun/misc/Version-template.java
$(SHARE_SRC)/classes/sun/misc/Version.java.template
$(prep-target)
$(RM) $@.temp
$(SED) -e 's/@@launcher_name@@/$(LAUNCHER_NAME)/g' \

View File

@ -128,7 +128,7 @@ endif # PLATFORM solaris
# for dynamic inclusion of extra sound libs: these
# JNI libs will be loaded from Platform.java
CPPFLAGS += -DEXTRA_SOUND_JNI_LIBS="\"$(EXTRA_SOUND_JNI_LIBS)\""
CPPFLAGS += -DEXTRA_SOUND_JNI_LIBS='"$(EXTRA_SOUND_JNI_LIBS)"'
# integrate MIDI i/o in jsound lib
ifeq ($(INCLUDE_MIDI),TRUE)

View File

@ -55,21 +55,25 @@ ifeq ($(PLATFORM), solaris)
endif # PLATFORM solaris
ifeq ($(ARCH), i586)
CPPFLAGS += -DX_ARCH=X_I586
endif # ARCH i586
ifeq ($(ZERO_BUILD), true)
CPPFLAGS += -DX_ARCH=X_ZERO
else
ifeq ($(ARCH), i586)
CPPFLAGS += -DX_ARCH=X_I586
endif # ARCH i586
ifeq ($(ARCH), sparc)
CPPFLAGS += -DX_ARCH=X_SPARC
endif # ARCH sparc
ifeq ($(ARCH), sparc)
CPPFLAGS += -DX_ARCH=X_SPARC
endif # ARCH sparc
ifeq ($(ARCH), sparcv9)
CPPFLAGS += -DX_ARCH=X_SPARCV9
endif # ARCH sparcv9
ifeq ($(ARCH), sparcv9)
CPPFLAGS += -DX_ARCH=X_SPARCV9
endif # ARCH sparcv9
ifeq ($(ARCH), amd64)
CPPFLAGS += -DX_ARCH=X_AMD64
endif # ARCH amd64
ifeq ($(ARCH), amd64)
CPPFLAGS += -DX_ARCH=X_AMD64
endif # ARCH amd64
endif
# files needed for MIDI i/o

View File

@ -339,3 +339,82 @@ fi
PATH="${path4sdk}"
export PATH
# Export variables required for Zero
if [ "${ZERO_BUILD}" = true ] ; then
# ZERO_LIBARCH is the name of the architecture-specific
# subdirectory under $JAVA_HOME/jre/lib
arch=$(uname -m)
case "${arch}" in
x86_64) ZERO_LIBARCH=amd64 ;;
i?86) ZERO_LIBARCH=i386 ;;
sparc64) ZERO_LIBARCH=sparcv9 ;;
arm*) ZERO_LIBARCH=arm ;;
*) ZERO_LIBARCH="$(arch)"
esac
export ZERO_LIBARCH
# ARCH_DATA_MODEL is the number of bits in a pointer
case "${ZERO_LIBARCH}" in
i386|ppc|s390|sparc|arm)
ARCH_DATA_MODEL=32
;;
amd64|ppc64|s390x|sparcv9|ia64|alpha)
ARCH_DATA_MODEL=64
;;
*)
echo "ERROR: Unable to determine ARCH_DATA_MODEL for ${ZERO_LIBARCH}"
exit 1
esac
export ARCH_DATA_MODEL
# ZERO_ENDIANNESS is the endianness of the processor
case "${ZERO_LIBARCH}" in
i386|amd64|ia64)
ZERO_ENDIANNESS=little
;;
ppc*|s390*|sparc*|alpha)
ZERO_ENDIANNESS=big
;;
*)
echo "ERROR: Unable to determine ZERO_ENDIANNESS for ${ZERO_LIBARCH}"
exit 1
esac
export ZERO_ENDIANNESS
# ZERO_ARCHDEF is used to enable architecture-specific code
case "${ZERO_LIBARCH}" in
i386) ZERO_ARCHDEF=IA32 ;;
ppc*) ZERO_ARCHDEF=PPC ;;
s390*) ZERO_ARCHDEF=S390 ;;
sparc*) ZERO_ARCHDEF=SPARC ;;
*) ZERO_ARCHDEF=$(echo "${ZERO_LIBARCH}" | tr a-z A-Z)
esac
export ZERO_ARCHDEF
# ZERO_ARCHFLAG tells the compiler which mode to build for
case "${ZERO_LIBARCH}" in
s390)
ZERO_ARCHFLAG="-m31"
;;
*)
ZERO_ARCHFLAG="-m${ARCH_DATA_MODEL}"
esac
export ZERO_ARCHFLAG
# LIBFFI_CFLAGS and LIBFFI_LIBS tell the compiler how to compile and
# link against libffi
pkgconfig=$(which pkg-config 2>/dev/null)
if [ -x "${pkgconfig}" ] ; then
if [ "${LIBFFI_CFLAGS}" = "" ] ; then
LIBFFI_CFLAGS=$("${pkgconfig}" --cflags libffi)
fi
if [ "${LIBFFI_LIBS}" = "" ] ; then
LIBFFI_LIBS=$("${pkgconfig}" --libs libffi)
fi
fi
if [ "${LIBFFI_LIBS}" = "" ] ; then
LIBFFI_LIBS="-lffi"
fi
export LIBFFI_CFLAGS
export LIBFFI_LIBS
fi

View File

@ -1,5 +1,5 @@
#
# Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved.
# Copyright 2006-2009 Sun Microsystems, Inc. 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
@ -34,8 +34,8 @@ solaris_i586_5.10,\
solaris_x64_5.10,\
linux_i586_2.6,\
linux_x64_2.6,\
windows_i586,\
windows_x64
windows_i586_5.0,\
windows_x64_5.2
# The different build flavors we want
jprt.build.flavors=product,fastdebug
@ -51,21 +51,37 @@ jprt.run.flavor.c2.option=-server
jprt.solaris_sparcv9.build.platform.match32=solaris_sparc_5.10
jprt.solaris_x64.build.platform.match32=solaris_i586_5.10
# Standard list of jprt test targets for this workspace
# Standard test target for everybody
jprt.test.targets=*-*-*-jvm98
jprt.regression.test.targets= \
*-product-*-java/lang, \
*-product-*-java/security, \
*-product-*-java/text, \
*-product-*-java/util
#jprt.regression.test.targets= \
# *-product-*-java/awt, \
# *-product-*-java/beans, \
# *-product-*-java/io, \
# *-product-*-java/net, \
# *-product-*-java/nio, \
# *-product-*-java/rmi, \
# Test targets in test/Makefile (some longer running tests only test c2)
jprt.make.rule.test.targets= \
*-product-*-jdk_beans1, \
*-product-*-jdk_beans2, \
*-product-*-jdk_beans3, \
*-product-*-jdk_io, \
*-product-*-jdk_lang, \
*-product-*-jdk_management1, \
*-product-*-jdk_management2, \
*-product-*-jdk_math, \
*-product-*-jdk_misc, \
*-product-*-jdk_net, \
*-product-*-jdk_nio1, \
*-product-*-jdk_nio2, \
*-product-*-jdk_nio3, \
*-product-*-jdk_security1, \
*-product-*-jdk_security2, \
*-product-*-jdk_security3, \
*-product-*-jdk_text, \
*-product-*-jdk_tools1, \
*-product-*-jdk_tools2, \
*-product-*-jdk_util
# Some of these are crashing Xvfb or windows manager, need dedicated DISPLAY per test batch
jprt2.make.rule.test.targets= \
*-product-*-jdk_awt, \
*-product-*-jdk_rmi, \
*-product-*-jdk_swing, \
# Directories needed to build
jprt.bundle.exclude.src.dirs=build

View File

@ -137,15 +137,15 @@ ifeq ($(PROGRAM),jdb)
# PROGRAM, JAVA_ARGS, and APP_CLASSPATH are used in src/share/bin/java.c
# SA is currently not available on windows (for any ARCH), or linux-ia64:
ifneq ($(ARCH), ia64)
JDB_CLASSPATH = "{ \"/lib/tools.jar\", \"/lib/sa-jdi.jar\", \"/classes\" }"
OTHER_CPPFLAGS += -DAPP_CLASSPATH=$(JDB_CLASSPATH)
JDB_CLASSPATH = { "/lib/tools.jar", "/lib/sa-jdi.jar", "/classes" }
OTHER_CPPFLAGS += -DAPP_CLASSPATH='$(JDB_CLASSPATH)'
endif
endif
# jconsole only
ifeq ($(PROGRAM),jconsole)
JCONSOLE_CLASSPATH = "{ \"/lib/jconsole.jar\", \"/lib/tools.jar\", \"/classes\" }"
OTHER_CPPFLAGS += -DAPP_CLASSPATH=$(JCONSOLE_CLASSPATH)
JCONSOLE_CLASSPATH = { "/lib/jconsole.jar", "/lib/tools.jar", "/classes" }
OTHER_CPPFLAGS += -DAPP_CLASSPATH='$(JCONSOLE_CLASSPATH)'
ifeq ($(PLATFORM), windows)
OTHER_CPPFLAGS += -DJAVAW
LDLIBS_COMMON += user32.lib
@ -163,8 +163,8 @@ endif
# SA tools need special app classpath
ifeq ($(SA_TOOL),true)
SA_CLASSPATH = "{ \"/lib/tools.jar\", \"/lib/sa-jdi.jar\", \"/classes\"}"
OTHER_CPPFLAGS += -DAPP_CLASSPATH=$(SA_CLASSPATH)
SA_CLASSPATH = { "/lib/tools.jar", "/lib/sa-jdi.jar", "/classes" }
OTHER_CPPFLAGS += -DAPP_CLASSPATH='$(SA_CLASSPATH)'
endif
# Wildcards
@ -173,11 +173,11 @@ ifeq ($(WILDCARDS),true)
endif
# Always tell native code what the main class is
OTHER_CPPFLAGS += -DMAIN_CLASS=\"$(MAIN_CLASS)\"
OTHER_CPPFLAGS += -DMAIN_CLASS='"$(MAIN_CLASS)"'
# Construct initializer for initial arguments to java
ALL_ARGS = -J-ms8m $(MAIN_JAVA_ARGS) $(MAIN_CLASS) $(MAIN_ARGS)
JAVA_ARGS = "{ $(ALL_ARGS:%=\"%\",) }"
JAVA_ARGS = { $(ALL_ARGS:%="%",) }
# Always report launcher info
build: launcher_info

View File

@ -33,7 +33,7 @@ includes=\
com/sun/tools/jconsole/ \
sun/tools/jconsole/
excludes=\
sun/tools/jconsole/Version-template.java
sun/tools/jconsole/Version.java.template
jtreg.tests=\
sun/tools/jconsole/
javadoc.packagenames=\

View File

@ -35,7 +35,7 @@
<target name="-pre-compile">
<copy
file="${root}/src/share/classes/sun/tools/jconsole/Version-template.java"
file="${root}/src/share/classes/sun/tools/jconsole/Version.java.template"
tofile="${gensrc.dir}/sun/tools/jconsole/Version.java"/>
<replace
file="${gensrc.dir}/sun/tools/jconsole/Version.java"

View File

@ -53,7 +53,6 @@ SUNWprivate_1.1 {
Java_sun_awt_image_GifImageDecoder_initIDs;
Java_sun_awt_image_GifImageDecoder_parseImage;
Java_sun_awt_image_ImageRepresentation_initIDs;
Java_sun_awt_image_ImageRepresentation_setBytePixels;
Java_sun_awt_image_ImageRepresentation_setDiffICM;
Java_sun_awt_image_ImageRepresentation_setICMpixels;
Java_sun_awt_image_ImagingLib_convolveBI;

View File

@ -55,7 +55,6 @@ SUNWprivate_1.1 {
Java_sun_awt_image_GifImageDecoder_parseImage;
Java_sun_awt_image_Image_initIDs;
Java_sun_awt_image_ImageRepresentation_initIDs;
Java_sun_awt_image_ImageRepresentation_setBytePixels;
Java_sun_awt_image_ImageRepresentation_setDiffICM;
Java_sun_awt_image_ImageRepresentation_setICMpixels;
Java_sun_awt_image_ImagingLib_convolveBI;

View File

@ -70,7 +70,7 @@ include $(BUILDDIR)/common/Classes.gmk
build: $(FILES_png) $(FILES_gif) $(TEMPDIR)/manifest $(JARFILE)
$(GENSRCDIR)/sun/tools/jconsole/Version.java: \
$(SHARE_SRC)/classes/sun/tools/jconsole/Version-template.java
$(SHARE_SRC)/classes/sun/tools/jconsole/Version.java.template
$(MKDIR) -p $(@D)
$(SED) -e 's/@@jconsole_version@@/$(FULL_VERSION)/g' $< > $@

View File

@ -44,14 +44,6 @@ include $(BUILDDIR)/common/Defs.gmk
include FILES_java.gmk
AUTO_FILES_JAVA_DIRS = sun/nio/cs/ext
# Exclude a few sources on windows
ifeq ($(PLATFORM), windows)
AUTO_JAVA_PRUNE = sun/nio/cs/ext/COMPOUND_TEXT.java \
sun/nio/cs/ext/COMPOUND_TEXT_Decoder.java \
sun/nio/cs/ext/COMPOUND_TEXT_Encoder.java \
sun/nio/cs/ext/CompoundTextSupport.java
endif # PLATFORM
# For Cygwin, command line arguments that are paths must be converted to
# windows style paths. These paths cannot be used as targets, however, because
# the ":" in them will interfere with GNU Make rules, generating "multiple

View File

@ -38,7 +38,6 @@ SUBDIRS = \
compile_properties \
dir_diff \
dtdbuilder \
fontchecker \
freetypecheck \
generate_break_iterator \
GenerateCharacter \

View File

@ -1,175 +0,0 @@
/*
* Copyright 2002-2004 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package build.tools.fontchecker;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
/**
* FontCheckDummy (not unlike Crash Test Dummy).
*
* <PRE>
* FontCheckDummy is the "child" process. Its task is to verify
* integrity of system fonts. Since unexpected crashes are known
* to occur when certain fonts are manipulated, the process is
* "monitored" by the parent process, which might have to restart
* the "child" if it crashes.
* </PRE>
*
* @author Ilya Bagrak
*/
public class FontCheckDummy implements FontCheckerConstants {
/**
* Input stream from parent process.
*/
private BufferedReader is;
/**
* Output stream to parent process.
*/
private BufferedOutputStream os;
/**
* Image on which font characters will be drawn.
*/
private BufferedImage bi;
/**
* graphics object on which characters will be drawn.
*/
private Graphics graphics;
/**
* This constructor wraps the process's standard output and input streams
* to enable easier communication with parent process. It also initializes
* the graphics object used for drawing font characters.
* <BR><BR>
* @see FontCheckerConstants
*/
public FontCheckDummy() {
is = new BufferedReader(new InputStreamReader(System.in));
os = new BufferedOutputStream(System.out);
/* make suffficient space for 12 point font */
bi = new BufferedImage(40, 40, BufferedImage.TYPE_INT_RGB);
graphics = bi.getGraphics();
try {
os.write(CHILD_STARTED_OK);
os.flush();
} catch (IOException e) {
System.exit(-1);
}
}
/**
* Initializes an instance of Font from given font path.
* <BR>
* This methods attempts to create an instance of font from
* a string that represents path to the font file.
* <BR><BR>
* @param fontPath string representing path to font file
* @param flag indicating whether or not checking of non-TrueType fonts
* is necessary
*/
private void testFont(String fontPath, boolean checkNonTTF) {
FontFileFilter fff = new FontFileFilter(checkNonTTF);
File fontFile = new File(fontPath);
if (!fontFile.canRead()) {
try {
os.write(ERR_FONT_NOT_FOUND);
os.flush();
} catch (IOException e) {
System.exit(-1);
}
}
Font font = null;
try {
File file = new File(fontPath);
font = Font.createFont(fff.getFontType(fontPath), file);
} catch (FontFormatException e1) {
} catch (IOException e2) {
}
if (font == null) {
return;
}
font = font.deriveFont(Font.PLAIN, 12);
String name = font.getFontName();
String family = font.getFamily();
char[] testChars = { '0' };
if (font.canDisplay(testChars[0])) {
graphics.setFont(font);
graphics.drawChars(testChars, 0, 1, 20, 20);
}
try {
os.write(ERR_FONT_OK);
os.flush();
} catch (IOException e) {
System.exit(-1);
}
}
/**
* Begins synchronous communication betweeen parent and child processes.
* <BR>
* This method begins communication between parent and child processes.
* FontCheckDummy reads a line of text from input stream (@see #is).
*/
public void run() {
String command = null;
while (true) {
try {
command = is.readLine();
} catch (IOException e) {
System.exit(-1);
}
if (command != null && command.length() >= 1) {
int cmd = Integer.parseInt(command.substring(0,1));
if (cmd == EXITCOMMAND) {
return;
}
boolean checkNonTTF = ((cmd == 1) ? true : false);
String fontPath = command.substring(1);
testFont(fontPath, checkNonTTF);
} else {
return;
}
}
}
public static void main(String[] args) {
try {
/* Background app. */
System.setProperty("java.awt.headless", "true");
System.setProperty("sun.java2d.noddraw", "true");
new FontCheckDummy().run();
} catch (Throwable t) {
}
System.exit(0);
}
}

View File

@ -1,452 +0,0 @@
/*
* Copyright 2002-2004 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package build.tools.fontchecker;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import sun.font.FontManager;
/**
* FontChecker.
*
* <PRE>
* This is a FontChecker program. This class is a "parent" process
* which invokes a "child" process. The child process will test
* series of fonts and may crash as it encounters invalid fonts.
* The "parent" process must then interpret error codes passed to it
* by the "child" process and restart the "child" process if necessary.
*
* usage: java FontChecker [-v] -o outputfile
*
* -o is the name of the file to contains canonical path names of
* bad fonts that are identified. This file is not created if
* no bad fonts are found.
* -v verbose: prints progress messages.
*
* </PRE>
*
* @author Ilya Bagrak
*/
public class FontChecker implements ActionListener, FontCheckerConstants {
/**
* Output stream to subprocess.
* Corresponds to the subprocess's System.in".
*/
private PrintWriter procPipeOut;
/**
* Input stream from subprocess.
* Corresponds to the subprocess's System.out".
*/
private BufferedInputStream procPipeIn;
/**
* Child process.
*/
private Process childProc;
/**
* Name of output file to write file names of bad fonts
*/
private String outputFile;
/**
* Reference to currently executing thread.
*/
private Thread currThread;
/**
* Timeout timer for a single font check
*/
private javax.swing.Timer timeOne;
/**
* Timeout timer for all font checks
*/
private javax.swing.Timer timeAll;
/**
* max time (in milliseconds) allowed for checking a single font.
*/
private static int timeoutOne = 10000;
/**
* max time (in milliseconds) allowed for checking all fonts.
*/
private static int timeoutAll = 120000;
/**
* Boolean flag indicating whether FontChecker is required to
* check non-TrueType fonts.
*/
private boolean checkNonTTF = false;
/**
* List of bad fonts found in the system.
*/
private Vector badFonts = new Vector();
/**
* whether to print warnings messges etc to stdout/err
* default is false
*/
private static boolean verbose = false;
/* Command to use to exec sub-process. */
private static String javaCmd = "java";
static void printlnMessage(String s) {
if (verbose) {
System.out.println(s);
}
}
/**
* Event handler for timer event.
* <BR>
* Stops the timer and interrupts the current thread which is
* still waiting on I/O from the child process.
* <BR><BR>
* @param evt timer event
*/
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() == timeOne) {
timeOne.stop();
printlnMessage("Child timed out: killing");
childProc.destroy();
} else {
doExit(); // went on too long (ie timeAll timed out).
}
}
/**
* Initializes a FontChecker.
* <BR>
* This method is usually called after an unrecoverable error has
* been detected and a child process has either crashed or is in bad
* state. The method creates a new child process from
* scratch and initializes it's input/output streams.
*/
public void initialize() {
try {
if (childProc != null) {
childProc.destroy();
}
String fileSeparator = System.getProperty("file.separator");
String javaHome = System.getProperty("java.home");
String classPath = System.getProperty("java.class.path");
classPath = "\"" + classPath + "\"";
String opt = "-cp " + classPath + " -Dsun.java2d.fontpath=\"" +
javaHome + fileSeparator + "lib" + fileSeparator + "fonts\"";
/* command to exec the child process with the same JRE */
String cmd =
new String(javaHome + fileSeparator + "bin" +
fileSeparator + javaCmd +
" -XXsuppressExitMessage " + opt +
" com.sun.java2d.fontchecker.FontCheckDummy");
printlnMessage("cmd="+cmd);
childProc = Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
printlnMessage("can't execute child process");
System.exit(0);
} catch (SecurityException e) {
printlnMessage("Error: access denied");
System.exit(0);
}
/* initialize input/output streams to/from child process */
procPipeOut = new PrintWriter(childProc.getOutputStream());
procPipeIn = new BufferedInputStream(childProc.getInputStream());
try {
int code = procPipeIn.read();
if (code != CHILD_STARTED_OK) {
printlnMessage("bad child process start status="+code);
doExit();
}
} catch (IOException e) {
printlnMessage("can't read child process start status unknown");
doExit();
}
}
private void doExit() {
try {
if (procPipeOut != null) {
/* Tell the child to exit */
procPipeOut.write(EXITCOMMAND+System.getProperty("line.separator"));
procPipeOut.flush();
procPipeOut.close();
}
} catch (Throwable t) {
}
System.exit(0);
}
/**
* Tries to verify integrity of a font specified by a path.
* <BR>
* This method is used to test whether a font specified by the given
* path is valid and does not crash the system.
* <BR><BR>
* @param fontPath a string representation of font path
* to standard out during while this font is tried
* @return returns <code>true</code> if font is OK, and
* <code>false</code> otherwise.
*/
public boolean tryFont(File fontFile) {
int bytesRead = 0;
String fontPath = fontFile.getAbsolutePath();
printlnMessage("Checking font "+fontPath);
/* store reference to the current thread, so that when the timer
* fires it can be interrupted
*/
currThread = Thread.currentThread();
timeOne.restart();
/* write a string command out to child process
* The command is formed by appending whether to test non-TT fonts
* and font path to be tested
*/
String command = Integer.toString(checkNonTTF ? 1 : 0) +
fontPath +
System.getProperty("line.separator");
procPipeOut.write(command);
procPipeOut.flush();
/* check if underlying stream has encountered an error after
* command has been issued
*/
if (procPipeOut.checkError()){
printlnMessage("Error: font crashed");
initialize();
return false;
}
/* trying reading error code back from child process */
try {
bytesRead = procPipeIn.read();
} catch(InterruptedIOException e) {
/* A timeout timer fired before the operation completed */
printlnMessage("Error: timeout occured");
initialize();
return false;
} catch(IOException e) {
/* there was an error reading from the stream */
timeOne.stop();
printlnMessage("Error: font crashed");
initialize();
return false;
} catch (Throwable t) {
bytesRead = ERR_FONT_READ_EXCPT;
} finally {
timeOne.stop();
}
if (bytesRead == ERR_FONT_OK) {
printlnMessage("Font integrity verified");
return true;
} else if (bytesRead > 0) {
switch(bytesRead){
case ERR_FONT_NOT_FOUND:
printlnMessage("Error: font not found!");
break;
case ERR_FONT_BAD_FORMAT:
printlnMessage("Error: incorrect font format");
break;
case ERR_FONT_READ_EXCPT:
printlnMessage("Error: exception reading font");
break;
case ERR_FONT_DISPLAY:
printlnMessage("Error: can't display characters");
break;
case ERR_FONT_CRASH:
printlnMessage("Error: font crashed");
break;
default:
printlnMessage("Error: invalid error code:"+bytesRead);
break;
}
} else if (bytesRead == ERR_FONT_EOS) {
printlnMessage("Error: end of stream marker encountered");
} else {
printlnMessage("Error: invalid error code:"+bytesRead);
}
/* if we still haven't returned from this method, some error
* condition has occured and it is safer to re-initialize
*/
initialize();
return false;
}
/**
* Checks the integrity of all system fonts.
* <BR>
* This method goes through every font in system's font path and verifies
* its integrity via the tryFont method.
* <BR><BR>
* @param restart <code>true</code> if checking of fonts should continue
* after the first bad font is found, and <code>false</code> otherwise
* @return returns <code>true</code> if all fonts are valid,
* <code>false</code> otherwise
* @see #tryFont(String, boolean, boolean)
*/
public boolean checkFonts(boolean restart) {
/* file filter to filter out none-truetype font files */
FontFileFilter fff = new FontFileFilter(checkNonTTF);
boolean checkOk = true;
/* get platform-independent font path. Note that this bypasses
* the normal GraphicsEnvironment initialisation. In conjunction with
* the headless setting above, so we want to add
* java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
* to trigger a more normal initialisation.
*/
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
String fontPath = FontManager.getFontPath(true);
StringTokenizer st =
new StringTokenizer(fontPath,
System.getProperty("path.separator"));
/* some systems may have multiple font paths separated by
* platform-dependent characters, so fontPath string needs to be
* parsed
*/
timeOne = new javax.swing.Timer(timeoutOne, this);
timeAll = new javax.swing.Timer(timeoutAll, this);
timeAll.restart();
while (st.hasMoreTokens()) {
File fontRoot = new File(st.nextToken());
File[] fontFiles = fontRoot.listFiles(fff);
for (int i = 0; i < fontFiles.length; i++) {
/* for each font file that is not a directory and passes
* through the font filter run the test
*/
if (!fontFiles[i].isDirectory() &&
!tryFont(fontFiles[i])) {
checkOk = false;
badFonts.add(fontFiles[i].getAbsolutePath());
if (!restart) {
break;
}
}
}
}
/* Tell the child to exit */
procPipeOut.write(EXITCOMMAND+System.getProperty("line.separator"));
procPipeOut.flush();
procPipeOut.close();
return checkOk;
}
public static void main(String args[]){
try {
/* Background app. */
System.setProperty("java.awt.headless", "true");
System.setProperty("sun.java2d.noddraw", "true");
boolean restart = true;
boolean errorFlag = false;
FontChecker fc = new FontChecker();
int arg = 0;
while (arg < args.length && errorFlag == false) {
if (args[arg].equals("-v")) {
verbose = true;
}
else if (args[arg].equals("-w") &&
System.getProperty("os.name", "unknown").
startsWith("Windows")) {
javaCmd = "javaw";
}
else if (args[arg].equals("-o")) {
/* set output file */
if (++arg < args.length)
fc.outputFile = args[arg];
else {
/* invalid argument format */
printlnMessage("Error: invalid argument format");
errorFlag = true;
}
}
else {
/* invalid command line argument */
printlnMessage("Error: invalid argument value");
errorFlag = true;
}
arg++;
}
if (errorFlag || fc.outputFile == null) {
System.exit(0);
}
File outfile = new File(fc.outputFile);
if (outfile.exists()) {
outfile.delete();
}
fc.initialize();
if (!fc.checkFonts(restart)) {
String[] badFonts = (String[])fc.badFonts.toArray(new String[0]);
if (badFonts.length > 0) {
printlnMessage("Bad Fonts:");
try {
FileOutputStream fos =
new FileOutputStream(fc.outputFile);
PrintStream ps = new PrintStream(fos);
for (int i = 0; i < badFonts.length; i++) {
ps.println(badFonts[i]);
printlnMessage(badFonts[i]);
}
fos.close();
} catch (IOException e) {
}
}
} else {
printlnMessage("No bad fonts found.");
}
} catch (Throwable t) {
}
System.exit(0);
}
}

View File

@ -1,45 +0,0 @@
/*
* Copyright 2002-2004 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package build.tools.fontchecker;
public interface FontCheckerConstants {
/* code sent to indicate child process started OK */
public static final int CHILD_STARTED_OK = 100;
/* error codes returned from child process */
public static final int ERR_FONT_OK = 65;
public static final int ERR_FONT_NOT_FOUND = 60;
public static final int ERR_FONT_BAD_FORMAT = 61;
public static final int ERR_FONT_READ_EXCPT = 62;
public static final int ERR_FONT_DISPLAY = 64;
public static final int ERR_FONT_EOS = -1;
/* nl char sent after child crashes */
public static final int ERR_FONT_CRASH = 10;
/* 0 and 1 are reserved, and commands can only be a single digit integer */
public static final int EXITCOMMAND = 2;
}

View File

@ -1,97 +0,0 @@
/*
* Copyright 2002-2003 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* <PRE>
* This class filters TrueType font files from other file
* found in the font path.
*
* </PRE>
*
* @author Ilya Bagrak
*/
package build.tools.fontchecker;
import java.awt.*;
import java.io.*;
public class FontFileFilter implements java.io.FileFilter, FontCheckerConstants {
/**
* Boolean flag indicating whether this filter filters out
* non-TrueType fonts.
*/
private boolean checkNonTTF;
public FontFileFilter() {
this(false);
}
public FontFileFilter(boolean checkNonTTF) {
super();
this.checkNonTTF = checkNonTTF;
}
/**
* Checks whether a file is accepted by this filter.
* <BR>
* This method checks whehter a file is accepted by this filter.
* This filter is made to accept all the file whose extension is
* either .ttf or .TTF. These files are assumed to be TrueType fonts.
* <BR><BR>
* @return returns a boolean value indicating whether or not a file is
* accepted
*/
public boolean accept(File pathname) {
String name = pathname.getName();
return (name.endsWith(".ttf") ||
name.endsWith(".TTF") ||
name.endsWith(".ttc") ||
name.endsWith(".TTC")) ||
(name.endsWith(".pfb") ||
name.endsWith(".PFB") ||
name.endsWith(".pfa") ||
name.endsWith(".PFA") &&
checkNonTTF == true);
}
public static int getFontType(String filename) {
if (filename.endsWith(".ttf") ||
filename.endsWith(".TTF") ||
filename.endsWith(".ttc") ||
filename.endsWith(".TTC"))
return Font.TRUETYPE_FONT;
else if (filename.endsWith(".pfb") ||
filename.endsWith(".PFB") ||
filename.endsWith(".pfa") ||
filename.endsWith(".PFA"))
return Font.TYPE1_FONT;
else
return 999;
}
}

View File

@ -1,91 +0,0 @@
/*
* Copyright 2002-2003 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
Instructions for running FontChecker
------------------------------------
FontChecker is a program designed to identify fonts that may cause JRE
crashes. Such fonts may be corrupted files, or badly constructed fonts.
Some crashes may also be due to bugs in the JRE's font code.
This test is designed to run quickly and silently as part of the JRE
installation process. It will only benefit users who install the JRE
via that mechanism. It cannot guarantee to identify all "bad fonts" because
the tests are minimal. Nor can it prevent problems due to fonts installed
subsequently to the JRE's installation. However it does ensure that the
vast majority of problem fonts are identified. This is important
"RAS" functionality. It is targeted at the consumer/plugin market where
there is substantial likelihood of end-users having installed software
packages which may be delivered with fonts that are not up to commercial
standards.
The test is designed to be "fail safe". If the program fails to run
properly it has no impact on the installer or on JRE execution.
Thus there is no need to monitor successful execution of the test.
The test is not a new "tool" in the sense of "javah" etc.
The test is not designed to be user executable or visible, and should
be unpacked by the installer into a temporary location, and executed
once the rest of the JRE is installed (ie as a postinstall step), and
can then be deleted from the temporary location once installation is
complete. Not deleting the jar file before execution is complete is
probably the sole reason that the installer may want to wait for
the program to complete.
The FontChecker application can be run directly from the jar
file with this command:
%java -jar fontchecker.jar -o <file>
The output file is a required parameter in this version of the application.
The JRE installer should use the above form, and use it to create an
output file which must be named "badfonts.txt" and be placed into
the JRE's lib\fonts directory eg:-
java -jar fontchecker.jar -o "C:\Program Files\jre\lib\fonts\badfonts.txt"
Note the lower case "badfonts.txt", and the string quotes because of the spaces
in the path name.
The location given here is an example and needs to be calculated at install
time as $JREHOME\lib\fonts\badfonts.txt
The location and name are important, because the JRE at runtime will
look for this exactly located name and file.
This location is private to that JRE instance. It will not affect
any other JRE installed on the system.
If running from a different directory than that containing the jar file,
use the form containing the full path to the jar file, eg :
java -jar C:\fc\fontchecker.jar -o "C:\Program Files\jre\lib\fonts\badfonts.txt"
FontChecker application accepts following command line flags.
usage: java -jar fontchecker.jar -o outputfile
-v
-o is the name of the file to contains canonical path names of
bad fonts that are identified. This file is not created if
no bad fonts are found.
-v verbose mode: print progress/warning messages. Not recommended
for installer use.
-w if running on Windows, use "javaw" to exec the sub-process.

View File

@ -62,6 +62,8 @@ import javax.imageio.event.IIOReadWarningListener;
import java.io.*;
import java.nio.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
@ -502,12 +504,18 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
iis.reset();
try {
if (metadata.colorSpace == PROFILE_LINKED)
if (metadata.colorSpace == PROFILE_LINKED &&
isLinkedProfileAllowed() &&
!isUncOrDevicePath(profile))
{
String path = new String(profile, "windows-1252");
colorSpace =
new ICC_ColorSpace(ICC_Profile.getInstance(new String(profile)));
else
new ICC_ColorSpace(ICC_Profile.getInstance(path));
} else {
colorSpace =
new ICC_ColorSpace(ICC_Profile.getInstance(profile));
}
} catch (Exception e) {
colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
}
@ -1745,4 +1753,69 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
public void sequenceStarted(ImageReader src, int minIndex) {}
public void readAborted(ImageReader src) {}
}
private static Boolean isLinkedProfileDisabled = null;
private static boolean isLinkedProfileAllowed() {
if (isLinkedProfileDisabled == null) {
PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() {
public Boolean run() {
return Boolean.getBoolean("sun.imageio.plugins.bmp.disableLinkedProfiles");
}
};
isLinkedProfileDisabled = AccessController.doPrivileged(a);
}
return !isLinkedProfileDisabled;
}
private static Boolean isWindowsPlatform = null;
/**
* Verifies whether the byte array contans a unc path.
* Non-UNC path examples:
* c:\path\to\file - simple notation
* \\?\c:\path\to\file - long notation
*
* UNC path examples:
* \\server\share - a UNC path in simple notation
* \\?\UNC\server\share - a UNC path in long notation
* \\.\some\device - a path to device.
*/
private static boolean isUncOrDevicePath(byte[] p) {
if (isWindowsPlatform == null) {
PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() {
public Boolean run() {
String osname = System.getProperty("os.name");
return (osname != null &&
osname.toLowerCase().startsWith("win"));
}
};
isWindowsPlatform = AccessController.doPrivileged(a);
}
if (!isWindowsPlatform) {
/* no need for the check on platforms except windows */
return false;
}
/* normalize prefix of the path */
if (p[0] == '/') p[0] = '\\';
if (p[1] == '/') p[1] = '\\';
if (p[3] == '/') p[3] = '\\';
if ((p[0] == '\\') && (p[1] == '\\')) {
if ((p[2] == '?') && (p[3] == '\\')) {
// long path: whether unc or local
return ((p[4] == 'U' || p[4] == 'u') &&
(p[5] == 'N' || p[5] == 'n') &&
(p[6] == 'C' || p[6] == 'c'));
} else {
// device path or short unc notation
return true;
}
} else {
return false;
}
}
}

View File

@ -25,6 +25,8 @@
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
@ -46,16 +48,23 @@ import javax.swing.plaf.*;
*/
public class MotifButtonUI extends BasicButtonUI {
private final static MotifButtonUI motifButtonUI = new MotifButtonUI();
protected Color selectColor;
private boolean defaults_initialized = false;
private static final Object MOTIF_BUTTON_UI_KEY = new Object();
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c){
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifButtonUI motifButtonUI =
(MotifButtonUI) appContext.get(MOTIF_BUTTON_UI_KEY);
if (motifButtonUI == null) {
motifButtonUI = new MotifButtonUI();
appContext.put(MOTIF_BUTTON_UI_KEY, motifButtonUI);
}
return motifButtonUI;
}

View File

@ -25,6 +25,8 @@
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.plaf.*;
@ -45,7 +47,7 @@ import java.awt.*;
*/
public class MotifCheckBoxUI extends MotifRadioButtonUI {
private static final MotifCheckBoxUI motifCheckBoxUI = new MotifCheckBoxUI();
private static final Object MOTIF_CHECK_BOX_UI_KEY = new Object();
private final static String propertyPrefix = "CheckBox" + ".";
@ -55,7 +57,14 @@ public class MotifCheckBoxUI extends MotifRadioButtonUI {
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c){
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifCheckBoxUI motifCheckBoxUI =
(MotifCheckBoxUI) appContext.get(MOTIF_CHECK_BOX_UI_KEY);
if (motifCheckBoxUI == null) {
motifCheckBoxUI = new MotifCheckBoxUI();
appContext.put(MOTIF_CHECK_BOX_UI_KEY, motifCheckBoxUI);
}
return motifCheckBoxUI;
}

View File

@ -25,6 +25,8 @@
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.plaf.basic.BasicLabelUI;
import javax.swing.plaf.ComponentUI;
@ -44,9 +46,16 @@ import javax.swing.plaf.ComponentUI;
*/
public class MotifLabelUI extends BasicLabelUI
{
static MotifLabelUI sharedInstance = new MotifLabelUI();
private static final Object MOTIF_LABEL_UI_KEY = new Object();
public static ComponentUI createUI(JComponent c) {
return sharedInstance;
AppContext appContext = AppContext.getAppContext();
MotifLabelUI motifLabelUI =
(MotifLabelUI) appContext.get(MOTIF_LABEL_UI_KEY);
if (motifLabelUI == null) {
motifLabelUI = new MotifLabelUI();
appContext.put(MOTIF_LABEL_UI_KEY, motifLabelUI);
}
return motifLabelUI;
}
}

View File

@ -25,6 +25,8 @@
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.BasicRadioButtonUI;
@ -47,7 +49,7 @@ import java.awt.*;
*/
public class MotifRadioButtonUI extends BasicRadioButtonUI {
private static final MotifRadioButtonUI motifRadioButtonUI = new MotifRadioButtonUI();
private static final Object MOTIF_RADIO_BUTTON_UI_KEY = new Object();
protected Color focusColor;
@ -57,6 +59,13 @@ public class MotifRadioButtonUI extends BasicRadioButtonUI {
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MotifRadioButtonUI motifRadioButtonUI =
(MotifRadioButtonUI) appContext.get(MOTIF_RADIO_BUTTON_UI_KEY);
if (motifRadioButtonUI == null) {
motifRadioButtonUI = new MotifRadioButtonUI();
appContext.put(MOTIF_RADIO_BUTTON_UI_KEY, motifRadioButtonUI);
}
return motifRadioButtonUI;
}

View File

@ -25,6 +25,8 @@
package com.sun.java.swing.plaf.motif;
import sun.awt.AppContext;
import java.awt.*;
import java.awt.event.*;
@ -48,7 +50,7 @@ import javax.swing.plaf.basic.*;
*/
public class MotifToggleButtonUI extends BasicToggleButtonUI
{
private final static MotifToggleButtonUI motifToggleButtonUI = new MotifToggleButtonUI();
private static final Object MOTIF_TOGGLE_BUTTON_UI_KEY = new Object();
protected Color selectColor;
@ -58,6 +60,13 @@ public class MotifToggleButtonUI extends BasicToggleButtonUI
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
MotifToggleButtonUI motifToggleButtonUI =
(MotifToggleButtonUI) appContext.get(MOTIF_TOGGLE_BUTTON_UI_KEY);
if (motifToggleButtonUI == null) {
motifToggleButtonUI = new MotifToggleButtonUI();
appContext.put(MOTIF_TOGGLE_BUTTON_UI_KEY, motifToggleButtonUI);
}
return motifToggleButtonUI;
}

View File

@ -35,6 +35,7 @@ import java.awt.*;
import static com.sun.java.swing.plaf.windows.TMSchema.*;
import static com.sun.java.swing.plaf.windows.TMSchema.Part.*;
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
import sun.awt.AppContext;
/**
@ -52,8 +53,6 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
*/
public class WindowsButtonUI extends BasicButtonUI
{
private final static WindowsButtonUI windowsButtonUI = new WindowsButtonUI();
protected int dashedRectGapX;
protected int dashedRectGapY;
protected int dashedRectGapWidth;
@ -63,11 +62,19 @@ public class WindowsButtonUI extends BasicButtonUI
private boolean defaults_initialized = false;
private static final Object WINDOWS_BUTTON_UI_KEY = new Object();
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c){
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
WindowsButtonUI windowsButtonUI =
(WindowsButtonUI) appContext.get(WINDOWS_BUTTON_UI_KEY);
if (windowsButtonUI == null) {
windowsButtonUI = new WindowsButtonUI();
appContext.put(WINDOWS_BUTTON_UI_KEY, windowsButtonUI);
}
return windowsButtonUI;
}
@ -151,7 +158,7 @@ public class WindowsButtonUI extends BasicButtonUI
* allocating them in each paint call substantially reduced the time
* it took paint to run. Obviously, this method can't be re-entered.
*/
private static Rectangle viewRect = new Rectangle();
private Rectangle viewRect = new Rectangle();
public void paint(Graphics g, JComponent c) {
if (XPStyle.getXP() != null) {

View File

@ -25,6 +25,8 @@
package com.sun.java.swing.plaf.windows;
import sun.awt.AppContext;
import javax.swing.plaf.basic.*;
import javax.swing.*;
import javax.swing.plaf.*;
@ -49,7 +51,7 @@ public class WindowsCheckBoxUI extends WindowsRadioButtonUI
// of BasicCheckBoxUI because we want to pick up all the
// painting changes made in MetalRadioButtonUI.
private static final WindowsCheckBoxUI windowsCheckBoxUI = new WindowsCheckBoxUI();
private static final Object WINDOWS_CHECK_BOX_UI_KEY = new Object();
private final static String propertyPrefix = "CheckBox" + ".";
@ -59,6 +61,13 @@ public class WindowsCheckBoxUI extends WindowsRadioButtonUI
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
WindowsCheckBoxUI windowsCheckBoxUI =
(WindowsCheckBoxUI) appContext.get(WINDOWS_CHECK_BOX_UI_KEY);
if (windowsCheckBoxUI == null) {
windowsCheckBoxUI = new WindowsCheckBoxUI();
appContext.put(WINDOWS_CHECK_BOX_UI_KEY, windowsCheckBoxUI);
}
return windowsCheckBoxUI;
}

View File

@ -26,6 +26,8 @@
package com.sun.java.swing.plaf.windows;
import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
import java.awt.Color;
import java.awt.Graphics;
@ -51,12 +53,19 @@ import javax.swing.plaf.basic.BasicLabelUI;
*/
public class WindowsLabelUI extends BasicLabelUI {
private final static WindowsLabelUI windowsLabelUI = new WindowsLabelUI();
private static final Object WINDOWS_LABEL_UI_KEY = new Object();
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c){
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
WindowsLabelUI windowsLabelUI =
(WindowsLabelUI) appContext.get(WINDOWS_LABEL_UI_KEY);
if (windowsLabelUI == null) {
windowsLabelUI = new WindowsLabelUI();
appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI);
}
return windowsLabelUI;
}

View File

@ -25,6 +25,8 @@
package com.sun.java.swing.plaf.windows;
import sun.awt.AppContext;
import javax.swing.plaf.basic.*;
import javax.swing.*;
import javax.swing.plaf.*;
@ -44,7 +46,7 @@ import java.awt.*;
*/
public class WindowsRadioButtonUI extends BasicRadioButtonUI
{
private static final WindowsRadioButtonUI windowsRadioButtonUI = new WindowsRadioButtonUI();
private static final Object WINDOWS_RADIO_BUTTON_UI_KEY = new Object();
protected int dashedRectGapX;
protected int dashedRectGapY;
@ -59,6 +61,13 @@ public class WindowsRadioButtonUI extends BasicRadioButtonUI
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
WindowsRadioButtonUI windowsRadioButtonUI =
(WindowsRadioButtonUI) appContext.get(WINDOWS_RADIO_BUTTON_UI_KEY);
if (windowsRadioButtonUI == null) {
windowsRadioButtonUI = new WindowsRadioButtonUI();
appContext.put(WINDOWS_RADIO_BUTTON_UI_KEY, windowsRadioButtonUI);
}
return windowsRadioButtonUI;
}

View File

@ -25,6 +25,8 @@
package com.sun.java.swing.plaf.windows;
import sun.awt.AppContext;
import javax.swing.plaf.basic.*;
import javax.swing.border.*;
import javax.swing.plaf.*;
@ -49,18 +51,25 @@ import java.beans.PropertyChangeEvent;
*/
public class WindowsToggleButtonUI extends BasicToggleButtonUI
{
protected static int dashedRectGapX;
protected static int dashedRectGapY;
protected static int dashedRectGapWidth;
protected static int dashedRectGapHeight;
protected int dashedRectGapX;
protected int dashedRectGapY;
protected int dashedRectGapWidth;
protected int dashedRectGapHeight;
protected Color focusColor;
private final static WindowsToggleButtonUI windowsToggleButtonUI = new WindowsToggleButtonUI();
private static final Object WINDOWS_TOGGLE_BUTTON_UI_KEY = new Object();
private boolean defaults_initialized = false;
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
WindowsToggleButtonUI windowsToggleButtonUI =
(WindowsToggleButtonUI) appContext.get(WINDOWS_TOGGLE_BUTTON_UI_KEY);
if (windowsToggleButtonUI == null) {
windowsToggleButtonUI = new WindowsToggleButtonUI();
appContext.put(WINDOWS_TOGGLE_BUTTON_UI_KEY, windowsToggleButtonUI);
}
return windowsToggleButtonUI;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1999-2009 Sun Microsystems, Inc. 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
@ -32,12 +32,8 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
import java.net.Socket;
import java.util.Vector;
import java.util.Hashtable;
import javax.naming.CommunicationException;
import javax.naming.AuthenticationException;
import javax.naming.AuthenticationNotSupportedException;
import javax.naming.ServiceUnavailableException;
import javax.naming.NamingException;
import javax.naming.InterruptedNamingException;
@ -47,6 +43,8 @@ import javax.naming.ldap.Control;
import java.lang.reflect.Method;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import sun.misc.IOUtils;
//import javax.net.SocketFactory;
/**
@ -799,7 +797,6 @@ public final class Connection implements Runnable {
byte inbuf[]; // Buffer for reading incoming bytes
int inMsgId; // Message id of incoming response
int bytesread; // Number of bytes in inbuf
int bytesleft; // Number of bytes that need to read for completing resp
int br; // Temp; number of bytes read from stream
int offset; // Offset of where to store bytes in inbuf
int seqlen; // Length of ASN sequence
@ -811,7 +808,7 @@ public final class Connection implements Runnable {
try {
while (true) {
try {
inbuf = new byte[2048];
inbuf = new byte[10];
offset = 0;
seqlen = 0;
@ -871,19 +868,10 @@ public final class Connection implements Runnable {
}
// read in seqlen bytes
bytesleft = seqlen;
if ((offset + bytesleft) > inbuf.length) {
byte nbuf[] = new byte[offset + bytesleft];
System.arraycopy(inbuf, 0, nbuf, 0, offset);
inbuf = nbuf;
}
while (bytesleft > 0) {
bytesread = in.read(inbuf, offset, bytesleft);
if (bytesread < 0)
break; // EOF
offset += bytesread;
bytesleft -= bytesread;
}
byte[] left = IOUtils.readFully(in, seqlen, false);
inbuf = Arrays.copyOf(inbuf, offset + left.length);
System.arraycopy(left, 0, inbuf, offset, left.length);
offset += left.length;
/*
if (dump > 0) {
System.err.println("seqlen: " + seqlen);

View File

@ -53,7 +53,8 @@ import java.util.Set;
import java.util.StringTokenizer;
import java.util.WeakHashMap;
import sun.util.logging.PlatformLogger;
import java.util.logging.Level;
import java.util.logging.Logger;
import sun.awt.AppContext;
import sun.awt.HeadlessToolkit;
@ -110,7 +111,7 @@ public abstract class KeyboardFocusManager
{
// Shared focus engine logger
private static final PlatformLogger focusLog = PlatformLogger.getLogger("java.awt.focus.KeyboardFocusManager");
private static final Logger focusLog = Logger.getLogger("java.awt.focus.KeyboardFocusManager");
static {
/* ensure that the necessary native libraries are loaded */
@ -153,7 +154,7 @@ public abstract class KeyboardFocusManager
*/
private static native void initIDs();
private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.KeyboardFocusManager");
private static final Logger log = Logger.getLogger("java.awt.KeyboardFocusManager");
/**
* The identifier for the Forward focus traversal keys.
@ -503,8 +504,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return focusOwner;
} else {
if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
if (focusLog.isLoggable(Level.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@ -608,9 +609,9 @@ public abstract class KeyboardFocusManager
}
void setNativeFocusOwner(Component comp) {
if (focusLog.isLoggable(PlatformLogger.FINEST)) {
focusLog.finest("Calling peer {0} setCurrentFocusOwner for {1}",
peer, comp);
if (focusLog.isLoggable(Level.FINEST)) {
focusLog.log(Level.FINEST, "Calling peer {0} setCurrentFocusOwner for {1}",
new Object[] {String.valueOf(peer), String.valueOf(comp)});
}
peer.setCurrentFocusOwner(comp);
}
@ -672,8 +673,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return permanentFocusOwner;
} else {
if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
if (focusLog.isLoggable(Level.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@ -780,8 +781,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return focusedWindow;
} else {
if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
if (focusLog.isLoggable(Level.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@ -884,8 +885,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return activeWindow;
} else {
if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
if (focusLog.isLoggable(Level.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@ -918,8 +919,8 @@ public abstract class KeyboardFocusManager
Window oldActiveWindow;
synchronized (KeyboardFocusManager.class) {
oldActiveWindow = getActiveWindow();
if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.finer("Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
if (focusLog.isLoggable(Level.FINER)) {
focusLog.log(Level.FINER, "Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
}
try {
@ -1214,8 +1215,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return currentFocusCycleRoot;
} else {
if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
if (focusLog.isLoggable(Level.FINER)) {
focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@ -2148,9 +2149,9 @@ public abstract class KeyboardFocusManager
HeavyweightFocusRequest(Component heavyweight, Component descendant,
boolean temporary, CausedFocusEvent.Cause cause) {
if (log.isLoggable(PlatformLogger.FINE)) {
if (log.isLoggable(Level.FINE)) {
if (heavyweight == null) {
log.fine("Assertion (heavyweight != null) failed");
log.log(Level.FINE, "Assertion (heavyweight != null) failed");
}
}
@ -2160,12 +2161,12 @@ public abstract class KeyboardFocusManager
}
boolean addLightweightRequest(Component descendant,
boolean temporary, CausedFocusEvent.Cause cause) {
if (log.isLoggable(PlatformLogger.FINE)) {
if (log.isLoggable(Level.FINE)) {
if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) {
log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
log.log(Level.FINE, "Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
}
if (descendant == null) {
log.fine("Assertion (descendant != null) failed");
log.log(Level.FINE, "Assertion (descendant != null) failed");
}
}
@ -2338,12 +2339,12 @@ public abstract class KeyboardFocusManager
(Component heavyweight, Component descendant, boolean temporary,
boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
{
if (log.isLoggable(PlatformLogger.FINE)) {
if (log.isLoggable(Level.FINE)) {
if (heavyweight == null) {
log.fine("Assertion (heavyweight != null) failed");
log.log(Level.FINE, "Assertion (heavyweight != null) failed");
}
if (time == 0) {
log.fine("Assertion (time != 0) failed");
log.log(Level.FINE, "Assertion (time != 0) failed");
}
}
@ -2360,31 +2361,31 @@ public abstract class KeyboardFocusManager
Component currentFocusOwner = thisManager.getGlobalFocusOwner();
Component nativeFocusOwner = thisManager.getNativeFocusOwner();
Window nativeFocusedWindow = thisManager.getNativeFocusedWindow();
if (focusLog.isLoggable(PlatformLogger.FINER)) {
focusLog.finer("SNFH for {0} in {1}",
descendant, heavyweight);
if (focusLog.isLoggable(Level.FINER)) {
focusLog.log(Level.FINER, "SNFH for {0} in {1}",
new Object[] {String.valueOf(descendant), String.valueOf(heavyweight)});
}
if (focusLog.isLoggable(PlatformLogger.FINEST)) {
focusLog.finest("0. Current focus owner {0}",
currentFocusOwner);
focusLog.finest("0. Native focus owner {0}",
nativeFocusOwner);
focusLog.finest("0. Native focused window {0}",
nativeFocusedWindow);
if (focusLog.isLoggable(Level.FINEST)) {
focusLog.log(Level.FINEST, "0. Current focus owner {0}",
String.valueOf(currentFocusOwner));
focusLog.log(Level.FINEST, "0. Native focus owner {0}",
String.valueOf(nativeFocusOwner));
focusLog.log(Level.FINEST, "0. Native focused window {0}",
String.valueOf(nativeFocusedWindow));
}
synchronized (heavyweightRequests) {
HeavyweightFocusRequest hwFocusRequest = getLastHWRequest();
if (focusLog.isLoggable(PlatformLogger.FINEST)) {
focusLog.finest("Request {0}", hwFocusRequest);
if (focusLog.isLoggable(Level.FINEST)) {
focusLog.log(Level.FINEST, "Request {0}", String.valueOf(hwFocusRequest));
}
if (hwFocusRequest == null &&
heavyweight == nativeFocusOwner)
{
if (descendant == currentFocusOwner) {
// Redundant request.
if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.finest("1. SNFH_FAILURE for {0}",
descendant);
if (focusLog.isLoggable(Level.FINEST))
focusLog.log(Level.FINEST, "1. SNFH_FAILURE for {0}",
String.valueOf(descendant));
return SNFH_FAILURE;
}
@ -2416,8 +2417,8 @@ public abstract class KeyboardFocusManager
// SunToolkit.postPriorityEvent(newFocusOwnerEvent);
SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent);
if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.finest("2. SNFH_HANDLED for {0}", descendant);
if (focusLog.isLoggable(Level.FINEST))
focusLog.log(Level.FINEST, "2. SNFH_HANDLED for {0}", String.valueOf(descendant));
return SNFH_SUCCESS_HANDLED;
} else if (hwFocusRequest != null &&
hwFocusRequest.heavyweight == heavyweight) {
@ -2430,7 +2431,7 @@ public abstract class KeyboardFocusManager
manager.enqueueKeyEvents(time, descendant);
}
if (focusLog.isLoggable(PlatformLogger.FINEST))
if (focusLog.isLoggable(Level.FINEST))
focusLog.finest("3. SNFH_HANDLED for lightweight" +
descendant + " in " + heavyweight);
return SNFH_SUCCESS_HANDLED;
@ -2453,7 +2454,7 @@ public abstract class KeyboardFocusManager
(hwFocusRequest != null)
? hwFocusRequest.heavyweight
: nativeFocusedWindow)) {
if (focusLog.isLoggable(PlatformLogger.FINEST))
if (focusLog.isLoggable(Level.FINEST))
focusLog.finest("4. SNFH_FAILURE for " + descendant);
return SNFH_FAILURE;
}
@ -2463,7 +2464,7 @@ public abstract class KeyboardFocusManager
heavyweightRequests.add
(new HeavyweightFocusRequest(heavyweight, descendant,
temporary, cause));
if (focusLog.isLoggable(PlatformLogger.FINEST))
if (focusLog.isLoggable(Level.FINEST))
focusLog.finest("5. SNFH_PROCEED for " + descendant);
return SNFH_SUCCESS_PROCEED;
}
@ -2854,13 +2855,14 @@ public abstract class KeyboardFocusManager
}
KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
if (focusLog.isLoggable(PlatformLogger.FINER)) {
if (focusLog.isLoggable(Level.FINER)) {
if (event instanceof FocusEvent || event instanceof WindowEvent) {
focusLog.finer(">>> {0}", event);
focusLog.log(Level.FINER, ">>> {0}", new Object[] {String.valueOf(event)});
}
if (focusLog.isLoggable(PlatformLogger.FINER) && event instanceof KeyEvent) {
focusLog.finer(" focus owner is {0}", manager.getGlobalFocusOwner());
focusLog.finer(">>> {0}", event);
if (focusLog.isLoggable(Level.FINER) && event instanceof KeyEvent) {
focusLog.log(Level.FINER, " focus owner is {0}",
new Object[] {String.valueOf(manager.getGlobalFocusOwner())});
focusLog.log(Level.FINER, ">>> {0}", new Object[] {String.valueOf(event)});
}
}
@ -2944,9 +2946,9 @@ public abstract class KeyboardFocusManager
}
}
static void removeLastFocusRequest(Component heavyweight) {
if (log.isLoggable(PlatformLogger.FINE)) {
if (log.isLoggable(Level.FINE)) {
if (heavyweight == null) {
log.fine("Assertion (heavyweight != null) failed");
log.log(Level.FINE, "Assertion (heavyweight != null) failed");
}
}

View File

@ -865,7 +865,9 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_PYCC:
synchronized(ICC_Profile.class) {
if (PYCCprofile == null) {
if (getProfileFile("PYCC.pf") != null) {
if (!sun.jkernel.DownloadManager.isJREComplete() ||
standardProfileExists("PYCC.pf"))
{
ProfileDeferralInfo pInfo =
new ProfileDeferralInfo("PYCC.pf",
ColorSpace.TYPE_3CLR, 3,
@ -963,15 +965,15 @@ public class ICC_Profile implements Serializable {
* and it does not permit read access to the given file.
*/
public static ICC_Profile getInstance(String fileName) throws IOException {
ICC_Profile thisProfile;
FileInputStream fis;
ICC_Profile thisProfile;
FileInputStream fis = null;
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(fileName);
File f = getProfileFile(fileName);
if (f != null) {
fis = new FileInputStream(f);
}
if ((fis = openProfile(fileName)) == null) {
if (fis == null) {
throw new IOException("Cannot open file " + fileName);
}
@ -1083,11 +1085,22 @@ public class ICC_Profile implements Serializable {
void activateDeferredProfile() throws ProfileDataException {
byte profileData[];
FileInputStream fis;
String fileName = deferralInfo.filename;
final String fileName = deferralInfo.filename;
profileActivator = null;
deferralInfo = null;
if ((fis = openProfile(fileName)) == null) {
PrivilegedAction<FileInputStream> pa = new PrivilegedAction<FileInputStream>() {
public FileInputStream run() {
File f = getStandardProfileFile(fileName);
if (f != null) {
try {
return new FileInputStream(f);
} catch (FileNotFoundException e) {}
}
return null;
}
};
if ((fis = AccessController.doPrivileged(pa)) == null) {
throw new ProfileDataException("Cannot open file " + fileName);
}
try {
@ -1786,59 +1799,36 @@ public class ICC_Profile implements Serializable {
* available, such as a profile for sRGB. Built-in profiles use .pf as
* the file name extension for profiles, e.g. sRGB.pf.
*/
private static FileInputStream openProfile(final String fileName) {
return (FileInputStream)java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
File f = privilegedGetProfileFile(fileName);
if (f != null) {
try {
return new FileInputStream(f);
} catch (FileNotFoundException e) {
}
}
return null;
}
});
}
private static File getProfileFile(final String fileName) {
return (File)java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
return privilegedGetProfileFile(fileName);
}
});
}
/*
* this version is called from doPrivileged in openProfile
* or getProfileFile, so the whole method is privileged!
*/
private static File privilegedGetProfileFile(String fileName) {
private static File getProfileFile(String fileName) {
String path, dir, fullPath;
File f = new File(fileName); /* try absolute file name */
if (f.isAbsolute()) {
/* Rest of code has little sense for an absolute pathname,
so return here. */
return f.isFile() ? f : null;
}
if ((!f.isFile()) &&
((path = System.getProperty("java.iccprofile.path")) != null)){
/* try relative to java.iccprofile.path */
StringTokenizer st =
new StringTokenizer(path, File.pathSeparator);
while (st.hasMoreTokens() && (!f.isFile())) {
while (st.hasMoreTokens() && ((f == null) || (!f.isFile()))) {
dir = st.nextToken();
fullPath = dir + File.separatorChar + fileName;
f = new File(fullPath);
if (!isChildOf(f, dir)) {
f = null;
}
}
}
if ((!f.isFile()) &&
if (((f == null) || (!f.isFile())) &&
((path = System.getProperty("java.class.path")) != null)) {
/* try relative to java.class.path */
StringTokenizer st =
new StringTokenizer(path, File.pathSeparator);
while (st.hasMoreTokens() && (!f.isFile())) {
while (st.hasMoreTokens() && ((f == null) || (!f.isFile()))) {
dir = st.nextToken();
fullPath = dir + File.separatorChar + fileName;
f = new File(fullPath);
@ -1858,13 +1848,69 @@ public class ICC_Profile implements Serializable {
}
}
}
if (f.isFile()) {
if ((f == null) || (!f.isFile())) {
/* try the directory of built-in profiles */
f = getStandardProfileFile(fileName);
}
if (f != null && f.isFile()) {
return f;
}
return null;
}
/**
* Returns a file object corresponding to a built-in profile
* specified by fileName.
* If there is no built-in profile with such name, then the method
* returns null.
*/
private static File getStandardProfileFile(String fileName) {
String dir = System.getProperty("java.home") +
File.separatorChar + "lib" + File.separatorChar + "cmm";
String fullPath = dir + File.separatorChar + fileName;
File f = new File(fullPath);
if (!f.isFile()) {
//make sure file was installed in the kernel mode
try {
//kernel uses platform independent paths =>
// should not use platform separator char
sun.jkernel.DownloadManager.downloadFile("lib/cmm/"+fileName);
} catch (IOException ioe) {}
}
return (f.isFile() && isChildOf(f, dir)) ? f : null;
}
/**
* Checks whether given file resides inside give directory.
*/
private static boolean isChildOf(File f, String dirName) {
try {
File dir = new File(dirName);
String canonicalDirName = dir.getCanonicalPath();
if (!canonicalDirName.endsWith(File.separator)) {
canonicalDirName += File.separator;
}
String canonicalFileName = f.getCanonicalPath();
return canonicalFileName.startsWith(canonicalDirName);
} catch (IOException e) {
/* we do not expect the IOException here, because invocation
* of this function is always preceeded by isFile() call.
*/
return false;
}
}
/**
* Checks whether built-in profile specified by fileName exists.
*/
private static boolean standardProfileExists(final String fileName) {
return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
return getStandardProfileFile(fileName) != null;
}
});
}
/*
* Serialization support.

View File

@ -42,12 +42,11 @@ import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.sql.Timestamp;
import java.util.*;
import javax.swing.Box;
@ -290,13 +289,44 @@ class java_util_Date_PersistenceDelegate extends PersistenceDelegate {
* @author Sergey A. Malenkov
*/
final class java_sql_Timestamp_PersistenceDelegate extends java_util_Date_PersistenceDelegate {
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
Timestamp oldTime = (Timestamp)oldInstance;
Timestamp newTime = (Timestamp)newInstance;
private static final Method getNanosMethod = getNanosMethod();
int nanos = oldTime.getNanos();
if (nanos != newTime.getNanos()) {
out.writeStatement(new Statement(oldTime, "setNanos", new Object[] {nanos}));
private static Method getNanosMethod() {
try {
Class<?> c = Class.forName("java.sql.Timestamp", true, null);
return c.getMethod("getNanos");
} catch (ClassNotFoundException e) {
return null;
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
}
/**
* Invoke Timstamp getNanos.
*/
private static int getNanos(Object obj) {
if (getNanosMethod == null)
throw new AssertionError("Should not get here");
try {
return (Integer)getNanosMethod.invoke(obj);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException)
throw (RuntimeException)cause;
if (cause instanceof Error)
throw (Error)cause;
throw new AssertionError(e);
} catch (IllegalAccessException iae) {
throw new AssertionError(iae);
}
}
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
// assumes oldInstance and newInstance are Timestamps
int nanos = getNanos(oldInstance);
if (nanos != getNanos(newInstance)) {
out.writeStatement(new Statement(oldInstance, "setNanos", new Object[] {nanos}));
}
}
}

View File

@ -186,11 +186,6 @@ public abstract class ClassLoader {
parallelLoaders.add(ClassLoader.class);
}
// If initialization succeed this is set to true and security checks will
// succeed. Otherwise the object is not initialized and the object is
// useless.
private final boolean initialized;
// The parent class loader for delegation
// Note: VM hardcoded the offset of this field, thus all new fields
// must be added *after* it.
@ -232,6 +227,31 @@ public abstract class ClassLoader {
private final HashMap<String, Package> packages =
new HashMap<String, Package>();
private static Void checkCreateClassLoader() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkCreateClassLoader();
}
return null;
}
private ClassLoader(Void unused, ClassLoader parent) {
this.parent = parent;
if (parallelLoaders.contains(this.getClass())) {
parallelLockMap = new ConcurrentHashMap<String, Object>();
package2certs = new ConcurrentHashMap<String, Certificate[]>();
domains =
Collections.synchronizedSet(new HashSet<ProtectionDomain>());
assertionLock = new Object();
} else {
// no finer-grained lock; lock on the classloader instance
parallelLockMap = null;
package2certs = new Hashtable<String, Certificate[]>();
domains = new HashSet<ProtectionDomain>();
assertionLock = this;
}
}
/**
* Creates a new class loader using the specified parent class loader for
* delegation.
@ -252,25 +272,7 @@ public abstract class ClassLoader {
* @since 1.2
*/
protected ClassLoader(ClassLoader parent) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkCreateClassLoader();
}
this.parent = parent;
if (parallelLoaders.contains(this.getClass())) {
parallelLockMap = new ConcurrentHashMap<String, Object>();
package2certs = new ConcurrentHashMap<String, Certificate[]>();
domains =
Collections.synchronizedSet(new HashSet<ProtectionDomain>());
assertionLock = new Object();
} else {
// no finer-grained lock; lock on the classloader instance
parallelLockMap = null;
package2certs = new Hashtable<String, Certificate[]>();
domains = new HashSet<ProtectionDomain>();
assertionLock = this;
}
initialized = true;
this(checkCreateClassLoader(), parent);
}
/**
@ -289,25 +291,7 @@ public abstract class ClassLoader {
* of a new class loader.
*/
protected ClassLoader() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkCreateClassLoader();
}
this.parent = getSystemClassLoader();
if (parallelLoaders.contains(this.getClass())) {
parallelLockMap = new ConcurrentHashMap<String, Object>();
package2certs = new ConcurrentHashMap<String, Certificate[]>();
domains =
Collections.synchronizedSet(new HashSet<ProtectionDomain>());
assertionLock = new Object();
} else {
// no finer-grained lock; lock on the classloader instance
parallelLockMap = null;
package2certs = new Hashtable<String, Certificate[]>();
domains = new HashSet<ProtectionDomain>();
assertionLock = this;
}
initialized = true;
this(checkCreateClassLoader(), getSystemClassLoader());
}
// -- Class --
@ -754,7 +738,6 @@ public abstract class ClassLoader {
ProtectionDomain protectionDomain)
throws ClassFormatError
{
check();
protectionDomain = preDefineClass(name, protectionDomain);
Class c = null;
@ -838,8 +821,6 @@ public abstract class ClassLoader {
ProtectionDomain protectionDomain)
throws ClassFormatError
{
check();
int len = b.remaining();
// Use byte[] if not a direct ByteBufer:
@ -984,7 +965,6 @@ public abstract class ClassLoader {
* @see #defineClass(String, byte[], int, int)
*/
protected final void resolveClass(Class<?> c) {
check();
resolveClass0(c);
}
@ -1015,7 +995,6 @@ public abstract class ClassLoader {
protected final Class<?> findSystemClass(String name)
throws ClassNotFoundException
{
check();
ClassLoader system = getSystemClassLoader();
if (system == null) {
if (!checkName(name))
@ -1035,7 +1014,6 @@ public abstract class ClassLoader {
*/
private Class findBootstrapClassOrNull(String name)
{
check();
if (!checkName(name)) return null;
return findBootstrapClass(name);
@ -1044,13 +1022,6 @@ public abstract class ClassLoader {
// return null if not found
private native Class findBootstrapClass(String name);
// Check to make sure the class loader has been initialized.
private void check() {
if (!initialized) {
throw new SecurityException("ClassLoader object not initialized");
}
}
/**
* Returns the class with the given <a href="#name">binary name</a> if this
* loader has been recorded by the Java virtual machine as an initiating
@ -1066,7 +1037,6 @@ public abstract class ClassLoader {
* @since 1.1
*/
protected final Class<?> findLoadedClass(String name) {
check();
if (!checkName(name))
return null;
return findLoadedClass0(name);
@ -1087,7 +1057,6 @@ public abstract class ClassLoader {
* @since 1.1
*/
protected final void setSigners(Class<?> c, Object[] signers) {
check();
c.setSigners(signers);
}
@ -2205,3 +2174,4 @@ class SystemClassLoaderAction
return sys;
}
}

View File

@ -288,11 +288,11 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
*/
public BigInteger(String val, int radix) {
int cursor = 0, numDigits;
int len = val.length();
final int len = val.length();
if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
throw new NumberFormatException("Radix out of range");
if (val.length() == 0)
if (len == 0)
throw new NumberFormatException("Zero length BigInteger");
// Check for at most one leading sign
@ -303,7 +303,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
// No leading sign character or at most one leading sign character
if (index1 == 0 || index2 == 0) {
cursor = 1;
if (val.length() == 1)
if (len == 1)
throw new NumberFormatException("Zero length BigInteger");
}
if (index1 == 0)
@ -342,7 +342,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
// Process remaining digit groups
int superRadix = intRadix[radix];
int groupVal = 0;
while (cursor < val.length()) {
while (cursor < len) {
group = val.substring(cursor, cursor += digitsPerInt[radix]);
groupVal = Integer.parseInt(group, radix);
if (groupVal < 0)

View File

@ -1,5 +1,5 @@
/*
* Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2009 Sun Microsystems, Inc. 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
@ -414,16 +414,17 @@ public abstract class MessageDigest extends MessageDigestSpi {
*
* @return true if the digests are equal, false otherwise.
*/
public static boolean isEqual(byte digesta[], byte digestb[]) {
if (digesta.length != digestb.length)
public static boolean isEqual(byte[] digesta, byte[] digestb) {
if (digesta.length != digestb.length) {
return false;
for (int i = 0; i < digesta.length; i++) {
if (digesta[i] != digestb[i]) {
return false;
}
}
return true;
int result = 0;
// time-constant comparison
for (int i = 0; i < digesta.length; i++) {
result |= digesta[i] ^ digestb[i];
}
return result == 0;
}
/**

View File

@ -256,9 +256,8 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
public boolean addAll(int index, Collection<? extends E> c) {
rangeCheckForAdd(index);
boolean modified = false;
Iterator<? extends E> e = c.iterator();
while (e.hasNext()) {
add(index++, e.next());
for (E e : c) {
add(index++, e);
modified = true;
}
return modified;

View File

@ -183,11 +183,9 @@ public abstract class AbstractQueue<E>
if (c == this)
throw new IllegalArgumentException();
boolean modified = false;
Iterator<? extends E> e = c.iterator();
while (e.hasNext()) {
if (add(e.next()))
for (E e : c)
if (add(e))
modified = true;
}
return modified;
}

View File

@ -57,51 +57,14 @@ public class Arrays {
// Suppresses default constructor, ensuring non-instantiability.
private Arrays() {}
// Sorting
/*
* Sorting of primitive type arrays.
*/
/**
* Sorts the specified array into ascending numerical order.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
*/
public static void sort(long[] a) {
sort(a, 0, a.length);
}
/**
* Sorts the specified range of the specified array into ascending order. The
* range of to be sorted extends from the index {@code fromIndex}, inclusive,
* to the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element, inclusively, to be sorted
* @param toIndex the index of the last element, exclusively, to be sorted
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code fromIndex < 0} or {@code toIndex > a.length}
*/
public static void sort(long[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
}
/**
* Sorts the specified array into ascending numerical order.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
@ -110,37 +73,76 @@ public class Arrays {
* @param a the array to be sorted
*/
public static void sort(int[] a) {
sort(a, 0, a.length);
DualPivotQuicksort.sort(a);
}
/**
* Sorts the specified range of the specified array into ascending order. The
* range of to be sorted extends from the index {@code fromIndex}, inclusive,
* to the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* Sorts the specified range of the array into ascending order. The range
* to be sorted extends from the index {@code fromIndex}, inclusive, to
* the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element, inclusively, to be sorted
* @param toIndex the index of the last element, exclusively, to be sorted
* @param fromIndex the index of the first element, inclusive, to be sorted
* @param toIndex the index of the last element, exclusive, to be sorted
*
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code fromIndex < 0} or {@code toIndex > a.length}
*/
public static void sort(int[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
DualPivotQuicksort.sort(a, fromIndex, toIndex);
}
/**
* Sorts the specified array into ascending numerical order.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
*/
public static void sort(long[] a) {
DualPivotQuicksort.sort(a);
}
/**
* Sorts the specified range of the array into ascending order. The range
* to be sorted extends from the index {@code fromIndex}, inclusive, to
* the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element, inclusive, to be sorted
* @param toIndex the index of the last element, exclusive, to be sorted
*
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code fromIndex < 0} or {@code toIndex > a.length}
*/
public static void sort(long[] a, int fromIndex, int toIndex) {
DualPivotQuicksort.sort(a, fromIndex, toIndex);
}
/**
* Sorts the specified array into ascending numerical order.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
@ -149,37 +151,37 @@ public class Arrays {
* @param a the array to be sorted
*/
public static void sort(short[] a) {
sort(a, 0, a.length);
DualPivotQuicksort.sort(a);
}
/**
* Sorts the specified range of the specified array into ascending order. The
* range of to be sorted extends from the index {@code fromIndex}, inclusive,
* to the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* Sorts the specified range of the array into ascending order. The range
* to be sorted extends from the index {@code fromIndex}, inclusive, to
* the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element, inclusively, to be sorted
* @param toIndex the index of the last element, exclusively, to be sorted
* @param fromIndex the index of the first element, inclusive, to be sorted
* @param toIndex the index of the last element, exclusive, to be sorted
*
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code fromIndex < 0} or {@code toIndex > a.length}
*/
public static void sort(short[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
DualPivotQuicksort.sort(a, fromIndex, toIndex);
}
/**
* Sorts the specified array into ascending numerical order.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
@ -188,37 +190,37 @@ public class Arrays {
* @param a the array to be sorted
*/
public static void sort(char[] a) {
sort(a, 0, a.length);
DualPivotQuicksort.sort(a);
}
/**
* Sorts the specified range of the specified array into ascending order. The
* range of to be sorted extends from the index {@code fromIndex}, inclusive,
* to the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* Sorts the specified range of the array into ascending order. The range
* to be sorted extends from the index {@code fromIndex}, inclusive, to
* the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element, inclusively, to be sorted
* @param toIndex the index of the last element, exclusively, to be sorted
* @param fromIndex the index of the first element, inclusive, to be sorted
* @param toIndex the index of the last element, exclusive, to be sorted
*
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code fromIndex < 0} or {@code toIndex > a.length}
*/
public static void sort(char[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
DualPivotQuicksort.sort(a, fromIndex, toIndex);
}
/**
* Sorts the specified array into ascending numerical order.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
@ -227,160 +229,45 @@ public class Arrays {
* @param a the array to be sorted
*/
public static void sort(byte[] a) {
sort(a, 0, a.length);
DualPivotQuicksort.sort(a);
}
/**
* Sorts the specified range of the specified array into ascending order. The
* range of to be sorted extends from the index {@code fromIndex}, inclusive,
* to the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* Sorts the specified range of the array into ascending order. The range
* to be sorted extends from the index {@code fromIndex}, inclusive, to
* the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element, inclusively, to be sorted
* @param toIndex the index of the last element, exclusively, to be sorted
* @param fromIndex the index of the first element, inclusive, to be sorted
* @param toIndex the index of the last element, exclusive, to be sorted
*
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code fromIndex < 0} or {@code toIndex > a.length}
*/
public static void sort(byte[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
DualPivotQuicksort.sort(a, fromIndex, toIndex - 1);
DualPivotQuicksort.sort(a, fromIndex, toIndex);
}
/**
* Sorts the specified array into ascending numerical order.
*
* <p>The {@code <} relation does not provide a total order on
* all floating-point values; although they are distinct numbers
* {@code -0.0d == 0.0d} is {@code true} and a NaN value compares
* neither less than, greater than, nor equal to any floating-point
* value, even itself. To allow the sort to proceed, instead of using
* the {@code <} relation to determine ascending numerical order,
* this method uses the total order imposed by {@link Double#compareTo}.
* This ordering differs from the {@code <} relation in that {@code -0.0d}
* is treated as less than {@code 0.0d} and NaN is considered greater than
* any other floating-point value. For the purposes of sorting, all NaN
* values are considered equivalent and equal.
* <p>The {@code <} relation does not provide a total order on all float
* values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN}
* value compares neither less than, greater than, nor equal to any value,
* even itself. This method uses the total order imposed by the method
* {@link Float#compareTo}: {@code -0.0f} is treated as less than value
* {@code 0.0f} and {@code Float.NaN} is considered greater than any
* other value and all {@code Float.NaN} values are considered equal.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
*/
public static void sort(double[] a) {
sort(a, 0, a.length);
}
/**
* Sorts the specified range of the specified array into ascending order. The
* range of to be sorted extends from the index {@code fromIndex}, inclusive,
* to the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty.
*
* <p>The {@code <} relation does not provide a total order on
* all floating-point values; although they are distinct numbers
* {@code -0.0d == 0.0d} is {@code true} and a NaN value compares
* neither less than, greater than, nor equal to any floating-point
* value, even itself. To allow the sort to proceed, instead of using
* the {@code <} relation to determine ascending numerical order,
* this method uses the total order imposed by {@link Double#compareTo}.
* This ordering differs from the {@code <} relation in that {@code -0.0d}
* is treated as less than {@code 0.0d} and NaN is considered greater than
* any other floating-point value. For the purposes of sorting, all NaN
* values are considered equivalent and equal.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element, inclusively, to be sorted
* @param toIndex the index of the last element, exclusively, to be sorted
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code fromIndex < 0} or {@code toIndex > a.length}
*/
public static void sort(double[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
sortNegZeroAndNaN(a, fromIndex, toIndex);
}
private static void sortNegZeroAndNaN(double[] a, int fromIndex, int toIndex) {
final long NEG_ZERO_BITS = Double.doubleToLongBits(-0.0d);
/*
* The sort is done in three phases to avoid the expense of using
* NaN and -0.0d aware comparisons during the main sort.
*
* Preprocessing phase: move any NaN's to end of array, count the
* number of -0.0d's, and turn them into 0.0d's.
*/
int numNegZeros = 0;
int i = fromIndex;
int n = toIndex;
double temp;
while (i < n) {
if (a[i] != a[i]) {
n--;
temp = a[i];
a[i] = a[n];
a[n] = temp;
}
else {
if (a[i] == 0 && Double.doubleToLongBits(a[i]) == NEG_ZERO_BITS) {
a[i] = 0.0d;
numNegZeros++;
}
i++;
}
}
// Main sort phase: quicksort everything but the NaN's
DualPivotQuicksort.sort(a, fromIndex, n - 1);
// Postprocessing phase: change 0.0d's to -0.0d's as required
if (numNegZeros != 0) {
int j = binarySearch0(a, fromIndex, n, 0.0d); // position of ANY zero
do {
j--;
}
while (j >= fromIndex && a[j] == 0.0d);
// j is now one less than the index of the FIRST zero
for (int k = 0; k < numNegZeros; k++) {
a[++j] = -0.0d;
}
}
}
/**
* Sorts the specified array into ascending numerical order.
*
* <p>The {@code <} relation does not provide a total order on
* all floating-point values; although they are distinct numbers
* {@code -0.0f == 0.0f} is {@code true} and a NaN value compares
* neither less than, greater than, nor equal to any floating-point
* value, even itself. To allow the sort to proceed, instead of using
* the {@code <} relation to determine ascending numerical order,
* this method uses the total order imposed by {@link Float#compareTo}.
* This ordering differs from the {@code <} relation in that {@code -0.0f}
* is treated as less than {@code 0.0f} and NaN is considered greater than
* any other floating-point value. For the purposes of sorting, all NaN
* values are considered equivalent and equal.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
@ -389,93 +276,101 @@ public class Arrays {
* @param a the array to be sorted
*/
public static void sort(float[] a) {
sort(a, 0, a.length);
DualPivotQuicksort.sort(a);
}
/**
* Sorts the specified range of the specified array into ascending order. The
* range of to be sorted extends from the index {@code fromIndex}, inclusive,
* to the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* Sorts the specified range of the array into ascending order. The range
* to be sorted extends from the index {@code fromIndex}, inclusive, to
* the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty.
*
* <p>The {@code <} relation does not provide a total order on
* all floating-point values; although they are distinct numbers
* {@code -0.0f == 0.0f} is {@code true} and a NaN value compares
* neither less than, greater than, nor equal to any floating-point
* value, even itself. To allow the sort to proceed, instead of using
* the {@code <} relation to determine ascending numerical order,
* this method uses the total order imposed by {@link Float#compareTo}.
* This ordering differs from the {@code <} relation in that {@code -0.0f}
* is treated as less than {@code 0.0f} and NaN is considered greater than
* any other floating-point value. For the purposes of sorting, all NaN
* values are considered equivalent and equal.
* <p>The {@code <} relation does not provide a total order on all float
* values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN}
* value compares neither less than, greater than, nor equal to any value,
* even itself. This method uses the total order imposed by the method
* {@link Float#compareTo}: {@code -0.0f} is treated as less than value
* {@code 0.0f} and {@code Float.NaN} is considered greater than any
* other value and all {@code Float.NaN} values are considered equal.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort,
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element, inclusively, to be sorted
* @param toIndex the index of the last element, exclusively, to be sorted
* @param fromIndex the index of the first element, inclusive, to be sorted
* @param toIndex the index of the last element, exclusive, to be sorted
*
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code fromIndex < 0} or {@code toIndex > a.length}
*/
public static void sort(float[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
sortNegZeroAndNaN(a, fromIndex, toIndex);
DualPivotQuicksort.sort(a, fromIndex, toIndex);
}
private static void sortNegZeroAndNaN(float[] a, int fromIndex, int toIndex) {
final int NEG_ZERO_BITS = Float.floatToIntBits(-0.0f);
/*
* The sort is done in three phases to avoid the expense of using
* NaN and -0.0f aware comparisons during the main sort.
*
* Preprocessing phase: move any NaN's to end of array, count the
* number of -0.0f's, and turn them into 0.0f's.
*/
int numNegZeros = 0;
int i = fromIndex;
int n = toIndex;
float temp;
while (i < n) {
if (a[i] != a[i]) {
n--;
temp = a[i];
a[i] = a[n];
a[n] = temp;
}
else {
if (a[i] == 0 && Float.floatToIntBits(a[i]) == NEG_ZERO_BITS) {
a[i] = 0.0f;
numNegZeros++;
}
i++;
}
}
// Main sort phase: quicksort everything but the NaN's
DualPivotQuicksort.sort(a, fromIndex, n - 1);
// Postprocessing phase: change 0.0f's to -0.0f's as required
if (numNegZeros != 0) {
int j = binarySearch0(a, fromIndex, n, 0.0f); // position of ANY zero
do {
j--;
}
while (j >= fromIndex && a[j] == 0.0f);
// j is now one less than the index of the FIRST zero
for (int k = 0; k < numNegZeros; k++) {
a[++j] = -0.0f;
}
}
/**
* Sorts the specified array into ascending numerical order.
*
* <p>The {@code <} relation does not provide a total order on all double
* values: {@code -0.0d == 0.0d} is {@code true} and a {@code Double.NaN}
* value compares neither less than, greater than, nor equal to any value,
* even itself. This method uses the total order imposed by the method
* {@link Double#compareTo}: {@code -0.0d} is treated as less than value
* {@code 0.0d} and {@code Double.NaN} is considered greater than any
* other value and all {@code Double.NaN} values are considered equal.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
*/
public static void sort(double[] a) {
DualPivotQuicksort.sort(a);
}
/**
* Sorts the specified range of the array into ascending order. The range
* to be sorted extends from the index {@code fromIndex}, inclusive, to
* the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
* the range to be sorted is empty.
*
* <p>The {@code <} relation does not provide a total order on all double
* values: {@code -0.0d == 0.0d} is {@code true} and a {@code Double.NaN}
* value compares neither less than, greater than, nor equal to any value,
* even itself. This method uses the total order imposed by the method
* {@link Double#compareTo}: {@code -0.0d} is treated as less than value
* {@code 0.0d} and {@code Double.NaN} is considered greater than any
* other value and all {@code Double.NaN} values are considered equal.
*
* <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
* by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
* offers O(n log(n)) performance on many data sets that cause other
* quicksorts to degrade to quadratic performance, and is typically
* faster than traditional (one-pivot) Quicksort implementations.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element, inclusive, to be sorted
* @param toIndex the index of the last element, exclusive, to be sorted
*
* @throws IllegalArgumentException if {@code fromIndex > toIndex}
* @throws ArrayIndexOutOfBoundsException
* if {@code fromIndex < 0} or {@code toIndex > a.length}
*/
public static void sort(double[] a, int fromIndex, int toIndex) {
DualPivotQuicksort.sort(a, fromIndex, toIndex);
}
/*
* Sorting of complex type arrays.
*
*/
/**
* Old merge sort implementation can be selected (for
* compatibility with broken comparators) using a system property.

File diff suppressed because it is too large Load Diff

View File

@ -2485,55 +2485,45 @@ public final class Formatter implements Closeable, Flushable {
private static Pattern fsPattern = Pattern.compile(formatSpecifier);
// Look for format specifiers in the format string.
/**
* Finds format specifiers in the format string.
*/
private FormatString[] parse(String s) {
ArrayList al = new ArrayList();
ArrayList<FormatString> al = new ArrayList<FormatString>();
Matcher m = fsPattern.matcher(s);
int i = 0;
while (i < s.length()) {
for (int i = 0, len = s.length(); i < len; ) {
if (m.find(i)) {
// Anything between the start of the string and the beginning
// of the format specifier is either fixed text or contains
// an invalid format string.
if (m.start() != i) {
// Make sure we didn't miss any invalid format specifiers
checkText(s.substring(i, m.start()));
checkText(s, i, m.start());
// Assume previous characters were fixed text
al.add(new FixedString(s.substring(i, m.start())));
}
// Expect 6 groups in regular expression
String[] sa = new String[6];
for (int j = 0; j < m.groupCount(); j++)
{
sa[j] = m.group(j + 1);
// System.out.print(sa[j] + " ");
}
// System.out.println();
al.add(new FormatSpecifier(this, sa));
al.add(new FormatSpecifier(m));
i = m.end();
} else {
// No more valid format specifiers. Check for possible invalid
// format specifiers.
checkText(s.substring(i));
checkText(s, i, len);
// The rest of the string is fixed text
al.add(new FixedString(s.substring(i)));
break;
}
}
// FormatString[] fs = new FormatString[al.size()];
// for (int j = 0; j < al.size(); j++)
// System.out.println(((FormatString) al.get(j)).toString());
return (FormatString[]) al.toArray(new FormatString[0]);
return al.toArray(new FormatString[al.size()]);
}
private void checkText(String s) {
int idx;
// If there are any '%' in the given string, we got a bad format
// specifier.
if ((idx = s.indexOf('%')) != -1) {
char c = (idx > s.length() - 2 ? '%' : s.charAt(idx + 1));
throw new UnknownFormatConversionException(String.valueOf(c));
private static void checkText(String s, int start, int end) {
for (int i = start; i < end; i++) {
// Any '%' found in the region starts an invalid format specifier.
if (s.charAt(i) == '%') {
char c = (i == end - 1) ? '%' : s.charAt(i + 1);
throw new UnknownFormatConversionException(String.valueOf(c));
}
}
}
@ -2562,8 +2552,6 @@ public final class Formatter implements Closeable, Flushable {
private boolean dt = false;
private char c;
private Formatter formatter;
// cache the line separator
private String ls;
@ -2650,21 +2638,22 @@ public final class Formatter implements Closeable, Flushable {
return c;
}
FormatSpecifier(Formatter formatter, String[] sa) {
this.formatter = formatter;
int idx = 0;
FormatSpecifier(Matcher m) {
int idx = 1;
index(sa[idx++]);
flags(sa[idx++]);
width(sa[idx++]);
precision(sa[idx++]);
index(m.group(idx++));
flags(m.group(idx++));
width(m.group(idx++));
precision(m.group(idx++));
if (sa[idx] != null) {
String tT = m.group(idx++);
if (tT != null) {
dt = true;
if (sa[idx].equals("T"))
if (tT.equals("T"))
f.add(Flags.UPPERCASE);
}
conversion(sa[++idx]);
conversion(m.group(idx));
if (dt)
checkDateTime();
@ -2819,9 +2808,9 @@ public final class Formatter implements Closeable, Flushable {
private void printString(Object arg, Locale l) throws IOException {
if (arg instanceof Formattable) {
Formatter fmt = formatter;
if (formatter.locale() != l)
fmt = new Formatter(formatter.out(), l);
Formatter fmt = Formatter.this;
if (fmt.locale() != l)
fmt = new Formatter(fmt.out(), l);
((Formattable)arg).formatTo(fmt, f.valueOf(), width, precision);
} else {
if (f.contains(Flags.ALTERNATE))

View File

@ -448,10 +448,8 @@ public class HashMap<K,V>
}
private void putAllForCreate(Map<? extends K, ? extends V> m) {
for (Iterator<? extends Map.Entry<? extends K, ? extends V>> i = m.entrySet().iterator(); i.hasNext(); ) {
Map.Entry<? extends K, ? extends V> e = i.next();
for (Map.Entry<? extends K, ? extends V> e : m.entrySet())
putForCreate(e.getKey(), e.getValue());
}
}
/**
@ -536,10 +534,8 @@ public class HashMap<K,V>
resize(newCapacity);
}
for (Iterator<? extends Map.Entry<? extends K, ? extends V>> i = m.entrySet().iterator(); i.hasNext(); ) {
Map.Entry<? extends K, ? extends V> e = i.next();
for (Map.Entry<? extends K, ? extends V> e : m.entrySet())
put(e.getKey(), e.getValue());
}
}
/**

View File

@ -280,8 +280,8 @@ public class HashSet<E>
s.writeInt(map.size());
// Write out all elements in the proper order.
for (Iterator i=map.keySet().iterator(); i.hasNext(); )
s.writeObject(i.next());
for (E e : map.keySet())
s.writeObject(e);
}
/**

File diff suppressed because it is too large Load Diff

View File

@ -50,6 +50,18 @@ import sun.misc.Unsafe;
* <p>
* Many applications will find the method {@link Math#random} simpler to use.
*
* <p>Instances of {@code java.util.Random} are threadsafe.
* However, the concurrent use of the same {@code java.util.Random}
* instance across threads may encounter contention and consequent
* poor performance. Consider instead using
* {@link java.util.concurrent.ThreadLocalRandom} in multithreaded
* designs.
*
* <p>Instances of {@code java.util.Random} are not cryptographically
* secure. Consider instead using {@link java.security.SecureRandom} to
* get a cryptographically secure pseudo-random number generator for use
* by security-sensitive applications.
*
* @author Frank Yellin
* @since 1.0
*/

View File

@ -218,8 +218,8 @@ public class ArrayBlockingQueue<E> extends AbstractQueue<E>
if (capacity < c.size())
throw new IllegalArgumentException();
for (Iterator<? extends E> it = c.iterator(); it.hasNext();)
add(it.next());
for (E e : c)
add(e);
}
/**

View File

@ -250,8 +250,8 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
* of its elements are null
*/
public ConcurrentLinkedQueue(Collection<? extends E> c) {
for (Iterator<? extends E> it = c.iterator(); it.hasNext();)
add(it.next());
for (E e : c)
add(e);
}
// Have to override just to update the javadoc

View File

@ -895,7 +895,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
if (n != null) {
Node<K,V> f = n.next;
if (n != b.next) // inconsistent read
break;;
break;
Object v = n.value;
if (v == null) { // n is deleted
n.helpDelete(b, f);

View File

@ -148,7 +148,8 @@ import java.util.concurrent.atomic.*;
*
* </pre>
*
* <p>Memory consistency effects: Actions in a thread prior to calling
* <p>Memory consistency effects: Until the count reaches
* zero, actions in a thread prior to calling
* {@code countDown()}
* <a href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
* actions following a successful return from a corresponding

View File

@ -332,8 +332,8 @@ public interface ExecutorService extends Executor {
* @param tasks the collection of tasks
* @return the result returned by one of the tasks
* @throws InterruptedException if interrupted while waiting
* @throws NullPointerException if tasks or any of its elements
* are <tt>null</tt>
* @throws NullPointerException if tasks or any element task
* subject to execution is <tt>null</tt>
* @throws IllegalArgumentException if tasks is empty
* @throws ExecutionException if no task successfully completes
* @throws RejectedExecutionException if tasks cannot be scheduled
@ -356,8 +356,8 @@ public interface ExecutorService extends Executor {
* @param unit the time unit of the timeout argument
* @return the result returned by one of the tasks.
* @throws InterruptedException if interrupted while waiting
* @throws NullPointerException if tasks, any of its elements, or
* unit are <tt>null</tt>
* @throws NullPointerException if tasks, or unit, or any element
* task subject to execution is <tt>null</tt>
* @throws TimeoutException if the given timeout elapses before
* any task successfully completes
* @throws ExecutionException if no task successfully completes

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,827 @@
/*
* 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain
*/
package java.util.concurrent;
import java.util.Collection;
/**
* A thread managed by a {@link ForkJoinPool}. This class is
* subclassable solely for the sake of adding functionality -- there
* are no overridable methods dealing with scheduling or execution.
* However, you can override initialization and termination methods
* surrounding the main task processing loop. If you do create such a
* subclass, you will also need to supply a custom {@link
* ForkJoinPool.ForkJoinWorkerThreadFactory} to use it in a {@code
* ForkJoinPool}.
*
* @since 1.7
* @author Doug Lea
*/
public class ForkJoinWorkerThread extends Thread {
/*
* Algorithm overview:
*
* 1. Work-Stealing: Work-stealing queues are special forms of
* Deques that support only three of the four possible
* end-operations -- push, pop, and deq (aka steal), and only do
* so under the constraints that push and pop are called only from
* the owning thread, while deq may be called from other threads.
* (If you are unfamiliar with them, you probably want to read
* Herlihy and Shavit's book "The Art of Multiprocessor
* programming", chapter 16 describing these in more detail before
* proceeding.) The main work-stealing queue design is roughly
* similar to "Dynamic Circular Work-Stealing Deque" by David
* Chase and Yossi Lev, SPAA 2005
* (http://research.sun.com/scalable/pubs/index.html). The main
* difference ultimately stems from gc requirements that we null
* out taken slots as soon as we can, to maintain as small a
* footprint as possible even in programs generating huge numbers
* of tasks. To accomplish this, we shift the CAS arbitrating pop
* vs deq (steal) from being on the indices ("base" and "sp") to
* the slots themselves (mainly via method "casSlotNull()"). So,
* both a successful pop and deq mainly entail CAS'ing a non-null
* slot to null. Because we rely on CASes of references, we do
* not need tag bits on base or sp. They are simple ints as used
* in any circular array-based queue (see for example ArrayDeque).
* Updates to the indices must still be ordered in a way that
* guarantees that (sp - base) > 0 means the queue is empty, but
* otherwise may err on the side of possibly making the queue
* appear nonempty when a push, pop, or deq have not fully
* committed. Note that this means that the deq operation,
* considered individually, is not wait-free. One thief cannot
* successfully continue until another in-progress one (or, if
* previously empty, a push) completes. However, in the
* aggregate, we ensure at least probabilistic
* non-blockingness. If an attempted steal fails, a thief always
* chooses a different random victim target to try next. So, in
* order for one thief to progress, it suffices for any
* in-progress deq or new push on any empty queue to complete. One
* reason this works well here is that apparently-nonempty often
* means soon-to-be-stealable, which gives threads a chance to
* activate if necessary before stealing (see below).
*
* This approach also enables support for "async mode" where local
* task processing is in FIFO, not LIFO order; simply by using a
* version of deq rather than pop when locallyFifo is true (as set
* by the ForkJoinPool). This allows use in message-passing
* frameworks in which tasks are never joined.
*
* Efficient implementation of this approach currently relies on
* an uncomfortable amount of "Unsafe" mechanics. To maintain
* correct orderings, reads and writes of variable base require
* volatile ordering. Variable sp does not require volatile write
* but needs cheaper store-ordering on writes. Because they are
* protected by volatile base reads, reads of the queue array and
* its slots do not need volatile load semantics, but writes (in
* push) require store order and CASes (in pop and deq) require
* (volatile) CAS semantics. (See "Idempotent work stealing" by
* Michael, Saraswat, and Vechev, PPoPP 2009
* http://portal.acm.org/citation.cfm?id=1504186 for an algorithm
* with similar properties, but without support for nulling
* slots.) Since these combinations aren't supported using
* ordinary volatiles, the only way to accomplish these
* efficiently is to use direct Unsafe calls. (Using external
* AtomicIntegers and AtomicReferenceArrays for the indices and
* array is significantly slower because of memory locality and
* indirection effects.)
*
* Further, performance on most platforms is very sensitive to
* placement and sizing of the (resizable) queue array. Even
* though these queues don't usually become all that big, the
* initial size must be large enough to counteract cache
* contention effects across multiple queues (especially in the
* presence of GC cardmarking). Also, to improve thread-locality,
* queues are currently initialized immediately after the thread
* gets the initial signal to start processing tasks. However,
* all queue-related methods except pushTask are written in a way
* that allows them to instead be lazily allocated and/or disposed
* of when empty. All together, these low-level implementation
* choices produce as much as a factor of 4 performance
* improvement compared to naive implementations, and enable the
* processing of billions of tasks per second, sometimes at the
* expense of ugliness.
*
* 2. Run control: The primary run control is based on a global
* counter (activeCount) held by the pool. It uses an algorithm
* similar to that in Herlihy and Shavit section 17.6 to cause
* threads to eventually block when all threads declare they are
* inactive. For this to work, threads must be declared active
* when executing tasks, and before stealing a task. They must be
* inactive before blocking on the Pool Barrier (awaiting a new
* submission or other Pool event). In between, there is some free
* play which we take advantage of to avoid contention and rapid
* flickering of the global activeCount: If inactive, we activate
* only if a victim queue appears to be nonempty (see above).
* Similarly, a thread tries to inactivate only after a full scan
* of other threads. The net effect is that contention on
* activeCount is rarely a measurable performance issue. (There
* are also a few other cases where we scan for work rather than
* retry/block upon contention.)
*
* 3. Selection control. We maintain policy of always choosing to
* run local tasks rather than stealing, and always trying to
* steal tasks before trying to run a new submission. All steals
* are currently performed in randomly-chosen deq-order. It may be
* worthwhile to bias these with locality / anti-locality
* information, but doing this well probably requires more
* lower-level information from JVMs than currently provided.
*/
/**
* Capacity of work-stealing queue array upon initialization.
* Must be a power of two. Initial size must be at least 2, but is
* padded to minimize cache effects.
*/
private static final int INITIAL_QUEUE_CAPACITY = 1 << 13;
/**
* Maximum work-stealing queue array size. Must be less than or
* equal to 1 << 28 to ensure lack of index wraparound. (This
* is less than usual bounds, because we need leftshift by 3
* to be in int range).
*/
private static final int MAXIMUM_QUEUE_CAPACITY = 1 << 28;
/**
* The pool this thread works in. Accessed directly by ForkJoinTask.
*/
final ForkJoinPool pool;
/**
* The work-stealing queue array. Size must be a power of two.
* Initialized when thread starts, to improve memory locality.
*/
private ForkJoinTask<?>[] queue;
/**
* Index (mod queue.length) of next queue slot to push to or pop
* from. It is written only by owner thread, via ordered store.
* Both sp and base are allowed to wrap around on overflow, but
* (sp - base) still estimates size.
*/
private volatile int sp;
/**
* Index (mod queue.length) of least valid queue slot, which is
* always the next position to steal from if nonempty.
*/
private volatile int base;
/**
* Activity status. When true, this worker is considered active.
* Must be false upon construction. It must be true when executing
* tasks, and BEFORE stealing a task. It must be false before
* calling pool.sync.
*/
private boolean active;
/**
* Run state of this worker. Supports simple versions of the usual
* shutdown/shutdownNow control.
*/
private volatile int runState;
/**
* Seed for random number generator for choosing steal victims.
* Uses Marsaglia xorshift. Must be nonzero upon initialization.
*/
private int seed;
/**
* Number of steals, transferred to pool when idle
*/
private int stealCount;
/**
* Index of this worker in pool array. Set once by pool before
* running, and accessed directly by pool during cleanup etc.
*/
int poolIndex;
/**
* The last barrier event waited for. Accessed in pool callback
* methods, but only by current thread.
*/
long lastEventCount;
/**
* True if use local fifo, not default lifo, for local polling
*/
private boolean locallyFifo;
/**
* Creates a ForkJoinWorkerThread operating in the given pool.
*
* @param pool the pool this thread works in
* @throws NullPointerException if pool is null
*/
protected ForkJoinWorkerThread(ForkJoinPool pool) {
if (pool == null) throw new NullPointerException();
this.pool = pool;
// Note: poolIndex is set by pool during construction
// Remaining initialization is deferred to onStart
}
// Public access methods
/**
* Returns the pool hosting this thread.
*
* @return the pool
*/
public ForkJoinPool getPool() {
return pool;
}
/**
* Returns the index number of this thread in its pool. The
* returned value ranges from zero to the maximum number of
* threads (minus one) that have ever been created in the pool.
* This method may be useful for applications that track status or
* collect results per-worker rather than per-task.
*
* @return the index number
*/
public int getPoolIndex() {
return poolIndex;
}
/**
* Establishes local first-in-first-out scheduling mode for forked
* tasks that are never joined.
*
* @param async if true, use locally FIFO scheduling
*/
void setAsyncMode(boolean async) {
locallyFifo = async;
}
// Runstate management
// Runstate values. Order matters
private static final int RUNNING = 0;
private static final int SHUTDOWN = 1;
private static final int TERMINATING = 2;
private static final int TERMINATED = 3;
final boolean isShutdown() { return runState >= SHUTDOWN; }
final boolean isTerminating() { return runState >= TERMINATING; }
final boolean isTerminated() { return runState == TERMINATED; }
final boolean shutdown() { return transitionRunStateTo(SHUTDOWN); }
final boolean shutdownNow() { return transitionRunStateTo(TERMINATING); }
/**
* Transitions to at least the given state.
*
* @return {@code true} if not already at least at given state
*/
private boolean transitionRunStateTo(int state) {
for (;;) {
int s = runState;
if (s >= state)
return false;
if (UNSAFE.compareAndSwapInt(this, runStateOffset, s, state))
return true;
}
}
/**
* Tries to set status to active; fails on contention.
*/
private boolean tryActivate() {
if (!active) {
if (!pool.tryIncrementActiveCount())
return false;
active = true;
}
return true;
}
/**
* Tries to set status to inactive; fails on contention.
*/
private boolean tryInactivate() {
if (active) {
if (!pool.tryDecrementActiveCount())
return false;
active = false;
}
return true;
}
/**
* Computes next value for random victim probe. Scans don't
* require a very high quality generator, but also not a crummy
* one. Marsaglia xor-shift is cheap and works well.
*/
private static int xorShift(int r) {
r ^= (r << 13);
r ^= (r >>> 17);
return r ^ (r << 5);
}
// Lifecycle methods
/**
* This method is required to be public, but should never be
* called explicitly. It performs the main run loop to execute
* ForkJoinTasks.
*/
public void run() {
Throwable exception = null;
try {
onStart();
pool.sync(this); // await first pool event
mainLoop();
} catch (Throwable ex) {
exception = ex;
} finally {
onTermination(exception);
}
}
/**
* Executes tasks until shut down.
*/
private void mainLoop() {
while (!isShutdown()) {
ForkJoinTask<?> t = pollTask();
if (t != null || (t = pollSubmission()) != null)
t.quietlyExec();
else if (tryInactivate())
pool.sync(this);
}
}
/**
* Initializes internal state after construction but before
* processing any tasks. If you override this method, you must
* invoke super.onStart() at the beginning of the method.
* Initialization requires care: Most fields must have legal
* default values, to ensure that attempted accesses from other
* threads work correctly even before this thread starts
* processing tasks.
*/
protected void onStart() {
// Allocate while starting to improve chances of thread-local
// isolation
queue = new ForkJoinTask<?>[INITIAL_QUEUE_CAPACITY];
// Initial value of seed need not be especially random but
// should differ across workers and must be nonzero
int p = poolIndex + 1;
seed = p + (p << 8) + (p << 16) + (p << 24); // spread bits
}
/**
* Performs cleanup associated with termination of this worker
* thread. If you override this method, you must invoke
* {@code super.onTermination} at the end of the overridden method.
*
* @param exception the exception causing this thread to abort due
* to an unrecoverable error, or {@code null} if completed normally
*/
protected void onTermination(Throwable exception) {
// Execute remaining local tasks unless aborting or terminating
while (exception == null && pool.isProcessingTasks() && base != sp) {
try {
ForkJoinTask<?> t = popTask();
if (t != null)
t.quietlyExec();
} catch (Throwable ex) {
exception = ex;
}
}
// Cancel other tasks, transition status, notify pool, and
// propagate exception to uncaught exception handler
try {
do {} while (!tryInactivate()); // ensure inactive
cancelTasks();
runState = TERMINATED;
pool.workerTerminated(this);
} catch (Throwable ex) { // Shouldn't ever happen
if (exception == null) // but if so, at least rethrown
exception = ex;
} finally {
if (exception != null)
ForkJoinTask.rethrowException(exception);
}
}
// Intrinsics-based support for queue operations.
private static long slotOffset(int i) {
return ((long) i << qShift) + qBase;
}
/**
* Adds in store-order the given task at given slot of q to null.
* Caller must ensure q is non-null and index is in range.
*/
private static void setSlot(ForkJoinTask<?>[] q, int i,
ForkJoinTask<?> t) {
UNSAFE.putOrderedObject(q, slotOffset(i), t);
}
/**
* CAS given slot of q to null. Caller must ensure q is non-null
* and index is in range.
*/
private static boolean casSlotNull(ForkJoinTask<?>[] q, int i,
ForkJoinTask<?> t) {
return UNSAFE.compareAndSwapObject(q, slotOffset(i), t, null);
}
/**
* Sets sp in store-order.
*/
private void storeSp(int s) {
UNSAFE.putOrderedInt(this, spOffset, s);
}
// Main queue methods
/**
* Pushes a task. Called only by current thread.
*
* @param t the task. Caller must ensure non-null.
*/
final void pushTask(ForkJoinTask<?> t) {
ForkJoinTask<?>[] q = queue;
int mask = q.length - 1;
int s = sp;
setSlot(q, s & mask, t);
storeSp(++s);
if ((s -= base) == 1)
pool.signalWork();
else if (s >= mask)
growQueue();
}
/**
* Tries to take a task from the base of the queue, failing if
* either empty or contended.
*
* @return a task, or null if none or contended
*/
final ForkJoinTask<?> deqTask() {
ForkJoinTask<?> t;
ForkJoinTask<?>[] q;
int i;
int b;
if (sp != (b = base) &&
(q = queue) != null && // must read q after b
(t = q[i = (q.length - 1) & b]) != null &&
casSlotNull(q, i, t)) {
base = b + 1;
return t;
}
return null;
}
/**
* Tries to take a task from the base of own queue, activating if
* necessary, failing only if empty. Called only by current thread.
*
* @return a task, or null if none
*/
final ForkJoinTask<?> locallyDeqTask() {
int b;
while (sp != (b = base)) {
if (tryActivate()) {
ForkJoinTask<?>[] q = queue;
int i = (q.length - 1) & b;
ForkJoinTask<?> t = q[i];
if (t != null && casSlotNull(q, i, t)) {
base = b + 1;
return t;
}
}
}
return null;
}
/**
* Returns a popped task, or null if empty. Ensures active status
* if non-null. Called only by current thread.
*/
final ForkJoinTask<?> popTask() {
int s = sp;
while (s != base) {
if (tryActivate()) {
ForkJoinTask<?>[] q = queue;
int mask = q.length - 1;
int i = (s - 1) & mask;
ForkJoinTask<?> t = q[i];
if (t == null || !casSlotNull(q, i, t))
break;
storeSp(s - 1);
return t;
}
}
return null;
}
/**
* Specialized version of popTask to pop only if
* topmost element is the given task. Called only
* by current thread while active.
*
* @param t the task. Caller must ensure non-null.
*/
final boolean unpushTask(ForkJoinTask<?> t) {
ForkJoinTask<?>[] q = queue;
int mask = q.length - 1;
int s = sp - 1;
if (casSlotNull(q, s & mask, t)) {
storeSp(s);
return true;
}
return false;
}
/**
* Returns next task or null if empty or contended
*/
final ForkJoinTask<?> peekTask() {
ForkJoinTask<?>[] q = queue;
if (q == null)
return null;
int mask = q.length - 1;
int i = locallyFifo ? base : (sp - 1);
return q[i & mask];
}
/**
* Doubles queue array size. Transfers elements by emulating
* steals (deqs) from old array and placing, oldest first, into
* new array.
*/
private void growQueue() {
ForkJoinTask<?>[] oldQ = queue;
int oldSize = oldQ.length;
int newSize = oldSize << 1;
if (newSize > MAXIMUM_QUEUE_CAPACITY)
throw new RejectedExecutionException("Queue capacity exceeded");
ForkJoinTask<?>[] newQ = queue = new ForkJoinTask<?>[newSize];
int b = base;
int bf = b + oldSize;
int oldMask = oldSize - 1;
int newMask = newSize - 1;
do {
int oldIndex = b & oldMask;
ForkJoinTask<?> t = oldQ[oldIndex];
if (t != null && !casSlotNull(oldQ, oldIndex, t))
t = null;
setSlot(newQ, b & newMask, t);
} while (++b != bf);
pool.signalWork();
}
/**
* Tries to steal a task from another worker. Starts at a random
* index of workers array, and probes workers until finding one
* with non-empty queue or finding that all are empty. It
* randomly selects the first n probes. If these are empty, it
* resorts to a full circular traversal, which is necessary to
* accurately set active status by caller. Also restarts if pool
* events occurred since last scan, which forces refresh of
* workers array, in case barrier was associated with resize.
*
* This method must be both fast and quiet -- usually avoiding
* memory accesses that could disrupt cache sharing etc other than
* those needed to check for and take tasks. This accounts for,
* among other things, updating random seed in place without
* storing it until exit.
*
* @return a task, or null if none found
*/
private ForkJoinTask<?> scan() {
ForkJoinTask<?> t = null;
int r = seed; // extract once to keep scan quiet
ForkJoinWorkerThread[] ws; // refreshed on outer loop
int mask; // must be power 2 minus 1 and > 0
outer:do {
if ((ws = pool.workers) != null && (mask = ws.length - 1) > 0) {
int idx = r;
int probes = ~mask; // use random index while negative
for (;;) {
r = xorShift(r); // update random seed
ForkJoinWorkerThread v = ws[mask & idx];
if (v == null || v.sp == v.base) {
if (probes <= mask)
idx = (probes++ < 0) ? r : (idx + 1);
else
break;
}
else if (!tryActivate() || (t = v.deqTask()) == null)
continue outer; // restart on contention
else
break outer;
}
}
} while (pool.hasNewSyncEvent(this)); // retry on pool events
seed = r;
return t;
}
/**
* Gets and removes a local or stolen task.
*
* @return a task, if available
*/
final ForkJoinTask<?> pollTask() {
ForkJoinTask<?> t = locallyFifo ? locallyDeqTask() : popTask();
if (t == null && (t = scan()) != null)
++stealCount;
return t;
}
/**
* Gets a local task.
*
* @return a task, if available
*/
final ForkJoinTask<?> pollLocalTask() {
return locallyFifo ? locallyDeqTask() : popTask();
}
/**
* Returns a pool submission, if one exists, activating first.
*
* @return a submission, if available
*/
private ForkJoinTask<?> pollSubmission() {
ForkJoinPool p = pool;
while (p.hasQueuedSubmissions()) {
ForkJoinTask<?> t;
if (tryActivate() && (t = p.pollSubmission()) != null)
return t;
}
return null;
}
// Methods accessed only by Pool
/**
* Removes and cancels all tasks in queue. Can be called from any
* thread.
*/
final void cancelTasks() {
ForkJoinTask<?> t;
while (base != sp && (t = deqTask()) != null)
t.cancelIgnoringExceptions();
}
/**
* Drains tasks to given collection c.
*
* @return the number of tasks drained
*/
final int drainTasksTo(Collection<? super ForkJoinTask<?>> c) {
int n = 0;
ForkJoinTask<?> t;
while (base != sp && (t = deqTask()) != null) {
c.add(t);
++n;
}
return n;
}
/**
* Gets and clears steal count for accumulation by pool. Called
* only when known to be idle (in pool.sync and termination).
*/
final int getAndClearStealCount() {
int sc = stealCount;
stealCount = 0;
return sc;
}
/**
* Returns {@code true} if at least one worker in the given array
* appears to have at least one queued task.
*
* @param ws array of workers
*/
static boolean hasQueuedTasks(ForkJoinWorkerThread[] ws) {
if (ws != null) {
int len = ws.length;
for (int j = 0; j < 2; ++j) { // need two passes for clean sweep
for (int i = 0; i < len; ++i) {
ForkJoinWorkerThread w = ws[i];
if (w != null && w.sp != w.base)
return true;
}
}
}
return false;
}
// Support methods for ForkJoinTask
/**
* Returns an estimate of the number of tasks in the queue.
*/
final int getQueueSize() {
// suppress momentarily negative values
return Math.max(0, sp - base);
}
/**
* Returns an estimate of the number of tasks, offset by a
* function of number of idle workers.
*/
final int getEstimatedSurplusTaskCount() {
// The halving approximates weighting idle vs non-idle workers
return (sp - base) - (pool.getIdleThreadCount() >>> 1);
}
/**
* Scans, returning early if joinMe done.
*/
final ForkJoinTask<?> scanWhileJoining(ForkJoinTask<?> joinMe) {
ForkJoinTask<?> t = pollTask();
if (t != null && joinMe.status < 0 && sp == base) {
pushTask(t); // unsteal if done and this task would be stealable
t = null;
}
return t;
}
/**
* Runs tasks until {@code pool.isQuiescent()}.
*/
final void helpQuiescePool() {
for (;;) {
ForkJoinTask<?> t = pollTask();
if (t != null)
t.quietlyExec();
else if (tryInactivate() && pool.isQuiescent())
break;
}
do {} while (!tryActivate()); // re-activate on exit
}
// Unsafe mechanics
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
private static final long spOffset =
objectFieldOffset("sp", ForkJoinWorkerThread.class);
private static final long runStateOffset =
objectFieldOffset("runState", ForkJoinWorkerThread.class);
private static final long qBase;
private static final int qShift;
static {
qBase = UNSAFE.arrayBaseOffset(ForkJoinTask[].class);
int s = UNSAFE.arrayIndexScale(ForkJoinTask[].class);
if ((s & (s-1)) != 0)
throw new Error("data type scale not a power of two");
qShift = 31 - Integer.numberOfLeadingZeros(s);
}
private static long objectFieldOffset(String field, Class<?> klazz) {
try {
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
} catch (NoSuchFieldException e) {
// Convert Exception to corresponding Error
NoSuchFieldError error = new NoSuchFieldError(field);
error.initCause(e);
throw error;
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,179 @@
/*
* 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain
*/
package java.util.concurrent;
/**
* A recursive resultless {@link ForkJoinTask}. This class
* establishes conventions to parameterize resultless actions as
* {@code Void} {@code ForkJoinTask}s. Because {@code null} is the
* only valid value of type {@code Void}, methods such as join always
* return {@code null} upon completion.
*
* <p><b>Sample Usages.</b> Here is a sketch of a ForkJoin sort that
* sorts a given {@code long[]} array:
*
* <pre> {@code
* class SortTask extends RecursiveAction {
* final long[] array; final int lo; final int hi;
* SortTask(long[] array, int lo, int hi) {
* this.array = array; this.lo = lo; this.hi = hi;
* }
* protected void compute() {
* if (hi - lo < THRESHOLD)
* sequentiallySort(array, lo, hi);
* else {
* int mid = (lo + hi) >>> 1;
* invokeAll(new SortTask(array, lo, mid),
* new SortTask(array, mid, hi));
* merge(array, lo, hi);
* }
* }
* }}</pre>
*
* You could then sort {@code anArray} by creating {@code new
* SortTask(anArray, 0, anArray.length-1) } and invoking it in a
* ForkJoinPool. As a more concrete simple example, the following
* task increments each element of an array:
* <pre> {@code
* class IncrementTask extends RecursiveAction {
* final long[] array; final int lo; final int hi;
* IncrementTask(long[] array, int lo, int hi) {
* this.array = array; this.lo = lo; this.hi = hi;
* }
* protected void compute() {
* if (hi - lo < THRESHOLD) {
* for (int i = lo; i < hi; ++i)
* array[i]++;
* }
* else {
* int mid = (lo + hi) >>> 1;
* invokeAll(new IncrementTask(array, lo, mid),
* new IncrementTask(array, mid, hi));
* }
* }
* }}</pre>
*
* <p>The following example illustrates some refinements and idioms
* that may lead to better performance: RecursiveActions need not be
* fully recursive, so long as they maintain the basic
* divide-and-conquer approach. Here is a class that sums the squares
* of each element of a double array, by subdividing out only the
* right-hand-sides of repeated divisions by two, and keeping track of
* them with a chain of {@code next} references. It uses a dynamic
* threshold based on method {@code getSurplusQueuedTaskCount}, but
* counterbalances potential excess partitioning by directly
* performing leaf actions on unstolen tasks rather than further
* subdividing.
*
* <pre> {@code
* double sumOfSquares(ForkJoinPool pool, double[] array) {
* int n = array.length;
* Applyer a = new Applyer(array, 0, n, null);
* pool.invoke(a);
* return a.result;
* }
*
* class Applyer extends RecursiveAction {
* final double[] array;
* final int lo, hi;
* double result;
* Applyer next; // keeps track of right-hand-side tasks
* Applyer(double[] array, int lo, int hi, Applyer next) {
* this.array = array; this.lo = lo; this.hi = hi;
* this.next = next;
* }
*
* double atLeaf(int l, int h) {
* double sum = 0;
* for (int i = l; i < h; ++i) // perform leftmost base step
* sum += array[i] * array[i];
* return sum;
* }
*
* protected void compute() {
* int l = lo;
* int h = hi;
* Applyer right = null;
* while (h - l > 1 && getSurplusQueuedTaskCount() <= 3) {
* int mid = (l + h) >>> 1;
* right = new Applyer(array, mid, h, right);
* right.fork();
* h = mid;
* }
* double sum = atLeaf(l, h);
* while (right != null) {
* if (right.tryUnfork()) // directly calculate if not stolen
* sum += right.atLeaf(right.lo, right.hi);
* else {
* right.helpJoin();
* sum += right.result;
* }
* right = right.next;
* }
* result = sum;
* }
* }}</pre>
*
* @since 1.7
* @author Doug Lea
*/
public abstract class RecursiveAction extends ForkJoinTask<Void> {
private static final long serialVersionUID = 5232453952276485070L;
/**
* The main computation performed by this task.
*/
protected abstract void compute();
/**
* Always returns null.
*/
public final Void getRawResult() { return null; }
/**
* Requires null completion value.
*/
protected final void setRawResult(Void mustBeNull) { }
/**
* Implements execution conventions for RecursiveActions.
*/
protected final boolean exec() {
compute();
return true;
}
}

View File

@ -0,0 +1,97 @@
/*
* 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain
*/
package java.util.concurrent;
/**
* A recursive result-bearing {@link ForkJoinTask}.
*
* <p>For a classic example, here is a task computing Fibonacci numbers:
*
* <pre> {@code
* class Fibonacci extends RecursiveTask<Integer> {
* final int n;
* Fibonacci(int n) { this.n = n; }
* Integer compute() {
* if (n <= 1)
* return n;
* Fibonacci f1 = new Fibonacci(n - 1);
* f1.fork();
* Fibonacci f2 = new Fibonacci(n - 2);
* return f2.compute() + f1.join();
* }
* }}</pre>
*
* However, besides being a dumb way to compute Fibonacci functions
* (there is a simple fast linear algorithm that you'd use in
* practice), this is likely to perform poorly because the smallest
* subtasks are too small to be worthwhile splitting up. Instead, as
* is the case for nearly all fork/join applications, you'd pick some
* minimum granularity size (for example 10 here) for which you always
* sequentially solve rather than subdividing.
*
* @since 1.7
* @author Doug Lea
*/
public abstract class RecursiveTask<V> extends ForkJoinTask<V> {
private static final long serialVersionUID = 5232453952276485270L;
/**
* The result of the computation.
*/
V result;
/**
* The main computation performed by this task.
*/
protected abstract V compute();
public final V getRawResult() {
return result;
}
protected final void setRawResult(V value) {
result = value;
}
/**
* Implements execution conventions for RecursiveTask.
*/
protected final boolean exec() {
result = compute();
return true;
}
}

View File

@ -61,6 +61,14 @@ import java.util.*;
* causes tasks to be immediately removed from the work queue at
* time of cancellation.
*
* <p>Successive executions of a task scheduled via
* <code>scheduleAtFixedRate</code> or
* <code>scheduleWithFixedDelay</code> do not overlap. While different
* executions may be performed by different threads, the effects of
* prior executions <a
* href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
* those of subsequent ones.
*
* <p>While this class inherits from {@link ThreadPoolExecutor}, a few
* of the inherited tuning methods are not useful for it. In
* particular, because it acts as a fixed-sized pool using

View File

@ -0,0 +1,228 @@
/*
* 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain
*/
package java.util.concurrent;
import java.util.Random;
/**
* A random number generator isolated to the current thread. Like the
* global {@link java.util.Random} generator used by the {@link
* java.lang.Math} class, a {@code ThreadLocalRandom} is initialized
* with an internally generated seed that may not otherwise be
* modified. When applicable, use of {@code ThreadLocalRandom} rather
* than shared {@code Random} objects in concurrent programs will
* typically encounter much less overhead and contention. Use of
* {@code ThreadLocalRandom} is particularly appropriate when multiple
* tasks (for example, each a {@link ForkJoinTask}) use random numbers
* in parallel in thread pools.
*
* <p>Usages of this class should typically be of the form:
* {@code ThreadLocalRandom.current().nextX(...)} (where
* {@code X} is {@code Int}, {@code Long}, etc).
* When all usages are of this form, it is never possible to
* accidently share a {@code ThreadLocalRandom} across multiple threads.
*
* <p>This class also provides additional commonly used bounded random
* generation methods.
*
* @since 1.7
* @author Doug Lea
*/
public class ThreadLocalRandom extends Random {
// same constants as Random, but must be redeclared because private
private final static long multiplier = 0x5DEECE66DL;
private final static long addend = 0xBL;
private final static long mask = (1L << 48) - 1;
/**
* The random seed. We can't use super.seed.
*/
private long rnd;
/**
* Initialization flag to permit the first and only allowed call
* to setSeed (inside Random constructor) to succeed. We can't
* allow others since it would cause setting seed in one part of a
* program to unintentionally impact other usages by the thread.
*/
boolean initialized;
// Padding to help avoid memory contention among seed updates in
// different TLRs in the common case that they are located near
// each other.
private long pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7;
/**
* The actual ThreadLocal
*/
private static final ThreadLocal<ThreadLocalRandom> localRandom =
new ThreadLocal<ThreadLocalRandom>() {
protected ThreadLocalRandom initialValue() {
return new ThreadLocalRandom();
}
};
/**
* Constructor called only by localRandom.initialValue.
* We rely on the fact that the superclass no-arg constructor
* invokes setSeed exactly once to initialize.
*/
ThreadLocalRandom() {
super();
}
/**
* Returns the current thread's {@code ThreadLocalRandom}.
*
* @return the current thread's {@code ThreadLocalRandom}
*/
public static ThreadLocalRandom current() {
return localRandom.get();
}
/**
* Throws {@code UnsupportedOperationException}. Setting seeds in
* this generator is not supported.
*
* @throws UnsupportedOperationException always
*/
public void setSeed(long seed) {
if (initialized)
throw new UnsupportedOperationException();
initialized = true;
rnd = (seed ^ multiplier) & mask;
}
protected int next(int bits) {
rnd = (rnd * multiplier + addend) & mask;
return (int) (rnd >>> (48-bits));
}
/**
* Returns a pseudorandom, uniformly distributed value between the
* given least value (inclusive) and bound (exclusive).
*
* @param least the least value returned
* @param bound the upper bound (exclusive)
* @throws IllegalArgumentException if least greater than or equal
* to bound
* @return the next value
*/
public int nextInt(int least, int bound) {
if (least >= bound)
throw new IllegalArgumentException();
return nextInt(bound - least) + least;
}
/**
* Returns a pseudorandom, uniformly distributed value
* between 0 (inclusive) and the specified value (exclusive).
*
* @param n the bound on the random number to be returned. Must be
* positive.
* @return the next value
* @throws IllegalArgumentException if n is not positive
*/
public long nextLong(long n) {
if (n <= 0)
throw new IllegalArgumentException("n must be positive");
// Divide n by two until small enough for nextInt. On each
// iteration (at most 31 of them but usually much less),
// randomly choose both whether to include high bit in result
// (offset) and whether to continue with the lower vs upper
// half (which makes a difference only if odd).
long offset = 0;
while (n >= Integer.MAX_VALUE) {
int bits = next(2);
long half = n >>> 1;
long nextn = ((bits & 2) == 0) ? half : n - half;
if ((bits & 1) == 0)
offset += n - nextn;
n = nextn;
}
return offset + nextInt((int) n);
}
/**
* Returns a pseudorandom, uniformly distributed value between the
* given least value (inclusive) and bound (exclusive).
*
* @param least the least value returned
* @param bound the upper bound (exclusive)
* @return the next value
* @throws IllegalArgumentException if least greater than or equal
* to bound
*/
public long nextLong(long least, long bound) {
if (least >= bound)
throw new IllegalArgumentException();
return nextLong(bound - least) + least;
}
/**
* Returns a pseudorandom, uniformly distributed {@code double} value
* between 0 (inclusive) and the specified value (exclusive).
*
* @param n the bound on the random number to be returned. Must be
* positive.
* @return the next value
* @throws IllegalArgumentException if n is not positive
*/
public double nextDouble(double n) {
if (n <= 0)
throw new IllegalArgumentException("n must be positive");
return nextDouble() * n;
}
/**
* Returns a pseudorandom, uniformly distributed value between the
* given least value (inclusive) and bound (exclusive).
*
* @param least the least value returned
* @param bound the upper bound (exclusive)
* @return the next value
* @throws IllegalArgumentException if least greater than or equal
* to bound
*/
public double nextDouble(double least, double bound) {
if (least >= bound)
throw new IllegalArgumentException();
return nextDouble() * (bound - least) + least;
}
private static final long serialVersionUID = -5851777807851030925L;
}

View File

@ -0,0 +1,161 @@
/*
* 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* This file is available under and governed by the GNU General Public
* License version 2 only, as published by the Free Software Foundation.
* However, the following notice accompanied the original version of this
* file:
*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain
*/
package java.util.concurrent;
/**
* A {@link BlockingQueue} in which producers may wait for consumers
* to receive elements. A {@code TransferQueue} may be useful for
* example in message passing applications in which producers
* sometimes (using method {@link #transfer}) await receipt of
* elements by consumers invoking {@code take} or {@code poll}, while
* at other times enqueue elements (via method {@code put}) without
* waiting for receipt.
* {@linkplain #tryTransfer(Object) Non-blocking} and
* {@linkplain #tryTransfer(Object,long,TimeUnit) time-out} versions of
* {@code tryTransfer} are also available.
* A {@code TransferQueue} may also be queried, via {@link
* #hasWaitingConsumer}, whether there are any threads waiting for
* items, which is a converse analogy to a {@code peek} operation.
*
* <p>Like other blocking queues, a {@code TransferQueue} may be
* capacity bounded. If so, an attempted transfer operation may
* initially block waiting for available space, and/or subsequently
* block waiting for reception by a consumer. Note that in a queue
* with zero capacity, such as {@link SynchronousQueue}, {@code put}
* and {@code transfer} are effectively synonymous.
*
* <p>This interface is a member of the
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>.
*
* @since 1.7
* @author Doug Lea
* @param <E> the type of elements held in this collection
*/
public interface TransferQueue<E> extends BlockingQueue<E> {
/**
* Transfers the element to a waiting consumer immediately, if possible.
*
* <p>More precisely, transfers the specified element immediately
* if there exists a consumer already waiting to receive it (in
* {@link #take} or timed {@link #poll(long,TimeUnit) poll}),
* otherwise returning {@code false} without enqueuing the element.
*
* @param e the element to transfer
* @return {@code true} if the element was transferred, else
* {@code false}
* @throws ClassCastException if the class of the specified element
* prevents it from being added to this queue
* @throws NullPointerException if the specified element is null
* @throws IllegalArgumentException if some property of the specified
* element prevents it from being added to this queue
*/
boolean tryTransfer(E e);
/**
* Transfers the element to a consumer, waiting if necessary to do so.
*
* <p>More precisely, transfers the specified element immediately
* if there exists a consumer already waiting to receive it (in
* {@link #take} or timed {@link #poll(long,TimeUnit) poll}),
* else waits until the element is received by a consumer.
*
* @param e the element to transfer
* @throws InterruptedException if interrupted while waiting,
* in which case the element is not left enqueued
* @throws ClassCastException if the class of the specified element
* prevents it from being added to this queue
* @throws NullPointerException if the specified element is null
* @throws IllegalArgumentException if some property of the specified
* element prevents it from being added to this queue
*/
void transfer(E e) throws InterruptedException;
/**
* Transfers the element to a consumer if it is possible to do so
* before the timeout elapses.
*
* <p>More precisely, transfers the specified element immediately
* if there exists a consumer already waiting to receive it (in
* {@link #take} or timed {@link #poll(long,TimeUnit) poll}),
* else waits until the element is received by a consumer,
* returning {@code false} if the specified wait time elapses
* before the element can be transferred.
*
* @param e the element to transfer
* @param timeout how long to wait before giving up, in units of
* {@code unit}
* @param unit a {@code TimeUnit} determining how to interpret the
* {@code timeout} parameter
* @return {@code true} if successful, or {@code false} if
* the specified waiting time elapses before completion,
* in which case the element is not left enqueued
* @throws InterruptedException if interrupted while waiting,
* in which case the element is not left enqueued
* @throws ClassCastException if the class of the specified element
* prevents it from being added to this queue
* @throws NullPointerException if the specified element is null
* @throws IllegalArgumentException if some property of the specified
* element prevents it from being added to this queue
*/
boolean tryTransfer(E e, long timeout, TimeUnit unit)
throws InterruptedException;
/**
* Returns {@code true} if there is at least one consumer waiting
* to receive an element via {@link #take} or
* timed {@link #poll(long,TimeUnit) poll}.
* The return value represents a momentary state of affairs.
*
* @return {@code true} if there is at least one waiting consumer
*/
boolean hasWaitingConsumer();
/**
* Returns an estimate of the number of consumers waiting to
* receive elements via {@link #take} or timed
* {@link #poll(long,TimeUnit) poll}. The return value is an
* approximation of a momentary state of affairs, that may be
* inaccurate if consumers have completed or given up waiting.
* The value may be useful for monitoring and heuristics, but
* not for synchronization control. Implementations of this
* method are likely to be noticeably slower than those for
* {@link #hasWaitingConsumer}.
*
* @return the number of consumers waiting to receive elements
*/
int getWaitingConsumerCount();
}

View File

@ -170,8 +170,8 @@ import java.util.Date;
* <p>As interruption generally implies cancellation, and checks for
* interruption are often infrequent, an implementation can favor responding
* to an interrupt over normal method return. This is true even if it can be
* shown that the interrupt occurred after another action may have unblocked
* the thread. An implementation should document this behavior.
* shown that the interrupt occurred after another action that may have
* unblocked the thread. An implementation should document this behavior.
*
* @since 1.5
* @author Doug Lea

View File

@ -92,6 +92,13 @@
* assists in coordinating the processing of groups of
* asynchronous tasks.
*
* <p>Class {@link java.util.concurrent.ForkJoinPool} provides an
* Executor primarily designed for processing instances of {@link
* java.util.concurrent.ForkJoinTask} and its subclasses. These
* classes employ a work-stealing scheduler that attains high
* throughput for tasks conforming to restrictions that often hold in
* computation-intensive parallel processing.
*
* <h2>Queues</h2>
*
* The {@link java.util.concurrent.ConcurrentLinkedQueue} class
@ -110,6 +117,12 @@
* for producer-consumer, messaging, parallel tasking, and
* related concurrent designs.
*
* <p> Extended interface {@link java.util.concurrent.TransferQueue},
* and implementation {@link java.util.concurrent.LinkedTransferQueue}
* introduce a synchronous {@code transfer} method (along with related
* features) in which a producer may optionally block awaiting its
* consumer.
*
* <p>The {@link java.util.concurrent.BlockingDeque} interface
* extends {@code BlockingQueue} to support both FIFO and LIFO
* (stack-based) operations.
@ -136,15 +149,28 @@
*
* <h2>Synchronizers</h2>
*
* Four classes aid common special-purpose synchronization idioms.
* {@link java.util.concurrent.Semaphore} is a classic concurrency tool.
* {@link java.util.concurrent.CountDownLatch} is a very simple yet very
* common utility for blocking until a given number of signals, events,
* or conditions hold. A {@link java.util.concurrent.CyclicBarrier} is a
* resettable multiway synchronization point useful in some styles of
* parallel programming. An {@link java.util.concurrent.Exchanger} allows
* two threads to exchange objects at a rendezvous point, and is useful
* in several pipeline designs.
* Five classes aid common special-purpose synchronization idioms.
* <ul>
*
* <li>{@link java.util.concurrent.Semaphore} is a classic concurrency tool.
*
* <li>{@link java.util.concurrent.CountDownLatch} is a very simple yet
* very common utility for blocking until a given number of signals,
* events, or conditions hold.
*
* <li>A {@link java.util.concurrent.CyclicBarrier} is a resettable
* multiway synchronization point useful in some styles of parallel
* programming.
*
* <li>A {@link java.util.concurrent.Phaser} provides
* a more flexible form of barrier that may be used to control phased
* computation among multiple threads.
*
* <li>An {@link java.util.concurrent.Exchanger} allows two threads to
* exchange objects at a rendezvous point, and is useful in several
* pipeline designs.
*
* </ul>
*
* <h2>Concurrent Collections</h2>
*
@ -259,7 +285,8 @@
* in each thread <i>happen-before</i> those subsequent to the
* corresponding {@code exchange()} in another thread.
*
* <li>Actions prior to calling {@code CyclicBarrier.await}
* <li>Actions prior to calling {@code CyclicBarrier.await} and
* {@code Phaser.awaitAdvance} (as well as its variants)
* <i>happen-before</i> actions performed by the barrier action, and
* actions performed by the barrier action <i>happen-before</i> actions
* subsequent to a successful return from the corresponding {@code await}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,10 +27,7 @@
package javax.swing;
import java.awt.event.*;
import java.applet.*;
import java.awt.*;
import java.io.Serializable;
import sun.swing.UIAction;
/**
* Manages all the <code>ToolTips</code> in the system.
@ -60,7 +57,7 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
JComponent insideComponent;
MouseEvent mouseEvent;
boolean showImmediately;
final static ToolTipManager sharedInstance = new ToolTipManager();
private static final Object TOOL_TIP_MANAGER_KEY = new Object();
transient Popup tipWindow;
/** The Window tip is being displayed in. This will be non-null if
* the Window tip is in differs from that of insideComponent's Window.
@ -345,7 +342,13 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
* @return a shared <code>ToolTipManager</code> object
*/
public static ToolTipManager sharedInstance() {
return sharedInstance;
Object value = SwingUtilities.appContextGet(TOOL_TIP_MANAGER_KEY);
if (value instanceof ToolTipManager) {
return (ToolTipManager) value;
}
ToolTipManager manager = new ToolTipManager();
SwingUtilities.appContextPut(TOOL_TIP_MANAGER_KEY, manager);
return manager;
}
// add keylistener here to trigger tip for access

View File

@ -1,5 +1,5 @@
/*
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. 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
@ -197,6 +197,8 @@ public class UIManager implements Serializable
Vector<LookAndFeel> auxLookAndFeels = null;
SwingPropertyChangeSupport changeSupport;
LookAndFeelInfo[] installedLAFs;
UIDefaults getLookAndFeelDefaults() { return tables[0]; }
void setLookAndFeelDefaults(UIDefaults x) { tables[0] = x; }
@ -227,18 +229,6 @@ public class UIManager implements Serializable
*/
private static final Object classLock = new Object();
/* Cache the last referenced LAFState to improve performance
* when accessing it. The cache is based on last thread rather
* than last AppContext because of the cost of looking up the
* AppContext each time. Since most Swing UI work is on the
* EventDispatchThread, this hits often enough to justify the
* overhead. (4193032)
*/
private static Thread currentLAFStateThread = null;
private static LAFState currentLAFState = null;
/**
* Return the <code>LAFState</code> object, lazily create one if necessary.
* All access to the <code>LAFState</code> fields is done via this method,
@ -248,13 +238,6 @@ public class UIManager implements Serializable
* </pre>
*/
private static LAFState getLAFState() {
// First check whether we're running on the same thread as
// the last request.
Thread thisThread = Thread.currentThread();
if (thisThread == currentLAFStateThread) {
return currentLAFState;
}
LAFState rv = (LAFState)SwingUtilities.appContextGet(
SwingUtilities2.LAF_STATE_KEY);
if (rv == null) {
@ -268,10 +251,6 @@ public class UIManager implements Serializable
}
}
}
currentLAFStateThread = thisThread;
currentLAFState = rv;
return rv;
}
@ -431,7 +410,10 @@ public class UIManager implements Serializable
*/
public static LookAndFeelInfo[] getInstalledLookAndFeels() {
maybeInitialize();
LookAndFeelInfo[] ilafs = installedLAFs;
LookAndFeelInfo[] ilafs = getLAFState().installedLAFs;
if (ilafs == null) {
ilafs = installedLAFs;
}
LookAndFeelInfo[] rv = new LookAndFeelInfo[ilafs.length];
System.arraycopy(ilafs, 0, rv, 0, ilafs.length);
return rv;
@ -453,9 +435,10 @@ public class UIManager implements Serializable
public static void setInstalledLookAndFeels(LookAndFeelInfo[] infos)
throws SecurityException
{
maybeInitialize();
LookAndFeelInfo[] newInfos = new LookAndFeelInfo[infos.length];
System.arraycopy(infos, 0, newInfos, 0, infos.length);
installedLAFs = newInfos;
getLAFState().installedLAFs = newInfos;
}
@ -1307,10 +1290,11 @@ public class UIManager implements Serializable
}
}
installedLAFs = new LookAndFeelInfo[ilafs.size()];
LookAndFeelInfo[] installedLAFs = new LookAndFeelInfo[ilafs.size()];
for(int i = 0; i < ilafs.size(); i++) {
installedLAFs[i] = ilafs.elementAt(i);
}
getLAFState().installedLAFs = installedLAFs;
}

View File

@ -26,6 +26,8 @@
package javax.swing.plaf.basic;
import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
import java.awt.*;
import java.awt.event.*;
import java.io.Serializable;
@ -44,9 +46,6 @@ import javax.swing.text.View;
* @author Jeff Dinkins
*/
public class BasicButtonUI extends ButtonUI{
// Shared UI object
private final static BasicButtonUI buttonUI = new BasicButtonUI();
// Visual constants
// NOTE: This is not used or set any where. Were we allowed to remove
// fields, this would be removed.
@ -61,10 +60,19 @@ public class BasicButtonUI extends ButtonUI{
private final static String propertyPrefix = "Button" + ".";
private static final Object BASIC_BUTTON_UI_KEY = new Object();
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
BasicButtonUI buttonUI =
(BasicButtonUI) appContext.get(BASIC_BUTTON_UI_KEY);
if (buttonUI == null) {
buttonUI = new BasicButtonUI();
appContext.put(BASIC_BUTTON_UI_KEY, buttonUI);
}
return buttonUI;
}

View File

@ -25,6 +25,8 @@
package javax.swing.plaf.basic;
import sun.awt.AppContext;
import javax.swing.*;
import java.awt.*;
@ -49,7 +51,7 @@ import java.io.Serializable;
*/
public class BasicCheckBoxUI extends BasicRadioButtonUI {
private final static BasicCheckBoxUI checkboxUI = new BasicCheckBoxUI();
private static final Object BASIC_CHECK_BOX_UI_KEY = new Object();
private final static String propertyPrefix = "CheckBox" + ".";
@ -57,6 +59,13 @@ public class BasicCheckBoxUI extends BasicRadioButtonUI {
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
BasicCheckBoxUI checkboxUI =
(BasicCheckBoxUI) appContext.get(BASIC_CHECK_BOX_UI_KEY);
if (checkboxUI == null) {
checkboxUI = new BasicCheckBoxUI();
appContext.put(BASIC_CHECK_BOX_UI_KEY, checkboxUI);
}
return checkboxUI;
}

View File

@ -28,6 +28,8 @@ package javax.swing.plaf.basic;
import sun.swing.SwingUtilities2;
import sun.swing.DefaultLookup;
import sun.swing.UIAction;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.text.View;
@ -63,7 +65,7 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
* name in defaults table under the key "LabelUI".
*/
protected static BasicLabelUI labelUI = new BasicLabelUI();
private final static BasicLabelUI SAFE_BASIC_LABEL_UI = new BasicLabelUI();
private static final Object BASIC_LABEL_UI_KEY = new Object();
private Rectangle paintIconR = new Rectangle();
private Rectangle paintTextR = new Rectangle();
@ -394,10 +396,16 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
public static ComponentUI createUI(JComponent c) {
if (System.getSecurityManager() != null) {
return SAFE_BASIC_LABEL_UI;
} else {
return labelUI;
AppContext appContext = AppContext.getAppContext();
BasicLabelUI safeBasicLabelUI =
(BasicLabelUI) appContext.get(BASIC_LABEL_UI_KEY);
if (safeBasicLabelUI == null) {
safeBasicLabelUI = new BasicLabelUI();
appContext.put(BASIC_LABEL_UI_KEY, safeBasicLabelUI);
}
return safeBasicLabelUI;
}
return labelUI;
}
public void propertyChange(PropertyChangeEvent e) {

View File

@ -32,6 +32,7 @@ import javax.swing.border.*;
import javax.swing.plaf.*;
import javax.swing.text.View;
import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
/**
@ -41,7 +42,7 @@ import sun.swing.SwingUtilities2;
*/
public class BasicRadioButtonUI extends BasicToggleButtonUI
{
private final static BasicRadioButtonUI radioButtonUI = new BasicRadioButtonUI();
private static final Object BASIC_RADIO_BUTTON_UI_KEY = new Object();
protected Icon icon;
@ -53,6 +54,13 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
BasicRadioButtonUI radioButtonUI =
(BasicRadioButtonUI) appContext.get(BASIC_RADIO_BUTTON_UI_KEY);
if (radioButtonUI == null) {
radioButtonUI = new BasicRadioButtonUI();
appContext.put(BASIC_RADIO_BUTTON_UI_KEY, radioButtonUI);
}
return radioButtonUI;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,14 +31,12 @@ import sun.swing.DefaultLookup;
import sun.swing.UIAction;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.peer.ComponentPeer;
import java.awt.peer.LightweightPeer;
import java.beans.*;
import java.util.*;
import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.SplitPaneUI;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
@ -106,13 +104,13 @@ public class BasicSplitPaneUI extends SplitPaneUI
* Keys to use for forward focus traversal when the JComponent is
* managing focus.
*/
private static Set<KeyStroke> managingFocusForwardTraversalKeys;
private Set<KeyStroke> managingFocusForwardTraversalKeys;
/**
* Keys to use for backward focus traversal when the JComponent is
* managing focus.
*/
private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
private Set<KeyStroke> managingFocusBackwardTraversalKeys;
/**
@ -675,7 +673,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
* @return increment via keyboard methods.
*/
int getKeyboardMoveIncrement() {
return KEYBOARD_DIVIDER_MOVE_OFFSET;
return 3;
}
/**

View File

@ -25,6 +25,8 @@
package javax.swing.plaf.basic;
import sun.awt.AppContext;
import java.awt.*;
import java.awt.event.*;
@ -43,7 +45,7 @@ import javax.swing.text.View;
*/
public class BasicToggleButtonUI extends BasicButtonUI {
private final static BasicToggleButtonUI toggleButtonUI = new BasicToggleButtonUI();
private static final Object BASIC_TOGGLE_BUTTON_UI_KEY = new Object();
private final static String propertyPrefix = "ToggleButton" + ".";
@ -51,6 +53,13 @@ public class BasicToggleButtonUI extends BasicButtonUI {
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
BasicToggleButtonUI toggleButtonUI =
(BasicToggleButtonUI) appContext.get(BASIC_TOGGLE_BUTTON_UI_KEY);
if (toggleButtonUI == null) {
toggleButtonUI = new BasicToggleButtonUI();
appContext.put(BASIC_TOGGLE_BUTTON_UI_KEY, toggleButtonUI);
}
return toggleButtonUI;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-2009 Sun Microsystems, Inc. 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,9 @@ package javax.swing.plaf.metal;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import sun.awt.AppContext;
/**
* Implements the bumps used throughout the Metal Look and Feel.
@ -49,19 +50,9 @@ class MetalBumps implements Icon {
protected Color shadowColor;
protected Color backColor;
protected static Vector<BumpBuffer> buffers = new Vector<BumpBuffer>();
private static final Object METAL_BUMPS = new Object();
protected BumpBuffer buffer;
public MetalBumps( Dimension bumpArea ) {
this( bumpArea.width, bumpArea.height );
}
public MetalBumps( int width, int height ) {
this(width, height, MetalLookAndFeel.getPrimaryControlHighlight(),
MetalLookAndFeel.getPrimaryControlDarkShadow(),
MetalLookAndFeel.getPrimaryControlShadow());
}
/**
* Creates MetalBumps of the specified size with the specified colors.
* If <code>newBackColor</code> is null, the background will be
@ -73,26 +64,22 @@ class MetalBumps implements Icon {
setBumpColors( newTopColor, newShadowColor, newBackColor );
}
private BumpBuffer getBuffer(GraphicsConfiguration gc, Color aTopColor,
Color aShadowColor, Color aBackColor) {
if (buffer != null && buffer.hasSameConfiguration(
gc, aTopColor, aShadowColor, aBackColor)) {
return buffer;
private static BumpBuffer createBuffer(GraphicsConfiguration gc,
Color topColor, Color shadowColor, Color backColor) {
AppContext context = AppContext.getAppContext();
List<BumpBuffer> buffers = (List<BumpBuffer>) context.get(METAL_BUMPS);
if (buffers == null) {
buffers = new ArrayList<BumpBuffer>();
context.put(METAL_BUMPS, buffers);
}
BumpBuffer result = null;
for (BumpBuffer aBuffer : buffers) {
if ( aBuffer.hasSameConfiguration(gc, aTopColor, aShadowColor,
aBackColor)) {
result = aBuffer;
break;
for (BumpBuffer buffer : buffers) {
if (buffer.hasSameConfiguration(gc, topColor, shadowColor, backColor)) {
return buffer;
}
}
if (result == null) {
result = new BumpBuffer(gc, topColor, shadowColor, backColor);
buffers.addElement(result);
}
return result;
BumpBuffer buffer = new BumpBuffer(gc, topColor, shadowColor, backColor);
buffers.add(buffer);
return buffer;
}
public void setBumpArea( Dimension bumpArea ) {
@ -119,10 +106,12 @@ class MetalBumps implements Icon {
GraphicsConfiguration gc = (g instanceof Graphics2D) ?
((Graphics2D) g).getDeviceConfiguration() : null;
buffer = getBuffer(gc, topColor, shadowColor, backColor);
if ((buffer == null) || !buffer.hasSameConfiguration(gc, topColor, shadowColor, backColor)) {
buffer = createBuffer(gc, topColor, shadowColor, backColor);
}
int bufferWidth = buffer.getImageSize().width;
int bufferHeight = buffer.getImageSize().height;
int bufferWidth = BumpBuffer.IMAGE_SIZE;
int bufferHeight = BumpBuffer.IMAGE_SIZE;
int iconWidth = getIconWidth();
int iconHeight = getIconHeight();
int x2 = x + iconWidth;
@ -155,7 +144,6 @@ class MetalBumps implements Icon {
class BumpBuffer {
static final int IMAGE_SIZE = 64;
static Dimension imageSize = new Dimension( IMAGE_SIZE, IMAGE_SIZE );
transient Image image;
Color topColor;
@ -197,10 +185,6 @@ class BumpBuffer {
return image;
}
public Dimension getImageSize() {
return imageSize;
}
/**
* Paints the bumps into the current image.
*/

View File

@ -26,6 +26,8 @@
package javax.swing.plaf.metal;
import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
@ -49,19 +51,25 @@ import javax.swing.plaf.*;
* @author Tom Santos
*/
public class MetalButtonUI extends BasicButtonUI {
private final static MetalButtonUI metalButtonUI = new MetalButtonUI();
// NOTE: These are not really needed, but at this point we can't pull
// them. Their values are updated purely for historical reasons.
protected Color focusColor;
protected Color selectColor;
protected Color disabledTextColor;
private static final Object METAL_BUTTON_UI_KEY = new Object();
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MetalButtonUI metalButtonUI =
(MetalButtonUI) appContext.get(METAL_BUTTON_UI_KEY);
if (metalButtonUI == null) {
metalButtonUI = new MetalButtonUI();
appContext.put(METAL_BUTTON_UI_KEY, metalButtonUI);
}
return metalButtonUI;
}

View File

@ -25,6 +25,8 @@
package javax.swing.plaf.metal;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.plaf.basic.BasicCheckBoxUI;
@ -55,7 +57,7 @@ public class MetalCheckBoxUI extends MetalRadioButtonUI {
// of BasicCheckBoxUI because we want to pick up all the
// painting changes made in MetalRadioButtonUI.
private final static MetalCheckBoxUI checkboxUI = new MetalCheckBoxUI();
private static final Object METAL_CHECK_BOX_UI_KEY = new Object();
private final static String propertyPrefix = "CheckBox" + ".";
@ -65,6 +67,13 @@ public class MetalCheckBoxUI extends MetalRadioButtonUI {
// Create PlAF
// ********************************
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
MetalCheckBoxUI checkboxUI =
(MetalCheckBoxUI) appContext.get(METAL_CHECK_BOX_UI_KEY);
if (checkboxUI == null) {
checkboxUI = new MetalCheckBoxUI();
appContext.put(METAL_CHECK_BOX_UI_KEY, checkboxUI);
}
return checkboxUI;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,10 +31,8 @@ import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
import java.util.EventListener;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import javax.swing.plaf.*;
/**
@ -51,7 +49,7 @@ public class MetalInternalFrameUI extends BasicInternalFrameUI {
private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0);
protected static String IS_PALETTE = "JInternalFrame.isPalette";
private static String IS_PALETTE_KEY = "JInternalFrame.isPalette";
private static String FRAME_TYPE = "JInternalFrame.frameType";
private static String NORMAL_FRAME = "normal";
private static String PALETTE_FRAME = "palette";
@ -68,7 +66,7 @@ public class MetalInternalFrameUI extends BasicInternalFrameUI {
public void installUI(JComponent c) {
super.installUI(c);
Object paletteProp = c.getClientProperty( IS_PALETTE );
Object paletteProp = c.getClientProperty(IS_PALETTE_KEY);
if ( paletteProp != null ) {
setPalette( ((Boolean)paletteProp).booleanValue() );
}
@ -187,7 +185,7 @@ public class MetalInternalFrameUI extends BasicInternalFrameUI {
ui.setFrameType( (String) e.getNewValue() );
}
}
else if ( name.equals( IS_PALETTE ) )
else if ( name.equals(IS_PALETTE_KEY) )
{
if ( e.getNewValue() != null )
{

View File

@ -26,6 +26,8 @@
package javax.swing.plaf.metal;
import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
@ -51,15 +53,21 @@ public class MetalLabelUI extends BasicLabelUI
* name in defaults table under the key "LabelUI".
*/
protected static MetalLabelUI metalLabelUI = new MetalLabelUI();
private final static MetalLabelUI SAFE_METAL_LABEL_UI = new MetalLabelUI();
private static final Object METAL_LABEL_UI_KEY = new Object();
public static ComponentUI createUI(JComponent c) {
if (System.getSecurityManager() != null) {
return SAFE_METAL_LABEL_UI;
} else {
return metalLabelUI;
AppContext appContext = AppContext.getAppContext();
MetalLabelUI safeMetalLabelUI =
(MetalLabelUI) appContext.get(METAL_LABEL_UI_KEY);
if (safeMetalLabelUI == null) {
safeMetalLabelUI = new MetalLabelUI();
appContext.put(METAL_LABEL_UI_KEY, safeMetalLabelUI);
}
return safeMetalLabelUI;
}
return metalLabelUI;
}
/**

View File

@ -26,6 +26,8 @@
package javax.swing.plaf.metal;
import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
@ -53,7 +55,7 @@ import javax.swing.text.View;
*/
public class MetalRadioButtonUI extends BasicRadioButtonUI {
private static final MetalRadioButtonUI metalRadioButtonUI = new MetalRadioButtonUI();
private static final Object METAL_RADIO_BUTTON_UI_KEY = new Object();
protected Color focusColor;
protected Color selectColor;
@ -65,6 +67,13 @@ public class MetalRadioButtonUI extends BasicRadioButtonUI {
// Create PlAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MetalRadioButtonUI metalRadioButtonUI =
(MetalRadioButtonUI) appContext.get(METAL_RADIO_BUTTON_UI_KEY);
if (metalRadioButtonUI == null) {
metalRadioButtonUI = new MetalRadioButtonUI();
appContext.put(METAL_RADIO_BUTTON_UI_KEY, metalRadioButtonUI);
}
return metalRadioButtonUI;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-2009 Sun Microsystems, Inc. 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
@ -54,12 +54,13 @@ public class MetalSliderUI extends BasicSliderUI {
protected final int TICK_BUFFER = 4;
protected boolean filledSlider = false;
// NOTE: these next three variables are currently unused.
// NOTE: these next five variables are currently unused.
protected static Color thumbColor;
protected static Color highlightColor;
protected static Color darkShadowColor;
protected static int trackWidth;
protected static int tickLength;
private int safeLength;
/**
* A default horizontal thumb <code>Icon</code>. This field might not be
@ -107,7 +108,7 @@ public class MetalSliderUI extends BasicSliderUI {
public void installUI( JComponent c ) {
trackWidth = ((Integer)UIManager.get( "Slider.trackWidth" )).intValue();
tickLength = ((Integer)UIManager.get( "Slider.majorTickLength" )).intValue();
tickLength = safeLength = ((Integer)UIManager.get( "Slider.majorTickLength" )).intValue();
horizThumbIcon = SAFE_HORIZ_THUMB_ICON =
UIManager.getIcon( "Slider.horizontalThumbIcon" );
vertThumbIcon = SAFE_VERT_THUMB_ICON =
@ -477,8 +478,8 @@ public class MetalSliderUI extends BasicSliderUI {
* determine the tick area rectangle.
*/
public int getTickLength() {
return slider.getOrientation() == JSlider.HORIZONTAL ? tickLength + TICK_BUFFER + 1 :
tickLength + TICK_BUFFER + 3;
return slider.getOrientation() == JSlider.HORIZONTAL ? safeLength + TICK_BUFFER + 1 :
safeLength + TICK_BUFFER + 3;
}
/**
@ -523,22 +524,22 @@ public class MetalSliderUI extends BasicSliderUI {
protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() );
g.drawLine( x, TICK_BUFFER, x, TICK_BUFFER + (tickLength / 2) );
g.drawLine( x, TICK_BUFFER, x, TICK_BUFFER + (safeLength / 2) );
}
protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() );
g.drawLine( x, TICK_BUFFER , x, TICK_BUFFER + (tickLength - 1) );
g.drawLine( x, TICK_BUFFER , x, TICK_BUFFER + (safeLength - 1) );
}
protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() );
if (MetalUtils.isLeftToRight(slider)) {
g.drawLine( TICK_BUFFER, y, TICK_BUFFER + (tickLength / 2), y );
g.drawLine( TICK_BUFFER, y, TICK_BUFFER + (safeLength / 2), y );
}
else {
g.drawLine( 0, y, tickLength/2, y );
g.drawLine( 0, y, safeLength/2, y );
}
}
@ -546,10 +547,10 @@ public class MetalSliderUI extends BasicSliderUI {
g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() );
if (MetalUtils.isLeftToRight(slider)) {
g.drawLine( TICK_BUFFER, y, TICK_BUFFER + tickLength, y );
g.drawLine( TICK_BUFFER, y, TICK_BUFFER + safeLength, y );
}
else {
g.drawLine( 0, y, tickLength, y );
g.drawLine( 0, y, safeLength, y );
}
}
}

View File

@ -26,6 +26,8 @@
package javax.swing.plaf.metal;
import sun.swing.SwingUtilities2;
import sun.awt.AppContext;
import java.awt.*;
import java.awt.event.*;
import java.lang.ref.*;
@ -55,7 +57,7 @@ import java.io.Serializable;
*/
public class MetalToggleButtonUI extends BasicToggleButtonUI {
private static final MetalToggleButtonUI metalToggleButtonUI = new MetalToggleButtonUI();
private static final Object METAL_TOGGLE_BUTTON_UI_KEY = new Object();
protected Color focusColor;
protected Color selectColor;
@ -67,6 +69,13 @@ public class MetalToggleButtonUI extends BasicToggleButtonUI {
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
MetalToggleButtonUI metalToggleButtonUI =
(MetalToggleButtonUI) appContext.get(METAL_TOGGLE_BUTTON_UI_KEY);
if (metalToggleButtonUI == null) {
metalToggleButtonUI = new MetalToggleButtonUI();
appContext.put(METAL_TOGGLE_BUTTON_UI_KEY, metalToggleButtonUI);
}
return metalToggleButtonUI;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1995-2009 Sun Microsystems, Inc. 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
@ -51,6 +51,7 @@ import java.security.Permission;
import java.security.PermissionCollection;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import sun.misc.IOUtils;
import sun.net.www.ParseUtil;
import sun.security.util.SecurityConstants;
@ -331,36 +332,7 @@ public class AppletClassLoader extends URLClassLoader {
byte[] b;
try {
if (len != -1) {
// Read exactly len bytes from the input stream
b = new byte[len];
while (len > 0) {
int n = in.read(b, b.length - len, len);
if (n == -1) {
throw new IOException("unexpected EOF");
}
len -= n;
}
} else {
// Read until end of stream is reached - use 8K buffer
// to speed up performance [stanleyh]
b = new byte[8192];
int total = 0;
while ((len = in.read(b, total, b.length - total)) != -1) {
total += len;
if (total >= b.length) {
byte[] tmp = new byte[total * 2];
System.arraycopy(b, 0, tmp, 0, total);
b = tmp;
}
}
// Trim array to correct size, if necessary
if (total != b.length) {
byte[] tmp = new byte[total];
System.arraycopy(b, 0, tmp, 0, total);
b = tmp;
}
}
b = IOUtils.readFully(in, len, true);
} finally {
in.close();
}

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