提交 51d946c6 编写于 作者: V vinnie

Merge

......@@ -49,3 +49,4 @@ b3f3240135f0c10b9f2481c174b81b7fcf0daa60 jdk7-b71
460639b036f327282832a4fe52b7aa45688afd50 jdk7-b72
f708138c9aca4b389872838fe6773872fce3609e jdk7-b73
eacb36e30327e7ae33baa068e82ddccbd91eaae2 jdk7-b74
8885b22565077236a927e824ef450742e434a230 jdk7-b75
......@@ -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)
#
......
......@@ -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
......
......@@ -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)
#
......
......@@ -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)
#
......
......@@ -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)
......
......@@ -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
......
......@@ -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 \
......
......@@ -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
#
......
......@@ -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)
......
......@@ -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)"'
此差异已折叠。
......@@ -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
......
......@@ -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
......
......@@ -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' \
......
......@@ -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)
......
......@@ -55,21 +55,25 @@ ifeq ($(PLATFORM), solaris)
endif # PLATFORM solaris
ifeq ($(ARCH), i586)
CPPFLAGS += -DX_ARCH=X_I586
endif # ARCH i586
ifeq ($(ARCH), sparc)
CPPFLAGS += -DX_ARCH=X_SPARC
endif # ARCH sparc
ifeq ($(ARCH), sparcv9)
CPPFLAGS += -DX_ARCH=X_SPARCV9
endif # ARCH sparcv9
ifeq ($(ARCH), amd64)
CPPFLAGS += -DX_ARCH=X_AMD64
endif # ARCH amd64
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), sparcv9)
CPPFLAGS += -DX_ARCH=X_SPARCV9
endif # ARCH sparcv9
ifeq ($(ARCH), amd64)
CPPFLAGS += -DX_ARCH=X_AMD64
endif # ARCH amd64
endif
# files needed for MIDI i/o
......
......@@ -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
#
# 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
......
......@@ -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
......
......@@ -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=\
......
......@@ -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"
......
......@@ -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;
......
......@@ -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;
......
......@@ -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' $< > $@
......
......@@ -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
......
......@@ -38,7 +38,6 @@ SUBDIRS = \
compile_properties \
dir_diff \
dtdbuilder \
fontchecker \
freetypecheck \
generate_break_iterator \
GenerateCharacter \
......
/*
* 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);
}
}
/*
* 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);
}
}
/*
* 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.
......@@ -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;
}
}
}
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
}
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
/*
* 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);
......
......@@ -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(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.FINER)) {
focusLog.log(Level.FINER, "SNFH for {0} in {1}",
new Object[] {String.valueOf(descendant), String.valueOf(heavyweight)});
}
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");
}
}
......
......@@ -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);
}
if ((fis = openProfile(fileName)) == null) {
File f = getProfileFile(fileName);
if (f != null) {
fis = new FileInputStream(f);
}
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.
......
......@@ -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();
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);
}
}
int nanos = oldTime.getNanos();
if (nanos != newTime.getNanos()) {
out.writeStatement(new Statement(oldTime, "setNanos", new Object[] {nanos}));
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}));
}
}
}
......
......@@ -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;
}
}
......@@ -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)
......
/*
* 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;
}
int result = 0;
// time-constant comparison
for (int i = 0; i < digesta.length; i++) {
if (digesta[i] != digestb[i]) {
return false;
}
result |= digesta[i] ^ digestb[i];
}
return true;
return result == 0;
}
/**
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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))
......
......@@ -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());
}
}
/**
......
......@@ -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);
}
/**
......
......@@ -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
*/
......
......@@ -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);
}
/**
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
此差异已折叠。
/*
* 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;
}
}
/*
* 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
......@@ -24,74 +23,75 @@
*/
/*
* <PRE>
* This class filters TrueType font files from other file
* found in the font path.
* 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:
*
* </PRE>
*
* @author Ilya Bagrak
* 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 build.tools.fontchecker;
package java.util.concurrent;
import java.awt.*;
import java.io.*;
/**
* 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;
public class FontFileFilter implements java.io.FileFilter, FontCheckerConstants {
/**
* The result of the computation.
*/
V result;
/**
* Boolean flag indicating whether this filter filters out
* non-TrueType fonts.
* The main computation performed by this task.
*/
private boolean checkNonTTF;
protected abstract V compute();
public FontFileFilter() {
this(false);
public final V getRawResult() {
return result;
}
public FontFileFilter(boolean checkNonTTF) {
super();
this.checkNonTTF = checkNonTTF;
protected final void setRawResult(V value) {
result = value;
}
/**
* 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
* Implements execution conventions for RecursiveTask.
*/
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;
protected final boolean exec() {
result = compute();
return true;
}
}
......@@ -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
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册