- After installing
- Fedora 9
- you need to make sure you have
- the "Software Development" bundle installed, plus the
- following packages:
-
-
-
cups devel: Cups Development Package
-
freetype 2.3+ devel: Freetype 2.3 Development Package
-
hg: Mercurial, if you need to clone or manage source repositories
-
ksh: May be needed when using webrev
-
+
Fedora 9
+
+
+ After installing Fedora 9
+ you need to install several build dependencies. The simplest
+ way to do it is to execute the following commands as user
+ root:
+
+ yum-builddep java-openjdk
+
+ yum install gcc gcc-c++
+
+ In addition, it's necessary to set a few environment variables for the build:
+
+
+ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-openjdk
-
- Always a good idea to do a complete Software Update/Refresh
- after you get all the packages installed.
+
Fedora 10
+
+
+ After installing Fedora 10
+ you need to install several build dependencies. The simplest
+ way to do it is to execute the following commands as user
+ root:
+
+ yum-builddep java-1.6.0-openjdk
+
+ yum install gcc gcc-c++
+
+ In addition, it's necessary to set a few environment variables for the build:
+
+
+ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-openjdk
+
+
Fedora 11
+
+
+ After installing Fedora 11
+ you need to install several build dependencies. The simplest
+ way to do it is to execute the following commands as user
+ root:
+
+ yum-builddep java-1.6.0-openjdk
+
+ yum install gcc gcc-c++
+
+ In addition, it's necessary to set a few environment variables for the build:
+
+
+ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-openjdk
+
- In addition to needing the Bootstrap JDK and the Binary Plugs,
- when building on Ubuntu you will need to
- make sure certain packages are installed.
- In particular, certain X11 packages, make, m4, gawk, gcc 4,
- binutils, cups, freetype
- and alsa.
-
-
Ubuntu 6.06
+
Debian 5.0 (Lenny)
- The following list of packages for Ubuntu 6.06 is a working set that
- does appear to work.
-
- Note that it's quite possible that some of these
- packages are not required, so anyone discovering that some of the
- packages listed below are NOT required,
- please let the
- OpenJDK
- team know.
-
- All the packages below can be installed with the
- Synaptic Package manager provided with the base Ubuntu 6.06 release.
-
-
-
binutils (2.16.1cvs20060117-1ubuntu2.1)
-
cpp (4:4.0.3-1)
-
cpp-4.0 (4.0.3-1ubuntu5)
-
libfreetype6-dev
-
g++ (4:4.0.3-1)
-
g++-4.0 (4.0.3-1ubuntu5)
-
gawk (1:3.1.5-2build1)
-
gcc (4:4.0.3-1)
-
gcc-4.0 (4.0.3-1ubuntu5)
-
libasound2-dev (1.0.10-2ubuntu4)
-
libc6 (2.3.6-0ubuntu20) to 2.3.6-0ubuntu20.4
-
libc6-dev (2.3.6-0ubuntu20.4)
-
libc6-i686 (2.3.6-0ubuntu20) to 2.3.6-0ubuntu20.4
-
libcupsys2-dev (1.2.2-0ubuntu0.6.06)
-
libgcrypt11-dev (1.2.2-1)
-
libgnutls-dev (1.2.9-2ubuntu1.1)
-
libgnutls12 (1.2.9-2ubuntu1) to 1.2.9-2ubuntu1.1
-
libgpg-error-dev (1.1-4)
-
libice-dev (2:1.0.0-0ubuntu2)
-
liblockfile1 (1.06.1)
-
libopencdk8-dev (0.5.7-2)
-
libpopt-dev (1.7-5)
-
libsm-dev (2:1.0.0-0ubuntu2)
-
libstdc++6-4.0-dev (4.0.3-1ubuntu5)
-
libtasn1-2-dev (0.2.17-1ubuntu1)
-
libx11-dev (2:1.0.0-0ubuntu9)
-
libxau-dev (1:1.0.0-0ubuntu4)
-
libxaw-headers (2:1.0.1-0ubuntu3)
-
libxaw7-dev (2:1.0.1-0ubuntu3)
-
libxdmcp-dev (1:1.0.0-0ubuntu2)
-
libxext-dev (2:1.0.0-0ubuntu4)
-
libxi-dev (2:1.0.0-0ubuntu3)
-
libxmu-dev (2:1.0.0-0ubuntu3)
-
libxmu-headers (2:1.0.0-0ubuntu3)
-
libxmuu-dev (2:1.0.0-0ubuntu3)
-
libxp-dev (6.8.2-11ubuntu2)
-
libxpm-dev (1:3.5.4.2-0ubuntu3)
-
libxrandr-dev (1:1.1.0.2-0ubuntu4)
-
libxt-dev (1:1.0.0-0ubuntu3)
-
libxtrap-dev (2:1.0.0-0ubuntu2)
-
libxtst-dev (2:1.0.1-0ubuntu2)
-
libxv-dev (2:1.0.1-0ubuntu3)
-
linux-kernel-headers (2.6.11.2-0ubuntu18)
-
m4 (1.4.4-1)
-
make (3.80+3.81.b4-1)
-
ssl-cert (1.0.13)
-
x-dev (7.0.4-0ubuntu2)
-
x11proto-core-dev (7.0.4-0ubuntu2)
-
x11proto-input-dev (1.3.2-0ubuntu2)
-
x11proto-kb-dev (1.0.2-0ubuntu2)
-
x11proto-randr-dev (1.1.2-0ubuntu2)
-
x11proto-record-dev (1.13.2-0ubuntu2)
-
x11proto-trap-dev (3.4.3-0ubuntu2)
-
x11proto-video-dev (2.2.2-0ubuntu2)
-
x11proto-xext-dev (7.0.2-0ubuntu2)
-
xlibs-dev (7.0.0-0ubuntu45)
-
zlib1g-dev (1:1.2.3-6ubuntu4)
-
-
-
-
Ubuntu 7.04
-
- Using the Synaptic Package Manager, download the following
- packages (double indented packages are automatically aquired
- due to package dependencies):
-
-
-
build-essential
-
-
dpkg-dev
-
g++
-
g++-4.1
-
libc6-dev
-
libstdc++6.4.1-dev
-
linux-libc-dev
-
-
gawk
-
m4
-
libasound2-dev
-
libcupsys2-dev
-
-
libgcrypt11-dev
-
lgnutls-dev
-
libgpg-error-dev
-
liblzo-dev
-
libopencdk8-dev
-
libpopt-dev
-
libtasn1-3-dev
-
zlib1g-dev
-
-
sun-java6-jdk
-
-
java-common
-
libltdl3
-
odbcinst1debian1
-
sun-java6-bin
-
sun-java6-jre
-
unixodbc
-
-
xlibs-dev
-
-
(many)
-
-
x11proto-print-dev
-
libxaw7-dev
-
-
libxaw-headers
-
-
libxp-dev
-
libfreetype6-dev
-
-
+
+ After installing Debian 5
+ you need to install several build dependencies.
+ The simplest way to install the build dependencies is to
+ execute the following commands as user root:
+
+ aptitude build-dep openjdk-6
+
+ aptitude install openjdk-6-jdk libmotif-dev
+
+ In addition, it's necessary to set a few environment variables for the build:
+
+ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk
+
+ After installing Ubuntu 8.04
+ you need to install several build dependencies.
+
+ First, you need to enable the universe repository in the
+ Software Sources application and reload the repository
+ information. The Software Sources application is available
+ under the System/Administration menu.
+
+ The simplest way to install the build dependencies is to
+ execute the following commands:
+
+ sudo aptitude build-dep openjdk-6
+
+ sudo aptitude install openjdk-6-jdk
+
+ In addition, it's necessary to set a few environment variables for the build:
+
+ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk
+
+
Ubuntu 8.10
+
+
+ After installing Ubuntu 8.10
+ you need to install several build dependencies. The simplest
+ way to do it is to execute the following commands:
+
+ sudo aptitude build-dep openjdk-6
+
+ sudo aptitude install openjdk-6-jdk
+
+ In addition, it's necessary to set a few environment variables for the build:
+
+ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk
+
+
Ubuntu 9.04
+
+
+ After installing Ubuntu 9.04
+ you need to install several build dependencies. The simplest
+ way to do it is to execute the following commands:
+
+ sudo aptitude build-dep openjdk-6
+
+ sudo aptitude install openjdk-6-jdk
+
+ In addition, it's necessary to set a few environment variables for the build:
+
+ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk
+
+ After installing OpenSUSE 11.1
+ you need to install several build dependencies.
+ The simplest way to install the build dependencies is to
+ execute the following commands:
+
+ sudo zypper source-install -d java-1_6_0-openjdk
+
+ sudo zypper install make
+
+ In addition, it is necessary to set a few environment variables for the build:
+
+ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-1.6.0-openjdk
+
+ Finally, you need to unset the JAVA_HOME environment variable:
+
+ export -n JAVA_HOME
+
+ After installing Mandriva Linux One 2009 Spring
+ you need to install several build dependencies.
+ The simplest way to install the build dependencies is to
+ execute the following commands as user root:
+
+ urpmi java-1.6.0-openjdk-devel ant make gcc gcc-c++ freetype-devel zip unzip libcups2-devel libxrender1-devel libalsa2-devel libstc++-static-devel libxtst6-devel libxi-devel
+
+ In addition, it is necessary to set a few environment variables for the build:
+
+ export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-1.6.0-openjdk
+
+ After installing OpenSolaris 2009.06
+ you need to install several build dependencies.
+ The simplest way to install the build dependencies is to
+ execute the following commands:
+
+ pfexec pkg install SUNWgmake SUNWj6dev SUNWant sunstudioexpress SUNWcups SUNWzip SUNWunzip SUNWxwhl SUNWxorg-headers SUNWaudh SUNWfreetype2
+
+ In addition, it is necessary to set a few environment variables for the build:
+
+ export LANG=C ALT_COMPILER_PATH=/opt/SunStudioExpress/bin/ ALT_CUPS_HEADERS_PATH=/usr/include/
+
+ Finally, you need to make sure that the build process can find the Sun Studio compilers:
+
+ export PATH=$PATH:/opt/SunStudioExpress/bin/
+
- JIBX libraries version 1.1.5 is required for building the OpenJDK.
- Namely, the following JAR files from the JIBX distribution package
- are required:
-
-
bcel.jar
-
jibx-bind.jar
-
jibx-run.jar
-
xpp3.jar
-
-
- You can download the package from the
- JIBX site.
-
- You will need to set the
- ALT_JIBX_LIBS_PATH
- environment variable to refer to place where the JAR files,
- above, are located.
-
The location of the CUPS header files.
diff --git a/corba/.hgtags b/corba/.hgtags
index 88061f47606..d5a056ab705 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -45,3 +45,6 @@ a12ea7c7b497b4ba7830550095ef633bd6f43971 jdk7-b67
5182bcc9c60cac429d1f7988676cec7320752be3 jdk7-b68
8120d308ec4e805c5588b8d9372844d781c4112d jdk7-b69
175bd68779546078dbdb6dacd7f0aced79ed22b1 jdk7-b70
+3f1ef7f899ea2aec189c4fb67e5c8fa374437c50 jdk7-b71
+c793a31209263fbb867c23c752599d85c21abb73 jdk7-b72
+b751c528c55560cf2adeaeef24b39ca1f4d1cbf7 jdk7-b73
diff --git a/corba/make/Makefile b/corba/make/Makefile
index d986cc3251f..b2178145b64 100644
--- a/corba/make/Makefile
+++ b/corba/make/Makefile
@@ -141,12 +141,12 @@ $(CLASSES_JAR):
#----- src.zip
-SRC_ZIP_FILES = $(shell $(FIND) $(SRC_CLASSES_DIR) \( -name SCCS -o -name \*-template \) -prune -o -type f -print )
+SRC_ZIP_FILES = $(shell $(FIND) $(SRC_CLASSES_DIR) \( -name \*-template \) -prune -o -type f -print )
SRC_ZIP = $(LIB_DIR)/src.zip
$(SRC_ZIP): $(SRC_ZIP_FILES)
abs_src_zip=`cd $(@D) ; pwd`/$(@F) ; \
- ( cd $(SRC_CLASSES_DIR) ; $(FIND) . \( -name SCCS -o -name \*-template \) -prune -o -type f -print | $(ZIP) -q $$abs_src_zip -@ ) ; \
+ ( cd $(SRC_CLASSES_DIR) ; $(FIND) . \( -name \*-template \) -prune -o -type f -print | $(ZIP) -q $$abs_src_zip -@ ) ; \
( cd $(GENSRC_DIR) ; $(FIND) . -type f -print | $(ZIP) -q $$abs_src_zip -@ ) ;
#----- bin.zip
diff --git a/corba/make/common/BuildToolJar.gmk b/corba/make/common/BuildToolJar.gmk
index 7d4ad4169fc..dee6038abcf 100644
--- a/corba/make/common/BuildToolJar.gmk
+++ b/corba/make/common/BuildToolJar.gmk
@@ -1,5 +1,5 @@
#
-# Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -24,22 +24,29 @@
#
# Input: BUILDDIR PACKAGE PKGDIR PROGRAM BUILDTOOL_SOURCE_ROOT BUILDTOOL_MAIN
-
+
+# All subdirectories under the package root for the tool (max depth 4)
+_WC_DIRS = * */* */*/* */*/*/*
+
BUILDTOOL_MAIN_SOURCE_FILE = $(BUILDTOOL_SOURCE_ROOT)/$(BUILDTOOL_MAIN)
BUILDTOOL_MANIFEST_FILE = $(BUILDTOOLCLASSDIR)/$(PROGRAM)_manifest.mf
BUILDTOOL_JAR_FILE = $(BUILDTOOLJARDIR)/$(PROGRAM).jar
-BUILDTOOL_ALL_FILES := $(shell $(CD) $(BUILDTOOL_SOURCE_ROOT) \
- && $(FIND) $(PKGDIR) $(SCM_DIRS_prune) -o -type f -print)
-BUILTTOOL_MAINCLASS = $(subst /,.,$(BUILDTOOL_MAIN:%.java=%))
+BUILTTOOL_MAINCLASS = $(subst /,.,$(BUILDTOOL_MAIN:%.java=%))
-all build: $(BUILDTOOL_JAR_FILE) tool_info
+# Wildcard patterns that find all the sources for this build tool
+BUILDTOOL_WC_PATTERNS = $(BUILDTOOL_SOURCE_ROOT)/$(PKGDIR)/*.java \
+ $(patsubst %, $(BUILDTOOL_SOURCE_ROOT)/$(PKGDIR)/%/*.java, $(_WC_DIRS))
+
+# Wildcard expansion that finds all the files
+BUILDTOOL_SRC_FILES := $(wildcard $(BUILDTOOL_WC_PATTERNS))
+
+all build: $(BUILDTOOL_JAR_FILE)
$(BUILDTOOL_MANIFEST_FILE): $(BUILDTOOL_MAIN_SOURCE_FILE)
@$(prep-target)
$(ECHO) "Main-Class: $(BUILTTOOL_MAINCLASS)" > $@
-$(BUILDTOOL_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) \
- $(BUILDTOOL_ALL_FILES:%=$(BUILDTOOL_SOURCE_ROOT)/%)
+$(BUILDTOOL_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) $(BUILDTOOL_SRC_FILES)
@$(prep-target)
@$(MKDIR) -p $(BUILDTOOLCLASSDIR)
$(BOOT_JAVAC_CMD) -d $(BUILDTOOLCLASSDIR) \
@@ -49,23 +56,8 @@ $(BUILDTOOL_JAR_FILE): $(BUILDTOOL_MANIFEST_FILE) \
$(JAR_JFLAGS) || $(RM) $@
@$(java-vm-cleanup)
-# Printing out a build tool information line
-define printBuildToolSetting
-if [ "$2" != "" ] ; then $(PRINTF) "%-25s %s\n" "$1:" "$2"; fi
-endef
-
-# Print out the build tool information
-tool_info:
- @$(ECHO) "========================================================="
- @$(call printBuildToolSetting,BUILDTOOL,$(PROGRAM))
- @$(call printBuildToolSetting,PACKAGE,$(PACKAGE))
- @$(call printBuildToolSetting,BUILDTOOL_SOURCE_ROOT,$(BUILDTOOL_SOURCE_ROOT))
- @$(call printBuildToolSetting,BUILTTOOL_MAINCLASS,$(BUILTTOOL_MAINCLASS))
- @$(call printBuildToolSetting,BUILDTOOL_JAR_FILE,$(BUILDTOOL_JAR_FILE))
- @$(ECHO) "========================================================="
-
clean clobber::
- $(RM) -r $(BUILDTOOLCLASSDIR)/$(PKGDIR)
- $(RM) $(BUILDTOOL_MANIFEST_FILE)
- $(RM) $(BUILDTOOL_JAR_FILE)
+ $(RM) -r $(BUILDTOOLCLASSDIR)/$(PKGDIR) \
+ $(BUILDTOOL_MANIFEST_FILE) \
+ $(BUILDTOOL_JAR_FILE)
diff --git a/corba/make/common/CancelImplicits.gmk b/corba/make/common/CancelImplicits.gmk
index 73417af1925..2e291e5e83e 100644
--- a/corba/make/common/CancelImplicits.gmk
+++ b/corba/make/common/CancelImplicits.gmk
@@ -1,5 +1,5 @@
#
-# Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -56,11 +56,3 @@ ifndef USE_IMPLICITS
%: %.sh
endif
-#
-# If you are using RCS, you must set the variable USE_RCS at the make
-# command line. Otherwise we disable RCS.
-#
-ifndef USE_RCS
-%:: %,v
-%:: RCS/%,v
-endif
diff --git a/corba/make/common/Defs.gmk b/corba/make/common/Defs.gmk
index 7fc4c26c67e..f020ef7f8d5 100644
--- a/corba/make/common/Defs.gmk
+++ b/corba/make/common/Defs.gmk
@@ -1,5 +1,5 @@
#
-# Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -310,125 +310,32 @@ endef
SUBDIRS_MAKEFLAGS-clobber = INCREMENTAL_BUILD=false
SUBDIRS_MAKEFLAGS-clean = INCREMENTAL_BUILD=false
-# Current directory
-CURRENT_DIRECTORY := $(shell $(PWD))
-
-# If no timing wanted, we need to define these as empty
-ifdef NO_TIMING
-
-TIMING_ID:=NA
-
-define TIMING_start
-t=0:0:0:0
-endef
-
-define TIMING_end
-time_used=0
-endef
-
-else # NO_TIMING
-
-# Default timing id
-TIMING_ID:=$(shell $(BASENAME) $(CURRENT_DIRECTORY))
-
-# Timing start (must be used in same shell, e.g. same command line)
-# Defines the shell variable $1 to have the start time.
-define TIMING_start
-$1=`$(DATE) +%j:%H:%M:%S`
-endef
-
-# Timing end (must be used in same shell, e.g. same command line)
-# Expects shell variable $1 to have been defined as the start time.
-# Expects shell variable $2 to have timing id string
-# Sets total_seconds shell variable as the total seconds used.
-# Sets time_used shell variable to contain format "%dh%dm%ds"
-define TIMING_end
-begTime="$${$1}"; \
-timing_id="$${$2}"; \
-endTime=`$(DATE) +%j:%H:%M:%S`; \
-d1=`$(ECHO) $${begTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \
-if [ "$${d1}" = "" ] ; then d1=0; fi; \
-h1=`$(ECHO) $${begTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \
-if [ "$${h1}" = "" ] ; then h1=0; fi; \
-m1=`$(ECHO) $${begTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \
-if [ "$${m1}" = "" ] ; then m1=0; fi; \
-s1=`$(ECHO) $${begTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \
-if [ "$${s1}" = "" ] ; then s1=0; fi; \
-d2=`$(ECHO) $${endTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \
-if [ "$${d2}" = "" ] ; then d2=0; fi; \
-h2=`$(ECHO) $${endTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \
-if [ "$${h2}" = "" ] ; then h2=0; fi; \
-m2=`$(ECHO) $${endTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \
-if [ "$${m2}" = "" ] ; then m2=0; fi; \
-s2=`$(ECHO) $${endTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \
-if [ "$${s2}" = "" ] ; then s2=0; fi; \
-t1_secs=`$(EXPR) $${d1} '*' 60 '*' 60 '*' 24 '+' $${h1} '*' 60 '*' 60 \
- '+' $${m1} '*' 60 '+' $${s1}`; \
-t2_secs=`$(EXPR) $${d2} '*' 60 '*' 60 '*' 24 '+' $${h2} '*' 60 '*' 60 \
- '+' $${m2} '*' 60 '+' $${s2}`; \
-total_seconds=`$(EXPR) $${t2_secs} '-' $${t1_secs}`; \
-if [ "$${total_seconds}" -lt 0 ] ; then total_seconds=0; fi; \
-t_hour=`$(EXPR) $${total_seconds} '/' '(' 60 '*' 60 ')'`h; \
-t_min=`$(EXPR) '(' $${total_seconds} '%' '(' 60 '*' 60 ')' ')' '/' 60`m; \
-t_sec=`$(EXPR) $${total_seconds} '%' 60`s; \
-time_used=$${t_sec}; \
-if [ "$${t_hour}" != "0h" ] ; then \
-time_used=$${t_hour}$${t_min}$${t_sec}; \
-elif [ "$${t_min}" != "0m" ] ; then \
-time_used=$${t_min}$${t_sec}; \
-else \
-time_used=$${t_sec}; \
-fi; \
-$(PRINTF) " Timing: %05d seconds or %s for %s\n" \
- $${total_seconds} $${time_used} $${timing_id}
-endef
-
-endif # NO_TIMING
-
# Given a SUBDIRS list, cd into them and make them
# SUBDIRS_MAKEFLAGS Make settings for a subdir make
# SUBDIRS_MAKEFLAGS-$@ Make settings specific to this target
define SUBDIRS-loop
-@$(ECHO) "Begin Processing SUBDIRS: $(SUBDIRS)"
@for i in DUMMY $(SUBDIRS) ; do \
if [ "$$i" != "DUMMY" ] ; then \
- $(ECHO) ">>>Recursively making "$$i" "$@" @ `$(DATE)` ..."; \
- timing_id="$(TIMING_ID)-`$(BASENAME) $${i}`"; \
- $(call TIMING_start,startTime); \
- curDir=$(CURRENT_DIRECTORY); \
- $(CD) $$i; $(MAKE) $@ TIMING_ID=$${timing_id} \
- $(SUBDIRS_MAKEFLAGS) \
- $(SUBDIRS_MAKEFLAGS-$@) \
- FULL_VERSION=$(FULL_VERSION) \
- RELEASE=$(RELEASE) || exit 1; \
- $(CD) $${curDir}; \
- $(call TIMING_end,startTime,timing_id); \
- $(ECHO) "<<>>Recursively making "$$i" "$@" @ `$(DATE)` ..."; \
- timing_id="$(TIMING_ID)-`$(BASENAME) $${i}`"; \
- $(call TIMING_start,startTime); \
- curDir=$(CURRENT_DIRECTORY); \
- $(CD) $$i; $(MAKE) $@ TIMING_ID=$${timing_id} \
- $(OTHERSUBDIRS_MAKEFLAGS) \
- FULL_VERSION=$(FULL_VERSION) \
- RELEASE=$(RELEASE) || exit 1; \
- $(CD) $${curDir}; \
- $(call TIMING_end,startTime,timing_id); \
- $(ECHO) "<<> $(WARNING_FILE)
- @$(ECHO) " This file may be from an unresolved Teamware conflict." >> $(WARNING_FILE)
- @$(ECHO) " This is also a symptom of a Teamware bringover/putback failure" >> $(WARNING_FILE)
- @$(ECHO) " in which SCCS files are updated but not checked out." >> $(WARNING_FILE)
- @$(ECHO) " Check for other out of date files in your workspace." >> $(WARNING_FILE)
- @$(ECHO) "" >> $(WARNING_FILE)
- @#exit 666
+# Prevent the use of many default suffix rules we do not need
+.SUFFIXES:
+.SUFFIXES: .c .o .h .obj .cpp .hpp .java .class
+# Make sure we are all insane
ifdef INSANE
export INSANE
endif
-ifdef ALT_COPYRIGHT_YEAR
- COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR)
-else
- COPYRIGHT_YEAR = $(shell $(DATE) '+%Y')
+# Make sure we have the current year
+ifndef COPYRIGHT_YEAR
+ ifdef ALT_COPYRIGHT_YEAR
+ COPYRIGHT_YEAR := $(ALT_COPYRIGHT_YEAR)
+ else
+ COPYRIGHT_YEAR := $(shell $(DATE) '+%Y')
+ endif
+ export COPYRIGHT_YEAR
endif
# Install of imported file (JDK_IMPORT_PATH, or some other external location)
diff --git a/corba/make/common/Rules.gmk b/corba/make/common/Rules.gmk
index 0598f08df88..571e6f8486d 100644
--- a/corba/make/common/Rules.gmk
+++ b/corba/make/common/Rules.gmk
@@ -27,17 +27,6 @@
#
# Rules shared by all Java makefiles.
#
-# Used to apply to source file $<, checks code conventions, issues warnings.
-define check-conventions
- if [ "$(CONVENTION_WATCH)" = "true" ] ; then \
- if [ "`$(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]'`" != "" ] ; then \
- $(ECHO) "WARNING: File contains tabs, ^M, or ^L characters: $<"; \
- if [ "$(CONVENTION_DETAILS)" = "true" ] ; then \
- $(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]' ; \
- fi; \
- fi; \
- fi
-endef
# Make sure the default rule is all
rules_default_rule: all
@@ -162,7 +151,6 @@ JAVA_SOURCE_LIST=$(TEMPDIR)/.classes.list
# Add a java source to the list
define add-java-file
$(ECHO) "$?" >> $(JAVA_SOURCE_LIST)
-$(check-conventions)
endef
$(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java
@@ -197,11 +185,8 @@ JAVAC_PREFER_SOURCE = -Xprefer:source
.compile.classlist : $(JAVA_SOURCE_LIST)
@$(MKDIR) -p $(CLASSDESTDIR)
- @if [ `$(CAT) $(JAVA_SOURCE_LIST) | $(WC) -l` -ge 1 ] ; then \
- $(ECHO) "# Java sources to be compiled: (listed in file $(JAVA_SOURCE_LIST))"; \
+ if [ -s $(JAVA_SOURCE_LIST) ] ; then \
$(CAT) $(JAVA_SOURCE_LIST); \
- $(ECHO) "# Running javac:"; \
- $(ECHO) $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
$(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
fi
@$(java-vm-cleanup)
@@ -220,10 +205,7 @@ endif
packages.clean:
ifeq ($(DONT_CLOBBER_CLASSES),false)
ifdef AUTO_FILES_JAVA_DIRS
- @for sdir in $(AUTO_FILES_JAVA_DIRS); do \
- $(ECHO) "$(RM) -r $(CLASSDESTDIR)/$$sdir"; \
- $(RM) -r $(CLASSDESTDIR)/$$sdir; \
- done
+ $(RM) -r $(patsubst %, $(CLASSDESTDIR)/%, $(AUTO_FILES_JAVA_DIRS))
else
$(RM) -r $(CLASSDESTDIR)/$(PKGDIR)
endif
@@ -259,15 +241,13 @@ classheaders: classes $(CLASSHDR_DOTFILE)
$(CLASSHDR_DOTFILE): $(CLASSES_export)
$(prep-target)
- @$(ECHO) "# Running javah:"
$(JAVAH_CMD) -d $(CLASSHDRDIR)/ \
$(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner))
@$(java-vm-cleanup)
@$(TOUCH) $@
classheaders.clean:
- $(RM) $(CLASSHDR_DOTFILE)
- $(RM) -r $(CLASSHDRDIR)
+ $(RM) -r $(CLASSHDRDIR) $(CLASSHDR_DOTFILE)
else # FILES_export
diff --git a/corba/make/common/shared/Compiler-msvc.gmk b/corba/make/common/shared/Compiler-msvc.gmk
index 048ca78eb51..b9c779f0f37 100644
--- a/corba/make/common/shared/Compiler-msvc.gmk
+++ b/corba/make/common/shared/Compiler-msvc.gmk
@@ -48,11 +48,17 @@ ifeq ($(PLATFORM), windows)
NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo
# Compiler version and type (Always get word after "Version")
- CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(SED) 's/.*\(Version.*\)/\1/' | $(NAWK) '{print $$2}')
-
+ ifndef CC_VER
+ CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(SED) 's/.*\(Version.*\)/\1/' | $(NAWK) '{print $$2}')
+ export CC_VER
+ endif
+
# SDK-64 and MSVC6 put REBASE.EXE in a different places - go figure...
ifeq ($(ARCH_DATA_MODEL), 32)
- LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
+ ifndef LINK_VER
+ LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
+ export LINK_VER
+ endif
CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
ifeq ($(CC_MAJORVER), 13)
# This should be: CC_VER=13.10.3077 LINK_VER=7.10.3077
@@ -93,7 +99,10 @@ ifeq ($(PLATFORM), windows)
endif
else
# else ARCH_DATA_MODEL is 64
- LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
+ ifndef LINK_VER
+ LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
+ export LINK_VER
+ endif
CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
CC_MINORVER :=$(call MinorVersion,$(CC_VER))
CC_MICROVER :=$(call MicroVersion,$(CC_VER))
diff --git a/corba/make/common/shared/Defs-utils.gmk b/corba/make/common/shared/Defs-utils.gmk
index 51bdb660372..67b17795e45 100644
--- a/corba/make/common/shared/Defs-utils.gmk
+++ b/corba/make/common/shared/Defs-utils.gmk
@@ -116,7 +116,6 @@ RC = $(UTILS_COMMAND_PATH)rc
RMDIR = $(UTILS_COMMAND_PATH)rmdir
RPM = $(UTILS_COMMAND_PATH)rpm
RPMBUILD = $(UTILS_COMMAND_PATH)rpmbuild
-SCCS = $(UTILS_CCS_BIN_PATH)sccs
SED = $(UTILS_COMMAND_PATH)sed
SH = $(UTILS_COMMAND_PATH)sh
SHOWREV = $(UTILS_USR_BIN_PATH)showrev
diff --git a/corba/make/common/shared/Defs-windows.gmk b/corba/make/common/shared/Defs-windows.gmk
index 3e1fad1226a..8f09e3ca9d0 100644
--- a/corba/make/common/shared/Defs-windows.gmk
+++ b/corba/make/common/shared/Defs-windows.gmk
@@ -113,32 +113,38 @@ _system_drive:=$(call CheckValue,_system_drive,C:)
# UNIXCOMMAND_PATH: path to where the most common Unix commands are.
# NOTE: Must end with / so that it could be empty, allowing PATH usage.
-ifdef ALT_UNIXCOMMAND_PATH
- xALT_UNIXCOMMAND_PATH :="$(subst \,/,$(ALT_UNIXCOMMAND_PATH))"
- fxALT_UNIXCOMMAND_PATH :=$(call FullPath,$(xALT_UNIXCOMMAND_PATH))
- UNIXCOMMAND_PATH :=$(call PrefixPath,$(fxALT_UNIXCOMMAND_PATH))
-else
- ifdef USING_CYGWIN
- UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin)
+ifndef UNIXCOMMAND_PATH
+ ifdef ALT_UNIXCOMMAND_PATH
+ xALT_UNIXCOMMAND_PATH :="$(subst \,/,$(ALT_UNIXCOMMAND_PATH))"
+ fxALT_UNIXCOMMAND_PATH :=$(call FullPath,$(xALT_UNIXCOMMAND_PATH))
+ UNIXCOMMAND_PATH :=$(call PrefixPath,$(fxALT_UNIXCOMMAND_PATH))
else
- ifdef ROOTDIR
- xROOTDIR :="$(subst \,/,$(ROOTDIR))"
- _rootdir :=$(call FullPath,$(xROOTDIR))
+ ifdef USING_CYGWIN
+ UNIXCOMMAND_PATH :=$(call PrefixPath,/usr/bin)
else
- xROOTDIR :="$(_system_drive)/mksnt"
- _rootdir :=$(call FullPath,$(xROOTDIR))
- endif
- ifneq ($(_rootdir),)
- UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt)
+ ifdef ROOTDIR
+ xROOTDIR :="$(subst \,/,$(ROOTDIR))"
+ _rootdir :=$(call FullPath,$(xROOTDIR))
+ else
+ xROOTDIR :="$(_system_drive)/mksnt"
+ _rootdir :=$(call FullPath,$(xROOTDIR))
+ endif
+ ifneq ($(_rootdir),)
+ UNIXCOMMAND_PATH :=$(call PrefixPath,$(_rootdir)/mksnt)
+ endif
endif
endif
+ UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
+ export UNIXCOMMAND_PATH
endif
-UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
# Get version of MKS or CYGWIN
ifdef USING_CYGWIN
-_CYGWIN_VER :=$(shell $(UNAME))
-CYGWIN_VER :=$(call GetVersion,$(_CYGWIN_VER))
+ ifndef CYGWIN_VER
+ _CYGWIN_VER :=$(shell $(UNAME))
+ CYGWIN_VER :=$(call GetVersion,$(_CYGWIN_VER))
+ export CYGWIN_VER
+ endif
else # MKS
_MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@')
MKS_VER :=$(call GetVersion,$(_MKS_VER))
@@ -168,235 +174,234 @@ endif # MKS
# Process Windows values into FullPath values, these paths may have \ chars
-# System root
-ifdef SYSTEMROOT
- xSYSTEMROOT :="$(subst \,/,$(SYSTEMROOT))"
- _system_root :=$(call FullPath,$(xSYSTEMROOT))
-else
- ifdef SystemRoot
- xSYSTEMROOT :="$(subst \,/,$(SystemRoot))"
- _system_root :=$(call FullPath,$(xSYSTEMROOT))
+# Program Files directory
+ifndef SHORTPROGRAMFILES
+ ifdef PROGRAMFILES
+ xPROGRAMFILES :="$(subst \,/,$(PROGRAMFILES))"
else
- ifdef WINDIR
- xWINDIR :="$(subst \,/,$(WINDIR))"
- _system_root :=$(call FullPath,$(xWINDIR))
+ ifeq ($(ARCH_DATA_MODEL), 32)
+ xPROGRAMFILES :="$(_system_drive)/Program Files"
else
- ifdef windir
- xWINDIR :="$(subst \,/,$(windir))"
- _system_root :=$(call FullPath,$(xWINDIR))
- endif
+ xPROGRAMFILES :="$(_system_drive)/Program Files (x86)"
endif
endif
-endif
-_system_root:=$(call CheckValue,_system_root,$(_system_drive)/WINNT)
-
-# Program Files directory
-ifdef PROGRAMFILES
- xPROGRAMFILES :="$(subst \,/,$(PROGRAMFILES))"
-else
ifeq ($(ARCH_DATA_MODEL), 32)
- xPROGRAMFILES :="$(_system_drive)/Program Files"
+ SHORTPROGRAMFILES :=$(call FullPath,$(xPROGRAMFILES))
else
- xPROGRAMFILES :="$(_system_drive)/Program Files (x86)"
+ ifdef PROGRAMW6432
+ xPROGRAMW6432 :="$(subst \,/,$(PROGRAMW6432))"
+ else
+ xPROGRAMW6432 :="$(_system_drive)/Program Files"
+ endif
+ SHORTPROGRAMFILES :=$(call FullPath,$(xPROGRAMW6432))
endif
-endif
-ifeq ($(ARCH_DATA_MODEL), 32)
- _program_files :=$(call FullPath,$(xPROGRAMFILES))
-else
- ifdef PROGRAMW6432
- xPROGRAMW6432 :="$(subst \,/,$(PROGRAMW6432))"
- else
- xPROGRAMW6432 :="$(_system_drive)/Program Files"
+ ifneq ($(word 1,$(SHORTPROGRAMFILES)),$(SHORTPROGRAMFILES))
+ SHORTPROGRAMFILES :=
endif
- _program_files :=$(call FullPath,$(xPROGRAMW6432))
- _program_files32 :=$(call FullPath,$(xPROGRAMFILES))
- ifneq ($(word 1,$(_program_files32)),$(_program_files32))
- _program_files32:=
- endif
-endif
-ifneq ($(word 1,$(_program_files)),$(_program_files))
- _program_files:=
+ export SHORTPROGRAMFILES
endif
# Compilers, SDK, and Visual Studio (MSDEV) [32bit is different from 64bit]
ifeq ($(ARCH_DATA_MODEL), 32)
- # Try looking in MSVCDIR or MSVCDir area first (set by vcvars32.bat)
- ifdef MSVCDIR
- xMSVCDIR :="$(subst \,/,$(MSVCDIR))"
- _msvc_dir :=$(call FullPath,$(xMSVCDIR))
- else
- ifdef MSVCDir
- xMSVCDIR :="$(subst \,/,$(MSVCDir))"
- _msvc_dir :=$(call FullPath,$(xMSVCDIR))
+ ifndef SHORTMSVCDIR
+ # Try looking in MSVCDIR or MSVCDir area first (set by vcvars32.bat)
+ ifdef MSVCDIR
+ xMSVCDIR :="$(subst \,/,$(MSVCDIR))"
+ SHORTMSVCDIR :=$(call FullPath,$(xMSVCDIR))
else
- ifneq ($(_program_files),)
- xMSVCDIR :="$(_program_files)/Microsoft Visual Studio .NET 2003/Vc7"
- _msvc_dir :=$(call FullPath,$(xMSVCDIR))
+ ifdef MSVCDir
+ xMSVCDIR :="$(subst \,/,$(MSVCDir))"
+ SHORTMSVCDIR :=$(call FullPath,$(xMSVCDIR))
+ else
+ ifneq ($(SHORTPROGRAMFILES),)
+ xMSVCDIR :="$(SHORTPROGRAMFILES)/Microsoft Visual Studio .NET 2003/Vc7"
+ SHORTMSVCDIR :=$(call FullPath,$(xMSVCDIR))
+ endif
endif
endif
- endif
- ifneq ($(subst MSDev98,OLDOLDOLD,$(_msvc_dir)),$(_msvc_dir))
- _msvc_dir :=
- endif
- # If we still don't have it, look for VS71COMNTOOLS, setup by installer?
- ifeq ($(_msvc_dir),)
- ifdef VS71COMNTOOLS # /Common/Tools directory, use ../../Vc7
- xVS71COMNTOOLS :="$(subst \,/,$(VS71COMNTOOLS))"
- _vs71tools :=$(call FullPath,$(xVS71COMNTOOLS))
+ ifneq ($(subst MSDev98,OLDOLDOLD,$(SHORTMSVCDIR)),$(SHORTMSVCDIR))
+ SHORTMSVCDIR :=
endif
- ifneq ($(_vs71tools),)
- _msvc_dir :=$(_vs71tools)/../../Vc7
+ # If we still don't have it, look for VS71COMNTOOLS, setup by installer?
+ ifeq ($(SHORTMSVCDIR),)
+ ifdef VS71COMNTOOLS # /Common/Tools directory, use ../../Vc7
+ xVS71COMNTOOLS :="$(subst \,/,$(VS71COMNTOOLS))"
+ _vs71tools :=$(call FullPath,$(xVS71COMNTOOLS))
+ endif
+ ifneq ($(_vs71tools),)
+ SHORTMSVCDIR :=$(_vs71tools)/../../Vc7
+ endif
endif
+ export SHORTMSVCDIR
endif
- ifneq ($(_msvc_dir),)
- _compiler_bin :=$(_msvc_dir)/Bin
- _redist_sdk :=$(_msvc_dir)/../SDK/v1.1/Bin
- _ms_sdk :=$(_msvc_dir)/PlatformSDK
+ ifneq ($(SHORTMSVCDIR),)
+ SHORTCOMPILERBIN :=$(SHORTMSVCDIR)/Bin
+ SHORTPSDK :=$(SHORTMSVCDIR)/PlatformSDK
+ export SHORTCOMPILERBIN
+ export SHORTPSDK
endif
endif
# The Microsoft Platform SDK installed by itself
-ifneq ($(_program_files),)
- xPSDK :="$(_program_files)/Microsoft Platform SDK"
- _psdk :=$(call FullPath,$(xPSDK))
- ifeq ($(_psdk),)
- xPSDK :="$(_program_files)/Microsoft SDK"
- _psdk :=$(call FullPath,$(xMSSDK))
+ifneq ($(SHORTPROGRAMFILES),)
+ ifndef SHORTPSDK
+ xPSDK :="$(SHORTPROGRAMFILES)/Microsoft Platform SDK"
+ SHORTPSDK :=$(call FullPath,$(xPSDK))
+ ifeq ($(SHORTPSDK),)
+ xPSDK :="$(SHORTPROGRAMFILES)/Microsoft SDK"
+ SHORTPSDK :=$(call FullPath,$(xMSSDK))
+ endif
+ export SHORTPSDK
endif
endif
# If no SDK found yet, look in other places
-ifeq ($(_ms_sdk),)
+ifndef SHORTPSDK
ifdef MSSDK
- xMSSDK :="$(subst \,/,$(MSSDK))"
- _ms_sdk :=$(call FullPath,$(xMSSDK))
+ xMSSDK :="$(subst \,/,$(MSSDK))"
+ SHORTPSDK :=$(call FullPath,$(xMSSDK))
else
ifdef MSSdk
- xMSSDK :="$(subst \,/,$(MSSdk))"
- _ms_sdk :=$(call FullPath,$(xMSSDK))
- else
- _ms_sdk :=$(_psdk)
+ xMSSDK :="$(subst \,/,$(MSSdk))"
+ SHORTPSDK :=$(call FullPath,$(xMSSDK))
endif
endif
+ export SHORTPSDK
endif
# Compilers for 64bit are from SDK
ifeq ($(ARCH_DATA_MODEL), 64)
- xMSSDK61 :="C:/Program Files/Microsoft SDKs/Windows/v6.1/"
- MSSDK61 :=$(call FullPath,$(xMSSDK61))
- xVS2008 :="C:/Program Files (x86)/Microsoft Visual Studio 9.0/"
- _vs2008 :=$(call FullPath,$(xVS2008))
- ifneq ($(_vs2008),)
- ifeq ($(ARCH), ia64)
- _compiler_bin :=$(_vs2008)/VC/Bin/x86_ia64
- endif
- ifeq ($(ARCH), amd64)
- _compiler_bin :=$(_vs2008)/VC/Bin/$(ARCH)
- _redist_sdk :=$(MSSDK61)/VC/redist
- endif
- else
- ifneq ($(_ms_sdk),)
+ ifndef SHORTCOMPILERBIN
+ xMSSDK61 :="C:/Program Files/Microsoft SDKs/Windows/v6.1/"
+ MSSDK61 :=$(call FullPath,$(xMSSDK61))
+ xVS2008 :="C:/Program Files (x86)/Microsoft Visual Studio 9.0/"
+ _vs2008 :=$(call FullPath,$(xVS2008))
+ ifneq ($(_vs2008),)
ifeq ($(ARCH), ia64)
- _compiler_bin :=$(_ms_sdk)/Bin/Win64
+ SHORTCOMPILERBIN :=$(_vs2008)/VC/Bin/x86_ia64
endif
ifeq ($(ARCH), amd64)
- _compiler_bin :=$(_ms_sdk)/Bin/Win64/x86/$(ARCH)
- _redist_sdk :=$(_ms_sdk)/redist/win64/AMD64
+ SHORTCOMPILERBIN :=$(_vs2008)/VC/Bin/$(ARCH)
+ endif
+ else
+ ifneq ($(SHORTPSDK),)
+ ifeq ($(ARCH), ia64)
+ SHORTCOMPILERBIN :=$(SHORTPSDK)/Bin/Win64
+ endif
+ ifeq ($(ARCH), amd64)
+ SHORTCOMPILERBIN :=$(SHORTPSDK)/Bin/Win64/x86/$(ARCH)
+ endif
endif
endif
+ export SHORTCOMPILERBIN
endif
endif
# Location on system where jdk installs might be
-ifneq ($(_program_files),)
- USRJDKINSTANCES_PATH =$(_program_files)/Java
+ifneq ($(SHORTPROGRAMFILES),)
+ USRJDKINSTANCES_PATH =$(SHORTPROGRAMFILES)/Java
else
USRJDKINSTANCES_PATH =$(_system_drive)/
endif
# SLASH_JAVA: location of all network accessable files
-ifdef ALT_SLASH_JAVA
- xALT_SLASH_JAVA :="$(subst \,/,$(ALT_SLASH_JAVA))"
- SLASH_JAVA :=$(call FullPath,$(xALT_SLASH_JAVA))
-else
- ifdef ALT_JDK_JAVA_DRIVE
- SLASH_JAVA =$(JDK_JAVA_DRIVE)
+ifndef SLASH_JAVA
+ ifdef ALT_SLASH_JAVA
+ xALT_SLASH_JAVA :="$(subst \,/,$(ALT_SLASH_JAVA))"
+ SLASH_JAVA :=$(call FullPath,$(xALT_SLASH_JAVA))
else
- SLASH_JAVA =J:
+ ifdef ALT_JDK_JAVA_DRIVE
+ SLASH_JAVA =$(JDK_JAVA_DRIVE)
+ else
+ SLASH_JAVA =J:
+ endif
endif
+ SLASH_JAVA:=$(call AltCheckSpaces,SLASH_JAVA)
+ SLASH_JAVA:=$(call AltCheckValue,SLASH_JAVA)
+ export SLASH_JAVA
endif
-SLASH_JAVA:=$(call AltCheckSpaces,SLASH_JAVA)
-SLASH_JAVA:=$(call AltCheckValue,SLASH_JAVA)
# JDK_DEVTOOLS_DIR: common path for all the java devtools
-ifdef ALT_JDK_DEVTOOLS_DIR
- xALT_JDK_DEVTOOLS_DIR :="$(subst \,/,$(ALT_JDK_DEVTOOLS_DIR))"
- JDK_DEVTOOLS_DIR :=$(call FullPath,$(xALT_JDK_DEVTOOLS_DIR))
-else
- JDK_DEVTOOLS_DIR =$(SLASH_JAVA)/devtools
+ifndef JDK_DEVTOOLS_DIR
+ ifdef ALT_JDK_DEVTOOLS_DIR
+ xALT_JDK_DEVTOOLS_DIR :="$(subst \,/,$(ALT_JDK_DEVTOOLS_DIR))"
+ JDK_DEVTOOLS_DIR :=$(call FullPath,$(xALT_JDK_DEVTOOLS_DIR))
+ else
+ JDK_DEVTOOLS_DIR =$(SLASH_JAVA)/devtools
+ endif
+ JDK_DEVTOOLS_DIR:=$(call AltCheckSpaces,JDK_DEVTOOLS_DIR)
+ JDK_DEVTOOLS_DIR:=$(call AltCheckValue,JDK_DEVTOOLS_DIR)
+ export JDK_DEVTOOLS_DIR
endif
-JDK_DEVTOOLS_DIR:=$(call AltCheckSpaces,JDK_DEVTOOLS_DIR)
-JDK_DEVTOOLS_DIR:=$(call AltCheckValue,JDK_DEVTOOLS_DIR)
# COMPILER_PATH: path to where the compiler and tools are installed.
# NOTE: Must end with / so that it could be empty, allowing PATH usage.
-ifdef ALT_COMPILER_PATH
- xALT_COMPILER_PATH :="$(subst \,/,$(ALT_COMPILER_PATH))"
- fxALT_COMPILER_PATH :=$(call FullPath,$(xALT_COMPILER_PATH))
- COMPILER_PATH :=$(call PrefixPath,$(fxALT_COMPILER_PATH))
-else
- COMPILER_PATH :=$(call PrefixPath,$(_compiler_bin))
+ifndef COMPILER_PATH
+ ifdef ALT_COMPILER_PATH
+ xALT_COMPILER_PATH :="$(subst \,/,$(ALT_COMPILER_PATH))"
+ fxALT_COMPILER_PATH :=$(call FullPath,$(xALT_COMPILER_PATH))
+ COMPILER_PATH :=$(call PrefixPath,$(fxALT_COMPILER_PATH))
+ else
+ COMPILER_PATH :=$(call PrefixPath,$(SHORTCOMPILERBIN))
+ endif
+ COMPILER_PATH :=$(call AltCheckSpaces,COMPILER_PATH)
+ export COMPILER_PATH
endif
-COMPILER_PATH :=$(call AltCheckSpaces,COMPILER_PATH)
# MSDEVTOOLS_PATH: path to where the additional MS Compiler tools are.
# NOTE: Must end with / so that it could be empty, allowing PATH usage.
-ifdef ALT_MSDEVTOOLS_PATH
- xALT_MSDEVTOOLS_PATH :="$(subst \,/,$(ALT_MSDEVTOOLS_PATH))"
- fxALT_MSDEVTOOLS_PATH :=$(call FullPath,$(xALT_MSDEVTOOLS_PATH))
- MSDEVTOOLS_PATH :=$(call PrefixPath,$(fxALT_MSDEVTOOLS_PATH))
-else
- ifeq ($(ARCH_DATA_MODEL), 64)
- ifdef MSTOOLS
- xMSTOOLS :="$(subst \,/,$(MSTOOLS))"
- _ms_tools :=$(call FullPath,$(xMSTOOLS))
- else
- ifdef Mstools
- xMSTOOLS :="$(subst \,/,$(Mstools))"
+ifndef MSDEVTOOLS_PATH
+ ifdef ALT_MSDEVTOOLS_PATH
+ xALT_MSDEVTOOLS_PATH :="$(subst \,/,$(ALT_MSDEVTOOLS_PATH))"
+ fxALT_MSDEVTOOLS_PATH :=$(call FullPath,$(xALT_MSDEVTOOLS_PATH))
+ MSDEVTOOLS_PATH :=$(call PrefixPath,$(fxALT_MSDEVTOOLS_PATH))
+ else
+ ifeq ($(ARCH_DATA_MODEL), 64)
+ ifdef MSTOOLS
+ xMSTOOLS :="$(subst \,/,$(MSTOOLS))"
_ms_tools :=$(call FullPath,$(xMSTOOLS))
else
- _ms_tools :=
+ ifdef Mstools
+ xMSTOOLS :="$(subst \,/,$(Mstools))"
+ _ms_tools :=$(call FullPath,$(xMSTOOLS))
+ else
+ _ms_tools :=
+ endif
+ endif
+ ifneq ($(_ms_tools),)
+ _ms_tools_bin :=$(_ms_tools)/Bin
+ else
+ # Assumes compiler bin is .../Bin/win64/x86/AMD64, rc.exe is 3 levels up
+ _ms_tools_bin :=$(SHORTCOMPILERBIN)/../../..
endif
- endif
- ifneq ($(_ms_tools),)
- _ms_tools_bin :=$(_ms_tools)/Bin
else
- # Assumes compiler bin is .../Bin/win64/x86/AMD64, rc.exe is 3 levels up
- _ms_tools_bin :=$(_compiler_bin)/../../..
+ _ms_tools_bin :=$(SHORTCOMPILERBIN)
endif
- else
- _ms_tools_bin :=$(_compiler_bin)
+ MSDEVTOOLS_PATH :=$(call PrefixPath,$(_ms_tools_bin))
endif
- MSDEVTOOLS_PATH :=$(call PrefixPath,$(_ms_tools_bin))
+ MSDEVTOOLS_PATH:=$(call AltCheckSpaces,MSDEVTOOLS_PATH)
+ export MSDEVTOOLS_PATH
endif
-MSDEVTOOLS_PATH:=$(call AltCheckSpaces,MSDEVTOOLS_PATH)
# DEVTOOLS_PATH: for other tools required for building (such as zip, etc.)
# NOTE: Must end with / so that it could be empty, allowing PATH usage.
-ifdef ALT_DEVTOOLS_PATH
- xALT_DEVTOOLS_PATH :="$(subst \,/,$(ALT_DEVTOOLS_PATH))"
- fxALT_DEVTOOLS_PATH :=$(call FullPath,$(xALT_DEVTOOLS_PATH))
- DEVTOOLS_PATH :=$(call PrefixPath,$(fxALT_DEVTOOLS_PATH))
-else
- ifdef USING_CYGWIN
- DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
+ifndef DEVTOOLS_PATH
+ ifdef ALT_DEVTOOLS_PATH
+ xALT_DEVTOOLS_PATH :="$(subst \,/,$(ALT_DEVTOOLS_PATH))"
+ fxALT_DEVTOOLS_PATH :=$(call FullPath,$(xALT_DEVTOOLS_PATH))
+ DEVTOOLS_PATH :=$(call PrefixPath,$(fxALT_DEVTOOLS_PATH))
else
- xDEVTOOLS_PATH :="$(_system_drive)/utils"
- fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH))
- DEVTOOLS_PATH :=$(call PrefixPath,$(fxDEVTOOLS_PATH))
+ ifdef USING_CYGWIN
+ DEVTOOLS_PATH :=$(UNIXCOMMAND_PATH)
+ else
+ xDEVTOOLS_PATH :="$(_system_drive)/utils"
+ fxDEVTOOLS_PATH :=$(call FullPath,$(xDEVTOOLS_PATH))
+ DEVTOOLS_PATH :=$(call PrefixPath,$(fxDEVTOOLS_PATH))
+ endif
endif
+ DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH)
+ export DEVTOOLS_PATH
endif
-DEVTOOLS_PATH:=$(call AltCheckSpaces,DEVTOOLS_PATH)
# _BOOTDIR1: First choice for a Bootstrap JDK, previous released JDK.
# _BOOTDIR2: Second choice
@@ -410,20 +415,26 @@ endif
# BUILD_JDK_IMPORT_PATH: location of JDK install trees to import for
# multiple platforms, e.g. windows-i586, solaris-sparc, linux-586, etc.
-ifdef ALT_BUILD_JDK_IMPORT_PATH
- BUILD_JDK_IMPORT_PATH :=$(call FullPath,$(ALT_BUILD_JDK_IMPORT_PATH))
-else
- BUILD_JDK_IMPORT_PATH = $(PROMOTED_BUILD_BINARIES)
+ifndef BUILD_JDK_IMPORT_PATH
+ ifdef ALT_BUILD_JDK_IMPORT_PATH
+ BUILD_JDK_IMPORT_PATH :=$(call FullPath,$(ALT_BUILD_JDK_IMPORT_PATH))
+ else
+ BUILD_JDK_IMPORT_PATH = $(PROMOTED_BUILD_BINARIES)
+ endif
+ BUILD_JDK_IMPORT_PATH:=$(call AltCheckSpaces,BUILD_JDK_IMPORT_PATH)
+ BUILD_JDK_IMPORT_PATH:=$(call AltCheckValue,BUILD_JDK_IMPORT_PATH)
+ export BUILD_JDK_IMPORT_PATH
endif
-BUILD_JDK_IMPORT_PATH:=$(call AltCheckSpaces,BUILD_JDK_IMPORT_PATH)
-BUILD_JDK_IMPORT_PATH:=$(call AltCheckValue,BUILD_JDK_IMPORT_PATH)
# JDK_IMPORT_PATH: location of previously built JDK (this version) to import
-ifdef ALT_JDK_IMPORT_PATH
- JDK_IMPORT_PATH :=$(call FullPath,$(ALT_JDK_IMPORT_PATH))
-else
- JDK_IMPORT_PATH = $(BUILD_JDK_IMPORT_PATH)/$(PLATFORM)-$(ARCH)$(_JDK_IMPORT_VARIANT)
+ifndef JDK_IMPORT_PATH
+ ifdef ALT_JDK_IMPORT_PATH
+ JDK_IMPORT_PATH :=$(call FullPath,$(ALT_JDK_IMPORT_PATH))
+ else
+ JDK_IMPORT_PATH = $(BUILD_JDK_IMPORT_PATH)/$(PLATFORM)-$(ARCH)$(_JDK_IMPORT_VARIANT)
+ endif
+ JDK_IMPORT_PATH:=$(call AltCheckSpaces,JDK_IMPORT_PATH)
+ JDK_IMPORT_PATH:=$(call AltCheckValue,JDK_IMPORT_PATH)
+ export JDK_IMPORT_PATH
endif
-JDK_IMPORT_PATH:=$(call AltCheckSpaces,JDK_IMPORT_PATH)
-JDK_IMPORT_PATH:=$(call AltCheckValue,JDK_IMPORT_PATH)
diff --git a/corba/make/common/shared/Defs.gmk b/corba/make/common/shared/Defs.gmk
index e5afa8eb8e3..652b56e9ef5 100644
--- a/corba/make/common/shared/Defs.gmk
+++ b/corba/make/common/shared/Defs.gmk
@@ -228,12 +228,15 @@ else
endif
# FULL_VERSION is RELEASE and -BUILD_NUMBER if BUILD_NUMBER is set
-ifdef BUILD_NUMBER
- FULL_VERSION = $(RELEASE)-$(BUILD_NUMBER)
-else
- BUILD_NUMBER = b00
- USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`)
- FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER)
+ifndef FULL_VERSION
+ ifdef BUILD_NUMBER
+ FULL_VERSION = $(RELEASE)-$(BUILD_NUMBER)
+ else
+ BUILD_NUMBER = b00
+ USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`)
+ FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER)
+ endif
+ export FULL_VERSION
endif
# Promoted build location
diff --git a/corba/make/common/shared/Platform.gmk b/corba/make/common/shared/Platform.gmk
index 18f3aa330ec..c444d06f802 100644
--- a/corba/make/common/shared/Platform.gmk
+++ b/corba/make/common/shared/Platform.gmk
@@ -84,21 +84,14 @@ PLATFORM_SHARED=done
# REQUIRED_LINUX_VER linux only: required version of linux
# REQUIRED_LINUX_FULLVER linux only: required full version of linux
-SYSTEM_UNAME := $(shell uname)
+ifndef SYSTEM_UNAME
+ SYSTEM_UNAME := $(shell uname)
+ export SYSTEM_UNAME
+endif
# Normal boot jdk is previous release, but a hard requirement is a 1.5 boot
REQUIRED_BOOT_VER = 1.5
-#
-# Prune out all known SCM (Source Code Management) directories
-# so they will not be included when copying directory trees
-# or packaging up .jar files, etc. This applies to all workspaces.
-#
-SCM_DIRs = .hg .svn CVS RCS SCCS Codemgr_wsdata deleted_files
-# When changing SCM_DIRs also change SCM_DIRS_rexp and SCM_DIRS_prune:
-SCM_DIRS_rexp = ".hg|.svn|CVS|RCS|SCCS|Codemgr_wsdata|deleted_files"
-SCM_DIRS_prune = \( -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS -o -name Codemgr_wsdata -o -name deleted_files \) -prune
-
# Don't define this unless it's not defined
ifndef VARIANT
VARIANT=OPT
@@ -372,14 +365,17 @@ ifeq ($(PLATFORM), windows)
REQUIRED_FREE_SPACE=500000
OS_VENDOR = Microsoft
# How much RAM does this machine have:
- MB_OF_MEMORY := $(shell \
- if [ -f "C:/cygwin/bin/free.exe" ] ; then \
- ( C:/cygwin/bin/bash.exe -c "C:/cygwin/bin/free.exe -m" ) | \
- grep Mem: | \
- sed -e 's@\ \ *@ @g' | cut -d' ' -f2 ; \
- else \
- echo "512"; \
- fi)
+ ifndef MB_OF_MEMORY
+ MB_OF_MEMORY := $(shell \
+ if [ -f "C:/cygwin/bin/free.exe" ] ; then \
+ ( C:/cygwin/bin/bash.exe -c "C:/cygwin/bin/free.exe -m" ) | \
+ grep Mem: | \
+ sed -e 's@\ \ *@ @g' | cut -d' ' -f2 ; \
+ else \
+ echo "512"; \
+ fi)
+ export MB_OF_MEMORY
+ endif
endif
# Machines with 512Mb or less of real memory are considered low memory
@@ -387,30 +383,36 @@ endif
# system swapping during the build.
# If we don't know, assume 512. Subtract 128 from MB for VM MAX.
# Don't set VM max over 1024-128=896.
-ifneq ($(MB_OF_MEMORY),)
- LOW_MEMORY_MACHINE := $(shell \
- if [ $(MB_OF_MEMORY) -le 512 ] ; then \
- echo "true"; \
- else \
- echo "false"; \
- fi)
- MAX_VM_MEMORY := $(shell \
- if [ $(MB_OF_MEMORY) -le 1024 ] ; then \
- expr $(MB_OF_MEMORY) '-' 128 ; \
- else \
- echo "896"; \
- fi)
- MIN_VM_MEMORY := $(shell \
- if [ $(MAX_VM_MEMORY) -le 128 ] ; then \
- expr $(MAX_VM_MEMORY) '-' 8 ; \
- else \
- echo "128"; \
- fi)
-else
- MB_OF_MEMORY := unknown
- LOW_MEMORY_MACHINE := true
- MAX_VM_MEMORY := 384
- MIN_VM_MEMORY := 128
+ifndef MAX_VM_MEMORY
+ ifneq ($(MB_OF_MEMORY),)
+ LOW_MEMORY_MACHINE := $(shell \
+ if [ $(MB_OF_MEMORY) -le 512 ] ; then \
+ echo "true"; \
+ else \
+ echo "false"; \
+ fi)
+ MAX_VM_MEMORY := $(shell \
+ if [ $(MB_OF_MEMORY) -le 1024 ] ; then \
+ expr $(MB_OF_MEMORY) '-' 128 ; \
+ else \
+ echo "896"; \
+ fi)
+ MIN_VM_MEMORY := $(shell \
+ if [ $(MAX_VM_MEMORY) -le 128 ] ; then \
+ expr $(MAX_VM_MEMORY) '-' 8 ; \
+ else \
+ echo "128"; \
+ fi)
+ else
+ MB_OF_MEMORY := unknown
+ LOW_MEMORY_MACHINE := true
+ MAX_VM_MEMORY := 384
+ MIN_VM_MEMORY := 128
+ endif
+ export MAX_VM_MEMORY
+ export MIN_VM_MEMORY
+ export LOW_MEMORY_MACHINE
+ export MAX_VM_MEMORY
endif
REQUIRED_ZIP_VER = 2.2
diff --git a/corba/make/jprt.properties b/corba/make/jprt.properties
index 928f5998a4c..d932b72d9a3 100644
--- a/corba/make/jprt.properties
+++ b/corba/make/jprt.properties
@@ -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
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index ae801762b3b..92383ca276a 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -45,3 +45,6 @@ ba313800759b678979434d6da8ed3bf49eb8bea4 jdk7-b65
d07e68298d4e17ebf93d8299e43fcc3ded26472a jdk7-b68
54fd4d9232969ea6cd3d236e5ad276183bb0d423 jdk7-b69
0632c3e615a315ff11e2ab1d64f4d82ff9853461 jdk7-b70
+50a95aa4a247f0cbbf66df285a8b1d78ffb153d9 jdk7-b71
+a94714c550658fd6741793ef036cb9625dc2ab1a jdk7-b72
+faf94d94786b621f8e13cbcc941ca69c6d967c3f jdk7-b73
diff --git a/hotspot/agent/make/saenv.sh b/hotspot/agent/make/saenv.sh
index 1487716b380..81faf5e3c94 100644
--- a/hotspot/agent/make/saenv.sh
+++ b/hotspot/agent/make/saenv.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2003-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
diff --git a/hotspot/agent/make/saenv64.sh b/hotspot/agent/make/saenv64.sh
index e28df4ee6ec..6990c4f5a0b 100644
--- a/hotspot/agent/make/saenv64.sh
+++ b/hotspot/agent/make/saenv64.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2003-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
diff --git a/hotspot/agent/src/os/solaris/proc/Makefile b/hotspot/agent/src/os/solaris/proc/Makefile
index 4696662aa6d..46013cf81c6 100644
--- a/hotspot/agent/src/os/solaris/proc/Makefile
+++ b/hotspot/agent/src/os/solaris/proc/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2002-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
diff --git a/hotspot/agent/src/os/solaris/proc/mapfile b/hotspot/agent/src/os/solaris/proc/mapfile
index eaa63b0adf0..375b9180352 100644
--- a/hotspot/agent/src/os/solaris/proc/mapfile
+++ b/hotspot/agent/src/os/solaris/proc/mapfile
@@ -1,7 +1,7 @@
#
#
-# Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2003-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
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java
index 570c5814e9b..9fc04f5dfb5 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/CodeCache.java
@@ -33,6 +33,7 @@ import sun.jvm.hotspot.utilities.*;
public class CodeCache {
private static AddressField heapField;
+ private static AddressField scavengeRootNMethodsField;
private static VirtualConstructor virtualConstructor;
private CodeHeap heap;
@@ -49,6 +50,7 @@ public class CodeCache {
Type type = db.lookupType("CodeCache");
heapField = type.getAddressField("_heap");
+ scavengeRootNMethodsField = type.getAddressField("_scavenge_root_nmethods");
virtualConstructor = new VirtualConstructor(db);
// Add mappings for all possible CodeBlob subclasses
@@ -67,6 +69,10 @@ public class CodeCache {
heap = (CodeHeap) VMObjectFactory.newObject(CodeHeap.class, heapField.getValue());
}
+ public NMethod scavengeRootMethods() {
+ return (NMethod) VMObjectFactory.newObject(NMethod.class, scavengeRootNMethodsField.getValue());
+ }
+
public boolean contains(Address p) {
return getHeap().contains(p);
}
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java
index 36bcd026096..7f48d5807ee 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java
@@ -40,7 +40,10 @@ public class NMethod extends CodeBlob {
/** != InvocationEntryBci if this nmethod is an on-stack replacement method */
private static CIntegerField entryBCIField;
/** To support simple linked-list chaining of nmethods */
- private static AddressField linkField;
+ private static AddressField osrLinkField;
+ private static AddressField scavengeRootLinkField;
+ private static CIntegerField scavengeRootStateField;
+
/** Offsets for different nmethod parts */
private static CIntegerField exceptionOffsetField;
private static CIntegerField deoptOffsetField;
@@ -87,7 +90,10 @@ public class NMethod extends CodeBlob {
zombieInstructionSizeField = type.getCIntegerField("_zombie_instruction_size");
methodField = type.getOopField("_method");
entryBCIField = type.getCIntegerField("_entry_bci");
- linkField = type.getAddressField("_link");
+ osrLinkField = type.getAddressField("_osr_link");
+ scavengeRootLinkField = type.getAddressField("_scavenge_root_link");
+ scavengeRootStateField = type.getCIntegerField("_scavenge_root_state");
+
exceptionOffsetField = type.getCIntegerField("_exception_offset");
deoptOffsetField = type.getCIntegerField("_deoptimize_offset");
origPCOffsetField = type.getCIntegerField("_orig_pc_offset");
@@ -219,10 +225,19 @@ public class NMethod extends CodeBlob {
return getEntryBCI();
}
- public NMethod getLink() {
- return (NMethod) VMObjectFactory.newObject(NMethod.class, linkField.getValue(addr));
+ public NMethod getOSRLink() {
+ return (NMethod) VMObjectFactory.newObject(NMethod.class, osrLinkField.getValue(addr));
}
+ public NMethod getScavengeRootLink() {
+ return (NMethod) VMObjectFactory.newObject(NMethod.class, scavengeRootLinkField.getValue(addr));
+ }
+
+ public int getScavengeRootState() {
+ return (int) scavengeRootStateField.getValue(addr);
+ }
+
+
/** Tells whether frames described by this nmethod can be
deoptimized. Note: native wrappers cannot be deoptimized. */
public boolean canBeDeoptimized() { return isJavaMethod(); }
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java
index e8ffd9bbf18..48cb4edbcd2 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-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
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/FreeChunk.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/FreeChunk.java
index db7628e196b..28b94a969c7 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/FreeChunk.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/FreeChunk.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-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
diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version
index 1e60768f056..480b8edfc1a 100644
--- a/hotspot/make/hotspot_version
+++ b/hotspot/make/hotspot_version
@@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2009
HS_MAJOR_VER=17
HS_MINOR_VER=0
-HS_BUILD_NUMBER=01
+HS_BUILD_NUMBER=03
JDK_MAJOR_VER=1
JDK_MINOR_VER=7
diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp
index b53cc4f737a..5899e4e9ae9 100644
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp
@@ -4676,3 +4676,50 @@ void MacroAssembler::reinit_heapbase() {
load_ptr_contents(base, G6_heapbase);
}
}
+
+// Compare char[] arrays aligned to 4 bytes.
+void MacroAssembler::char_arrays_equals(Register ary1, Register ary2,
+ Register limit, Register result,
+ Register chr1, Register chr2, Label& Ldone) {
+ Label Lvector, Lloop;
+ assert(chr1 == result, "should be the same");
+
+ // Note: limit contains number of bytes (2*char_elements) != 0.
+ andcc(limit, 0x2, chr1); // trailing character ?
+ br(Assembler::zero, false, Assembler::pt, Lvector);
+ delayed()->nop();
+
+ // compare the trailing char
+ sub(limit, sizeof(jchar), limit);
+ lduh(ary1, limit, chr1);
+ lduh(ary2, limit, chr2);
+ cmp(chr1, chr2);
+ br(Assembler::notEqual, true, Assembler::pt, Ldone);
+ delayed()->mov(G0, result); // not equal
+
+ // only one char ?
+ br_on_reg_cond(rc_z, true, Assembler::pn, limit, Ldone);
+ delayed()->add(G0, 1, result); // zero-length arrays are equal
+
+ // word by word compare, dont't need alignment check
+ bind(Lvector);
+ // Shift ary1 and ary2 to the end of the arrays, negate limit
+ add(ary1, limit, ary1);
+ add(ary2, limit, ary2);
+ neg(limit, limit);
+
+ lduw(ary1, limit, chr1);
+ bind(Lloop);
+ lduw(ary2, limit, chr2);
+ cmp(chr1, chr2);
+ br(Assembler::notEqual, true, Assembler::pt, Ldone);
+ delayed()->mov(G0, result); // not equal
+ inccc(limit, 2*sizeof(jchar));
+ // annul LDUW if branch is not taken to prevent access past end of array
+ br(Assembler::notZero, true, Assembler::pt, Lloop);
+ delayed()->lduw(ary1, limit, chr1); // hoisted
+
+ // Caller should set it:
+ // add(G0, 1, result); // equals
+}
+
diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp
index cd538ada404..163c59783b1 100644
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp
@@ -2455,6 +2455,11 @@ public:
void inc_counter(address counter_addr, Register Rtmp1, Register Rtmp2);
void inc_counter(int* counter_addr, Register Rtmp1, Register Rtmp2);
+ // Compare char[] arrays aligned to 4 bytes.
+ void char_arrays_equals(Register ary1, Register ary2,
+ Register limit, Register result,
+ Register chr1, Register chr2, Label& Ldone);
+
#undef VIRTUAL
};
diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
index c542a8bef07..2583f7cee23 100644
--- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
@@ -2171,7 +2171,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
// subtype which we can't check or src is the same array as dst
// but not necessarily exactly of type default_type.
Label known_ok, halt;
- jobject2reg(op->expected_type()->encoding(), tmp);
+ jobject2reg(op->expected_type()->constant_encoding(), tmp);
__ ld_ptr(dst, oopDesc::klass_offset_in_bytes(), tmp2);
if (basic_type != T_OBJECT) {
__ cmp(tmp, tmp2);
@@ -2429,7 +2429,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
assert(data->is_BitData(), "need BitData for checkcast");
Register mdo = k_RInfo;
Register data_val = Rtmp1;
- jobject2reg(md->encoding(), mdo);
+ jobject2reg(md->constant_encoding(), mdo);
int mdo_offset_bias = 0;
if (!Assembler::is_simm13(md->byte_offset_of_slot(data, DataLayout::header_offset()) + data->size_in_bytes())) {
@@ -2452,7 +2452,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
// patching may screw with our temporaries on sparc,
// so let's do it before loading the class
if (k->is_loaded()) {
- jobject2reg(k->encoding(), k_RInfo);
+ jobject2reg(k->constant_encoding(), k_RInfo);
} else {
jobject2reg_with_patching(k_RInfo, op->info_for_patch());
}
@@ -2513,7 +2513,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
// patching may screw with our temporaries on sparc,
// so let's do it before loading the class
if (k->is_loaded()) {
- jobject2reg(k->encoding(), k_RInfo);
+ jobject2reg(k->constant_encoding(), k_RInfo);
} else {
jobject2reg_with_patching(k_RInfo, op->info_for_patch());
}
@@ -2717,7 +2717,7 @@ void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
assert(op->tmp1()->is_single_cpu(), "tmp1 must be allocated");
Register mdo = op->mdo()->as_register();
Register tmp1 = op->tmp1()->as_register();
- jobject2reg(md->encoding(), mdo);
+ jobject2reg(md->constant_encoding(), mdo);
int mdo_offset_bias = 0;
if (!Assembler::is_simm13(md->byte_offset_of_slot(data, CounterData::count_offset()) +
data->size_in_bytes())) {
@@ -2774,7 +2774,7 @@ void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
if (receiver == NULL) {
Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)) -
mdo_offset_bias);
- jobject2reg(known_klass->encoding(), tmp1);
+ jobject2reg(known_klass->constant_encoding(), tmp1);
__ st_ptr(tmp1, recv_addr);
Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) -
mdo_offset_bias);
diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp
index f9e123bbb2e..2a69ade2156 100644
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp
@@ -668,7 +668,7 @@ void LIRGenerator::do_CompareAndSwap(Intrinsic* x, ValueType* type) {
__ add(obj.result(), offset.result(), addr);
if (type == objectType) { // Write-barrier needed for Object fields.
- pre_barrier(obj.result(), false, NULL);
+ pre_barrier(addr, false, NULL);
}
if (type == objectType)
@@ -896,7 +896,7 @@ void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
LIR_Opr len = length.result();
BasicType elem_type = x->elt_type();
- __ oop2reg(ciTypeArrayKlass::make(elem_type)->encoding(), klass_reg);
+ __ oop2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg);
CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info);
__ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path);
diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad
index 9751224d772..4852ee53210 100644
--- a/hotspot/src/cpu/sparc/vm/sparc.ad
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad
@@ -2838,63 +2838,41 @@ enc_class Fast_Unlock(iRegP oop, iRegP box, o7RegP scratch, iRegP scratch2) %{
%}
- enc_class enc_String_Compare(o0RegP str1, o1RegP str2, g3RegP tmp1, g4RegP tmp2, notemp_iRegI result) %{
+ enc_class enc_String_Compare(o0RegP str1, o1RegP str2, g3RegI cnt1, g4RegI cnt2, notemp_iRegI result) %{
Label Ldone, Lloop;
MacroAssembler _masm(&cbuf);
Register str1_reg = reg_to_register_object($str1$$reg);
Register str2_reg = reg_to_register_object($str2$$reg);
- Register tmp1_reg = reg_to_register_object($tmp1$$reg);
- Register tmp2_reg = reg_to_register_object($tmp2$$reg);
+ Register cnt1_reg = reg_to_register_object($cnt1$$reg);
+ Register cnt2_reg = reg_to_register_object($cnt2$$reg);
Register result_reg = reg_to_register_object($result$$reg);
- // Get the first character position in both strings
- // [8] char array, [12] offset, [16] count
- int value_offset = java_lang_String:: value_offset_in_bytes();
- int offset_offset = java_lang_String::offset_offset_in_bytes();
- int count_offset = java_lang_String:: count_offset_in_bytes();
-
- // load str1 (jchar*) base address into tmp1_reg
- __ load_heap_oop(str1_reg, value_offset, tmp1_reg);
- __ ld(str1_reg, offset_offset, result_reg);
- __ add(tmp1_reg, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp1_reg);
- __ ld(str1_reg, count_offset, str1_reg); // hoisted
- __ sll(result_reg, exact_log2(sizeof(jchar)), result_reg);
- __ load_heap_oop(str2_reg, value_offset, tmp2_reg); // hoisted
- __ add(result_reg, tmp1_reg, tmp1_reg);
-
- // load str2 (jchar*) base address into tmp2_reg
- // __ ld_ptr(str2_reg, value_offset, tmp2_reg); // hoisted
- __ ld(str2_reg, offset_offset, result_reg);
- __ add(tmp2_reg, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp2_reg);
- __ ld(str2_reg, count_offset, str2_reg); // hoisted
- __ sll(result_reg, exact_log2(sizeof(jchar)), result_reg);
- __ subcc(str1_reg, str2_reg, O7); // hoisted
- __ add(result_reg, tmp2_reg, tmp2_reg);
+ assert(result_reg != str1_reg &&
+ result_reg != str2_reg &&
+ result_reg != cnt1_reg &&
+ result_reg != cnt2_reg ,
+ "need different registers");
// Compute the minimum of the string lengths(str1_reg) and the
// difference of the string lengths (stack)
- // discard string base pointers, after loading up the lengths
- // __ ld(str1_reg, count_offset, str1_reg); // hoisted
- // __ ld(str2_reg, count_offset, str2_reg); // hoisted
-
// See if the lengths are different, and calculate min in str1_reg.
// Stash diff in O7 in case we need it for a tie-breaker.
Label Lskip;
- // __ subcc(str1_reg, str2_reg, O7); // hoisted
- __ sll(str1_reg, exact_log2(sizeof(jchar)), str1_reg); // scale the limit
+ __ subcc(cnt1_reg, cnt2_reg, O7);
+ __ sll(cnt1_reg, exact_log2(sizeof(jchar)), cnt1_reg); // scale the limit
__ br(Assembler::greater, true, Assembler::pt, Lskip);
- // str2 is shorter, so use its count:
- __ delayed()->sll(str2_reg, exact_log2(sizeof(jchar)), str1_reg); // scale the limit
+ // cnt2 is shorter, so use its count:
+ __ delayed()->sll(cnt2_reg, exact_log2(sizeof(jchar)), cnt1_reg); // scale the limit
__ bind(Lskip);
- // reallocate str1_reg, str2_reg, result_reg
+ // reallocate cnt1_reg, cnt2_reg, result_reg
// Note: limit_reg holds the string length pre-scaled by 2
- Register limit_reg = str1_reg;
- Register chr2_reg = str2_reg;
+ Register limit_reg = cnt1_reg;
+ Register chr2_reg = cnt2_reg;
Register chr1_reg = result_reg;
- // tmp{12} are the base pointers
+ // str{12} are the base pointers
// Is the minimum length zero?
__ cmp(limit_reg, (int)(0 * sizeof(jchar))); // use cast to resolve overloading ambiguity
@@ -2902,8 +2880,8 @@ enc_class Fast_Unlock(iRegP oop, iRegP box, o7RegP scratch, iRegP scratch2) %{
__ delayed()->mov(O7, result_reg); // result is difference in lengths
// Load first characters
- __ lduh(tmp1_reg, 0, chr1_reg);
- __ lduh(tmp2_reg, 0, chr2_reg);
+ __ lduh(str1_reg, 0, chr1_reg);
+ __ lduh(str2_reg, 0, chr2_reg);
// Compare first characters
__ subcc(chr1_reg, chr2_reg, chr1_reg);
@@ -2915,7 +2893,7 @@ enc_class Fast_Unlock(iRegP oop, iRegP box, o7RegP scratch, iRegP scratch2) %{
// Check after comparing first character to see if strings are equivalent
Label LSkip2;
// Check if the strings start at same location
- __ cmp(tmp1_reg, tmp2_reg);
+ __ cmp(str1_reg, str2_reg);
__ brx(Assembler::notEqual, true, Assembler::pt, LSkip2);
__ delayed()->nop();
@@ -2932,23 +2910,23 @@ enc_class Fast_Unlock(iRegP oop, iRegP box, o7RegP scratch, iRegP scratch2) %{
__ br(Assembler::equal, true, Assembler::pn, Ldone);
__ delayed()->mov(O7, result_reg); // result is difference in lengths
- // Shift tmp1_reg and tmp2_reg to the end of the arrays, negate limit
- __ add(tmp1_reg, limit_reg, tmp1_reg);
- __ add(tmp2_reg, limit_reg, tmp2_reg);
+ // Shift str1_reg and str2_reg to the end of the arrays, negate limit
+ __ add(str1_reg, limit_reg, str1_reg);
+ __ add(str2_reg, limit_reg, str2_reg);
__ neg(chr1_reg, limit_reg); // limit = -(limit-2)
// Compare the rest of the characters
- __ lduh(tmp1_reg, limit_reg, chr1_reg);
+ __ lduh(str1_reg, limit_reg, chr1_reg);
__ bind(Lloop);
- // __ lduh(tmp1_reg, limit_reg, chr1_reg); // hoisted
- __ lduh(tmp2_reg, limit_reg, chr2_reg);
+ // __ lduh(str1_reg, limit_reg, chr1_reg); // hoisted
+ __ lduh(str2_reg, limit_reg, chr2_reg);
__ subcc(chr1_reg, chr2_reg, chr1_reg);
__ br(Assembler::notZero, false, Assembler::pt, Ldone);
assert(chr1_reg == result_reg, "result must be pre-placed");
__ delayed()->inccc(limit_reg, sizeof(jchar));
// annul LDUH if branch is not taken to prevent access past end of string
__ br(Assembler::notZero, true, Assembler::pt, Lloop);
- __ delayed()->lduh(tmp1_reg, limit_reg, chr1_reg); // hoisted
+ __ delayed()->lduh(str1_reg, limit_reg, chr1_reg); // hoisted
// If strings are equal up to min length, return the length difference.
__ mov(O7, result_reg);
@@ -2957,125 +2935,80 @@ enc_class Fast_Unlock(iRegP oop, iRegP box, o7RegP scratch, iRegP scratch2) %{
__ bind(Ldone);
%}
-enc_class enc_String_Equals(o0RegP str1, o1RegP str2, g3RegP tmp1, g4RegP tmp2, notemp_iRegI result) %{
- Label Lword, Lword_loop, Lpost_word, Lchar, Lchar_loop, Ldone;
+enc_class enc_String_Equals(o0RegP str1, o1RegP str2, g3RegI cnt, notemp_iRegI result) %{
+ Label Lword_loop, Lpost_word, Lchar, Lchar_loop, Ldone;
MacroAssembler _masm(&cbuf);
Register str1_reg = reg_to_register_object($str1$$reg);
Register str2_reg = reg_to_register_object($str2$$reg);
- Register tmp1_reg = reg_to_register_object($tmp1$$reg);
- Register tmp2_reg = reg_to_register_object($tmp2$$reg);
+ Register cnt_reg = reg_to_register_object($cnt$$reg);
+ Register tmp1_reg = O7;
Register result_reg = reg_to_register_object($result$$reg);
- // Get the first character position in both strings
- // [8] char array, [12] offset, [16] count
- int value_offset = java_lang_String:: value_offset_in_bytes();
- int offset_offset = java_lang_String::offset_offset_in_bytes();
- int count_offset = java_lang_String:: count_offset_in_bytes();
+ assert(result_reg != str1_reg &&
+ result_reg != str2_reg &&
+ result_reg != cnt_reg &&
+ result_reg != tmp1_reg ,
+ "need different registers");
- // load str1 (jchar*) base address into tmp1_reg
- __ load_heap_oop(Address(str1_reg, value_offset), tmp1_reg);
- __ ld(Address(str1_reg, offset_offset), result_reg);
- __ add(tmp1_reg, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp1_reg);
- __ ld(Address(str1_reg, count_offset), str1_reg); // hoisted
- __ sll(result_reg, exact_log2(sizeof(jchar)), result_reg);
- __ load_heap_oop(Address(str2_reg, value_offset), tmp2_reg); // hoisted
- __ add(result_reg, tmp1_reg, tmp1_reg);
-
- // load str2 (jchar*) base address into tmp2_reg
- // __ ld_ptr(Address(str2_reg, value_offset), tmp2_reg); // hoisted
- __ ld(Address(str2_reg, offset_offset), result_reg);
- __ add(tmp2_reg, arrayOopDesc::base_offset_in_bytes(T_CHAR), tmp2_reg);
- __ ld(Address(str2_reg, count_offset), str2_reg); // hoisted
- __ sll(result_reg, exact_log2(sizeof(jchar)), result_reg);
- __ cmp(str1_reg, str2_reg); // hoisted
- __ add(result_reg, tmp2_reg, tmp2_reg);
-
- __ sll(str1_reg, exact_log2(sizeof(jchar)), str1_reg);
- __ br(Assembler::notEqual, true, Assembler::pt, Ldone);
- __ delayed()->mov(G0, result_reg); // not equal
-
- __ br_zero(Assembler::equal, true, Assembler::pn, str1_reg, Ldone);
- __ delayed()->add(G0, 1, result_reg); //equals
-
- __ cmp(tmp1_reg, tmp2_reg); //same string ?
+ __ cmp(str1_reg, str2_reg); //same char[] ?
__ brx(Assembler::equal, true, Assembler::pn, Ldone);
__ delayed()->add(G0, 1, result_reg);
+ __ br_on_reg_cond(Assembler::rc_z, true, Assembler::pn, cnt_reg, Ldone);
+ __ delayed()->add(G0, 1, result_reg); // count == 0
+
//rename registers
- Register limit_reg = str1_reg;
- Register chr2_reg = str2_reg;
+ Register limit_reg = cnt_reg;
Register chr1_reg = result_reg;
- // tmp{12} are the base pointers
+ Register chr2_reg = tmp1_reg;
//check for alignment and position the pointers to the ends
- __ or3(tmp1_reg, tmp2_reg, chr1_reg);
- __ andcc(chr1_reg, 0x3, chr1_reg); // notZero means at least one not 4-byte aligned
- __ br(Assembler::notZero, false, Assembler::pn, Lchar);
- __ delayed()->nop();
+ __ or3(str1_reg, str2_reg, chr1_reg);
+ __ andcc(chr1_reg, 0x3, chr1_reg);
+ // notZero means at least one not 4-byte aligned.
+ // We could optimize the case when both arrays are not aligned
+ // but it is not frequent case and it requires additional checks.
+ __ br(Assembler::notZero, false, Assembler::pn, Lchar); // char by char compare
+ __ delayed()->sll(limit_reg, exact_log2(sizeof(jchar)), limit_reg); // set byte count
- __ bind(Lword);
- __ and3(limit_reg, 0x2, O7); //remember the remainder (either 0 or 2)
- __ andn(limit_reg, 0x3, limit_reg);
- __ br_zero(Assembler::zero, false, Assembler::pn, limit_reg, Lpost_word);
- __ delayed()->nop();
-
- __ add(tmp1_reg, limit_reg, tmp1_reg);
- __ add(tmp2_reg, limit_reg, tmp2_reg);
- __ neg(limit_reg);
-
- __ lduw(tmp1_reg, limit_reg, chr1_reg);
- __ bind(Lword_loop);
- __ lduw(tmp2_reg, limit_reg, chr2_reg);
- __ cmp(chr1_reg, chr2_reg);
- __ br(Assembler::notEqual, true, Assembler::pt, Ldone);
- __ delayed()->mov(G0, result_reg);
- __ inccc(limit_reg, 2*sizeof(jchar));
- // annul LDUW if branch i s not taken to prevent access past end of string
- __ br(Assembler::notZero, true, Assembler::pt, Lword_loop); //annul on taken
- __ delayed()->lduw(tmp1_reg, limit_reg, chr1_reg); // hoisted
-
- __ bind(Lpost_word);
- __ br_zero(Assembler::zero, true, Assembler::pt, O7, Ldone);
- __ delayed()->add(G0, 1, result_reg);
-
- __ lduh(tmp1_reg, 0, chr1_reg);
- __ lduh(tmp2_reg, 0, chr2_reg);
- __ cmp (chr1_reg, chr2_reg);
- __ br(Assembler::notEqual, true, Assembler::pt, Ldone);
- __ delayed()->mov(G0, result_reg);
+ // Compare char[] arrays aligned to 4 bytes.
+ __ char_arrays_equals(str1_reg, str2_reg, limit_reg, result_reg,
+ chr1_reg, chr2_reg, Ldone);
__ ba(false,Ldone);
__ delayed()->add(G0, 1, result_reg);
+ // char by char compare
__ bind(Lchar);
- __ add(tmp1_reg, limit_reg, tmp1_reg);
- __ add(tmp2_reg, limit_reg, tmp2_reg);
+ __ add(str1_reg, limit_reg, str1_reg);
+ __ add(str2_reg, limit_reg, str2_reg);
__ neg(limit_reg); //negate count
- __ lduh(tmp1_reg, limit_reg, chr1_reg);
+ __ lduh(str1_reg, limit_reg, chr1_reg);
+ // Lchar_loop
__ bind(Lchar_loop);
- __ lduh(tmp2_reg, limit_reg, chr2_reg);
+ __ lduh(str2_reg, limit_reg, chr2_reg);
__ cmp(chr1_reg, chr2_reg);
__ br(Assembler::notEqual, true, Assembler::pt, Ldone);
__ delayed()->mov(G0, result_reg); //not equal
__ inccc(limit_reg, sizeof(jchar));
// annul LDUH if branch is not taken to prevent access past end of string
- __ br(Assembler::notZero, true, Assembler::pt, Lchar_loop); //annul on taken
- __ delayed()->lduh(tmp1_reg, limit_reg, chr1_reg); // hoisted
+ __ br(Assembler::notZero, true, Assembler::pt, Lchar_loop);
+ __ delayed()->lduh(str1_reg, limit_reg, chr1_reg); // hoisted
__ add(G0, 1, result_reg); //equal
__ bind(Ldone);
%}
-enc_class enc_Array_Equals(o0RegP ary1, o1RegP ary2, g3RegP tmp1, g4RegP tmp2, notemp_iRegI result) %{
+enc_class enc_Array_Equals(o0RegP ary1, o1RegP ary2, g3RegP tmp1, notemp_iRegI result) %{
Label Lvector, Ldone, Lloop;
MacroAssembler _masm(&cbuf);
Register ary1_reg = reg_to_register_object($ary1$$reg);
Register ary2_reg = reg_to_register_object($ary2$$reg);
Register tmp1_reg = reg_to_register_object($tmp1$$reg);
- Register tmp2_reg = reg_to_register_object($tmp2$$reg);
+ Register tmp2_reg = O7;
Register result_reg = reg_to_register_object($result$$reg);
int length_offset = arrayOopDesc::length_offset_in_bytes();
@@ -3101,7 +3034,7 @@ enc_class enc_Array_Equals(o0RegP ary1, o1RegP ary2, g3RegP tmp1, g4RegP tmp2, n
__ br(Assembler::notEqual, true, Assembler::pn, Ldone);
__ delayed()->mov(G0, result_reg); // not equal
- __ br_zero(Assembler::zero, true, Assembler::pn, tmp1_reg, Ldone);
+ __ br_on_reg_cond(Assembler::rc_z, true, Assembler::pn, tmp1_reg, Ldone);
__ delayed()->add(G0, 1, result_reg); // zero-length arrays are equal
// load array addresses
@@ -3109,45 +3042,16 @@ enc_class enc_Array_Equals(o0RegP ary1, o1RegP ary2, g3RegP tmp1, g4RegP tmp2, n
__ add(ary2_reg, base_offset, ary2_reg);
// renaming registers
- Register chr1_reg = tmp2_reg; // for characters in ary1
- Register chr2_reg = result_reg; // for characters in ary2
+ Register chr1_reg = result_reg; // for characters in ary1
+ Register chr2_reg = tmp2_reg; // for characters in ary2
Register limit_reg = tmp1_reg; // length
// set byte count
__ sll(limit_reg, exact_log2(sizeof(jchar)), limit_reg);
- __ andcc(limit_reg, 0x2, chr1_reg); //trailing character ?
- __ br(Assembler::zero, false, Assembler::pt, Lvector);
- __ delayed()->nop();
-
- //compare the trailing char
- __ sub(limit_reg, sizeof(jchar), limit_reg);
- __ lduh(ary1_reg, limit_reg, chr1_reg);
- __ lduh(ary2_reg, limit_reg, chr2_reg);
- __ cmp(chr1_reg, chr2_reg);
- __ br(Assembler::notEqual, true, Assembler::pt, Ldone);
- __ delayed()->mov(G0, result_reg); // not equal
-
- // only one char ?
- __ br_zero(Assembler::zero, true, Assembler::pn, limit_reg, Ldone);
- __ delayed()->add(G0, 1, result_reg); // zero-length arrays are equal
-
- __ bind(Lvector);
- // Shift ary1_reg and ary2_reg to the end of the arrays, negate limit
- __ add(ary1_reg, limit_reg, ary1_reg);
- __ add(ary2_reg, limit_reg, ary2_reg);
- __ neg(limit_reg, limit_reg);
-
- __ lduw(ary1_reg, limit_reg, chr1_reg);
- __ bind(Lloop);
- __ lduw(ary2_reg, limit_reg, chr2_reg);
- __ cmp(chr1_reg, chr2_reg);
- __ br(Assembler::notEqual, false, Assembler::pt, Ldone);
- __ delayed()->mov(G0, result_reg); // not equal
- __ inccc(limit_reg, 2*sizeof(jchar));
- // annul LDUW if branch is not taken to prevent access past end of string
- __ br(Assembler::notZero, true, Assembler::pt, Lloop); //annul on taken
- __ delayed()->lduw(ary1_reg, limit_reg, chr1_reg); // hoisted
+ // Compare char[] arrays aligned to 4 bytes.
+ __ char_arrays_equals(ary1_reg, ary2_reg, limit_reg, result_reg,
+ chr1_reg, chr2_reg, Ldone);
__ add(G0, 1, result_reg); // equals
__ bind(Ldone);
@@ -9471,33 +9375,33 @@ instruct clear_array(iRegX cnt, iRegP base, iRegX temp, Universe dummy, flagsReg
ins_pipe(long_memory_op);
%}
-instruct string_compare(o0RegP str1, o1RegP str2, g3RegP tmp1, g4RegP tmp2, notemp_iRegI result,
- o7RegI tmp3, flagsReg ccr) %{
- match(Set result (StrComp str1 str2));
- effect(USE_KILL str1, USE_KILL str2, KILL tmp1, KILL tmp2, KILL ccr, KILL tmp3);
+instruct string_compare(o0RegP str1, o1RegP str2, g3RegI cnt1, g4RegI cnt2, notemp_iRegI result,
+ o7RegI tmp, flagsReg ccr) %{
+ match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
+ effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL ccr, KILL tmp);
ins_cost(300);
- format %{ "String Compare $str1,$str2 -> $result" %}
- ins_encode( enc_String_Compare(str1, str2, tmp1, tmp2, result) );
+ format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp" %}
+ ins_encode( enc_String_Compare(str1, str2, cnt1, cnt2, result) );
ins_pipe(long_memory_op);
%}
-instruct string_equals(o0RegP str1, o1RegP str2, g3RegP tmp1, g4RegP tmp2, notemp_iRegI result,
- o7RegI tmp3, flagsReg ccr) %{
- match(Set result (StrEquals str1 str2));
- effect(USE_KILL str1, USE_KILL str2, KILL tmp1, KILL tmp2, KILL ccr, KILL tmp3);
+instruct string_equals(o0RegP str1, o1RegP str2, g3RegI cnt, notemp_iRegI result,
+ o7RegI tmp, flagsReg ccr) %{
+ match(Set result (StrEquals (Binary str1 str2) cnt));
+ effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt, KILL tmp, KILL ccr);
ins_cost(300);
- format %{ "String Equals $str1,$str2 -> $result" %}
- ins_encode( enc_String_Equals(str1, str2, tmp1, tmp2, result) );
+ format %{ "String Equals $str1,$str2,$cnt -> $result // KILL $tmp" %}
+ ins_encode( enc_String_Equals(str1, str2, cnt, result) );
ins_pipe(long_memory_op);
%}
-instruct array_equals(o0RegP ary1, o1RegP ary2, g3RegP tmp1, g4RegP tmp2, notemp_iRegI result,
- flagsReg ccr) %{
+instruct array_equals(o0RegP ary1, o1RegP ary2, g3RegI tmp1, notemp_iRegI result,
+ o7RegI tmp2, flagsReg ccr) %{
match(Set result (AryEq ary1 ary2));
effect(USE_KILL ary1, USE_KILL ary2, KILL tmp1, KILL tmp2, KILL ccr);
ins_cost(300);
- format %{ "Array Equals $ary1,$ary2 -> $result" %}
- ins_encode( enc_Array_Equals(ary1, ary2, tmp1, tmp2, result));
+ format %{ "Array Equals $ary1,$ary2 -> $result // KILL $tmp1,$tmp2" %}
+ ins_encode( enc_Array_Equals(ary1, ary2, tmp1, result));
ins_pipe(long_memory_op);
%}
diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp
index 20e6d08c48f..b742a5a36a7 100644
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp
@@ -8404,6 +8404,319 @@ void MacroAssembler::reinit_heapbase() {
}
#endif // _LP64
+// IndexOf substring.
+void MacroAssembler::string_indexof(Register str1, Register str2,
+ Register cnt1, Register cnt2, Register result,
+ XMMRegister vec, Register tmp) {
+ assert(UseSSE42Intrinsics, "SSE4.2 is required");
+
+ Label RELOAD_SUBSTR, PREP_FOR_SCAN, SCAN_TO_SUBSTR,
+ SCAN_SUBSTR, RET_NOT_FOUND, CLEANUP;
+
+ push(str1); // string addr
+ push(str2); // substr addr
+ push(cnt2); // substr count
+ jmpb(PREP_FOR_SCAN);
+
+ // Substr count saved at sp
+ // Substr saved at sp+1*wordSize
+ // String saved at sp+2*wordSize
+
+ // Reload substr for rescan
+ bind(RELOAD_SUBSTR);
+ movl(cnt2, Address(rsp, 0));
+ movptr(str2, Address(rsp, wordSize));
+ // We came here after the beginninig of the substring was
+ // matched but the rest of it was not so we need to search
+ // again. Start from the next element after the previous match.
+ subptr(str1, result); // Restore counter
+ shrl(str1, 1);
+ addl(cnt1, str1);
+ lea(str1, Address(result, 2)); // Reload string
+
+ // Load substr
+ bind(PREP_FOR_SCAN);
+ movdqu(vec, Address(str2, 0));
+ addl(cnt1, 8); // prime the loop
+ subptr(str1, 16);
+
+ // Scan string for substr in 16-byte vectors
+ bind(SCAN_TO_SUBSTR);
+ subl(cnt1, 8);
+ addptr(str1, 16);
+
+ // pcmpestri
+ // inputs:
+ // xmm - substring
+ // rax - substring length (elements count)
+ // mem - scaned string
+ // rdx - string length (elements count)
+ // 0xd - mode: 1100 (substring search) + 01 (unsigned shorts)
+ // outputs:
+ // rcx - matched index in string
+ assert(cnt1 == rdx && cnt2 == rax && tmp == rcx, "pcmpestri");
+
+ pcmpestri(vec, Address(str1, 0), 0x0d);
+ jcc(Assembler::above, SCAN_TO_SUBSTR); // CF == 0 && ZF == 0
+ jccb(Assembler::aboveEqual, RET_NOT_FOUND); // CF == 0
+
+ // Fallthrough: found a potential substr
+
+ // Make sure string is still long enough
+ subl(cnt1, tmp);
+ cmpl(cnt1, cnt2);
+ jccb(Assembler::negative, RET_NOT_FOUND);
+ // Compute start addr of substr
+ lea(str1, Address(str1, tmp, Address::times_2));
+ movptr(result, str1); // save
+
+ // Compare potential substr
+ addl(cnt1, 8); // prime the loop
+ addl(cnt2, 8);
+ subptr(str1, 16);
+ subptr(str2, 16);
+
+ // Scan 16-byte vectors of string and substr
+ bind(SCAN_SUBSTR);
+ subl(cnt1, 8);
+ subl(cnt2, 8);
+ addptr(str1, 16);
+ addptr(str2, 16);
+ movdqu(vec, Address(str2, 0));
+ pcmpestri(vec, Address(str1, 0), 0x0d);
+ jcc(Assembler::noOverflow, RELOAD_SUBSTR); // OF == 0
+ jcc(Assembler::positive, SCAN_SUBSTR); // SF == 0
+
+ // Compute substr offset
+ subptr(result, Address(rsp, 2*wordSize));
+ shrl(result, 1); // index
+ jmpb(CLEANUP);
+
+ bind(RET_NOT_FOUND);
+ movl(result, -1);
+
+ bind(CLEANUP);
+ addptr(rsp, 3*wordSize);
+}
+
+// Compare strings.
+void MacroAssembler::string_compare(Register str1, Register str2,
+ Register cnt1, Register cnt2, Register result,
+ XMMRegister vec1, XMMRegister vec2) {
+ Label LENGTH_DIFF_LABEL, POP_LABEL, DONE_LABEL, WHILE_HEAD_LABEL;
+
+ // Compute the minimum of the string lengths and the
+ // difference of the string lengths (stack).
+ // Do the conditional move stuff
+ movl(result, cnt1);
+ subl(cnt1, cnt2);
+ push(cnt1);
+ if (VM_Version::supports_cmov()) {
+ cmovl(Assembler::lessEqual, cnt2, result);
+ } else {
+ Label GT_LABEL;
+ jccb(Assembler::greater, GT_LABEL);
+ movl(cnt2, result);
+ bind(GT_LABEL);
+ }
+
+ // Is the minimum length zero?
+ testl(cnt2, cnt2);
+ jcc(Assembler::zero, LENGTH_DIFF_LABEL);
+
+ // Load first characters
+ load_unsigned_short(result, Address(str1, 0));
+ load_unsigned_short(cnt1, Address(str2, 0));
+
+ // Compare first characters
+ subl(result, cnt1);
+ jcc(Assembler::notZero, POP_LABEL);
+ decrementl(cnt2);
+ jcc(Assembler::zero, LENGTH_DIFF_LABEL);
+
+ {
+ // Check after comparing first character to see if strings are equivalent
+ Label LSkip2;
+ // Check if the strings start at same location
+ cmpptr(str1, str2);
+ jccb(Assembler::notEqual, LSkip2);
+
+ // Check if the length difference is zero (from stack)
+ cmpl(Address(rsp, 0), 0x0);
+ jcc(Assembler::equal, LENGTH_DIFF_LABEL);
+
+ // Strings might not be equivalent
+ bind(LSkip2);
+ }
+
+ // Advance to next character
+ addptr(str1, 2);
+ addptr(str2, 2);
+
+ if (UseSSE42Intrinsics) {
+ // With SSE4.2, use double quad vector compare
+ Label COMPARE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_TAIL;
+ // Setup to compare 16-byte vectors
+ movl(cnt1, cnt2);
+ andl(cnt2, 0xfffffff8); // cnt2 holds the vector count
+ andl(cnt1, 0x00000007); // cnt1 holds the tail count
+ testl(cnt2, cnt2);
+ jccb(Assembler::zero, COMPARE_TAIL);
+
+ lea(str2, Address(str2, cnt2, Address::times_2));
+ lea(str1, Address(str1, cnt2, Address::times_2));
+ negptr(cnt2);
+
+ bind(COMPARE_VECTORS);
+ movdqu(vec1, Address(str1, cnt2, Address::times_2));
+ movdqu(vec2, Address(str2, cnt2, Address::times_2));
+ pxor(vec1, vec2);
+ ptest(vec1, vec1);
+ jccb(Assembler::notZero, VECTOR_NOT_EQUAL);
+ addptr(cnt2, 8);
+ jcc(Assembler::notZero, COMPARE_VECTORS);
+ jmpb(COMPARE_TAIL);
+
+ // Mismatched characters in the vectors
+ bind(VECTOR_NOT_EQUAL);
+ lea(str1, Address(str1, cnt2, Address::times_2));
+ lea(str2, Address(str2, cnt2, Address::times_2));
+ movl(cnt1, 8);
+
+ // Compare tail (< 8 chars), or rescan last vectors to
+ // find 1st mismatched characters
+ bind(COMPARE_TAIL);
+ testl(cnt1, cnt1);
+ jccb(Assembler::zero, LENGTH_DIFF_LABEL);
+ movl(cnt2, cnt1);
+ // Fallthru to tail compare
+ }
+
+ // Shift str2 and str1 to the end of the arrays, negate min
+ lea(str1, Address(str1, cnt2, Address::times_2, 0));
+ lea(str2, Address(str2, cnt2, Address::times_2, 0));
+ negptr(cnt2);
+
+ // Compare the rest of the characters
+ bind(WHILE_HEAD_LABEL);
+ load_unsigned_short(result, Address(str1, cnt2, Address::times_2, 0));
+ load_unsigned_short(cnt1, Address(str2, cnt2, Address::times_2, 0));
+ subl(result, cnt1);
+ jccb(Assembler::notZero, POP_LABEL);
+ increment(cnt2);
+ jcc(Assembler::notZero, WHILE_HEAD_LABEL);
+
+ // Strings are equal up to min length. Return the length difference.
+ bind(LENGTH_DIFF_LABEL);
+ pop(result);
+ jmpb(DONE_LABEL);
+
+ // Discard the stored length difference
+ bind(POP_LABEL);
+ addptr(rsp, wordSize);
+
+ // That's it
+ bind(DONE_LABEL);
+}
+
+// Compare char[] arrays aligned to 4 bytes or substrings.
+void MacroAssembler::char_arrays_equals(bool is_array_equ, Register ary1, Register ary2,
+ Register limit, Register result, Register chr,
+ XMMRegister vec1, XMMRegister vec2) {
+ Label TRUE_LABEL, FALSE_LABEL, DONE, COMPARE_VECTORS, COMPARE_CHAR;
+
+ int length_offset = arrayOopDesc::length_offset_in_bytes();
+ int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
+
+ // Check the input args
+ cmpptr(ary1, ary2);
+ jcc(Assembler::equal, TRUE_LABEL);
+
+ if (is_array_equ) {
+ // Need additional checks for arrays_equals.
+ andptr(ary1, ary2);
+ jcc(Assembler::zero, FALSE_LABEL); // One pointer is NULL
+
+ // Check the lengths
+ movl(limit, Address(ary1, length_offset));
+ cmpl(limit, Address(ary2, length_offset));
+ jcc(Assembler::notEqual, FALSE_LABEL);
+ }
+
+ // count == 0
+ testl(limit, limit);
+ jcc(Assembler::zero, TRUE_LABEL);
+
+ if (is_array_equ) {
+ // Load array address
+ lea(ary1, Address(ary1, base_offset));
+ lea(ary2, Address(ary2, base_offset));
+ }
+
+ shll(limit, 1); // byte count != 0
+ movl(result, limit); // copy
+
+ if (UseSSE42Intrinsics) {
+ // With SSE4.2, use double quad vector compare
+ Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
+ // Compare 16-byte vectors
+ andl(result, 0x0000000e); // tail count (in bytes)
+ andl(limit, 0xfffffff0); // vector count (in bytes)
+ jccb(Assembler::zero, COMPARE_TAIL);
+
+ lea(ary1, Address(ary1, limit, Address::times_1));
+ lea(ary2, Address(ary2, limit, Address::times_1));
+ negptr(limit);
+
+ bind(COMPARE_WIDE_VECTORS);
+ movdqu(vec1, Address(ary1, limit, Address::times_1));
+ movdqu(vec2, Address(ary2, limit, Address::times_1));
+ pxor(vec1, vec2);
+ ptest(vec1, vec1);
+ jccb(Assembler::notZero, FALSE_LABEL);
+ addptr(limit, 16);
+ jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
+
+ bind(COMPARE_TAIL); // limit is zero
+ movl(limit, result);
+ // Fallthru to tail compare
+ }
+
+ // Compare 4-byte vectors
+ andl(limit, 0xfffffffc); // vector count (in bytes)
+ jccb(Assembler::zero, COMPARE_CHAR);
+
+ lea(ary1, Address(ary1, limit, Address::times_1));
+ lea(ary2, Address(ary2, limit, Address::times_1));
+ negptr(limit);
+
+ bind(COMPARE_VECTORS);
+ movl(chr, Address(ary1, limit, Address::times_1));
+ cmpl(chr, Address(ary2, limit, Address::times_1));
+ jccb(Assembler::notEqual, FALSE_LABEL);
+ addptr(limit, 4);
+ jcc(Assembler::notZero, COMPARE_VECTORS);
+
+ // Compare trailing char (final 2 bytes), if any
+ bind(COMPARE_CHAR);
+ testl(result, 0x2); // tail char
+ jccb(Assembler::zero, TRUE_LABEL);
+ load_unsigned_short(chr, Address(ary1, 0));
+ load_unsigned_short(limit, Address(ary2, 0));
+ cmpl(chr, limit);
+ jccb(Assembler::notEqual, FALSE_LABEL);
+
+ bind(TRUE_LABEL);
+ movl(result, 1); // return true
+ jmpb(DONE);
+
+ bind(FALSE_LABEL);
+ xorl(result, result); // return false
+
+ // That's it
+ bind(DONE);
+}
+
Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
switch (cond) {
// Note some conditions are synonyms for others
diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp
index 997b73445ea..2d61a3cf0aa 100644
--- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp
@@ -2206,6 +2206,20 @@ public:
void movl2ptr(Register dst, Address src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(movl(dst, src)); }
void movl2ptr(Register dst, Register src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(if (dst != src) movl(dst, src)); }
+ // IndexOf strings.
+ void string_indexof(Register str1, Register str2,
+ Register cnt1, Register cnt2, Register result,
+ XMMRegister vec, Register tmp);
+
+ // Compare strings.
+ void string_compare(Register str1, Register str2,
+ Register cnt1, Register cnt2, Register result,
+ XMMRegister vec1, XMMRegister vec2);
+
+ // Compare char[] arrays.
+ void char_arrays_equals(bool is_array_equ, Register ary1, Register ary2,
+ Register limit, Register result, Register chr,
+ XMMRegister vec1, XMMRegister vec2);
#undef VIRTUAL
diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
index 982f85f5e80..f8cdb23ee82 100644
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
@@ -1638,7 +1638,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
jobject2reg_with_patching(k_RInfo, op->info_for_patch());
} else {
#ifdef _LP64
- __ movoop(k_RInfo, k->encoding());
+ __ movoop(k_RInfo, k->constant_encoding());
#else
k_RInfo = noreg;
#endif // _LP64
@@ -1661,7 +1661,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
assert(data != NULL, "need data for checkcast");
assert(data->is_BitData(), "need BitData for checkcast");
Register mdo = klass_RInfo;
- __ movoop(mdo, md->encoding());
+ __ movoop(mdo, md->constant_encoding());
Address data_addr(mdo, md->byte_offset_of_slot(data, DataLayout::header_offset()));
int header_bits = DataLayout::flag_mask_to_header_mask(BitData::null_seen_byte_constant());
__ orl(data_addr, header_bits);
@@ -1679,7 +1679,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
#ifdef _LP64
__ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
#else
- __ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->encoding());
+ __ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->constant_encoding());
#endif // _LP64
} else {
__ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
@@ -1696,7 +1696,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
#ifdef _LP64
__ cmpptr(k_RInfo, Address(klass_RInfo, k->super_check_offset()));
#else
- __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->encoding());
+ __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->constant_encoding());
#endif // _LP64
if (sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes() != k->super_check_offset()) {
__ jcc(Assembler::notEqual, *stub->entry());
@@ -1707,7 +1707,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
#ifdef _LP64
__ cmpptr(klass_RInfo, k_RInfo);
#else
- __ cmpoop(klass_RInfo, k->encoding());
+ __ cmpoop(klass_RInfo, k->constant_encoding());
#endif // _LP64
__ jcc(Assembler::equal, done);
@@ -1715,7 +1715,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
#ifdef _LP64
__ push(k_RInfo);
#else
- __ pushoop(k->encoding());
+ __ pushoop(k->constant_encoding());
#endif // _LP64
__ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
__ pop(klass_RInfo);
@@ -1763,7 +1763,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
if (!k->is_loaded()) {
jobject2reg_with_patching(k_RInfo, op->info_for_patch());
} else {
- LP64_ONLY(__ movoop(k_RInfo, k->encoding()));
+ LP64_ONLY(__ movoop(k_RInfo, k->constant_encoding()));
}
assert(obj != k_RInfo, "must be different");
@@ -1774,7 +1774,7 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
// get object class
// not a safepoint as obj null check happens earlier
if (LP64_ONLY(false &&) k->is_loaded()) {
- NOT_LP64(__ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->encoding()));
+ NOT_LP64(__ cmpoop(Address(obj, oopDesc::klass_offset_in_bytes()), k->constant_encoding()));
k_RInfo = noreg;
} else {
__ cmpptr(k_RInfo, Address(obj, oopDesc::klass_offset_in_bytes()));
@@ -1791,14 +1791,14 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
#ifndef _LP64
if (k->is_loaded()) {
// See if we get an immediate positive hit
- __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->encoding());
+ __ cmpoop(Address(klass_RInfo, k->super_check_offset()), k->constant_encoding());
__ jcc(Assembler::equal, one);
if (sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes() == k->super_check_offset()) {
// check for self
- __ cmpoop(klass_RInfo, k->encoding());
+ __ cmpoop(klass_RInfo, k->constant_encoding());
__ jcc(Assembler::equal, one);
__ push(klass_RInfo);
- __ pushoop(k->encoding());
+ __ pushoop(k->constant_encoding());
__ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
__ pop(klass_RInfo);
__ pop(dst);
@@ -3112,7 +3112,7 @@ void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
// subtype which we can't check or src is the same array as dst
// but not necessarily exactly of type default_type.
Label known_ok, halt;
- __ movoop(tmp, default_type->encoding());
+ __ movoop(tmp, default_type->constant_encoding());
if (basic_type != T_OBJECT) {
__ cmpptr(tmp, dst_klass_addr);
__ jcc(Assembler::notEqual, halt);
@@ -3200,7 +3200,7 @@ void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
assert(data->is_CounterData(), "need CounterData for calls");
assert(op->mdo()->is_single_cpu(), "mdo must be allocated");
Register mdo = op->mdo()->as_register();
- __ movoop(mdo, md->encoding());
+ __ movoop(mdo, md->constant_encoding());
Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
__ addl(counter_addr, DataLayout::counter_increment);
Bytecodes::Code bc = method->java_code_at_bci(bci);
@@ -3240,7 +3240,7 @@ void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
ciKlass* receiver = vc_data->receiver(i);
if (receiver == NULL) {
Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)));
- __ movoop(recv_addr, known_klass->encoding());
+ __ movoop(recv_addr, known_klass->constant_encoding());
Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)));
__ addl(data_addr, DataLayout::counter_increment);
return;
diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
index d49793aba56..2e2c1364717 100644
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-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
@@ -994,7 +994,7 @@ void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
LIR_Opr len = length.result();
BasicType elem_type = x->elt_type();
- __ oop2reg(ciTypeArrayKlass::make(elem_type)->encoding(), klass_reg);
+ __ oop2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg);
CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info);
__ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path);
diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad
index 58723cd89d1..71657a809bf 100644
--- a/hotspot/src/cpu/x86/vm/x86_32.ad
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad
@@ -379,7 +379,7 @@ void emit_d32_reloc(CodeBuffer &cbuf, int d32, RelocationHolder const& rspec,
int format) {
#ifdef ASSERT
if (rspec.reloc()->type() == relocInfo::oop_type && d32 != 0 && d32 != (int)Universe::non_oop_word()) {
- assert(oop(d32)->is_oop() && oop(d32)->is_perm(), "cannot embed non-perm oops in code");
+ assert(oop(d32)->is_oop() && (ScavengeRootsInCode || !oop(d32)->is_scavengable()), "cannot embed scavengable oops in code");
}
#endif
cbuf.relocate(cbuf.inst_mark(), rspec, format);
@@ -3701,458 +3701,6 @@ encode %{
}
%}
- enc_class enc_String_Compare(eDIRegP str1, eSIRegP str2, regXD tmp1, regXD tmp2,
- eAXRegI tmp3, eBXRegI tmp4, eCXRegI result) %{
- Label ECX_GOOD_LABEL, LENGTH_DIFF_LABEL,
- POP_LABEL, DONE_LABEL, CONT_LABEL,
- WHILE_HEAD_LABEL;
- MacroAssembler masm(&cbuf);
-
- XMMRegister tmp1Reg = as_XMMRegister($tmp1$$reg);
- XMMRegister tmp2Reg = as_XMMRegister($tmp2$$reg);
-
- // Get the first character position in both strings
- // [8] char array, [12] offset, [16] count
- int value_offset = java_lang_String::value_offset_in_bytes();
- int offset_offset = java_lang_String::offset_offset_in_bytes();
- int count_offset = java_lang_String::count_offset_in_bytes();
- int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
-
- masm.movptr(rax, Address(rsi, value_offset));
- masm.movl(rcx, Address(rsi, offset_offset));
- masm.lea(rax, Address(rax, rcx, Address::times_2, base_offset));
- masm.movptr(rbx, Address(rdi, value_offset));
- masm.movl(rcx, Address(rdi, offset_offset));
- masm.lea(rbx, Address(rbx, rcx, Address::times_2, base_offset));
-
- // Compute the minimum of the string lengths(rsi) and the
- // difference of the string lengths (stack)
-
- if (VM_Version::supports_cmov()) {
- masm.movl(rdi, Address(rdi, count_offset));
- masm.movl(rsi, Address(rsi, count_offset));
- masm.movl(rcx, rdi);
- masm.subl(rdi, rsi);
- masm.push(rdi);
- masm.cmovl(Assembler::lessEqual, rsi, rcx);
- } else {
- masm.movl(rdi, Address(rdi, count_offset));
- masm.movl(rcx, Address(rsi, count_offset));
- masm.movl(rsi, rdi);
- masm.subl(rdi, rcx);
- masm.push(rdi);
- masm.jccb(Assembler::lessEqual, ECX_GOOD_LABEL);
- masm.movl(rsi, rcx);
- // rsi holds min, rcx is unused
- }
-
- // Is the minimum length zero?
- masm.bind(ECX_GOOD_LABEL);
- masm.testl(rsi, rsi);
- masm.jcc(Assembler::zero, LENGTH_DIFF_LABEL);
-
- // Load first characters
- masm.load_unsigned_short(rcx, Address(rbx, 0));
- masm.load_unsigned_short(rdi, Address(rax, 0));
-
- // Compare first characters
- masm.subl(rcx, rdi);
- masm.jcc(Assembler::notZero, POP_LABEL);
- masm.decrementl(rsi);
- masm.jcc(Assembler::zero, LENGTH_DIFF_LABEL);
-
- {
- // Check after comparing first character to see if strings are equivalent
- Label LSkip2;
- // Check if the strings start at same location
- masm.cmpptr(rbx,rax);
- masm.jccb(Assembler::notEqual, LSkip2);
-
- // Check if the length difference is zero (from stack)
- masm.cmpl(Address(rsp, 0), 0x0);
- masm.jcc(Assembler::equal, LENGTH_DIFF_LABEL);
-
- // Strings might not be equivalent
- masm.bind(LSkip2);
- }
-
- // Advance to next character
- masm.addptr(rax, 2);
- masm.addptr(rbx, 2);
-
- if (UseSSE42Intrinsics) {
- // With SSE4.2, use double quad vector compare
- Label COMPARE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_TAIL;
- // Setup to compare 16-byte vectors
- masm.movl(rdi, rsi);
- masm.andl(rsi, 0xfffffff8); // rsi holds the vector count
- masm.andl(rdi, 0x00000007); // rdi holds the tail count
- masm.testl(rsi, rsi);
- masm.jccb(Assembler::zero, COMPARE_TAIL);
-
- masm.lea(rax, Address(rax, rsi, Address::times_2));
- masm.lea(rbx, Address(rbx, rsi, Address::times_2));
- masm.negl(rsi);
-
- masm.bind(COMPARE_VECTORS);
- masm.movdqu(tmp1Reg, Address(rax, rsi, Address::times_2));
- masm.movdqu(tmp2Reg, Address(rbx, rsi, Address::times_2));
- masm.pxor(tmp1Reg, tmp2Reg);
- masm.ptest(tmp1Reg, tmp1Reg);
- masm.jccb(Assembler::notZero, VECTOR_NOT_EQUAL);
- masm.addl(rsi, 8);
- masm.jcc(Assembler::notZero, COMPARE_VECTORS);
- masm.jmpb(COMPARE_TAIL);
-
- // Mismatched characters in the vectors
- masm.bind(VECTOR_NOT_EQUAL);
- masm.lea(rax, Address(rax, rsi, Address::times_2));
- masm.lea(rbx, Address(rbx, rsi, Address::times_2));
- masm.movl(rdi, 8);
-
- // Compare tail (< 8 chars), or rescan last vectors to
- // find 1st mismatched characters
- masm.bind(COMPARE_TAIL);
- masm.testl(rdi, rdi);
- masm.jccb(Assembler::zero, LENGTH_DIFF_LABEL);
- masm.movl(rsi, rdi);
- // Fallthru to tail compare
- }
-
- //Shift rax, and rbx, to the end of the arrays, negate min
- masm.lea(rax, Address(rax, rsi, Address::times_2, 0));
- masm.lea(rbx, Address(rbx, rsi, Address::times_2, 0));
- masm.negl(rsi);
-
- // Compare the rest of the characters
- masm.bind(WHILE_HEAD_LABEL);
- masm.load_unsigned_short(rcx, Address(rbx, rsi, Address::times_2, 0));
- masm.load_unsigned_short(rdi, Address(rax, rsi, Address::times_2, 0));
- masm.subl(rcx, rdi);
- masm.jccb(Assembler::notZero, POP_LABEL);
- masm.incrementl(rsi);
- masm.jcc(Assembler::notZero, WHILE_HEAD_LABEL);
-
- // Strings are equal up to min length. Return the length difference.
- masm.bind(LENGTH_DIFF_LABEL);
- masm.pop(rcx);
- masm.jmpb(DONE_LABEL);
-
- // Discard the stored length difference
- masm.bind(POP_LABEL);
- masm.addptr(rsp, 4);
-
- // That's it
- masm.bind(DONE_LABEL);
- %}
-
- enc_class enc_String_Equals(eDIRegP str1, eSIRegP str2, regXD tmp1, regXD tmp2,
- eBXRegI tmp3, eCXRegI tmp4, eAXRegI result) %{
- Label RET_TRUE, RET_FALSE, DONE, COMPARE_VECTORS, COMPARE_CHAR;
- MacroAssembler masm(&cbuf);
-
- XMMRegister tmp1Reg = as_XMMRegister($tmp1$$reg);
- XMMRegister tmp2Reg = as_XMMRegister($tmp2$$reg);
-
- int value_offset = java_lang_String::value_offset_in_bytes();
- int offset_offset = java_lang_String::offset_offset_in_bytes();
- int count_offset = java_lang_String::count_offset_in_bytes();
- int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
-
- // does source == target string?
- masm.cmpptr(rdi, rsi);
- masm.jcc(Assembler::equal, RET_TRUE);
-
- // get and compare counts
- masm.movl(rcx, Address(rdi, count_offset));
- masm.movl(rax, Address(rsi, count_offset));
- masm.cmpl(rcx, rax);
- masm.jcc(Assembler::notEqual, RET_FALSE);
- masm.testl(rax, rax);
- masm.jcc(Assembler::zero, RET_TRUE);
-
- // get source string offset and value
- masm.movptr(rbx, Address(rsi, value_offset));
- masm.movl(rax, Address(rsi, offset_offset));
- masm.leal(rsi, Address(rbx, rax, Address::times_2, base_offset));
-
- // get compare string offset and value
- masm.movptr(rbx, Address(rdi, value_offset));
- masm.movl(rax, Address(rdi, offset_offset));
- masm.leal(rdi, Address(rbx, rax, Address::times_2, base_offset));
-
- // Set byte count
- masm.shll(rcx, 1);
- masm.movl(rax, rcx);
-
- if (UseSSE42Intrinsics) {
- // With SSE4.2, use double quad vector compare
- Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
- // Compare 16-byte vectors
- masm.andl(rcx, 0xfffffff0); // vector count (in bytes)
- masm.andl(rax, 0x0000000e); // tail count (in bytes)
- masm.testl(rcx, rcx);
- masm.jccb(Assembler::zero, COMPARE_TAIL);
- masm.lea(rdi, Address(rdi, rcx, Address::times_1));
- masm.lea(rsi, Address(rsi, rcx, Address::times_1));
- masm.negl(rcx);
-
- masm.bind(COMPARE_WIDE_VECTORS);
- masm.movdqu(tmp1Reg, Address(rdi, rcx, Address::times_1));
- masm.movdqu(tmp2Reg, Address(rsi, rcx, Address::times_1));
- masm.pxor(tmp1Reg, tmp2Reg);
- masm.ptest(tmp1Reg, tmp1Reg);
- masm.jccb(Assembler::notZero, RET_FALSE);
- masm.addl(rcx, 16);
- masm.jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
- masm.bind(COMPARE_TAIL);
- masm.movl(rcx, rax);
- // Fallthru to tail compare
- }
-
- // Compare 4-byte vectors
- masm.andl(rcx, 0xfffffffc); // vector count (in bytes)
- masm.andl(rax, 0x00000002); // tail char (in bytes)
- masm.testl(rcx, rcx);
- masm.jccb(Assembler::zero, COMPARE_CHAR);
- masm.lea(rdi, Address(rdi, rcx, Address::times_1));
- masm.lea(rsi, Address(rsi, rcx, Address::times_1));
- masm.negl(rcx);
-
- masm.bind(COMPARE_VECTORS);
- masm.movl(rbx, Address(rdi, rcx, Address::times_1));
- masm.cmpl(rbx, Address(rsi, rcx, Address::times_1));
- masm.jccb(Assembler::notEqual, RET_FALSE);
- masm.addl(rcx, 4);
- masm.jcc(Assembler::notZero, COMPARE_VECTORS);
-
- // Compare trailing char (final 2 bytes), if any
- masm.bind(COMPARE_CHAR);
- masm.testl(rax, rax);
- masm.jccb(Assembler::zero, RET_TRUE);
- masm.load_unsigned_short(rbx, Address(rdi, 0));
- masm.load_unsigned_short(rcx, Address(rsi, 0));
- masm.cmpl(rbx, rcx);
- masm.jccb(Assembler::notEqual, RET_FALSE);
-
- masm.bind(RET_TRUE);
- masm.movl(rax, 1); // return true
- masm.jmpb(DONE);
-
- masm.bind(RET_FALSE);
- masm.xorl(rax, rax); // return false
-
- masm.bind(DONE);
- %}
-
- enc_class enc_String_IndexOf(eSIRegP str1, eDIRegP str2, regXD tmp1, eAXRegI tmp2,
- eCXRegI tmp3, eDXRegI tmp4, eBXRegI result) %{
- // SSE4.2 version
- Label LOAD_SUBSTR, PREP_FOR_SCAN, SCAN_TO_SUBSTR,
- SCAN_SUBSTR, RET_NEG_ONE, RET_NOT_FOUND, CLEANUP, DONE;
- MacroAssembler masm(&cbuf);
-
- XMMRegister tmp1Reg = as_XMMRegister($tmp1$$reg);
-
- // Get the first character position in both strings
- // [8] char array, [12] offset, [16] count
- int value_offset = java_lang_String::value_offset_in_bytes();
- int offset_offset = java_lang_String::offset_offset_in_bytes();
- int count_offset = java_lang_String::count_offset_in_bytes();
- int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
-
- // Get counts for string and substr
- masm.movl(rdx, Address(rsi, count_offset));
- masm.movl(rax, Address(rdi, count_offset));
- // Check for substr count > string count
- masm.cmpl(rax, rdx);
- masm.jcc(Assembler::greater, RET_NEG_ONE);
-
- // Start the indexOf operation
- // Get start addr of string
- masm.movptr(rbx, Address(rsi, value_offset));
- masm.movl(rcx, Address(rsi, offset_offset));
- masm.lea(rsi, Address(rbx, rcx, Address::times_2, base_offset));
- masm.push(rsi);
-
- // Get start addr of substr
- masm.movptr(rbx, Address(rdi, value_offset));
- masm.movl(rcx, Address(rdi, offset_offset));
- masm.lea(rdi, Address(rbx, rcx, Address::times_2, base_offset));
- masm.push(rdi);
- masm.push(rax);
- masm.jmpb(PREP_FOR_SCAN);
-
- // Substr count saved at sp
- // Substr saved at sp+4
- // String saved at sp+8
-
- // Prep to load substr for scan
- masm.bind(LOAD_SUBSTR);
- masm.movptr(rdi, Address(rsp, 4));
- masm.movl(rax, Address(rsp, 0));
-
- // Load substr
- masm.bind(PREP_FOR_SCAN);
- masm.movdqu(tmp1Reg, Address(rdi, 0));
- masm.addl(rdx, 8); // prime the loop
- masm.subptr(rsi, 16);
-
- // Scan string for substr in 16-byte vectors
- masm.bind(SCAN_TO_SUBSTR);
- masm.subl(rdx, 8);
- masm.addptr(rsi, 16);
- masm.pcmpestri(tmp1Reg, Address(rsi, 0), 0x0d);
- masm.jcc(Assembler::above, SCAN_TO_SUBSTR); // CF == 0 && ZF == 0
- masm.jccb(Assembler::aboveEqual, RET_NOT_FOUND); // CF == 0
-
- // Fallthru: found a potential substr
-
- // Make sure string is still long enough
- masm.subl(rdx, rcx);
- masm.cmpl(rdx, rax);
- masm.jccb(Assembler::negative, RET_NOT_FOUND);
- // Compute start addr of substr
- masm.lea(rsi, Address(rsi, rcx, Address::times_2));
- masm.movptr(rbx, rsi);
-
- // Compare potential substr
- masm.addl(rdx, 8); // prime the loop
- masm.addl(rax, 8);
- masm.subptr(rsi, 16);
- masm.subptr(rdi, 16);
-
- // Scan 16-byte vectors of string and substr
- masm.bind(SCAN_SUBSTR);
- masm.subl(rax, 8);
- masm.subl(rdx, 8);
- masm.addptr(rsi, 16);
- masm.addptr(rdi, 16);
- masm.movdqu(tmp1Reg, Address(rdi, 0));
- masm.pcmpestri(tmp1Reg, Address(rsi, 0), 0x0d);
- masm.jcc(Assembler::noOverflow, LOAD_SUBSTR); // OF == 0
- masm.jcc(Assembler::positive, SCAN_SUBSTR); // SF == 0
-
- // Compute substr offset
- masm.movptr(rsi, Address(rsp, 8));
- masm.subptr(rbx, rsi);
- masm.shrl(rbx, 1);
- masm.jmpb(CLEANUP);
-
- masm.bind(RET_NEG_ONE);
- masm.movl(rbx, -1);
- masm.jmpb(DONE);
-
- masm.bind(RET_NOT_FOUND);
- masm.movl(rbx, -1);
-
- masm.bind(CLEANUP);
- masm.addptr(rsp, 12);
-
- masm.bind(DONE);
- %}
-
- enc_class enc_Array_Equals(eDIRegP ary1, eSIRegP ary2, regXD tmp1, regXD tmp2,
- eBXRegI tmp3, eDXRegI tmp4, eAXRegI result) %{
- Label TRUE_LABEL, FALSE_LABEL, DONE, COMPARE_VECTORS, COMPARE_CHAR;
- MacroAssembler masm(&cbuf);
-
- XMMRegister tmp1Reg = as_XMMRegister($tmp1$$reg);
- XMMRegister tmp2Reg = as_XMMRegister($tmp2$$reg);
- Register ary1Reg = as_Register($ary1$$reg);
- Register ary2Reg = as_Register($ary2$$reg);
- Register tmp3Reg = as_Register($tmp3$$reg);
- Register tmp4Reg = as_Register($tmp4$$reg);
- Register resultReg = as_Register($result$$reg);
-
- int length_offset = arrayOopDesc::length_offset_in_bytes();
- int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
-
- // Check the input args
- masm.cmpptr(ary1Reg, ary2Reg);
- masm.jcc(Assembler::equal, TRUE_LABEL);
- masm.testptr(ary1Reg, ary1Reg);
- masm.jcc(Assembler::zero, FALSE_LABEL);
- masm.testptr(ary2Reg, ary2Reg);
- masm.jcc(Assembler::zero, FALSE_LABEL);
-
- // Check the lengths
- masm.movl(tmp4Reg, Address(ary1Reg, length_offset));
- masm.movl(resultReg, Address(ary2Reg, length_offset));
- masm.cmpl(tmp4Reg, resultReg);
- masm.jcc(Assembler::notEqual, FALSE_LABEL);
- masm.testl(resultReg, resultReg);
- masm.jcc(Assembler::zero, TRUE_LABEL);
-
- // Load array addrs
- masm.lea(ary1Reg, Address(ary1Reg, base_offset));
- masm.lea(ary2Reg, Address(ary2Reg, base_offset));
-
- // Set byte count
- masm.shll(tmp4Reg, 1);
- masm.movl(resultReg, tmp4Reg);
-
- if (UseSSE42Intrinsics) {
- // With SSE4.2, use double quad vector compare
- Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
- // Compare 16-byte vectors
- masm.andl(tmp4Reg, 0xfffffff0); // vector count (in bytes)
- masm.andl(resultReg, 0x0000000e); // tail count (in bytes)
- masm.testl(tmp4Reg, tmp4Reg);
- masm.jccb(Assembler::zero, COMPARE_TAIL);
- masm.lea(ary1Reg, Address(ary1Reg, tmp4Reg, Address::times_1));
- masm.lea(ary2Reg, Address(ary2Reg, tmp4Reg, Address::times_1));
- masm.negl(tmp4Reg);
-
- masm.bind(COMPARE_WIDE_VECTORS);
- masm.movdqu(tmp1Reg, Address(ary1Reg, tmp4Reg, Address::times_1));
- masm.movdqu(tmp2Reg, Address(ary2Reg, tmp4Reg, Address::times_1));
- masm.pxor(tmp1Reg, tmp2Reg);
- masm.ptest(tmp1Reg, tmp1Reg);
-
- masm.jccb(Assembler::notZero, FALSE_LABEL);
- masm.addl(tmp4Reg, 16);
- masm.jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
- masm.bind(COMPARE_TAIL);
- masm.movl(tmp4Reg, resultReg);
- // Fallthru to tail compare
- }
-
- // Compare 4-byte vectors
- masm.andl(tmp4Reg, 0xfffffffc); // vector count (in bytes)
- masm.andl(resultReg, 0x00000002); // tail char (in bytes)
- masm.testl(tmp4Reg, tmp4Reg);
- masm.jccb(Assembler::zero, COMPARE_CHAR);
- masm.lea(ary1Reg, Address(ary1Reg, tmp4Reg, Address::times_1));
- masm.lea(ary2Reg, Address(ary2Reg, tmp4Reg, Address::times_1));
- masm.negl(tmp4Reg);
-
- masm.bind(COMPARE_VECTORS);
- masm.movl(tmp3Reg, Address(ary1Reg, tmp4Reg, Address::times_1));
- masm.cmpl(tmp3Reg, Address(ary2Reg, tmp4Reg, Address::times_1));
- masm.jccb(Assembler::notEqual, FALSE_LABEL);
- masm.addl(tmp4Reg, 4);
- masm.jcc(Assembler::notZero, COMPARE_VECTORS);
-
- // Compare trailing char (final 2 bytes), if any
- masm.bind(COMPARE_CHAR);
- masm.testl(resultReg, resultReg);
- masm.jccb(Assembler::zero, TRUE_LABEL);
- masm.load_unsigned_short(tmp3Reg, Address(ary1Reg, 0));
- masm.load_unsigned_short(tmp4Reg, Address(ary2Reg, 0));
- masm.cmpl(tmp3Reg, tmp4Reg);
- masm.jccb(Assembler::notEqual, FALSE_LABEL);
-
- masm.bind(TRUE_LABEL);
- masm.movl(resultReg, 1); // return true
- masm.jmpb(DONE);
-
- masm.bind(FALSE_LABEL);
- masm.xorl(resultReg, resultReg); // return false
-
- // That's it
- masm.bind(DONE);
- %}
enc_class enc_pop_rdx() %{
emit_opcode(cbuf,0x5A);
@@ -12718,48 +12266,64 @@ instruct rep_stos(eCXRegI cnt, eDIRegP base, eAXRegI zero, Universe dummy, eFlag
ins_pipe( pipe_slow );
%}
-instruct string_compare(eDIRegP str1, eSIRegP str2, regXD tmp1, regXD tmp2,
- eAXRegI tmp3, eBXRegI tmp4, eCXRegI result, eFlagsReg cr) %{
- match(Set result (StrComp str1 str2));
- effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, KILL tmp3, KILL tmp4, KILL cr);
- //ins_cost(300);
+instruct string_compare(eDIRegP str1, eCXRegI cnt1, eSIRegP str2, eBXRegI cnt2,
+ eAXRegI result, regXD tmp1, regXD tmp2, eFlagsReg cr) %{
+ match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
+ effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr);
- format %{ "String Compare $str1,$str2 -> $result // KILL EAX, EBX" %}
- ins_encode( enc_String_Compare(str1, str2, tmp1, tmp2, tmp3, tmp4, result) );
+ format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp1, $tmp2" %}
+ ins_encode %{
+ __ string_compare($str1$$Register, $str2$$Register,
+ $cnt1$$Register, $cnt2$$Register, $result$$Register,
+ $tmp1$$XMMRegister, $tmp2$$XMMRegister);
+ %}
ins_pipe( pipe_slow );
%}
// fast string equals
-instruct string_equals(eDIRegP str1, eSIRegP str2, regXD tmp1, regXD tmp2,
- eBXRegI tmp3, eCXRegI tmp4, eAXRegI result, eFlagsReg cr) %{
- match(Set result (StrEquals str1 str2));
- effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, KILL tmp3, KILL tmp4, KILL cr);
+instruct string_equals(eDIRegP str1, eSIRegP str2, eCXRegI cnt, eAXRegI result,
+ regXD tmp1, regXD tmp2, eBXRegI tmp3, eFlagsReg cr) %{
+ match(Set result (StrEquals (Binary str1 str2) cnt));
+ effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, USE_KILL cnt, KILL tmp3, KILL cr);
- format %{ "String Equals $str1,$str2 -> $result // KILL EBX, ECX" %}
- ins_encode( enc_String_Equals(tmp1, tmp2, str1, str2, tmp3, tmp4, result) );
+ format %{ "String Equals $str1,$str2,$cnt -> $result // KILL $tmp1, $tmp2, $tmp3" %}
+ ins_encode %{
+ __ char_arrays_equals(false, $str1$$Register, $str2$$Register,
+ $cnt$$Register, $result$$Register, $tmp3$$Register,
+ $tmp1$$XMMRegister, $tmp2$$XMMRegister);
+ %}
ins_pipe( pipe_slow );
%}
-instruct string_indexof(eSIRegP str1, eDIRegP str2, regXD tmp1, eAXRegI tmp2,
- eCXRegI tmp3, eDXRegI tmp4, eBXRegI result, eFlagsReg cr) %{
+instruct string_indexof(eDIRegP str1, eDXRegI cnt1, eSIRegP str2, eAXRegI cnt2,
+ eBXRegI result, regXD tmp1, eCXRegI tmp2, eFlagsReg cr) %{
predicate(UseSSE42Intrinsics);
- match(Set result (StrIndexOf str1 str2));
- effect(TEMP tmp1, USE_KILL str1, USE_KILL str2, KILL tmp2, KILL tmp3, KILL tmp4, KILL cr);
+ match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 cnt2)));
+ effect(TEMP tmp1, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL tmp2, KILL cr);
- format %{ "String IndexOf $str1,$str2 -> $result // KILL EAX, ECX, EDX" %}
- ins_encode( enc_String_IndexOf(str1, str2, tmp1, tmp2, tmp3, tmp4, result) );
+ format %{ "String IndexOf $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp2, $tmp1" %}
+ ins_encode %{
+ __ string_indexof($str1$$Register, $str2$$Register,
+ $cnt1$$Register, $cnt2$$Register, $result$$Register,
+ $tmp1$$XMMRegister, $tmp2$$Register);
+ %}
ins_pipe( pipe_slow );
%}
// fast array equals
-instruct array_equals(eDIRegP ary1, eSIRegP ary2, regXD tmp1, regXD tmp2, eBXRegI tmp3,
- eDXRegI tmp4, eAXRegI result, eFlagsReg cr) %{
+instruct array_equals(eDIRegP ary1, eSIRegP ary2, eAXRegI result,
+ regXD tmp1, regXD tmp2, eCXRegI tmp3, eBXRegI tmp4, eFlagsReg cr)
+%{
match(Set result (AryEq ary1 ary2));
effect(TEMP tmp1, TEMP tmp2, USE_KILL ary1, USE_KILL ary2, KILL tmp3, KILL tmp4, KILL cr);
//ins_cost(300);
- format %{ "Array Equals $ary1,$ary2 -> $result // KILL EBX, EDX" %}
- ins_encode( enc_Array_Equals(ary1, ary2, tmp1, tmp2, tmp3, tmp4, result) );
+ format %{ "Array Equals $ary1,$ary2 -> $result // KILL $tmp1, $tmp2, $tmp3, $tmp4" %}
+ ins_encode %{
+ __ char_arrays_equals(true, $ary1$$Register, $ary2$$Register,
+ $tmp3$$Register, $result$$Register, $tmp4$$Register,
+ $tmp1$$XMMRegister, $tmp2$$XMMRegister);
+ %}
ins_pipe( pipe_slow );
%}
diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad
index 52afa81f659..5927b5081a7 100644
--- a/hotspot/src/cpu/x86/vm/x86_64.ad
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad
@@ -683,7 +683,7 @@ void emit_d32_reloc(CodeBuffer& cbuf,
#ifdef ASSERT
if (rspec.reloc()->type() == relocInfo::oop_type &&
d32 != 0 && d32 != (intptr_t) Universe::non_oop_word()) {
- assert(oop((intptr_t)d32)->is_oop() && oop((intptr_t)d32)->is_perm(), "cannot embed non-perm oops in code");
+ assert(oop((intptr_t)d32)->is_oop() && (ScavengeRootsInCode || !oop((intptr_t)d32)->is_scavengable()), "cannot embed scavengable oops in code");
}
#endif
cbuf.relocate(cbuf.inst_mark(), rspec, format);
@@ -721,8 +721,8 @@ void emit_d64_reloc(CodeBuffer& cbuf,
#ifdef ASSERT
if (rspec.reloc()->type() == relocInfo::oop_type &&
d64 != 0 && d64 != (int64_t) Universe::non_oop_word()) {
- assert(oop(d64)->is_oop() && oop(d64)->is_perm(),
- "cannot embed non-perm oops in code");
+ assert(oop(d64)->is_oop() && (ScavengeRootsInCode || !oop(d64)->is_scavengable()),
+ "cannot embed scavengable oops in code");
}
#endif
cbuf.relocate(cbuf.inst_mark(), rspec, format);
@@ -3701,448 +3701,6 @@ encode %{
}
%}
- enc_class enc_String_Compare(rdi_RegP str1, rsi_RegP str2, regD tmp1, regD tmp2,
- rax_RegI tmp3, rbx_RegI tmp4, rcx_RegI result) %{
- Label RCX_GOOD_LABEL, LENGTH_DIFF_LABEL,
- POP_LABEL, DONE_LABEL, CONT_LABEL,
- WHILE_HEAD_LABEL;
- MacroAssembler masm(&cbuf);
-
- XMMRegister tmp1Reg = as_XMMRegister($tmp1$$reg);
- XMMRegister tmp2Reg = as_XMMRegister($tmp2$$reg);
-
- // Get the first character position in both strings
- // [8] char array, [12] offset, [16] count
- int value_offset = java_lang_String::value_offset_in_bytes();
- int offset_offset = java_lang_String::offset_offset_in_bytes();
- int count_offset = java_lang_String::count_offset_in_bytes();
- int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
-
- masm.load_heap_oop(rax, Address(rsi, value_offset));
- masm.movl(rcx, Address(rsi, offset_offset));
- masm.lea(rax, Address(rax, rcx, Address::times_2, base_offset));
- masm.load_heap_oop(rbx, Address(rdi, value_offset));
- masm.movl(rcx, Address(rdi, offset_offset));
- masm.lea(rbx, Address(rbx, rcx, Address::times_2, base_offset));
-
- // Compute the minimum of the string lengths(rsi) and the
- // difference of the string lengths (stack)
-
- // do the conditional move stuff
- masm.movl(rdi, Address(rdi, count_offset));
- masm.movl(rsi, Address(rsi, count_offset));
- masm.movl(rcx, rdi);
- masm.subl(rdi, rsi);
- masm.push(rdi);
- masm.cmov(Assembler::lessEqual, rsi, rcx);
-
- // Is the minimum length zero?
- masm.bind(RCX_GOOD_LABEL);
- masm.testl(rsi, rsi);
- masm.jcc(Assembler::zero, LENGTH_DIFF_LABEL);
-
- // Load first characters
- masm.load_unsigned_short(rcx, Address(rbx, 0));
- masm.load_unsigned_short(rdi, Address(rax, 0));
-
- // Compare first characters
- masm.subl(rcx, rdi);
- masm.jcc(Assembler::notZero, POP_LABEL);
- masm.decrementl(rsi);
- masm.jcc(Assembler::zero, LENGTH_DIFF_LABEL);
-
- {
- // Check after comparing first character to see if strings are equivalent
- Label LSkip2;
- // Check if the strings start at same location
- masm.cmpptr(rbx, rax);
- masm.jccb(Assembler::notEqual, LSkip2);
-
- // Check if the length difference is zero (from stack)
- masm.cmpl(Address(rsp, 0), 0x0);
- masm.jcc(Assembler::equal, LENGTH_DIFF_LABEL);
-
- // Strings might not be equivalent
- masm.bind(LSkip2);
- }
-
- // Advance to next character
- masm.addptr(rax, 2);
- masm.addptr(rbx, 2);
-
- if (UseSSE42Intrinsics) {
- // With SSE4.2, use double quad vector compare
- Label COMPARE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_TAIL;
- // Setup to compare 16-byte vectors
- masm.movl(rdi, rsi);
- masm.andl(rsi, 0xfffffff8); // rsi holds the vector count
- masm.andl(rdi, 0x00000007); // rdi holds the tail count
- masm.testl(rsi, rsi);
- masm.jccb(Assembler::zero, COMPARE_TAIL);
-
- masm.lea(rax, Address(rax, rsi, Address::times_2));
- masm.lea(rbx, Address(rbx, rsi, Address::times_2));
- masm.negptr(rsi);
-
- masm.bind(COMPARE_VECTORS);
- masm.movdqu(tmp1Reg, Address(rax, rsi, Address::times_2));
- masm.movdqu(tmp2Reg, Address(rbx, rsi, Address::times_2));
- masm.pxor(tmp1Reg, tmp2Reg);
- masm.ptest(tmp1Reg, tmp1Reg);
- masm.jccb(Assembler::notZero, VECTOR_NOT_EQUAL);
- masm.addptr(rsi, 8);
- masm.jcc(Assembler::notZero, COMPARE_VECTORS);
- masm.jmpb(COMPARE_TAIL);
-
- // Mismatched characters in the vectors
- masm.bind(VECTOR_NOT_EQUAL);
- masm.lea(rax, Address(rax, rsi, Address::times_2));
- masm.lea(rbx, Address(rbx, rsi, Address::times_2));
- masm.movl(rdi, 8);
-
- // Compare tail (< 8 chars), or rescan last vectors to
- // find 1st mismatched characters
- masm.bind(COMPARE_TAIL);
- masm.testl(rdi, rdi);
- masm.jccb(Assembler::zero, LENGTH_DIFF_LABEL);
- masm.movl(rsi, rdi);
- // Fallthru to tail compare
- }
-
- // Shift RAX and RBX to the end of the arrays, negate min
- masm.lea(rax, Address(rax, rsi, Address::times_2, 0));
- masm.lea(rbx, Address(rbx, rsi, Address::times_2, 0));
- masm.negptr(rsi);
-
- // Compare the rest of the characters
- masm.bind(WHILE_HEAD_LABEL);
- masm.load_unsigned_short(rcx, Address(rbx, rsi, Address::times_2, 0));
- masm.load_unsigned_short(rdi, Address(rax, rsi, Address::times_2, 0));
- masm.subl(rcx, rdi);
- masm.jccb(Assembler::notZero, POP_LABEL);
- masm.increment(rsi);
- masm.jcc(Assembler::notZero, WHILE_HEAD_LABEL);
-
- // Strings are equal up to min length. Return the length difference.
- masm.bind(LENGTH_DIFF_LABEL);
- masm.pop(rcx);
- masm.jmpb(DONE_LABEL);
-
- // Discard the stored length difference
- masm.bind(POP_LABEL);
- masm.addptr(rsp, 8);
-
- // That's it
- masm.bind(DONE_LABEL);
- %}
-
- enc_class enc_String_IndexOf(rsi_RegP str1, rdi_RegP str2, regD tmp1, rax_RegI tmp2,
- rcx_RegI tmp3, rdx_RegI tmp4, rbx_RegI result) %{
- // SSE4.2 version
- Label LOAD_SUBSTR, PREP_FOR_SCAN, SCAN_TO_SUBSTR,
- SCAN_SUBSTR, RET_NEG_ONE, RET_NOT_FOUND, CLEANUP, DONE;
- MacroAssembler masm(&cbuf);
-
- XMMRegister tmp1Reg = as_XMMRegister($tmp1$$reg);
-
- // Get the first character position in both strings
- // [8] char array, [12] offset, [16] count
- int value_offset = java_lang_String::value_offset_in_bytes();
- int offset_offset = java_lang_String::offset_offset_in_bytes();
- int count_offset = java_lang_String::count_offset_in_bytes();
- int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
-
- // Get counts for string and substr
- masm.movl(rdx, Address(rsi, count_offset));
- masm.movl(rax, Address(rdi, count_offset));
- // Check for substr count > string count
- masm.cmpl(rax, rdx);
- masm.jcc(Assembler::greater, RET_NEG_ONE);
-
- // Start the indexOf operation
- // Get start addr of string
- masm.load_heap_oop(rbx, Address(rsi, value_offset));
- masm.movl(rcx, Address(rsi, offset_offset));
- masm.lea(rsi, Address(rbx, rcx, Address::times_2, base_offset));
- masm.push(rsi);
-
- // Get start addr of substr
- masm.load_heap_oop(rbx, Address(rdi, value_offset));
- masm.movl(rcx, Address(rdi, offset_offset));
- masm.lea(rdi, Address(rbx, rcx, Address::times_2, base_offset));
- masm.push(rdi);
- masm.push(rax);
- masm.jmpb(PREP_FOR_SCAN);
-
- // Substr count saved at sp
- // Substr saved at sp+8
- // String saved at sp+16
-
- // Prep to load substr for scan
- masm.bind(LOAD_SUBSTR);
- masm.movptr(rdi, Address(rsp, 8));
- masm.movl(rax, Address(rsp, 0));
-
- // Load substr
- masm.bind(PREP_FOR_SCAN);
- masm.movdqu(tmp1Reg, Address(rdi, 0));
- masm.addq(rdx, 8); // prime the loop
- masm.subptr(rsi, 16);
-
- // Scan string for substr in 16-byte vectors
- masm.bind(SCAN_TO_SUBSTR);
- masm.subq(rdx, 8);
- masm.addptr(rsi, 16);
- masm.pcmpestri(tmp1Reg, Address(rsi, 0), 0x0d);
- masm.jcc(Assembler::above, SCAN_TO_SUBSTR);
- masm.jccb(Assembler::aboveEqual, RET_NOT_FOUND);
-
- // Fallthru: found a potential substr
-
- //Make sure string is still long enough
- masm.subl(rdx, rcx);
- masm.cmpl(rdx, rax);
- masm.jccb(Assembler::negative, RET_NOT_FOUND);
- // Compute start addr of substr
- masm.lea(rsi, Address(rsi, rcx, Address::times_2));
- masm.movptr(rbx, rsi);
-
- // Compare potential substr
- masm.addq(rdx, 8); // prime the loop
- masm.addq(rax, 8);
- masm.subptr(rsi, 16);
- masm.subptr(rdi, 16);
-
- // Scan 16-byte vectors of string and substr
- masm.bind(SCAN_SUBSTR);
- masm.subq(rax, 8);
- masm.subq(rdx, 8);
- masm.addptr(rsi, 16);
- masm.addptr(rdi, 16);
- masm.movdqu(tmp1Reg, Address(rdi, 0));
- masm.pcmpestri(tmp1Reg, Address(rsi, 0), 0x0d);
- masm.jcc(Assembler::noOverflow, LOAD_SUBSTR); // OF == 0
- masm.jcc(Assembler::positive, SCAN_SUBSTR); // SF == 0
-
- // Compute substr offset
- masm.movptr(rsi, Address(rsp, 16));
- masm.subptr(rbx, rsi);
- masm.shrl(rbx, 1);
- masm.jmpb(CLEANUP);
-
- masm.bind(RET_NEG_ONE);
- masm.movl(rbx, -1);
- masm.jmpb(DONE);
-
- masm.bind(RET_NOT_FOUND);
- masm.movl(rbx, -1);
-
- masm.bind(CLEANUP);
- masm.addptr(rsp, 24);
-
- masm.bind(DONE);
- %}
-
- enc_class enc_String_Equals(rdi_RegP str1, rsi_RegP str2, regD tmp1, regD tmp2,
- rbx_RegI tmp3, rcx_RegI tmp2, rax_RegI result) %{
- Label RET_TRUE, RET_FALSE, DONE, COMPARE_VECTORS, COMPARE_CHAR;
- MacroAssembler masm(&cbuf);
-
- XMMRegister tmp1Reg = as_XMMRegister($tmp1$$reg);
- XMMRegister tmp2Reg = as_XMMRegister($tmp2$$reg);
-
- int value_offset = java_lang_String::value_offset_in_bytes();
- int offset_offset = java_lang_String::offset_offset_in_bytes();
- int count_offset = java_lang_String::count_offset_in_bytes();
- int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
-
- // does source == target string?
- masm.cmpptr(rdi, rsi);
- masm.jcc(Assembler::equal, RET_TRUE);
-
- // get and compare counts
- masm.movl(rcx, Address(rdi, count_offset));
- masm.movl(rax, Address(rsi, count_offset));
- masm.cmpl(rcx, rax);
- masm.jcc(Assembler::notEqual, RET_FALSE);
- masm.testl(rax, rax);
- masm.jcc(Assembler::zero, RET_TRUE);
-
- // get source string offset and value
- masm.load_heap_oop(rbx, Address(rsi, value_offset));
- masm.movl(rax, Address(rsi, offset_offset));
- masm.lea(rsi, Address(rbx, rax, Address::times_2, base_offset));
-
- // get compare string offset and value
- masm.load_heap_oop(rbx, Address(rdi, value_offset));
- masm.movl(rax, Address(rdi, offset_offset));
- masm.lea(rdi, Address(rbx, rax, Address::times_2, base_offset));
-
- // Set byte count
- masm.shll(rcx, 1);
- masm.movl(rax, rcx);
-
- if (UseSSE42Intrinsics) {
- // With SSE4.2, use double quad vector compare
- Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
- // Compare 16-byte vectors
- masm.andl(rcx, 0xfffffff0); // vector count (in bytes)
- masm.andl(rax, 0x0000000e); // tail count (in bytes)
- masm.testl(rcx, rcx);
- masm.jccb(Assembler::zero, COMPARE_TAIL);
- masm.lea(rdi, Address(rdi, rcx, Address::times_1));
- masm.lea(rsi, Address(rsi, rcx, Address::times_1));
- masm.negptr(rcx);
-
- masm.bind(COMPARE_WIDE_VECTORS);
- masm.movdqu(tmp1Reg, Address(rdi, rcx, Address::times_1));
- masm.movdqu(tmp2Reg, Address(rsi, rcx, Address::times_1));
- masm.pxor(tmp1Reg, tmp2Reg);
- masm.ptest(tmp1Reg, tmp1Reg);
- masm.jccb(Assembler::notZero, RET_FALSE);
- masm.addptr(rcx, 16);
- masm.jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
- masm.bind(COMPARE_TAIL);
- masm.movl(rcx, rax);
- // Fallthru to tail compare
- }
-
- // Compare 4-byte vectors
- masm.andl(rcx, 0xfffffffc); // vector count (in bytes)
- masm.andl(rax, 0x00000002); // tail char (in bytes)
- masm.testl(rcx, rcx);
- masm.jccb(Assembler::zero, COMPARE_CHAR);
- masm.lea(rdi, Address(rdi, rcx, Address::times_1));
- masm.lea(rsi, Address(rsi, rcx, Address::times_1));
- masm.negptr(rcx);
-
- masm.bind(COMPARE_VECTORS);
- masm.movl(rbx, Address(rdi, rcx, Address::times_1));
- masm.cmpl(rbx, Address(rsi, rcx, Address::times_1));
- masm.jccb(Assembler::notEqual, RET_FALSE);
- masm.addptr(rcx, 4);
- masm.jcc(Assembler::notZero, COMPARE_VECTORS);
-
- // Compare trailing char (final 2 bytes), if any
- masm.bind(COMPARE_CHAR);
- masm.testl(rax, rax);
- masm.jccb(Assembler::zero, RET_TRUE);
- masm.load_unsigned_short(rbx, Address(rdi, 0));
- masm.load_unsigned_short(rcx, Address(rsi, 0));
- masm.cmpl(rbx, rcx);
- masm.jccb(Assembler::notEqual, RET_FALSE);
-
- masm.bind(RET_TRUE);
- masm.movl(rax, 1); // return true
- masm.jmpb(DONE);
-
- masm.bind(RET_FALSE);
- masm.xorl(rax, rax); // return false
-
- masm.bind(DONE);
- %}
-
- enc_class enc_Array_Equals(rdi_RegP ary1, rsi_RegP ary2, regD tmp1, regD tmp2,
- rax_RegI tmp3, rbx_RegI tmp4, rcx_RegI result) %{
- Label TRUE_LABEL, FALSE_LABEL, DONE, COMPARE_VECTORS, COMPARE_CHAR;
- MacroAssembler masm(&cbuf);
-
- XMMRegister tmp1Reg = as_XMMRegister($tmp1$$reg);
- XMMRegister tmp2Reg = as_XMMRegister($tmp2$$reg);
- Register ary1Reg = as_Register($ary1$$reg);
- Register ary2Reg = as_Register($ary2$$reg);
- Register tmp3Reg = as_Register($tmp3$$reg);
- Register tmp4Reg = as_Register($tmp4$$reg);
- Register resultReg = as_Register($result$$reg);
-
- int length_offset = arrayOopDesc::length_offset_in_bytes();
- int base_offset = arrayOopDesc::base_offset_in_bytes(T_CHAR);
-
- // Check the input args
- masm.cmpq(ary1Reg, ary2Reg);
- masm.jcc(Assembler::equal, TRUE_LABEL);
- masm.testq(ary1Reg, ary1Reg);
- masm.jcc(Assembler::zero, FALSE_LABEL);
- masm.testq(ary2Reg, ary2Reg);
- masm.jcc(Assembler::zero, FALSE_LABEL);
-
- // Check the lengths
- masm.movl(tmp4Reg, Address(ary1Reg, length_offset));
- masm.movl(resultReg, Address(ary2Reg, length_offset));
- masm.cmpl(tmp4Reg, resultReg);
- masm.jcc(Assembler::notEqual, FALSE_LABEL);
- masm.testl(resultReg, resultReg);
- masm.jcc(Assembler::zero, TRUE_LABEL);
-
- //load array address
- masm.lea(ary1Reg, Address(ary1Reg, base_offset));
- masm.lea(ary2Reg, Address(ary2Reg, base_offset));
-
- //set byte count
- masm.shll(tmp4Reg, 1);
- masm.movl(resultReg,tmp4Reg);
-
- if (UseSSE42Intrinsics){
- // With SSE4.2, use double quad vector compare
- Label COMPARE_WIDE_VECTORS, COMPARE_TAIL;
- // Compare 16-byte vectors
- masm.andl(tmp4Reg, 0xfffffff0); // vector count (in bytes)
- masm.andl(resultReg, 0x0000000e); // tail count (in bytes)
- masm.testl(tmp4Reg, tmp4Reg);
- masm.jccb(Assembler::zero, COMPARE_TAIL);
- masm.lea(ary1Reg, Address(ary1Reg, tmp4Reg, Address::times_1));
- masm.lea(ary2Reg, Address(ary2Reg, tmp4Reg, Address::times_1));
- masm.negptr(tmp4Reg);
-
- masm.bind(COMPARE_WIDE_VECTORS);
- masm.movdqu(tmp1Reg, Address(ary1Reg, tmp4Reg, Address::times_1));
- masm.movdqu(tmp2Reg, Address(ary2Reg, tmp4Reg, Address::times_1));
- masm.pxor(tmp1Reg, tmp2Reg);
- masm.ptest(tmp1Reg, tmp1Reg);
-
- masm.jccb(Assembler::notZero, FALSE_LABEL);
- masm.addptr(tmp4Reg, 16);
- masm.jcc(Assembler::notZero, COMPARE_WIDE_VECTORS);
- masm.bind(COMPARE_TAIL);
- masm.movl(tmp4Reg, resultReg);
- // Fallthru to tail compare
- }
-
- // Compare 4-byte vectors
- masm.andl(tmp4Reg, 0xfffffffc); // vector count (in bytes)
- masm.andl(resultReg, 0x00000002); // tail char (in bytes)
- masm.testl(tmp4Reg, tmp4Reg); //if tmp2 == 0, only compare char
- masm.jccb(Assembler::zero, COMPARE_CHAR);
- masm.lea(ary1Reg, Address(ary1Reg, tmp4Reg, Address::times_1));
- masm.lea(ary2Reg, Address(ary2Reg, tmp4Reg, Address::times_1));
- masm.negptr(tmp4Reg);
-
- masm.bind(COMPARE_VECTORS);
- masm.movl(tmp3Reg, Address(ary1Reg, tmp4Reg, Address::times_1));
- masm.cmpl(tmp3Reg, Address(ary2Reg, tmp4Reg, Address::times_1));
- masm.jccb(Assembler::notEqual, FALSE_LABEL);
- masm.addptr(tmp4Reg, 4);
- masm.jcc(Assembler::notZero, COMPARE_VECTORS);
-
- // Compare trailing char (final 2 bytes), if any
- masm.bind(COMPARE_CHAR);
- masm.testl(resultReg, resultReg);
- masm.jccb(Assembler::zero, TRUE_LABEL);
- masm.load_unsigned_short(tmp3Reg, Address(ary1Reg, 0));
- masm.load_unsigned_short(tmp4Reg, Address(ary2Reg, 0));
- masm.cmpl(tmp3Reg, tmp4Reg);
- masm.jccb(Assembler::notEqual, FALSE_LABEL);
-
- masm.bind(TRUE_LABEL);
- masm.movl(resultReg, 1); // return true
- masm.jmpb(DONE);
-
- masm.bind(FALSE_LABEL);
- masm.xorl(resultReg, resultReg); // return false
-
- // That's it
- masm.bind(DONE);
- %}
enc_class enc_rethrow()
%{
@@ -12096,52 +11654,67 @@ instruct rep_stos(rcx_RegL cnt, rdi_RegP base, rax_RegI zero, Universe dummy,
ins_pipe(pipe_slow);
%}
-instruct string_compare(rdi_RegP str1, rsi_RegP str2, regD tmp1, regD tmp2,
- rax_RegI tmp3, rbx_RegI tmp4, rcx_RegI result, rFlagsReg cr)
+instruct string_compare(rdi_RegP str1, rcx_RegI cnt1, rsi_RegP str2, rbx_RegI cnt2,
+ rax_RegI result, regD tmp1, regD tmp2, rFlagsReg cr)
%{
- match(Set result (StrComp str1 str2));
- effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, KILL tmp3, KILL tmp4, KILL cr);
- //ins_cost(300);
+ match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
+ effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr);
- format %{ "String Compare $str1, $str2 -> $result // XXX KILL RAX, RBX" %}
- ins_encode( enc_String_Compare(str1, str2, tmp1, tmp2, tmp3, tmp4, result) );
+ format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp1, $tmp2" %}
+ ins_encode %{
+ __ string_compare($str1$$Register, $str2$$Register,
+ $cnt1$$Register, $cnt2$$Register, $result$$Register,
+ $tmp1$$XMMRegister, $tmp2$$XMMRegister);
+ %}
ins_pipe( pipe_slow );
%}
-instruct string_indexof(rsi_RegP str1, rdi_RegP str2, regD tmp1, rax_RegI tmp2,
- rcx_RegI tmp3, rdx_RegI tmp4, rbx_RegI result, rFlagsReg cr)
+instruct string_indexof(rdi_RegP str1, rdx_RegI cnt1, rsi_RegP str2, rax_RegI cnt2,
+ rbx_RegI result, regD tmp1, rcx_RegI tmp2, rFlagsReg cr)
%{
predicate(UseSSE42Intrinsics);
- match(Set result (StrIndexOf str1 str2));
- effect(TEMP tmp1, USE_KILL str1, USE_KILL str2, KILL tmp2, KILL tmp3, KILL tmp4, KILL cr);
+ match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 cnt2)));
+ effect(TEMP tmp1, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL tmp2, KILL cr);
- format %{ "String IndexOf $str1,$str2 -> $result // KILL RAX, RCX, RDX" %}
- ins_encode( enc_String_IndexOf(str1, str2, tmp1, tmp2, tmp3, tmp4, result) );
+ format %{ "String IndexOf $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp1, $tmp2" %}
+ ins_encode %{
+ __ string_indexof($str1$$Register, $str2$$Register,
+ $cnt1$$Register, $cnt2$$Register, $result$$Register,
+ $tmp1$$XMMRegister, $tmp2$$Register);
+ %}
ins_pipe( pipe_slow );
%}
// fast string equals
-instruct string_equals(rdi_RegP str1, rsi_RegP str2, regD tmp1, regD tmp2, rbx_RegI tmp3,
- rcx_RegI tmp4, rax_RegI result, rFlagsReg cr)
+instruct string_equals(rdi_RegP str1, rsi_RegP str2, rcx_RegI cnt, rax_RegI result,
+ regD tmp1, regD tmp2, rbx_RegI tmp3, rFlagsReg cr)
%{
- match(Set result (StrEquals str1 str2));
- effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, KILL tmp3, KILL tmp4, KILL cr);
+ match(Set result (StrEquals (Binary str1 str2) cnt));
+ effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, USE_KILL cnt, KILL tmp3, KILL cr);
- format %{ "String Equals $str1,$str2 -> $result // KILL RBX, RCX" %}
- ins_encode( enc_String_Equals(str1, str2, tmp1, tmp2, tmp3, tmp4, result) );
+ format %{ "String Equals $str1,$str2,$cnt -> $result // KILL $tmp1, $tmp2, $tmp3" %}
+ ins_encode %{
+ __ char_arrays_equals(false, $str1$$Register, $str2$$Register,
+ $cnt$$Register, $result$$Register, $tmp3$$Register,
+ $tmp1$$XMMRegister, $tmp2$$XMMRegister);
+ %}
ins_pipe( pipe_slow );
%}
// fast array equals
-instruct array_equals(rdi_RegP ary1, rsi_RegP ary2, regD tmp1, regD tmp2, rax_RegI tmp3,
- rbx_RegI tmp4, rcx_RegI result, rFlagsReg cr)
+instruct array_equals(rdi_RegP ary1, rsi_RegP ary2, rax_RegI result,
+ regD tmp1, regD tmp2, rcx_RegI tmp3, rbx_RegI tmp4, rFlagsReg cr)
%{
match(Set result (AryEq ary1 ary2));
effect(TEMP tmp1, TEMP tmp2, USE_KILL ary1, USE_KILL ary2, KILL tmp3, KILL tmp4, KILL cr);
//ins_cost(300);
- format %{ "Array Equals $ary1,$ary2 -> $result // KILL RAX, RBX" %}
- ins_encode( enc_Array_Equals(ary1, ary2, tmp1, tmp2, tmp3, tmp4, result) );
+ format %{ "Array Equals $ary1,$ary2 -> $result // KILL $tmp1, $tmp2, $tmp3, $tmp4" %}
+ ins_encode %{
+ __ char_arrays_equals(true, $ary1$$Register, $ary2$$Register,
+ $tmp3$$Register, $result$$Register, $tmp4$$Register,
+ $tmp1$$XMMRegister, $tmp2$$XMMRegister);
+ %}
ins_pipe( pipe_slow );
%}
diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp b/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp
index d4ff200619f..5d86fe459cd 100644
--- a/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2007 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
diff --git a/hotspot/src/os_cpu/solaris_x86/vm/atomic_solaris_x86.inline.hpp b/hotspot/src/os_cpu/solaris_x86/vm/atomic_solaris_x86.inline.hpp
index d127d6ea902..f270c3d1da7 100644
--- a/hotspot/src/os_cpu/solaris_x86/vm/atomic_solaris_x86.inline.hpp
+++ b/hotspot/src/os_cpu/solaris_x86/vm/atomic_solaris_x86.inline.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2007 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
diff --git a/hotspot/src/share/vm/adlc/formssel.cpp b/hotspot/src/share/vm/adlc/formssel.cpp
index 11bfa14f7e8..2ec20c66109 100644
--- a/hotspot/src/share/vm/adlc/formssel.cpp
+++ b/hotspot/src/share/vm/adlc/formssel.cpp
@@ -828,11 +828,13 @@ uint InstructForm::oper_input_base(FormDict &globals) {
return AdlcVMDeps::Parms; // Skip the machine-state edges
if( _matrule->_rChild &&
- ( strcmp(_matrule->_rChild->_opType,"StrComp" )==0 ||
+ ( strcmp(_matrule->_rChild->_opType,"AryEq" )==0 ||
+ strcmp(_matrule->_rChild->_opType,"StrComp" )==0 ||
strcmp(_matrule->_rChild->_opType,"StrEquals" )==0 ||
strcmp(_matrule->_rChild->_opType,"StrIndexOf")==0 )) {
- // String.(compareTo/equals/indexOf) take 1 control and 4 memory edges.
- return 5;
+ // String.(compareTo/equals/indexOf) and Arrays.equals
+ // take 1 control and 1 memory edges.
+ return 2;
}
// Check for handling of 'Memory' input/edge in the ideal world.
diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
index 30a1ada8231..caa99ded618 100644
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
@@ -1442,7 +1442,7 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
switch (field_type) {
case T_ARRAY:
case T_OBJECT:
- if (field_val.as_object()->has_encoding()) {
+ if (field_val.as_object()->should_be_constant()) {
constant = new Constant(as_ValueType(field_val));
}
break;
diff --git a/hotspot/src/share/vm/c1/c1_IR.cpp b/hotspot/src/share/vm/c1/c1_IR.cpp
index 47e1c0d4151..7ecf4812b08 100644
--- a/hotspot/src/share/vm/c1/c1_IR.cpp
+++ b/hotspot/src/share/vm/c1/c1_IR.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 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
diff --git a/hotspot/src/share/vm/c1/c1_IR.hpp b/hotspot/src/share/vm/c1/c1_IR.hpp
index a3bcc2a477f..f7bbea2ff3b 100644
--- a/hotspot/src/share/vm/c1/c1_IR.hpp
+++ b/hotspot/src/share/vm/c1/c1_IR.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2006 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
diff --git a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp
index 0388385a8b0..60298587a7d 100644
--- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp
+++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp
@@ -133,12 +133,12 @@ void InstructionPrinter::print_object(Value obj) {
ciMethod* m = (ciMethod*)value;
output()->print("", m->holder()->name()->as_utf8(), m->name()->as_utf8());
} else {
- output()->print("
*
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * display the added component.
+ *
* @param comp the component to be added
* @param constraints an object expressing layout constraints
* for this component
@@ -1033,6 +1048,7 @@ public class Container extends Component {
* @see #add(Component)
* @see #add(Component, int)
* @see #add(Component, java.lang.Object)
+ * @see #invalidate
* @see LayoutManager
* @see LayoutManager2
* @since JDK1.1
@@ -1145,19 +1161,18 @@ public class Container extends Component {
* This method also notifies the layout manager to remove the
* component from this container's layout via the
* removeLayoutComponent method.
- *
*
- * Note: If a component has been removed from a container that
- * had been displayed, {@link #validate} must be
- * called on that container to reflect changes.
- * If multiple components are being removed, you can improve
- * efficiency by calling {@link #validate} only once,
- * after all the components have been removed.
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * reflect the changes.
+ *
*
* @param index the index of the component to be removed
* @throws ArrayIndexOutOfBoundsException if {@code index} is not in
* range {@code [0, getComponentCount()-1]}
* @see #add
+ * @see #invalidate
* @see #validate
* @see #getComponentCount
* @since JDK1.1
@@ -1209,17 +1224,15 @@ public class Container extends Component {
* This method also notifies the layout manager to remove the
* component from this container's layout via the
* removeLayoutComponent method.
- *
*
- * Note: If a component has been removed from a container that
- * had been displayed, {@link #validate} must be
- * called on that container to reflect changes.
- * If multiple components are being removed, you can improve
- * efficiency by calling {@link #validate} only once,
- * after all the components have been removed.
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * reflect the changes.
*
* @param comp the component to be removed
* @see #add
+ * @see #invalidate
* @see #validate
* @see #remove(int)
*/
@@ -1239,8 +1252,15 @@ public class Container extends Component {
* This method also notifies the layout manager to remove the
* components from this container's layout via the
* removeLayoutComponent method.
+ *
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy. If the container has already been
+ * displayed, the hierarchy must be validated thereafter in order to
+ * reflect the changes.
+ *
* @see #add
* @see #remove
+ * @see #invalidate
*/
public void removeAll() {
synchronized (getTreeLock()) {
@@ -1287,33 +1307,33 @@ public class Container extends Component {
int superListening = super.numListening(mask);
if (mask == AWTEvent.HIERARCHY_EVENT_MASK) {
- if (eventLog.isLoggable(Level.FINE)) {
+ if (eventLog.isLoggable(PlatformLogger.FINE)) {
// Verify listeningChildren is correct
int sum = 0;
for (Component comp : component) {
sum += comp.numListening(mask);
}
if (listeningChildren != sum) {
- eventLog.log(Level.FINE, "Assertion (listeningChildren == sum) failed");
+ eventLog.fine("Assertion (listeningChildren == sum) failed");
}
}
return listeningChildren + superListening;
} else if (mask == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) {
- if (eventLog.isLoggable(Level.FINE)) {
+ if (eventLog.isLoggable(PlatformLogger.FINE)) {
// Verify listeningBoundsChildren is correct
int sum = 0;
for (Component comp : component) {
sum += comp.numListening(mask);
}
if (listeningBoundsChildren != sum) {
- eventLog.log(Level.FINE, "Assertion (listeningBoundsChildren == sum) failed");
+ eventLog.fine("Assertion (listeningBoundsChildren == sum) failed");
}
}
return listeningBoundsChildren + superListening;
} else {
// assert false;
- if (eventLog.isLoggable(Level.FINE)) {
- eventLog.log(Level.FINE, "This code must never be reached");
+ if (eventLog.isLoggable(PlatformLogger.FINE)) {
+ eventLog.fine("This code must never be reached");
}
return superListening;
}
@@ -1321,13 +1341,13 @@ public class Container extends Component {
// Should only be called while holding tree lock
void adjustListeningChildren(long mask, int num) {
- if (eventLog.isLoggable(Level.FINE)) {
+ if (eventLog.isLoggable(PlatformLogger.FINE)) {
boolean toAssert = (mask == AWTEvent.HIERARCHY_EVENT_MASK ||
mask == AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK ||
mask == (AWTEvent.HIERARCHY_EVENT_MASK |
AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
if (!toAssert) {
- eventLog.log(Level.FINE, "Assertion failed");
+ eventLog.fine("Assertion failed");
}
}
@@ -1362,14 +1382,14 @@ public class Container extends Component {
// Should only be called while holding tree lock
int countHierarchyMembers() {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
// Verify descendantsCount is correct
int sum = 0;
for (Component comp : component) {
sum += comp.countHierarchyMembers();
}
if (descendantsCount != sum) {
- log.log(Level.FINE, "Assertion (descendantsCount == sum) failed");
+ log.fine("Assertion (descendantsCount == sum) failed");
}
}
return descendantsCount + 1;
@@ -1432,9 +1452,14 @@ public class Container extends Component {
/**
* Sets the layout manager for this container.
+ *
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param mgr the specified layout manager
* @see #doLayout
* @see #getLayout
+ * @see #invalidate
*/
public void setLayout(LayoutManager mgr) {
layoutMgr = mgr;
@@ -1502,9 +1527,17 @@ public class Container extends Component {
*
If this {@code Container} is not valid, this method invokes
* the {@code validateTree} method and marks this {@code Container}
* as valid. Otherwise, no action is performed.
+ *
+ * Note that the {@code invalidate()} method may invalidate not only the
+ * component it is called upon, but also the parents of the component.
+ * Therefore, to restore the validity of the hierarchy, the {@code
+ * validate()} method must be invoked on the top-most invalid container of
+ * the hierarchy. For performance reasons a developer may postpone the
+ * validation of the hierarchy till a bunch of layout-related operations
+ * completes, e.g. after adding all the children to the container.
*
* @see #add(java.awt.Component)
- * @see Component#invalidate
+ * @see #invalidate
* @see javax.swing.JComponent#revalidate()
* @see #validateTree
*/
@@ -1588,8 +1621,13 @@ public class Container extends Component {
/**
* Sets the font of this container.
+ *
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
+ *
* @param f The font to become this container's font.
* @see Component#getFont
+ * @see #invalidate
* @since JDK1.0
*/
public void setFont(Font f) {
@@ -3386,12 +3424,16 @@ public class Container extends Component {
/**
* Sets the ComponentOrientation property of this container
* and all components contained within it.
+ *
+ * This method changes layout-related information, and therefore,
+ * invalidates the component hierarchy.
*
* @param o the new component orientation of this container and
* the components contained within it.
* @exception NullPointerException if orientation is null.
* @see Component#setComponentOrientation
* @see Component#getComponentOrientation
+ * @see #invalidate
* @since 1.4
*/
public void applyComponentOrientation(ComponentOrientation o) {
@@ -3924,7 +3966,7 @@ public class Container extends Component {
final void recursiveSubtractAndApplyShape(Region shape, int fromZorder, int toZorder) {
checkTreeLock();
- if (mixingLog.isLoggable(Level.FINE)) {
+ if (mixingLog.isLoggable(PlatformLogger.FINE)) {
mixingLog.fine("this = " + this +
"; shape=" + shape + "; fromZ=" + fromZorder + "; toZ=" + toZorder);
}
@@ -3961,7 +4003,7 @@ public class Container extends Component {
final void recursiveApplyCurrentShape(int fromZorder, int toZorder) {
checkTreeLock();
- if (mixingLog.isLoggable(Level.FINE)) {
+ if (mixingLog.isLoggable(PlatformLogger.FINE)) {
mixingLog.fine("this = " + this +
"; fromZ=" + fromZorder + "; toZ=" + toZorder);
}
@@ -4065,20 +4107,20 @@ public class Container extends Component {
@Override
void mixOnShowing() {
synchronized (getTreeLock()) {
- if (mixingLog.isLoggable(Level.FINE)) {
+ if (mixingLog.isLoggable(PlatformLogger.FINE)) {
mixingLog.fine("this = " + this);
}
- if (!isMixingNeeded()) {
- return;
- }
-
boolean isLightweight = isLightweight();
if (isLightweight && isRecursivelyVisibleUpToHeavyweightContainer()) {
recursiveShowHeavyweightChildren();
}
+ if (!isMixingNeeded()) {
+ return;
+ }
+
if (!isLightweight || (isLightweight && hasHeavyweightDescendants())) {
recursiveApplyCurrentShape();
}
@@ -4090,7 +4132,7 @@ public class Container extends Component {
@Override
void mixOnHiding(boolean isLightweight) {
synchronized (getTreeLock()) {
- if (mixingLog.isLoggable(Level.FINE)) {
+ if (mixingLog.isLoggable(PlatformLogger.FINE)) {
mixingLog.fine("this = " + this +
"; isLightweight=" + isLightweight);
}
@@ -4104,7 +4146,7 @@ public class Container extends Component {
@Override
void mixOnReshaping() {
synchronized (getTreeLock()) {
- if (mixingLog.isLoggable(Level.FINE)) {
+ if (mixingLog.isLoggable(PlatformLogger.FINE)) {
mixingLog.fine("this = " + this);
}
@@ -4139,7 +4181,7 @@ public class Container extends Component {
@Override
void mixOnZOrderChanging(int oldZorder, int newZorder) {
synchronized (getTreeLock()) {
- if (mixingLog.isLoggable(Level.FINE)) {
+ if (mixingLog.isLoggable(PlatformLogger.FINE)) {
mixingLog.fine("this = " + this +
"; oldZ=" + oldZorder + "; newZ=" + newZorder);
}
@@ -4160,7 +4202,7 @@ public class Container extends Component {
@Override
void mixOnValidating() {
synchronized (getTreeLock()) {
- if (mixingLog.isLoggable(Level.FINE)) {
+ if (mixingLog.isLoggable(PlatformLogger.FINE)) {
mixingLog.fine("this = " + this);
}
@@ -4206,7 +4248,7 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
*/
private static final int LWD_MOUSE_DRAGGED_OVER = 1500;
- private static final Logger eventLog = Logger.getLogger("java.awt.event.LightweightDispatcher");
+ private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.LightweightDispatcher");
LightweightDispatcher(Container nativeContainer) {
this.nativeContainer = nativeContainer;
@@ -4348,10 +4390,10 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
// This may send it somewhere that doesn't have MouseWheelEvents
// enabled. In this case, Component.dispatchEventImpl() will
// retarget the event to a parent that DOES have the events enabled.
- if (eventLog.isLoggable(Level.FINEST) && (mouseOver != null)) {
- eventLog.log(Level.FINEST, "retargeting mouse wheel to " +
- mouseOver.getName() + ", " +
- mouseOver.getClass());
+ if (eventLog.isLoggable(PlatformLogger.FINEST) && (mouseOver != null)) {
+ eventLog.finest("retargeting mouse wheel to " +
+ mouseOver.getName() + ", " +
+ mouseOver.getClass());
}
retargetMouseEvent(mouseOver, id, e);
break;
diff --git a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java
index e3913a7fff9..dc5f830ef22 100644
--- a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java
+++ b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java
@@ -24,9 +24,9 @@
*/
package java.awt;
-import java.util.logging.*;
import java.util.List;
import java.util.ArrayList;
+import sun.util.logging.PlatformLogger;
/**
* A FocusTraversalPolicy that determines traversal order based on the order
@@ -60,7 +60,7 @@ import java.util.ArrayList;
public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
implements java.io.Serializable
{
- private static final Logger log = Logger.getLogger("java.awt.ContainerOrderFocusTraversalPolicy");
+ private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.ContainerOrderFocusTraversalPolicy");
final private int FORWARD_TRAVERSAL = 0;
final private int BACKWARD_TRAVERSAL = 1;
@@ -165,7 +165,7 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
if (getImplicitDownCycleTraversal()) {
retComp = cont.getFocusTraversalPolicy().getDefaultComponent(cont);
- if (retComp != null && log.isLoggable(Level.FINE)) {
+ if (retComp != null && log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Transfered focus down-cycle to " + retComp +
" in the focus cycle root " + cont);
}
@@ -177,7 +177,7 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
cont.getFocusTraversalPolicy().getDefaultComponent(cont) :
cont.getFocusTraversalPolicy().getLastComponent(cont));
- if (retComp != null && log.isLoggable(Level.FINE)) {
+ if (retComp != null && log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Transfered focus to " + retComp + " in the FTP provider " + cont);
}
}
@@ -208,7 +208,7 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
* aComponent is null
*/
public Component getComponentAfter(Container aContainer, Component aComponent) {
- if (log.isLoggable(Level.FINE)) log.fine("### Searching in " + aContainer + " for component after " + aComponent);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Searching in " + aContainer + " for component after " + aComponent);
if (aContainer == null || aComponent == null) {
throw new IllegalArgumentException("aContainer and aComponent cannot be null");
@@ -236,7 +236,7 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
// See if the component is inside of policy provider.
Container provider = getTopmostProvider(aContainer, aComponent);
if (provider != null) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Asking FTP " + provider + " for component after " + aComponent);
}
@@ -247,7 +247,7 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
// Null result means that we overstepped the limit of the FTP's cycle.
// In that case we must quit the cycle, otherwise return the component found.
if (afterComp != null) {
- if (log.isLoggable(Level.FINE)) log.fine("### FTP returned " + afterComp);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### FTP returned " + afterComp);
return afterComp;
}
aComponent = provider;
@@ -255,12 +255,12 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
List cycle = getFocusTraversalCycle(aContainer);
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle + ", component is " + aComponent);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is " + cycle + ", component is " + aComponent);
int index = getComponentIndex(cycle, aComponent);
if (index < 0) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Didn't find component " + aComponent + " in a cycle " + aContainer);
}
return getFirstComponent(aContainer);
@@ -325,7 +325,7 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
// See if the component is inside of policy provider.
Container provider = getTopmostProvider(aContainer, aComponent);
if (provider != null) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Asking FTP " + provider + " for component after " + aComponent);
}
@@ -336,7 +336,7 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
// Null result means that we overstepped the limit of the FTP's cycle.
// In that case we must quit the cycle, otherwise return the component found.
if (beforeComp != null) {
- if (log.isLoggable(Level.FINE)) log.fine("### FTP returned " + beforeComp);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### FTP returned " + beforeComp);
return beforeComp;
}
aComponent = provider;
@@ -349,12 +349,12 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
List cycle = getFocusTraversalCycle(aContainer);
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle + ", component is " + aComponent);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is " + cycle + ", component is " + aComponent);
int index = getComponentIndex(cycle, aComponent);
if (index < 0) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Didn't find component " + aComponent + " in a cycle " + aContainer);
}
return getLastComponent(aContainer);
@@ -401,7 +401,7 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
public Component getFirstComponent(Container aContainer) {
List cycle;
- if (log.isLoggable(Level.FINE)) log.fine("### Getting first component in " + aContainer);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Getting first component in " + aContainer);
if (aContainer == null) {
throw new IllegalArgumentException("aContainer cannot be null");
@@ -420,10 +420,10 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
}
if (cycle.size() == 0) {
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is empty");
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is empty");
return null;
}
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is " + cycle);
for (Component comp : cycle) {
if (accept(comp)) {
@@ -451,7 +451,7 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
*/
public Component getLastComponent(Container aContainer) {
List cycle;
- if (log.isLoggable(Level.FINE)) log.fine("### Getting last component in " + aContainer);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Getting last component in " + aContainer);
if (aContainer == null) {
throw new IllegalArgumentException("aContainer cannot be null");
@@ -470,10 +470,10 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
}
if (cycle.size() == 0) {
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is empty");
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is empty");
return null;
}
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is " + cycle);
for (int i= cycle.size() - 1; i >= 0; i--) {
Component comp = cycle.get(i);
diff --git a/jdk/src/share/classes/java/awt/Cursor.java b/jdk/src/share/classes/java/awt/Cursor.java
index 0187eac69b9..9f841f14359 100644
--- a/jdk/src/share/classes/java/awt/Cursor.java
+++ b/jdk/src/share/classes/java/awt/Cursor.java
@@ -36,10 +36,10 @@ import java.util.Hashtable;
import java.util.Properties;
import java.util.StringTokenizer;
-import java.util.logging.*;
-
import java.security.AccessController;
+import sun.util.logging.PlatformLogger;
+
/**
* A class to encapsulate the bitmap representation of the mouse cursor.
*
@@ -119,7 +119,7 @@ public class Cursor implements java.io.Serializable {
public static final int MOVE_CURSOR = 13;
/**
- * @deprecated As of JDK version 1.7, the {@link #getPredefinedCursor()}
+ * @deprecated As of JDK version 1.7, the {@link #getPredefinedCursor(int)}
* method should be used instead.
*/
@Deprecated
@@ -191,7 +191,7 @@ public class Cursor implements java.io.Serializable {
*/
private static final long serialVersionUID = 8028237497568985504L;
- private static final Logger log = Logger.getLogger("java.awt.Cursor");
+ private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.Cursor");
static {
/* ensure that the necessary native libraries are loaded */
@@ -298,8 +298,8 @@ public class Cursor implements java.io.Serializable {
String key = prefix + DotFileSuffix;
if (!systemCustomCursorProperties.containsKey(key)) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "Cursor.getSystemCustomCursor(" + name + ") returned null");
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null");
}
return null;
}
@@ -353,8 +353,8 @@ public class Cursor implements java.io.Serializable {
}
if (cursor == null) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "Cursor.getSystemCustomCursor(" + name + ") returned null");
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null");
}
} else {
systemCustomCursors.put(name, cursor);
diff --git a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java
index 71342bdaeed..4bc8b8fbf7b 100644
--- a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java
+++ b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java
@@ -35,8 +35,7 @@ import java.util.Iterator;
import java.util.ListIterator;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
@@ -62,7 +61,7 @@ import sun.awt.CausedFocusEvent;
* @since 1.4
*/
public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
- private static final Logger focusLog = Logger.getLogger("java.awt.focus.DefaultKeyboardFocusManager");
+ private static final PlatformLogger focusLog = PlatformLogger.getLogger("java.awt.focus.DefaultKeyboardFocusManager");
// null weak references to not create too many objects
private static final WeakReference NULL_WINDOW_WR =
@@ -275,7 +274,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
* false otherwise
*/
public boolean dispatchEvent(AWTEvent e) {
- if (focusLog.isLoggable(Level.FINE) && (e instanceof WindowEvent || e instanceof FocusEvent)) focusLog.fine("" + e);
+ if (focusLog.isLoggable(PlatformLogger.FINE) && (e instanceof WindowEvent || e instanceof FocusEvent)) focusLog.fine("" + e);
switch (e.getID()) {
case WindowEvent.WINDOW_GAINED_FOCUS: {
WindowEvent we = (WindowEvent)e;
@@ -378,9 +377,9 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
// The component which last has the focus when this window was focused
// should receive focus first
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "tempLost {0}, toFocus {1}",
- new Object[]{tempLost, toFocus});
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
+ focusLog.finer("tempLost {0}, toFocus {1}",
+ tempLost, toFocus);
}
if (tempLost != null) {
tempLost.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
@@ -447,8 +446,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
Component oldFocusOwner = getGlobalFocusOwner();
Component newFocusOwner = fe.getComponent();
if (oldFocusOwner == newFocusOwner) {
- if (focusLog.isLoggable(Level.FINE)) {
- focusLog.log(Level.FINE, "Skipping {0} because focus owner is the same", new Object[] {e});
+ if (focusLog.isLoggable(PlatformLogger.FINE)) {
+ focusLog.fine("Skipping {0} because focus owner is the same", e);
}
// We can't just drop the event - there could be
// type-ahead markers associated with it.
@@ -565,16 +564,16 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
FocusEvent fe = (FocusEvent)e;
Component currentFocusOwner = getGlobalFocusOwner();
if (currentFocusOwner == null) {
- if (focusLog.isLoggable(Level.FINE)) focusLog.log(Level.FINE, "Skipping {0} because focus owner is null",
- new Object[] {e});
+ if (focusLog.isLoggable(PlatformLogger.FINE))
+ focusLog.fine("Skipping {0} because focus owner is null", e);
break;
}
// Ignore cases where a Component loses focus to itself.
// If we make a mistake because of retargeting, then the
// FOCUS_GAINED handler will correct it.
if (currentFocusOwner == fe.getOppositeComponent()) {
- if (focusLog.isLoggable(Level.FINE)) focusLog.log(Level.FINE, "Skipping {0} because current focus owner is equal to opposite",
- new Object[] {e});
+ if (focusLog.isLoggable(PlatformLogger.FINE))
+ focusLog.fine("Skipping {0} because current focus owner is equal to opposite", e);
break;
}
@@ -642,9 +641,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
Window losingFocusWindow = we.getWindow();
Window activeWindow = getGlobalActiveWindow();
Window oppositeWindow = we.getOppositeWindow();
- if (focusLog.isLoggable(Level.FINE)) focusLog.log(Level.FINE, "Active {0}, Current focused {1}, losing focus {2} opposite {3}",
- new Object[] {activeWindow, currentFocusedWindow,
- losingFocusWindow, oppositeWindow});
+ if (focusLog.isLoggable(PlatformLogger.FINE))
+ focusLog.fine("Active {0}, Current focused {1}, losing focus {2} opposite {3}",
+ activeWindow, currentFocusedWindow,
+ losingFocusWindow, oppositeWindow);
if (currentFocusedWindow == null) {
break;
}
@@ -828,7 +828,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
}
}
if (ke != null) {
- focusLog.log(Level.FINER, "Pumping approved event {0}", new Object[] {ke});
+ focusLog.finer("Pumping approved event {0}", ke);
enqueuedKeyEvents.removeFirst();
}
}
@@ -843,14 +843,14 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
* Dumps the list of type-ahead queue markers to stderr
*/
void dumpMarkers() {
- if (focusLog.isLoggable(Level.FINEST)) {
- focusLog.log(Level.FINEST, ">>> Markers dump, time: {0}", System.currentTimeMillis());
+ if (focusLog.isLoggable(PlatformLogger.FINEST)) {
+ focusLog.finest(">>> Markers dump, time: {0}", System.currentTimeMillis());
synchronized (this) {
if (typeAheadMarkers.size() != 0) {
Iterator iter = typeAheadMarkers.iterator();
while (iter.hasNext()) {
TypeAheadMarker marker = (TypeAheadMarker)iter.next();
- focusLog.log(Level.FINEST, " {0}", marker);
+ focusLog.finest(" {0}", marker);
}
}
}
@@ -878,7 +878,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
// The fix is rolled out.
if (ke.getWhen() > marker.after) {
- focusLog.log(Level.FINER, "Storing event {0} because of marker {1}", new Object[] {ke, marker});
+ focusLog.finer("Storing event {0} because of marker {1}", ke, marker);
enqueuedKeyEvents.addLast(ke);
return true;
}
@@ -890,7 +890,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
}
case FocusEvent.FOCUS_GAINED:
- focusLog.log(Level.FINEST, "Markers before FOCUS_GAINED on {0}", new Object[] {target});
+ focusLog.finest("Markers before FOCUS_GAINED on {0}", target);
dumpMarkers();
// Search the marker list for the first marker tied to
// the Component which just gained focus. Then remove
@@ -919,10 +919,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
}
} else {
// Exception condition - event without marker
- focusLog.log(Level.FINER, "Event without marker {0}", e);
+ focusLog.finer("Event without marker {0}", e);
}
}
- focusLog.log(Level.FINEST, "Markers after FOCUS_GAINED");
+ focusLog.finest("Markers after FOCUS_GAINED");
dumpMarkers();
redispatchEvent(target, e);
@@ -1159,8 +1159,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
return;
}
- focusLog.log(Level.FINER, "Enqueue at {0} for {1}",
- new Object[] {after, untilFocused});
+ focusLog.finer("Enqueue at {0} for {1}",
+ after, untilFocused);
int insertionIndex = 0,
i = typeAheadMarkers.size();
@@ -1199,8 +1199,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
return;
}
- focusLog.log(Level.FINER, "Dequeue at {0} for {1}",
- new Object[] {after, untilFocused});
+ focusLog.finer("Dequeue at {0} for {1}",
+ after, untilFocused);
TypeAheadMarker marker;
ListIterator iter = typeAheadMarkers.listIterator
diff --git a/jdk/src/share/classes/java/awt/Dialog.java b/jdk/src/share/classes/java/awt/Dialog.java
index 4660e6ea07c..b897183ca8b 100644
--- a/jdk/src/share/classes/java/awt/Dialog.java
+++ b/jdk/src/share/classes/java/awt/Dialog.java
@@ -856,7 +856,7 @@ public class Dialog extends Window {
if (type == ModalityType.TOOLKIT_MODAL) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
- sm.checkPermission(SecurityConstants.TOOLKIT_MODALITY_PERMISSION);
+ sm.checkPermission(SecurityConstants.AWT.TOOLKIT_MODALITY_PERMISSION);
}
}
modalityType = type;
diff --git a/jdk/src/share/classes/java/awt/EventDispatchThread.java b/jdk/src/share/classes/java/awt/EventDispatchThread.java
index f35ff913a7d..e0c46a37d33 100644
--- a/jdk/src/share/classes/java/awt/EventDispatchThread.java
+++ b/jdk/src/share/classes/java/awt/EventDispatchThread.java
@@ -36,7 +36,7 @@ import sun.awt.AWTAutoShutdown;
import sun.awt.SunToolkit;
import java.util.Vector;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
import sun.awt.dnd.SunDragSourceContextPeer;
import sun.awt.EventQueueDelegate;
@@ -61,7 +61,7 @@ import sun.awt.EventQueueDelegate;
* @since 1.1
*/
class EventDispatchThread extends Thread {
- private static final Logger eventLog = Logger.getLogger("java.awt.event.EventDispatchThread");
+ private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventDispatchThread");
private EventQueue theQueue;
private boolean doDispatch = true;
@@ -275,8 +275,8 @@ class EventDispatchThread extends Thread {
}
while (eventOK == false);
- if (eventLog.isLoggable(Level.FINEST)) {
- eventLog.log(Level.FINEST, "Dispatching: " + event);
+ if (eventLog.isLoggable(PlatformLogger.FINEST)) {
+ eventLog.finest("Dispatching: " + event);
}
Object handle = null;
@@ -308,8 +308,8 @@ class EventDispatchThread extends Thread {
}
private void processException(Throwable e) {
- if (eventLog.isLoggable(Level.FINE)) {
- eventLog.log(Level.FINE, "Processing exception: " + e);
+ if (eventLog.isLoggable(PlatformLogger.FINE)) {
+ eventLog.fine("Processing exception: " + e);
}
getUncaughtExceptionHandler().uncaughtException(this, e);
// don't rethrow the exception to avoid EDT recreation
diff --git a/jdk/src/share/classes/java/awt/EventQueue.java b/jdk/src/share/classes/java/awt/EventQueue.java
index 45230515330..3e9febf79b7 100644
--- a/jdk/src/share/classes/java/awt/EventQueue.java
+++ b/jdk/src/share/classes/java/awt/EventQueue.java
@@ -36,7 +36,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.EmptyStackException;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.AWTAutoShutdown;
@@ -153,7 +153,7 @@ public class EventQueue {
private final String name = "AWT-EventQueue-" + nextThreadNum();
- private static final Logger eventLog = Logger.getLogger("java.awt.event.EventQueue");
+ private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
static {
AWTAccessor.setEventQueueAccessor(
@@ -707,8 +707,8 @@ public class EventQueue {
* @since 1.2
*/
public synchronized void push(EventQueue newEventQueue) {
- if (eventLog.isLoggable(Level.FINE)) {
- eventLog.log(Level.FINE, "EventQueue.push(" + newEventQueue + ")");
+ if (eventLog.isLoggable(PlatformLogger.FINE)) {
+ eventLog.fine("EventQueue.push(" + newEventQueue + ")");
}
if (nextQueue != null) {
@@ -722,8 +722,8 @@ public class EventQueue {
try {
newEventQueue.postEventPrivate(getNextEvent());
} catch (InterruptedException ie) {
- if (eventLog.isLoggable(Level.FINE)) {
- eventLog.log(Level.FINE, "Interrupted push", ie);
+ if (eventLog.isLoggable(PlatformLogger.FINE)) {
+ eventLog.fine("Interrupted push", ie);
}
}
}
@@ -766,8 +766,8 @@ public class EventQueue {
* @since 1.2
*/
protected void pop() throws EmptyStackException {
- if (eventLog.isLoggable(Level.FINE)) {
- eventLog.log(Level.FINE, "EventQueue.pop(" + this + ")");
+ if (eventLog.isLoggable(PlatformLogger.FINE)) {
+ eventLog.fine("EventQueue.pop(" + this + ")");
}
// To prevent deadlock, we lock on the previous EventQueue before
@@ -790,8 +790,8 @@ public class EventQueue {
try {
previousQueue.postEventPrivate(getNextEvent());
} catch (InterruptedException ie) {
- if (eventLog.isLoggable(Level.FINE)) {
- eventLog.log(Level.FINE, "Interrupted pop", ie);
+ if (eventLog.isLoggable(PlatformLogger.FINE)) {
+ eventLog.fine("Interrupted pop", ie);
}
}
}
@@ -843,7 +843,8 @@ public class EventQueue {
final void initDispatchThread() {
synchronized (this) {
- if (dispatchThread == null && !threadGroup.isDestroyed()) {
+ AppContext appContext = AppContext.getAppContext();
+ if (dispatchThread == null && !threadGroup.isDestroyed() && !appContext.isDisposed()) {
dispatchThread = (EventDispatchThread)
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
diff --git a/jdk/src/share/classes/java/awt/Font.java b/jdk/src/share/classes/java/awt/Font.java
index 97773143415..792acdd07a1 100644
--- a/jdk/src/share/classes/java/awt/Font.java
+++ b/jdk/src/share/classes/java/awt/Font.java
@@ -30,7 +30,6 @@ import java.awt.font.GlyphVector;
import java.awt.font.LineMetrics;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
-import java.awt.font.TransformAttribute;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
@@ -42,21 +41,21 @@ import java.security.PrivilegedExceptionAction;
import java.text.AttributedCharacterIterator.Attribute;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
-import java.util.HashMap;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Map;
import sun.font.StandardGlyphVector;
-import sun.java2d.FontSupport;
import sun.font.AttributeMap;
import sun.font.AttributeValues;
-import sun.font.EAttribute;
import sun.font.CompositeFont;
import sun.font.CreatedFontTracker;
import sun.font.Font2D;
import sun.font.Font2DHandle;
+import sun.font.FontAccess;
import sun.font.FontManager;
+import sun.font.FontManagerFactory;
+import sun.font.FontUtilities;
import sun.font.GlyphLayout;
import sun.font.FontLineMetrics;
import sun.font.CoreMetrics;
@@ -223,10 +222,29 @@ import static sun.font.EAttribute.*;
*/
public class Font implements java.io.Serializable
{
+ private static class FontAccessImpl extends FontAccess {
+ public Font2D getFont2D(Font font) {
+ return font.getFont2D();
+ }
+
+ public void setFont2D(Font font, Font2DHandle handle) {
+ font.font2DHandle = handle;
+ }
+
+ public void setCreatedFont(Font font) {
+ font.createdFont = true;
+ }
+
+ public boolean isCreatedFont(Font font) {
+ return font.createdFont;
+ }
+ }
+
static {
/* ensure that the necessary native libraries are loaded */
Toolkit.loadLibraries();
initIDs();
+ FontAccess.setFontAccess(new FontAccessImpl());
}
/**
@@ -464,16 +482,17 @@ public class Font implements java.io.Serializable
}
private Font2D getFont2D() {
- if (FontManager.usingPerAppContextComposites &&
+ FontManager fm = FontManagerFactory.getInstance();
+ if (fm.usingPerAppContextComposites() &&
font2DHandle != null &&
font2DHandle.font2D instanceof CompositeFont &&
((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
- return FontManager.findFont2D(name, style,
+ return fm.findFont2D(name, style,
FontManager.LOGICAL_FALLBACK);
} else if (font2DHandle == null) {
font2DHandle =
- FontManager.findFont2D(name, style,
- FontManager.LOGICAL_FALLBACK).handle;
+ fm.findFont2D(name, style,
+ FontManager.LOGICAL_FALLBACK).handle;
}
/* Do not cache the de-referenced font2D. It must be explicitly
* de-referenced to pick up a valid font in the event that the
@@ -570,8 +589,8 @@ public class Font implements java.io.Serializable
if (created) {
if (handle.font2D instanceof CompositeFont &&
handle.font2D.getStyle() != style) {
- this.font2DHandle =
- FontManager.getNewComposite(null, style, handle);
+ FontManager fm = FontManagerFactory.getInstance();
+ this.font2DHandle = fm.getNewComposite(null, style, handle);
} else {
this.font2DHandle = handle;
}
@@ -586,9 +605,9 @@ public class Font implements java.io.Serializable
/* Font2D instances created by this method track their font file
* so that when the Font2D is GC'd it can also remove the file.
*/
- this.font2DHandle =
- FontManager.createFont2D(fontFile, fontFormat,
- isCopy, tracker).handle;
+ FontManager fm = FontManagerFactory.getInstance();
+ this.font2DHandle = fm.createFont2D(fontFile, fontFormat, isCopy,
+ tracker).handle;
this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
this.style = Font.PLAIN;
this.size = 1;
@@ -640,8 +659,9 @@ public class Font implements java.io.Serializable
}
if (handle.font2D instanceof CompositeFont) {
if (newStyle != -1 || newName != null) {
+ FontManager fm = FontManagerFactory.getInstance();
this.font2DHandle =
- FontManager.getNewComposite(newName, newStyle, handle);
+ fm.getNewComposite(newName, newStyle, handle);
}
} else if (newName != null) {
this.createdFont = false;
@@ -852,7 +872,6 @@ public class Font implements java.io.Serializable
throw new IllegalArgumentException ("font format not recognized");
}
boolean copiedFontData = false;
-
try {
final File tFile = AccessController.doPrivileged(
new PrivilegedExceptionAction() {
@@ -2320,7 +2339,7 @@ public class Font implements java.io.Serializable
(values.getKerning() == 0 && values.getLigatures() == 0 &&
values.getBaselineTransform() == null);
if (simple) {
- simple = !FontManager.isComplexText(chars, beginIndex, limit);
+ simple = ! FontUtilities.isComplexText(chars, beginIndex, limit);
}
if (simple) {
diff --git a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
index d77b2f22b8b..392a4478140 100644
--- a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
+++ b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
@@ -27,9 +27,14 @@
package java.awt;
import java.awt.image.BufferedImage;
+import java.security.AccessController;
import java.util.Locale;
+
+import sun.font.FontManager;
+import sun.font.FontManagerFactory;
import sun.java2d.HeadlessGraphicsEnvironment;
import sun.java2d.SunGraphicsEnvironment;
+import sun.security.action.GetPropertyAction;
/**
*
@@ -73,34 +78,52 @@ public abstract class GraphicsEnvironment {
*/
public static synchronized GraphicsEnvironment getLocalGraphicsEnvironment() {
if (localEnv == null) {
- String nm = (String) java.security.AccessController.doPrivileged
- (new sun.security.action.GetPropertyAction
- ("java.awt.graphicsenv", null));
-
- try {
-// long t0 = System.currentTimeMillis();
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- Class geCls = Class.forName(nm, true, cl);
- localEnv = (GraphicsEnvironment)geCls.newInstance();
-// long t1 = System.currentTimeMillis();
-// System.out.println("GE creation took " + (t1-t0)+ "ms.");
- if (isHeadless()) {
- localEnv = new HeadlessGraphicsEnvironment(localEnv);
- }
- } catch (ClassNotFoundException e) {
- throw new Error("Could not find class: "+nm);
- } catch (InstantiationException e) {
- throw new Error("Could not instantiate Graphics Environment: "
- + nm);
- } catch (IllegalAccessException e) {
- throw new Error ("Could not access Graphics Environment: "
- + nm);
- }
+ localEnv = createGE();
}
return localEnv;
}
+ /**
+ * Creates and returns the GraphicsEnvironment, according to the
+ * system property 'java.awt.graphicsenv'.
+ *
+ * @return the graphics environment
+ */
+ private static GraphicsEnvironment createGE() {
+ GraphicsEnvironment ge;
+ String nm = AccessController.doPrivileged(new GetPropertyAction("java.awt.graphicsenv", null));
+ try {
+// long t0 = System.currentTimeMillis();
+ Class geCls;
+ try {
+ // First we try if the bootclassloader finds the requested
+ // class. This way we can avoid to run in a privileged block.
+ geCls = Class.forName(nm);
+ } catch (ClassNotFoundException ex) {
+ // If the bootclassloader fails, we try again with the
+ // application classloader.
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ geCls = Class.forName(nm, true, cl);
+ }
+ ge = (GraphicsEnvironment) geCls.newInstance();
+// long t1 = System.currentTimeMillis();
+// System.out.println("GE creation took " + (t1-t0)+ "ms.");
+ if (isHeadless()) {
+ localEnv = new HeadlessGraphicsEnvironment(localEnv);
+ }
+ } catch (ClassNotFoundException e) {
+ throw new Error("Could not find class: "+nm);
+ } catch (InstantiationException e) {
+ throw new Error("Could not instantiate Graphics Environment: "
+ + nm);
+ } catch (IllegalAccessException e) {
+ throw new Error ("Could not access Graphics Environment: "
+ + nm);
+ }
+ return ge;
+ }
+
/**
* Tests whether or not a display, keyboard, and mouse can be
* supported in this environment. If this method returns true,
@@ -333,7 +356,8 @@ public abstract class GraphicsEnvironment {
if (font == null) {
throw new NullPointerException("font cannot be null.");
}
- return sun.font.FontManager.registerFont(font);
+ FontManager fm = FontManagerFactory.getInstance();
+ return fm.registerFont(font);
}
/**
@@ -357,10 +381,8 @@ public abstract class GraphicsEnvironment {
* @since 1.5
*/
public void preferLocaleFonts() {
- if (!(this instanceof SunGraphicsEnvironment)) {
- return;
- }
- sun.font.FontManager.preferLocaleFonts();
+ FontManager fm = FontManagerFactory.getInstance();
+ fm.preferLocaleFonts();
}
/**
@@ -380,10 +402,8 @@ public abstract class GraphicsEnvironment {
* @since 1.5
*/
public void preferProportionalFonts() {
- if (!(this instanceof SunGraphicsEnvironment)) {
- return;
- }
- sun.font.FontManager.preferProportionalFonts();
+ FontManager fm = FontManagerFactory.getInstance();
+ fm.preferProportionalFonts();
}
/**
diff --git a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java
index 521c70403ae..da94b624be0 100644
--- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java
+++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java
@@ -53,8 +53,7 @@ import java.util.Set;
import java.util.StringTokenizer;
import java.util.WeakHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.HeadlessToolkit;
@@ -111,7 +110,7 @@ public abstract class KeyboardFocusManager
{
// Shared focus engine logger
- private static final Logger focusLog = Logger.getLogger("java.awt.focus.KeyboardFocusManager");
+ private static final PlatformLogger focusLog = PlatformLogger.getLogger("java.awt.focus.KeyboardFocusManager");
static {
/* ensure that the necessary native libraries are loaded */
@@ -154,7 +153,7 @@ public abstract class KeyboardFocusManager
*/
private static native void initIDs();
- private static final Logger log = Logger.getLogger("java.awt.KeyboardFocusManager");
+ private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.KeyboardFocusManager");
/**
* The identifier for the Forward focus traversal keys.
@@ -504,8 +503,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return focusOwner;
} else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
+ focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@@ -609,9 +608,9 @@ public abstract class KeyboardFocusManager
}
void setNativeFocusOwner(Component comp) {
- if (focusLog.isLoggable(Level.FINEST)) {
- focusLog.log(Level.FINEST, "Calling peer {0} setCurrentFocusOwner for {1}",
- new Object[] {peer, comp});
+ if (focusLog.isLoggable(PlatformLogger.FINEST)) {
+ focusLog.finest("Calling peer {0} setCurrentFocusOwner for {1}",
+ peer, comp);
}
peer.setCurrentFocusOwner(comp);
}
@@ -673,8 +672,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return permanentFocusOwner;
} else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
+ focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@@ -781,8 +780,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return focusedWindow;
} else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
+ focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@@ -885,8 +884,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return activeWindow;
} else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
+ focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@@ -919,8 +918,8 @@ public abstract class KeyboardFocusManager
Window oldActiveWindow;
synchronized (KeyboardFocusManager.class) {
oldActiveWindow = getActiveWindow();
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
+ focusLog.finer("Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
}
try {
@@ -1215,8 +1214,8 @@ public abstract class KeyboardFocusManager
if (this == getCurrentKeyboardFocusManager()) {
return currentFocusCycleRoot;
} else {
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
+ focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
}
throw new SecurityException(notPrivileged);
}
@@ -2149,9 +2148,9 @@ public abstract class KeyboardFocusManager
HeavyweightFocusRequest(Component heavyweight, Component descendant,
boolean temporary, CausedFocusEvent.Cause cause) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
if (heavyweight == null) {
- log.log(Level.FINE, "Assertion (heavyweight != null) failed");
+ log.fine("Assertion (heavyweight != null) failed");
}
}
@@ -2161,12 +2160,12 @@ public abstract class KeyboardFocusManager
}
boolean addLightweightRequest(Component descendant,
boolean temporary, CausedFocusEvent.Cause cause) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) {
- log.log(Level.FINE, "Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
+ log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
}
if (descendant == null) {
- log.log(Level.FINE, "Assertion (descendant != null) failed");
+ log.fine("Assertion (descendant != null) failed");
}
}
@@ -2339,12 +2338,12 @@ public abstract class KeyboardFocusManager
(Component heavyweight, Component descendant, boolean temporary,
boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
{
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
if (heavyweight == null) {
- log.log(Level.FINE, "Assertion (heavyweight != null) failed");
+ log.fine("Assertion (heavyweight != null) failed");
}
if (time == 0) {
- log.log(Level.FINE, "Assertion (time != 0) failed");
+ log.fine("Assertion (time != 0) failed");
}
}
@@ -2361,31 +2360,31 @@ public abstract class KeyboardFocusManager
Component currentFocusOwner = thisManager.getGlobalFocusOwner();
Component nativeFocusOwner = thisManager.getNativeFocusOwner();
Window nativeFocusedWindow = thisManager.getNativeFocusedWindow();
- if (focusLog.isLoggable(Level.FINER)) {
- focusLog.log(Level.FINER, "SNFH for {0} in {1}",
- new Object[] {descendant, heavyweight});
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
+ focusLog.finer("SNFH for {0} in {1}",
+ descendant, heavyweight);
}
- if (focusLog.isLoggable(Level.FINEST)) {
- focusLog.log(Level.FINEST, "0. Current focus owner {0}",
- currentFocusOwner);
- focusLog.log(Level.FINEST, "0. Native focus owner {0}",
- nativeFocusOwner);
- focusLog.log(Level.FINEST, "0. Native focused window {0}",
- nativeFocusedWindow);
+ 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);
}
synchronized (heavyweightRequests) {
HeavyweightFocusRequest hwFocusRequest = getLastHWRequest();
- if (focusLog.isLoggable(Level.FINEST)) {
- focusLog.log(Level.FINEST, "Request {0}", hwFocusRequest);
+ if (focusLog.isLoggable(PlatformLogger.FINEST)) {
+ focusLog.finest("Request {0}", hwFocusRequest);
}
if (hwFocusRequest == null &&
heavyweight == nativeFocusOwner)
{
if (descendant == currentFocusOwner) {
// Redundant request.
- if (focusLog.isLoggable(Level.FINEST))
- focusLog.log(Level.FINEST, "1. SNFH_FAILURE for {0}",
- descendant);
+ if (focusLog.isLoggable(PlatformLogger.FINEST))
+ focusLog.finest("1. SNFH_FAILURE for {0}",
+ descendant);
return SNFH_FAILURE;
}
@@ -2417,8 +2416,8 @@ public abstract class KeyboardFocusManager
// SunToolkit.postPriorityEvent(newFocusOwnerEvent);
SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent);
- if (focusLog.isLoggable(Level.FINEST))
- focusLog.log(Level.FINEST, "2. SNFH_HANDLED for {0}", descendant);
+ if (focusLog.isLoggable(PlatformLogger.FINEST))
+ focusLog.finest("2. SNFH_HANDLED for {0}", descendant);
return SNFH_SUCCESS_HANDLED;
} else if (hwFocusRequest != null &&
hwFocusRequest.heavyweight == heavyweight) {
@@ -2431,7 +2430,7 @@ public abstract class KeyboardFocusManager
manager.enqueueKeyEvents(time, descendant);
}
- if (focusLog.isLoggable(Level.FINEST))
+ if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.finest("3. SNFH_HANDLED for lightweight" +
descendant + " in " + heavyweight);
return SNFH_SUCCESS_HANDLED;
@@ -2454,7 +2453,7 @@ public abstract class KeyboardFocusManager
(hwFocusRequest != null)
? hwFocusRequest.heavyweight
: nativeFocusedWindow)) {
- if (focusLog.isLoggable(Level.FINEST))
+ if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.finest("4. SNFH_FAILURE for " + descendant);
return SNFH_FAILURE;
}
@@ -2464,7 +2463,7 @@ public abstract class KeyboardFocusManager
heavyweightRequests.add
(new HeavyweightFocusRequest(heavyweight, descendant,
temporary, cause));
- if (focusLog.isLoggable(Level.FINEST))
+ if (focusLog.isLoggable(PlatformLogger.FINEST))
focusLog.finest("5. SNFH_PROCEED for " + descendant);
return SNFH_SUCCESS_PROCEED;
}
@@ -2855,13 +2854,13 @@ public abstract class KeyboardFocusManager
}
KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
- if (focusLog.isLoggable(Level.FINER)) {
+ if (focusLog.isLoggable(PlatformLogger.FINER)) {
if (event instanceof FocusEvent || event instanceof WindowEvent) {
- focusLog.log(Level.FINER, ">>> {0}", new Object[] {event});
+ focusLog.finer(">>> {0}", event);
}
- if (focusLog.isLoggable(Level.FINER) && event instanceof KeyEvent) {
- focusLog.log(Level.FINER, " focus owner is {0}", new Object[] {manager.getGlobalFocusOwner()});
- focusLog.log(Level.FINER, ">>> {0}", new Object[] {event});
+ if (focusLog.isLoggable(PlatformLogger.FINER) && event instanceof KeyEvent) {
+ focusLog.finer(" focus owner is {0}", manager.getGlobalFocusOwner());
+ focusLog.finer(">>> {0}", event);
}
}
@@ -2945,9 +2944,9 @@ public abstract class KeyboardFocusManager
}
}
static void removeLastFocusRequest(Component heavyweight) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
if (heavyweight == null) {
- log.log(Level.FINE, "Assertion (heavyweight != null) failed");
+ log.fine("Assertion (heavyweight != null) failed");
}
}
diff --git a/jdk/src/share/classes/java/awt/MouseInfo.java b/jdk/src/share/classes/java/awt/MouseInfo.java
index dce20bc0b84..8905ecaee9c 100644
--- a/jdk/src/share/classes/java/awt/MouseInfo.java
+++ b/jdk/src/share/classes/java/awt/MouseInfo.java
@@ -76,7 +76,7 @@ public class MouseInfo {
SecurityManager security = System.getSecurityManager();
if (security != null) {
- security.checkPermission(SecurityConstants.WATCH_MOUSE_PERMISSION);
+ security.checkPermission(SecurityConstants.AWT.WATCH_MOUSE_PERMISSION);
}
Point point = new Point(0, 0);
diff --git a/jdk/src/share/classes/java/awt/Robot.java b/jdk/src/share/classes/java/awt/Robot.java
index c9a32e2d01d..d262910a220 100644
--- a/jdk/src/share/classes/java/awt/Robot.java
+++ b/jdk/src/share/classes/java/awt/Robot.java
@@ -167,7 +167,7 @@ public class Robot {
private void checkRobotAllowed() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
- security.checkPermission(SecurityConstants.CREATE_ROBOT_PERMISSION);
+ security.checkPermission(SecurityConstants.AWT.CREATE_ROBOT_PERMISSION);
}
}
@@ -466,7 +466,7 @@ public class Robot {
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(
- SecurityConstants.READ_DISPLAY_PIXELS_PERMISSION);
+ SecurityConstants.AWT.READ_DISPLAY_PIXELS_PERMISSION);
}
}
diff --git a/jdk/src/share/classes/java/awt/SplashScreen.java b/jdk/src/share/classes/java/awt/SplashScreen.java
index cc172fc38a9..c0c6fc6c161 100644
--- a/jdk/src/share/classes/java/awt/SplashScreen.java
+++ b/jdk/src/share/classes/java/awt/SplashScreen.java
@@ -29,8 +29,7 @@ import java.awt.image.*;
import java.net.URL;
import java.net.URLConnection;
import java.io.File;
-import java.util.logging.Logger;
-import java.util.logging.Level;
+import sun.util.logging.PlatformLogger;
import sun.awt.image.SunWritableRaster;
/**
@@ -204,8 +203,8 @@ public final class SplashScreen {
}
}
catch(java.net.MalformedURLException e) {
- if (log.isLoggable(Level.FINE)) {
- log.log(Level.FINE, "MalformedURLException caught in the getImageURL() method", e);
+ if (log.isLoggable(PlatformLogger.FINE)) {
+ log.fine("MalformedURLException caught in the getImageURL() method", e);
}
}
}
@@ -355,7 +354,7 @@ public final class SplashScreen {
*/
private static SplashScreen theInstance = null;
- private static final Logger log = Logger.getLogger("java.awt.SplashScreen");
+ private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.SplashScreen");
private native static void _update(long splashPtr, int[] data, int x, int y, int width, int height, int scanlineStride);
private native static boolean _isVisible(long splashPtr);
diff --git a/jdk/src/share/classes/java/awt/SystemTray.java b/jdk/src/share/classes/java/awt/SystemTray.java
index 2aa172108b1..91cffdce9f2 100644
--- a/jdk/src/share/classes/java/awt/SystemTray.java
+++ b/jdk/src/share/classes/java/awt/SystemTray.java
@@ -490,7 +490,7 @@ public class SystemTray {
static void checkSystemTrayAllowed() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
- security.checkPermission(SecurityConstants.ACCESS_SYSTEM_TRAY_PERMISSION);
+ security.checkPermission(SecurityConstants.AWT.ACCESS_SYSTEM_TRAY_PERMISSION);
}
}
diff --git a/jdk/src/share/classes/java/awt/Toolkit.java b/jdk/src/share/classes/java/awt/Toolkit.java
index aaa6afdd5a0..5dca887afb0 100644
--- a/jdk/src/share/classes/java/awt/Toolkit.java
+++ b/jdk/src/share/classes/java/awt/Toolkit.java
@@ -48,7 +48,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.util.*;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -1956,7 +1956,7 @@ public abstract class Toolkit {
*/
public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType);
- private static final Logger log = Logger.getLogger("java.awt.Toolkit");
+ private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.Toolkit");
private static final int LONG_BITS = 64;
private int[] calls = new int[LONG_BITS];
@@ -2025,7 +2025,7 @@ public abstract class Toolkit {
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
- security.checkPermission(SecurityConstants.ALL_AWT_EVENTS_PERMISSION);
+ security.checkPermission(SecurityConstants.AWT.ALL_AWT_EVENTS_PERMISSION);
}
synchronized (this) {
SelectiveAWTEventListener selectiveListener =
@@ -2094,7 +2094,7 @@ public abstract class Toolkit {
}
SecurityManager security = System.getSecurityManager();
if (security != null) {
- security.checkPermission(SecurityConstants.ALL_AWT_EVENTS_PERMISSION);
+ security.checkPermission(SecurityConstants.AWT.ALL_AWT_EVENTS_PERMISSION);
}
synchronized (this) {
@@ -2123,9 +2123,9 @@ public abstract class Toolkit {
}
synchronized int countAWTEventListeners(long eventMask) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
if (eventMask == 0) {
- log.log(Level.FINE, "Assertion (eventMask != 0) failed");
+ log.fine("Assertion (eventMask != 0) failed");
}
}
@@ -2165,7 +2165,7 @@ public abstract class Toolkit {
public AWTEventListener[] getAWTEventListeners() {
SecurityManager security = System.getSecurityManager();
if (security != null) {
- security.checkPermission(SecurityConstants.ALL_AWT_EVENTS_PERMISSION);
+ security.checkPermission(SecurityConstants.AWT.ALL_AWT_EVENTS_PERMISSION);
}
synchronized (this) {
EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
@@ -2217,7 +2217,7 @@ public abstract class Toolkit {
public AWTEventListener[] getAWTEventListeners(long eventMask) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
- security.checkPermission(SecurityConstants.ALL_AWT_EVENTS_PERMISSION);
+ security.checkPermission(SecurityConstants.AWT.ALL_AWT_EVENTS_PERMISSION);
}
synchronized (this) {
EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java
index b216fdb1c15..8ea9ec821d8 100644
--- a/jdk/src/share/classes/java/awt/Window.java
+++ b/jdk/src/share/classes/java/awt/Window.java
@@ -48,8 +48,6 @@ import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.Vector;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.accessibility.*;
import sun.awt.AWTAccessor;
@@ -61,6 +59,7 @@ import sun.java2d.Disposer;
import sun.java2d.pipe.Region;
import sun.security.action.GetPropertyAction;
import sun.security.util.SecurityConstants;
+import sun.util.logging.PlatformLogger;
/**
* A Window object is a top-level window with no borders and no
@@ -324,7 +323,7 @@ public class Window extends Container implements Accessible {
*/
private static final long serialVersionUID = 4497834738069338734L;
- private static final Logger log = Logger.getLogger("java.awt.Window");
+ private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.Window");
private static final boolean locationByPlatformProp;
@@ -1581,7 +1580,7 @@ public class Window extends Container implements Accessible {
if (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
- sm.checkPermission(SecurityConstants.TOOLKIT_MODALITY_PERMISSION);
+ sm.checkPermission(SecurityConstants.AWT.TOOLKIT_MODALITY_PERMISSION);
}
}
modalExclusionType = exclusionType;
@@ -2129,7 +2128,7 @@ public class Window extends Container implements Accessible {
public final void setAlwaysOnTop(boolean alwaysOnTop) throws SecurityException {
SecurityManager security = System.getSecurityManager();
if (security != null) {
- security.checkPermission(SecurityConstants.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
+ security.checkPermission(SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
}
boolean oldAlwaysOnTop;
@@ -2985,7 +2984,7 @@ public class Window extends Container implements Accessible {
}
synchronized (getTreeLock()) {
super.setGraphicsConfiguration(gc);
- if (log.isLoggable(Level.FINER)) {
+ if (log.isLoggable(PlatformLogger.FINER)) {
log.finer("+ Window.setGraphicsConfiguration(): new GC is \n+ " + getGraphicsConfiguration_NoClientCode() + "\n+ this is " + this);
}
}
@@ -3347,7 +3346,7 @@ public class Window extends Container implements Accessible {
*
* @return the opacity of the window
*
- * @see Window#setOpacity
+ * @see Window#setOpacity(float)
* @see GraphicsDevice.WindowTranslucency
*
* @since 1.7
@@ -3366,7 +3365,7 @@ public class Window extends Container implements Accessible {
* window. This is a platform-dependent behavior.
*
* In order for this method to enable the translucency effect, the {@link
- * GraphicsDevice#isWindowTranslucencySupported()} method must indicate that
+ * GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)} method must indicate that
* the {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT}
* translucency is supported.
*
@@ -3375,8 +3374,8 @@ public class Window extends Container implements Accessible {
* IllegalComponentStateException} is thrown.
*
* The translucency levels of individual pixels may also be effected by the
- * alpha component of their color (see {@link setBackground()}) and the
- * current shape of this window (see {@link setShape()}).
+ * alpha component of their color (see {@link Window#setBackground(Color)}) and the
+ * current shape of this window (see {@link #setShape(Shape)}).
*
* @param opacity the opacity level to set to the window
*
@@ -3389,10 +3388,10 @@ public class Window extends Container implements Accessible {
* translucency kind is not supported and the opacity is less than 1.0f
*
* @see Window#getOpacity
- * @see Window#setBackground()
- * @see Window#setShape()
+ * @see Window#setBackground(Color)
+ * @see Window#setShape(Shape)
* @see GraphicsDevice.WindowTranslucency
- * @see GraphicsDevice#isWindowTranslucencySupported()
+ * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
*
* @since 1.7
*/
@@ -3434,7 +3433,7 @@ public class Window extends Container implements Accessible {
* @return the shape of the window or {@code null} if no
* shape is specified for the window
*
- * @see Window#setShape
+ * @see Window#setShape(Shape)
* @see GraphicsDevice.WindowTranslucency
*
* @since 1.7
@@ -3458,19 +3457,19 @@ public class Window extends Container implements Accessible {
*
*
The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
* PERPIXEL_TRANSPARENT} translucency kind must be supported by the
- * underlying system (see {@link })
+ * underlying system
* and
*
The window must not be in the full-screen mode (see
- * {@link GraphicsDevice#setFullScreenWindow()})
+ * {@link GraphicsDevice#setFullScreenWindow(Window)})
*
* If a certain condition is not met, either the {@code
* UnsupportedOperationException} or {@code IllegalComponentStateException}
* is thrown.
*
* The tranlucency levels of individual pixels may also be effected by the
- * alpha component of their color (see {@link setBackground()}) and the
- * opacity value (see {@link setOpacity()}). See {@link
- * GraphicsDevice#WindowTranslucency} for more details.
+ * alpha component of their color (see {@link Window#setBackground(Color)}) and the
+ * opacity value (see {@link #setOpacity(float)}). See {@link
+ * GraphicsDevice.WindowTranslucency} for more details.
*
* @param shape the shape to set to the window
*
@@ -3481,10 +3480,10 @@ public class Window extends Container implements Accessible {
* PERPIXEL_TRANSPARENT} translucency is not supported
*
* @see Window#getShape()
- * @see Window#setBackgound()
- * @see Window#setOpacity()
+ * @see Window#setBackground(Color)
+ * @see Window#setOpacity(float)
* @see GraphicsDevice.WindowTranslucency
- * @see GraphicsDevice#isWindowTranslucencySupported()
+ * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
*
* @since 1.7
*/
@@ -3520,7 +3519,7 @@ public class Window extends Container implements Accessible {
*
* @return this component's background color
*
- * @see Window#setBackground
+ * @see Window#setBackground(Color)
* @see Window#isOpaque
* @see GraphicsDevice.WindowTranslucency
*/
@@ -3544,7 +3543,7 @@ public class Window extends Container implements Accessible {
* PERPIXEL_TRANSLUCENT} translucency must be supported
* by the graphics device where this window is located and
*
The window must not be in the full-screen mode (see {@link
- * GraphicsDevice#setFullScreenWindow()})
+ * GraphicsDevice#setFullScreenWindow(Window)})
*
* If a certain condition is not met at the time of calling this method,
* the alpha component of the given background color will not effect the
@@ -3561,8 +3560,8 @@ public class Window extends Container implements Accessible {
* method is equal to zero.)
*
* The actual level of translucency of a given pixel also depends on window
- * opacity (see {@link setOpacity()}), as well as the current shape of
- * this window (see {@link setShape()}).
+ * opacity (see {@link #setOpacity(float)}), as well as the current shape of
+ * this window (see {@link #setShape(Shape)}).
*
* Note that painting a pixel with the alpha value of 0 may or may not
* disable the mouse event handling on this pixel. This is a
@@ -3585,10 +3584,10 @@ public class Window extends Container implements Accessible {
*
* @see Window#getBackground
* @see Window#isOpaque
- * @see Window#setOpacity()
- * @see Window#setShape()
+ * @see Window#setOpacity(float)
+ * @see Window#setShape(Shape)
* @see GraphicsDevice.WindowTranslucency
- * @see GraphicsDevice#isWindowTranslucencySupported()
+ * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
* @see GraphicsConfiguration#isTranslucencyCapable()
*/
@Override
@@ -3635,7 +3634,7 @@ public class Window extends Container implements Accessible {
* @return {@code true} if the window is opaque, {@code false} otherwise
*
* @see Window#getBackground
- * @see Window#setBackground
+ * @see Window#setBackground(Color)
* @since 1.7
*/
@Override
diff --git a/jdk/src/share/classes/java/awt/color/ICC_Profile.java b/jdk/src/share/classes/java/awt/color/ICC_Profile.java
index 44f28508788..78ba43d4bc4 100644
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java
@@ -58,6 +58,8 @@ import java.util.StringTokenizer;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import sun.misc.BootClassLoaderHook;
+
/**
* A representation of color profile data for device independent and
* device dependent color spaces based on the International Color
@@ -1850,11 +1852,10 @@ public class ICC_Profile implements Serializable {
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) {}
+ BootClassLoaderHook hook = BootClassLoaderHook.getHook();
+ if (hook.getHook() != null) {
+ hook.prefetchFile("lib/cmm/"+fileName);
+ }
}
}
diff --git a/jdk/src/share/classes/java/awt/dnd/DragSourceContext.java b/jdk/src/share/classes/java/awt/dnd/DragSourceContext.java
index 07768598fd5..9899fedc275 100644
--- a/jdk/src/share/classes/java/awt/dnd/DragSourceContext.java
+++ b/jdk/src/share/classes/java/awt/dnd/DragSourceContext.java
@@ -275,7 +275,7 @@ public class DragSourceContext
*
* @param c the initial {@code Cursor} for this drag operation,
* or {@code null} for the default cursor handling;
- * see {@linkplain #defaultCursor class
+ * see {@linkplain Cursor class
* level documentation} for more details
* on the cursor handling during drag and drop
*
diff --git a/jdk/src/share/classes/java/awt/event/InputEvent.java b/jdk/src/share/classes/java/awt/event/InputEvent.java
index 06492d1d0f0..d465a0f979a 100644
--- a/jdk/src/share/classes/java/awt/event/InputEvent.java
+++ b/jdk/src/share/classes/java/awt/event/InputEvent.java
@@ -29,8 +29,7 @@ import java.awt.Event;
import java.awt.Component;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
-import java.util.logging.Logger;
-import java.util.logging.Level;
+import sun.util.logging.PlatformLogger;
import java.util.Arrays;
/**
@@ -55,7 +54,7 @@ import java.util.Arrays;
* @since 1.1
*/
public abstract class InputEvent extends ComponentEvent {
- private static final Logger log = Logger.getLogger("java.awt.event.InputEvent");
+ private static final PlatformLogger logger = PlatformLogger.getLogger("java.awt.event.InputEvent");
/**
* The Shift key modifier constant.
@@ -344,8 +343,8 @@ public abstract class InputEvent extends ComponentEvent {
sm.checkSystemClipboardAccess();
b = true;
} catch (SecurityException se) {
- if (log.isLoggable(Level.FINE)) {
- log.log(Level.FINE, "InputEvent.canAccessSystemClipboard() got SecurityException ", se);
+ if (logger.isLoggable(PlatformLogger.FINE)) {
+ logger.fine("InputEvent.canAccessSystemClipboard() got SecurityException ", se);
}
}
} else {
diff --git a/jdk/src/share/classes/java/lang/Boolean.java b/jdk/src/share/classes/java/lang/Boolean.java
index b614dafdaae..8a3d6ab996e 100644
--- a/jdk/src/share/classes/java/lang/Boolean.java
+++ b/jdk/src/share/classes/java/lang/Boolean.java
@@ -255,7 +255,25 @@ public final class Boolean implements java.io.Serializable,
* @since 1.5
*/
public int compareTo(Boolean b) {
- return (b.value == value ? 0 : (value ? 1 : -1));
+ return compare(this.value, b.value);
+ }
+
+ /**
+ * Compares two {@code boolean} values.
+ * The value returned is identical to what would be returned by:
+ *
+ *
+ * @param x the first {@code boolean} to compare
+ * @param y the second {@code boolean} to compare
+ * @return the value {@code 0} if {@code x == y};
+ * a value less than {@code 0} if {@code !x && y}; and
+ * a value greater than {@code 0} if {@code x && !y}
+ * @since 1.7
+ */
+ public static int compare(boolean x, boolean y) {
+ return (x == y) ? 0 : (x ? 1 : -1);
}
private static boolean toBoolean(String name) {
diff --git a/jdk/src/share/classes/java/lang/Byte.java b/jdk/src/share/classes/java/lang/Byte.java
index 459c2237a18..ce5adee7f53 100644
--- a/jdk/src/share/classes/java/lang/Byte.java
+++ b/jdk/src/share/classes/java/lang/Byte.java
@@ -201,7 +201,7 @@ public final class Byte extends Number implements Comparable {
*/
public static Byte valueOf(String s, int radix)
throws NumberFormatException {
- return new Byte(parseByte(s, radix));
+ return valueOf(parseByte(s, radix));
}
/**
@@ -277,7 +277,7 @@ public final class Byte extends Number implements Comparable {
if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException(
"Value " + i + " out of range from input " + nm);
- return (byte)i;
+ return valueOf((byte)i);
}
/**
@@ -374,11 +374,14 @@ public final class Byte extends Number implements Comparable {
* base 10.
*/
public String toString() {
- return String.valueOf((int)value);
+ return Integer.toString((int)value);
}
/**
- * Returns a hash code for this {@code Byte}.
+ * Returns a hash code for this {@code Byte}; equal to the result
+ * of invoking {@code intValue()}.
+ *
+ * @return a hash code value for this {@code Byte}
*/
public int hashCode() {
return (int)value;
@@ -415,7 +418,25 @@ public final class Byte extends Number implements Comparable {
* @since 1.2
*/
public int compareTo(Byte anotherByte) {
- return this.value - anotherByte.value;
+ return compare(this.value, anotherByte.value);
+ }
+
+ /**
+ * Compares two {@code byte} values numerically.
+ * The value returned is identical to what would be returned by:
+ *
+ *
+ * @param x the first {@code byte} to compare
+ * @param y the second {@code byte} to compare
+ * @return the value {@code 0} if {@code x == y};
+ * a value less than {@code 0} if {@code x < y}; and
+ * a value greater than {@code 0} if {@code x > y}
+ * @since 1.7
+ */
+ public static int compare(byte x, byte y) {
+ return x - y;
}
/**
diff --git a/jdk/src/share/classes/java/lang/Character.java b/jdk/src/share/classes/java/lang/Character.java
index 56e763ee6a6..8f106a473dd 100644
--- a/jdk/src/share/classes/java/lang/Character.java
+++ b/jdk/src/share/classes/java/lang/Character.java
@@ -162,7 +162,7 @@ class Character extends Object implements java.io.Serializable, ComparableClass instance representing the primitive type
@@ -518,75 +518,91 @@ class Character extends Object implements java.io.Serializable, Comparableleading-surrogate.
+ * The minimum value of a
+ *
+ * Unicode high-surrogate code unit
+ * in the UTF-16 encoding, constant '\uD800'.
+ * A high-surrogate is also known as a leading-surrogate.
*
* @since 1.5
*/
public static final char MIN_HIGH_SURROGATE = '\uD800';
/**
- * The maximum value of a Unicode high-surrogate code unit in the
- * UTF-16 encoding. A high-surrogate is also known as a
- * leading-surrogate.
+ * The maximum value of a
+ *
+ * Unicode high-surrogate code unit
+ * in the UTF-16 encoding, constant '\uDBFF'.
+ * A high-surrogate is also known as a leading-surrogate.
*
* @since 1.5
*/
public static final char MAX_HIGH_SURROGATE = '\uDBFF';
/**
- * The minimum value of a Unicode low-surrogate code unit in the
- * UTF-16 encoding. A low-surrogate is also known as a
- * trailing-surrogate.
+ * The minimum value of a
+ *
+ * Unicode low-surrogate code unit
+ * in the UTF-16 encoding, constant '\uDC00'.
+ * A low-surrogate is also known as a trailing-surrogate.
*
* @since 1.5
*/
public static final char MIN_LOW_SURROGATE = '\uDC00';
/**
- * The maximum value of a Unicode low-surrogate code unit in the
- * UTF-16 encoding. A low-surrogate is also known as a
- * trailing-surrogate.
+ * The maximum value of a
+ *
+ * Unicode low-surrogate code unit
+ * in the UTF-16 encoding, constant '\uDFFF'.
+ * A low-surrogate is also known as a trailing-surrogate.
*
* @since 1.5
*/
public static final char MAX_LOW_SURROGATE = '\uDFFF';
/**
- * The minimum value of a Unicode surrogate code unit in the UTF-16 encoding.
+ * The minimum value of a Unicode surrogate code unit in the
+ * UTF-16 encoding, constant '\uD800'.
*
* @since 1.5
*/
public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE;
/**
- * The maximum value of a Unicode surrogate code unit in the UTF-16 encoding.
+ * The maximum value of a Unicode surrogate code unit in the
+ * UTF-16 encoding, constant '\uDFFF'.
*
* @since 1.5
*/
public static final char MAX_SURROGATE = MAX_LOW_SURROGATE;
/**
- * The minimum value of a supplementary code point.
+ * The minimum value of a
+ *
+ * Unicode supplementary code point, constant {@code U+10000}.
*
* @since 1.5
*/
public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000;
/**
- * The minimum value of a Unicode code point.
+ * The minimum value of a
+ *
+ * Unicode code point, constant {@code U+0000}.
*
* @since 1.5
*/
public static final int MIN_CODE_POINT = 0x000000;
/**
- * The maximum value of a Unicode code point.
+ * The maximum value of a
+ *
+ * Unicode code point, constant {@code U+10FFFF}.
*
* @since 1.5
*/
- public static final int MAX_CODE_POINT = 0x10ffff;
+ public static final int MAX_CODE_POINT = 0X10FFFF;
/**
@@ -2571,9 +2587,9 @@ class Character extends Object implements java.io.Serializable, ComparableCharacter instance representing c.
@@ -2596,8 +2612,10 @@ class Character extends Object implements java.io.Serializable, ComparableCharacter.
- * @return a hash code value for this object.
+ * Returns a hash code for this {@code Character}; equal to the result
+ * of invoking {@code charValue()}.
+ *
+ * @return a hash code value for this {@code Character}
*/
public int hashCode() {
return (int)value;
@@ -2648,19 +2666,15 @@ class Character extends Object implements java.io.Serializable, Comparable0x0000 to
- * 0x10FFFF inclusive. This method is equivalent to
- * the expression:
- *
- *
+ * Determines whether the specified code point is a valid
+ *
+ * Unicode code point value.
*
* @param codePoint the Unicode code point to be tested
- * @return true if the specified code point value
- * is a valid code point value;
- * false otherwise.
+ * @return {@code true} if the specified code point value is between
+ * {@link #MIN_CODE_POINT} and
+ * {@link #MAX_CODE_POINT} inclusive;
+ * {@code false} otherwise.
* @since 1.5
*/
public static boolean isValidCodePoint(int codePoint) {
@@ -2669,15 +2683,13 @@ class Character extends Object implements java.io.Serializable, Comparable
+ * is in the supplementary character range.
*
* @param codePoint the character (Unicode code point) to be tested
- * @return true if the specified character is in the Unicode
- * supplementary character range; false otherwise.
+ * @return {@code true} if the specified code point is between
+ * {@link #MIN_SUPPLEMENTARY_CODE_POINT} and
+ * {@link #MAX_CODE_POINT} inclusive;
+ * {@code false} otherwise.
* @since 1.5
*/
public static boolean isSupplementaryCodePoint(int codePoint) {
@@ -2686,56 +2698,83 @@ class Character extends Object implements java.io.Serializable, Comparablechar value is a
- * high-surrogate code unit (also known as leading-surrogate
- * code unit). Such values do not represent characters by
- * themselves, but are used in the representation of supplementary characters in the
- * UTF-16 encoding.
+ * Determines if the given {@code char} value is a
+ *
+ * Unicode high-surrogate code unit
+ * (also known as leading-surrogate code unit).
*
- *
This method returns true if and only if
- *
ch >= '\uD800' && ch <= '\uDBFF'
- *
- * is true.
+ *
Such values do not represent characters by themselves,
+ * but are used in the representation of
+ * supplementary characters
+ * in the UTF-16 encoding.
*
- * @param ch the char value to be tested.
- * @return true if the char value
- * is between '\uD800' and '\uDBFF' inclusive;
- * false otherwise.
- * @see java.lang.Character#isLowSurrogate(char)
- * @see Character.UnicodeBlock#of(int)
- * @since 1.5
+ * @param ch the {@code char} value to be tested.
+ * @return {@code true} if the {@code char} value is between
+ * {@link #MIN_HIGH_SURROGATE} and
+ * {@link #MAX_HIGH_SURROGATE} inclusive;
+ * {@code false} otherwise.
+ * @see #isLowSurrogate(char)
+ * @see Character.UnicodeBlock#of(int)
+ * @since 1.5
*/
public static boolean isHighSurrogate(char ch) {
return ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE;
}
/**
- * Determines if the given char value is a
- * low-surrogate code unit (also known as trailing-surrogate code
- * unit). Such values do not represent characters by themselves,
- * but are used in the representation of supplementary characters in the UTF-16 encoding.
+ * Determines if the given {@code char} value is a
+ *
+ * Unicode low-surrogate code unit
+ * (also known as trailing-surrogate code unit).
*
- *
This method returns true if and only if
- *
ch >= '\uDC00' && ch <= '\uDFFF'
- *
is true.
+ *
Such values do not represent characters by themselves,
+ * but are used in the representation of
+ * supplementary characters
+ * in the UTF-16 encoding.
*
- * @param ch the char value to be tested.
- * @return true if the char value
- * is between '\uDC00' and '\uDFFF' inclusive;
- * false otherwise.
- * @see java.lang.Character#isHighSurrogate(char)
- * @since 1.5
+ * @param ch the {@code char} value to be tested.
+ * @return {@code true} if the {@code char} value is between
+ * {@link #MIN_LOW_SURROGATE} and
+ * {@link #MAX_LOW_SURROGATE} inclusive;
+ * {@code false} otherwise.
+ * @see #isHighSurrogate(char)
+ * @since 1.5
*/
public static boolean isLowSurrogate(char ch) {
return ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE;
}
+ /**
+ * Determines if the given {@code char} value is a Unicode
+ * surrogate code unit.
+ *
+ *
Such values do not represent characters by themselves,
+ * but are used in the representation of
+ * supplementary characters
+ * in the UTF-16 encoding.
+ *
+ *
A char value is a surrogate code unit if and only if it is either
+ * a {@linkplain #isLowSurrogate(char) low-surrogate code unit} or
+ * a {@linkplain #isHighSurrogate(char) high-surrogate code unit}.
+ *
+ * @param ch the {@code char} value to be tested.
+ * @return {@code true} if the {@code char} value is between
+ * {@link #MIN_SURROGATE} and
+ * {@link #MAX_SURROGATE} inclusive;
+ * {@code false} otherwise.
+ * @since 1.7
+ */
+ public static boolean isSurrogate(char ch) {
+ return ch >= MIN_SURROGATE && ch <= MAX_SURROGATE;
+ }
+
/**
* Determines whether the specified pair of char
- * values is a valid surrogate pair. This method is equivalent to
- * the expression:
+ * values is a valid
+ *
+ * Unicode surrogate pair.
+
+ *
This method is equivalent to the expression:
*
* isHighSurrogate(high) && isLowSurrogate(low)
*
@@ -4925,7 +4964,25 @@ class Character extends Object implements java.io.Serializable, Comparable
+ * Character.valueOf(x).compareTo(Character.valueOf(y))
+ *
+ *
+ * @param x the first {@code char} to compare
+ * @param y the second {@code char} to compare
+ * @return the value {@code 0} if {@code x == y};
+ * a value less than {@code 0} if {@code x < y}; and
+ * a value greater than {@code 0} if {@code x > y}
+ * @since 1.7
+ */
+ public static int compare(char x, char y) {
+ return x - y;
}
/**
@@ -4968,7 +5025,7 @@ class Character extends Object implements java.io.Serializable, Comparablechar value in unsigned
- * binary form.
+ * binary form, constant {@code 16}.
*
* @since 1.5
*/
diff --git a/jdk/src/share/classes/java/lang/Class.java b/jdk/src/share/classes/java/lang/Class.java
index ddf57631790..111c78ce188 100644
--- a/jdk/src/share/classes/java/lang/Class.java
+++ b/jdk/src/share/classes/java/lang/Class.java
@@ -265,7 +265,7 @@ public final
}
/** Called after security checks have been made. */
- private static native Class forName0(String name, boolean initialize,
+ private static native Class> forName0(String name, boolean initialize,
ClassLoader loader)
throws ClassNotFoundException;
@@ -339,7 +339,7 @@ public final
);
}
try {
- Class[] empty = {};
+ Class>[] empty = {};
final Constructor c = getConstructor0(empty, Member.DECLARED);
// Disable accessibility checks on the constructor
// since we have to do the security check here anyway
@@ -361,7 +361,7 @@ public final
// Security check (same as in java.lang.reflect.Constructor)
int modifiers = tmpConstructor.getModifiers();
if (!Reflection.quickCheckMemberAccess(this, modifiers)) {
- Class caller = Reflection.getCallerClass(3);
+ Class> caller = Reflection.getCallerClass(3);
if (newInstanceCallerCache != caller) {
Reflection.ensureMemberAccess(caller, this, null, modifiers);
newInstanceCallerCache = caller;
@@ -377,7 +377,7 @@ public final
}
}
private volatile transient Constructor cachedConstructor;
- private volatile transient Class newInstanceCallerCache;
+ private volatile transient Class> newInstanceCallerCache;
/**
@@ -565,8 +565,9 @@ public final
* represented by this object.
*/
public String getName() {
+ String name = this.name;
if (name == null)
- name = getName0();
+ this.name = name = getName0();
return name;
}
@@ -637,7 +638,7 @@ public final
if (getGenericSignature() != null)
return (TypeVariable>[])getGenericInfo().getTypeParameters();
else
- return (TypeVariable>[])new TypeVariable[0];
+ return (TypeVariable>[])new TypeVariable>[0];
}
@@ -900,7 +901,7 @@ public final
MethodRepository typeInfo = MethodRepository.make(enclosingInfo.getDescriptor(),
getFactory());
- Class returnType = toClass(typeInfo.getReturnType());
+ Class> returnType = toClass(typeInfo.getReturnType());
Type [] parameterTypes = typeInfo.getParameterTypes();
Class>[] parameterClasses = new Class>[parameterTypes.length];
@@ -995,12 +996,12 @@ public final
}
- private static Class toClass(Type o) {
+ private static Class> toClass(Type o) {
if (o instanceof GenericArrayType)
return Array.newInstance(toClass(((GenericArrayType)o).getGenericComponentType()),
0)
.getClass();
- return (Class)o;
+ return (Class>)o;
}
/**
@@ -1041,7 +1042,7 @@ public final
* Loop over all declared constructors; match number
* of and type of parameters.
*/
- for(Constructor c: enclosingInfo.getEnclosingClass().getDeclaredConstructors()) {
+ for(Constructor> c: enclosingInfo.getEnclosingClass().getDeclaredConstructors()) {
Class>[] candidateParamClasses = c.getParameterTypes();
if (candidateParamClasses.length == parameterClasses.length) {
boolean matches = true;
@@ -1303,12 +1304,12 @@ public final
// has already been ok'd by the SecurityManager.
return java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ new java.security.PrivilegedAction[]>() {
public Class[] run() {
- List list = new ArrayList();
- Class currentClass = Class.this;
+ List> list = new ArrayList>();
+ Class> currentClass = Class.this;
while (currentClass != null) {
- Class[] members = currentClass.getDeclaredClasses();
+ Class>[] members = currentClass.getDeclaredClasses();
for (int i = 0; i < members.length; i++) {
if (Modifier.isPublic(members[i].getModifiers())) {
list.add(members[i]);
@@ -2190,7 +2191,7 @@ public final
return name;
}
if (!name.startsWith("/")) {
- Class c = this;
+ Class> c = this;
while (c.isArray()) {
c = c.getComponentType();
}
@@ -2564,12 +2565,12 @@ public final
// out concrete implementations inherited from superclasses at
// the end.
MethodArray inheritedMethods = new MethodArray();
- Class[] interfaces = getInterfaces();
+ Class>[] interfaces = getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
inheritedMethods.addAll(interfaces[i].privateGetPublicMethods());
}
if (!isInterface()) {
- Class c = getSuperclass();
+ Class> c = getSuperclass();
if (c != null) {
MethodArray supers = new MethodArray();
supers.addAll(c.privateGetPublicMethods());
@@ -2631,16 +2632,16 @@ public final
return res;
}
// Direct superinterfaces, recursively
- Class[] interfaces = getInterfaces();
+ Class>[] interfaces = getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
- Class c = interfaces[i];
+ Class> c = interfaces[i];
if ((res = c.getField0(name)) != null) {
return res;
}
}
// Direct superclass, recursively
if (!isInterface()) {
- Class c = getSuperclass();
+ Class> c = getSuperclass();
if (c != null) {
if ((res = c.getField0(name)) != null) {
return res;
@@ -2652,7 +2653,7 @@ public final
private static Method searchMethods(Method[] methods,
String name,
- Class[] parameterTypes)
+ Class>[] parameterTypes)
{
Method res = null;
String internedName = name.intern();
@@ -2669,7 +2670,7 @@ public final
}
- private Method getMethod0(String name, Class[] parameterTypes) {
+ private Method getMethod0(String name, Class>[] parameterTypes) {
// Note: the intent is that the search algorithm this routine
// uses be equivalent to the ordering imposed by
// privateGetPublicMethods(). It fetches only the declared
@@ -2686,7 +2687,7 @@ public final
}
// Search superclass's methods
if (!isInterface()) {
- Class c = getSuperclass();
+ Class super T> c = getSuperclass();
if (c != null) {
if ((res = c.getMethod0(name, parameterTypes)) != null) {
return res;
@@ -2694,9 +2695,9 @@ public final
}
}
// Search superinterfaces' methods
- Class[] interfaces = getInterfaces();
+ Class>[] interfaces = getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
- Class c = interfaces[i];
+ Class> c = interfaces[i];
if ((res = c.getMethod0(name, parameterTypes)) != null) {
return res;
}
@@ -2705,7 +2706,7 @@ public final
return null;
}
- private Constructor getConstructor0(Class[] parameterTypes,
+ private Constructor getConstructor0(Class>[] parameterTypes,
int which) throws NoSuchMethodException
{
Constructor[] constructors = privateGetDeclaredConstructors((which == Member.PUBLIC));
@@ -2774,9 +2775,9 @@ public final
private native Field[] getDeclaredFields0(boolean publicOnly);
private native Method[] getDeclaredMethods0(boolean publicOnly);
private native Constructor[] getDeclaredConstructors0(boolean publicOnly);
- private native Class[] getDeclaredClasses0();
+ private native Class>[] getDeclaredClasses0();
- private static String argumentTypesToString(Class[] argTypes) {
+ private static String argumentTypesToString(Class>[] argTypes) {
StringBuilder buf = new StringBuilder();
buf.append("(");
if (argTypes != null) {
@@ -2784,7 +2785,7 @@ public final
if (i > 0) {
buf.append(", ");
}
- Class c = argTypes[i];
+ Class> c = argTypes[i];
buf.append((c == null) ? "null" : c.getName());
}
}
@@ -2857,7 +2858,7 @@ public final
}
// Retrieves the desired assertion status of this class from the VM
- private static native boolean desiredAssertionStatus0(Class clazz);
+ private static native boolean desiredAssertionStatus0(Class> clazz);
/**
* Returns true if and only if this class was declared as an enum in the
@@ -2978,7 +2979,7 @@ public final
getName() + " is not an enum type");
Map m = new HashMap(2 * universe.length);
for (T constant : universe)
- m.put(((Enum)constant).name(), constant);
+ m.put(((Enum>)constant).name(), constant);
enumConstantDirectory = m;
}
return enumConstantDirectory;
@@ -3076,8 +3077,8 @@ public final
}
// Annotations cache
- private transient Map annotations;
- private transient Map declaredAnnotations;
+ private transient Map, Annotation> annotations;
+ private transient Map, Annotation> declaredAnnotations;
private synchronized void initAnnotationsIfNecessary() {
clearCachesOnClassRedefinition();
@@ -3089,10 +3090,10 @@ public final
if (superClass == null) {
annotations = declaredAnnotations;
} else {
- annotations = new HashMap();
+ annotations = new HashMap, Annotation>();
superClass.initAnnotationsIfNecessary();
- for (Map.Entry e : superClass.annotations.entrySet()) {
- Class annotationClass = e.getKey();
+ for (Map.Entry, Annotation> e : superClass.annotations.entrySet()) {
+ Class extends Annotation> annotationClass = e.getKey();
if (AnnotationType.getInstance(annotationClass).isInherited())
annotations.put(annotationClass, e.getValue());
}
diff --git a/jdk/src/share/classes/java/lang/ClassLoader.java b/jdk/src/share/classes/java/lang/ClassLoader.java
index d25100958a0..bd59d95667a 100644
--- a/jdk/src/share/classes/java/lang/ClassLoader.java
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java
@@ -51,6 +51,7 @@ import java.util.Vector;
import java.util.Hashtable;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
+import sun.misc.BootClassLoaderHook;
import sun.misc.ClassFileTransformer;
import sun.misc.CompoundEnumeration;
import sun.misc.Resource;
@@ -58,7 +59,6 @@ import sun.misc.URLClassPath;
import sun.misc.VM;
import sun.reflect.Reflection;
import sun.security.util.SecurityConstants;
-import sun.jkernel.DownloadManager;
/**
* A class loader is an object that is responsible for loading classes. The
@@ -380,16 +380,28 @@ public abstract class ClassLoader {
// First, check if the class has already been loaded
Class c = findLoadedClass(name);
if (c == null) {
+ long t0 = System.nanoTime();
try {
if (parent != null) {
c = parent.loadClass(name, false);
} else {
- c = findBootstrapClass0(name);
+ c = findBootstrapClassOrNull(name);
}
} catch (ClassNotFoundException e) {
+ // ClassNotFoundException thrown if class not found
+ // from the non-null parent class loader
+ }
+
+ if (c == null) {
// If still not found, then invoke findClass in order
// to find the class.
+ long t1 = System.nanoTime();
c = findClass(name);
+
+ // this is the defining class loader; record the stats
+ sun.misc.PerfCounter.getParentDelegationTime().addTime(t1 - t0);
+ sun.misc.PerfCounter.getFindClassTime().addElapsedTimeFrom(t1);
+ sun.misc.PerfCounter.getFindClasses().increment();
}
}
if (resolve) {
@@ -1008,22 +1020,29 @@ public abstract class ClassLoader {
if (system == null) {
if (!checkName(name))
throw new ClassNotFoundException(name);
- return findBootstrapClass(name);
+ Class cls = findBootstrapClass(name);
+ if (cls == null) {
+ throw new ClassNotFoundException(name);
+ }
+ return cls;
}
return system.loadClass(name);
}
- private Class findBootstrapClass0(String name)
- throws ClassNotFoundException
+ /**
+ * Returns a class loaded by the bootstrap class loader;
+ * or return null if not found.
+ */
+ private Class findBootstrapClassOrNull(String name)
{
check();
- if (!checkName(name))
- throw new ClassNotFoundException(name);
+ if (!checkName(name)) return null;
+
return findBootstrapClass(name);
}
- private native Class findBootstrapClass(String name)
- throws ClassNotFoundException;
+ // return null if not found
+ private native Class findBootstrapClass(String name);
// Check to make sure the class loader has been initialized.
private void check() {
@@ -1281,21 +1300,7 @@ public abstract class ClassLoader {
* Find resources from the VM's built-in classloader.
*/
private static URL getBootstrapResource(String name) {
- try {
- // If this is a known JRE resource, ensure that its bundle is
- // downloaded. If it isn't known, we just ignore the download
- // failure and check to see if we can find the resource anyway
- // (which is possible if the boot class path has been modified).
- if (sun.misc.VM.isBootedKernelVM()) {
- sun.jkernel.DownloadManager.getBootClassPathEntryForResource(
- name);
- }
- } catch (NoClassDefFoundError e) {
- // This happens while Java itself is being compiled; DownloadManager
- // isn't accessible when this code is first invoked. It isn't an
- // issue, as if we can't find DownloadManager, we can safely assume
- // that additional code is not available for download.
- }
+ BootClassLoaderHook.preLoadResource(name);
URLClassPath ucp = getBootstrapClassPath();
Resource res = ucp.getResource(name);
return res != null ? res.getURL() : null;
@@ -1812,24 +1817,7 @@ public abstract class ClassLoader {
// Invoked in the java.lang.Runtime class to implement load and loadLibrary.
static void loadLibrary(Class fromClass, String name,
boolean isAbsolute) {
- try {
- if (VM.isBootedKernelVM() && !DownloadManager.isJREComplete() &&
- !DownloadManager.isCurrentThreadDownloading()) {
- DownloadManager.downloadFile("bin/" +
- System.mapLibraryName(name));
- // it doesn't matter if the downloadFile call returns false --
- // it probably just means that this is a user library, as
- // opposed to a JRE library
- }
- } catch (IOException e) {
- throw new UnsatisfiedLinkError("Error downloading library " +
- name + ": " + e);
- } catch (NoClassDefFoundError e) {
- // This happens while Java itself is being compiled; DownloadManager
- // isn't accessible when this code is first invoked. It isn't an
- // issue, as if we can't find DownloadManager, we can safely assume
- // that additional code is not available for download.
- }
+ BootClassLoaderHook.preLoadLibrary(name);
ClassLoader loader =
(fromClass == null) ? null : fromClass.getClassLoader();
if (sys_paths == null) {
diff --git a/jdk/src/share/classes/java/lang/Double.java b/jdk/src/share/classes/java/lang/Double.java
index 8efb241b808..ebc6fd3cada 100644
--- a/jdk/src/share/classes/java/lang/Double.java
+++ b/jdk/src/share/classes/java/lang/Double.java
@@ -629,7 +629,7 @@ public final class Double extends Number implements Comparable {
* @see java.lang.Double#toString(double)
*/
public String toString() {
- return String.valueOf(value);
+ return toString(value);
}
/**
diff --git a/jdk/src/share/classes/java/lang/Float.java b/jdk/src/share/classes/java/lang/Float.java
index eb133016f6b..c86b7bb1f9c 100644
--- a/jdk/src/share/classes/java/lang/Float.java
+++ b/jdk/src/share/classes/java/lang/Float.java
@@ -551,7 +551,7 @@ public final class Float extends Number implements Comparable {
* @see java.lang.Float#toString(float)
*/
public String toString() {
- return String.valueOf(value);
+ return Float.toString(value);
}
/**
diff --git a/jdk/src/share/classes/java/lang/Integer.java b/jdk/src/share/classes/java/lang/Integer.java
index a66a8fae792..7aa03c07b5b 100644
--- a/jdk/src/share/classes/java/lang/Integer.java
+++ b/jdk/src/share/classes/java/lang/Integer.java
@@ -746,7 +746,7 @@ public final class Integer extends Number implements Comparable {
* base 10.
*/
public String toString() {
- return String.valueOf(value);
+ return toString(value);
}
/**
@@ -1010,9 +1010,25 @@ public final class Integer extends Number implements Comparable {
* @since 1.2
*/
public int compareTo(Integer anotherInteger) {
- int thisVal = this.value;
- int anotherVal = anotherInteger.value;
- return (thisVal
+ * Integer.valueOf(x).compareTo(Integer.valueOf(y))
+ *
+ *
+ * @param x the first {@code int} to compare
+ * @param y the second {@code int} to compare
+ * @return the value {@code 0} if {@code x == y};
+ * a value less than {@code 0} if {@code x < y}; and
+ * a value greater than {@code 0} if {@code x > y}
+ * @since 1.7
+ */
+ public static int compare(int x, int y) {
+ return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
diff --git a/jdk/src/share/classes/java/lang/Long.java b/jdk/src/share/classes/java/lang/Long.java
index 58014997f35..2bb6da15923 100644
--- a/jdk/src/share/classes/java/lang/Long.java
+++ b/jdk/src/share/classes/java/lang/Long.java
@@ -761,7 +761,7 @@ public final class Long extends Number implements Comparable {
* base 10.
*/
public String toString() {
- return String.valueOf(value);
+ return toString(value);
}
/**
@@ -950,9 +950,25 @@ public final class Long extends Number implements Comparable {
* @since 1.2
*/
public int compareTo(Long anotherLong) {
- long thisVal = this.value;
- long anotherVal = anotherLong.value;
- return (thisVal
+ * Long.valueOf(x).compareTo(Long.valueOf(y))
+ *
+ *
+ * @param x the first {@code long} to compare
+ * @param y the second {@code long} to compare
+ * @return the value {@code 0} if {@code x == y};
+ * a value less than {@code 0} if {@code x < y}; and
+ * a value greater than {@code 0} if {@code x > y}
+ * @since 1.7
+ */
+ public static int compare(long x, long y) {
+ return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
diff --git a/jdk/src/share/classes/java/lang/Package.java b/jdk/src/share/classes/java/lang/Package.java
index 63cad6b1e4a..80d40ae871e 100644
--- a/jdk/src/share/classes/java/lang/Package.java
+++ b/jdk/src/share/classes/java/lang/Package.java
@@ -320,7 +320,7 @@ public class Package implements java.lang.reflect.AnnotatedElement {
* @param class the class to get the package of.
* @return the package of the class. It may be null if no package
* information is available from the archive or codebase. */
- static Package getPackage(Class c) {
+ static Package getPackage(Class> c) {
String name = c.getName();
int i = name.lastIndexOf('.');
if (i != -1) {
diff --git a/jdk/src/share/classes/java/lang/SecurityManager.java b/jdk/src/share/classes/java/lang/SecurityManager.java
index ea0dd5ea998..9006588fa08 100644
--- a/jdk/src/share/classes/java/lang/SecurityManager.java
+++ b/jdk/src/share/classes/java/lang/SecurityManager.java
@@ -1341,7 +1341,7 @@ class SecurityManager {
throw new NullPointerException("window can't be null");
}
try {
- checkPermission(SecurityConstants.TOPLEVEL_WINDOW_PERMISSION);
+ checkPermission(SecurityConstants.AWT.TOPLEVEL_WINDOW_PERMISSION);
return true;
} catch (SecurityException se) {
// just return false
@@ -1391,7 +1391,7 @@ class SecurityManager {
* @see #checkPermission(java.security.Permission) checkPermission
*/
public void checkSystemClipboardAccess() {
- checkPermission(SecurityConstants.ACCESS_CLIPBOARD_PERMISSION);
+ checkPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION);
}
/**
@@ -1412,7 +1412,7 @@ class SecurityManager {
* @see #checkPermission(java.security.Permission) checkPermission
*/
public void checkAwtEventQueueAccess() {
- checkPermission(SecurityConstants.CHECK_AWT_EVENTQUEUE_PERMISSION);
+ checkPermission(SecurityConstants.AWT.CHECK_AWT_EVENTQUEUE_PERMISSION);
}
/*
diff --git a/jdk/src/share/classes/java/lang/Short.java b/jdk/src/share/classes/java/lang/Short.java
index a2d98b277ee..b00e8b25cec 100644
--- a/jdk/src/share/classes/java/lang/Short.java
+++ b/jdk/src/share/classes/java/lang/Short.java
@@ -170,7 +170,7 @@ public final class Short extends Number implements Comparable {
*/
public static Short valueOf(String s, int radix)
throws NumberFormatException {
- return new Short(parseShort(s, radix));
+ return valueOf(parseShort(s, radix));
}
/**
@@ -282,7 +282,7 @@ public final class Short extends Number implements Comparable {
if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException(
"Value " + i + " out of range from input " + nm);
- return (short)i;
+ return valueOf((short)i);
}
/**
@@ -379,11 +379,14 @@ public final class Short extends Number implements Comparable {
* base 10.
*/
public String toString() {
- return String.valueOf((int)value);
+ return Integer.toString((int)value);
}
/**
- * Returns a hash code for this {@code Short}.
+ * Returns a hash code for this {@code Short}; equal to the result
+ * of invoking {@code intValue()}.
+ *
+ * @return a hash code value for this {@code Short}
*/
public int hashCode() {
return (int)value;
@@ -420,7 +423,25 @@ public final class Short extends Number implements Comparable {
* @since 1.2
*/
public int compareTo(Short anotherShort) {
- return this.value - anotherShort.value;
+ return compare(this.value, anotherShort.value);
+ }
+
+ /**
+ * Compares two {@code short} values numerically.
+ * The value returned is identical to what would be returned by:
+ *
+ *
+ * @param x the first {@code short} to compare
+ * @param y the second {@code short} to compare
+ * @return the value {@code 0} if {@code x == y};
+ * a value less than {@code 0} if {@code x < y}; and
+ * a value greater than {@code 0} if {@code x > y}
+ * @since 1.7
+ */
+ public static int compare(short x, short y) {
+ return x - y;
}
/**
diff --git a/jdk/src/share/classes/java/lang/String.java b/jdk/src/share/classes/java/lang/String.java
index e4327434c38..6aaf7684bf3 100644
--- a/jdk/src/share/classes/java/lang/String.java
+++ b/jdk/src/share/classes/java/lang/String.java
@@ -2995,7 +2995,7 @@ public final class String
* @see java.lang.Integer#toString(int, int)
*/
public static String valueOf(int i) {
- return Integer.toString(i, 10);
+ return Integer.toString(i);
}
/**
@@ -3009,7 +3009,7 @@ public final class String
* @see java.lang.Long#toString(long)
*/
public static String valueOf(long l) {
- return Long.toString(l, 10);
+ return Long.toString(l);
}
/**
diff --git a/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java b/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java
index 7934ebe9484..1f94a4c5a15 100644
--- a/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java
+++ b/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java
@@ -131,7 +131,7 @@ public class AccessibleObject implements AnnotatedElement {
throws SecurityException
{
if (obj instanceof Constructor && flag == true) {
- Constructor c = (Constructor)obj;
+ Constructor> c = (Constructor>)obj;
if (c.getDeclaringClass() == Class.class) {
throw new SecurityException("Can not make a java.lang.Class" +
" constructor accessible");
diff --git a/jdk/src/share/classes/java/lang/reflect/Constructor.java b/jdk/src/share/classes/java/lang/reflect/Constructor.java
index 0c101ccacb8..3ec31e3e605 100644
--- a/jdk/src/share/classes/java/lang/reflect/Constructor.java
+++ b/jdk/src/share/classes/java/lang/reflect/Constructor.java
@@ -64,8 +64,8 @@ public final
private Class clazz;
private int slot;
- private Class[] parameterTypes;
- private Class[] exceptionTypes;
+ private Class>[] parameterTypes;
+ private Class>[] exceptionTypes;
private int modifiers;
// Generics and annotations support
private transient String signature;
@@ -80,11 +80,7 @@ public final
// always succeed (it is not affected by the granting or revoking
// of permissions); we speed up the check in the common case by
// remembering the last Class for which the check succeeded.
- private volatile Class securityCheckCache;
-
- // Modifiers that can be applied to a constructor in source code
- private static final int LANGUAGE_MODIFIERS =
- Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
+ private volatile Class> securityCheckCache;
// Generics infrastructure
// Accessor for factory
@@ -117,8 +113,8 @@ public final
* package via sun.reflect.LangReflectAccess.
*/
Constructor(Class declaringClass,
- Class[] parameterTypes,
- Class[] checkedExceptions,
+ Class>[] parameterTypes,
+ Class>[] checkedExceptions,
int modifiers,
int slot,
String signature,
@@ -279,10 +275,6 @@ public final
* Returns an array of length 0 if the underlying method declares
* no exceptions in its {@code throws} clause.
*
- *
If an exception type is a parameterized type, the {@code Type}
- * object returned for it must accurately reflect the actual type
- * parameters used in the source code.
- *
*
If an exception type is a type variable or a parameterized
* type, it is created. Otherwise, it is resolved.
*
@@ -315,11 +307,11 @@ public final
*/
public boolean equals(Object obj) {
if (obj != null && obj instanceof Constructor) {
- Constructor other = (Constructor)obj;
+ Constructor> other = (Constructor>)obj;
if (getDeclaringClass() == other.getDeclaringClass()) {
/* Avoid unnecessary cloning */
- Class[] params1 = parameterTypes;
- Class[] params2 = other.parameterTypes;
+ Class>[] params1 = parameterTypes;
+ Class>[] params2 = other.parameterTypes;
if (params1.length == params2.length) {
for (int i = 0; i < params1.length; i++) {
if (params1[i] != params2[i])
@@ -359,20 +351,20 @@ public final
public String toString() {
try {
StringBuffer sb = new StringBuffer();
- int mod = getModifiers() & LANGUAGE_MODIFIERS;
+ int mod = getModifiers() & Modifier.constructorModifiers();
if (mod != 0) {
sb.append(Modifier.toString(mod) + " ");
}
sb.append(Field.getTypeName(getDeclaringClass()));
sb.append("(");
- Class[] params = parameterTypes; // avoid clone
+ Class>[] params = parameterTypes; // avoid clone
for (int j = 0; j < params.length; j++) {
sb.append(Field.getTypeName(params[j]));
if (j < (params.length - 1))
sb.append(",");
}
sb.append(")");
- Class[] exceptions = exceptionTypes; // avoid clone
+ Class>[] exceptions = exceptionTypes; // avoid clone
if (exceptions.length > 0) {
sb.append(" throws ");
for (int k = 0; k < exceptions.length; k++) {
@@ -423,7 +415,7 @@ public final
public String toGenericString() {
try {
StringBuilder sb = new StringBuilder();
- int mod = getModifiers() & LANGUAGE_MODIFIERS;
+ int mod = getModifiers() & Modifier.constructorModifiers();
if (mod != 0) {
sb.append(Modifier.toString(mod) + " ");
}
@@ -460,7 +452,7 @@ public final
sb.append(" throws ");
for (int k = 0; k < exceptions.length; k++) {
sb.append((exceptions[k] instanceof Class)?
- ((Class)exceptions[k]).getName():
+ ((Class>)exceptions[k]).getName():
exceptions[k].toString());
if (k < (exceptions.length - 1))
sb.append(",");
@@ -526,7 +518,7 @@ public final
{
if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
- Class caller = Reflection.getCallerClass(2);
+ Class> caller = Reflection.getCallerClass(2);
if (securityCheckCache != caller) {
Reflection.ensureMemberAccess(caller, clazz, null, modifiers);
securityCheckCache = caller;
@@ -633,9 +625,9 @@ public final
return AnnotationParser.toArray(declaredAnnotations());
}
- private transient Map declaredAnnotations;
+ private transient Map, Annotation> declaredAnnotations;
- private synchronized Map declaredAnnotations() {
+ private synchronized Map, Annotation> declaredAnnotations() {
if (declaredAnnotations == null) {
declaredAnnotations = AnnotationParser.parseAnnotations(
annotations, sun.misc.SharedSecrets.getJavaLangAccess().
diff --git a/jdk/src/share/classes/java/lang/reflect/Field.java b/jdk/src/share/classes/java/lang/reflect/Field.java
index 5a3e9e9ab7d..7a39f096373 100644
--- a/jdk/src/share/classes/java/lang/reflect/Field.java
+++ b/jdk/src/share/classes/java/lang/reflect/Field.java
@@ -58,12 +58,12 @@ import sun.reflect.annotation.AnnotationParser;
public final
class Field extends AccessibleObject implements Member {
- private Class clazz;
+ private Class> clazz;
private int slot;
// This is guaranteed to be interned by the VM in the 1.4
// reflection implementation
private String name;
- private Class type;
+ private Class> type;
private int modifiers;
// Generics and annotations support
private transient String signature;
@@ -81,8 +81,8 @@ class Field extends AccessibleObject implements Member {
// More complicated security check cache needed here than for
// Class.newInstance() and Constructor.newInstance()
- private Class securityCheckCache;
- private Class securityCheckTargetClassCache;
+ private Class> securityCheckCache;
+ private Class> securityCheckTargetClassCache;
// Generics infrastructure
@@ -112,9 +112,9 @@ class Field extends AccessibleObject implements Member {
* instantiation of these objects in Java code from the java.lang
* package via sun.reflect.LangReflectAccess.
*/
- Field(Class declaringClass,
+ Field(Class> declaringClass,
String name,
- Class type,
+ Class> type,
int modifiers,
int slot,
String signature,
@@ -964,10 +964,10 @@ class Field extends AccessibleObject implements Member {
private void doSecurityCheck(Object obj) throws IllegalAccessException {
if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
- Class caller = Reflection.getCallerClass(4);
- Class targetClass = ((obj == null || !Modifier.isProtected(modifiers))
- ? clazz
- : obj.getClass());
+ Class> caller = Reflection.getCallerClass(4);
+ Class> targetClass = ((obj == null || !Modifier.isProtected(modifiers))
+ ? clazz
+ : obj.getClass());
synchronized (this) {
if ((securityCheckCache == caller)
@@ -987,10 +987,10 @@ class Field extends AccessibleObject implements Member {
/*
* Utility routine to paper over array type names
*/
- static String getTypeName(Class type) {
+ static String getTypeName(Class> type) {
if (type.isArray()) {
try {
- Class cl = type;
+ Class> cl = type;
int dimensions = 0;
while (cl.isArray()) {
dimensions++;
@@ -1025,9 +1025,9 @@ class Field extends AccessibleObject implements Member {
return AnnotationParser.toArray(declaredAnnotations());
}
- private transient Map declaredAnnotations;
+ private transient Map, Annotation> declaredAnnotations;
- private synchronized Map declaredAnnotations() {
+ private synchronized Map, Annotation> declaredAnnotations() {
if (declaredAnnotations == null) {
declaredAnnotations = AnnotationParser.parseAnnotations(
annotations, sun.misc.SharedSecrets.getJavaLangAccess().
diff --git a/jdk/src/share/classes/java/lang/reflect/Method.java b/jdk/src/share/classes/java/lang/reflect/Method.java
index c638869cd38..b9793c7754b 100644
--- a/jdk/src/share/classes/java/lang/reflect/Method.java
+++ b/jdk/src/share/classes/java/lang/reflect/Method.java
@@ -61,14 +61,14 @@ import java.util.Map;
public final
class Method extends AccessibleObject implements GenericDeclaration,
Member {
- private Class clazz;
+ private Class> clazz;
private int slot;
// This is guaranteed to be interned by the VM in the 1.4
// reflection implementation
private String name;
- private Class returnType;
- private Class[] parameterTypes;
- private Class[] exceptionTypes;
+ private Class> returnType;
+ private Class>[] parameterTypes;
+ private Class>[] exceptionTypes;
private int modifiers;
// Generics and annotations support
private transient String signature;
@@ -85,14 +85,8 @@ public final
// More complicated security check cache needed here than for
// Class.newInstance() and Constructor.newInstance()
- private Class securityCheckCache;
- private Class securityCheckTargetClassCache;
-
- // Modifiers that can be applied to a method in source code
- private static final int LANGUAGE_MODIFIERS =
- Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
- Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL |
- Modifier.SYNCHRONIZED | Modifier.NATIVE;
+ private Class> securityCheckCache;
+ private Class> securityCheckTargetClassCache;
// Generics infrastructure
@@ -120,11 +114,11 @@ public final
* instantiation of these objects in Java code from the java.lang
* package via sun.reflect.LangReflectAccess.
*/
- Method(Class declaringClass,
+ Method(Class> declaringClass,
String name,
- Class[] parameterTypes,
- Class returnType,
- Class[] checkedExceptions,
+ Class>[] parameterTypes,
+ Class> returnType,
+ Class>[] checkedExceptions,
int modifiers,
int slot,
String signature,
@@ -323,10 +317,6 @@ public final
* Returns an array of length 0 if the underlying method declares
* no exceptions in its {@code throws} clause.
*
- *
If an exception type is a parameterized type, the {@code Type}
- * object returned for it must accurately reflect the actual type
- * parameters used in the source code.
- *
*
If an exception type is a type variable or a parameterized
* type, it is created. Otherwise, it is resolved.
*
@@ -365,8 +355,8 @@ public final
if (!returnType.equals(other.getReturnType()))
return false;
/* Avoid unnecessary cloning */
- Class[] params1 = parameterTypes;
- Class[] params2 = other.parameterTypes;
+ Class>[] params1 = parameterTypes;
+ Class>[] params2 = other.parameterTypes;
if (params1.length == params2.length) {
for (int i = 0; i < params1.length; i++) {
if (params1[i] != params2[i])
@@ -408,26 +398,26 @@ public final
* {@code public}, {@code protected} or {@code private} first,
* and then other modifiers in the following order:
* {@code abstract}, {@code static}, {@code final},
- * {@code synchronized}, {@code native}.
+ * {@code synchronized}, {@code native}, {@code strictfp}.
*/
public String toString() {
try {
StringBuffer sb = new StringBuffer();
- int mod = getModifiers() & LANGUAGE_MODIFIERS;
+ int mod = getModifiers() & Modifier.methodModifiers();
if (mod != 0) {
sb.append(Modifier.toString(mod) + " ");
}
sb.append(Field.getTypeName(getReturnType()) + " ");
sb.append(Field.getTypeName(getDeclaringClass()) + ".");
sb.append(getName() + "(");
- Class[] params = parameterTypes; // avoid clone
+ Class>[] params = parameterTypes; // avoid clone
for (int j = 0; j < params.length; j++) {
sb.append(Field.getTypeName(params[j]));
if (j < (params.length - 1))
sb.append(",");
}
sb.append(")");
- Class[] exceptions = exceptionTypes; // avoid clone
+ Class>[] exceptions = exceptionTypes; // avoid clone
if (exceptions.length > 0) {
sb.append(" throws ");
for (int k = 0; k < exceptions.length; k++) {
@@ -473,7 +463,7 @@ public final
* {@code public}, {@code protected} or {@code private} first,
* and then other modifiers in the following order:
* {@code abstract}, {@code static}, {@code final},
- * {@code synchronized} {@code native}.
+ * {@code synchronized}, {@code native}, {@code strictfp}.
*
* @return a string describing this {@code Method},
* include type parameters
@@ -483,7 +473,7 @@ public final
public String toGenericString() {
try {
StringBuilder sb = new StringBuilder();
- int mod = getModifiers() & LANGUAGE_MODIFIERS;
+ int mod = getModifiers() & Modifier.methodModifiers();
if (mod != 0) {
sb.append(Modifier.toString(mod) + " ");
}
@@ -600,10 +590,10 @@ public final
{
if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
- Class caller = Reflection.getCallerClass(1);
- Class targetClass = ((obj == null || !Modifier.isProtected(modifiers))
- ? clazz
- : obj.getClass());
+ Class> caller = Reflection.getCallerClass(1);
+ Class> targetClass = ((obj == null || !Modifier.isProtected(modifiers))
+ ? clazz
+ : obj.getClass());
boolean cached;
synchronized (this) {
@@ -712,9 +702,9 @@ public final
return AnnotationParser.toArray(declaredAnnotations());
}
- private transient Map declaredAnnotations;
+ private transient Map, Annotation> declaredAnnotations;
- private synchronized Map declaredAnnotations() {
+ private synchronized Map, Annotation> declaredAnnotations() {
if (declaredAnnotations == null) {
declaredAnnotations = AnnotationParser.parseAnnotations(
annotations, sun.misc.SharedSecrets.getJavaLangAccess().
@@ -741,7 +731,7 @@ public final
public Object getDefaultValue() {
if (annotationDefault == null)
return null;
- Class memberType = AnnotationType.invocationHandlerReturnType(
+ Class> memberType = AnnotationType.invocationHandlerReturnType(
getReturnType());
Object result = AnnotationParser.parseMemberValue(
memberType, ByteBuffer.wrap(annotationDefault),
diff --git a/jdk/src/share/classes/java/lang/reflect/Modifier.java b/jdk/src/share/classes/java/lang/reflect/Modifier.java
index 2882f04722f..f32822c2f09 100644
--- a/jdk/src/share/classes/java/lang/reflect/Modifier.java
+++ b/jdk/src/share/classes/java/lang/reflect/Modifier.java
@@ -235,6 +235,11 @@ class Modifier {
* possible validity of the combination of modifiers represented
* by the input.
*
+ * Note that to perform such checking for a known kind of entity,
+ * such as a constructor or method, first AND the argument of
+ * {@code toString} with the appropriate mask from a method like
+ * {@link #constructorModifiers} or {@link #methodModifiers}.
+ *
* @param mod a set of modifiers
* @return a string representation of the set of modifiers
* represented by {@code mod}
@@ -353,4 +358,108 @@ class Modifier {
static boolean isSynthetic(int mod) {
return (mod & SYNTHETIC) != 0;
}
+
+ /**
+ * See JLSv3 section 8.1.1.
+ */
+ private static final int CLASS_MODIFIERS =
+ Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
+ Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL |
+ Modifier.STRICT;
+
+ /**
+ * See JLSv3 section 9.1.1.
+ */
+ private static final int INTERFACE_MODIFIERS =
+ Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
+ Modifier.ABSTRACT | Modifier.STATIC | Modifier.STRICT;
+
+
+ /**
+ * See JLSv3 section 8.8.3.
+ */
+ private static final int CONSTRUCTOR_MODIFIERS =
+ Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
+
+ /**
+ * See JLSv3 section 8.4.3.
+ */
+ private static final int METHOD_MODIFIERS =
+ Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
+ Modifier.ABSTRACT | Modifier.STATIC | Modifier.FINAL |
+ Modifier.SYNCHRONIZED | Modifier.NATIVE | Modifier.STRICT;
+
+ /**
+ * See JLSv3 section 8.3.1.
+ */
+ private static final int FIELD_MODIFIERS =
+ Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
+ Modifier.STATIC | Modifier.FINAL | Modifier.TRANSIENT |
+ Modifier.VOLATILE;
+
+ /**
+ * Return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to a class.
+ * @return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to a class.
+ *
+ * @jls3 8.1.1 Class Modifiers
+ * @since 1.7
+ */
+ public static int classModifiers() {
+ return CLASS_MODIFIERS;
+ }
+
+ /**
+ * Return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to an interface.
+ * @return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to an inteface.
+ *
+ * @jls3 9.1.1 Interface Modifiers
+ * @since 1.7
+ */
+ public static int interfaceModifiers() {
+ return INTERFACE_MODIFIERS;
+ }
+
+ /**
+ * Return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to a constructor.
+ * @return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to a constructor.
+ *
+ * @jls3 8.8.3 Constructor Modifiers
+ * @since 1.7
+ */
+ public static int constructorModifiers() {
+ return CONSTRUCTOR_MODIFIERS;
+ }
+
+ /**
+ * Return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to a method.
+ * @return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to a method.
+ *
+ * @jls3 8.4.3 Method Modifiers
+ * @since 1.7
+ */
+ public static int methodModifiers() {
+ return METHOD_MODIFIERS;
+ }
+
+
+ /**
+ * Return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to a field.
+ * @return an {@code int} value OR-ing together the source language
+ * modifiers that can be applied to a field.
+ *
+ * @jls3 8.3.1 Field Modifiers
+ * @since 1.7
+ */
+ public static int fieldModifiers() {
+ return FIELD_MODIFIERS;
+ }
}
diff --git a/jdk/src/share/classes/java/lang/reflect/Proxy.java b/jdk/src/share/classes/java/lang/reflect/Proxy.java
index 07b7e85df56..258c64aff69 100644
--- a/jdk/src/share/classes/java/lang/reflect/Proxy.java
+++ b/jdk/src/share/classes/java/lang/reflect/Proxy.java
@@ -350,7 +350,7 @@ public class Proxy implements java.io.Serializable {
throw new IllegalArgumentException("interface limit exceeded");
}
- Class proxyClass = null;
+ Class> proxyClass = null;
/* collect interface names to use as key for proxy class cache */
String[] interfaceNames = new String[interfaces.length];
@@ -364,7 +364,7 @@ public class Proxy implements java.io.Serializable {
* interface to the same Class object.
*/
String interfaceName = interfaces[i].getName();
- Class interfaceClass = null;
+ Class> interfaceClass = null;
try {
interfaceClass = Class.forName(interfaceName, false, loader);
} catch (ClassNotFoundException e) {
diff --git a/jdk/src/share/classes/java/lang/reflect/ReflectAccess.java b/jdk/src/share/classes/java/lang/reflect/ReflectAccess.java
index ff09637a934..28f1b63230f 100644
--- a/jdk/src/share/classes/java/lang/reflect/ReflectAccess.java
+++ b/jdk/src/share/classes/java/lang/reflect/ReflectAccess.java
@@ -33,9 +33,9 @@ import sun.reflect.ConstructorAccessor;
package to instantiate objects in this package. */
class ReflectAccess implements sun.reflect.LangReflectAccess {
- public Field newField(Class declaringClass,
+ public Field newField(Class> declaringClass,
String name,
- Class type,
+ Class> type,
int modifiers,
int slot,
String signature,
@@ -50,11 +50,11 @@ class ReflectAccess implements sun.reflect.LangReflectAccess {
annotations);
}
- public Method newMethod(Class declaringClass,
+ public Method newMethod(Class> declaringClass,
String name,
- Class[] parameterTypes,
- Class returnType,
- Class[] checkedExceptions,
+ Class>[] parameterTypes,
+ Class> returnType,
+ Class>[] checkedExceptions,
int modifiers,
int slot,
String signature,
@@ -76,8 +76,8 @@ class ReflectAccess implements sun.reflect.LangReflectAccess {
}
public Constructor newConstructor(Class declaringClass,
- Class[] parameterTypes,
- Class[] checkedExceptions,
+ Class>[] parameterTypes,
+ Class>[] checkedExceptions,
int modifiers,
int slot,
String signature,
@@ -102,29 +102,29 @@ class ReflectAccess implements sun.reflect.LangReflectAccess {
m.setMethodAccessor(accessor);
}
- public ConstructorAccessor getConstructorAccessor(Constructor c) {
+ public ConstructorAccessor getConstructorAccessor(Constructor> c) {
return c.getConstructorAccessor();
}
- public void setConstructorAccessor(Constructor c,
+ public void setConstructorAccessor(Constructor> c,
ConstructorAccessor accessor)
{
c.setConstructorAccessor(accessor);
}
- public int getConstructorSlot(Constructor c) {
+ public int getConstructorSlot(Constructor> c) {
return c.getSlot();
}
- public String getConstructorSignature(Constructor c) {
+ public String getConstructorSignature(Constructor> c) {
return c.getSignature();
}
- public byte[] getConstructorAnnotations(Constructor c) {
+ public byte[] getConstructorAnnotations(Constructor> c) {
return c.getRawAnnotations();
}
- public byte[] getConstructorParameterAnnotations(Constructor c) {
+ public byte[] getConstructorParameterAnnotations(Constructor> c) {
return c.getRawParameterAnnotations();
}
diff --git a/jdk/src/share/classes/java/math/BigDecimal.java b/jdk/src/share/classes/java/math/BigDecimal.java
index 0feec208bb9..4d76b4010e7 100644
--- a/jdk/src/share/classes/java/math/BigDecimal.java
+++ b/jdk/src/share/classes/java/math/BigDecimal.java
@@ -315,6 +315,10 @@ public class BigDecimal extends Number implements Comparable {
new BigDecimal(BigInteger.ZERO, 0, 15, 1),
};
+ // Half of Long.MIN_VALUE & Long.MAX_VALUE.
+ private static final long HALF_LONG_MAX_VALUE = Long.MAX_VALUE / 2;
+ private static final long HALF_LONG_MIN_VALUE = Long.MIN_VALUE / 2;
+
// Constants
/**
* The value 0, with a scale of 0.
@@ -1455,10 +1459,15 @@ public class BigDecimal extends Number implements Comparable {
} else if (roundingMode == ROUND_FLOOR) { // Towards -infinity
increment = (qsign < 0);
} else {
- if (isLongDivision || ldivisor != INFLATED)
- cmpFracHalf = longCompareMagnitude(2 * r, ldivisor);
- else
+ if (isLongDivision || ldivisor != INFLATED) {
+ if (r <= HALF_LONG_MIN_VALUE || r > HALF_LONG_MAX_VALUE) {
+ cmpFracHalf = 1; // 2 * r can't fit into long
+ } else {
+ cmpFracHalf = longCompareMagnitude(2 * r, ldivisor);
+ }
+ } else {
cmpFracHalf = mr.compareHalf(mdivisor);
+ }
if (cmpFracHalf < 0)
increment = false; // We're closer to higher digit
else if (cmpFracHalf > 0) // We're closer to lower digit
diff --git a/jdk/src/share/classes/java/net/CookieManager.java b/jdk/src/share/classes/java/net/CookieManager.java
index 32790a8f185..95de8c0db3b 100644
--- a/jdk/src/share/classes/java/net/CookieManager.java
+++ b/jdk/src/share/classes/java/net/CookieManager.java
@@ -157,7 +157,7 @@ public class CookieManager extends CookieHandler
// if not specify CookieStore to use, use default one
if (store == null) {
- cookieJar = new sun.net.www.protocol.http.InMemoryCookieStore();
+ cookieJar = new InMemoryCookieStore();
} else {
cookieJar = store;
}
diff --git a/jdk/src/share/classes/sun/net/www/protocol/http/InMemoryCookieStore.java b/jdk/src/share/classes/java/net/InMemoryCookieStore.java
similarity index 99%
rename from jdk/src/share/classes/sun/net/www/protocol/http/InMemoryCookieStore.java
rename to jdk/src/share/classes/java/net/InMemoryCookieStore.java
index 2e7b54f70c0..697ca88d710 100644
--- a/jdk/src/share/classes/sun/net/www/protocol/http/InMemoryCookieStore.java
+++ b/jdk/src/share/classes/java/net/InMemoryCookieStore.java
@@ -23,7 +23,7 @@
* have any questions.
*/
-package sun.net.www.protocol.http;
+package java.net;
import java.net.URI;
import java.net.CookieStore;
@@ -43,7 +43,7 @@ import java.util.concurrent.locks.ReentrantLock;
* @author Edward Wang
* @since 1.6
*/
-public class InMemoryCookieStore implements CookieStore {
+class InMemoryCookieStore implements CookieStore {
// the in-memory representation of cookies
private List cookieJar = null;
diff --git a/jdk/src/share/classes/java/net/URLClassLoader.java b/jdk/src/share/classes/java/net/URLClassLoader.java
index 22be20b7ecd..c4f775db71a 100644
--- a/jdk/src/share/classes/java/net/URLClassLoader.java
+++ b/jdk/src/share/classes/java/net/URLClassLoader.java
@@ -340,6 +340,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* used.
*/
private Class defineClass(String name, Resource res) throws IOException {
+ long t0 = System.nanoTime();
int i = name.lastIndexOf('.');
URL url = res.getCodeSourceURL();
if (i != -1) {
@@ -370,12 +371,14 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
// Use (direct) ByteBuffer:
CodeSigner[] signers = res.getCodeSigners();
CodeSource cs = new CodeSource(url, signers);
+ sun.misc.PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
return defineClass(name, bb, cs);
} else {
byte[] b = res.getBytes();
// must read certificates AFTER reading bytes.
CodeSigner[] signers = res.getCodeSigners();
CodeSource cs = new CodeSource(url, signers);
+ sun.misc.PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
return defineClass(name, b, 0, b.length, cs);
}
}
diff --git a/jdk/src/share/classes/java/net/doc-files/net-properties.html b/jdk/src/share/classes/java/net/doc-files/net-properties.html
index e6b6330ba42..384abd8d93f 100644
--- a/jdk/src/share/classes/java/net/doc-files/net-properties.html
+++ b/jdk/src/share/classes/java/net/doc-files/net-properties.html
@@ -71,12 +71,12 @@ of proxies.
HTTP
The following proxy settings are used by the HTTP protocol handler.
-
http.proxyHost (default: <none>)
+
http.proxyHost (default: <none>)
The hostname, or address, of the proxy server
http.proxyPort (default: 80)
The port number of the proxy server.
-
http.nonProxyHosts (default: <none>)
+
http.nonProxyHosts (default: localhost|127.*|[::1])
Indicates the hosts that should be accessed without going
through the proxy. Typically this defines internal hosts.
The value of this property is a list of hosts,
@@ -86,7 +86,8 @@ of proxies.
will indicate that every hosts in the foo.com domain and the
localhost should be accessed directly even if a proxy server is
specified.
-
+
The default value excludes all common variations of the loopback address.
+
HTTPS This is HTTP over SSL, a secure version of HTTP
mainly used when confidentiality (like on payment sites) is needed.
The following proxy settings are used by the HTTPS protocol handler.
@@ -107,7 +108,7 @@ of proxies.
ftp.proxyPort (default: 80)
The port number of the proxy server.
-
ftp.nonProxyHosts (default: <none>)
+
ftp.nonProxyHosts (default: localhost|127.*|[::1])
Indicates the hosts that should be accessed without going
through the proxy. Typically this defines internal hosts.
The value of this property is a list of hosts, separated by
@@ -117,6 +118,7 @@ of proxies.
will indicate that every hosts in the foo.com domain and the
localhost should be accessed directly even if a proxy server is
specified.
+
The default value excludes all common variations of the loopback address.
SOCKS This is another type of proxy. It allows for lower
level type of tunneling since it works at the TCP level. In effect,
diff --git a/jdk/src/share/classes/java/nio/file/FileTreeWalker.java b/jdk/src/share/classes/java/nio/file/FileTreeWalker.java
index 71cb86eb88a..1452bd66b2a 100644
--- a/jdk/src/share/classes/java/nio/file/FileTreeWalker.java
+++ b/jdk/src/share/classes/java/nio/file/FileTreeWalker.java
@@ -41,8 +41,12 @@ class FileTreeWalker {
private final boolean detectCycles;
private final LinkOption[] linkOptions;
private final FileVisitor super Path> visitor;
+ private final int maxDepth;
- FileTreeWalker(Set options, FileVisitor super Path> visitor) {
+ FileTreeWalker(Set options,
+ FileVisitor super Path> visitor,
+ int maxDepth)
+ {
boolean fl = false;
boolean dc = false;
for (FileVisitOption option: options) {
@@ -58,18 +62,15 @@ class FileTreeWalker {
this.linkOptions = (fl) ? new LinkOption[0] :
new LinkOption[] { LinkOption.NOFOLLOW_LINKS };
this.visitor = visitor;
+ this.maxDepth = maxDepth;
}
/**
* Walk file tree starting at the given file
*/
- void walk(Path start, int maxDepth) {
- // don't use attributes of starting file as they may be stale
- if (start instanceof BasicFileAttributesHolder) {
- ((BasicFileAttributesHolder)start).invalidate();
- }
+ void walk(Path start) {
FileVisitResult result = walk(start,
- maxDepth,
+ 0,
new ArrayList());
if (result == null) {
throw new NullPointerException("Visitor returned 'null'");
@@ -89,12 +90,15 @@ class FileTreeWalker {
List ancestors)
{
// depth check
- if (depth-- < 0)
+ if (depth > maxDepth)
return FileVisitResult.CONTINUE;
// if attributes are cached then use them if possible
BasicFileAttributes attrs = null;
- if (file instanceof BasicFileAttributesHolder) {
+ if ((depth > 0) &&
+ (file instanceof BasicFileAttributesHolder) &&
+ (System.getSecurityManager() == null))
+ {
BasicFileAttributes cached = ((BasicFileAttributesHolder)file).get();
if (!followLinks || !cached.isSymbolicLink())
attrs = cached;
@@ -120,6 +124,10 @@ class FileTreeWalker {
}
}
} catch (SecurityException x) {
+ // If access to starting file is denied then SecurityException
+ // is thrown, otherwise the file is ignored.
+ if (depth == 0)
+ throw x;
return FileVisitResult.CONTINUE;
}
}
@@ -196,7 +204,7 @@ class FileTreeWalker {
try {
for (Path entry: stream) {
inAction = true;
- result = walk(entry, depth, ancestors);
+ result = walk(entry, depth+1, ancestors);
inAction = false;
// returning null will cause NPE to be thrown
diff --git a/jdk/src/share/classes/java/nio/file/Files.java b/jdk/src/share/classes/java/nio/file/Files.java
index 00e1014526c..ca5bc5698e1 100644
--- a/jdk/src/share/classes/java/nio/file/Files.java
+++ b/jdk/src/share/classes/java/nio/file/Files.java
@@ -133,10 +133,11 @@ public final class Files {
*
This method walks a file tree rooted at a given starting file. The
* file tree traversal is depth-first with the given {@link
* FileVisitor} invoked for each file encountered. File tree traversal
- * completes when all accessible files in the tree have been visited, a
- * visitor returns a result of {@link FileVisitResult#TERMINATE TERMINATE},
- * or the visitor terminates due to an uncaught {@code Error} or {@code
- * RuntimeException}.
+ * completes when all accessible files in the tree have been visited, or a
+ * visit method returns a result of {@link FileVisitResult#TERMINATE
+ * TERMINATE}. Where a visit method terminates due an uncaught error or
+ * runtime exception then the traversal is terminated and the error or
+ * exception is propagated to the caller of this method.
*
*
For each file encountered this method attempts to gets its {@link
* java.nio.file.attribute.BasicFileAttributes}. If the file is not a
@@ -222,7 +223,7 @@ public final class Files {
{
if (maxDepth < 0)
throw new IllegalArgumentException("'maxDepth' is negative");
- new FileTreeWalker(options, visitor).walk(start, maxDepth);
+ new FileTreeWalker(options, visitor, maxDepth).walk(start);
}
/**
diff --git a/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java b/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java
index 761773513ed..f252ef03eea 100644
--- a/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java
+++ b/jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java
@@ -124,8 +124,8 @@ public class SimpleFileVisitor implements FileVisitor {
* cause.
*
* @throws IOError
- * if iteration of the directory completed prematurely due to an
- * I/O error
+ * with the I/O exception thrown when iteration of the directory
+ * completed prematurely due to an I/O error
*/
@Override
public FileVisitResult postVisitDirectory(T dir, IOException exc) {
diff --git a/jdk/src/share/classes/java/util/Currency.java b/jdk/src/share/classes/java/util/Currency.java
index 5c9124a90c8..714bd3b2363 100644
--- a/jdk/src/share/classes/java/util/Currency.java
+++ b/jdk/src/share/classes/java/util/Currency.java
@@ -35,12 +35,12 @@ import java.io.Serializable;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.spi.CurrencyNameProvider;
import java.util.spi.LocaleServiceProvider;
import sun.util.LocaleServiceProviderPool;
+import sun.util.logging.PlatformLogger;
import sun.util.resources.LocaleData;
import sun.util.resources.OpenListResourceBundle;
@@ -244,7 +244,7 @@ public final class Currency implements Serializable {
}
}
} catch (IOException e) {
- log(Level.INFO, "currency.properties is ignored because of an IOException", e);
+ info("currency.properties is ignored because of an IOException", e);
}
return null;
}
@@ -686,7 +686,7 @@ public final class Currency implements Serializable {
.append("The entry in currency.properties for ")
.append(ctry).append(" is ignored because of the invalid country code.")
.toString();
- log(Level.INFO, message, null);
+ info(message, null);
return;
}
@@ -698,7 +698,7 @@ public final class Currency implements Serializable {
.append(ctry)
.append(" is ignored because the value format is not recognized.")
.toString();
- log(Level.INFO, message, null);
+ info(message, null);
return;
}
@@ -726,13 +726,13 @@ public final class Currency implements Serializable {
setMainTableEntry(ctry.charAt(0), ctry.charAt(1), entry);
}
- private static void log(Level level, String message, Throwable t) {
- Logger logger = Logger.getLogger("java.util.Currency");
- if (logger.isLoggable(level)) {
+ private static void info(String message, Throwable t) {
+ PlatformLogger logger = PlatformLogger.getLogger("java.util.Currency");
+ if (logger.isLoggable(PlatformLogger.INFO)) {
if (t != null) {
- logger.log(level, message, t);
+ logger.info(message, t);
} else {
- logger.log(level, message);
+ logger.info(message);
}
}
}
diff --git a/jdk/src/share/classes/java/util/Properties.java b/jdk/src/share/classes/java/util/Properties.java
index 29363b1fec3..d93a18f97f2 100644
--- a/jdk/src/share/classes/java/util/Properties.java
+++ b/jdk/src/share/classes/java/util/Properties.java
@@ -101,12 +101,12 @@ import java.io.BufferedWriter;
* <!ATTLIST entry key CDATA #REQUIRED>
*
*
- * @see native2ascii tool for Solaris
- * @see native2ascii tool for Windows
- *
*
This class is thread-safe: multiple threads can share a single
* Properties object without the need for external synchronization.
*
+ * @see native2ascii tool for Solaris
+ * @see native2ascii tool for Windows
+ *
* @author Arthur van Hoff
* @author Michael McCloskey
* @author Xueming Shen
diff --git a/jdk/src/share/classes/java/util/SimpleTimeZone.java b/jdk/src/share/classes/java/util/SimpleTimeZone.java
index b0fd57de8df..d97d6f59a03 100644
--- a/jdk/src/share/classes/java/util/SimpleTimeZone.java
+++ b/jdk/src/share/classes/java/util/SimpleTimeZone.java
@@ -1372,7 +1372,7 @@ public class SimpleTimeZone extends TimeZone {
throw new IllegalArgumentException(
"Illegal start month " + startMonth);
}
- if (startTime < 0 || startTime >= millisPerDay) {
+ if (startTime < 0 || startTime > millisPerDay) {
throw new IllegalArgumentException(
"Illegal start time " + startTime);
}
@@ -1419,7 +1419,7 @@ public class SimpleTimeZone extends TimeZone {
throw new IllegalArgumentException(
"Illegal end month " + endMonth);
}
- if (endTime < 0 || endTime >= millisPerDay) {
+ if (endTime < 0 || endTime > millisPerDay) {
throw new IllegalArgumentException(
"Illegal end time " + endTime);
}
diff --git a/jdk/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java b/jdk/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java
index 10f2b6540cd..dc946786f83 100644
--- a/jdk/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java
+++ b/jdk/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java
@@ -766,19 +766,21 @@ public class LinkedBlockingQueue extends AbstractQueue
}
/**
- * Unlike other traversal methods, iterators need to handle:
+ * Returns the next live successor of p, or null if no such.
+ *
+ * Unlike other traversal methods, iterators need to handle both:
* - dequeued nodes (p.next == p)
- * - interior removed nodes (p.item == null)
+ * - (possibly multiple) interior removed nodes (p.item == null)
*/
private Node nextNode(Node p) {
- Node s = p.next;
- if (p == s)
- return head.next;
- // Skip over removed nodes.
- // May be necessary if multiple interior Nodes are removed.
- while (s != null && s.item == null)
- s = s.next;
- return s;
+ for (;;) {
+ Node s = p.next;
+ if (s == p)
+ return head.next;
+ if (s == null || s.item != null)
+ return s;
+ p = s;
+ }
}
public E next() {
diff --git a/jdk/src/share/classes/java/util/jar/Attributes.java b/jdk/src/share/classes/java/util/jar/Attributes.java
index 27a2aba8ef9..e9a9e6e6f69 100644
--- a/jdk/src/share/classes/java/util/jar/Attributes.java
+++ b/jdk/src/share/classes/java/util/jar/Attributes.java
@@ -34,7 +34,7 @@ import java.util.Set;
import java.util.Collection;
import java.util.AbstractSet;
import java.util.Iterator;
-import java.util.logging.Logger;
+import sun.util.logging.PlatformLogger;
import java.util.Comparator;
import sun.misc.ASCIICaseInsensitiveComparator;
@@ -419,7 +419,7 @@ public class Attributes implements Map, Cloneable {
}
try {
if ((putValue(name, value) != null) && (!lineContinued)) {
- Logger.getLogger("java.util.jar").warning(
+ PlatformLogger.getLogger("java.util.jar").warning(
"Duplicate name in Manifest: " + name
+ ".\n"
+ "Ensure that the manifest does not "
diff --git a/jdk/src/share/classes/java/util/logging/ErrorManager.java b/jdk/src/share/classes/java/util/logging/ErrorManager.java
index 39c215151fc..8a6d935dea3 100644
--- a/jdk/src/share/classes/java/util/logging/ErrorManager.java
+++ b/jdk/src/share/classes/java/util/logging/ErrorManager.java
@@ -28,7 +28,7 @@ package java.util.logging;
/**
* ErrorManager objects can be attached to Handlers to process
- * any error that occur on a Handler during Logging.
+ * any error that occurs on a Handler during Logging.
*
* When processing logging output, if a Handler encounters problems
* then rather than throwing an Exception back to the issuer of
@@ -72,7 +72,7 @@ public class ErrorManager {
/**
* The error method is called when a Handler failure occurs.
*
- * This method may be overriden in subclasses. The default
+ * This method may be overridden in subclasses. The default
* behavior in this base class is that the first call is
* reported to System.err, and subsequent calls are ignored.
*
diff --git a/jdk/src/share/classes/java/util/logging/FileHandler.java b/jdk/src/share/classes/java/util/logging/FileHandler.java
index a4f18bd2130..23031a010c8 100644
--- a/jdk/src/share/classes/java/util/logging/FileHandler.java
+++ b/jdk/src/share/classes/java/util/logging/FileHandler.java
@@ -39,7 +39,7 @@ import java.security.*;
* For a rotating set of files, as each file reaches a given size
* limit, it is closed, rotated out, and a new file opened.
* Successively older files are named by adding "0", "1", "2",
- * etc into the base filename.
+ * etc. into the base filename.
*
* By default buffering is enabled in the IO libraries but each log
* record is flushed out when it is complete.
@@ -391,7 +391,7 @@ public class FileHandler extends StreamHandler {
// Generate a lock file name from the "unique" int.
lockFileName = generate(pattern, 0, unique).toString() + ".lck";
// Now try to lock that filename.
- // Because some systems (e.g. Solaris) can only do file locks
+ // Because some systems (e.g., Solaris) can only do file locks
// between processes (and not within a process), we first check
// if we ourself already have the file locked.
synchronized(locks) {
diff --git a/jdk/src/share/classes/java/util/logging/Formatter.java b/jdk/src/share/classes/java/util/logging/Formatter.java
index 7e7030ba6b0..7cf5c1764a1 100644
--- a/jdk/src/share/classes/java/util/logging/Formatter.java
+++ b/jdk/src/share/classes/java/util/logging/Formatter.java
@@ -52,7 +52,7 @@ public abstract class Formatter {
* Format the given log record and return the formatted string.
*
* The resulting formatted String will normally include a
- * localized and formated version of the LogRecord's message field.
+ * localized and formatted version of the LogRecord's message field.
* It is recommended to use the {@link Formatter#formatMessage}
* convenience method to localize and format the message field.
*
@@ -66,7 +66,7 @@ public abstract class Formatter {
* Return the header string for a set of formatted records.
*
* This base class returns an empty string, but this may be
- * overriden by subclasses.
+ * overridden by subclasses.
*
* @param h The target handler (can be null)
* @return header string
@@ -79,7 +79,7 @@ public abstract class Formatter {
* Return the tail string for a set of formatted records.
*
* This base class returns an empty string, but this may be
- * overriden by subclasses.
+ * overridden by subclasses.
*
* @param h The target handler (can be null)
* @return tail string
diff --git a/jdk/src/share/classes/java/util/logging/Handler.java b/jdk/src/share/classes/java/util/logging/Handler.java
index 2643c734714..7c1c6268b00 100644
--- a/jdk/src/share/classes/java/util/logging/Handler.java
+++ b/jdk/src/share/classes/java/util/logging/Handler.java
@@ -274,7 +274,7 @@ public abstract class Handler {
* Level and whether it satisfies any Filter. It also
* may make other Handler specific checks that might prevent a
* handler from logging the LogRecord. It will return false if
- * the LogRecord is Null.
+ * the LogRecord is null.
*
* @param record a LogRecord
* @return true if the LogRecord would be logged.
diff --git a/jdk/src/share/classes/java/util/logging/Level.java b/jdk/src/share/classes/java/util/logging/Level.java
index 910a50d1ebb..173201f80ee 100644
--- a/jdk/src/share/classes/java/util/logging/Level.java
+++ b/jdk/src/share/classes/java/util/logging/Level.java
@@ -110,7 +110,7 @@ public class Level implements java.io.Serializable {
* Typically INFO messages will be written to the console
* or its equivalent. So the INFO level should only be
* used for reasonably significant messages that will
- * make sense to end users and system admins.
+ * make sense to end users and system administrators.
* This level is initialized to 800.
*/
public static final Level INFO = new Level("INFO", 800, defaultBundle);
@@ -245,6 +245,8 @@ public class Level implements java.io.Serializable {
}
/**
+ * Returns a string representation of this Level.
+ *
* @return the non-localized name of the Level, for example "INFO".
*/
public final String toString() {
@@ -299,14 +301,14 @@ public class Level implements java.io.Serializable {
* @throws IllegalArgumentException if the value is not valid.
* Valid values are integers between Integer.MIN_VALUE
* and Integer.MAX_VALUE, and all known level names.
- * Known names are the levels defined by this class (i.e. FINE,
+ * Known names are the levels defined by this class (e.g., FINE,
* FINER, FINEST), or created by this class with
* appropriate package access, or new levels defined or created
* by subclasses.
*
* @return The parsed value. Passing an integer that corresponds to a known name
- * (eg 700) will return the associated name (eg CONFIG).
- * Passing an integer that does not (eg 1) will return a new level name
+ * (e.g., 700) will return the associated name (e.g., CONFIG).
+ * Passing an integer that does not (e.g., 1) will return a new level name
* initialized to that value.
*/
public static synchronized Level parse(String name) throws IllegalArgumentException {
diff --git a/jdk/src/share/classes/java/util/logging/LogManager.java b/jdk/src/share/classes/java/util/logging/LogManager.java
index e6412565a87..4faea17d79e 100644
--- a/jdk/src/share/classes/java/util/logging/LogManager.java
+++ b/jdk/src/share/classes/java/util/logging/LogManager.java
@@ -283,6 +283,10 @@ public class LogManager {
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
readConfiguration();
+
+ // Platform loggers begin to delegate to java.util.logging.Logger
+ sun.util.logging.PlatformLogger.redirectPlatformLoggers();
+
return null;
}
});
diff --git a/jdk/src/share/classes/java/util/logging/LogRecord.java b/jdk/src/share/classes/java/util/logging/LogRecord.java
index 2610316a5e3..e6706319ffa 100644
--- a/jdk/src/share/classes/java/util/logging/LogRecord.java
+++ b/jdk/src/share/classes/java/util/logging/LogRecord.java
@@ -188,7 +188,7 @@ public class LogRecord implements java.io.Serializable {
}
/**
- * Get the source Logger name's
+ * Get the source Logger's name.
*
* @return source logger name (may be null)
*/
@@ -197,7 +197,7 @@ public class LogRecord implements java.io.Serializable {
}
/**
- * Set the source Logger name.
+ * Set the source Logger's name.
*
* @param name the source logger name (may be null)
*/
@@ -530,6 +530,7 @@ public class LogRecord implements java.io.Serializable {
int depth = access.getStackTraceDepth(throwable);
String logClassName = "java.util.logging.Logger";
+ String plogClassName = "sun.util.logging.PlatformLogger";
boolean lookingForLogger = true;
for (int ix = 0; ix < depth; ix++) {
// Calling getStackTraceElement directly prevents the VM
@@ -539,15 +540,18 @@ public class LogRecord implements java.io.Serializable {
String cname = frame.getClassName();
if (lookingForLogger) {
// Skip all frames until we have found the first logger frame.
- if (cname.equals(logClassName)) {
+ if (cname.equals(logClassName) || cname.startsWith(plogClassName)) {
lookingForLogger = false;
}
} else {
- if (!cname.equals(logClassName)) {
- // We've found the relevant frame.
- setSourceClassName(cname);
- setSourceMethodName(frame.getMethodName());
- return;
+ if (!cname.equals(logClassName) && !cname.startsWith(plogClassName)) {
+ // skip reflection call
+ if (!cname.startsWith("java.lang.reflect.") && !cname.startsWith("sun.reflect.")) {
+ // We've found the relevant frame.
+ setSourceClassName(cname);
+ setSourceMethodName(frame.getMethodName());
+ return;
+ }
}
}
}
diff --git a/jdk/src/share/classes/java/util/logging/Logger.java b/jdk/src/share/classes/java/util/logging/Logger.java
index 5ae2b427133..cd9f4d90568 100644
--- a/jdk/src/share/classes/java/util/logging/Logger.java
+++ b/jdk/src/share/classes/java/util/logging/Logger.java
@@ -66,7 +66,7 @@ import java.lang.ref.WeakReference;
* effective level from its parent.
*
* On each logging call the Logger initially performs a cheap
- * check of the request level (e.g. SEVERE or FINE) against the
+ * check of the request level (e.g., SEVERE or FINE) against the
* effective log level of the logger. If the request level is
* lower than the log level, the logging call returns immediately.
*
@@ -230,7 +230,7 @@ public class Logger {
* Protected method to construct a logger for a named subsystem.
*
* The logger will be initially configured with a null Level
- * and with useParentHandlers true.
+ * and with useParentHandlers set to true.
*
* @param name A name for the logger. This should
* be a dot-separated name and should normally
@@ -240,7 +240,7 @@ public class Logger {
* @param resourceBundleName name of ResourceBundle to be used for localizing
* messages for this logger. May be null if none
* of the messages require localization.
- * @throws MissingResourceException if the ResourceBundleName is non-null and
+ * @throws MissingResourceException if the resourceBundleName is non-null and
* no corresponding resource can be found.
*/
protected Logger(String name, String resourceBundleName) {
@@ -285,7 +285,7 @@ public class Logger {
*
* If a new logger is created its log level will be configured
* based on the LogManager configuration and it will configured
- * to also send logging output to its parent's handlers. It will
+ * to also send logging output to its parent's Handlers. It will
* be registered in the LogManager global namespace.
*
* @param name A name for the logger. This should
@@ -308,7 +308,7 @@ public class Logger {
*
* If a new logger is created its log level will be configured
* based on the LogManager and it will configured to also send logging
- * output to its parent loggers Handlers. It will be registered in
+ * output to its parent's Handlers. It will be registered in
* the LogManager global namespace.
*
* If the named Logger already exists and does not yet have a
@@ -326,7 +326,8 @@ public class Logger {
* messages for this logger. May be null if none of
* the messages require localization.
* @return a suitable Logger
- * @throws MissingResourceException if the named ResourceBundle cannot be found.
+ * @throws MissingResourceException if the resourceBundleName is non-null and
+ * no corresponding resource can be found.
* @throws IllegalArgumentException if the Logger already exists and uses
* a different resource bundle name.
* @throws NullPointerException if the name is null.
@@ -395,7 +396,8 @@ public class Logger {
* messages for this logger.
* May be null if none of the messages require localization.
* @return a newly created private Logger
- * @throws MissingResourceException if the named ResourceBundle cannot be found.
+ * @throws MissingResourceException if the resourceBundleName is non-null and
+ * no corresponding resource can be found.
*/
public static synchronized Logger getAnonymousLogger(String resourceBundleName) {
LogManager manager = LogManager.getLogManager();
@@ -514,7 +516,7 @@ public class Logger {
* level then the given message is forwarded to all the
* registered output Handler objects.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param msg The string message (or a key in the message catalog)
*/
public void log(Level level, String msg) {
@@ -532,7 +534,7 @@ public class Logger {
* level then a corresponding LogRecord is created and forwarded
* to all the registered output Handler objects.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param msg The string message (or a key in the message catalog)
* @param param1 parameter to the message
*/
@@ -553,7 +555,7 @@ public class Logger {
* level then a corresponding LogRecord is created and forwarded
* to all the registered output Handler objects.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param msg The string message (or a key in the message catalog)
* @param params array of parameters to the message
*/
@@ -578,7 +580,7 @@ public class Logger {
* processed specially by output Formatters and is not treated
* as a formatting parameter to the LogRecord message property.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param msg The string message (or a key in the message catalog)
* @param thrown Throwable associated with log message.
*/
@@ -603,7 +605,7 @@ public class Logger {
* level then the given message is forwarded to all the
* registered output Handler objects.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param sourceClass name of class that issued the logging request
* @param sourceMethod name of method that issued the logging request
* @param msg The string message (or a key in the message catalog)
@@ -626,7 +628,7 @@ public class Logger {
* level then a corresponding LogRecord is created and forwarded
* to all the registered output Handler objects.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param sourceClass name of class that issued the logging request
* @param sourceMethod name of method that issued the logging request
* @param msg The string message (or a key in the message catalog)
@@ -653,7 +655,7 @@ public class Logger {
* level then a corresponding LogRecord is created and forwarded
* to all the registered output Handler objects.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param sourceClass name of class that issued the logging request
* @param sourceMethod name of method that issued the logging request
* @param msg The string message (or a key in the message catalog)
@@ -684,7 +686,7 @@ public class Logger {
* processed specially by output Formatters and is not treated
* as a formatting parameter to the LogRecord message property.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param sourceClass name of class that issued the logging request
* @param sourceMethod name of method that issued the logging request
* @param msg The string message (or a key in the message catalog)
@@ -731,7 +733,7 @@ public class Logger {
* resource bundle name is null, or an empty String or invalid
* then the msg string is not localized.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param sourceClass name of class that issued the logging request
* @param sourceMethod name of method that issued the logging request
* @param bundleName name of resource bundle to localize msg,
@@ -762,7 +764,7 @@ public class Logger {
* resource bundle name is null, or an empty String or invalid
* then the msg string is not localized.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param sourceClass name of class that issued the logging request
* @param sourceMethod name of method that issued the logging request
* @param bundleName name of resource bundle to localize msg,
@@ -795,7 +797,7 @@ public class Logger {
* resource bundle name is null, or an empty String or invalid
* then the msg string is not localized.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param sourceClass name of class that issued the logging request
* @param sourceMethod name of method that issued the logging request
* @param bundleName name of resource bundle to localize msg,
@@ -832,7 +834,7 @@ public class Logger {
* processed specially by output Formatters and is not treated
* as a formatting parameter to the LogRecord message property.
*
- * @param level One of the message level identifiers, e.g. SEVERE
+ * @param level One of the message level identifiers, e.g., SEVERE
* @param sourceClass name of class that issued the logging request
* @param sourceMethod name of method that issued the logging request
* @param bundleName name of resource bundle to localize msg,
@@ -1214,7 +1216,7 @@ public class Logger {
/**
* Specify whether or not this logger should send its output
- * to it's parent Logger. This means that any LogRecords will
+ * to its parent Logger. This means that any LogRecords will
* also be written to the parent's Handlers, and potentially
* to its parent, recursively up the namespace.
*
diff --git a/jdk/src/share/classes/java/util/logging/LoggingMXBean.java b/jdk/src/share/classes/java/util/logging/LoggingMXBean.java
index cb67d7b4fb0..a3abe3c69b1 100644
--- a/jdk/src/share/classes/java/util/logging/LoggingMXBean.java
+++ b/jdk/src/share/classes/java/util/logging/LoggingMXBean.java
@@ -105,8 +105,8 @@ public interface LoggingMXBean extends PlatformManagedObject {
*
* @param loggerName The name of the Logger to be set.
* Must be non-null.
- * @param levelName The name of the level to set the specified logger to,
- * or null if to set the level to inherit
+ * @param levelName The name of the level to set on the specified logger,
+ * or null if setting the level to inherit
* from its nearest ancestor.
*
* @throws IllegalArgumentException if the specified logger
diff --git a/jdk/src/share/classes/java/util/logging/MemoryHandler.java b/jdk/src/share/classes/java/util/logging/MemoryHandler.java
index d812e3bf64f..aa632223667 100644
--- a/jdk/src/share/classes/java/util/logging/MemoryHandler.java
+++ b/jdk/src/share/classes/java/util/logging/MemoryHandler.java
@@ -136,7 +136,7 @@ public class MemoryHandler extends Handler {
* @param size the number of log records to buffer (must be greater than zero)
* @param pushLevel message level to push on
*
- * @throws IllegalArgumentException is size is <= 0
+ * @throws IllegalArgumentException if size is <= 0
*/
public MemoryHandler(Handler target, int size, Level pushLevel) {
if (target == null || pushLevel == null) {
@@ -258,7 +258,7 @@ public class MemoryHandler extends Handler {
* This method checks if the LogRecord has an appropriate level and
* whether it satisfies any Filter. However it does not
* check whether the LogRecord would result in a "push" of the
- * buffer contents. It will return false if the LogRecord is Null.
+ * buffer contents. It will return false if the LogRecord is null.
*
* @param record a LogRecord
* @return true if the LogRecord would be logged.
diff --git a/jdk/src/share/classes/java/util/logging/StreamHandler.java b/jdk/src/share/classes/java/util/logging/StreamHandler.java
index 766142a1a58..ce47fe90427 100644
--- a/jdk/src/share/classes/java/util/logging/StreamHandler.java
+++ b/jdk/src/share/classes/java/util/logging/StreamHandler.java
@@ -220,7 +220,7 @@ public class StreamHandler extends Handler {
*
* This method checks if the LogRecord has an appropriate level and
* whether it satisfies any Filter. It will also return false if
- * no output stream has been assigned yet or the LogRecord is Null.
+ * no output stream has been assigned yet or the LogRecord is null.
*
* @param record a LogRecord
* @return true if the LogRecord would be logged.
diff --git a/jdk/src/share/classes/java/util/zip/ZipEntry.java b/jdk/src/share/classes/java/util/zip/ZipEntry.java
index cba69b0c1a2..8da5a4f54ad 100644
--- a/jdk/src/share/classes/java/util/zip/ZipEntry.java
+++ b/jdk/src/share/classes/java/util/zip/ZipEntry.java
@@ -26,6 +26,7 @@
package java.util.zip;
import java.util.Date;
+import sun.misc.BootClassLoaderHook;
/**
* This class is used to represent a ZIP file entry.
@@ -109,12 +110,16 @@ class ZipEntry implements ZipConstants, Cloneable {
* @see #getTime()
*/
public void setTime(long time) {
- // fix for bug 6625963: we bypass time calculations while Kernel is
- // downloading bundles, since they aren't necessary and would cause
- // the Kernel core to depend upon the (very large) time zone data
- if (sun.misc.VM.isBootedKernelVM() &&
- sun.jkernel.DownloadManager.isCurrentThreadDownloading()) {
- this.time = sun.jkernel.DownloadManager.KERNEL_STATIC_MODTIME;
+ // Same value as defined in sun.jkernel.DownloadManager.KERNEL_STATIC_MODTIME
+ // to avoid direct reference to DownoadManager class. Need to revisit
+ // if this is needed any more (see comment in the DownloadManager class)
+ final int KERNEL_STATIC_MODTIME = 10000000;
+ BootClassLoaderHook hook = BootClassLoaderHook.getHook();
+ if (hook != null && hook.isCurrentThreadPrefetching()) {
+ // fix for bug 6625963: we bypass time calculations while Kernel is
+ // downloading bundles, since they aren't necessary and would cause
+ // the Kernel core to depend upon the (very large) time zone data
+ this.time = KERNEL_STATIC_MODTIME;
} else {
this.time = javaToDosTime(time);
}
@@ -253,14 +258,10 @@ class ZipEntry implements ZipConstants, Cloneable {
* the first 0xFFFF bytes are output to the ZIP file entry.
*
* @param comment the comment string
- * @exception IllegalArgumentException if the length of the specified
- * comment string is greater than 0xFFFF bytes
+ *
* @see #getComment()
*/
public void setComment(String comment) {
- if (comment != null && comment.length() > 0xffff) {
- throw new IllegalArgumentException("invalid entry comment length");
- }
this.comment = comment;
}
diff --git a/jdk/src/share/classes/java/util/zip/ZipFile.java b/jdk/src/share/classes/java/util/zip/ZipFile.java
index 76c270c1b10..583d7dcfe1a 100644
--- a/jdk/src/share/classes/java/util/zip/ZipFile.java
+++ b/jdk/src/share/classes/java/util/zip/ZipFile.java
@@ -195,7 +195,10 @@ class ZipFile implements ZipConstants, Closeable {
if (charset == null)
throw new NullPointerException("charset is null");
this.zc = ZipCoder.get(charset);
+ long t0 = System.nanoTime();
jzfile = open(name, mode, file.lastModified());
+ sun.misc.PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0);
+ sun.misc.PerfCounter.getZipFileCount().increment();
this.name = name;
this.total = getTotal(jzfile);
}
diff --git a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java
index 2d13d835c1b..f3e79555ba1 100644
--- a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java
+++ b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java
@@ -168,8 +168,8 @@ import javax.sql.rowset.serial.*;
* The majority of methods for setting placeholder parameters take two parameters,
* with the first parameter
* indicating which placeholder parameter is to be set, and the second parameter
- * giving the value to be set. Methods such as getInt,
- * getString, getBoolean, and getLong fall into
+ * giving the value to be set. Methods such as setInt,
+ * setString, setBoolean, and setLong fall into
* this category. After these methods have been called, a call to the method
* getParams will return an array with the values that have been set. Each
* element in the array is an Object instance representing the
@@ -3259,9 +3259,9 @@ public static final int ASCII_STREAM_PARAM = 2;
* @param x the parameter value
* @exception SQLException if a database access error occurs or
* this method is called on a closed CallableStatement
- * @see #getBoolean
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
+ * @see #getParams
* @since 1.4
*/
public void setBoolean(String parameterName, boolean x) throws SQLException{
@@ -3281,7 +3281,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getByte
+ * @see #getParams
* @since 1.4
*/
public void setByte(String parameterName, byte x) throws SQLException{
@@ -3301,7 +3301,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getShort
+ * @see #getParams
* @since 1.4
*/
public void setShort(String parameterName, short x) throws SQLException{
@@ -3320,7 +3320,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getInt
+ * @see #getParams
* @since 1.4
*/
public void setInt(String parameterName, int x) throws SQLException{
@@ -3339,7 +3339,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getLong
+ * @see #getParams
* @since 1.4
*/
public void setLong(String parameterName, long x) throws SQLException{
@@ -3358,7 +3358,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getFloat
+ * @see #getParams
* @since 1.4
*/
public void setFloat(String parameterName, float x) throws SQLException{
@@ -3377,7 +3377,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getDouble
+ * @see #getParams
* @since 1.4
*/
public void setDouble(String parameterName, double x) throws SQLException{
@@ -3398,7 +3398,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getBigDecimal
+ * @see #getParams
* @since 1.4
*/
public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException{
@@ -3421,7 +3421,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getString
+ * @see #getParams
* @since 1.4
*/
public void setString(String parameterName, String x) throws SQLException{
@@ -3443,7 +3443,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getBytes
+ * @see #getParams
* @since 1.4
*/
public void setBytes(String parameterName, byte x[]) throws SQLException{
@@ -3464,7 +3464,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getTimestamp
+ * @see #getParams
* @since 1.4
*/
public void setTimestamp(String parameterName, java.sql.Timestamp x)
@@ -3712,7 +3712,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* or STRUCT data type and the JDBC driver does not support
* this data type
* @see Types
- * @see #getObject
+ * @see #getParams
* @since 1.4
*/
public void setObject(String parameterName, Object x, int targetSqlType, int scale)
@@ -3740,7 +3740,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* REF, ROWID, SQLXML
* or STRUCT data type and the JDBC driver does not support
* this data type
- * @see #getObject
+ * @see #getParams
* @since 1.4
*/
public void setObject(String parameterName, Object x, int targetSqlType)
@@ -3782,7 +3782,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* Object parameter is ambiguous
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getObject
+ * @see #getParams
* @since 1.4
*/
public void setObject(String parameterName, Object x) throws SQLException{
@@ -4064,7 +4064,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getDate
+ * @see #getParams
* @since 1.4
*/
public void setDate(String parameterName, java.sql.Date x)
@@ -4091,7 +4091,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getDate
+ * @see #getParams
* @since 1.4
*/
public void setDate(String parameterName, java.sql.Date x, Calendar cal)
@@ -4111,7 +4111,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getTime
+ * @see #getParams
* @since 1.4
*/
public void setTime(String parameterName, java.sql.Time x)
@@ -4138,7 +4138,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getTime
+ * @see #getParams
* @since 1.4
*/
public void setTime(String parameterName, java.sql.Time x, Calendar cal)
@@ -4165,7 +4165,7 @@ public static final int ASCII_STREAM_PARAM = 2;
* this method is called on a closed CallableStatement
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
- * @see #getTimestamp
+ * @see #getParams
* @since 1.4
*/
public void setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal)
diff --git a/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java b/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java
index eb230a09050..faeae5f527e 100644
--- a/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java
+++ b/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java
@@ -32,7 +32,6 @@ import java.lang.reflect.*;
import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.util.*;
-import java.util.logging.*;
import com.sun.java.swing.SwingUtilities3;
@@ -41,6 +40,7 @@ import sun.java2d.SunGraphics2D;
import sun.security.action.GetPropertyAction;
import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
import sun.awt.SunToolkit;
+import sun.util.logging.PlatformLogger;
/**
* A PaintManager implementation that uses a BufferStrategy for
@@ -78,7 +78,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
private static Method COMPONENT_CREATE_BUFFER_STRATEGY_METHOD;
private static Method COMPONENT_GET_BUFFER_STRATEGY_METHOD;
- private static final Logger LOGGER = Logger.getLogger(
+ private static final PlatformLogger LOGGER = PlatformLogger.getLogger(
"javax.swing.BufferStrategyPaintManager");
/**
@@ -222,9 +222,9 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
}
private void dispose(java.util.List bufferInfos) {
- if (LOGGER.isLoggable(Level.FINER)) {
- LOGGER.log(Level.FINER, "BufferStrategyPaintManager disposed",
- new RuntimeException());
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
+ LOGGER.finer("BufferStrategyPaintManager disposed",
+ new RuntimeException());
}
if (bufferInfos != null) {
for (BufferInfo bufferInfo : bufferInfos) {
@@ -305,7 +305,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
}
}
// Invalid root, do what Swing has always done.
- if (LOGGER.isLoggable(Level.FINER)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
LOGGER.finer("prepare failed");
}
return super.paint(paintingComponent, bufferComponent, g, x, y, w, h);
@@ -335,7 +335,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
}
accumulate(x + xOffset + deltaX, y + yOffset + deltaY, w, h);
} else {
- if (LOGGER.isLoggable(Level.FINER)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
LOGGER.finer("copyArea: prepare failed or not in sync");
}
// Prepare failed, or not in sync. By calling super.copyArea
@@ -363,7 +363,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
}
}
}
- if (LOGGER.isLoggable(Level.FINEST)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINEST)) {
LOGGER.finest("beginPaint");
}
// Reset the area that needs to be painted.
@@ -371,7 +371,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
}
public void endPaint() {
- if (LOGGER.isLoggable(Level.FINEST)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINEST)) {
LOGGER.finest("endPaint: region " + accumulatedX + " " +
accumulatedY + " " + accumulatedMaxX + " " +
accumulatedMaxY);
@@ -420,7 +420,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
contentsLost = bufferStrategy.contentsLost();
}
if (contentsLost) {
- if (LOGGER.isLoggable(Level.FINER)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
LOGGER.finer("endPaint: contents lost");
}
// Shown region was bogus, mark buffer as out of sync.
@@ -514,7 +514,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
contentsLost = true;
bufferInfo = new BufferInfo(root);
bufferInfos.add(bufferInfo);
- if (LOGGER.isLoggable(Level.FINER)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
LOGGER.finer("prepare: new BufferInfo: " + root);
}
}
@@ -525,7 +525,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
bsg = bufferStrategy.getDrawGraphics();
if (bufferStrategy.contentsRestored()) {
contentsLost = true;
- if (LOGGER.isLoggable(Level.FINER)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
LOGGER.finer(
"prepare: contents restored in prepare");
}
@@ -539,7 +539,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
if (bufferInfo.getContentsLostDuringExpose()) {
contentsLost = true;
bufferInfo.setContentsLostDuringExpose(false);
- if (LOGGER.isLoggable(Level.FINER)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
LOGGER.finer("prepare: contents lost on expose");
}
}
@@ -642,7 +642,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
if (biRoot == null) {
// Window gc'ed
bufferInfos.remove(counter);
- if (LOGGER.isLoggable(Level.FINER)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
LOGGER.finer("BufferInfo pruned, root null");
}
}
@@ -748,7 +748,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
if (bs != null) {
weakBS = new WeakReference(bs);
}
- if (LOGGER.isLoggable(Level.FINER)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
LOGGER.finer("getBufferStrategy: created bs: " + bs);
}
}
@@ -806,7 +806,7 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
BufferStrategy bs = null;
if (SwingUtilities3.isVsyncRequested(root)) {
bs = createBufferStrategy(root, true);
- if (LOGGER.isLoggable(Level.FINER)) {
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
LOGGER.finer("createBufferStrategy: using vsynced strategy");
}
}
@@ -848,9 +848,9 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
invoke(root);
} catch (InvocationTargetException ite) {
// Type is not supported
- if (LOGGER.isLoggable(Level.FINER)) {
- LOGGER.log(Level.FINER, "createBufferStratety failed",
- ite);
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
+ LOGGER.finer("createBufferStratety failed",
+ ite);
}
} catch (IllegalArgumentException iae) {
assert false;
@@ -864,9 +864,9 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
bs = ((Window)root).getBufferStrategy();
} catch (AWTException e) {
// Type not supported
- if (LOGGER.isLoggable(Level.FINER)) {
- LOGGER.log(Level.FINER, "createBufferStratety failed",
- e);
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
+ LOGGER.finer("createBufferStratety failed",
+ e);
}
}
}
@@ -878,8 +878,8 @@ class BufferStrategyPaintManager extends RepaintManager.PaintManager {
*/
public void dispose() {
Container root = getRoot();
- if (LOGGER.isLoggable(Level.FINER)) {
- LOGGER.log(Level.FINER, "disposed BufferInfo for: " + root);
+ if (LOGGER.isLoggable(PlatformLogger.FINER)) {
+ LOGGER.finer("disposed BufferInfo for: " + root);
}
if (root != null) {
root.removeComponentListener(this);
diff --git a/jdk/src/share/classes/javax/swing/JEditorPane.java b/jdk/src/share/classes/javax/swing/JEditorPane.java
index 21528752fd5..4dfbf92488e 100644
--- a/jdk/src/share/classes/javax/swing/JEditorPane.java
+++ b/jdk/src/share/classes/javax/swing/JEditorPane.java
@@ -24,6 +24,8 @@
*/
package javax.swing;
+import sun.swing.SwingUtilities2;
+
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.*;
@@ -1123,6 +1125,7 @@ public class JEditorPane extends JTextComponent {
* @param content the content to replace the selection with. This
* value can be null
*/
+ @Override
public void replaceSelection(String content) {
if (! isEditable()) {
UIManager.getLookAndFeel().provideErrorFeedback(JEditorPane.this);
@@ -1133,6 +1136,7 @@ public class JEditorPane extends JTextComponent {
try {
Document doc = getDocument();
Caret caret = getCaret();
+ boolean composedTextSaved = saveComposedText(caret.getDot());
int p0 = Math.min(caret.getDot(), caret.getMark());
int p1 = Math.max(caret.getDot(), caret.getMark());
if (doc instanceof AbstractDocument) {
@@ -1148,6 +1152,9 @@ public class JEditorPane extends JTextComponent {
getInputAttributes());
}
}
+ if (composedTextSaved) {
+ restoreComposedText();
+ }
} catch (BadLocationException e) {
UIManager.getLookAndFeel().provideErrorFeedback(JEditorPane.this);
}
@@ -1323,8 +1330,8 @@ public class JEditorPane extends JTextComponent {
*/
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
- if (getParent() instanceof JViewport) {
- JViewport port = (JViewport)getParent();
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
TextUI ui = getUI();
int prefWidth = d.width;
int prefHeight = d.height;
@@ -1445,8 +1452,8 @@ public class JEditorPane extends JTextComponent {
* match its own, false otherwise
*/
public boolean getScrollableTracksViewportWidth() {
- if (getParent() instanceof JViewport) {
- JViewport port = (JViewport)getParent();
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
TextUI ui = getUI();
int w = port.getWidth();
Dimension min = ui.getMinimumSize(this);
@@ -1467,8 +1474,8 @@ public class JEditorPane extends JTextComponent {
* false otherwise
*/
public boolean getScrollableTracksViewportHeight() {
- if (getParent() instanceof JViewport) {
- JViewport port = (JViewport)getParent();
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
TextUI ui = getUI();
int h = port.getHeight();
Dimension min = ui.getMinimumSize(this);
diff --git a/jdk/src/share/classes/javax/swing/JFileChooser.java b/jdk/src/share/classes/javax/swing/JFileChooser.java
index 8ba9c7c42af..dae4a1ce599 100644
--- a/jdk/src/share/classes/javax/swing/JFileChooser.java
+++ b/jdk/src/share/classes/javax/swing/JFileChooser.java
@@ -715,7 +715,7 @@ public class JFileChooser extends JComponent implements Accessible {
*
*
JFileChooser.CANCEL_OPTION
*
JFileChooser.APPROVE_OPTION
- *
JFileCHooser.ERROR_OPTION if an error occurs or the
+ *
JFileChooser.ERROR_OPTION if an error occurs or the
* dialog is dismissed
*
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
@@ -724,6 +724,11 @@ public class JFileChooser extends JComponent implements Accessible {
*/
public int showDialog(Component parent, String approveButtonText)
throws HeadlessException {
+ if (dialog != null) {
+ // Prevent to show second instance of dialog if the previous one still exists
+ return JFileChooser.ERROR_OPTION;
+ }
+
if(approveButtonText != null) {
setApproveButtonText(approveButtonText);
setDialogType(CUSTOM_DIALOG);
diff --git a/jdk/src/share/classes/javax/swing/JLayer.java b/jdk/src/share/classes/javax/swing/JLayer.java
index b8cc69e9bcd..93f4b799722 100644
--- a/jdk/src/share/classes/javax/swing/JLayer.java
+++ b/jdk/src/share/classes/javax/swing/JLayer.java
@@ -1,6 +1,26 @@
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ * Copyright 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
+ * 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 javax.swing;
@@ -36,28 +56,70 @@ import java.security.PrivilegedAction;
* {@code JLayer} is a good solution if you only need to do custom painting
* over compound component or catch input events from its subcomponents.
*
+ * import javax.swing.*;
+ * import javax.swing.plaf.LayerUI;
+ * import java.awt.*;
+ *
+ * public class JLayerSample {
+ *
+ * private static JLayer<JComponent> createLayer() {
+ * // This custom layerUI will fill the layer with translucent green
+ * // and print out all mouseMotion events generated within its borders
+ * LayerUI<JComponent> layerUI = new LayerUI<JComponent>() {
+ *
+ * public void paint(Graphics g, JComponent c) {
+ * // paint the layer as is
+ * super.paint(g, c);
+ * // fill it with the translucent green
+ * g.setColor(new Color(0, 128, 0, 128));
+ * g.fillRect(0, 0, c.getWidth(), c.getHeight());
+ * }
+ *
+ * public void installUI(JComponent c) {
+ * super.installUI(c);
+ * // enable mouse motion events for the layer's subcomponents
+ * ((JLayer) c).setLayerEventMask(AWTEvent.MOUSE_MOTION_EVENT_MASK);
+ * }
+ *
+ * public void uninstallUI(JComponent c) {
+ * super.uninstallUI(c);
+ * // reset the layer event mask
+ * ((JLayer) c).setLayerEventMask(0);
+ * }
+ *
+ * // overridden method which catches MouseMotion events
+ * public void eventDispatched(AWTEvent e, JLayer<? extends JComponent> l) {
+ * System.out.println("AWTEvent detected: " + e);
+ * }
+ * };
* // create a component to be decorated with the layer
- * JPanel panel = new JPanel();
- * panel.add(new JButton("JButton"));
- * // This custom layerUI will fill the layer with translucent green
- * // and print out all mouseMotion events generated within its borders
- * LayerUI<JPanel> layerUI = new LayerUI<JPanel>() {
- * public void paint(Graphics g, JCompo nent c) {
- * // paint the layer as is
- * super.paint(g, c);
- * // fill it with the translucent green
- * g.setColor(new Color(0, 128, 0, 128));
- * g.fillRect(0, 0, c.getWidth(), c.getHeight());
- * }
- * // overridden method which catches MouseMotion events
- * public void eventDispatched(AWTEvent e, JLayer<JPanel> l) {
- * System.out.println("AWTEvent detected: " + e);
- * }
- * };
- * // create the layer for the panel using our custom layerUI
- * JLayer<JPanel> layer = new JLayer<JPanel>(panel, layerUI);
- * // work with the layer as with any other Swing component
- * frame.add(layer);
+ * JPanel panel = new JPanel();
+ * panel.add(new JButton("JButton"));
+ *
+ * // create the layer for the panel using our custom layerUI
+ * return new JLayer<JComponent>(panel, layerUI);
+ * }
+ *
+ * private static void createAndShowGUI() {
+ * final JFrame frame = new JFrame();
+ * frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ *
+ * // work with the layer as with any other Swing component
+ * frame.add(createLayer());
+ *
+ * frame.setSize(200, 200);
+ * frame.setLocationRelativeTo(null);
+ * frame.setVisible(true);
+ * }
+ *
+ * public static void main(String[] args) throws Exception {
+ * SwingUtilities.invokeAndWait(new Runnable() {
+ * public void run() {
+ * createAndShowGUI();
+ * }
+ * });
+ * }
+ * }
*
*
* Note: {@code JLayer} doesn't support the following methods:
@@ -158,7 +220,7 @@ public final class JLayer
* @return the {@code JLayer}'s view component
* or {@code null} if none exists
*
- * @see #setView(V)
+ * @see #setView(Component)
*/
public V getView() {
return view;
@@ -259,7 +321,7 @@ public final class JLayer
* @throws UnsupportedOperationException this method is not supported
*
* @see #setView(Component)
- * @see #setGlassPane(Component)
+ * @see #setGlassPane(JPanel)
*/
protected void addImpl(Component comp, Object constraints, int index) {
throw new UnsupportedOperationException(
@@ -271,7 +333,9 @@ public final class JLayer
* {@inheritDoc}
*/
public void remove(Component comp) {
- if (comp == getView()) {
+ if (comp == null) {
+ super.remove(comp);
+ } else if (comp == getView()) {
setView(null);
} else if (comp == getGlassPane()) {
setGlassPane(null);
@@ -319,7 +383,7 @@ public final class JLayer
* @return false if {@code JLayer}'s {@code glassPane} is visible
*/
public boolean isOptimizedDrawingEnabled() {
- return !glassPane.isVisible();
+ return glassPane == null || !glassPane.isVisible();
}
/**
@@ -388,7 +452,10 @@ public final class JLayer
if (layerEventMask != oldEventMask) {
disableEvents(oldEventMask);
enableEvents(eventMask);
- eventController.updateAWTEventListener(this);
+ if (isDisplayable()) {
+ eventController.updateAWTEventListener(
+ oldEventMask, layerEventMask);
+ }
}
}
@@ -475,9 +542,6 @@ public final class JLayer
if (getUI() != null) {
return getUI().getScrollableTracksViewportHeight(this);
}
- if (getParent() instanceof JViewport) {
- return ((getParent()).getHeight() > getPreferredSize().height);
- }
return false;
}
@@ -498,9 +562,6 @@ public final class JLayer
if (getUI() != null) {
return getUI().getScrollableTracksViewportWidth(this);
}
- if (getParent() instanceof JViewport) {
- return ((getParent()).getWidth() > getPreferredSize().width);
- }
return false;
}
@@ -535,20 +596,36 @@ public final class JLayer
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
- if (getUI() != null) {
- setUI(getUI());
+ if (layerUI != null) {
+ setUI(layerUI);
}
- if (getLayerEventMask() != 0) {
- eventController.updateAWTEventListener(this);
+ if (eventMask != 0) {
+ eventController.updateAWTEventListener(0, eventMask);
}
}
+ /**
+ * {@inheritDoc}
+ */
+ public void addNotify() {
+ super.addNotify();
+ eventController.updateAWTEventListener(0, eventMask);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeNotify() {
+ super.removeNotify();
+ eventController.updateAWTEventListener(eventMask, 0);
+ }
+
/**
* static AWTEventListener to be shared with all AbstractLayerUIs
*/
private static class LayerEventController implements AWTEventListener {
- private ArrayList> layerList =
- new ArrayList>();
+ private ArrayList layerMaskList =
+ new ArrayList();
private long currentEventMask;
@@ -572,37 +649,24 @@ public final class JLayer
}
}
- private boolean layerListContains(JLayer l) {
- for (WeakReference layerWeakReference : layerList) {
- if (layerWeakReference.get() == l) {
- return true;
- }
+ private void updateAWTEventListener(long oldEventMask, long newEventMask) {
+ if (oldEventMask != 0) {
+ layerMaskList.remove(oldEventMask);
}
- return false;
- }
-
- private void updateAWTEventListener(JLayer layer) {
- if (!layerListContains(layer) && layer.getLayerEventMask() != 0) {
- layerList.add(new WeakReference(layer));
+ if (newEventMask != 0) {
+ layerMaskList.add(newEventMask);
}
long combinedMask = 0;
- Iterator> it = layerList.iterator();
- while (it.hasNext()) {
- WeakReference weakRef = it.next();
- JLayer currLayer = weakRef.get();
- if (currLayer == null) {
- it.remove();
- } else {
- combinedMask |= currLayer.getLayerEventMask();
- }
+ for (Long mask : layerMaskList) {
+ combinedMask |= mask;
}
if (combinedMask == 0) {
removeAWTEventListener();
- layerList.clear();
} else if (getCurrentEventMask() != combinedMask) {
removeAWTEventListener();
addAWTEventListener(combinedMask);
}
+ currentEventMask = combinedMask;
}
private long getCurrentEventMask() {
@@ -617,7 +681,7 @@ public final class JLayer
return null;
}
});
- currentEventMask = eventMask;
+
}
private void removeAWTEventListener() {
@@ -628,7 +692,6 @@ public final class JLayer
return null;
}
});
- currentEventMask = 0;
}
private boolean isEventEnabled(long eventMask, int id) {
@@ -785,4 +848,4 @@ public final class JLayer
public void removeLayoutComponent(Component comp) {
}
}
-}
\ No newline at end of file
+}
diff --git a/jdk/src/share/classes/javax/swing/JList.java b/jdk/src/share/classes/javax/swing/JList.java
index 772c7554056..796ac11ba6c 100644
--- a/jdk/src/share/classes/javax/swing/JList.java
+++ b/jdk/src/share/classes/javax/swing/JList.java
@@ -2722,8 +2722,9 @@ public class JList extends JComponent implements Scrollable, Accessible
getVisibleRowCount() <= 0) {
return true;
}
- if (getParent() instanceof JViewport) {
- return (getParent().getWidth() > getPreferredSize().width);
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
+ return port.getWidth() > getPreferredSize().width;
}
return false;
}
@@ -2747,8 +2748,9 @@ public class JList extends JComponent implements Scrollable, Accessible
getVisibleRowCount() <= 0) {
return true;
}
- if (getParent() instanceof JViewport) {
- return (getParent().getHeight() > getPreferredSize().height);
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
+ return port.getHeight() > getPreferredSize().height;
}
return false;
}
diff --git a/jdk/src/share/classes/javax/swing/JPopupMenu.java b/jdk/src/share/classes/javax/swing/JPopupMenu.java
index 8f90a02a2a9..78715b886be 100644
--- a/jdk/src/share/classes/javax/swing/JPopupMenu.java
+++ b/jdk/src/share/classes/javax/swing/JPopupMenu.java
@@ -412,7 +412,7 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(
- SecurityConstants.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
+ SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION);
}
} catch (SecurityException se) {
// There is no permission to show popups over the task bar
diff --git a/jdk/src/share/classes/javax/swing/JTable.java b/jdk/src/share/classes/javax/swing/JTable.java
index dc9adebc4d4..521f17ab8a5 100644
--- a/jdk/src/share/classes/javax/swing/JTable.java
+++ b/jdk/src/share/classes/javax/swing/JTable.java
@@ -718,9 +718,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #addNotify
*/
protected void configureEnclosingScrollPane() {
- Container p = getParent();
- if (p instanceof JViewport) {
- Container gp = p.getParent();
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
+ Container gp = port.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)gp;
// Make certain we are the viewPort's view and not, for
@@ -750,9 +750,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* from configureEnclosingScrollPane() and updateUI() in a safe manor.
*/
private void configureEnclosingScrollPaneUI() {
- Container p = getParent();
- if (p instanceof JViewport) {
- Container gp = p.getParent();
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
+ Container gp = port.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)gp;
// Make certain we are the viewPort's view and not, for
@@ -819,9 +819,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @since 1.3
*/
protected void unconfigureEnclosingScrollPane() {
- Container p = getParent();
- if (p instanceof JViewport) {
- Container gp = p.getParent();
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
+ Container gp = port.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)gp;
// Make certain we are the viewPort's view and not, for
@@ -5215,9 +5215,10 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #getFillsViewportHeight
*/
public boolean getScrollableTracksViewportHeight() {
+ JViewport port = SwingUtilities2.getViewport(this);
return getFillsViewportHeight()
- && getParent() instanceof JViewport
- && (getParent().getHeight() > getPreferredSize().height);
+ && port != null
+ && port.getHeight() > getPreferredSize().height;
}
/**
diff --git a/jdk/src/share/classes/javax/swing/JTextField.java b/jdk/src/share/classes/javax/swing/JTextField.java
index c104f36ec98..de408914d22 100644
--- a/jdk/src/share/classes/javax/swing/JTextField.java
+++ b/jdk/src/share/classes/javax/swing/JTextField.java
@@ -24,6 +24,8 @@
*/
package javax.swing;
+import sun.swing.SwingUtilities2;
+
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
@@ -288,11 +290,7 @@ public class JTextField extends JTextComponent implements SwingConstants {
* @see JComponent#isValidateRoot
*/
public boolean isValidateRoot() {
- Component parent = getParent();
- if (parent instanceof JViewport) {
- return false;
- }
- return true;
+ return SwingUtilities2.getViewport(this) == null;
}
diff --git a/jdk/src/share/classes/javax/swing/JTextPane.java b/jdk/src/share/classes/javax/swing/JTextPane.java
index efb339bd59f..7f113ddd59c 100644
--- a/jdk/src/share/classes/javax/swing/JTextPane.java
+++ b/jdk/src/share/classes/javax/swing/JTextPane.java
@@ -170,6 +170,7 @@ public class JTextPane extends JEditorPane {
*
* @param content the content to replace the selection with
*/
+ @Override
public void replaceSelection(String content) {
replaceSelection(content, true);
}
@@ -183,6 +184,7 @@ public class JTextPane extends JEditorPane {
if (doc != null) {
try {
Caret caret = getCaret();
+ boolean composedTextSaved = saveComposedText(caret.getDot());
int p0 = Math.min(caret.getDot(), caret.getMark());
int p1 = Math.max(caret.getDot(), caret.getMark());
AttributeSet attr = getInputAttributes().copyAttributes();
@@ -197,6 +199,9 @@ public class JTextPane extends JEditorPane {
doc.insertString(p0, content, attr);
}
}
+ if (composedTextSaved) {
+ restoreComposedText();
+ }
} catch (BadLocationException e) {
UIManager.getLookAndFeel().provideErrorFeedback(JTextPane.this);
}
diff --git a/jdk/src/share/classes/javax/swing/JTree.java b/jdk/src/share/classes/javax/swing/JTree.java
index 639dd45e8f9..1b200f78591 100644
--- a/jdk/src/share/classes/javax/swing/JTree.java
+++ b/jdk/src/share/classes/javax/swing/JTree.java
@@ -3498,8 +3498,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportWidth
*/
public boolean getScrollableTracksViewportWidth() {
- if (getParent() instanceof JViewport) {
- return getParent().getWidth() > getPreferredSize().width;
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
+ return port.getWidth() > getPreferredSize().width;
}
return false;
}
@@ -3514,8 +3515,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportHeight
*/
public boolean getScrollableTracksViewportHeight() {
- if (getParent() instanceof JViewport) {
- return getParent().getHeight() > getPreferredSize().height;
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
+ return port.getHeight() > getPreferredSize().height;
}
return false;
}
diff --git a/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java b/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java
index 715732fcee0..c856c8898c3 100644
--- a/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java
+++ b/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java
@@ -29,7 +29,7 @@ import java.awt.Container;
import java.awt.Window;
import java.util.*;
import java.awt.FocusTraversalPolicy;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
/**
* A FocusTraversalPolicy that determines traversal order by sorting the
@@ -64,7 +64,7 @@ public class SortingFocusTraversalPolicy
private Comparator super Component> comparator;
private boolean implicitDownCycleTraversal = true;
- private Logger log = Logger.getLogger("javax.swing.SortingFocusTraversalPolicy");
+ private PlatformLogger log = PlatformLogger.getLogger("javax.swing.SortingFocusTraversalPolicy");
/**
* Used by getComponentAfter and getComponentBefore for efficiency. In
@@ -115,8 +115,8 @@ public class SortingFocusTraversalPolicy
try {
index = Collections.binarySearch(cycle, aComponent, comparator);
} catch (ClassCastException e) {
- if (log.isLoggable(Level.FINE)) {
- log.log(Level.FINE, "### During the binary search for " + aComponent + " the exception occured: ", e);
+ if (log.isLoggable(PlatformLogger.FINE)) {
+ log.fine("### During the binary search for " + aComponent + " the exception occured: ", e);
}
return -1;
}
@@ -193,7 +193,7 @@ public class SortingFocusTraversalPolicy
if (getImplicitDownCycleTraversal()) {
retComp = cont.getFocusTraversalPolicy().getDefaultComponent(cont);
- if (retComp != null && log.isLoggable(Level.FINE)) {
+ if (retComp != null && log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Transfered focus down-cycle to " + retComp +
" in the focus cycle root " + cont);
}
@@ -205,7 +205,7 @@ public class SortingFocusTraversalPolicy
cont.getFocusTraversalPolicy().getDefaultComponent(cont) :
cont.getFocusTraversalPolicy().getLastComponent(cont));
- if (retComp != null && log.isLoggable(Level.FINE)) {
+ if (retComp != null && log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Transfered focus to " + retComp + " in the FTP provider " + cont);
}
}
@@ -236,7 +236,7 @@ public class SortingFocusTraversalPolicy
* aComponent is null
*/
public Component getComponentAfter(Container aContainer, Component aComponent) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Searching in " + aContainer + " for component after " + aComponent);
}
@@ -260,7 +260,7 @@ public class SortingFocusTraversalPolicy
// See if the component is inside of policy provider.
Container provider = getTopmostProvider(aContainer, aComponent);
if (provider != null) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Asking FTP " + provider + " for component after " + aComponent);
}
@@ -271,7 +271,7 @@ public class SortingFocusTraversalPolicy
// Null result means that we overstepped the limit of the FTP's cycle.
// In that case we must quit the cycle, otherwise return the component found.
if (afterComp != null) {
- if (log.isLoggable(Level.FINE)) log.fine("### FTP returned " + afterComp);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### FTP returned " + afterComp);
return afterComp;
}
aComponent = provider;
@@ -279,12 +279,12 @@ public class SortingFocusTraversalPolicy
List cycle = getFocusTraversalCycle(aContainer);
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle + ", component is " + aComponent);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is " + cycle + ", component is " + aComponent);
int index = getComponentIndex(cycle, aComponent);
if (index < 0) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Didn't find component " + aComponent + " in a cycle " + aContainer);
}
return getFirstComponent(aContainer);
@@ -349,7 +349,7 @@ public class SortingFocusTraversalPolicy
// See if the component is inside of policy provider.
Container provider = getTopmostProvider(aContainer, aComponent);
if (provider != null) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Asking FTP " + provider + " for component after " + aComponent);
}
@@ -360,7 +360,7 @@ public class SortingFocusTraversalPolicy
// Null result means that we overstepped the limit of the FTP's cycle.
// In that case we must quit the cycle, otherwise return the component found.
if (beforeComp != null) {
- if (log.isLoggable(Level.FINE)) log.fine("### FTP returned " + beforeComp);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### FTP returned " + beforeComp);
return beforeComp;
}
aComponent = provider;
@@ -373,12 +373,12 @@ public class SortingFocusTraversalPolicy
List cycle = getFocusTraversalCycle(aContainer);
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle + ", component is " + aComponent);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is " + cycle + ", component is " + aComponent);
int index = getComponentIndex(cycle, aComponent);
if (index < 0) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
log.fine("### Didn't find component " + aComponent + " in a cycle " + aContainer);
}
return getLastComponent(aContainer);
@@ -424,7 +424,7 @@ public class SortingFocusTraversalPolicy
public Component getFirstComponent(Container aContainer) {
List cycle;
- if (log.isLoggable(Level.FINE)) log.fine("### Getting first component in " + aContainer);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Getting first component in " + aContainer);
if (aContainer == null) {
throw new IllegalArgumentException("aContainer cannot be null");
}
@@ -436,10 +436,10 @@ public class SortingFocusTraversalPolicy
}
if (cycle.size() == 0) {
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is empty");
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is empty");
return null;
}
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is " + cycle);
for (Component comp : cycle) {
if (accept(comp)) {
@@ -466,7 +466,7 @@ public class SortingFocusTraversalPolicy
*/
public Component getLastComponent(Container aContainer) {
List cycle;
- if (log.isLoggable(Level.FINE)) log.fine("### Getting last component in " + aContainer);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Getting last component in " + aContainer);
if (aContainer == null) {
throw new IllegalArgumentException("aContainer cannot be null");
@@ -479,10 +479,10 @@ public class SortingFocusTraversalPolicy
}
if (cycle.size() == 0) {
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is empty");
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is empty");
return null;
}
- if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("### Cycle is " + cycle);
for (int i= cycle.size() - 1; i >= 0; i--) {
Component comp = cycle.get(i);
diff --git a/jdk/src/share/classes/javax/swing/SwingUtilities.java b/jdk/src/share/classes/javax/swing/SwingUtilities.java
index 21a75ce1d97..d7a26a0dd72 100644
--- a/jdk/src/share/classes/javax/swing/SwingUtilities.java
+++ b/jdk/src/share/classes/javax/swing/SwingUtilities.java
@@ -999,24 +999,20 @@ public class SwingUtilities implements SwingConstants
textR.height = (int) v.getPreferredSpan(View.Y_AXIS);
} else {
textR.width = SwingUtilities2.stringWidth(c, fm, text);
-
- // Take into account the left and right side bearings.
- // This gives more space than it is actually needed,
- // but there are two reasons:
- // 1. If we set the width to the actual bounds,
- // all callers would have to account for the bearings
- // themselves. NOTE: all pref size calculations don't do it.
- // 2. You can do a drawString at the returned location
- // and the text won't be clipped.
lsb = SwingUtilities2.getLeftSideBearing(c, fm, text);
if (lsb < 0) {
+ // If lsb is negative, add it to the width and later
+ // adjust the x location. This gives more space than is
+ // actually needed.
+ // This is done like this for two reasons:
+ // 1. If we set the width to the actual bounds all
+ // callers would have to account for negative lsb
+ // (pref size calculations ONLY look at width of
+ // textR)
+ // 2. You can do a drawString at the returned location
+ // and the text won't be clipped.
textR.width -= lsb;
}
- rsb = SwingUtilities2.getRightSideBearing(c, fm, text);
- if (rsb > 0) {
- textR.width += rsb;
- }
-
if (textR.width > availTextWidth) {
text = SwingUtilities2.clipString(c, fm, text,
availTextWidth);
diff --git a/jdk/src/share/classes/javax/swing/plaf/LayerUI.java b/jdk/src/share/classes/javax/swing/plaf/LayerUI.java
index 44c57ce3cad..cf64687421a 100644
--- a/jdk/src/share/classes/javax/swing/plaf/LayerUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/LayerUI.java
@@ -1,6 +1,26 @@
/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ * Copyright 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
+ * 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 javax.swing.plaf;
@@ -202,6 +222,7 @@ public class LayerUI
* Returns an array of all the listeners which have been associated
* with the named property.
*
+ * @param propertyName The name of the property being listened to
* @return all of the {@code PropertyChangeListener}s associated with
* the named property; if no such listeners have been added or
* if {@code propertyName} is {@code null}, an empty
@@ -242,6 +263,7 @@ public class LayerUI
/**
* Returns the preferred size of the viewport for a view component.
*
+ * @param l the {@code JLayer} component where this UI delegate is being installed
* @return the preferred size of the viewport for a view component
* @see Scrollable#getPreferredScrollableViewportSize()
*/
@@ -257,6 +279,10 @@ public class LayerUI
* that display logical rows or columns in order to completely expose
* one block of rows or columns, depending on the value of orientation.
*
+ * @param l the {@code JLayer} component where this UI delegate is being installed
+ * @param visibleRect The view area visible within the viewport
+ * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
+ * @param direction Less than zero to scroll up/left, greater than zero for down/right.
* @return the "block" increment for scrolling in the specified direction
* @see Scrollable#getScrollableBlockIncrement(Rectangle, int, int)
*/
@@ -276,6 +302,7 @@ public class LayerUI
* determine the height of the layer, unless the preferred height
* of the layer is smaller than the height of the viewport.
*
+ * @param l the {@code JLayer} component where this UI delegate is being installed
* @return whether the layer should track the height of the viewport
* @see Scrollable#getScrollableTracksViewportHeight()
*/
@@ -283,9 +310,6 @@ public class LayerUI
if (l.getView() instanceof Scrollable) {
return ((Scrollable)l.getView()).getScrollableTracksViewportHeight();
}
- if (l.getParent() instanceof JViewport) {
- return (((JViewport)l.getParent()).getHeight() > l.getPreferredSize().height);
- }
return false;
}
@@ -294,6 +318,7 @@ public class LayerUI
* determine the width of the layer, unless the preferred width
* of the layer is smaller than the width of the viewport.
*
+ * @param l the {@code JLayer} component where this UI delegate is being installed
* @return whether the layer should track the width of the viewport
* @see Scrollable
* @see LayerUI#getScrollableTracksViewportWidth(JLayer)
@@ -302,9 +327,6 @@ public class LayerUI
if (l.getView() instanceof Scrollable) {
return ((Scrollable)l.getView()).getScrollableTracksViewportWidth();
}
- if (l.getParent() instanceof JViewport) {
- return (((JViewport)l.getParent()).getWidth() > l.getPreferredSize().width);
- }
return false;
}
@@ -318,6 +340,10 @@ public class LayerUI
* Scrolling containers, like JScrollPane, will use this method
* each time the user requests a unit scroll.
*
+ * @param l the {@code JLayer} component where this UI delegate is being installed
+ * @param visibleRect The view area visible within the viewport
+ * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
+ * @param direction Less than zero to scroll up/left, greater than zero for down/right.
* @return The "unit" increment for scrolling in the specified direction.
* This value should always be positive.
* @see Scrollable#getScrollableUnitIncrement(Rectangle, int, int)
@@ -367,4 +393,4 @@ public class LayerUI
}
return super.getBaselineResizeBehavior(c);
}
-}
\ No newline at end of file
+}
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java
index 80b449ce7c5..3b2fa972e64 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java
@@ -1766,7 +1766,7 @@ public class BasicComboBoxUI extends ComboBoxUI {
}
private boolean isTypeAheadKey( KeyEvent e ) {
- return !e.isAltDown() && !e.isControlDown() && !e.isMetaDown();
+ return !e.isAltDown() && !BasicGraphicsUtils.isMenuShortcutKeyDown(e);
}
//
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java
index a9940321dfc..fca8b933ff4 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java
@@ -483,11 +483,12 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup {
protected JList createList() {
return new JList( comboBox.getModel() ) {
public void processMouseEvent(MouseEvent e) {
- if (e.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
// Fix for 4234053. Filter out the Control Key from the list.
// ie., don't allow CTRL key deselection.
+ Toolkit toolkit = Toolkit.getDefaultToolkit();
e = new MouseEvent((Component)e.getSource(), e.getID(), e.getWhen(),
- e.getModifiers() ^ InputEvent.CTRL_MASK,
+ e.getModifiers() ^ toolkit.getMenuShortcutKeyMask(),
e.getX(), e.getY(),
e.getXOnScreen(), e.getYOnScreen(),
e.getClickCount(),
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
index 44f99d6d3e3..7056676ae04 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -924,7 +924,8 @@ public class BasicFileChooserUI extends FileChooserUI {
boolean isTrav = (selectedFile != null && chooser.isTraversable(selectedFile));
boolean isDirSelEnabled = chooser.isDirectorySelectionEnabled();
boolean isFileSelEnabled = chooser.isFileSelectionEnabled();
- boolean isCtrl = (e != null && (e.getModifiers() & ActionEvent.CTRL_MASK) != 0);
+ boolean isCtrl = (e != null && (e.getModifiers() &
+ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0);
if (isDir && isTrav && (isCtrl || !isDirSelEnabled)) {
changeDirectory(selectedFile);
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java
index 6d831493746..06830129574 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicGraphicsUtils.java
@@ -33,7 +33,10 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
+import java.awt.Toolkit;
import java.awt.event.KeyEvent;
+import java.awt.event.InputEvent;
+
import sun.swing.SwingUtilities2;
@@ -303,4 +306,9 @@ public class BasicGraphicsUtils
static boolean isLeftToRight( Component c ) {
return c.getComponentOrientation().isLeftToRight();
}
+
+ static boolean isMenuShortcutKeyDown(InputEvent event) {
+ return (event.getModifiers() &
+ Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
+ }
}
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java
index 7704d10e102..1d3ee7b3509 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicListUI.java
@@ -2371,8 +2371,9 @@ public class BasicListUI extends ListUI
JList src = (JList)e.getSource();
ListModel model = src.getModel();
- if (model.getSize() == 0 || e.isAltDown() || e.isControlDown() || e.isMetaDown() ||
- isNavigationKey(e)) {
+ if (model.getSize() == 0 || e.isAltDown() ||
+ BasicGraphicsUtils.isMenuShortcutKeyDown(e) ||
+ isNavigationKey(e)) {
// Nothing to select
return;
}
@@ -2665,7 +2666,7 @@ public class BasicListUI extends ListUI
if (row != -1 && DragRecognitionSupport.mousePressed(e)) {
dragPressDidSelection = false;
- if (e.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
// do nothing for control - will be handled on release
// or when drag starts
return;
@@ -2717,7 +2718,7 @@ public class BasicListUI extends ListUI
anchorSelected = list.isSelectedIndex(anchorIndex);
}
- if (e.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
if (e.isShiftDown()) {
if (anchorSelected) {
list.addSelectionInterval(anchorIndex, row);
@@ -2742,7 +2743,7 @@ public class BasicListUI extends ListUI
}
public void dragStarting(MouseEvent me) {
- if (me.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) {
int row = SwingUtilities2.loc2IndexFileList(list, me.getPoint());
list.addSelectionInterval(row, row);
}
@@ -2758,7 +2759,7 @@ public class BasicListUI extends ListUI
return;
}
- if (e.isShiftDown() || e.isControlDown()) {
+ if (e.isShiftDown() || BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
return;
}
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuUI.java
index ba31712eb47..02febb9bf62 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicMenuUI.java
@@ -196,10 +196,6 @@ public class BasicMenuUI extends BasicMenuItemUI
return getHandler();
}
- protected MenuKeyListener createMenuKeyListener(JComponent c) {
- return (MenuKeyListener)getHandler();
- }
-
public Dimension getMaximumSize(JComponent c) {
if (((JMenu)menuItem).isTopLevelMenu() == true) {
Dimension d = c.getPreferredSize();
@@ -401,8 +397,7 @@ public class BasicMenuUI extends BasicMenuItemUI
public void stateChanged(ChangeEvent e) { }
}
- private class Handler extends BasicMenuItemUI.Handler implements
- MenuKeyListener {
+ private class Handler extends BasicMenuItemUI.Handler {
//
// PropertyChangeListener
//
@@ -585,45 +580,5 @@ public class BasicMenuUI extends BasicMenuItemUI
}
public void menuDragMouseExited(MenuDragMouseEvent e) {}
public void menuDragMouseReleased(MenuDragMouseEvent e) {}
-
-
- //
- // MenuKeyListener
- //
- /**
- * Open the Menu
- */
- public void menuKeyTyped(MenuKeyEvent e) {
- if (!crossMenuMnemonic && BasicPopupMenuUI.getLastPopup() != null) {
- // when crossMenuMnemonic is not set, we don't open a toplevel
- // menu if another toplevel menu is already open
- return;
- }
-
- char key = Character.toLowerCase((char)menuItem.getMnemonic());
- MenuElement path[] = e.getPath();
- MenuSelectionManager manager = e.getMenuSelectionManager();
- if (key == Character.toLowerCase(e.getKeyChar())) {
- JPopupMenu popupMenu = ((JMenu)menuItem).getPopupMenu();
- ArrayList newList = new ArrayList(Arrays.asList(path));
- newList.add(popupMenu);
- MenuElement subs[] = popupMenu.getSubElements();
- MenuElement sub =
- BasicPopupMenuUI.findEnabledChild(subs, -1, true);
- if(sub != null) {
- newList.add(sub);
- }
- MenuElement newPath[] = new MenuElement[0];
- newPath = newList.toArray(newPath);
- manager.setSelectedPath(newPath);
- e.consume();
- } else if (((JMenu)menuItem).isTopLevelMenu()
- && BasicPopupMenuUI.getLastPopup() == null) {
- manager.clearSelectedPath();
- }
- }
-
- public void menuKeyPressed(MenuKeyEvent e) {}
- public void menuKeyReleased(MenuKeyEvent e) {}
}
}
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java
index dc94bf547f9..90f983052d0 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java
@@ -339,7 +339,7 @@ public class BasicPopupMenuUI extends PopupMenuUI {
indexes[matches++] = j;
}
}
- if (item.isArmed()) {
+ if (item.isArmed() || item.isSelected()) {
currentIndex = matches - 1;
}
}
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
index 97e2f60f52b..02bb547d318 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
@@ -1507,7 +1507,8 @@ public class BasicSliderUI extends SliderUI{
propertyName == "paintTicks" ||
propertyName == "paintTrack" ||
propertyName == "font" ||
- propertyName == "paintLabels") {
+ propertyName == "paintLabels" ||
+ propertyName == "Slider.paintThumbArrowShape") {
checkedLabelBaselines = false;
calculateGeometry();
slider.repaint();
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java
index 16ceab73ee2..7e85bee803f 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTableUI.java
@@ -1027,7 +1027,7 @@ public class BasicTableUI extends TableUI
shouldStartTimer =
table.isCellSelected(pressedRow, pressedCol) &&
!e.isShiftDown() &&
- !e.isControlDown() &&
+ !BasicGraphicsUtils.isMenuShortcutKeyDown(e) &&
!outsidePrefSize;
}
@@ -1051,7 +1051,7 @@ public class BasicTableUI extends TableUI
dragPressDidSelection = false;
- if (e.isControlDown() && isFileList) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e) && isFileList) {
// do nothing for control - will be handled on release
// or when drag starts
return;
@@ -1115,7 +1115,9 @@ public class BasicTableUI extends TableUI
CellEditor editor = table.getCellEditor();
if (dragEnabled || editor == null || editor.shouldSelectCell(e)) {
- table.changeSelection(pressedRow, pressedCol, e.isControlDown(), e.isShiftDown());
+ table.changeSelection(pressedRow, pressedCol,
+ BasicGraphicsUtils.isMenuShortcutKeyDown(e),
+ e.isShiftDown());
}
}
@@ -1212,7 +1214,7 @@ public class BasicTableUI extends TableUI
public void dragStarting(MouseEvent me) {
dragStarted = true;
- if (me.isControlDown() && isFileList) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(me) && isFileList) {
table.getSelectionModel().addSelectionInterval(pressedRow,
pressedRow);
table.getColumnModel().getSelectionModel().
@@ -1251,7 +1253,8 @@ public class BasicTableUI extends TableUI
return;
}
- table.changeSelection(row, column, e.isControlDown(), true);
+ table.changeSelection(row, column,
+ BasicGraphicsUtils.isMenuShortcutKeyDown(e), true);
}
diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
index 8fdc88d946f..22fa61f00dc 100644
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
@@ -2265,7 +2265,7 @@ public class BasicTreeUI extends TreeUI
*/
protected boolean isToggleSelectionEvent(MouseEvent event) {
return (SwingUtilities.isLeftMouseButton(event) &&
- event.isControlDown());
+ BasicGraphicsUtils.isMenuShortcutKeyDown(event));
}
/**
@@ -3255,7 +3255,7 @@ public class BasicTreeUI extends TreeUI
// handle first letter navigation
if(tree != null && tree.getRowCount()>0 && tree.hasFocus() &&
tree.isEnabled()) {
- if (e.isAltDown() || e.isControlDown() || e.isMetaDown() ||
+ if (e.isAltDown() || BasicGraphicsUtils.isMenuShortcutKeyDown(e) ||
isNavigationKey(e)) {
return;
}
@@ -3511,7 +3511,7 @@ public class BasicTreeUI extends TreeUI
dragPressDidSelection = false;
- if (e.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
// do nothing for control - will be handled on release
// or when drag starts
return;
@@ -3565,7 +3565,7 @@ public class BasicTreeUI extends TreeUI
public void dragStarting(MouseEvent me) {
dragStarted = true;
- if (me.isControlDown()) {
+ if (BasicGraphicsUtils.isMenuShortcutKeyDown(me)) {
tree.addSelectionPath(pressedPath);
setAnchorSelectionPath(pressedPath);
setLeadSelectionPath(pressedPath, true);
diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java
index 8893782d951..831221d57f9 100644
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-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
@@ -25,8 +25,6 @@
package javax.swing.plaf.metal;
import java.awt.*;
-import java.beans.*;
-import javax.swing.*;
/**
* DesktopProperty that only uses font height in configuring font. This
@@ -60,7 +58,7 @@ class MetalFontDesktopProperty extends com.sun.java.swing.plaf.windows.DesktopPr
* @param type MetalTheme font type.
*/
MetalFontDesktopProperty(int type) {
- this(propertyMapping[type], Toolkit.getDefaultToolkit(), type);
+ this(propertyMapping[type], type);
}
/**
@@ -72,8 +70,8 @@ class MetalFontDesktopProperty extends com.sun.java.swing.plaf.windows.DesktopPr
* @param type Type of font being used, corresponds to MetalTheme font
* type.
*/
- MetalFontDesktopProperty(String key, Toolkit kit, int type) {
- super(key, null, kit);
+ MetalFontDesktopProperty(String key, int type) {
+ super(key, null);
this.type = type;
}
diff --git a/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java b/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
index 07432841961..76eb24df040 100644
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1541,10 +1541,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
table.putDefaults(defaults);
if (isWindows() && useSystemFonts() && theme.isSystemTheme()) {
- Toolkit kit = Toolkit.getDefaultToolkit();
Object messageFont = new MetalFontDesktopProperty(
- "win.messagebox.font.height", kit, MetalTheme.
- CONTROL_TEXT_FONT);
+ "win.messagebox.font.height", MetalTheme.CONTROL_TEXT_FONT);
defaults = new Object[] {
"OptionPane.messageFont", messageFont,
diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template b/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template
index 492b53583ed..caff0b212a0 100644
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template
@@ -26,7 +26,7 @@ package ${PACKAGE};
import javax.swing.Painter;
import java.awt.Graphics;
-import sun.font.FontManager;
+import sun.font.FontUtilities;
import sun.swing.plaf.synth.DefaultSynthStyle;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
@@ -101,14 +101,7 @@ final class ${LAF_NAME}Defaults {
*/
private FontUIResource defaultFont;
- /**
- * Map of lists of derived colors keyed by the DerivedColorKeys
- */
- private Map derivedColorsMap =
- new HashMap();
-
- /** Tempory key used for fetching from the derivedColorsMap */
- private final DerivedColorKey tmpDCKey = new DerivedColorKey();
+ private ColorTree colorTree = new ColorTree();
/** Listener for changes to user defaults table */
private DefaultsListener defaultsListener = new DefaultsListener();
@@ -117,14 +110,14 @@ final class ${LAF_NAME}Defaults {
void initialize() {
// add listener for derived colors
UIManager.addPropertyChangeListener(defaultsListener);
- UIManager.getDefaults().addPropertyChangeListener(defaultsListener);
+ UIManager.getDefaults().addPropertyChangeListener(colorTree);
}
/** Called by UIManager when this look and feel is uninstalled. */
void uninitialize() {
// remove listener for derived colors
- UIManager.getDefaults().removePropertyChangeListener(defaultsListener);
UIManager.removePropertyChangeListener(defaultsListener);
+ UIManager.getDefaults().removePropertyChangeListener(colorTree);
}
/**
@@ -138,7 +131,7 @@ final class ${LAF_NAME}Defaults {
//regions and their states that this class will use for later lookup.
//Additional regions can be registered later by 3rd party components.
//These are simply the default registrations.
- defaultFont = FontManager.getFontConfigFUIR("sans", Font.PLAIN, 12);
+ defaultFont = FontUtilities.getFontConfigFUIR("sans", Font.PLAIN, 12);
defaultStyle = new DefaultSynthStyle();
defaultStyle.setFont(defaultFont);
@@ -663,22 +656,23 @@ ${UI_DEFAULT_INIT}
}
}
- /**
- * Get a derived color, derived colors are shared instances and will be
- * updated when its parent UIDefault color changes.
- *
- * @param uiDefaultParentName The parent UIDefault key
- * @param hOffset The hue offset
- * @param sOffset The saturation offset
- * @param bOffset The brightness offset
- * @param aOffset The alpha offset
- * @return The stored derived color
- */
- public DerivedColor getDerivedColor(String uiDefaultParentName,
- float hOffset, float sOffset,
- float bOffset, int aOffset){
- return getDerivedColor(uiDefaultParentName, hOffset, sOffset,
- bOffset, aOffset, true);
+ private void addColor(UIDefaults d, String uin, int r, int g, int b, int a) {
+ Color color = new ColorUIResource(new Color(r, g, b, a));
+ colorTree.addColor(uin, color);
+ d.put(uin, color);
+ }
+
+ private void addColor(UIDefaults d, String uin, String parentUin,
+ float hOffset, float sOffset, float bOffset, int aOffset) {
+ addColor(d, uin, parentUin, hOffset, sOffset, bOffset, aOffset, true);
+ }
+
+ private void addColor(UIDefaults d, String uin, String parentUin,
+ float hOffset, float sOffset, float bOffset,
+ int aOffset, boolean uiResource) {
+ Color color = getDerivedColor(uin, parentUin,
+ hOffset, sOffset, bOffset, aOffset, uiResource);
+ d.put(uin, color);
}
/**
@@ -694,89 +688,110 @@ ${UI_DEFAULT_INIT}
* false if it should not be a UIResource
* @return The stored derived color
*/
- public DerivedColor getDerivedColor(String uiDefaultParentName,
+ public DerivedColor getDerivedColor(String parentUin,
float hOffset, float sOffset,
float bOffset, int aOffset,
boolean uiResource){
- tmpDCKey.set(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset,
- uiResource);
- DerivedColor color = derivedColorsMap.get(tmpDCKey);
- if (color == null){
- if (uiResource) {
- color = new DerivedColor.UIResource(uiDefaultParentName,
- hOffset, sOffset, bOffset, aOffset);
- } else {
- color = new DerivedColor(uiDefaultParentName, hOffset, sOffset,
- bOffset, aOffset);
- }
- // calculate the initial value
- color.rederiveColor();
- // add the listener so that if the color changes we'll propogate it
- color.addPropertyChangeListener(defaultsListener);
- // add to the derived colors table
- derivedColorsMap.put(new DerivedColorKey(uiDefaultParentName,
- hOffset, sOffset, bOffset, aOffset, uiResource),color);
- }
- return color;
+ return getDerivedColor(null, parentUin,
+ hOffset, sOffset, bOffset, aOffset, uiResource);
}
- /**
- * Key class for derived colors
- */
- private class DerivedColorKey {
- private String uiDefaultParentName;
- private float hOffset, sOffset, bOffset;
- private int aOffset;
- private boolean uiResource;
-
- DerivedColorKey(){}
-
- DerivedColorKey(String uiDefaultParentName, float hOffset,
- float sOffset, float bOffset, int aOffset,
- boolean uiResource) {
- set(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset, uiResource);
+ private DerivedColor getDerivedColor(String uin, String parentUin,
+ float hOffset, float sOffset,
+ float bOffset, int aOffset,
+ boolean uiResource) {
+ DerivedColor color;
+ if (uiResource) {
+ color = new DerivedColor.UIResource(parentUin,
+ hOffset, sOffset, bOffset, aOffset);
+ } else {
+ color = new DerivedColor(parentUin, hOffset, sOffset,
+ bOffset, aOffset);
}
- void set (String uiDefaultParentName, float hOffset,
- float sOffset, float bOffset, int aOffset,
- boolean uiResource) {
- this.uiDefaultParentName = uiDefaultParentName;
- this.hOffset = hOffset;
- this.sOffset = sOffset;
- this.bOffset = bOffset;
- this.aOffset = aOffset;
- this.uiResource = uiResource;
+ if (derivedColors.containsKey(color)) {
+ return derivedColors.get(color);
+ } else {
+ derivedColors.put(color, color);
+ color.rederiveColor(); /// move to ARP.decodeColor() ?
+ colorTree.addColor(uin, color);
+ return color;
+ }
+ }
+
+ private Map derivedColors =
+ new HashMap();
+
+ private class ColorTree implements PropertyChangeListener {
+ private Node root = new Node(null, null);
+ private Map nodes = new HashMap();
+
+ public Color getColor(String uin) {
+ return nodes.get(uin).color;
+ }
+
+ public void addColor(String uin, Color color) {
+ Node parent = getParentNode(color);
+ Node node = new Node(color, parent);
+ parent.children.add(node);
+ if (uin != null) {
+ nodes.put(uin, node);
+ }
+ }
+
+ private Node getParentNode(Color color) {
+ Node parent = root;
+ if (color instanceof DerivedColor) {
+ String parentUin = ((DerivedColor)color).getUiDefaultParentName();
+ Node p = nodes.get(parentUin);
+ if (p != null) {
+ parent = p;
+ }
+ }
+ return parent;
+ }
+
+ public void update() {
+ root.update();
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof DerivedColorKey)) return false;
- DerivedColorKey that = (DerivedColorKey) o;
- if (aOffset != that.aOffset) return false;
- if (Float.compare(that.bOffset, bOffset) != 0) return false;
- if (Float.compare(that.hOffset, hOffset) != 0) return false;
- if (Float.compare(that.sOffset, sOffset) != 0) return false;
- if (uiDefaultParentName != null ?
- !uiDefaultParentName.equals(that.uiDefaultParentName) :
- that.uiDefaultParentName != null) return false;
- if (this.uiResource != that.uiResource) return false;
- return true;
+ public void propertyChange(PropertyChangeEvent ev) {
+ String name = ev.getPropertyName();
+ Node node = nodes.get(name);
+ if (node != null) {
+ // this is a registered color
+ node.parent.children.remove(node);
+ Color color = (Color) ev.getNewValue();
+ Node parent = getParentNode(color);
+ node.set(color, parent);
+ parent.children.add(node);
+ node.update();
+ }
}
- @Override
- public int hashCode() {
- int result = super.hashCode();
- result = 31 * result + uiDefaultParentName.hashCode();
- result = 31 * result + hOffset != +0.0f ?
- Float.floatToIntBits(hOffset) : 0;
- result = 31 * result + sOffset != +0.0f ?
- Float.floatToIntBits(sOffset) : 0;
- result = 31 * result + bOffset != +0.0f ?
- Float.floatToIntBits(bOffset) : 0;
- result = 31 * result + aOffset;
- result = 31 * result + (uiResource ? 1 : 0);
- return result;
+ class Node {
+ Color color;
+ Node parent;
+ List children = new LinkedList();
+
+ Node(Color color, Node parent) {
+ set(color, parent);
+ }
+
+ public void set(Color color, Node parent) {
+ this.color = color;
+ this.parent = parent;
+ }
+
+ public void update() {
+ if (color instanceof DerivedColor) {
+ ((DerivedColor)color).rederiveColor();
+ }
+ for (Node child: children) {
+ child.update();
+ }
+ }
}
}
@@ -786,49 +801,12 @@ ${UI_DEFAULT_INIT}
private class DefaultsListener implements PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
- Object src = evt.getSource();
- String key = evt.getPropertyName();
- if (key.equals("lookAndFeel")){
+ if ("lookAndFeel".equals(evt.getPropertyName())) {
// LAF has been installed, this is the first point at which we
// can access our defaults table via UIManager so before now
// all derived colors will be incorrect.
// First we need to update
- for (DerivedColor color : derivedColorsMap.values()) {
- color.rederiveColor();
- }
- } else if (src instanceof DerivedColor && key.equals("rgb")) {
- // derived color that is in UIManager defaults has changed
- // update all its dependent colors. Don't worry about doing
- // this recursively since calling rederiveColor will cause
- // another PCE to be fired, ending up here and essentially
- // recursing
- DerivedColor parentColor = (DerivedColor)src;
- String parentKey = null;
- Set> entries =
- UIManager.getDefaults().entrySet();
-
- for (Map.Entry entry : entries) {
- Object value = entry.getValue();
- if (value == parentColor) {
- parentKey = entry.getKey().toString();
- }
- }
-
- if (parentKey == null) {
- //couldn't find the DerivedColor in the UIDefaults map,
- //so we just bail.
- return;
- }
-
- for (Map.Entry entry : entries) {
- Object value = entry.getValue();
- if (value instanceof DerivedColor) {
- DerivedColor color = (DerivedColor)entry.getValue();
- if (parentKey.equals(color.getUiDefaultParentName())) {
- color.rederiveColor();
- }
- }
- }
+ colorTree.update();
}
}
}
@@ -875,4 +853,3 @@ ${UI_DEFAULT_INIT}
}
}
}
-
diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java b/jdk/src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java
index 20b7b1aacec..56bac5f4fb6 100644
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java
@@ -39,8 +39,6 @@ import java.beans.PropertyChangeListener;
* @author Jasper Potts
*/
class DerivedColor extends Color {
- private final PropertyChangeSupport changeSupport =
- new PropertyChangeSupport(this);
private final String uiDefaultParentName;
private final float hOffset, sOffset, bOffset;
private final int aOffset;
@@ -79,7 +77,6 @@ class DerivedColor extends Color {
* Recalculate the derived color from the UIManager parent color and offsets
*/
public void rederiveColor() {
- int old = argbValue;
Color src = UIManager.getColor(uiDefaultParentName);
if (src != null) {
float[] tmp = Color.RGBtoHSB(src.getRed(), src.getGreen(), src.getBlue(), null);
@@ -97,7 +94,6 @@ class DerivedColor extends Color {
int alpha = clamp(aOffset);
argbValue = (Color.HSBtoRGB(tmp[0], tmp[1], tmp[2]) & 0xFFFFFF) | (alpha << 24);
}
- changeSupport.firePropertyChange("rgb", old, argbValue);
}
/**
@@ -141,35 +137,6 @@ class DerivedColor extends Color {
return result;
}
- /**
- * Add a PropertyChangeListener to the listener list.
- * The listener is registered for all properties.
- * The same listener object may be added more than once, and will be called
- * as many times as it is added.
- * If listener is null, no exception is thrown and no action
- * is taken.
- *
- * @param listener The PropertyChangeListener to be added
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- changeSupport.addPropertyChangeListener(listener);
- }
-
- /**
- * Remove a PropertyChangeListener from the listener list.
- * This removes a PropertyChangeListener that was registered
- * for all properties.
- * If listener was added more than once to the same event
- * source, it will be notified one less time after being removed.
- * If listener is null, or was never added, no exception is
- * thrown and no action is taken.
- *
- * @param listener The PropertyChangeListener to be removed
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- changeSupport.removePropertyChangeListener(listener);
- }
-
private float clamp(float value) {
if (value < 0) {
value = 0;
@@ -211,5 +178,15 @@ class DerivedColor extends Color {
float bOffset, int aOffset) {
super(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset);
}
+
+ @Override
+ public boolean equals(Object o) {
+ return (o instanceof UIResource) && super.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode() + 7;
+ }
}
}
diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
index 8c5d121b7e1..3f100bc811b 100644
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
@@ -40,6 +40,9 @@ import java.awt.Container;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.image.BufferedImage;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.*;
import javax.swing.GrayFilter;
import javax.swing.Icon;
import javax.swing.JToolBar;
@@ -87,6 +90,8 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
*/
private UIDefaults uiDefaults;
+ private DefaultsListener defaultsListener = new DefaultsListener();
+
/**
* Create a new NimbusLookAndFeel.
*/
@@ -115,8 +120,7 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
defaults.uninitialize();
// clear all cached images to free memory
ImageCache.getInstance().flush();
- // remove the listeners and things installed by NimbusStyle
- NimbusStyle.uninitialize();
+ UIManager.getDefaults().removePropertyChangeListener(defaultsListener);
}
/**
@@ -515,4 +519,62 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
return obj;
}
}
+
+ private Map> compiledDefaults = null;
+ private boolean defaultListenerAdded = false;
+
+ static String parsePrefix(String key) {
+ if (key == null) {
+ return null;
+ }
+ boolean inquotes = false;
+ for (int i = 0; i < key.length(); i++) {
+ char c = key.charAt(i);
+ if (c == '"') {
+ inquotes = !inquotes;
+ } else if ((c == '[' || c == '.') && !inquotes) {
+ return key.substring(0, i);
+ }
+ }
+ return null;
+ }
+
+ Map getDefaultsForPrefix(String prefix) {
+ if (compiledDefaults == null) {
+ compiledDefaults = new HashMap>();
+ for (Map.Entry entry: UIManager.getDefaults().entrySet()) {
+ if (entry.getKey() instanceof String) {
+ addDefault((String) entry.getKey(), entry.getValue());
+ }
+ }
+ if (! defaultListenerAdded) {
+ UIManager.getDefaults().addPropertyChangeListener(defaultsListener);
+ defaultListenerAdded = true;
+ }
+ }
+ return compiledDefaults.get(prefix);
+ }
+
+ private void addDefault(String key, Object value) {
+ String prefix = parsePrefix(key);
+ if (prefix != null) {
+ Map keys = compiledDefaults.get(prefix);
+ if (keys == null) {
+ keys = new HashMap();
+ compiledDefaults.put(prefix, keys);
+ }
+ keys.put(key, value);
+ }
+ }
+
+ private class DefaultsListener implements PropertyChangeListener {
+ @Override public void propertyChange(PropertyChangeEvent ev) {
+ String key = ev.getPropertyName();
+ if ("UIDefaults".equals(key)) {
+ compiledDefaults = null;
+ } else {
+ addDefault(key, ev.getNewValue());
+ }
+ }
+ }
}
diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java
index 04efc91cf01..a8f8b3fc5b6 100644
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java
@@ -26,7 +26,6 @@ package javax.swing.plaf.nimbus;
import javax.swing.Painter;
-import java.beans.PropertyChangeEvent;
import javax.swing.JComponent;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
@@ -39,16 +38,13 @@ import javax.swing.plaf.synth.SynthStyle;
import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
-import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import sun.awt.AppContext;
/**
*
A SynthStyle implementation used by Nimbus. Each Region that has been
@@ -232,42 +228,6 @@ public final class NimbusStyle extends SynthStyle {
super.installDefaults(ctx);
}
- static String parsePrefix(String key) {
- if (key == null) return null;
- boolean inquotes = false;
- for (int i=0; i> compiledDefaults =
- (Map>)
- ctx.get("NimbusStyle.defaults");
-
- if (compiledDefaults == null) {
- // the entire UIDefaults tables are parsed and compiled into
- // this map of maps. The key of the compiledDefaults is the
- // prefix for each style, while the value is a map of
- // keys->values for that prefix.
- compiledDefaults = new HashMap>();
-
- // get all the defaults from UIManager.getDefaults() and put them
- // into the compiledDefaults
- compileDefaults(compiledDefaults, UIManager.getDefaults());
-
- // This second statement pulls defaults from the laf defaults
- UIDefaults lafDefaults = UIManager.getLookAndFeelDefaults();
- compileDefaults(compiledDefaults, lafDefaults);
-
- // if it has not already been done, add a listener to both
- // UIManager.getDefaults() and UIManager.getLookAndFeelDefaults().
- PropertyChangeListener pcl = (PropertyChangeListener)
- ctx.get("NimbusStyle.defaults.pcl");
-
- // if pcl is null, then it has not yet been registered with
- // the UIManager defaults for this app context
- if (pcl == null) {
- // create a PCL which will simply clear out the compiled
- // defaults from the app context, causing it to be recomputed
- // on subsequent passes
- pcl = new DefaultsListener();
- // add the PCL to both defaults tables that we pay attention
- // to, so that if the UIDefaults are updated, then the
- // precompiled defaults will be cleared from the app context
- // and recomputed on subsequent passes
- UIManager.getDefaults().addPropertyChangeListener(pcl);
- UIManager.getLookAndFeelDefaults().addPropertyChangeListener(pcl);
- // save the PCL to the app context as a marker indicating
- // that the PCL has been registered so we don't end up adding
- // more than one listener to the UIDefaults tables.
- ctx.put("NimbusStyle.defaults.pcl", pcl);
- }
-
- // store the defaults for reuse
- ctx.put("NimbusStyle.defaults", compiledDefaults);
- }
-
- TreeMap defaults = compiledDefaults.get(prefix);
+ Map defaults =
+ ((NimbusLookAndFeel) UIManager.getLookAndFeel()).
+ getDefaultsForPrefix(prefix);
// inspect the client properties for the key "Nimbus.Overrides". If the
// value is an instance of UIDefaults, then these defaults are used
@@ -371,52 +274,6 @@ public final class NimbusStyle extends SynthStyle {
}
}
- // Now that I've accumulated all the defaults pertaining to this
- // style, call init which will read these defaults and configure
- // the default "values".
- init(values, defaults);
- }
-
- /**
- * Iterates over all the keys in the specified UIDefaults and compiles
- * those keys into the comiledDefaults data structure. It relies on
- * parsing the "prefix" out of the key. If the key is not a String or is
- * null then it is ignored. In all other cases a prefix is parsed out
- * (even if that prefix is the empty String or is a "fake" prefix. That
- * is, suppose you had a key Foo~~MySpecial.KeyThing~~. In this case this
- * is not a Nimbus formatted key, but we don't care, we treat it as if it
- * is. This doesn't pose any harm, it will simply never be used).
- *
- * @param compiledDefaults
- * @param d
- */
- private void compileDefaults(
- Map> compiledDefaults,
- UIDefaults d) {
- for (Object obj : new HashSet(d.keySet())) {
- if (obj instanceof String) {
- String key = (String)obj;
- String kp = parsePrefix(key);
- if (kp == null) continue;
- TreeMap map = compiledDefaults.get(kp);
- if (map == null) {
- map = new TreeMap();
- compiledDefaults.put(kp, map);
- }
- map.put(key, d.get(key));
- }
- }
- }
-
- /**
- * Initializes the given Values object with the defaults
- * contained in the given TreeMap.
- *
- * @param v The Values object to be initialized
- * @param myDefaults a map of UIDefaults to use in initializing the Values.
- * This map must contain only keys associated with this Style.
- */
- private void init(Values v, TreeMap myDefaults) {
//a list of the different types of states used by this style. This
//list may contain only "standard" states (those defined by Synth),
//or it may contain custom states, or it may contain only "standard"
@@ -433,7 +290,7 @@ public final class NimbusStyle extends SynthStyle {
//"values" stateTypes to be a non-null array.
//Otherwise, let the "values" stateTypes be null to indicate that
//there are no custom states or custom state ordering
- String statesString = (String)myDefaults.get(prefix + ".States");
+ String statesString = (String)defaults.get(prefix + ".States");
if (statesString != null) {
String s[] = statesString.split(",");
for (int i=0; i 0) {
- v.stateTypes = states.toArray(new State[states.size()]);
+ values.stateTypes = states.toArray(new State[states.size()]);
}
//assign codes for each of the state types
@@ -490,7 +347,7 @@ public final class NimbusStyle extends SynthStyle {
}
//Now iterate over all the keys in the defaults table
- for (String key : myDefaults.keySet()) {
+ for (String key : defaults.keySet()) {
//The key is something like JButton.Enabled.backgroundPainter,
//or JButton.States, or JButton.background.
//Remove the "JButton." portion of the key
@@ -528,11 +385,11 @@ public final class NimbusStyle extends SynthStyle {
//otherwise, assume it is a property and install it on the
//values object
if ("contentMargins".equals(property)) {
- v.contentMargins = (Insets)myDefaults.get(key);
+ values.contentMargins = (Insets)defaults.get(key);
} else if ("States".equals(property)) {
//ignore
} else {
- v.defaults.put(property, myDefaults.get(key));
+ values.defaults.put(property, defaults.get(key));
}
} else {
//it is possible that the developer has a malformed UIDefaults
@@ -582,13 +439,13 @@ public final class NimbusStyle extends SynthStyle {
//so put it in the UIDefaults associated with that runtime
//state
if ("backgroundPainter".equals(property)) {
- rs.backgroundPainter = (Painter)myDefaults.get(key);
+ rs.backgroundPainter = getPainter(defaults, key);
} else if ("foregroundPainter".equals(property)) {
- rs.foregroundPainter = (Painter) myDefaults.get(key);
+ rs.foregroundPainter = getPainter(defaults, key);
} else if ("borderPainter".equals(property)) {
- rs.borderPainter = (Painter) myDefaults.get(key);
+ rs.borderPainter = getPainter(defaults, key);
} else {
- rs.defaults.put(property, myDefaults.get(key));
+ rs.defaults.put(property, defaults.get(key));
}
}
}
@@ -598,7 +455,15 @@ public final class NimbusStyle extends SynthStyle {
Collections.sort(runtimeStates, STATE_COMPARATOR);
//finally, set the array of runtime states on the values object
- v.states = runtimeStates.toArray(new RuntimeState[runtimeStates.size()]);
+ values.states = runtimeStates.toArray(new RuntimeState[runtimeStates.size()]);
+ }
+
+ private Painter getPainter(Map defaults, String key) {
+ Object p = defaults.get(key);
+ if (p instanceof UIDefaults.LazyValue) {
+ p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
+ }
+ return (p instanceof Painter ? (Painter)p : null);
}
/**
@@ -1245,15 +1110,4 @@ public final class NimbusStyle extends SynthStyle {
return hash;
}
}
-
- /**
- * This listener is used to listen to the UIDefaults tables and clear out
- * the cached-precompiled map of defaults in that case.
- */
- private static final class DefaultsListener implements PropertyChangeListener {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- AppContext.getAppContext().put("NimbusStyle.defaults", null);
- }
- }
}
diff --git a/jdk/src/share/classes/javax/swing/plaf/nimbus/skin.laf b/jdk/src/share/classes/javax/swing/plaf/nimbus/skin.laf
index b44da311e2b..15532781cf2 100644
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/skin.laf
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/skin.laf
@@ -14824,7 +14824,9 @@
falseNO_CACHING
-
+
+
+
diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java
index a8ec7728a64..c775a4b18b9 100644
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java
@@ -475,11 +475,11 @@ public class SynthGraphicsUtils {
return result;
}
- static void applyInsets(Rectangle rect, Insets insets) {
+ static void applyInsets(Rectangle rect, Insets insets, boolean leftToRight) {
if (insets != null) {
- rect.x += insets.left;
+ rect.x += (leftToRight ? insets.left : insets.right);
rect.y += insets.top;
- rect.width -= (insets.right + rect.x);
+ rect.width -= (leftToRight ? insets.right : insets.left) + rect.x;
rect.height -= (insets.bottom + rect.y);
}
}
@@ -492,12 +492,12 @@ public class SynthGraphicsUtils {
g.setFont(style.getFont(context));
Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
- applyInsets(viewRect, mi.getInsets());
+ boolean leftToRight = SynthLookAndFeel.isLeftToRight(mi);
+ applyInsets(viewRect, mi.getInsets(), leftToRight);
SynthMenuItemLayoutHelper lh = new SynthMenuItemLayoutHelper(
- context, accContext, mi, checkIcon,
- arrowIcon, viewRect, defaultTextIconGap, acceleratorDelimiter,
- SynthLookAndFeel.isLeftToRight(mi),
+ context, accContext, mi, checkIcon, arrowIcon, viewRect,
+ defaultTextIconGap, acceleratorDelimiter, leftToRight,
MenuItemLayoutHelper.useCheckAndArrow(mi), propertyPrefix);
MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();
diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java
index 4ca139a709d..4dd5ddc29e2 100644
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java
@@ -195,7 +195,7 @@ class SynthMenuItemLayoutHelper extends MenuItemLayoutHelper {
getHorizontalAlignment(), getVerticalAlignment(),
getHorizontalTextPosition(), getVerticalTextPosition(),
getViewRect(), iconRect, textRect, getGap());
- textRect.width += getLeftTextExtraWidth() + getRightTextExtraWidth();
+ textRect.width += getLeftTextExtraWidth();
Rectangle labelRect = iconRect.union(textRect);
getLabelSize().setHeight(labelRect.height);
getLabelSize().setWidth(labelRect.width);
diff --git a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java
index 80d06101b98..6adb54f7d80 100644
--- a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java
+++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java
@@ -510,7 +510,7 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou
if ((e.getModifiers() & ActionEvent.SHIFT_MASK) != 0 &&
getDot() != -1) {
moveCaret(e);
- } else {
+ } else if (!e.isPopupTrigger()) {
positionCaret(e);
}
}
diff --git a/jdk/src/share/classes/javax/swing/text/JTextComponent.java b/jdk/src/share/classes/javax/swing/text/JTextComponent.java
index fc24214a844..371afda48b0 100644
--- a/jdk/src/share/classes/javax/swing/text/JTextComponent.java
+++ b/jdk/src/share/classes/javax/swing/text/JTextComponent.java
@@ -2069,8 +2069,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* width to match its own
*/
public boolean getScrollableTracksViewportWidth() {
- if (getParent() instanceof JViewport) {
- return (getParent().getWidth() > getPreferredSize().width);
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
+ return port.getWidth() > getPreferredSize().width;
}
return false;
}
@@ -2089,8 +2090,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* to match its own
*/
public boolean getScrollableTracksViewportHeight() {
- if (getParent() instanceof JViewport) {
- return (getParent().getHeight() > getPreferredSize().height);
+ JViewport port = SwingUtilities2.getViewport(this);
+ if (port != null) {
+ return (port.getHeight() > getPreferredSize().height);
}
return false;
}
@@ -4813,7 +4815,18 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
new AttributedString(text, composedIndex, text.getEndIndex()));
}
- private boolean saveComposedText(int pos) {
+ /**
+ * Saves composed text around the specified position.
+ *
+ * The composed text (if any) around the specified position is saved
+ * in a backing store and removed from the document.
+ *
+ * @param pos document position to identify the composed text location
+ * @return {@code true} if the composed text exists and is saved,
+ * {@code false} otherwise
+ * @see #restoreComposedText
+ */
+ protected boolean saveComposedText(int pos) {
if (composedTextExists()) {
int start = composedTextStart.getOffset();
int len = composedTextEnd.getOffset() -
@@ -4828,7 +4841,15 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
return false;
}
- private void restoreComposedText() {
+ /**
+ * Restores composed text previously saved by {@code saveComposedText}.
+ *
+ * The saved composed text is inserted back into the document. This method
+ * should be invoked only if {@code saveComposedText} returns {@code true}.
+ *
+ * @see #saveComposedText
+ */
+ protected void restoreComposedText() {
Document doc = getDocument();
try {
doc.insertString(caret.getDot(),
diff --git a/jdk/src/share/classes/javax/swing/text/ParagraphView.java b/jdk/src/share/classes/javax/swing/text/ParagraphView.java
index c02ea4d810e..1c9ae08c05f 100644
--- a/jdk/src/share/classes/javax/swing/text/ParagraphView.java
+++ b/jdk/src/share/classes/javax/swing/text/ParagraphView.java
@@ -716,7 +716,7 @@ public class ParagraphView extends FlowView implements TabExpander {
* @param axis the minor axis
* @param r the input {@code SizeRequirements} object
* @return the new or adjusted {@code SizeRequirements} object
- * @throw IllegalArgumentException if the {@code axis} parameter is invalid
+ * @throws IllegalArgumentException if the {@code axis} parameter is invalid
*/
@Override
protected SizeRequirements calculateMinorAxisRequirements(int axis,
diff --git a/jdk/src/share/classes/javax/swing/text/StyleContext.java b/jdk/src/share/classes/javax/swing/text/StyleContext.java
index 4d194eb9054..2ee0b5726be 100644
--- a/jdk/src/share/classes/javax/swing/text/StyleContext.java
+++ b/jdk/src/share/classes/javax/swing/text/StyleContext.java
@@ -35,7 +35,7 @@ import javax.swing.event.ChangeEvent;
import java.lang.ref.WeakReference;
import java.util.WeakHashMap;
-import sun.font.FontManager;
+import sun.font.FontUtilities;
/**
* A pool of styles and their associated resources. This class determines
@@ -263,8 +263,8 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
if (f == null) {
f = new Font(family, style, size);
}
- if (! FontManager.fontSupportsDefaultEncoding(f)) {
- f = FontManager.getCompositeFontUIResource(f);
+ if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
+ f = FontUtilities.getCompositeFontUIResource(f);
}
FontKey key = new FontKey(family, style, size);
fontTable.put(key, f);
diff --git a/jdk/src/share/classes/javax/swing/text/TextLayoutStrategy.java b/jdk/src/share/classes/javax/swing/text/TextLayoutStrategy.java
index 85afd75d973..0e3f9873bf1 100644
--- a/jdk/src/share/classes/javax/swing/text/TextLayoutStrategy.java
+++ b/jdk/src/share/classes/javax/swing/text/TextLayoutStrategy.java
@@ -30,6 +30,7 @@ import java.text.AttributedCharacterIterator;
import java.text.BreakIterator;
import java.awt.font.*;
import java.awt.geom.AffineTransform;
+import javax.swing.JComponent;
import javax.swing.event.DocumentEvent;
import sun.font.BidiUtils;
@@ -301,6 +302,13 @@ class TextLayoutStrategy extends FlowView.FlowStrategy {
iter = BreakIterator.getLineInstance();
}
+ Object shaper = null;
+ if (c instanceof JComponent) {
+ shaper = ((JComponent) c).getClientProperty(
+ TextAttribute.NUMERIC_SHAPING);
+ }
+ text.setShaper(shaper);
+
measurer = new LineBreakMeasurer(text, iter, frc);
// If the children of the FlowView's logical view are GlyphViews, they
@@ -399,6 +407,10 @@ class TextLayoutStrategy extends FlowView.FlowStrategy {
return pos - v.getStartOffset() + getBeginIndex();
}
+ private void setShaper(Object shaper) {
+ this.shaper = shaper;
+ }
+
// --- AttributedCharacterIterator methods -------------------------
/**
@@ -511,6 +523,8 @@ class TextLayoutStrategy extends FlowView.FlowStrategy {
} else if( attribute == TextAttribute.RUN_DIRECTION ) {
return
v.getDocument().getProperty(TextAttribute.RUN_DIRECTION);
+ } else if (attribute == TextAttribute.NUMERIC_SHAPING) {
+ return shaper;
}
return null;
}
@@ -532,8 +546,10 @@ class TextLayoutStrategy extends FlowView.FlowStrategy {
keys = new HashSet();
keys.add(TextAttribute.FONT);
keys.add(TextAttribute.RUN_DIRECTION);
+ keys.add(TextAttribute.NUMERIC_SHAPING);
}
+ private Object shaper = null;
}
}
diff --git a/jdk/src/share/classes/javax/swing/text/html/ParagraphView.java b/jdk/src/share/classes/javax/swing/text/html/ParagraphView.java
index 6d6006b0a6f..981690a1103 100644
--- a/jdk/src/share/classes/javax/swing/text/html/ParagraphView.java
+++ b/jdk/src/share/classes/javax/swing/text/html/ParagraphView.java
@@ -150,7 +150,7 @@ public class ParagraphView extends javax.swing.text.ParagraphView {
* @param axis the minor axis
* @param r the input {@code SizeRequirements} object
* @return the new or adjusted {@code SizeRequirements} object
- * @throw IllegalArgumentException if the {@code axis} parameter is invalid
+ * @throws IllegalArgumentException if the {@code axis} parameter is invalid
*/
protected SizeRequirements calculateMinorAxisRequirements(
int axis, SizeRequirements r) {
diff --git a/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java b/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java
index 2eb24e84616..0225fac4a03 100644
--- a/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java
+++ b/jdk/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java
@@ -1067,10 +1067,13 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
}
/**
- * Notifies listeners of a change in path. changePaths should contain
- * instances of PathPlaceHolder.
- */
- protected void notifyPathChange(Vector changedPaths,
+ * Notifies listeners of a change in path. changePaths should contain
+ * instances of PathPlaceHolder.
+ *
+ * @deprecated As of JDK version 1.7
+ */
+ @Deprecated
+ protected void notifyPathChange(Vector changedPaths,
TreePath oldLeadSelection) {
int cPathCount = changedPaths.size();
boolean[] newness = new boolean[cPathCount];
@@ -1078,7 +1081,7 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
PathPlaceHolder placeholder;
for(int counter = 0; counter < cPathCount; counter++) {
- placeholder = changedPaths.elementAt(counter);
+ placeholder = (PathPlaceHolder) changedPaths.elementAt(counter);
newness[counter] = placeholder.isNew;
paths[counter] = placeholder.path;
}
diff --git a/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java b/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java
index 871da0ce3f5..e513569f6dd 100644
--- a/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java
+++ b/jdk/src/share/classes/sun/awt/AWTAutoShutdown.java
@@ -30,7 +30,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Map;
-import java.util.logging.Logger;
+import sun.util.logging.PlatformLogger;
/**
* This class is to let AWT shutdown automatically when a user is done
@@ -154,14 +154,17 @@ public final class AWTAutoShutdown implements Runnable {
/**
* Add a specified thread to the set of busy event dispatch threads.
- * If this set already contains the specified thread, the call leaves
- * this set unchanged and returns silently.
+ * If this set already contains the specified thread or the thread is null,
+ * the call leaves this set unchanged and returns silently.
*
* @param thread thread to be added to this set, if not present.
* @see AWTAutoShutdown#notifyThreadFree
* @see AWTAutoShutdown#isReadyToShutdown
*/
public void notifyThreadBusy(final Thread thread) {
+ if (thread == null) {
+ return;
+ }
synchronized (activationLock) {
synchronized (mainLock) {
if (blockerThread == null) {
@@ -177,14 +180,17 @@ public final class AWTAutoShutdown implements Runnable {
/**
* Remove a specified thread from the set of busy event dispatch threads.
- * If this set doesn't contain the specified thread, the call leaves
- * this set unchanged and returns silently.
+ * If this set doesn't contain the specified thread or the thread is null,
+ * the call leaves this set unchanged and returns silently.
*
* @param thread thread to be removed from this set, if present.
* @see AWTAutoShutdown#notifyThreadBusy
* @see AWTAutoShutdown#isReadyToShutdown
*/
public void notifyThreadFree(final Thread thread) {
+ if (thread == null) {
+ return;
+ }
synchronized (activationLock) {
synchronized (mainLock) {
busyThreadSet.remove(thread);
@@ -363,7 +369,7 @@ public final class AWTAutoShutdown implements Runnable {
}
}
- final void dumpPeers(final Logger aLog) {
+ final void dumpPeers(final PlatformLogger aLog) {
synchronized (activationLock) {
synchronized (mainLock) {
aLog.fine("Mapped peers:");
diff --git a/jdk/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasResources.java b/jdk/src/share/classes/sun/awt/AWTPermissionFactory.java
similarity index 74%
rename from jdk/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasResources.java
rename to jdk/src/share/classes/sun/awt/AWTPermissionFactory.java
index 82f9c0dd8a9..73d7e2c5cac 100644
--- a/jdk/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasResources.java
+++ b/jdk/src/share/classes/sun/awt/AWTPermissionFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 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
@@ -22,21 +22,21 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
-package org.jdesktop.swingx.designer.utils;
-import java.io.File;
+package sun.awt;
+
+import java.awt.AWTPermission;
+import sun.security.util.PermissionFactory;
/**
- * HasResources - interface for model nodes that have resources
- *
- * @author Created by Jasper Potts (Jul 2, 2007)
+ * A factory object for AWTPermission objects.
*/
-public interface HasResources {
-
- public File getResourcesDir();
-
- public File getImagesDir();
-
- public File getTemplatesDir();
+public class AWTPermissionFactory
+ implements PermissionFactory
+{
+ @Override
+ public AWTPermission newPermission(String name) {
+ return new AWTPermission(name);
+ }
}
diff --git a/jdk/src/share/classes/sun/awt/AppContext.java b/jdk/src/share/classes/sun/awt/AppContext.java
index 4bdc337970b..3dcabdc6358 100644
--- a/jdk/src/share/classes/sun/awt/AppContext.java
+++ b/jdk/src/share/classes/sun/awt/AppContext.java
@@ -40,10 +40,9 @@ import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
+import sun.util.logging.PlatformLogger;
/**
* The AppContext is a table referenced by ThreadGroup which stores
@@ -128,7 +127,7 @@ import java.beans.PropertyChangeListener;
* @author Fred Ecks
*/
public final class AppContext {
- private static final Logger log = Logger.getLogger("sun.awt.AppContext");
+ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.AppContext");
/* Since the contents of an AppContext are unique to each Java
* session, this class should never be serialized. */
@@ -380,9 +379,7 @@ public final class AppContext {
try {
w.dispose();
} catch (Throwable t) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "exception occured while disposing app context", t);
- }
+ log.finer("exception occured while disposing app context", t);
}
}
AccessController.doPrivileged(new PrivilegedAction() {
diff --git a/jdk/src/share/classes/sun/awt/ComponentAccessor.java b/jdk/src/share/classes/sun/awt/ComponentAccessor.java
index 49a383815db..d186363e51b 100644
--- a/jdk/src/share/classes/sun/awt/ComponentAccessor.java
+++ b/jdk/src/share/classes/sun/awt/ComponentAccessor.java
@@ -39,8 +39,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Logger;
-import java.util.logging.Level;
+import sun.util.logging.PlatformLogger;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -78,7 +77,7 @@ public class ComponentAccessor
private static Method methodGetCursorNoClientCode;
private static Method methodLocationNoClientCode;
- private static final Logger log = Logger.getLogger("sun.awt.ComponentAccessor");
+ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.ComponentAccessor");
private ComponentAccessor() {
}
@@ -136,13 +135,13 @@ public class ComponentAccessor
methodLocationNoClientCode.setAccessible(true);
}
catch (NoSuchFieldException e) {
- log.log(Level.FINE, "Unable to initialize ComponentAccessor", e);
+ log.fine("Unable to initialize ComponentAccessor", e);
}
catch (ClassNotFoundException e) {
- log.log(Level.FINE, "Unable to initialize ComponentAccessor", e);
+ log.fine("Unable to initialize ComponentAccessor", e);
}
catch (NoSuchMethodException e) {
- log.log(Level.FINE, "Unable to initialize ComponentAccessor", e);
+ log.fine("Unable to initialize ComponentAccessor", e);
}
// to please javac
return null;
@@ -157,7 +156,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
}
@@ -168,7 +167,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
}
@@ -179,7 +178,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
}
@@ -190,7 +189,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
}
@@ -204,7 +203,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
}
@@ -214,7 +213,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return 0;
}
@@ -225,7 +224,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return 0;
}
@@ -236,7 +235,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return 0;
}
@@ -247,7 +246,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return 0;
}
@@ -258,7 +257,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return false;
}
@@ -271,10 +270,10 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
catch (InvocationTargetException e) {
- log.log(Level.FINE, "Unable to invoke on the Component object", e);
+ log.fine("Unable to invoke on the Component object", e);
}
return parent;
@@ -288,10 +287,10 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
catch (InvocationTargetException e) {
- log.log(Level.FINE, "Unable to invoke on the Component object", e);
+ log.fine("Unable to invoke on the Component object", e);
}
return font;
@@ -307,10 +306,10 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
catch (InvocationTargetException e) {
- log.log(Level.FINE, "Unable to invoke on the Component object", e);
+ log.fine("Unable to invoke on the Component object", e);
}
}
@@ -322,10 +321,10 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
catch (InvocationTargetException e) {
- log.log(Level.FINE, "Unable to invoke on the Component object", e);
+ log.fine("Unable to invoke on the Component object", e);
}
}
@@ -336,7 +335,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
}
@@ -348,7 +347,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return color;
}
@@ -361,7 +360,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return color;
}
@@ -372,7 +371,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
}
@@ -384,7 +383,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return f;
}
@@ -396,7 +395,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return peer;
}
@@ -406,7 +405,7 @@ public class ComponentAccessor
fieldPeer.set(c, peer);
} catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
}
@@ -415,7 +414,7 @@ public class ComponentAccessor
return fieldIgnoreRepaint.getBoolean(comp);
}
catch (IllegalAccessException e) {
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return false;
@@ -427,7 +426,7 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
return false;
}
@@ -439,10 +438,10 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
catch (InvocationTargetException e) {
- log.log(Level.FINE, "Unable to invoke on the Component object", e);
+ log.fine("Unable to invoke on the Component object", e);
}
return enabled;
}
@@ -455,10 +454,10 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
catch (InvocationTargetException e) {
- log.log(Level.FINE, "Unable to invoke on the Component object", e);
+ log.fine("Unable to invoke on the Component object", e);
}
return cursor;
@@ -472,12 +471,13 @@ public class ComponentAccessor
}
catch (IllegalAccessException e)
{
- log.log(Level.FINE, "Unable to access the Component object", e);
+ log.fine("Unable to access the Component object", e);
}
catch (InvocationTargetException e) {
- log.log(Level.FINE, "Unable to invoke on the Component object", e);
+ log.fine("Unable to invoke on the Component object", e);
}
return loc;
}
+
}
diff --git a/jdk/src/share/classes/sun/awt/DebugSettings.java b/jdk/src/share/classes/sun/awt/DebugSettings.java
index 0d2aaaf6251..9f0f4742c3e 100644
--- a/jdk/src/share/classes/sun/awt/DebugSettings.java
+++ b/jdk/src/share/classes/sun/awt/DebugSettings.java
@@ -28,7 +28,7 @@ package sun.awt;
import java.io.*;
import java.util.*;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
/*
* Internal class that manages sun.awt.Debug settings.
@@ -72,7 +72,7 @@ import java.util.logging.*;
* the fix for 4638447).
*/
final class DebugSettings {
- private static final Logger log = Logger.getLogger("sun.awt.debug.DebugSettings");
+ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.debug.DebugSettings");
/* standard debug property key names */
static final String PREFIX = "awtdebug";
@@ -128,8 +128,8 @@ final class DebugSettings {
});
// echo the initial property settings to stdout
- if (log.isLoggable(Level.FINE)) {
- log.log(Level.FINE, "DebugSettings:\n{0}", this);
+ if (log.isLoggable(PlatformLogger.FINE)) {
+ log.fine("DebugSettings:\n{0}" + this);
}
}
@@ -258,8 +258,8 @@ final class DebugSettings {
}
private void println(Object object) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, object.toString());
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer(object.toString());
}
}
diff --git a/jdk/src/share/classes/sun/awt/FontConfiguration.java b/jdk/src/share/classes/sun/awt/FontConfiguration.java
index 4504af24e9d..27cee5e38a6 100644
--- a/jdk/src/share/classes/sun/awt/FontConfiguration.java
+++ b/jdk/src/share/classes/sun/awt/FontConfiguration.java
@@ -30,7 +30,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -38,7 +37,6 @@ import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.logging.Logger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
@@ -49,7 +47,10 @@ import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import sun.font.CompositeFontDescriptor;
-import sun.java2d.SunGraphicsEnvironment;
+import sun.font.SunFontManager;
+import sun.font.FontManagerFactory;
+import sun.font.FontUtilities;
+import sun.util.logging.PlatformLogger;
/**
* Provides the definitions of the five logical fonts: Serif, SansSerif,
@@ -65,10 +66,10 @@ public abstract class FontConfiguration {
protected static Locale startupLocale = null;
protected static Hashtable localeMap = null;
private static FontConfiguration fontConfig;
- private static Logger logger;
+ private static PlatformLogger logger;
protected static boolean isProperties = true;
- protected SunGraphicsEnvironment environment;
+ protected SunFontManager fontManager;
protected boolean preferLocaleFonts;
protected boolean preferPropFonts;
@@ -80,11 +81,11 @@ public abstract class FontConfiguration {
/* A default FontConfiguration must be created before an alternate
* one to ensure proper static initialisation takes place.
*/
- public FontConfiguration(SunGraphicsEnvironment environment) {
- if (SunGraphicsEnvironment.debugFonts && logger == null) {
- logger = Logger.getLogger("sun.awt.FontConfiguration");
+ public FontConfiguration(SunFontManager fm) {
+ if (FontUtilities.debugFonts() && logger == null) {
+ logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
}
- this.environment = environment;
+ fontManager = fm;
setOsNameAndVersion(); /* static initialization */
setEncoding(); /* static initialization */
/* Separating out the file location from the rest of the
@@ -106,10 +107,10 @@ public abstract class FontConfiguration {
return true;
}
- public FontConfiguration(SunGraphicsEnvironment environment,
+ public FontConfiguration(SunFontManager fm,
boolean preferLocaleFonts,
boolean preferPropFonts) {
- this.environment = environment;
+ fontManager = fm;
this.preferLocaleFonts = preferLocaleFonts;
this.preferPropFonts = preferPropFonts;
/* fontConfig should be initialised by default constructor, and
@@ -198,17 +199,17 @@ public abstract class FontConfiguration {
loadBinary(in);
}
in.close();
- if (SunGraphicsEnvironment.debugFonts) {
+ if (FontUtilities.debugFonts()) {
logger.config("Read logical font configuration from " + f);
}
} catch (IOException e) {
- if (SunGraphicsEnvironment.debugFonts) {
+ if (FontUtilities.debugFonts()) {
logger.config("Failed to read logical font configuration from " + f);
}
}
}
String version = getVersion();
- if (!"1".equals(version) && SunGraphicsEnvironment.debugFonts) {
+ if (!"1".equals(version) && FontUtilities.debugFonts()) {
logger.config("Unsupported fontconfig version: " + version);
}
}
@@ -219,8 +220,8 @@ public abstract class FontConfiguration {
File fallbackDir = new File(fallbackDirName);
if (fallbackDir.exists() && fallbackDir.isDirectory()) {
- String[] ttfs = fallbackDir.list(SunGraphicsEnvironment.ttFilter);
- String[] t1s = fallbackDir.list(SunGraphicsEnvironment.t1Filter);
+ String[] ttfs = fallbackDir.list(fontManager.getTrueTypeFilter());
+ String[] t1s = fallbackDir.list(fontManager.getType1Filter());
int numTTFs = (ttfs == null) ? 0 : ttfs.length;
int numT1s = (t1s == null) ? 0 : t1s.length;
int len = numTTFs + numT1s;
@@ -236,7 +237,7 @@ public abstract class FontConfiguration {
installedFallbackFontFiles[i+numTTFs] =
fallbackDir + File.separator + t1s[i];
}
- environment.registerFontsInDir(fallbackDirName);
+ fontManager.registerFontsInDir(fallbackDirName);
}
}
@@ -365,7 +366,7 @@ public abstract class FontConfiguration {
stringTable = new StringBuilder(4096);
if (verbose && logger == null) {
- logger = Logger.getLogger("sun.awt.FontConfiguration");
+ logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
}
new PropertiesHandler().load(in);
@@ -465,7 +466,7 @@ public abstract class FontConfiguration {
nameIDs[index] = getComponentFontID(coreScripts[index],
fontIndex, styleIndex);
if (preferLocaleFonts && localeMap != null &&
- sun.font.FontManager.usingAlternateFontforJALocales()) {
+ fontManager.usingAlternateFontforJALocales()) {
nameIDs[index] = remapLocaleMap(fontIndex, styleIndex,
coreScripts[index], nameIDs[index]);
}
@@ -480,7 +481,7 @@ public abstract class FontConfiguration {
short id = getComponentFontID(fallbackScripts[i],
fontIndex, styleIndex);
if (preferLocaleFonts && localeMap != null &&
- sun.font.FontManager.usingAlternateFontforJALocales()) {
+ fontManager.usingAlternateFontforJALocales()) {
id = remapLocaleMap(fontIndex, styleIndex, fallbackScripts[i], id);
}
if (preferPropFonts) {
@@ -973,8 +974,8 @@ public abstract class FontConfiguration {
public CompositeFontDescriptor[] get2DCompositeFontInfo() {
CompositeFontDescriptor[] result =
new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES];
- String defaultFontFile = environment.getDefaultFontFile();
- String defaultFontFaceName = environment.getDefaultFontFaceName();
+ String defaultFontFile = fontManager.getDefaultFontFile();
+ String defaultFontFaceName = fontManager.getDefaultFontFaceName();
for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) {
String fontName = publicFontNames[fontIndex];
@@ -1121,7 +1122,7 @@ public abstract class FontConfiguration {
*/
HashMap existsMap;
public boolean needToSearchForFile(String fileName) {
- if (!environment.isLinux) {
+ if (!FontUtilities.isLinux) {
return false;
} else if (existsMap == null) {
existsMap = new HashMap();
@@ -1139,7 +1140,7 @@ public abstract class FontConfiguration {
} else {
exists = Boolean.valueOf((new File(fileName)).exists());
existsMap.put(fileName, exists);
- if (SunGraphicsEnvironment.debugFonts &&
+ if (FontUtilities.debugFonts() &&
exists == Boolean.FALSE) {
logger.warning("Couldn't locate font file " + fileName);
}
@@ -2067,7 +2068,8 @@ public abstract class FontConfiguration {
throw new Exception();
}
} catch (Exception e) {
- if (SunGraphicsEnvironment.debugFonts && logger != null) {
+ if (FontUtilities.debugFonts() &&
+ logger != null) {
logger.config("Failed parsing " + key +
" property of font configuration.");
diff --git a/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java b/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
index 6a8708a2abe..8a1743e3348 100644
--- a/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
+++ b/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
@@ -39,12 +39,11 @@ import java.awt.peer.ComponentPeer;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import sun.util.logging.PlatformLogger;
public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManagerPeer {
- private static final Logger focusLog = Logger.getLogger("sun.awt.focus.KeyboardFocusManagerPeerImpl");
+ private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.focus.KeyboardFocusManagerPeerImpl");
private static AWTAccessor.KeyboardFocusManagerAccessor kfmAccessor =
AWTAccessor.getKeyboardFocusManagerAccessor();
@@ -64,7 +63,8 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
public void clearGlobalFocusOwner(Window activeWindow) {
if (activeWindow != null) {
Component focusOwner = activeWindow.getFocusOwner();
- if (focusLog.isLoggable(Level.FINE)) focusLog.fine("Clearing global focus owner " + focusOwner);
+ if (focusLog.isLoggable(PlatformLogger.FINE))
+ focusLog.fine("Clearing global focus owner " + focusOwner);
if (focusOwner != null) {
FocusEvent fl = new CausedFocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
@@ -130,14 +130,16 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
false, lightweightChild, cause);
- if (focusLog.isLoggable(Level.FINER)) focusLog.finer("Posting focus event: " + fl);
+ if (focusLog.isLoggable(PlatformLogger.FINER))
+ focusLog.finer("Posting focus event: " + fl);
SunToolkit.postPriorityEvent(fl);
}
FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
false, currentOwner, cause);
- if (focusLog.isLoggable(Level.FINER)) focusLog.finer("Posting focus event: " + fg);
+ if (focusLog.isLoggable(PlatformLogger.FINER))
+ focusLog.finer("Posting focus event: " + fg);
SunToolkit.postPriorityEvent(fg);
return true;
}
diff --git a/jdk/src/share/classes/sun/awt/ScrollPaneWheelScroller.java b/jdk/src/share/classes/sun/awt/ScrollPaneWheelScroller.java
index 8035f3f2752..c68829e23f2 100644
--- a/jdk/src/share/classes/sun/awt/ScrollPaneWheelScroller.java
+++ b/jdk/src/share/classes/sun/awt/ScrollPaneWheelScroller.java
@@ -30,7 +30,7 @@ import java.awt.Insets;
import java.awt.Adjustable;
import java.awt.event.MouseWheelEvent;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
/*
* ScrollPaneWheelScroller is a helper class for implmenenting mouse wheel
@@ -39,7 +39,7 @@ import java.util.logging.*;
*/
public abstract class ScrollPaneWheelScroller {
- private static final Logger log = Logger.getLogger("sun.awt.ScrollPaneWheelScroller");
+ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.ScrollPaneWheelScroller");
private ScrollPaneWheelScroller() {}
@@ -47,8 +47,8 @@ public abstract class ScrollPaneWheelScroller {
* Called from ScrollPane.processMouseWheelEvent()
*/
public static void handleWheelScrolling(ScrollPane sp, MouseWheelEvent e) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("x = " + e.getX() + ", y = " + e.getY() + ", src is " + e.getSource());
}
int increment = 0;
@@ -56,8 +56,8 @@ public abstract class ScrollPaneWheelScroller {
Adjustable adj = getAdjustableToScroll(sp);
if (adj != null) {
increment = getIncrementFromAdjustable(adj, e);
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "increment from adjustable(" + adj.getClass() + ") : " + increment);
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("increment from adjustable(" + adj.getClass() + ") : " + increment);
}
scrollAdjustable(adj, increment);
}
@@ -74,8 +74,8 @@ public abstract class ScrollPaneWheelScroller {
// if policy is display always or never, use vert
if (policy == ScrollPane.SCROLLBARS_ALWAYS ||
policy == ScrollPane.SCROLLBARS_NEVER) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "using vertical scrolling due to scrollbar policy");
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("using vertical scrolling due to scrollbar policy");
}
return sp.getVAdjustable();
@@ -85,31 +85,31 @@ public abstract class ScrollPaneWheelScroller {
Insets ins = sp.getInsets();
int vertScrollWidth = sp.getVScrollbarWidth();
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "insets: l = " + ins.left + ", r = " + ins.right +
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("insets: l = " + ins.left + ", r = " + ins.right +
", t = " + ins.top + ", b = " + ins.bottom);
- log.log(Level.FINER, "vertScrollWidth = " + vertScrollWidth);
+ log.finer("vertScrollWidth = " + vertScrollWidth);
}
// Check if scrollbar is showing by examining insets of the
// ScrollPane
if (ins.right >= vertScrollWidth) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "using vertical scrolling because scrollbar is present");
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("using vertical scrolling because scrollbar is present");
}
return sp.getVAdjustable();
}
else {
int horizScrollHeight = sp.getHScrollbarHeight();
if (ins.bottom >= horizScrollHeight) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "using horiz scrolling because scrollbar is present");
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("using horiz scrolling because scrollbar is present");
}
return sp.getHAdjustable();
}
else {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "using NO scrollbar becsause neither is present");
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("using NO scrollbar becsause neither is present");
}
return null;
}
@@ -124,9 +124,9 @@ public abstract class ScrollPaneWheelScroller {
*/
public static int getIncrementFromAdjustable(Adjustable adj,
MouseWheelEvent e) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
if (adj == null) {
- log.log(Level.FINE, "Assertion (adj != null) failed");
+ log.fine("Assertion (adj != null) failed");
}
}
@@ -146,19 +146,19 @@ public abstract class ScrollPaneWheelScroller {
* bounds and sets the new value to the Adjustable.
*/
public static void scrollAdjustable(Adjustable adj, int amount) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
if (adj == null) {
- log.log(Level.FINE, "Assertion (adj != null) failed");
+ log.fine("Assertion (adj != null) failed");
}
if (amount == 0) {
- log.log(Level.FINE, "Assertion (amount != 0) failed");
+ log.fine("Assertion (amount != 0) failed");
}
}
int current = adj.getValue();
int upperLimit = adj.getMaximum() - adj.getVisibleAmount();
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "doScrolling by " + amount);
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("doScrolling by " + amount);
}
if (amount > 0 && current < upperLimit) { // still some room to scroll
diff --git a/jdk/src/share/classes/sun/awt/SunDisplayChanger.java b/jdk/src/share/classes/sun/awt/SunDisplayChanger.java
index b4c7f49bb4d..b586e783e58 100644
--- a/jdk/src/share/classes/sun/awt/SunDisplayChanger.java
+++ b/jdk/src/share/classes/sun/awt/SunDisplayChanger.java
@@ -33,7 +33,7 @@ import java.util.Set;
import java.util.HashMap;
import java.util.WeakHashMap;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
/**
* This class is used to aid in keeping track of DisplayChangedListeners and
@@ -54,7 +54,7 @@ import java.util.logging.*;
* screen to another on a system equipped with multiple displays.
*/
public class SunDisplayChanger {
- private static final Logger log = Logger.getLogger("sun.awt.multiscreen.SunDisplayChanger");
+ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.multiscreen.SunDisplayChanger");
// Create a new synchronizedMap with initial capacity of one listener.
// It is asserted that the most common case is to have one GraphicsDevice
@@ -68,13 +68,13 @@ public class SunDisplayChanger {
* notified when the display is changed.
*/
public void add(DisplayChangedListener theListener) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
if (theListener == null) {
- log.log(Level.FINE, "Assertion (theListener != null) failed");
+ log.fine("Assertion (theListener != null) failed");
}
}
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "Adding listener: " + theListener);
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("Adding listener: " + theListener);
}
listeners.put(theListener, null);
}
@@ -83,13 +83,13 @@ public class SunDisplayChanger {
* Remove the given DisplayChangeListener from this SunDisplayChanger.
*/
public void remove(DisplayChangedListener theListener) {
- if (log.isLoggable(Level.FINE)) {
+ if (log.isLoggable(PlatformLogger.FINE)) {
if (theListener == null) {
- log.log(Level.FINE, "Assertion (theListener != null) failed");
+ log.fine("Assertion (theListener != null) failed");
}
}
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "Removing listener: " + theListener);
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("Removing listener: " + theListener);
}
listeners.remove(theListener);
}
@@ -99,8 +99,8 @@ public class SunDisplayChanger {
* taken place by calling their displayChanged() methods.
*/
public void notifyListeners() {
- if (log.isLoggable(Level.FINEST)) {
- log.log(Level.FINEST, "notifyListeners");
+ if (log.isLoggable(PlatformLogger.FINEST)) {
+ log.finest("notifyListeners");
}
// This method is implemented by making a clone of the set of listeners,
// and then iterating over the clone. This is because during the course
@@ -126,8 +126,8 @@ public class SunDisplayChanger {
DisplayChangedListener current =
(DisplayChangedListener) itr.next();
try {
- if (log.isLoggable(Level.FINEST)) {
- log.log(Level.FINEST, "displayChanged for listener: " + current);
+ if (log.isLoggable(PlatformLogger.FINEST)) {
+ log.finest("displayChanged for listener: " + current);
}
current.displayChanged();
} catch (IllegalComponentStateException e) {
@@ -146,7 +146,7 @@ public class SunDisplayChanger {
* taken place by calling their paletteChanged() methods.
*/
public void notifyPaletteChanged() {
- if (log.isLoggable(Level.FINEST)) {
+ if (log.isLoggable(PlatformLogger.FINEST)) {
log.finest("notifyPaletteChanged");
}
// This method is implemented by making a clone of the set of listeners,
@@ -172,8 +172,8 @@ public class SunDisplayChanger {
DisplayChangedListener current =
(DisplayChangedListener) itr.next();
try {
- if (log.isLoggable(Level.FINEST)) {
- log.log(Level.FINEST, "paletteChanged for listener: " + current);
+ if (log.isLoggable(PlatformLogger.FINEST)) {
+ log.finest("paletteChanged for listener: " + current);
}
current.paletteChanged();
} catch (IllegalComponentStateException e) {
diff --git a/jdk/src/share/classes/sun/awt/SunGraphicsCallback.java b/jdk/src/share/classes/sun/awt/SunGraphicsCallback.java
index a85603462b7..da544187faa 100644
--- a/jdk/src/share/classes/sun/awt/SunGraphicsCallback.java
+++ b/jdk/src/share/classes/sun/awt/SunGraphicsCallback.java
@@ -27,14 +27,14 @@ package sun.awt;
import java.awt.*;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
public abstract class SunGraphicsCallback {
public static final int HEAVYWEIGHTS = 0x1;
public static final int LIGHTWEIGHTS = 0x2;
public static final int TWO_PASSES = 0x4;
- private static final Logger log = Logger.getLogger("sun.awt.SunGraphicsCallback");
+ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.SunGraphicsCallback");
public abstract void run(Component comp, Graphics cg);
@@ -87,11 +87,11 @@ public abstract class SunGraphicsCallback {
int ncomponents = comps.length;
Shape clip = g.getClip();
- if (log.isLoggable(Level.FINER) && (clip != null)) {
+ if (log.isLoggable(PlatformLogger.FINER) && (clip != null)) {
Rectangle newrect = clip.getBounds();
- log.log(Level.FINER, "x = " + newrect.x + ", y = " + newrect.y +
- ", width = " + newrect.width +
- ", height = " + newrect.height);
+ log.finer("x = " + newrect.x + ", y = " + newrect.y +
+ ", width = " + newrect.width +
+ ", height = " + newrect.height);
}
// A seriously sad hack--
diff --git a/jdk/src/share/classes/sun/awt/SunToolkit.java b/jdk/src/share/classes/sun/awt/SunToolkit.java
index b4dd06a445c..e9bc0450bbd 100644
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java
@@ -40,8 +40,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import sun.util.logging.PlatformLogger;
import sun.misc.SoftCache;
import sun.font.FontDesignMetrics;
import sun.awt.im.InputContext;
@@ -61,7 +60,7 @@ public abstract class SunToolkit extends Toolkit
implements WindowClosingSupport, WindowClosingListener,
ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider {
- private static final Logger log = Logger.getLogger("sun.awt.SunToolkit");
+ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.SunToolkit");
/* Load debug settings for native code */
static {
@@ -986,9 +985,9 @@ public abstract class SunToolkit extends Toolkit
//with scale factors x1, x3/4, x2/3, xN, x1/N.
Image im = i.next();
if (im == null) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "SunToolkit.getScaledIconImage: " +
- "Skipping the image passed into Java because it's null.");
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("SunToolkit.getScaledIconImage: " +
+ "Skipping the image passed into Java because it's null.");
}
continue;
}
@@ -1002,9 +1001,9 @@ public abstract class SunToolkit extends Toolkit
iw = im.getWidth(null);
ih = im.getHeight(null);
} catch (Exception e){
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "SunToolkit.getScaledIconImage: " +
- "Perhaps the image passed into Java is broken. Skipping this icon.");
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("SunToolkit.getScaledIconImage: " +
+ "Perhaps the image passed into Java is broken. Skipping this icon.");
}
continue;
}
@@ -1077,8 +1076,8 @@ public abstract class SunToolkit extends Toolkit
try {
int x = (width - bestWidth) / 2;
int y = (height - bestHeight) / 2;
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "WWindowPeer.getScaledIconData() result : " +
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("WWindowPeer.getScaledIconData() result : " +
"w : " + width + " h : " + height +
" iW : " + bestImage.getWidth(null) + " iH : " + bestImage.getHeight(null) +
" sim : " + bestSimilarity + " sf : " + bestScaleFactor +
@@ -1095,9 +1094,9 @@ public abstract class SunToolkit extends Toolkit
public static DataBufferInt getScaledIconData(java.util.List imageList, int width, int height) {
BufferedImage bimage = getScaledIconImage(imageList, width, height);
if (bimage == null) {
- if (log.isLoggable(Level.FINER)) {
- log.log(Level.FINER, "SunToolkit.getScaledIconData: " +
- "Perhaps the image passed into Java is broken. Skipping this icon.");
+ if (log.isLoggable(PlatformLogger.FINER)) {
+ log.finer("SunToolkit.getScaledIconData: " +
+ "Perhaps the image passed into Java is broken. Skipping this icon.");
}
return null;
}
@@ -1913,7 +1912,7 @@ public abstract class SunToolkit extends Toolkit
}
}
- protected static void dumpPeers(final Logger aLog) {
+ protected static void dumpPeers(final PlatformLogger aLog) {
AWTAutoShutdown.getInstance().dumpPeers(aLog);
}
diff --git a/jdk/src/share/classes/sun/awt/WindowAccessor.java b/jdk/src/share/classes/sun/awt/WindowAccessor.java
index 10368ef8483..e1fb7c4fc64 100644
--- a/jdk/src/share/classes/sun/awt/WindowAccessor.java
+++ b/jdk/src/share/classes/sun/awt/WindowAccessor.java
@@ -29,8 +29,7 @@ import java.awt.Window;
import java.lang.reflect.Field;
-import java.util.logging.Logger;
-import java.util.logging.Level;
+import sun.util.logging.PlatformLogger;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -41,7 +40,7 @@ public class WindowAccessor {
private static Field fieldIsAutoRequestFocus;
private static Field fieldIsTrayIconWindow;
- private static final Logger log = Logger.getLogger("sun.awt.WindowAccessor");
+ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.WindowAccessor");
private WindowAccessor() {
}
@@ -57,9 +56,9 @@ public class WindowAccessor {
fieldIsTrayIconWindow.setAccessible(true);
} catch (NoSuchFieldException e) {
- log.log(Level.FINE, "Unable to initialize WindowAccessor: ", e);
+ log.fine("Unable to initialize WindowAccessor: ", e);
} catch (ClassNotFoundException e) {
- log.log(Level.FINE, "Unable to initialize WindowAccessor: ", e);
+ log.fine("Unable to initialize WindowAccessor: ", e);
}
return null;
}
@@ -71,7 +70,7 @@ public class WindowAccessor {
return fieldIsAutoRequestFocus.getBoolean(w);
} catch (IllegalAccessException e) {
- log.log(Level.FINE, "Unable to access the Window object", e);
+ log.fine("Unable to access the Window object", e);
}
return true;
}
@@ -81,7 +80,7 @@ public class WindowAccessor {
return fieldIsTrayIconWindow.getBoolean(w);
} catch (IllegalAccessException e) {
- log.log(Level.FINE, "Unable to access the Window object", e);
+ log.fine("Unable to access the Window object", e);
}
return false;
}
@@ -91,7 +90,7 @@ public class WindowAccessor {
fieldIsTrayIconWindow.set(w, isTrayIconWindow);
} catch (IllegalAccessException e) {
- log.log(Level.FINE, "Unable to access the Window object", e);
+ log.fine("Unable to access the Window object", e);
}
}
}
diff --git a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java
index cfe0190b318..521e691024c 100644
--- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java
+++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java
@@ -89,7 +89,7 @@ import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
@@ -222,7 +222,7 @@ public abstract class DataTransferer {
*/
private static DataTransferer transferer;
- private static final Logger dtLog = Logger.getLogger("sun.awt.datatransfer.DataTransfer");
+ private static final PlatformLogger dtLog = PlatformLogger.getLogger("sun.awt.datatransfer.DataTransfer");
static {
Class tCharArrayClass = null, tByteArrayClass = null;
@@ -382,9 +382,9 @@ public abstract class DataTransferer {
* "text".
*/
public static boolean doesSubtypeSupportCharset(DataFlavor flavor) {
- if (dtLog.isLoggable(Level.FINE)) {
+ if (dtLog.isLoggable(PlatformLogger.FINE)) {
if (!"text".equals(flavor.getPrimaryType())) {
- dtLog.log(Level.FINE, "Assertion (\"text\".equals(flavor.getPrimaryType())) failed");
+ dtLog.fine("Assertion (\"text\".equals(flavor.getPrimaryType())) failed");
}
}
diff --git a/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java b/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java
index 6e9b44d7928..c137800b5ed 100644
--- a/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java
+++ b/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java
@@ -48,7 +48,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Arrays;
-import java.util.logging.*;
+import sun.util.logging.PlatformLogger;
import java.io.IOException;
import java.io.InputStream;
@@ -99,7 +99,7 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
protected static final Object _globalLock = new Object();
- private static final Logger dndLog = Logger.getLogger("sun.awt.dnd.SunDropTargetContextPeer");
+ private static final PlatformLogger dndLog = PlatformLogger.getLogger("sun.awt.dnd.SunDropTargetContextPeer");
/*
* a primitive mechanism for advertising intra-JVM Transferables
@@ -845,8 +845,8 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
void registerEvent(SunDropTargetEvent e) {
handler.lock();
- if (!eventSet.add(e) && dndLog.isLoggable(Level.FINE)) {
- dndLog.log(Level.FINE, "Event is already registered: " + e);
+ if (!eventSet.add(e) && dndLog.isLoggable(PlatformLogger.FINE)) {
+ dndLog.fine("Event is already registered: " + e);
}
handler.unlock();
}
diff --git a/jdk/src/share/classes/sun/awt/im/InputContext.java b/jdk/src/share/classes/sun/awt/im/InputContext.java
index d0c84c726ed..4a077cfa6d2 100644
--- a/jdk/src/share/classes/sun/awt/im/InputContext.java
+++ b/jdk/src/share/classes/sun/awt/im/InputContext.java
@@ -50,9 +50,9 @@ import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
-import java.util.logging.*;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
+import sun.util.logging.PlatformLogger;
import sun.awt.SunToolkit;
/**
@@ -67,7 +67,7 @@ import sun.awt.SunToolkit;
public class InputContext extends java.awt.im.InputContext
implements ComponentListener, WindowListener {
- private static final Logger log = Logger.getLogger("sun.awt.im.InputContext");
+ private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.im.InputContext");
// The current input method is represented by two objects:
// a locator is used to keep information about the selected
// input method and locale until we actually need a real input
@@ -386,7 +386,7 @@ public class InputContext extends java.awt.im.InputContext
}
previousInputMethod = null;
- if (log.isLoggable(Level.FINE)) log.fine("Current client component " + currentClientComponent);
+ if (log.isLoggable(PlatformLogger.FINE)) log.fine("Current client component " + currentClientComponent);
if (inputMethod instanceof InputMethodAdapter) {
((InputMethodAdapter) inputMethod).setClientComponent(currentClientComponent);
}
@@ -889,7 +889,7 @@ public class InputContext extends java.awt.im.InputContext
{inputMethodLocator.getDescriptor().getInputMethodDisplayName(null, Locale.getDefault()),
throwable.getLocalizedMessage()};
MessageFormat mf = new MessageFormat(errorTextFormat);
- Logger logger = Logger.getLogger("sun.awt.im");
+ PlatformLogger logger = PlatformLogger.getLogger("sun.awt.im");
logger.config(mf.format(args));
}
diff --git a/jdk/src/share/classes/sun/awt/shell/ShellFolderManager.java b/jdk/src/share/classes/sun/awt/shell/ShellFolderManager.java
index fe00063ffbb..ce42bd3a309 100644
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolderManager.java
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolderManager.java
@@ -57,8 +57,9 @@ class ShellFolderManager {
* folders, such as Desktop, Documents, History, Network, Home, etc.
* This is used in the shortcut panel of the filechooser on Windows 2000
* and Windows Me.
- * "fileChooserIcon nn":
- * Returns an Image - icon nn from resource 124 in comctl32.dll (Windows only).
+ * "fileChooserIcon ":
+ * Returns an Image - icon can be ListView, DetailsView, UpFolder, NewFolder or
+ * ViewMenu (Windows only).
*
* @return An Object matching the key string.
*/
diff --git a/jdk/src/share/classes/sun/font/CMap.java b/jdk/src/share/classes/sun/font/CMap.java
index d14451824d1..1d3d950221f 100644
--- a/jdk/src/share/classes/sun/font/CMap.java
+++ b/jdk/src/share/classes/sun/font/CMap.java
@@ -232,7 +232,7 @@ abstract class CMap {
* fonts are using gb2312 encoding, have to use this
* workaround to make Solaris zh_CN locale work. -sherman
*/
- if (FontManager.isSolaris && font.platName != null &&
+ if (FontUtilities.isSolaris && font.platName != null &&
(font.platName.startsWith(
"/usr/openwin/lib/locale/zh_CN.EUC/X11/fonts/TrueType") ||
font.platName.startsWith(
@@ -407,8 +407,8 @@ abstract class CMap {
subtableLength = buffer.getInt(offset+4) & INTMASK;
}
if (offset+subtableLength > buffer.capacity()) {
- if (FontManager.logging) {
- FontManager.logger.warning("Cmap subtable overflows buffer.");
+ if (FontUtilities.isLogging()) {
+ FontUtilities.getLogger().warning("Cmap subtable overflows buffer.");
}
}
switch (subtableFormat) {
diff --git a/jdk/src/share/classes/sun/font/CompositeFont.java b/jdk/src/share/classes/sun/font/CompositeFont.java
index 4712dc04d3d..7d51e47bc1a 100644
--- a/jdk/src/share/classes/sun/font/CompositeFont.java
+++ b/jdk/src/share/classes/sun/font/CompositeFont.java
@@ -60,7 +60,7 @@ public final class CompositeFont extends Font2D {
public CompositeFont(String name, String[] compFileNames,
String[] compNames, int metricsSlotCnt,
int[] exclRanges, int[] maxIndexes,
- boolean defer) {
+ boolean defer, SunFontManager fm) {
handle = new Font2DHandle(this);
fullName = name;
@@ -85,13 +85,13 @@ public final class CompositeFont extends Font2D {
* The caller could be responsible for this, but for now it seems
* better that it is handled internally to the CompositeFont class.
*/
- if (FontManager.eudcFont != null) {
+ if (fm.getEUDCFont() != null) {
numSlots++;
if (componentNames != null) {
componentNames = new String[numSlots];
System.arraycopy(compNames, 0, componentNames, 0, numSlots-1);
componentNames[numSlots-1] =
- FontManager.eudcFont.getFontName(null);
+ fm.getEUDCFont().getFontName(null);
}
if (componentFileNames != null) {
componentFileNames = new String[numSlots];
@@ -99,7 +99,7 @@ public final class CompositeFont extends Font2D {
componentFileNames, 0, numSlots-1);
}
components = new PhysicalFont[numSlots];
- components[numSlots-1] = FontManager.eudcFont;
+ components[numSlots-1] = fm.getEUDCFont();
deferredInitialisation = new boolean[numSlots];
if (defer) {
for (int i=0; i= 0x10000) {
diff --git a/jdk/src/share/classes/sun/font/FileFont.java b/jdk/src/share/classes/sun/font/FileFont.java
index 5aad11b2acd..74a07af6825 100644
--- a/jdk/src/share/classes/sun/font/FileFont.java
+++ b/jdk/src/share/classes/sun/font/FileFont.java
@@ -158,7 +158,8 @@ public abstract class FileFont extends PhysicalFont {
* rare maybe it is not worth doing this last part.
*/
synchronized void deregisterFontAndClearStrikeCache() {
- FontManager.deRegisterBadFont(this);
+ SunFontManager fm = SunFontManager.getInstance();
+ fm.deRegisterBadFont(this);
for (Reference strikeRef : strikeCache.values()) {
if (strikeRef != null) {
@@ -172,14 +173,14 @@ public abstract class FileFont extends PhysicalFont {
}
}
scaler.dispose();
- scaler = FontManager.getNullScaler();
+ scaler = FontScaler.getNullScaler();
}
StrikeMetrics getFontMetrics(long pScalerContext) {
try {
return getScaler().getFontMetrics(pScalerContext);
} catch (FontScalerException fe) {
- scaler = FontManager.getNullScaler();
+ scaler = FontScaler.getNullScaler();
return getFontMetrics(pScalerContext);
}
}
@@ -188,7 +189,7 @@ public abstract class FileFont extends PhysicalFont {
try {
return getScaler().getGlyphAdvance(pScalerContext, glyphCode);
} catch (FontScalerException fe) {
- scaler = FontManager.getNullScaler();
+ scaler = FontScaler.getNullScaler();
return getGlyphAdvance(pScalerContext, glyphCode);
}
}
@@ -197,7 +198,7 @@ public abstract class FileFont extends PhysicalFont {
try {
getScaler().getGlyphMetrics(pScalerContext, glyphCode, metrics);
} catch (FontScalerException fe) {
- scaler = FontManager.getNullScaler();
+ scaler = FontScaler.getNullScaler();
getGlyphMetrics(pScalerContext, glyphCode, metrics);
}
}
@@ -206,7 +207,7 @@ public abstract class FileFont extends PhysicalFont {
try {
return getScaler().getGlyphImage(pScalerContext, glyphCode);
} catch (FontScalerException fe) {
- scaler = FontManager.getNullScaler();
+ scaler = FontScaler.getNullScaler();
return getGlyphImage(pScalerContext, glyphCode);
}
}
@@ -215,7 +216,7 @@ public abstract class FileFont extends PhysicalFont {
try {
return getScaler().getGlyphOutlineBounds(pScalerContext, glyphCode);
} catch (FontScalerException fe) {
- scaler = FontManager.getNullScaler();
+ scaler = FontScaler.getNullScaler();
return getGlyphOutlineBounds(pScalerContext, glyphCode);
}
}
@@ -224,7 +225,7 @@ public abstract class FileFont extends PhysicalFont {
try {
return getScaler().getGlyphOutline(pScalerContext, glyphCode, x, y);
} catch (FontScalerException fe) {
- scaler = FontManager.getNullScaler();
+ scaler = FontScaler.getNullScaler();
return getGlyphOutline(pScalerContext, glyphCode, x, y);
}
}
@@ -233,7 +234,7 @@ public abstract class FileFont extends PhysicalFont {
try {
return getScaler().getGlyphVectorOutline(pScalerContext, glyphs, numGlyphs, x, y);
} catch (FontScalerException fe) {
- scaler = FontManager.getNullScaler();
+ scaler = FontScaler.getNullScaler();
return getGlyphVectorOutline(pScalerContext, glyphs, numGlyphs, x, y);
}
}
@@ -275,7 +276,8 @@ public abstract class FileFont extends PhysicalFont {
*/
fontFile.delete();
/* remove from delete on exit hook list : */
- FontManager.tmpFontFiles.remove(fontFile);
+ // FIXME: still need to be refactored
+ SunFontManager.getInstance().tmpFontFiles.remove(fontFile);
} catch (Exception e) {
}
}
diff --git a/jdk/src/share/classes/sun/font/FileFontStrike.java b/jdk/src/share/classes/sun/font/FileFontStrike.java
index 11dff8a20c1..b6c63521dd7 100644
--- a/jdk/src/share/classes/sun/font/FileFontStrike.java
+++ b/jdk/src/share/classes/sun/font/FileFontStrike.java
@@ -114,7 +114,7 @@ public class FileFontStrike extends PhysicalStrike {
private static native boolean initNative();
private static boolean isXPorLater = false;
static {
- if (FontManager.isWindows && !FontManager.useT2K &&
+ if (FontUtilities.isWindows && !FontUtilities.useT2K &&
!GraphicsEnvironment.isHeadless()) {
isXPorLater = initNative();
}
@@ -201,7 +201,7 @@ public class FileFontStrike extends PhysicalStrike {
this.disposer = new FontStrikeDisposer(fileFont, desc);
initGlyphCache();
pScalerContext = NullFontScaler.getNullScalerContext();
- FontManager.deRegisterBadFont(fileFont);
+ SunFontManager.getInstance().deRegisterBadFont(fileFont);
return;
}
/* First, see if native code should be used to create the glyph.
@@ -211,8 +211,8 @@ public class FileFontStrike extends PhysicalStrike {
* except that the advance returned by GDI is always overwritten by
* the JDK rasteriser supplied one (see getGlyphImageFromWindows()).
*/
- if (FontManager.isWindows && isXPorLater &&
- !FontManager.useT2K &&
+ if (FontUtilities.isWindows && isXPorLater &&
+ !FontUtilities.useT2K &&
!GraphicsEnvironment.isHeadless() &&
!fileFont.useJavaRasterizer &&
(desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HRGB ||
@@ -241,8 +241,8 @@ public class FileFontStrike extends PhysicalStrike {
}
}
}
- if (FontManager.logging && FontManager.isWindows) {
- FontManager.logger.info
+ if (FontUtilities.isLogging() && FontUtilities.isWindows) {
+ FontUtilities.getLogger().info
("Strike for " + fileFont + " at size = " + intPtSize +
" use natives = " + useNatives +
" useJavaRasteriser = " + fileFont.useJavaRasterizer +
@@ -298,7 +298,7 @@ public class FileFontStrike extends PhysicalStrike {
}
long getGlyphImageFromNative(int glyphCode) {
- if (FontManager.isWindows) {
+ if (FontUtilities.isWindows) {
return getGlyphImageFromWindows(glyphCode);
} else {
return getGlyphImageFromX11(glyphCode);
@@ -366,8 +366,8 @@ public class FileFontStrike extends PhysicalStrike {
} else {
if (useNatives) {
glyphPtr = getGlyphImageFromNative(glyphCode);
- if (glyphPtr == 0L && FontManager.logging) {
- FontManager.logger.info
+ if (glyphPtr == 0L && FontUtilities.isLogging()) {
+ FontUtilities.getLogger().info
("Strike for " + fileFont +
" at size = " + intPtSize +
" couldn't get native glyph for code = " + glyphCode);
@@ -528,7 +528,7 @@ public class FileFontStrike extends PhysicalStrike {
if (segmentedCache) {
int numSegments = (numGlyphs + SEGSIZE-1)/SEGSIZE;
- if (FontManager.longAddresses) {
+ if (longAddresses) {
glyphCacheFormat = SEGLONGARRAY;
segLongGlyphImages = new long[numSegments][];
this.disposer.segLongGlyphImages = segLongGlyphImages;
@@ -538,7 +538,7 @@ public class FileFontStrike extends PhysicalStrike {
this.disposer.segIntGlyphImages = segIntGlyphImages;
}
} else {
- if (FontManager.longAddresses) {
+ if (longAddresses) {
glyphCacheFormat = LONGARRAY;
longGlyphImages = new long[numGlyphs];
this.disposer.longGlyphImages = longGlyphImages;
diff --git a/jdk/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIBorder.java b/jdk/src/share/classes/sun/font/FontAccess.java
similarity index 63%
rename from jdk/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIBorder.java
rename to jdk/src/share/classes/sun/font/FontAccess.java
index 46c35ed1b08..442fb5a8fa3 100644
--- a/jdk/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIBorder.java
+++ b/jdk/src/share/classes/sun/font/FontAccess.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008 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
@@ -22,32 +22,27 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
-package org.jdesktop.synthdesigner.synthmodel;
-import javax.swing.border.Border;
+package sun.font;
-/**
- * UIBorder
- *
- * @author Richard Bair
- * @author Jasper Potts
- */
-public class UIBorder extends UIDefault {
+import java.awt.Font;
- public UIBorder() {
+public abstract class FontAccess {
+
+ private static FontAccess access;
+ public static synchronized void setFontAccess(FontAccess acc) {
+ if (access != null) {
+ throw new InternalError("Attempt to set FontAccessor twice");
+ }
+ access = acc;
}
- public UIBorder(String id, Border b) {
- super(id, b);
+ public static synchronized FontAccess getFontAccess() {
+ return access;
}
- public Border getBorder() {
- return super.getValue();
- }
-
- public void setBorder(Border b) {
- Border old = getBorder();
- super.setValue(b);
- firePropertyChange("border", old, b);
- }
+ public abstract Font2D getFont2D(Font f);
+ public abstract void setFont2D(Font f, Font2DHandle h);
+ public abstract void setCreatedFont(Font f);
+ public abstract boolean isCreatedFont(Font f);
}
diff --git a/jdk/src/share/classes/sun/font/FontDesignMetrics.java b/jdk/src/share/classes/sun/font/FontDesignMetrics.java
index d594f11b259..929c0d21dd8 100644
--- a/jdk/src/share/classes/sun/font/FontDesignMetrics.java
+++ b/jdk/src/share/classes/sun/font/FontDesignMetrics.java
@@ -261,8 +261,9 @@ public final class FontDesignMetrics extends FontMetrics {
* Note that currently Swing native L&F composites are not handled
* by this code as they use the metrics of the physical anyway.
*/
- if (FontManager.maybeUsingAlternateCompositeFonts() &&
- FontManager.getFont2D(font) instanceof CompositeFont) {
+ SunFontManager fm = SunFontManager.getInstance();
+ if (fm.maybeUsingAlternateCompositeFonts() &&
+ FontUtilities.getFont2D(font) instanceof CompositeFont) {
return new FontDesignMetrics(font, frc);
}
@@ -353,7 +354,7 @@ public final class FontDesignMetrics extends FontMetrics {
private void initMatrixAndMetrics() {
- Font2D font2D = FontManager.getFont2D(font);
+ Font2D font2D = FontUtilities.getFont2D(font);
fontStrike = font2D.getStrike(font, frc);
StrikeMetrics metrics = fontStrike.getFontMetrics();
this.ascent = metrics.getAscent();
@@ -473,7 +474,7 @@ public final class FontDesignMetrics extends FontMetrics {
char ch = str.charAt(i);
if (ch < 0x100) {
width += getLatinCharWidth(ch);
- } else if (FontManager.isNonSimpleChar(ch)) {
+ } else if (FontUtilities.isNonSimpleChar(ch)) {
width = new TextLayout(str, font, frc).getAdvance();
break;
} else {
@@ -504,7 +505,7 @@ public final class FontDesignMetrics extends FontMetrics {
char ch = data[i];
if (ch < 0x100) {
width += getLatinCharWidth(ch);
- } else if (FontManager.isNonSimpleChar(ch)) {
+ } else if (FontUtilities.isNonSimpleChar(ch)) {
String str = new String(data, off, len);
width = new TextLayout(str, font, frc).getAdvance();
break;
diff --git a/jdk/src/share/classes/sun/font/FontFamily.java b/jdk/src/share/classes/sun/font/FontFamily.java
index 3f0d5fd601d..ca2d1bfa6ab 100644
--- a/jdk/src/share/classes/sun/font/FontFamily.java
+++ b/jdk/src/share/classes/sun/font/FontFamily.java
@@ -107,8 +107,9 @@ public class FontFamily {
public void setFont(Font2D font, int style) {
if (font.getRank() > familyRank) {
- if (FontManager.logging) {
- FontManager.logger.warning("Rejecting adding " + font +
+ if (FontUtilities.isLogging()) {
+ FontUtilities.getLogger()
+ .warning("Rejecting adding " + font +
" of lower rank " + font.getRank() +
" to family " + this +
" of rank " + familyRank);
diff --git a/jdk/src/share/classes/sun/font/FontManager.java b/jdk/src/share/classes/sun/font/FontManager.java
index 6ac89628e2a..f79adfc13cf 100644
--- a/jdk/src/share/classes/sun/font/FontManager.java
+++ b/jdk/src/share/classes/sun/font/FontManager.java
@@ -22,3831 +22,124 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
-
package sun.font;
import java.awt.Font;
-import java.awt.GraphicsEnvironment;
import java.awt.FontFormatException;
import java.io.File;
-import java.io.FilenameFilter;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
import java.util.Locale;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
import java.util.TreeMap;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
import javax.swing.plaf.FontUIResource;
-import sun.awt.AppContext;
-import sun.awt.FontConfiguration;
-import sun.awt.SunHints;
-import sun.awt.SunToolkit;
-import sun.java2d.HeadlessGraphicsEnvironment;
-import sun.java2d.SunGraphicsEnvironment;
-
-import java.awt.geom.GeneralPath;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-
-import java.lang.reflect.Constructor;
-
-import sun.java2d.Disposer;
-
-/*
+/**
* Interface between Java Fonts (java.awt.Font) and the underlying
* font files/native font resources and the Java and native font scalers.
*/
-public final class FontManager {
+public interface FontManager {
- public static final int FONTFORMAT_NONE = -1;
- public static final int FONTFORMAT_TRUETYPE = 0;
- public static final int FONTFORMAT_TYPE1 = 1;
- public static final int FONTFORMAT_T2K = 2;
- public static final int FONTFORMAT_TTC = 3;
- public static final int FONTFORMAT_COMPOSITE = 4;
- public static final int FONTFORMAT_NATIVE = 5;
-
- public static final int NO_FALLBACK = 0;
- public static final int PHYSICAL_FALLBACK = 1;
- public static final int LOGICAL_FALLBACK = 2;
-
- public static final int QUADPATHTYPE = 1;
- public static final int CUBICPATHTYPE = 2;
-
- /* Pool of 20 font file channels chosen because some UTF-8 locale
- * composite fonts can use up to 16 platform fonts (including the
- * Lucida fall back). This should prevent channel thrashing when
- * dealing with one of these fonts.
- * The pool array stores the fonts, rather than directly referencing
- * the channels, as the font needs to do the open/close work.
- */
- private static final int CHANNELPOOLSIZE = 20;
- private static int lastPoolIndex = 0;
- private static FileFont fontFileCache[] = new FileFont[CHANNELPOOLSIZE];
-
- /* Need to implement a simple linked list scheme for fast
- * traversal and lookup.
- * Also want to "fast path" dialog so there's minimal overhead.
- */
- /* There are at exactly 20 composite fonts: 5 faces (but some are not
- * usually different), in 4 styles. The array may be auto-expanded
- * later if more are needed, eg for user-defined composites or locale
- * variants.
- */
- private static int maxCompFont = 0;
- private static CompositeFont [] compFonts = new CompositeFont[20];
- private static ConcurrentHashMap
- compositeFonts = new ConcurrentHashMap();
- private static ConcurrentHashMap
- physicalFonts = new ConcurrentHashMap();
- private static ConcurrentHashMap
- registeredFontFiles = new ConcurrentHashMap();
-
- /* given a full name find the Font. Remind: there's duplication
- * here in that this contains the content of compositeFonts +
- * physicalFonts.
- */
- private static ConcurrentHashMap
- fullNameToFont = new ConcurrentHashMap();
-
- /* TrueType fonts have localised names. Support searching all
- * of these before giving up on a name.
- */
- private static HashMap localeFullNamesToFont;
-
- private static PhysicalFont defaultPhysicalFont;
-
- /* deprecated, unsupported hack - actually invokes a bug! */
- private static boolean usePlatformFontMetrics = false;
-
- public static Logger logger = null;
- public static boolean logging;
- static boolean longAddresses;
- static String osName;
- static boolean useT2K;
- static boolean isWindows;
- static boolean isSolaris;
- public static boolean isSolaris8; // needed to check for JA wavedash fix.
- public static boolean isSolaris9; // needed to check for songti font usage.
- private static boolean loaded1dot0Fonts = false;
- static SunGraphicsEnvironment sgEnv;
- static boolean loadedAllFonts = false;
- static boolean loadedAllFontFiles = false;
- static TrueTypeFont eudcFont;
- static HashMap jreFontMap;
- static HashSet jreLucidaFontFiles;
- static String[] jreOtherFontFiles;
- static boolean noOtherJREFontFiles = false; // initial assumption.
- static boolean fontConfigFailed = false;
-
- /* Used to indicate required return type from toArray(..); */
- private static String[] STR_ARRAY = new String[0];
-
- private static void initJREFontMap() {
-
- /* Key is familyname+style value as an int.
- * Value is filename containing the font.
- * If no mapping exists, it means there is no font file for the style
- * If the mapping exists but the file doesn't exist in the deferred
- * list then it means its not installed.
- * This looks like a lot of code and strings but if it saves even
- * a single file being opened at JRE start-up there's a big payoff.
- * Lucida Sans is probably the only important case as the others
- * are rarely used. Consider removing the other mappings if there's
- * no evidence they are useful in practice.
- */
- jreFontMap = new HashMap();
- jreLucidaFontFiles = new HashSet();
- if (SunGraphicsEnvironment.isOpenJDK()) {
- return;
- }
- /* Lucida Sans Family */
- jreFontMap.put("lucida sans0", "LucidaSansRegular.ttf");
- jreFontMap.put("lucida sans1", "LucidaSansDemiBold.ttf");
- /* Lucida Sans full names (map Bold and DemiBold to same file) */
- jreFontMap.put("lucida sans regular0", "LucidaSansRegular.ttf");
- jreFontMap.put("lucida sans regular1", "LucidaSansDemiBold.ttf");
- jreFontMap.put("lucida sans bold1", "LucidaSansDemiBold.ttf");
- jreFontMap.put("lucida sans demibold1", "LucidaSansDemiBold.ttf");
-
- /* Lucida Sans Typewriter Family */
- jreFontMap.put("lucida sans typewriter0",
- "LucidaTypewriterRegular.ttf");
- jreFontMap.put("lucida sans typewriter1", "LucidaTypewriterBold.ttf");
- /* Typewriter full names (map Bold and DemiBold to same file) */
- jreFontMap.put("lucida sans typewriter regular0",
- "LucidaTypewriter.ttf");
- jreFontMap.put("lucida sans typewriter regular1",
- "LucidaTypewriterBold.ttf");
- jreFontMap.put("lucida sans typewriter bold1",
- "LucidaTypewriterBold.ttf");
- jreFontMap.put("lucida sans typewriter demibold1",
- "LucidaTypewriterBold.ttf");
-
- /* Lucida Bright Family */
- jreFontMap.put("lucida bright0", "LucidaBrightRegular.ttf");
- jreFontMap.put("lucida bright1", "LucidaBrightDemiBold.ttf");
- jreFontMap.put("lucida bright2", "LucidaBrightItalic.ttf");
- jreFontMap.put("lucida bright3", "LucidaBrightDemiItalic.ttf");
- /* Lucida Bright full names (map Bold and DemiBold to same file) */
- jreFontMap.put("lucida bright regular0", "LucidaBrightRegular.ttf");
- jreFontMap.put("lucida bright regular1", "LucidaBrightDemiBold.ttf");
- jreFontMap.put("lucida bright regular2", "LucidaBrightItalic.ttf");
- jreFontMap.put("lucida bright regular3", "LucidaBrightDemiItalic.ttf");
- jreFontMap.put("lucida bright bold1", "LucidaBrightDemiBold.ttf");
- jreFontMap.put("lucida bright bold3", "LucidaBrightDemiItalic.ttf");
- jreFontMap.put("lucida bright demibold1", "LucidaBrightDemiBold.ttf");
- jreFontMap.put("lucida bright demibold3","LucidaBrightDemiItalic.ttf");
- jreFontMap.put("lucida bright italic2", "LucidaBrightItalic.ttf");
- jreFontMap.put("lucida bright italic3", "LucidaBrightDemiItalic.ttf");
- jreFontMap.put("lucida bright bold italic3",
- "LucidaBrightDemiItalic.ttf");
- jreFontMap.put("lucida bright demibold italic3",
- "LucidaBrightDemiItalic.ttf");
- for (String ffile : jreFontMap.values()) {
- jreLucidaFontFiles.add(ffile);
- }
- }
-
- static {
-
- if (SunGraphicsEnvironment.debugFonts) {
- logger = Logger.getLogger("sun.java2d", null);
- logging = logger.getLevel() != Level.OFF;
- }
- initJREFontMap();
-
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- FontManagerNativeLibrary.load();
-
- // JNI throws an exception if a class/method/field is not found,
- // so there's no need to do anything explicit here.
- initIDs();
-
- switch (StrikeCache.nativeAddressSize) {
- case 8: longAddresses = true; break;
- case 4: longAddresses = false; break;
- default: throw new RuntimeException("Unexpected address size");
- }
-
- osName = System.getProperty("os.name", "unknownOS");
- isSolaris = osName.startsWith("SunOS");
-
- String t2kStr = System.getProperty("sun.java2d.font.scaler");
- if (t2kStr != null) {
- useT2K = "t2k".equals(t2kStr);
- }
- if (isSolaris) {
- String version = System.getProperty("os.version", "unk");
- isSolaris8 = version.equals("5.8");
- isSolaris9 = version.equals("5.9");
- } else {
- isWindows = osName.startsWith("Windows");
- if (isWindows) {
- String eudcFile =
- SunGraphicsEnvironment.eudcFontFileName;
- if (eudcFile != null) {
- try {
- eudcFont = new TrueTypeFont(eudcFile, null, 0,
- true);
- } catch (FontFormatException e) {
- }
- }
- String prop =
- System.getProperty("java2d.font.usePlatformFont");
- if (("true".equals(prop) || getPlatformFontVar())) {
- usePlatformFontMetrics = true;
- System.out.println("Enabling platform font metrics for win32. This is an unsupported option.");
- System.out.println("This yields incorrect composite font metrics as reported by 1.1.x releases.");
- System.out.println("It is appropriate only for use by applications which do not use any Java 2");
- System.out.println("functionality. This property will be removed in a later release.");
- }
- }
- }
- return null;
- }
- });
- }
-
- /* Initialise ptrs used by JNI methods */
- private static native void initIDs();
-
- public static void addToPool(FileFont font) {
-
- FileFont fontFileToClose = null;
- int freeSlot = -1;
-
- synchronized (fontFileCache) {
- /* Avoid duplicate entries in the pool, and don't close() it,
- * since this method is called only from within open().
- * Seeing a duplicate is most likely to happen if the thread
- * was interrupted during a read, forcing perhaps repeated
- * close and open calls and it eventually it ends up pointing
- * at the same slot.
- */
- for (int i=0;i= 0) {
- fontFileCache[freeSlot] = font;
- return;
- } else {
- /* replace with new font. */
- fontFileToClose = fontFileCache[lastPoolIndex];
- fontFileCache[lastPoolIndex] = font;
- /* lastPoolIndex is updated so that the least recently opened
- * file will be closed next.
- */
- lastPoolIndex = (lastPoolIndex+1) % CHANNELPOOLSIZE;
- }
- }
- /* Need to close the font file outside of the synchronized block,
- * since its possible some other thread is in an open() call on
- * this font file, and could be holding its lock and the pool lock.
- * Releasing the pool lock allows that thread to continue, so it can
- * then release the lock on this font, allowing the close() call
- * below to proceed.
- * Also, calling close() is safe because any other thread using
- * the font we are closing() synchronizes all reading, so we
- * will not close the file while its in use.
- */
- if (fontFileToClose != null) {
- fontFileToClose.close();
- }
- }
-
- /*
- * In the normal course of events, the pool of fonts can remain open
- * ready for quick access to their contents. The pool is sized so
- * that it is not an excessive consumer of system resources whilst
- * facilitating performance by providing ready access to the most
- * recently used set of font files.
- * The only reason to call removeFromPool(..) is for a Font that
- * you want to to have GC'd. Currently this would apply only to fonts
- * created with java.awt.Font.createFont(..).
- * In this case, the caller is expected to have arranged for the file
- * to be closed.
- * REMIND: consider how to know when a createFont created font should
- * be closed.
- */
- public static void removeFromPool(FileFont font) {
- synchronized (fontFileCache) {
- for (int i=0; i
- altNameCache) {
-
- CompositeFont cf = new CompositeFont(compositeName,
- componentFileNames,
- componentNames,
- numMetricsSlots,
- exclusionRanges,
- exclusionMaxIndex, defer);
- /* if the cache has an existing composite for this case, make
- * its handle point to this new font.
- * This ensures that when the altNameCache that is passed in
- * is the global mapNameCache - ie we are running as an application -
- * that any statically created java.awt.Font instances which already
- * have a Font2D instance will have that re-directed to the new Font
- * on subsequent uses. This is particularly important for "the"
- * default font instance, or similar cases where a UI toolkit (eg
- * Swing) has cached a java.awt.Font. Note that if Swing is using
- * a custom composite APIs which update the standard composites have
- * no effect - this is typically the case only when using the Windows
- * L&F where these APIs would conflict with that L&F anyway.
- */
- Font2D oldFont = (Font2D)
- altNameCache.get(compositeName.toLowerCase(Locale.ENGLISH));
- if (oldFont instanceof CompositeFont) {
- oldFont.handle.font2D = cf;
- }
- altNameCache.put(compositeName.toLowerCase(Locale.ENGLISH), cf);
- }
-
- private static void addCompositeToFontList(CompositeFont f, int rank) {
-
- if (logging) {
- logger.info("Add to Family "+ f.familyName +
- ", Font " + f.fullName + " rank="+rank);
- }
- f.setRank(rank);
- compositeFonts.put(f.fullName, f);
- fullNameToFont.put(f.fullName.toLowerCase(Locale.ENGLISH), f);
-
- FontFamily family = FontFamily.getFamily(f.familyName);
- if (family == null) {
- family = new FontFamily(f.familyName, true, rank);
- }
- family.setFont(f, f.style);
- }
-
- /*
- * Systems may have fonts with the same name.
- * We want to register only one of such fonts (at least until
- * such time as there might be APIs which can accommodate > 1).
- * Rank is 1) font configuration fonts, 2) JRE fonts, 3) OT/TT fonts,
- * 4) Type1 fonts, 5) native fonts.
- *
- * If the new font has the same name as the old font, the higher
- * ranked font gets added, replacing the lower ranked one.
- * If the fonts are of equal rank, then make a special case of
- * font configuration rank fonts, which are on closer inspection,
- * OT/TT fonts such that the larger font is registered. This is
- * a heuristic since a font may be "larger" in the sense of more
- * code points, or be a larger "file" because it has more bitmaps.
- * So it is possible that using filesize may lead to less glyphs, and
- * using glyphs may lead to lower quality display. Probably number
- * of glyphs is the ideal, but filesize is information we already
- * have and is good enough for the known cases.
- * Also don't want to register fonts that match JRE font families
- * but are coming from a source other than the JRE.
- * This will ensure that we will algorithmically style the JRE
- * plain font and get the same set of glyphs for all styles.
- *
- * Note that this method returns a value
- * if it returns the same object as its argument that means this
- * font was newly registered.
- * If it returns a different object it means this font already exists,
- * and you should use that one.
- * If it returns null means this font was not registered and none
- * in that name is registered. The caller must find a substitute
- */
- private static PhysicalFont addToFontList(PhysicalFont f, int rank) {
-
- String fontName = f.fullName;
- String familyName = f.familyName;
- if (fontName == null || "".equals(fontName)) {
- return null;
- }
- if (compositeFonts.containsKey(fontName)) {
- /* Don't register any font that has the same name as a composite */
- return null;
- }
- f.setRank(rank);
- if (!physicalFonts.containsKey(fontName)) {
- if (logging) {
- logger.info("Add to Family "+familyName +
- ", Font " + fontName + " rank="+rank);
- }
- physicalFonts.put(fontName, f);
- FontFamily family = FontFamily.getFamily(familyName);
- if (family == null) {
- family = new FontFamily(familyName, false, rank);
- family.setFont(f, f.style);
- } else if (family.getRank() >= rank) {
- family.setFont(f, f.style);
- }
- fullNameToFont.put(fontName.toLowerCase(Locale.ENGLISH), f);
- return f;
- } else {
- PhysicalFont newFont = f;
- PhysicalFont oldFont = physicalFonts.get(fontName);
- if (oldFont == null) {
- return null;
- }
- /* If the new font is of an equal or higher rank, it is a
- * candidate to replace the current one, subject to further tests.
- */
- if (oldFont.getRank() >= rank) {
-
- /* All fonts initialise their mapper when first
- * used. If the mapper is non-null then this font
- * has been accessed at least once. In that case
- * do not replace it. This may be overly stringent,
- * but its probably better not to replace a font that
- * someone is already using without a compelling reason.
- * Additionally the primary case where it is known
- * this behaviour is important is in certain composite
- * fonts, and since all the components of a given
- * composite are usually initialised together this
- * is unlikely. For this to be a problem, there would
- * have to be a case where two different composites used
- * different versions of the same-named font, and they
- * were initialised and used at separate times.
- * In that case we continue on and allow the new font to
- * be installed, but replaceFont will continue to allow
- * the original font to be used in Composite fonts.
- */
- if (oldFont.mapper != null && rank > Font2D.FONT_CONFIG_RANK) {
- return oldFont;
- }
-
- /* Normally we require a higher rank to replace a font,
- * but as a special case, if the two fonts are the same rank,
- * and are instances of TrueTypeFont we want the
- * more complete (larger) one.
- */
- if (oldFont.getRank() == rank) {
- if (oldFont instanceof TrueTypeFont &&
- newFont instanceof TrueTypeFont) {
- TrueTypeFont oldTTFont = (TrueTypeFont)oldFont;
- TrueTypeFont newTTFont = (TrueTypeFont)newFont;
- if (oldTTFont.fileSize >= newTTFont.fileSize) {
- return oldFont;
- }
- } else {
- return oldFont;
- }
- }
- /* Don't replace ever JRE fonts.
- * This test is in case a font configuration references
- * a Lucida font, which has been mapped to a Lucida
- * from the host O/S. The assumption here is that any
- * such font configuration file is probably incorrect, or
- * the host O/S version is for the use of AWT.
- * In other words if we reach here, there's a possible
- * problem with our choice of font configuration fonts.
- */
- if (oldFont.platName.startsWith(
- SunGraphicsEnvironment.jreFontDirName)) {
- if (logging) {
- logger.warning("Unexpected attempt to replace a JRE " +
- " font " + fontName + " from " +
- oldFont.platName +
- " with " + newFont.platName);
- }
- return oldFont;
- }
-
- if (logging) {
- logger.info("Replace in Family " + familyName +
- ",Font " + fontName + " new rank="+rank +
- " from " + oldFont.platName +
- " with " + newFont.platName);
- }
- replaceFont(oldFont, newFont);
- physicalFonts.put(fontName, newFont);
- fullNameToFont.put(fontName.toLowerCase(Locale.ENGLISH),
- newFont);
-
- FontFamily family = FontFamily.getFamily(familyName);
- if (family == null) {
- family = new FontFamily(familyName, false, rank);
- family.setFont(newFont, newFont.style);
- } else if (family.getRank() >= rank) {
- family.setFont(newFont, newFont.style);
- }
- return newFont;
- } else {
- return oldFont;
- }
- }
- }
-
- public static Font2D[] getRegisteredFonts() {
- PhysicalFont[] physFonts = getPhysicalFonts();
- int mcf = maxCompFont; /* for MT-safety */
- Font2D[] regFonts = new Font2D[physFonts.length+mcf];
- System.arraycopy(compFonts, 0, regFonts, 0, mcf);
- System.arraycopy(physFonts, 0, regFonts, mcf, physFonts.length);
- return regFonts;
- }
-
- public static PhysicalFont[] getPhysicalFonts() {
- return physicalFonts.values().toArray(new PhysicalFont[0]);
- }
-
-
- /* The class FontRegistrationInfo is used when a client says not
- * to register a font immediately. This mechanism is used to defer
- * initialisation of all the components of composite fonts at JRE
- * start-up. The CompositeFont class is "aware" of this and when it
- * is first used it asks for the registration of its components.
- * Also in the event that any physical font is requested the
- * deferred fonts are initialised before triggering a search of the
- * system.
- * Two maps are used. One to track the deferred fonts. The
- * other to track the fonts that have been initialised through this
- * mechanism.
- */
-
- private static final class FontRegistrationInfo {
-
- String fontFilePath;
- String[] nativeNames;
- int fontFormat;
- boolean javaRasterizer;
- int fontRank;
-
- FontRegistrationInfo(String fontPath, String[] names, int format,
- boolean useJavaRasterizer, int rank) {
- this.fontFilePath = fontPath;
- this.nativeNames = names;
- this.fontFormat = format;
- this.javaRasterizer = useJavaRasterizer;
- this.fontRank = rank;
- }
- }
-
- private static final ConcurrentHashMap
- deferredFontFiles =
- new ConcurrentHashMap();
- private static final ConcurrentHashMap
- initialisedFonts = new ConcurrentHashMap();
-
- /* Remind: possibly enhance initialiseDeferredFonts() to be
- * optionally given a name and a style and it could stop when it
- * finds that font - but this would be a problem if two of the
- * fonts reference the same font face name (cf the Solaris
- * euro fonts).
- */
- public static synchronized void initialiseDeferredFonts() {
- for (String fileName : deferredFontFiles.keySet()) {
- initialiseDeferredFont(fileName);
- }
- }
-
- public static synchronized void registerDeferredJREFonts(String jreDir) {
- for (FontRegistrationInfo info : deferredFontFiles.values()) {
- if (info.fontFilePath != null &&
- info.fontFilePath.startsWith(jreDir)) {
- initialiseDeferredFont(info.fontFilePath);
- }
- }
- }
-
- /* We keep a map of the files which contain the Lucida fonts so we
- * don't need to search for them.
- * But since we know what fonts these files contain, we can also avoid
- * opening them to look for a font name we don't recognise - see
- * findDeferredFont().
- * For typical cases where the font isn't a JRE one the overhead is
- * this method call, HashMap.get() and null reference test, then
- * a boolean test of noOtherJREFontFiles.
- */
- private static PhysicalFont findJREDeferredFont(String name, int style) {
-
- PhysicalFont physicalFont;
- String nameAndStyle = name.toLowerCase(Locale.ENGLISH) + style;
- String fileName = jreFontMap.get(nameAndStyle);
- if (fileName != null) {
- initSGEnv(); /* ensure jreFontDirName is initialised */
- fileName = SunGraphicsEnvironment.jreFontDirName +
- File.separator + fileName;
- if (deferredFontFiles.get(fileName) != null) {
- physicalFont = initialiseDeferredFont(fileName);
- if (physicalFont != null &&
- (physicalFont.getFontName(null).equalsIgnoreCase(name) ||
- physicalFont.getFamilyName(null).equalsIgnoreCase(name))
- && physicalFont.style == style) {
- return physicalFont;
- }
- }
- }
-
- /* Iterate over the deferred font files looking for any in the
- * jre directory that we didn't recognise, open each of these.
- * In almost all installations this will quickly fall through
- * because only the Lucidas will be present and jreOtherFontFiles
- * will be empty.
- * noOtherJREFontFiles is used so we can skip this block as soon
- * as its determined that its not needed - almost always after the
- * very first time through.
- */
- if (noOtherJREFontFiles) {
- return null;
- }
- synchronized (jreLucidaFontFiles) {
- if (jreOtherFontFiles == null) {
- HashSet otherFontFiles = new HashSet();
- for (String deferredFile : deferredFontFiles.keySet()) {
- File file = new File(deferredFile);
- String dir = file.getParent();
- String fname = file.getName();
- /* skip names which aren't absolute, aren't in the JRE
- * directory, or are known Lucida fonts.
- */
- if (dir == null ||
- !dir.equals(SunGraphicsEnvironment.jreFontDirName) ||
- jreLucidaFontFiles.contains(fname)) {
- continue;
- }
- otherFontFiles.add(deferredFile);
- }
- jreOtherFontFiles = otherFontFiles.toArray(STR_ARRAY);
- if (jreOtherFontFiles.length == 0) {
- noOtherJREFontFiles = true;
- }
- }
-
- for (int i=0; i fontToFileMap,
- HashMap fontToFamilyNameMap,
- HashMap>
- familyToFontListMap,
- Locale locale);
-
- /* Obtained from Platform APIs (windows only)
- * Map from lower-case font full name to basename of font file.
- * Eg "arial bold" -> ARIALBD.TTF.
- * For TTC files, there is a mapping for each font in the file.
- */
- private static HashMap fontToFileMap = null;
-
- /* Obtained from Platform APIs (windows only)
- * Map from lower-case font full name to the name of its font family
- * Eg "arial bold" -> "Arial"
- */
- private static HashMap fontToFamilyNameMap = null;
-
- /* Obtained from Platform APIs (windows only)
- * Map from a lower-case family name to a list of full names of
- * the member fonts, eg:
- * "arial" -> ["Arial", "Arial Bold", "Arial Italic","Arial Bold Italic"]
- */
- private static HashMap> familyToFontListMap= null;
-
- /* The directories which contain platform fonts */
- private static String[] pathDirs = null;
-
- private static boolean haveCheckedUnreferencedFontFiles;
-
- private static String[] getFontFilesFromPath(boolean noType1) {
- final FilenameFilter filter;
- if (noType1) {
- filter = SunGraphicsEnvironment.ttFilter;
- } else {
- filter = new SunGraphicsEnvironment.TTorT1Filter();
- }
- return (String[])AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- if (pathDirs.length == 1) {
- File dir = new File(pathDirs[0]);
- String[] files = dir.list(filter);
- if (files == null) {
- return new String[0];
- }
- for (int f=0; f fileList = new ArrayList();
- for (int i = 0; i< pathDirs.length; i++) {
- File dir = new File(pathDirs[i]);
- String[] files = dir.list(filter);
- if (files == null) {
- continue;
- }
- for (int f=0; f unmappedFontNames = null;
- for (String font : fontToFamilyNameMap.keySet()) {
- String file = fontToFileMap.get(font);
- if (file == null) {
- if (font.indexOf(" ") > 0) {
- String newName = font.replaceFirst(" ", " ");
- file = fontToFileMap.get(newName);
- /* If this name exists and isn't for a valid name
- * replace the mapping to the file with this font
- */
- if (file != null &&
- !fontToFamilyNameMap.containsKey(newName)) {
- fontToFileMap.remove(newName);
- fontToFileMap.put(font, file);
- }
- } else if (font.equals("marlett")) {
- fontToFileMap.put(font, "marlett.ttf");
- } else if (font.equals("david")) {
- file = fontToFileMap.get("david regular");
- if (file != null) {
- fontToFileMap.remove("david regular");
- fontToFileMap.put("david", file);
- }
- } else {
- if (unmappedFontNames == null) {
- unmappedFontNames = new ArrayList();
- }
- unmappedFontNames.add(font);
- }
- }
- }
-
- if (unmappedFontNames != null) {
- HashSet unmappedFontFiles = new HashSet();
-
- /* Every font key in fontToFileMap ought to correspond to a
- * font key in fontToFamilyNameMap. Entries that don't seem
- * to correspond are likely fonts that were named differently
- * by GDI than in the registry. One known cause of this is when
- * Windows has had its regional settings changed so that from
- * GDI we get a localised (eg Chinese or Japanese) name for the
- * font, but the registry retains the English version of the name
- * that corresponded to the "install" locale for windows.
- * Since we are in this code block because there are unmapped
- * font names, we can look to find unused font->file mappings
- * and then open the files to read the names. We don't generally
- * want to open font files, as its a performance hit, but this
- * occurs only for a small number of fonts on specific system
- * configs - ie is believed that a "true" Japanese windows would
- * have JA names in the registry too.
- * Clone fontToFileMap and remove from the clone all keys which
- * match a fontToFamilyNameMap key. What remains maps to the
- * files we want to open to find the fonts GDI returned.
- * A font in such a file is added to the fontToFileMap after
- * checking its one of the unmappedFontNames we are looking for.
- * The original name that didn't map is removed from fontToFileMap
- * so essentially this "fixes up" fontToFileMap to use the same
- * name as GDI.
- * Also note that typically the fonts for which this occurs in
- * CJK locales are TTC fonts and not all fonts in a TTC may have
- * localised names. Eg MSGOTHIC.TTC contains 3 fonts and one of
- * them "MS UI Gothic" has no JA name whereas the other two do.
- * So not every font in these files is unmapped or new.
- */
- HashMap ffmapCopy =
- (HashMap)(fontToFileMap.clone());
- for (String key : fontToFamilyNameMap.keySet()) {
- ffmapCopy.remove(key);
- }
- for (String key : ffmapCopy.keySet()) {
- unmappedFontFiles.add(ffmapCopy.get(key));
- fontToFileMap.remove(key);
- }
-
- resolveFontFiles(unmappedFontFiles, unmappedFontNames);
-
- /* If there are still unmapped font names, this means there's
- * something that wasn't in the registry. We need to get all
- * the font files directly and look at the ones that weren't
- * found in the registry.
- */
- if (unmappedFontNames.size() > 0) {
-
- /* getFontFilesFromPath() returns all lower case names.
- * To compare we also need lower case
- * versions of the names from the registry.
- */
- ArrayList registryFiles = new ArrayList();
-
- for (String regFile : fontToFileMap.values()) {
- registryFiles.add(regFile.toLowerCase());
- }
- /* We don't look for Type1 files here as windows will
- * not enumerate these, so aren't useful in reconciling
- * GDI's unmapped files. We do find these later when
- * we enumerate all fonts.
- */
- for (String pathFile : getFontFilesFromPath(true)) {
- if (!registryFiles.contains(pathFile)) {
- unmappedFontFiles.add(pathFile);
- }
- }
-
- resolveFontFiles(unmappedFontFiles, unmappedFontNames);
- }
-
- /* remove from the set of names that will be returned to the
- * user any fonts that can't be mapped to files.
- */
- if (unmappedFontNames.size() > 0) {
- int sz = unmappedFontNames.size();
- for (int i=0; i registryFiles = new ArrayList();
- for (String regFile : fontToFileMap.values()) {
- registryFiles.add(regFile.toLowerCase());
- }
-
- /* To avoid any issues with concurrent modification, create
- * copies of the existing maps, add the new fonts into these
- * and then replace the references to the old ones with the
- * new maps. ConcurrentHashmap is another option but its a lot
- * more changes and with this exception, these maps are intended
- * to be static.
- */
- HashMap fontToFileMap2 = null;
- HashMap fontToFamilyNameMap2 = null;
- HashMap> familyToFontListMap2 = null;;
-
- for (String pathFile : getFontFilesFromPath(false)) {
- if (!registryFiles.contains(pathFile)) {
- if (logging) {
- logger.info("Found non-registry file : " + pathFile);
- }
- PhysicalFont f = registerFontFile(getPathName(pathFile));
- if (f == null) {
- continue;
- }
- if (fontToFileMap2 == null) {
- fontToFileMap2 = new HashMap(fontToFileMap);
- fontToFamilyNameMap2 =
- new HashMap(fontToFamilyNameMap);
- familyToFontListMap2 = new
- HashMap>(familyToFontListMap);
- }
- String fontName = f.getFontName(null);
- String family = f.getFamilyName(null);
- String familyLC = family.toLowerCase();
- fontToFamilyNameMap2.put(fontName, family);
- fontToFileMap2.put(fontName, pathFile);
- ArrayList fonts = familyToFontListMap2.get(familyLC);
- if (fonts == null) {
- fonts = new ArrayList();
- } else {
- fonts = new ArrayList(fonts);
- }
- fonts.add(fontName);
- familyToFontListMap2.put(familyLC, fonts);
- }
- }
- if (fontToFileMap2 != null) {
- fontToFileMap = fontToFileMap2;
- familyToFontListMap = familyToFontListMap2;
- fontToFamilyNameMap = fontToFamilyNameMap2;
- }
- }
-
- private static void resolveFontFiles(HashSet unmappedFiles,
- ArrayList unmappedFonts) {
-
- Locale l = SunToolkit.getStartupLocale();
-
- for (String file : unmappedFiles) {
- try {
- int fn = 0;
- TrueTypeFont ttf;
- String fullPath = getPathName(file);
- if (logging) {
- logger.info("Trying to resolve file " + fullPath);
- }
- do {
- ttf = new TrueTypeFont(fullPath, null, fn++, true);
- // prefer the font's locale name.
- String fontName = ttf.getFontName(l).toLowerCase();
- if (unmappedFonts.contains(fontName)) {
- fontToFileMap.put(fontName, file);
- unmappedFonts.remove(fontName);
- if (logging) {
- logger.info("Resolved absent registry entry for " +
- fontName + " located in " + fullPath);
- }
- }
- }
- while (fn < ttf.getFontCount());
- } catch (Exception e) {
- }
- }
- }
-
- private static synchronized HashMap getFullNameToFileMap() {
- if (fontToFileMap == null) {
-
- initSGEnv();
- pathDirs = sgEnv.getPlatformFontDirs();
-
- fontToFileMap = new HashMap(100);
- fontToFamilyNameMap = new HashMap(100);
- familyToFontListMap = new HashMap>(50);
- populateFontFileNameMap(fontToFileMap,
- fontToFamilyNameMap,
- familyToFontListMap,
- Locale.ENGLISH);
- if (isWindows) {
- resolveWindowsFonts();
- }
- if (logging) {
- logPlatformFontInfo();
- }
- }
- return fontToFileMap;
- }
-
- private static void logPlatformFontInfo() {
- for (int i=0; i< pathDirs.length;i++) {
- logger.info("fontdir="+pathDirs[i]);
- }
- for (String keyName : fontToFileMap.keySet()) {
- logger.info("font="+keyName+" file="+ fontToFileMap.get(keyName));
- }
- for (String keyName : fontToFamilyNameMap.keySet()) {
- logger.info("font="+keyName+" family="+
- fontToFamilyNameMap.get(keyName));
- }
- for (String keyName : familyToFontListMap.keySet()) {
- logger.info("family="+keyName+ " fonts="+
- familyToFontListMap.get(keyName));
- }
- }
-
- /* Note this return list excludes logical fonts and JRE fonts */
- public static String[] getFontNamesFromPlatform() {
- if (getFullNameToFileMap().size() == 0) {
- return null;
- }
- checkForUnreferencedFontFiles();
- /* This odd code with TreeMap is used to preserve a historical
- * behaviour wrt the sorting order .. */
- ArrayList fontNames = new ArrayList();
- for (ArrayList a : familyToFontListMap.values()) {
- for (String s : a) {
- fontNames.add(s);
- }
- }
- return fontNames.toArray(STR_ARRAY);
- }
-
- public static boolean gotFontsFromPlatform() {
- return getFullNameToFileMap().size() != 0;
- }
-
- public static String getFileNameForFontName(String fontName) {
- String fontNameLC = fontName.toLowerCase(Locale.ENGLISH);
- return fontToFileMap.get(fontNameLC);
- }
-
- private static PhysicalFont registerFontFile(String file) {
- if (new File(file).isAbsolute() &&
- !registeredFontFiles.contains(file)) {
- int fontFormat = FONTFORMAT_NONE;
- int fontRank = Font2D.UNKNOWN_RANK;
- if (SunGraphicsEnvironment.ttFilter.accept(null, file)) {
- fontFormat = FONTFORMAT_TRUETYPE;
- fontRank = Font2D.TTF_RANK;
- } else if
- (SunGraphicsEnvironment.t1Filter.accept(null, file)) {
- fontFormat = FONTFORMAT_TYPE1;
- fontRank = Font2D.TYPE1_RANK;
- }
- if (fontFormat == FONTFORMAT_NONE) {
- return null;
- }
- return registerFontFile(file, null, fontFormat, false, fontRank);
- }
- return null;
- }
-
- /* Used to register any font files that are found by platform APIs
- * that weren't previously found in the standard font locations.
- * the isAbsolute() check is needed since that's whats stored in the
- * set, and on windows, the fonts in the system font directory that
- * are in the fontToFileMap are just basenames. We don't want to try
- * to register those again, but we do want to register other registry
- * installed fonts.
- */
- public static void registerOtherFontFiles(HashSet registeredFontFiles) {
- if (getFullNameToFileMap().size() == 0) {
- return;
- }
- for (String file : fontToFileMap.values()) {
- registerFontFile(file);
- }
- }
-
- public static boolean
- getFamilyNamesFromPlatform(TreeMap familyNames,
- Locale requestedLocale) {
- if (getFullNameToFileMap().size() == 0) {
- return false;
- }
- checkForUnreferencedFontFiles();
- for (String name : fontToFamilyNameMap.values()) {
- familyNames.put(name.toLowerCase(requestedLocale), name);
- }
- return true;
- }
-
- /* Path may be absolute or a base file name relative to one of
- * the platform font directories
- */
- private static String getPathName(final String s) {
- File f = new File(s);
- if (f.isAbsolute()) {
- return s;
- } else if (pathDirs.length==1) {
- return pathDirs[0] + File.separator + s;
- } else {
- String path = java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public String run() {
- for (int p=0; p family = null;
- String fontFile = null;
- String familyName = fontToFamilyNameMap.get(lcName);
- if (familyName != null) {
- fontFile = fontToFileMap.get(lcName);
- family = familyToFontListMap.get
- (familyName.toLowerCase(Locale.ENGLISH));
- } else {
- family = familyToFontListMap.get(lcName); // is lcName is a family?
- if (family != null && family.size() > 0) {
- String lcFontName = family.get(0).toLowerCase(Locale.ENGLISH);
- if (lcFontName != null) {
- familyName = fontToFamilyNameMap.get(lcFontName);
- }
- }
- }
- if (family == null || familyName == null) {
- return null;
- }
- String [] fontList = (String[])family.toArray(STR_ARRAY);
- if (fontList.length == 0) {
- return null;
- }
-
- /* first check that for every font in this family we can find
- * a font file. The specific reason for doing this is that
- * in at least one case on Windows a font has the face name "David"
- * but the registry entry is "David Regular". That is the "unique"
- * name of the font but in other cases the registry contains the
- * "full" name. See the specifications of name ids 3 and 4 in the
- * TrueType 'name' table.
- * In general this could cause a problem that we fail to register
- * if we all members of a family that we may end up mapping to
- * the wrong font member: eg return Bold when Plain is needed.
- */
- for (int f=0;f fontNameCache =
- new ConcurrentHashMap();
-
- /*
* The client supplies a name and a style.
* The name could be a family name, or a full name.
* A font may exist with the specified style, or it may
* exist only in some other style. For non-native fonts the scaler
* may be able to emulate the required style.
*/
- public static Font2D findFont2D(String name, int style, int fallback) {
- String lowerCaseName = name.toLowerCase(Locale.ENGLISH);
- String mapName = lowerCaseName + dotStyleStr(style);
- Font2D font;
+ public Font2D findFont2D(String name, int style, int fallback);
- /* If preferLocaleFonts() or preferProportionalFonts() has been
- * called we may be using an alternate set of composite fonts in this
- * app context. The presence of a pre-built name map indicates whether
- * this is so, and gives access to the alternate composite for the
- * name.
- */
- if (usingPerAppContextComposites) {
- ConcurrentHashMap altNameCache =
- (ConcurrentHashMap)
- AppContext.getAppContext().get(CompositeFont.class);
- if (altNameCache != null) {
- font = (Font2D)altNameCache.get(mapName);
- } else {
- font = null;
- }
- } else {
- font = fontNameCache.get(mapName);
- }
- if (font != null) {
- return font;
- }
-
- if (logging) {
- logger.info("Search for font: " + name);
- }
-
- // The check below is just so that the bitmap fonts being set by
- // AWT and Swing thru the desktop properties do not trigger the
- // the load fonts case. The two bitmap fonts are now mapped to
- // appropriate equivalents for serif and sansserif.
- // Note that the cost of this comparison is only for the first
- // call until the map is filled.
- if (isWindows) {
- if (lowerCaseName.equals("ms sans serif")) {
- name = "sansserif";
- } else if (lowerCaseName.equals("ms serif")) {
- name = "serif";
- }
- }
-
- /* This isn't intended to support a client passing in the
- * string default, but if a client passes in null for the name
- * the java.awt.Font class internally substitutes this name.
- * So we need to recognise it here to prevent a loadFonts
- * on the unrecognised name. The only potential problem with
- * this is it would hide any real font called "default"!
- * But that seems like a potential problem we can ignore for now.
- */
- if (lowerCaseName.equals("default")) {
- name = "dialog";
- }
-
- /* First see if its a family name. */
- FontFamily family = FontFamily.getFamily(name);
- if (family != null) {
- font = family.getFontWithExactStyleMatch(style);
- if (font == null) {
- font = findDeferredFont(name, style);
- }
- if (font == null) {
- font = family.getFont(style);
- }
- if (font == null) {
- font = family.getClosestStyle(style);
- }
- if (font != null) {
- fontNameCache.put(mapName, font);
- return font;
- }
- }
-
- /* If it wasn't a family name, it should be a full name of
- * either a composite, or a physical font
- */
- font = fullNameToFont.get(lowerCaseName);
- if (font != null) {
- /* Check that the requested style matches the matched font's style.
- * But also match style automatically if the requested style is
- * "plain". This because the existing behaviour is that the fonts
- * listed via getAllFonts etc always list their style as PLAIN.
- * This does lead to non-commutative behaviours where you might
- * start with "Lucida Sans Regular" and ask for a BOLD version
- * and get "Lucida Sans DemiBold" but if you ask for the PLAIN
- * style of "Lucida Sans DemiBold" you get "Lucida Sans DemiBold".
- * This consistent however with what happens if you have a bold
- * version of a font and no plain version exists - alg. styling
- * doesn't "unbolden" the font.
- */
- if (font.style == style || style == Font.PLAIN) {
- fontNameCache.put(mapName, font);
- return font;
- } else {
- /* If it was a full name like "Lucida Sans Regular", but
- * the style requested is "bold", then we want to see if
- * there's the appropriate match against another font in
- * that family before trying to load all fonts, or applying a
- * algorithmic styling
- */
- family = FontFamily.getFamily(font.getFamilyName(null));
- if (family != null) {
- Font2D familyFont = family.getFont(style|font.style);
- /* We exactly matched the requested style, use it! */
- if (familyFont != null) {
- fontNameCache.put(mapName, familyFont);
- return familyFont;
- } else {
- /* This next call is designed to support the case
- * where bold italic is requested, and if we must
- * style, then base it on either bold or italic -
- * not on plain!
- */
- familyFont = family.getClosestStyle(style|font.style);
- if (familyFont != null) {
- /* The next check is perhaps one
- * that shouldn't be done. ie if we get this
- * far we have probably as close a match as we
- * are going to get. We could load all fonts to
- * see if somehow some parts of the family are
- * loaded but not all of it.
- */
- if (familyFont.canDoStyle(style|font.style)) {
- fontNameCache.put(mapName, familyFont);
- return familyFont;
- }
- }
- }
- }
- }
- }
-
- /* If reach here its possible that this is in a client which never
- * loaded the GraphicsEnvironment, so we haven't even loaded ANY of
- * the fonts from the environment. Do so now and recurse.
- */
- if (sgEnv == null) {
- initSGEnv();
- return findFont2D(name, style, fallback);
- }
-
- if (isWindows) {
- /* Don't want Windows to return a Lucida Sans font from
- * C:\Windows\Fonts
- */
- if (deferredFontFiles.size() > 0) {
- font = findJREDeferredFont(lowerCaseName, style);
- if (font != null) {
- fontNameCache.put(mapName, font);
- return font;
- }
- }
- font = findFontFromPlatform(lowerCaseName, style);
- if (font != null) {
- if (logging) {
- logger.info("Found font via platform API for request:\"" +
- name + "\":, style="+style+
- " found font: " + font);
- }
- fontNameCache.put(mapName, font);
- return font;
- }
- }
-
- /* If reach here and no match has been located, then if there are
- * uninitialised deferred fonts, load as many of those as needed
- * to find the deferred font. If none is found through that
- * search continue on.
- * There is possibly a minor issue when more than one
- * deferred font implements the same font face. Since deferred
- * fonts are only those in font configuration files, this is a
- * controlled situation, the known case being Solaris euro_fonts
- * versions of Arial, Times New Roman, Courier New. However
- * the larger font will transparently replace the smaller one
- * - see addToFontList() - when it is needed by the composite font.
- */
- if (deferredFontFiles.size() > 0) {
- font = findDeferredFont(name, style);
- if (font != null) {
- fontNameCache.put(mapName, font);
- return font;
- }
- }
-
- /* Some apps use deprecated 1.0 names such as helvetica and courier. On
- * Solaris these are Type1 fonts in /usr/openwin/lib/X11/fonts/Type1.
- * If running on Solaris will register all the fonts in this
- * directory.
- * May as well register the whole directory without actually testing
- * the font name is one of the deprecated names as the next step would
- * load all fonts which are in this directory anyway.
- * In the event that this lookup is successful it potentially "hides"
- * TrueType versions of such fonts that are elsewhere but since they
- * do not exist on Solaris this is not a problem.
- * Set a flag to indicate we've done this registration to avoid
- * repetition and more seriously, to avoid recursion.
- */
- if (isSolaris&&!loaded1dot0Fonts) {
- /* "timesroman" is a special case since that's not the
- * name of any known font on Solaris or elsewhere.
- */
- if (lowerCaseName.equals("timesroman")) {
- font = findFont2D("serif", style, fallback);
- fontNameCache.put(mapName, font);
- }
- sgEnv.register1dot0Fonts();
- loaded1dot0Fonts = true;
- Font2D ff = findFont2D(name, style, fallback);
- return ff;
- }
-
- /* We check for application registered fonts before
- * explicitly loading all fonts as if necessary the registration
- * code will have done so anyway. And we don't want to needlessly
- * load the actual files for all fonts.
- * Just as for installed fonts we check for family before fullname.
- * We do not add these fonts to fontNameCache for the
- * app context case which eliminates the overhead of a per context
- * cache for these.
- */
-
- if (fontsAreRegistered || fontsAreRegisteredPerAppContext) {
- Hashtable familyTable = null;
- Hashtable nameTable;
-
- if (fontsAreRegistered) {
- familyTable = createdByFamilyName;
- nameTable = createdByFullName;
- } else {
- AppContext appContext = AppContext.getAppContext();
- familyTable =
- (Hashtable)appContext.get(regFamilyKey);
- nameTable =
- (Hashtable)appContext.get(regFullNameKey);
- }
-
- family = familyTable.get(lowerCaseName);
- if (family != null) {
- font = family.getFontWithExactStyleMatch(style);
- if (font == null) {
- font = family.getFont(style);
- }
- if (font == null) {
- font = family.getClosestStyle(style);
- }
- if (font != null) {
- if (fontsAreRegistered) {
- fontNameCache.put(mapName, font);
- }
- return font;
- }
- }
- font = nameTable.get(lowerCaseName);
- if (font != null) {
- if (fontsAreRegistered) {
- fontNameCache.put(mapName, font);
- }
- return font;
- }
- }
-
- /* If reach here and no match has been located, then if all fonts
- * are not yet loaded, do so, and then recurse.
- */
- if (!loadedAllFonts) {
- if (logging) {
- logger.info("Load fonts looking for:" + name);
- }
- sgEnv.loadFonts();
- loadedAllFonts = true;
- return findFont2D(name, style, fallback);
- }
-
- if (!loadedAllFontFiles) {
- if (logging) {
- logger.info("Load font files looking for:" + name);
- }
- sgEnv.loadFontFiles();
- loadedAllFontFiles = true;
- return findFont2D(name, style, fallback);
- }
-
- /* The primary name is the locale default - ie not US/English but
- * whatever is the default in this locale. This is the way it always
- * has been but may be surprising to some developers if "Arial Regular"
- * were hard-coded in their app and yet "Arial Regular" was not the
- * default name. Fortunately for them, as a consequence of the JDK
- * supporting returning names and family names for arbitrary locales,
- * we also need to support searching all localised names for a match.
- * But because this case of the name used to reference a font is not
- * the same as the default for this locale is rare, it makes sense to
- * search a much shorter list of default locale names and only go to
- * a longer list of names in the event that no match was found.
- * So add here code which searches localised names too.
- * As in 1.4.x this happens only after loading all fonts, which
- * is probably the right order.
- */
- if ((font = findFont2DAllLocales(name, style)) != null) {
- fontNameCache.put(mapName, font);
- return font;
- }
-
- /* Perhaps its a "compatibility" name - timesroman, helvetica,
- * or courier, which 1.0 apps used for logical fonts.
- * We look for these "late" after a loadFonts as we must not
- * hide real fonts of these names.
- * Map these appropriately:
- * On windows this means according to the rules specified by the
- * FontConfiguration : do it only for encoding==Cp1252
- *
- * REMIND: this is something we plan to remove.
- */
- if (isWindows) {
- String compatName =
- sgEnv.getFontConfiguration().getFallbackFamilyName(name, null);
- if (compatName != null) {
- font = findFont2D(compatName, style, fallback);
- fontNameCache.put(mapName, font);
- return font;
- }
- } else if (lowerCaseName.equals("timesroman")) {
- font = findFont2D("serif", style, fallback);
- fontNameCache.put(mapName, font);
- return font;
- } else if (lowerCaseName.equals("helvetica")) {
- font = findFont2D("sansserif", style, fallback);
- fontNameCache.put(mapName, font);
- return font;
- } else if (lowerCaseName.equals("courier")) {
- font = findFont2D("monospaced", style, fallback);
- fontNameCache.put(mapName, font);
- return font;
- }
-
- if (logging) {
- logger.info("No font found for:" + name);
- }
-
- switch (fallback) {
- case PHYSICAL_FALLBACK: return getDefaultPhysicalFont();
- case LOGICAL_FALLBACK: return getDefaultLogicalFont(style);
- default: return null;
- }
- }
-
- /* This method can be more efficient as it will only need to
- * do the lookup once, and subsequent calls on the java.awt.Font
- * instance can utilise the cached Font2D on that object.
- * Its unfortunate it needs to be a native method, but the font2D
- * variable has to be private.
- */
- public static native Font2D getFont2D(Font font);
-
- /* Stuff below was in NativeFontWrapper and needed a new home */
-
- /*
- * Workaround for apps which are dependent on a font metrics bug
- * in JDK 1.1. This is an unsupported win32 private setting.
- */
- public static boolean usePlatformFontMetrics() {
- return usePlatformFontMetrics;
- }
-
- static native boolean getPlatformFontVar();
-
- private static final short US_LCID = 0x0409; // US English - default
- private static Map lcidMap;
-
- // Return a Microsoft LCID from the given Locale.
- // Used when getting localized font data.
-
- public static short getLCIDFromLocale(Locale locale) {
- // optimize for common case
- if (locale.equals(Locale.US)) {
- return US_LCID;
- }
-
- if (lcidMap == null) {
- createLCIDMap();
- }
-
- String key = locale.toString();
- while (!"".equals(key)) {
- Short lcidObject = (Short) lcidMap.get(key);
- if (lcidObject != null) {
- return lcidObject.shortValue();
- }
- int pos = key.lastIndexOf('_');
- if (pos < 1) {
- return US_LCID;
- }
- key = key.substring(0, pos);
- }
-
- return US_LCID;
- }
-
-
- private static void addLCIDMapEntry(Map map,
- String key, short value) {
- map.put(key, Short.valueOf(value));
- }
-
- private static synchronized void createLCIDMap() {
- if (lcidMap != null) {
- return;
- }
-
- Map map = new HashMap(200);
-
- // the following statements are derived from the langIDMap
- // in src/windows/native/java/lang/java_props_md.c using the following
- // awk script:
- // $1~/\/\*/ { next}
- // $3~/\?\?/ { next }
- // $3!~/_/ { next }
- // $1~/0x0409/ { next }
- // $1~/0x0c0a/ { next }
- // $1~/0x042c/ { next }
- // $1~/0x0443/ { next }
- // $1~/0x0812/ { next }
- // $1~/0x04/ { print " addLCIDMapEntry(map, " substr($3, 0, 3) "\", (short) " substr($1, 0, 6) ");" ; next }
- // $3~/,/ { print " addLCIDMapEntry(map, " $3 " (short) " substr($1, 0, 6) ");" ; next }
- // { print " addLCIDMapEntry(map, " $3 ", (short) " substr($1, 0, 6) ");" ; next }
- // The lines of this script:
- // - eliminate comments
- // - eliminate questionable locales
- // - eliminate language-only locales
- // - eliminate the default LCID value
- // - eliminate a few other unneeded LCID values
- // - print language-only locale entries for x04* LCID values
- // (apparently Microsoft doesn't use language-only LCID values -
- // see http://www.microsoft.com/OpenType/otspec/name.htm
- // - print complete entries for all other LCID values
- // Run
- // awk -f awk-script langIDMap > statements
- addLCIDMapEntry(map, "ar", (short) 0x0401);
- addLCIDMapEntry(map, "bg", (short) 0x0402);
- addLCIDMapEntry(map, "ca", (short) 0x0403);
- addLCIDMapEntry(map, "zh", (short) 0x0404);
- addLCIDMapEntry(map, "cs", (short) 0x0405);
- addLCIDMapEntry(map, "da", (short) 0x0406);
- addLCIDMapEntry(map, "de", (short) 0x0407);
- addLCIDMapEntry(map, "el", (short) 0x0408);
- addLCIDMapEntry(map, "es", (short) 0x040a);
- addLCIDMapEntry(map, "fi", (short) 0x040b);
- addLCIDMapEntry(map, "fr", (short) 0x040c);
- addLCIDMapEntry(map, "iw", (short) 0x040d);
- addLCIDMapEntry(map, "hu", (short) 0x040e);
- addLCIDMapEntry(map, "is", (short) 0x040f);
- addLCIDMapEntry(map, "it", (short) 0x0410);
- addLCIDMapEntry(map, "ja", (short) 0x0411);
- addLCIDMapEntry(map, "ko", (short) 0x0412);
- addLCIDMapEntry(map, "nl", (short) 0x0413);
- addLCIDMapEntry(map, "no", (short) 0x0414);
- addLCIDMapEntry(map, "pl", (short) 0x0415);
- addLCIDMapEntry(map, "pt", (short) 0x0416);
- addLCIDMapEntry(map, "rm", (short) 0x0417);
- addLCIDMapEntry(map, "ro", (short) 0x0418);
- addLCIDMapEntry(map, "ru", (short) 0x0419);
- addLCIDMapEntry(map, "hr", (short) 0x041a);
- addLCIDMapEntry(map, "sk", (short) 0x041b);
- addLCIDMapEntry(map, "sq", (short) 0x041c);
- addLCIDMapEntry(map, "sv", (short) 0x041d);
- addLCIDMapEntry(map, "th", (short) 0x041e);
- addLCIDMapEntry(map, "tr", (short) 0x041f);
- addLCIDMapEntry(map, "ur", (short) 0x0420);
- addLCIDMapEntry(map, "in", (short) 0x0421);
- addLCIDMapEntry(map, "uk", (short) 0x0422);
- addLCIDMapEntry(map, "be", (short) 0x0423);
- addLCIDMapEntry(map, "sl", (short) 0x0424);
- addLCIDMapEntry(map, "et", (short) 0x0425);
- addLCIDMapEntry(map, "lv", (short) 0x0426);
- addLCIDMapEntry(map, "lt", (short) 0x0427);
- addLCIDMapEntry(map, "fa", (short) 0x0429);
- addLCIDMapEntry(map, "vi", (short) 0x042a);
- addLCIDMapEntry(map, "hy", (short) 0x042b);
- addLCIDMapEntry(map, "eu", (short) 0x042d);
- addLCIDMapEntry(map, "mk", (short) 0x042f);
- addLCIDMapEntry(map, "tn", (short) 0x0432);
- addLCIDMapEntry(map, "xh", (short) 0x0434);
- addLCIDMapEntry(map, "zu", (short) 0x0435);
- addLCIDMapEntry(map, "af", (short) 0x0436);
- addLCIDMapEntry(map, "ka", (short) 0x0437);
- addLCIDMapEntry(map, "fo", (short) 0x0438);
- addLCIDMapEntry(map, "hi", (short) 0x0439);
- addLCIDMapEntry(map, "mt", (short) 0x043a);
- addLCIDMapEntry(map, "se", (short) 0x043b);
- addLCIDMapEntry(map, "gd", (short) 0x043c);
- addLCIDMapEntry(map, "ms", (short) 0x043e);
- addLCIDMapEntry(map, "kk", (short) 0x043f);
- addLCIDMapEntry(map, "ky", (short) 0x0440);
- addLCIDMapEntry(map, "sw", (short) 0x0441);
- addLCIDMapEntry(map, "tt", (short) 0x0444);
- addLCIDMapEntry(map, "bn", (short) 0x0445);
- addLCIDMapEntry(map, "pa", (short) 0x0446);
- addLCIDMapEntry(map, "gu", (short) 0x0447);
- addLCIDMapEntry(map, "ta", (short) 0x0449);
- addLCIDMapEntry(map, "te", (short) 0x044a);
- addLCIDMapEntry(map, "kn", (short) 0x044b);
- addLCIDMapEntry(map, "ml", (short) 0x044c);
- addLCIDMapEntry(map, "mr", (short) 0x044e);
- addLCIDMapEntry(map, "sa", (short) 0x044f);
- addLCIDMapEntry(map, "mn", (short) 0x0450);
- addLCIDMapEntry(map, "cy", (short) 0x0452);
- addLCIDMapEntry(map, "gl", (short) 0x0456);
- addLCIDMapEntry(map, "dv", (short) 0x0465);
- addLCIDMapEntry(map, "qu", (short) 0x046b);
- addLCIDMapEntry(map, "mi", (short) 0x0481);
- addLCIDMapEntry(map, "ar_IQ", (short) 0x0801);
- addLCIDMapEntry(map, "zh_CN", (short) 0x0804);
- addLCIDMapEntry(map, "de_CH", (short) 0x0807);
- addLCIDMapEntry(map, "en_GB", (short) 0x0809);
- addLCIDMapEntry(map, "es_MX", (short) 0x080a);
- addLCIDMapEntry(map, "fr_BE", (short) 0x080c);
- addLCIDMapEntry(map, "it_CH", (short) 0x0810);
- addLCIDMapEntry(map, "nl_BE", (short) 0x0813);
- addLCIDMapEntry(map, "no_NO_NY", (short) 0x0814);
- addLCIDMapEntry(map, "pt_PT", (short) 0x0816);
- addLCIDMapEntry(map, "ro_MD", (short) 0x0818);
- addLCIDMapEntry(map, "ru_MD", (short) 0x0819);
- addLCIDMapEntry(map, "sr_CS", (short) 0x081a);
- addLCIDMapEntry(map, "sv_FI", (short) 0x081d);
- addLCIDMapEntry(map, "az_AZ", (short) 0x082c);
- addLCIDMapEntry(map, "se_SE", (short) 0x083b);
- addLCIDMapEntry(map, "ga_IE", (short) 0x083c);
- addLCIDMapEntry(map, "ms_BN", (short) 0x083e);
- addLCIDMapEntry(map, "uz_UZ", (short) 0x0843);
- addLCIDMapEntry(map, "qu_EC", (short) 0x086b);
- addLCIDMapEntry(map, "ar_EG", (short) 0x0c01);
- addLCIDMapEntry(map, "zh_HK", (short) 0x0c04);
- addLCIDMapEntry(map, "de_AT", (short) 0x0c07);
- addLCIDMapEntry(map, "en_AU", (short) 0x0c09);
- addLCIDMapEntry(map, "fr_CA", (short) 0x0c0c);
- addLCIDMapEntry(map, "sr_CS", (short) 0x0c1a);
- addLCIDMapEntry(map, "se_FI", (short) 0x0c3b);
- addLCIDMapEntry(map, "qu_PE", (short) 0x0c6b);
- addLCIDMapEntry(map, "ar_LY", (short) 0x1001);
- addLCIDMapEntry(map, "zh_SG", (short) 0x1004);
- addLCIDMapEntry(map, "de_LU", (short) 0x1007);
- addLCIDMapEntry(map, "en_CA", (short) 0x1009);
- addLCIDMapEntry(map, "es_GT", (short) 0x100a);
- addLCIDMapEntry(map, "fr_CH", (short) 0x100c);
- addLCIDMapEntry(map, "hr_BA", (short) 0x101a);
- addLCIDMapEntry(map, "ar_DZ", (short) 0x1401);
- addLCIDMapEntry(map, "zh_MO", (short) 0x1404);
- addLCIDMapEntry(map, "de_LI", (short) 0x1407);
- addLCIDMapEntry(map, "en_NZ", (short) 0x1409);
- addLCIDMapEntry(map, "es_CR", (short) 0x140a);
- addLCIDMapEntry(map, "fr_LU", (short) 0x140c);
- addLCIDMapEntry(map, "bs_BA", (short) 0x141a);
- addLCIDMapEntry(map, "ar_MA", (short) 0x1801);
- addLCIDMapEntry(map, "en_IE", (short) 0x1809);
- addLCIDMapEntry(map, "es_PA", (short) 0x180a);
- addLCIDMapEntry(map, "fr_MC", (short) 0x180c);
- addLCIDMapEntry(map, "sr_BA", (short) 0x181a);
- addLCIDMapEntry(map, "ar_TN", (short) 0x1c01);
- addLCIDMapEntry(map, "en_ZA", (short) 0x1c09);
- addLCIDMapEntry(map, "es_DO", (short) 0x1c0a);
- addLCIDMapEntry(map, "sr_BA", (short) 0x1c1a);
- addLCIDMapEntry(map, "ar_OM", (short) 0x2001);
- addLCIDMapEntry(map, "en_JM", (short) 0x2009);
- addLCIDMapEntry(map, "es_VE", (short) 0x200a);
- addLCIDMapEntry(map, "ar_YE", (short) 0x2401);
- addLCIDMapEntry(map, "es_CO", (short) 0x240a);
- addLCIDMapEntry(map, "ar_SY", (short) 0x2801);
- addLCIDMapEntry(map, "en_BZ", (short) 0x2809);
- addLCIDMapEntry(map, "es_PE", (short) 0x280a);
- addLCIDMapEntry(map, "ar_JO", (short) 0x2c01);
- addLCIDMapEntry(map, "en_TT", (short) 0x2c09);
- addLCIDMapEntry(map, "es_AR", (short) 0x2c0a);
- addLCIDMapEntry(map, "ar_LB", (short) 0x3001);
- addLCIDMapEntry(map, "en_ZW", (short) 0x3009);
- addLCIDMapEntry(map, "es_EC", (short) 0x300a);
- addLCIDMapEntry(map, "ar_KW", (short) 0x3401);
- addLCIDMapEntry(map, "en_PH", (short) 0x3409);
- addLCIDMapEntry(map, "es_CL", (short) 0x340a);
- addLCIDMapEntry(map, "ar_AE", (short) 0x3801);
- addLCIDMapEntry(map, "es_UY", (short) 0x380a);
- addLCIDMapEntry(map, "ar_BH", (short) 0x3c01);
- addLCIDMapEntry(map, "es_PY", (short) 0x3c0a);
- addLCIDMapEntry(map, "ar_QA", (short) 0x4001);
- addLCIDMapEntry(map, "es_BO", (short) 0x400a);
- addLCIDMapEntry(map, "es_SV", (short) 0x440a);
- addLCIDMapEntry(map, "es_HN", (short) 0x480a);
- addLCIDMapEntry(map, "es_NI", (short) 0x4c0a);
- addLCIDMapEntry(map, "es_PR", (short) 0x500a);
-
- lcidMap = map;
- }
-
- public static int getNumFonts() {
- return physicalFonts.size()+maxCompFont;
- }
-
- private static boolean fontSupportsEncoding(Font font, String encoding) {
- return getFont2D(font).supportsEncoding(encoding);
- }
-
- public synchronized static native String getFontPath(boolean noType1Fonts);
- public synchronized static native void setNativeFontPath(String fontPath);
-
-
- private static Thread fileCloser = null;
- static Vector tmpFontFiles = null;
-
- public static Font2D createFont2D(File fontFile, int fontFormat,
- boolean isCopy,
- CreatedFontTracker tracker)
- throws FontFormatException {
-
- String fontFilePath = fontFile.getPath();
- FileFont font2D = null;
- final File fFile = fontFile;
- final CreatedFontTracker _tracker = tracker;
- try {
- switch (fontFormat) {
- case Font.TRUETYPE_FONT:
- font2D = new TrueTypeFont(fontFilePath, null, 0, true);
- break;
- case Font.TYPE1_FONT:
- font2D = new Type1Font(fontFilePath, null, isCopy);
- break;
- default:
- throw new FontFormatException("Unrecognised Font Format");
- }
- } catch (FontFormatException e) {
- if (isCopy) {
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- if (_tracker != null) {
- _tracker.subBytes((int)fFile.length());
- }
- fFile.delete();
- return null;
- }
- });
- }
- throw(e);
- }
- if (isCopy) {
- font2D.setFileToRemove(fontFile, tracker);
- synchronized (FontManager.class) {
-
- if (tmpFontFiles == null) {
- tmpFontFiles = new Vector();
- }
- tmpFontFiles.add(fontFile);
-
- if (fileCloser == null) {
- final Runnable fileCloserRunnable = new Runnable() {
- public void run() {
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
-
- for (int i=0;i Font2D.FONT_CONFIG_RANK) {
- compFonts[i].replaceComponentFont(oldFont, newFont);
- }
- }
- }
-
- private static synchronized void loadLocaleNames() {
- if (localeFullNamesToFont != null) {
- return;
- }
- localeFullNamesToFont = new HashMap();
- Font2D[] fonts = getRegisteredFonts();
- for (int i=0; i
- altNameCache = new ConcurrentHashMap ();
- /* If there is an existing hashtable, we can drop it. */
- appContext.put(CompositeFont.class, altNameCache);
- usingPerAppContextComposites = true;
- sgEnv.createCompositeFonts(altNameCache, true, acPropPref);
- }
- }
-
- public static synchronized void preferProportionalFonts() {
-
- /* If no proportional fonts are configured, there's no need
- * to take any action.
- */
- if (!FontConfiguration.hasMonoToPropMap()) {
- return;
- }
-
- initSGEnv();
-
- if (!maybeMultiAppContext()) {
- if (gPropPref == true) {
- return;
- }
- gPropPref = true;
- sgEnv.createCompositeFonts(fontNameCache, gLocalePref, gPropPref);
- usingAlternateComposites = true;
- } else {
- AppContext appContext = AppContext.getAppContext();
- if (appContext.get(proportionalFontKey) == proportionalFontKey) {
- return;
- }
- appContext.put(proportionalFontKey, proportionalFontKey);
- boolean acLocalePref =
- appContext.get(localeFontKey) == localeFontKey;
- ConcurrentHashMap
- altNameCache = new ConcurrentHashMap ();
- /* If there is an existing hashtable, we can drop it. */
- appContext.put(CompositeFont.class, altNameCache);
- usingPerAppContextComposites = true;
- sgEnv.createCompositeFonts(altNameCache, acLocalePref, true);
- }
- }
-
- private static HashSet installedNames = null;
- private static HashSet getInstalledNames() {
- if (installedNames == null) {
- Locale l = sgEnv.getSystemStartupLocale();
- String[] installedFamilies = sgEnv.getInstalledFontFamilyNames(l);
- Font[] installedFonts = sgEnv.getAllInstalledFonts();
- HashSet names = new HashSet();
- for (int i=0; i createdByFamilyName;
- private static Hashtable createdByFullName;
- private static boolean fontsAreRegistered = false;
- private static boolean fontsAreRegisteredPerAppContext = false;
-
- public static boolean registerFont(Font font) {
- /* This method should not be called with "null".
- * It is the caller's responsibility to ensure that.
- */
- if (font == null) {
- return false;
- }
-
- /* Initialise these objects only once we start to use this API */
- synchronized (regFamilyKey) {
- if (createdByFamilyName == null) {
- createdByFamilyName = new Hashtable();
- createdByFullName = new Hashtable();
- }
- }
-
- if (!isCreatedFont(font)) {
- return false;
- }
- if (sgEnv == null) {
- initSGEnv();
- }
- /* We want to ensure that this font cannot override existing
- * installed fonts. Check these conditions :
- * - family name is not that of an installed font
- * - full name is not that of an installed font
- * - family name is not the same as the full name of an installed font
- * - full name is not the same as the family name of an installed font
- * The last two of these may initially look odd but the reason is
- * that (unfortunately) Font constructors do not distinuguish these.
- * An extreme example of such a problem would be a font which has
- * family name "Dialog.Plain" and full name of "Dialog".
- * The one arguably overly stringent restriction here is that if an
- * application wants to supply a new member of an existing family
- * It will get rejected. But since the JRE can perform synthetic
- * styling in many cases its not necessary.
- * We don't apply the same logic to registered fonts. If apps want
- * to do this lets assume they have a reason. It won't cause problems
- * except for themselves.
- */
- HashSet names = getInstalledNames();
- Locale l = sgEnv.getSystemStartupLocale();
- String familyName = font.getFamily(l).toLowerCase();
- String fullName = font.getFontName(l).toLowerCase();
- if (names.contains(familyName) || names.contains(fullName)) {
- return false;
- }
-
- /* Checks passed, now register the font */
- Hashtable familyTable;
- Hashtable fullNameTable;
- if (!maybeMultiAppContext()) {
- familyTable = createdByFamilyName;
- fullNameTable = createdByFullName;
- fontsAreRegistered = true;
- } else {
- AppContext appContext = AppContext.getAppContext();
- familyTable =
- (Hashtable)appContext.get(regFamilyKey);
- fullNameTable =
- (Hashtable)appContext.get(regFullNameKey);
- if (familyTable == null) {
- familyTable = new Hashtable();
- fullNameTable = new Hashtable();
- appContext.put(regFamilyKey, familyTable);
- appContext.put(regFullNameKey, fullNameTable);
- }
- fontsAreRegisteredPerAppContext = true;
- }
- /* Create the FontFamily and add font to the tables */
- Font2D font2D = getFont2D(font);
- int style = font2D.getStyle();
- FontFamily family = familyTable.get(familyName);
- if (family == null) {
- family = new FontFamily(font.getFamily(l));
- familyTable.put(familyName, family);
- }
- /* Remove name cache entries if not using app contexts.
- * To accommodate a case where code may have registered first a plain
- * family member and then used it and is now registering a bold family
- * member, we need to remove all members of the family, so that the
- * new style can get picked up rather than continuing to synthesise.
- */
- if (fontsAreRegistered) {
- removeFromCache(family.getFont(Font.PLAIN));
- removeFromCache(family.getFont(Font.BOLD));
- removeFromCache(family.getFont(Font.ITALIC));
- removeFromCache(family.getFont(Font.BOLD|Font.ITALIC));
- removeFromCache(fullNameTable.get(fullName));
- }
- family.setFont(font2D, style);
- fullNameTable.put(fullName, font2D);
- return true;
- }
-
- /* Remove from the name cache all references to the Font2D */
- private static void removeFromCache(Font2D font) {
- if (font == null) {
- return;
- }
- String[] keys = (String[])(fontNameCache.keySet().toArray(STR_ARRAY));
- for (int k=0; k getCreatedFontFamilyNames() {
-
- Hashtable familyTable;
- if (fontsAreRegistered) {
- familyTable = createdByFamilyName;
- } else if (fontsAreRegisteredPerAppContext) {
- AppContext appContext = AppContext.getAppContext();
- familyTable =
- (Hashtable)appContext.get(regFamilyKey);
- } else {
- return null;
- }
-
- Locale l = sgEnv.getSystemStartupLocale();
- synchronized (familyTable) {
- TreeMap map = new TreeMap();
- for (FontFamily f : familyTable.values()) {
- Font2D font2D = f.getFont(Font.PLAIN);
- if (font2D == null) {
- font2D = f.getClosestStyle(Font.PLAIN);
- }
- String name = font2D.getFamilyName(l);
- map.put(name.toLowerCase(l), name);
- }
- return map;
- }
- }
-
- public static Font[] getCreatedFonts() {
-
- Hashtable nameTable;
- if (fontsAreRegistered) {
- nameTable = createdByFullName;
- } else if (fontsAreRegisteredPerAppContext) {
- AppContext appContext = AppContext.getAppContext();
- nameTable =
- (Hashtable)appContext.get(regFullNameKey);
- } else {
- return null;
- }
-
- Locale l = sgEnv.getSystemStartupLocale();
- synchronized (nameTable) {
- Font[] fonts = new Font[nameTable.size()];
- int i=0;
- for (Font2D font2D : nameTable.values()) {
- fonts[i++] = new Font(font2D.getFontName(l), Font.PLAIN, 1);
- }
- return fonts;
- }
- }
-
- /* Begin support for GTK Look and Feel - query libfontconfig and
- * return a composite Font to Swing that uses the desktop font(s).
- */
-
- /* A small "map" from GTK/fontconfig names to the equivalent JDK
- * logical font name.
- */
- private static final String[][] nameMap = {
- {"sans", "sansserif"},
- {"sans-serif", "sansserif"},
- {"serif", "serif"},
- {"monospace", "monospaced"}
- };
-
- public static String mapFcName(String name) {
- for (int i = 0; i < nameMap.length; i++) {
- if (name.equals(nameMap[i][0])) {
- return nameMap[i][1];
- }
- }
- return null;
- }
-
- /* fontconfig recognises slants roman, italic, as well as oblique,
- * and a slew of weights, where the ones that matter here are
- * regular and bold.
- * To fully qualify what we want, we can for example ask for (eg)
- * Font.PLAIN : "serif:regular:roman"
- * Font.BOLD : "serif:bold:roman"
- * Font.ITALIC : "serif:regular:italic"
- * Font.BOLD|Font.ITALIC : "serif:bold:italic"
- */
- private static String[] fontConfigNames = {
- "sans:regular:roman",
- "sans:bold:roman",
- "sans:regular:italic",
- "sans:bold:italic",
-
- "serif:regular:roman",
- "serif:bold:roman",
- "serif:regular:italic",
- "serif:bold:italic",
-
- "monospace:regular:roman",
- "monospace:bold:roman",
- "monospace:regular:italic",
- "monospace:bold:italic",
- };
-
- /* These next three classes are just data structures.
- */
- static class FontConfigFont {
- String familyName; // eg Bitstream Vera Sans
- String styleStr; // eg Bold
- String fullName; // eg Bitstream Vera Sans Bold
- String fontFile; // eg /usr/X11/lib/fonts/foo.ttf
- }
-
- static class FcCompFont {
- String fcName; // eg sans
- String fcFamily; // eg sans
- String jdkName; // eg sansserif
- int style; // eg 0=PLAIN
- FontConfigFont firstFont;
- FontConfigFont[] allFonts;
- //boolean preferBitmaps; // if embedded bitmaps preferred over AA
- CompositeFont compFont; // null if not yet created/known.
- }
-
- static class FontConfigInfo {
- int fcVersion;
- String[] cacheDirs = new String[4];
- }
-
- private static String getFCLocaleStr() {
- Locale l = SunToolkit.getStartupLocale();
- String localeStr = l.getLanguage();
- String country = l.getCountry();
- if (!country.equals("")) {
- localeStr = localeStr + "-" + country;
- }
- return localeStr;
- }
-
- /* This does cause the native libfontconfig to be loaded and unloaded,
- * but it does not incur the overhead of initialisation of its
- * data structures, so shouldn't have a measurable impact.
- */
- public static native int getFontConfigVersion();
-
- private static native int
- getFontConfigAASettings(String locale, String fcFamily);
-
- /* This is public solely so that for debugging purposes it can be called
- * with other names, which might (eg) include a size, eg "sans-24"
- * The return value is a text aa rendering hint value.
- * Normally we should call the no-args version.
- */
- public static Object getFontConfigAAHint(String fcFamily) {
- if (isWindows) {
- return null;
- } else {
- int hint = getFontConfigAASettings(getFCLocaleStr(), fcFamily);
- if (hint < 0) {
- return null;
- } else {
- return SunHints.Value.get(SunHints.INTKEY_TEXT_ANTIALIASING,
- hint);
- }
- }
- }
-
- /* Called from code that needs to know what are the AA settings
- * that apps using FC would pick up for the default desktop font.
- * Note apps can change the default desktop font. etc, so this
- * isn't certain to be right but its going to correct for most cases.
- * Native return values map to the text aa values in sun.awt.SunHints.
- * which is used to look up the renderinghint value object.
- */
- public static Object getFontConfigAAHint() {
- return getFontConfigAAHint("sans");
- }
-
- /* This is populated by native */
- private static final FontConfigInfo fcInfo = new FontConfigInfo();
-
- /* This array has the array elements created in Java code and is
- * passed down to native to be filled in.
- */
- private static FcCompFont[] fontConfigFonts;
-
- /* Return an array of FcCompFont structs describing the primary
- * font located for each of fontconfig/GTK/Pango's logical font names.
- */
- private static native void getFontConfig(String locale,
- FontConfigInfo fcInfo,
- FcCompFont[] fonts,
- boolean includeFallbacks);
-
- static void populateFontConfig(FcCompFont[] fcInfo) {
- fontConfigFonts = fcInfo;
- }
-
- static FcCompFont[] loadFontConfig() {
- initFontConfigFonts(true);
- return fontConfigFonts;
- }
-
- static FontConfigInfo getFontConfigInfo() {
- initFontConfigFonts(true);
- return fcInfo;
- }
-
- /* This can be made public if it's needed to force a re-read
- * rather than using the cached values. The re-read would be needed
- * only if some event signalled that the fontconfig has changed.
- * In that event this method would need to return directly the array
- * to be used by the caller in case it subsequently changed.
- */
- private static synchronized void
- initFontConfigFonts(boolean includeFallbacks) {
-
- if (fontConfigFonts != null) {
- if (!includeFallbacks || (fontConfigFonts[0].allFonts != null)) {
- return;
- }
- }
-
- if (isWindows || fontConfigFailed) {
- return;
- }
-
- long t0 = 0;
- if (logging) {
- t0 = System.nanoTime();
- }
-
- FcCompFont[] fontArr = new FcCompFont[fontConfigNames.length];
- for (int i = 0; i< fontArr.length; i++) {
- fontArr[i] = new FcCompFont();
- fontArr[i].fcName = fontConfigNames[i];
- int colonPos = fontArr[i].fcName.indexOf(':');
- fontArr[i].fcFamily = fontArr[i].fcName.substring(0, colonPos);
- fontArr[i].jdkName = mapFcName(fontArr[i].fcFamily);
- fontArr[i].style = i % 4; // depends on array order.
- }
- getFontConfig(getFCLocaleStr(), fcInfo, fontArr, includeFallbacks);
- /* If don't find anything (eg no libfontconfig), then just return */
- for (int i = 0; i< fontArr.length; i++) {
- FcCompFont fci = fontArr[i];
- if (fci.firstFont == null) {
- if (logging) {
- logger.info("Fontconfig returned no fonts.");
- }
- fontConfigFailed = true;
- return;
- }
- }
- fontConfigFonts = fontArr;
-
- if (logging) {
- long t1 = System.nanoTime();
- logger.info("Time spent accessing fontconfig="+
- (t1-t0)/1000000+"ms.");
-
- for (int i = 0; i< fontConfigFonts.length; i++) {
- FcCompFont fci = fontConfigFonts[i];
- logger.info("FC font " + fci.fcName+" maps to family " +
- fci.firstFont.familyName +
- " in file " + fci.firstFont.fontFile);
- if (fci.allFonts != null) {
- for (int f=0;f pathList = new ArrayList();
- try {
- while (parser.hasMoreTokens()) {
- pathList.add(parser.nextToken());
- }
- } catch (NoSuchElementException e) {
- }
- return pathList.toArray(new String[0]);
- }
-
- /** returns an array of two strings. The first element is the
- * name of the font. The second element is the file name.
- */
- private static String[] defaultPlatformFont = null;
- public static String[] getDefaultPlatformFont() {
-
- if (defaultPlatformFont != null) {
- return defaultPlatformFont;
- }
-
- String[] info = new String[2];
- if (isWindows) {
- info[0] = "Arial";
- info[1] = "c:\\windows\\fonts";
- final String[] dirs = getPlatformFontDirs();
- if (dirs.length > 1) {
- String dir = (String)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- for (int i=0; i 0 &&
- fontConfigFonts[0].firstFont.fontFile != null) {
- info[0] = fontConfigFonts[0].firstFont.familyName;
- info[1] = fontConfigFonts[0].firstFont.fontFile;
- } else {
- info[0] = "Dialog";
- info[1] = "/dialog.ttf";
- }
- }
- }
- defaultPlatformFont = info;
- return defaultPlatformFont;
- }
-
- private FcCompFont getFcCompFont() {
- initFontConfigFonts(false);
- for (int i=0; i
+ * The actual change in font rendering behavior resulting from a call
+ * to this method is implementation dependent; it may have no effect at
+ * all, or the requested behavior may already match the default behavior.
+ * The behavior may differ between font rendering in lightweight
+ * and peered components. Since calling this method requests a
+ * different font, clients should expect different metrics, and may need
+ * to recalculate window sizes and layout. Therefore this method should
+ * be called before user interface initialisation.
+ *
+ * @see #preferProportionalFonts()
+ * @since 1.5
*/
- public static final int MIN_LAYOUT_CHARCODE = 0x0300;
+ public void preferLocaleFonts();
/**
- * Referenced by code in the JDK which wants to test for the
- * maximum char code for which layout may be required.
- * Note this does not account for supplementary characters
- * where the caller interprets 'layout' to mean any case where
- * one 'char' (ie the java type char) does not map to one glyph
+ * preferLocaleFonts() and preferProportionalFonts() are called to inform
+ * that the application could be using an alternate set of composite
+ * fonts, and so the implementation should try to create a CompositeFonts
+ * with this directive in mind.
+ *
+ * @see #preferLocaleFonts()
*/
- public static final int MAX_LAYOUT_CHARCODE = 0x206F;
+ public void preferProportionalFonts();
- /* If the character code falls into any of a number of unicode ranges
- * where we know that simple left->right layout mapping chars to glyphs
- * 1:1 and accumulating advances is going to produce incorrect results,
- * we want to know this so the caller can use a more intelligent layout
- * approach. A caller who cares about optimum performance may want to
- * check the first case and skip the method call if its in that range.
- * Although there's a lot of tests in here, knowing you can skip
- * CTL saves a great deal more. The rest of the checks are ordered
- * so that rather than checking explicitly if (>= start & <= end)
- * which would mean all ranges would need to be checked so be sure
- * CTL is not needed, the method returns as soon as it recognises
- * the code point is outside of a CTL ranges.
- * NOTE: Since this method accepts an 'int' it is asssumed to properly
- * represent a CHARACTER. ie it assumes the caller has already
- * converted surrogate pairs into supplementary characters, and so
- * can handle this case and doesn't need to be told such a case is
- * 'complex'.
- */
- static boolean isComplexCharCode(int code) {
-
- if (code < MIN_LAYOUT_CHARCODE || code > MAX_LAYOUT_CHARCODE) {
- return false;
- }
- else if (code <= 0x036f) {
- // Trigger layout for combining diacriticals 0x0300->0x036f
- return true;
- }
- else if (code < 0x0590) {
- // No automatic layout for Greek, Cyrillic, Armenian.
- return false;
- }
- else if (code <= 0x06ff) {
- // Hebrew 0590 - 05ff
- // Arabic 0600 - 06ff
- return true;
- }
- else if (code < 0x0900) {
- return false; // Syriac and Thaana
- }
- else if (code <= 0x0e7f) {
- // if Indic, assume shaping for conjuncts, reordering:
- // 0900 - 097F Devanagari
- // 0980 - 09FF Bengali
- // 0A00 - 0A7F Gurmukhi
- // 0A80 - 0AFF Gujarati
- // 0B00 - 0B7F Oriya
- // 0B80 - 0BFF Tamil
- // 0C00 - 0C7F Telugu
- // 0C80 - 0CFF Kannada
- // 0D00 - 0D7F Malayalam
- // 0D80 - 0DFF Sinhala
- // 0E00 - 0E7F if Thai, assume shaping for vowel, tone marks
- return true;
- }
- else if (code < 0x1780) {
- return false;
- }
- else if (code <= 0x17ff) { // 1780 - 17FF Khmer
- return true;
- }
- else if (code < 0x200c) {
- return false;
- }
- else if (code <= 0x200d) { // zwj or zwnj
- return true;
- }
- else if (code >= 0x202a && code <= 0x202e) { // directional control
- return true;
- }
- else if (code >= 0x206a && code <= 0x206f) { // directional control
- return true;
- }
- return false;
- }
-
- /* This is almost the same as the method above, except it takes a
- * char which means it may include undecoded surrogate pairs.
- * The distinction is made so that code which needs to identify all
- * cases in which we do not have a simple mapping from
- * char->unicode character->glyph can be be identified.
- * For example measurement cannot simply sum advances of 'chars',
- * the caret in editable text cannot advance one 'char' at a time, etc.
- * These callers really are asking for more than whether 'layout'
- * needs to be run, they need to know if they can assume 1->1
- * char->glyph mapping.
- */
- static boolean isNonSimpleChar(char ch) {
- return
- isComplexCharCode(ch) ||
- (ch >= CharToGlyphMapper.HI_SURROGATE_START &&
- ch <= CharToGlyphMapper.LO_SURROGATE_END);
- }
-
- /**
- * If there is anything in the text which triggers a case
- * where char->glyph does not map 1:1 in straightforward
- * left->right ordering, then this method returns true.
- * Scripts which might require it but are not treated as such
- * due to JDK implementations will not return true.
- * ie a 'true' return is an indication of the treatment by
- * the implementation.
- * Whether supplementary characters should be considered is dependent
- * on the needs of the caller. Since this method accepts the 'char' type
- * then such chars are always represented by a pair. From a rendering
- * perspective these will all (in the cases I know of) still be one
- * unicode character -> one glyph. But if a caller is using this to
- * discover any case where it cannot make naive assumptions about
- * the number of chars, and how to index through them, then it may
- * need the option to have a 'true' return in such a case.
- */
- public static boolean isComplexText(char [] chs, int start, int limit) {
-
- for (int i = start; i < limit; i++) {
- if (chs[i] < MIN_LAYOUT_CHARCODE) {
- continue;
- }
- else if (isNonSimpleChar(chs[i])) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Used by windows printing to assess if a font is likely to
- * be layout compatible with JDK
- * TrueType fonts should be, but if they have no GPOS table,
- * but do have a GSUB table, then they are probably older
- * fonts GDI handles differently.
- */
- public static boolean textLayoutIsCompatible(Font font) {
-
- Font2D font2D = FontManager.getFont2D(font);
- if (font2D instanceof TrueTypeFont) {
- TrueTypeFont ttf = (TrueTypeFont)font2D;
- return
- ttf.getDirectoryEntry(TrueTypeFont.GSUBTag) == null ||
- ttf.getDirectoryEntry(TrueTypeFont.GPOSTag) != null;
- } else {
- return false;
- }
- }
-
- private static FontScaler nullScaler = null;
- private static Constructor scalerConstructor = null;
-
- //Find preferred font scaler
- //
- //NB: we can allow property based preferences
- // (theoretically logic can be font type specific)
- static {
- Class scalerClass = null;
- Class arglst[] = new Class[] {Font2D.class, int.class,
- boolean.class, int.class};
-
- try {
- if (SunGraphicsEnvironment.isOpenJDK()) {
- scalerClass = Class.forName("sun.font.FreetypeFontScaler");
- } else {
- scalerClass = Class.forName("sun.font.T2KFontScaler");
- }
- } catch (ClassNotFoundException e) {
- scalerClass = NullFontScaler.class;
- }
-
- //NB: rewrite using factory? constructor is ugly way
- try {
- scalerConstructor = scalerClass.getConstructor(arglst);
- } catch (NoSuchMethodException e) {
- //should not happen
- }
- }
-
- /* At the moment it is harmless to create 2 null scalers
- so, technically, syncronized keyword is not needed.
-
- But it is safer to keep it to avoid subtle problems if we will be
- adding checks like whether scaler is null scaler. */
- public synchronized static FontScaler getNullScaler() {
- if (nullScaler == null) {
- nullScaler = new NullFontScaler();
- }
- return nullScaler;
- }
-
- /* This is the only place to instantiate new FontScaler.
- * Therefore this is very convinient place to register
- * scaler with Disposer as well as trigger deregistring bad font
- * in case when scaler reports this.
- */
-
- public static FontScaler getScaler(Font2D font,
- int indexInCollection,
- boolean supportsCJK,
- int filesize) {
- FontScaler scaler = null;
-
- try {
- Object args[] = new Object[] {font, indexInCollection,
- supportsCJK, filesize};
- scaler = scalerConstructor.newInstance(args);
- Disposer.addObjectRecord(font, scaler);
- } catch (Throwable e) {
- scaler = nullScaler;
-
- //if we can not instantiate scaler assume bad font
- //NB: technically it could be also because of internal scaler
- // error but here we are assuming scaler is ok.
- deRegisterBadFont(font);
- }
- return scaler;
- }
}
diff --git a/jdk/src/share/classes/sun/font/FontManagerFactory.java b/jdk/src/share/classes/sun/font/FontManagerFactory.java
new file mode 100644
index 00000000000..44bfe68c541
--- /dev/null
+++ b/jdk/src/share/classes/sun/font/FontManagerFactory.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2008 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 sun.font;
+
+import java.awt.AWTError;
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.awt.Toolkit;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import sun.security.action.GetPropertyAction;
+
+
+/**
+ * Factory class used to retrieve a valid FontManager instance for the current
+ * platform.
+ *
+ * A default implementation is given for Linux, Solaris and Windows.
+ * You can alter the behaviour of the {@link #getInstance()} method by setting
+ * the {@code sun.font.fontmanager} property. For example:
+ * {@code sun.font.fontmanager=sun.awt.X11FontManager}
+ */
+public final class FontManagerFactory {
+
+ /** Our singleton instance. */
+ private static FontManager instance = null;
+
+ private static final String DEFAULT_CLASS;
+ static {
+ if (FontUtilities.isWindows)
+ DEFAULT_CLASS = "sun.awt.Win32FontManager";
+ else
+ DEFAULT_CLASS = "sun.awt.X11FontManager";
+ }
+
+ /**
+ * Get a valid FontManager implementation for the current platform.
+ *
+ * @return a valid FontManager instance for the current platform
+ */
+ public static synchronized FontManager getInstance() {
+
+ if (instance != null) {
+ return instance;
+ }
+
+ String fmClassName = AccessController.doPrivileged(
+ new GetPropertyAction("sun.font.fontmanager",
+ DEFAULT_CLASS));
+
+ try {
+ @SuppressWarnings("unchecked")
+ ClassLoader cl = (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ClassLoader.getSystemClassLoader();
+ }
+ });
+
+ @SuppressWarnings("unchecked")
+ Class fmClass = Class.forName(fmClassName, true, cl);
+ instance = (FontManager) fmClass.newInstance();
+
+ } catch (ClassNotFoundException ex) {
+ InternalError err = new InternalError();
+ err.initCause(ex);
+ throw err;
+
+ } catch (InstantiationException ex) {
+ InternalError err = new InternalError();
+ err.initCause(ex);
+ throw err;
+
+ } catch (IllegalAccessException ex) {
+ InternalError err = new InternalError();
+ err.initCause(ex);
+ throw err;
+ }
+
+ return instance;
+ }
+}
diff --git a/jdk/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/OuterGlowEffect.java b/jdk/src/share/classes/sun/font/FontManagerForSGE.java
similarity index 53%
rename from jdk/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/OuterGlowEffect.java
rename to jdk/src/share/classes/sun/font/FontManagerForSGE.java
index c431ed747ea..05d1971e2ed 100644
--- a/jdk/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/OuterGlowEffect.java
+++ b/jdk/src/share/classes/sun/font/FontManagerForSGE.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008 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
@@ -22,34 +22,36 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
-package org.jdesktop.swingx.designer.effects;
-import org.jdesktop.swingx.designer.paint.Matte;
+package sun.font;
-import javax.swing.UIDefaults;
-import java.awt.Color;
+import java.awt.Font;
+import java.util.Locale;
+import java.util.TreeMap;
/**
- * OuterGlowEffect
- *
- * @author Created by Jasper Potts (Jun 21, 2007)
+ * This is an extension of the {@link FontManager} interface which has to
+ * be implemented on systems that want to use SunGraphicsEnvironment. It
+ * adds a couple of methods that are only required by SGE. Graphics
+ * implementations that use their own GraphicsEnvironment are not required
+ * to implement this and can use plain FontManager instead.
*/
-public class OuterGlowEffect extends DropShadowEffect {
-
- protected OuterGlowEffect() {
- distance = 0;
- }
-
- public OuterGlowEffect(UIDefaults uiDefaults) {
- color = new Matte(new Color(255, 255, 211), uiDefaults);
- }
+public interface FontManagerForSGE extends FontManager {
/**
- * Get the display name for this effect
- *
- * @return The user displayable name
+ * Return an array of created Fonts, or null, if no fonts were created yet.
*/
- public String getDisplayName() {
- return "Outer Glow";
- }
+ public Font[] getCreatedFonts();
+
+ /**
+ * Similar to getCreatedFonts, but returns a TreeMap of fonts by family name.
+ */
+ public TreeMap getCreatedFontFamilyNames();
+
+ /**
+ * Returns all fonts installed in this environment.
+ */
+ public Font[] getAllInstalledFonts();
+
+ public String[] getInstalledFontFamilyNames(Locale requestedLocale);
}
diff --git a/jdk/src/share/classes/sun/font/FontManagerNativeLibrary.java b/jdk/src/share/classes/sun/font/FontManagerNativeLibrary.java
index ddb83064c5b..f1227f092a5 100644
--- a/jdk/src/share/classes/sun/font/FontManagerNativeLibrary.java
+++ b/jdk/src/share/classes/sun/font/FontManagerNativeLibrary.java
@@ -34,7 +34,7 @@ public class FontManagerNativeLibrary {
public Object run() {
/* REMIND do we really have to load awt here? */
System.loadLibrary("awt");
- if (SunGraphicsEnvironment.isOpenJDK() &&
+ if (FontUtilities.isOpenJDK &&
System.getProperty("os.name").startsWith("Windows")) {
/* Ideally fontmanager library should not depend on
particular implementation of the font scaler.
diff --git a/jdk/src/share/classes/sun/font/FontResolver.java b/jdk/src/share/classes/sun/font/FontResolver.java
index 9c3f892c5d5..2cad8741f74 100644
--- a/jdk/src/share/classes/sun/font/FontResolver.java
+++ b/jdk/src/share/classes/sun/font/FontResolver.java
@@ -114,7 +114,7 @@ public final class FontResolver {
for (int i=0; i