提交 03bd64e4 编写于 作者: M mullan

Merge

# #
# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -87,8 +87,7 @@ ...@@ -87,8 +87,7 @@
# sign Alias for sign-jar # sign Alias for sign-jar
# sign-jar Builds/signs sunjce_provider.jar (no install) # sign-jar Builds/signs sunjce_provider.jar (no install)
# #
# obfus Builds/obfuscates/signs/installs # obfus Builds/obfuscates/signs sunjce_provider.jar
# sunjce_provider.jar
# #
# release Builds all targets in preparation # release Builds all targets in preparation
# for workspace integration. # for workspace integration.
...@@ -101,8 +100,25 @@ ...@@ -101,8 +100,25 @@
BUILDDIR = ../../../.. BUILDDIR = ../../../..
PACKAGE = com.sun.crypto.provider PACKAGE = com.sun.crypto.provider
PRODUCT = sun PRODUCT = sun
#
# The following is for when we need to do postprocessing
# (signing/obfuscation) against a read-only build. If the OUTPUTDIR
# isn't writable, the build currently crashes out.
#
ifndef OPENJDK
ifdef ALT_JCE_BUILD_DIR
# =====================================================
# Where to place the output, in case we're building from a read-only
# build area. (e.g. a release engineering build.)
JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
IGNORE_WRITABLE_OUTPUTDIR_TEST=true
else
JCE_BUILD_DIR=${TEMPDIR}
endif
endif
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# #
# Location for the newly built classfiles. # Location for the newly built classfiles.
...@@ -147,6 +163,8 @@ endif # OPENJDK ...@@ -147,6 +163,8 @@ endif # OPENJDK
# #
UNSIGNED_DIR = $(TEMPDIR)/unsigned UNSIGNED_DIR = $(TEMPDIR)/unsigned
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# ===================================================== # =====================================================
# Build the unsigned sunjce_provider.jar file. # Build the unsigned sunjce_provider.jar file.
...@@ -184,44 +202,66 @@ ifndef OPENJDK ...@@ -184,44 +202,66 @@ ifndef OPENJDK
# Sign the provider jar file. Not needed for OpenJDK. # Sign the provider jar file. Not needed for OpenJDK.
# #
SIGNED_DIR = $(TEMPDIR)/signed SIGNED_DIR = $(JCE_BUILD_DIR)/signed
sign: sign-jar sign: sign-jar
sign-jar: $(SIGNED_DIR)/sunjce_provider.jar sign-jar: $(SIGNED_DIR)/sunjce_provider.jar
ifndef ALT_JCE_BUILD_DIR
$(SIGNED_DIR)/sunjce_provider.jar: $(UNSIGNED_DIR)/sunjce_provider.jar $(SIGNED_DIR)/sunjce_provider.jar: $(UNSIGNED_DIR)/sunjce_provider.jar
$(sign-file) else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(SIGNED_DIR)/sunjce_provider.jar:
@if [ ! -r $(UNSIGNED_DIR)/sunjce_provider.jar ] ; then \
$(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunjce_provider.jar"; \
exit 1; \
fi
endif
$(call sign-file, $(UNSIGNED_DIR)/sunjce_provider.jar)
# ===================================================== # =====================================================
# Obfuscate/sign/install the JDK build. Not needed for OpenJDK. # Obfuscate/sign/install the JDK build. Not needed for OpenJDK.
# #
OBFUS_DIR = $(TEMPDIR)/obfus OBFUS_DIR = $(JCE_BUILD_DIR)/obfus/sunjce
CLOSED_DIR = $(BUILDDIR)/closed/com/sun/crypto/provider CLOSED_DIR = $(BUILDDIR)/closed/com/sun/crypto/provider
obfus: $(OBFUS_DIR)/sunjce_provider.jar obfus: $(OBFUS_DIR)/sunjce_provider.jar
$(release-warning) $(release-warning)
$(OBFUS_DIR)/sunjce_provider.jar: build-jar $(JCE_MANIFEST_FILE) ifndef ALT_JCE_BUILD_DIR
$(OBFUS_DIR)/sunjce_provider.jar: build-jar $(JCE_MANIFEST_FILE) \
$(OBFUS_DIR)/sunjce.dox
else
$(OBFUS_DIR)/sunjce_provider.jar: $(JCE_MANIFEST_FILE) $(OBFUS_DIR)/sunjce.dox
@if [ ! -d $(CLASSDESTDIR) ] ; then \
$(ECHO) "Couldn't find $(CLASSDESTDIR)"; \
exit 1; \
fi
endif
@$(ECHO) ">>>Obfuscating SunJCE Provider..."
$(presign) $(presign)
$(preobfus) $(preobfus)
@$(ECHO) ">>>Obfuscating Sun JCE Provider..."
$(prep-target) $(prep-target)
$(CD) $(OBFUS_DIR); \ $(CD) $(OBFUS_DIR); \
$(OBFUSCATOR) -fv \ $(OBFUSCATOR) -fv sunjce.dox
$(CURRENT_DIRECTORY)/$(CLOSED_DIR)/obfus/sunjce.dox
@$(CD) $(OBFUS_DIR); $(java-vm-cleanup) @$(CD) $(OBFUS_DIR); $(java-vm-cleanup)
$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \ $(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \
-C $(OBFUS_DIR)/build com \ -C $(OBFUS_DIR)/build com \
$(JAR_JFLAGS) $(JAR_JFLAGS)
$(sign-target) $(sign-target)
$(MKDIR) -p $(dir $(JAR_DESTFILE))
$(RM) $(JAR_DESTFILE)
$(CP) $@ $(JAR_DESTFILE)
@$(java-vm-cleanup) @$(java-vm-cleanup)
$(OBFUS_DIR)/sunjce.dox: $(CLOSED_DIR)/obfus/sunjce.dox
@$(ECHO) ">>>Creating sunjce.dox"
$(prep-target)
$(SED) "s:@@TEMPDIR@@:$(ABS_TEMPDIR):" $< > $@
# #
# The current obfuscator has a limitation in that it currently only # The current obfuscator has a limitation in that it currently only
# supports up to v49 class file format. Force v49 classfiles in our # supports up to v49 class file format. Force v49 classfiles in our
...@@ -235,9 +275,9 @@ TARGET_CLASS_VERSION = 5 ...@@ -235,9 +275,9 @@ TARGET_CLASS_VERSION = 5
# #
release: $(OBFUS_DIR)/sunjce_provider.jar release: $(OBFUS_DIR)/sunjce_provider.jar
$(RM) $(RELEASE_DIR)/sunjce_provider.jar $(RM) $(JCE_BUILD_DIR)/release/sunjce_provider.jar
$(MKDIR) -p $(RELEASE_DIR) $(MKDIR) -p $(JCE_BUILD_DIR)/release
$(CP) $(OBFUS_DIR)/sunjce_provider.jar $(RELEASE_DIR) $(CP) $(OBFUS_DIR)/sunjce_provider.jar $(JCE_BUILD_DIR)/release
$(release-warning) $(release-warning)
endif # OPENJDK endif # OPENJDK
...@@ -275,7 +315,7 @@ endif ...@@ -275,7 +315,7 @@ endif
# #
clobber clean:: clobber clean::
$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
.PHONY: build-jar jar install-jar .PHONY: build-jar jar install-jar
ifndef OPENJDK ifndef OPENJDK
......
...@@ -50,13 +50,13 @@ CC_DEPEND = -MM ...@@ -50,13 +50,13 @@ CC_DEPEND = -MM
CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)& $(dir $@)$*.$(DEPEND_SUFFIX)!g' CC_DEPEND_FILTER = $(SED) -e 's!$*\.$(OBJECT_SUFFIX)!$(dir $@)& $(dir $@)$*.$(DEPEND_SUFFIX)!g'
ifndef PLATFORM_SRC ifndef PLATFORM_SRC
PLATFORM_SRC = $(JDK_TOPDIR)/src/solaris PLATFORM_SRC = $(BUILDDIR)/../src/solaris
endif # PLATFORM_SRC endif # PLATFORM_SRC
# Platform specific closed sources # Platform specific closed sources
ifndef OPENJDK ifndef OPENJDK
ifndef CLOSED_PLATFORM_SRC ifndef CLOSED_PLATFORM_SRC
CLOSED_PLATFORM_SRC = $(JDK_TOPDIR)/src/closed/solaris CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris
endif endif
endif endif
......
...@@ -45,13 +45,13 @@ ...@@ -45,13 +45,13 @@
include $(JDK_MAKE_SHARED_DIR)/Defs.gmk include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
ifndef PLATFORM_SRC ifndef PLATFORM_SRC
PLATFORM_SRC = $(JDK_TOPDIR)/src/solaris PLATFORM_SRC = $(BUILDDIR)/../src/solaris
endif # PLATFORM_SRC endif # PLATFORM_SRC
# Platform specific closed sources # Platform specific closed sources
ifndef OPENJDK ifndef OPENJDK
ifndef CLOSED_PLATFORM_SRC ifndef CLOSED_PLATFORM_SRC
CLOSED_PLATFORM_SRC = $(JDK_TOPDIR)/src/closed/solaris CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/solaris
endif endif
endif endif
......
...@@ -51,13 +51,13 @@ ifndef LIB_LOCATION ...@@ -51,13 +51,13 @@ ifndef LIB_LOCATION
endif # LIB_LOCATION endif # LIB_LOCATION
ifndef PLATFORM_SRC ifndef PLATFORM_SRC
PLATFORM_SRC = $(JDK_TOPDIR)/src/windows PLATFORM_SRC = $(BUILDDIR)/../src/windows
endif # PLATFORM_SRC endif # PLATFORM_SRC
# Platform specific closed sources # Platform specific closed sources
ifndef OPENJDK ifndef OPENJDK
ifndef CLOSED_PLATFORM_SRC ifndef CLOSED_PLATFORM_SRC
CLOSED_PLATFORM_SRC = $(JDK_TOPDIR)/src/closed/windows CLOSED_PLATFORM_SRC = $(BUILDDIR)/../src/closed/windows
endif endif
endif endif
...@@ -367,7 +367,7 @@ else ...@@ -367,7 +367,7 @@ else
endif endif
# Settings for the VERSIONINFO tap on windows. # Settings for the VERSIONINFO tap on windows.
VERSIONINFO_RESOURCE = $(JDK_TOPDIR)/src/windows/resource/version.rc VERSIONINFO_RESOURCE = $(BUILDDIR)/../src/windows/resource/version.rc
ifneq ($(JDK_BUILD_NUMBER),) ifneq ($(JDK_BUILD_NUMBER),)
COOKED_BUILD_NUMBER = $(shell $(ECHO) $(JDK_BUILD_NUMBER) | $(SED) -e 's/^b//' -e 's/^0//') COOKED_BUILD_NUMBER = $(shell $(ECHO) $(JDK_BUILD_NUMBER) | $(SED) -e 's/^b//' -e 's/^0//')
......
...@@ -41,7 +41,15 @@ ...@@ -41,7 +41,15 @@
SUN_MAKE_TEST:sh = echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33 SUN_MAKE_TEST:sh = echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33
ifndef JDK_TOPDIR ifndef JDK_TOPDIR
JDK_TOPDIR=$(BUILDDIR)/.. ifdef BUILDDIR
JDK_TOPDIR=$(BUILDDIR)/..
else
JDK_TOPDIR:=$(error "ERROR: Cannot define top of jdk repository")
endif
endif
ifndef BUILDDIR
# Hack, due to deploy repository using this file.
BUILDDIR=$(JDK_TOPDIR)/make
endif endif
ifndef JDK_MAKE_SHARED_DIR ifndef JDK_MAKE_SHARED_DIR
JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared
...@@ -59,13 +67,13 @@ include $(JDK_TOPDIR)/make/common/CancelImplicits.gmk ...@@ -59,13 +67,13 @@ include $(JDK_TOPDIR)/make/common/CancelImplicits.gmk
# there yet. # there yet.
# #
ifndef SHARE_SRC ifndef SHARE_SRC
SHARE_SRC = $(JDK_TOPDIR)/src/share SHARE_SRC = $(BUILDDIR)/../src/share
endif endif
# Files that cannot be included in the OpenJDK distribution are # Files that cannot be included in the OpenJDK distribution are
# collected under a parent directory which contains just those files. # collected under a parent directory which contains just those files.
ifndef CLOSED_SRC ifndef CLOSED_SRC
CLOSED_SRC = $(JDK_TOPDIR)/src/closed CLOSED_SRC = $(BUILDDIR)/../src/closed
endif endif
# If we have no closed directory, force it to an openjdk build # If we have no closed directory, force it to an openjdk build
...@@ -170,14 +178,6 @@ ifdef OPENJDK ...@@ -170,14 +178,6 @@ ifdef OPENJDK
endif endif
endif # OPENJDK endif # OPENJDK
# Default output directory
ifdef OPENJDK
_OUTPUTDIR=$(JDK_TOPDIR)/build/$(PLATFORM)-$(ARCH)$(OPENJDK_SUFFIX)
else
_OUTPUTDIR=$(JDK_TOPDIR)/build/$(PLATFORM)-$(ARCH)
endif
# #
# Get platform definitions # Get platform definitions
# #
......
...@@ -36,7 +36,7 @@ ifndef JDK_MAKE_SHARED_DIR ...@@ -36,7 +36,7 @@ ifndef JDK_MAKE_SHARED_DIR
endif endif
ifndef CONTROL_TOPDIR ifndef CONTROL_TOPDIR
CONTROL_TOPDIR=$(TOPDIR)/control CONTROL_TOPDIR=$(TOPDIR)
endif endif
ifndef HOTSPOT_TOPDIR ifndef HOTSPOT_TOPDIR
HOTSPOT_TOPDIR=$(TOPDIR)/hotspot HOTSPOT_TOPDIR=$(TOPDIR)/hotspot
...@@ -70,7 +70,8 @@ endif ...@@ -70,7 +70,8 @@ endif
include $(JDK_MAKE_SHARED_DIR)/Platform.gmk include $(JDK_MAKE_SHARED_DIR)/Platform.gmk
# Default output directory # Default output directory
_OUTPUTDIR=$(CONTROL_TOPDIR)/build/$(PLATFORM)-$(ARCH) BUILD_PARENT_DIRECTORY=$(TOPDIR)
_OUTPUTDIR=$(TOPDIR)/build/$(PLATFORM)-$(ARCH)
# Get platform specific settings # Get platform specific settings
include $(JDK_MAKE_SHARED_DIR)/Defs.gmk include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
......
# #
# Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -55,7 +55,10 @@ include $(JDK_MAKE_SHARED_DIR)/Defs-utils.gmk ...@@ -55,7 +55,10 @@ include $(JDK_MAKE_SHARED_DIR)/Defs-utils.gmk
# Simple pwd path # Simple pwd path
define PwdPath define PwdPath
$(shell cd $1 2> $(DEV_NULL) && pwd) $(shell $(CD) $1 2> $(DEV_NULL) && $(PWD))
endef
define AbsPwdPathCheck
$(shell $(CD) .. 2> $(DEV_NULL) && $(CD) $1 2> $(DEV_NULL) && $(PWD))
endef endef
# Checks an ALT value for spaces (should be one word), # Checks an ALT value for spaces (should be one word),
...@@ -422,24 +425,64 @@ CACERTS_FILE:=$(call AltCheckSpaces,CACERTS_FILE) ...@@ -422,24 +425,64 @@ CACERTS_FILE:=$(call AltCheckSpaces,CACERTS_FILE)
CACERTS_FILE:=$(call AltCheckValue,CACERTS_FILE) CACERTS_FILE:=$(call AltCheckValue,CACERTS_FILE)
# OUTPUTDIR: Location of all output for the build # OUTPUTDIR: Location of all output for the build
_BACKUP_OUTPUTDIR = $(TEMP_DISK)/$(USER)/jdk-outputdir
ifdef ALT_OUTPUTDIR ifdef ALT_OUTPUTDIR
_POSSIBLE_OUTPUTDIR =$(subst \,/,$(ALT_OUTPUTDIR)) OUTPUTDIR:=$(subst \,/,$(ALT_OUTPUTDIR))
# Assumes this is absolute (checks later)
ABS_OUTPUTDIR:=$(OUTPUTDIR)
else else
ifndef _OUTPUTDIR ifndef _OUTPUTDIR
_OUTPUTDIR = $(_BACKUP_OUTPUTDIR) # Default: Get "build" parent directory, which should always exist
ifndef BUILD_PARENT_DIRECTORY
BUILD_PARENT_DIRECTORY=$(BUILDDIR)/..
endif
ABS_BUILD_PARENT_DIRECTORY:=$(call FullPath,$(BUILD_PARENT_DIRECTORY))
ifdef OPENJDK
_OUTPUTDIRNAME=$(PLATFORM)-$(ARCH)$(OPENJDK_SUFFIX)
else
_OUTPUTDIRNAME=$(PLATFORM)-$(ARCH)
endif
_OUTPUTDIR=$(BUILD_PARENT_DIRECTORY)/build/$(_OUTPUTDIRNAME)
ABS_OUTPUTDIR:=$(ABS_BUILD_PARENT_DIRECTORY)/build/$(_OUTPUTDIRNAME)
endif endif
_POSSIBLE_OUTPUTDIR =$(_OUTPUTDIR) OUTPUTDIR:=$(_OUTPUTDIR)
endif
_create_outputdir1:=$(shell mkdir -p $(_POSSIBLE_OUTPUTDIR) > $(DEV_NULL) 2>&1)
OUTPUTDIR:=$(call WriteDirExists,$(_POSSIBLE_OUTPUTDIR),$(_BACKUP_OUTPUTDIR))
_create_outputdir2:=$(shell mkdir -p $(OUTPUTDIR) > $(DEV_NULL) 2>&1)
ifeq "$(OUTPUTDIR)" "$(_BACKUP_OUTPUTDIR)"
_outputdir_warning:=$(warning "WARNING: OUTPUTDIR '$(_POSSIBLE_OUTPUTDIR)' not writable, will use '$(_BACKUP_OUTPUTDIR)'")
endif endif
# Check for spaces and null value
OUTPUTDIR:=$(call AltCheckSpaces,OUTPUTDIR) OUTPUTDIR:=$(call AltCheckSpaces,OUTPUTDIR)
OUTPUTDIR:=$(call AltCheckValue,OUTPUTDIR) OUTPUTDIR:=$(call AltCheckValue,OUTPUTDIR)
#
# When signing the JCE framework and provider, we could be using built
# bits on a read-only filesystem. If so, this test will fail and crash
# the build.
#
ifndef IGNORE_WRITABLE_OUTPUTDIR_TEST
# Create the output directory and make sure it exists and is writable
_create_outputdir:=$(shell $(MKDIR) -p "$(OUTPUTDIR)" > $(DEV_NULL) 2>&1)
ifeq ($(call WriteDirExists,$(OUTPUTDIR),/dev/null),/dev/null)
_outputdir_error:=$(error "ERROR: OUTPUTDIR '$(OUTPUTDIR)' not created or not writable")
endif
endif
# Define absolute path if needed and check for spaces and null value
ifndef ABS_OUTPUTDIR
ABS_OUTPUTDIR:=$(call FullPath,$(OUTPUTDIR))
endif
ABS_OUTPUTDIR:=$(call AltCheckSpaces,ABS_OUTPUTDIR)
ABS_OUTPUTDIR:=$(call AltCheckValue,ABS_OUTPUTDIR)
# Make doubly sure this is a full path
ifeq ($(call AbsPwdPathCheck,$(ABS_OUTPUTDIR)), )
ifdef ALT_OUTPUTDIR
_outputdir_error:=$(error "ERROR: Trouble with the absolute path for OUTPUTDIR '$(OUTPUTDIR)', was ALT_OUTPUTDIR '$(ALT_OUTPUTDIR)' an absolute path?")
else
_outputdir_error:=$(error "ERROR: Trouble with the absolute path for OUTPUTDIR '$(OUTPUTDIR)'")
endif
endif
_dir1:=$(call FullPath,$(ABS_OUTPUTDIR))
_dir2:=$(call FullPath,$(OUTPUTDIR))
ifneq ($(_dir1),$(_dir2))
_outputdir_error:=$(error "ERROR: ABS_OUTPUTDIR '$(ABS_OUTPUTDIR)' is not the same directory as OUTPUTDIR '$(OUTPUTDIR)', '$(_dir1)'!='$(_dir2)'")
endif
# Bin directory # Bin directory
# NOTE: ISA_DIR is usually empty, on Solaris it might be /sparcv9 or /amd64 # NOTE: ISA_DIR is usually empty, on Solaris it might be /sparcv9 or /amd64
BINDIR = $(OUTPUTDIR)/bin$(ISA_DIR) BINDIR = $(OUTPUTDIR)/bin$(ISA_DIR)
...@@ -475,9 +518,6 @@ else ...@@ -475,9 +518,6 @@ else
COPYRIGHT_YEAR = $(shell $(DATE) '+%Y') COPYRIGHT_YEAR = $(shell $(DATE) '+%Y')
endif endif
# Absolute path to output directory
ABS_OUTPUTDIR:=$(call FullPath,$(OUTPUTDIR))
# Get shared compiler settings # Get shared compiler settings
include $(JDK_MAKE_SHARED_DIR)/Compiler.gmk include $(JDK_MAKE_SHARED_DIR)/Compiler.gmk
...@@ -93,20 +93,18 @@ SYSTEM_UNAME := $(shell uname) ...@@ -93,20 +93,18 @@ SYSTEM_UNAME := $(shell uname)
# Normal boot jdk is previous release, but a hard requirement is a 1.5 boot # Normal boot jdk is previous release, but a hard requirement is a 1.5 boot
REQUIRED_BOOT_VER = 1.5 REQUIRED_BOOT_VER = 1.5
#This is specific to OpenJDK build # If we are using freetype, this is the required version
ifdef OPENJDK REQUIRED_FREETYPE_VERSION=2.3.0
REQUIRED_FREETYPE_VERSION=2.3.0
endif
# #
# Prune out all known SCM (Source Code Management) directories # Prune out all known SCM (Source Code Management) directories
# so they will not be included when copying directory trees # so they will not be included when copying directory trees
# or packaging up .jar files, etc. This applies to all workspaces. # or packaging up .jar files, etc. This applies to all workspaces.
# #
SCM_DIRs = .hg .svn CVS RCS SCCS Codemgr_wsdata deleted_files SCM_DIRs = .hg .svn CVS RCS SCCS Codemgr_wsdata deleted_files .hgignore .hgtags
# When changing SCM_DIRs also change SCM_DIRS_rexp and SCM_DIRS_prune: # 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_rexp = ".hg|.svn|CVS|RCS|SCCS|Codemgr_wsdata|deleted_files|.hgignore|.hgtags"
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 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 -o -name .hgignore -o -name .hgtags \) -prune
# Don't define this unless it's not defined # Don't define this unless it's not defined
ifndef VARIANT ifndef VARIANT
......
...@@ -191,7 +191,7 @@ sources: $(SPP) $(FILES_genout) ...@@ -191,7 +191,7 @@ sources: $(SPP) $(FILES_genout)
GEN_BUFFER_SH = genBuffer.sh GEN_BUFFER_SH = genBuffer.sh
GEN_BUFFER_CMD = SPP="$(SPP_CMD)" NAWK=$(NAWK) SED=$(SED) \ GEN_BUFFER_CMD = SPP="$(SPP_CMD)" NAWK=$(NAWK) SED=$(SED) SH=$(SH) \
$(SH) $(GEN_BUFFER_SH) $(SH) $(GEN_BUFFER_SH)
# Public abstract buffer classes # Public abstract buffer classes
...@@ -582,7 +582,7 @@ $(BUF_GEN)/ByteBufferAsDoubleBuffer%L.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.jav ...@@ -582,7 +582,7 @@ $(BUF_GEN)/ByteBufferAsDoubleBuffer%L.java: $(BUF_SRC)/ByteBufferAs-X-Buffer.jav
GEN_CODER_SH = genCoder.sh GEN_CODER_SH = genCoder.sh
GEN_CODER_CMD = SPP="$(SPP_CMD)" SED=$(SED) NAWK=$(NAWK) $(SH) $(GEN_CODER_SH) GEN_CODER_CMD = SPP="$(SPP_CMD)" SED=$(SED) NAWK=$(NAWK) SH=$(SH) $(SH) $(GEN_CODER_SH)
$(CS_GEN)/CharsetDecoder.java: $(CS_SRC)/Charset-X-Coder.java $(GEN_CODER_SH) $(CS_GEN)/CharsetDecoder.java: $(CS_SRC)/Charset-X-Coder.java $(GEN_CODER_SH)
$(prep-target) $(prep-target)
...@@ -602,7 +602,7 @@ $(CS_GEN)/CharsetEncoder.java: $(CS_SRC)/Charset-X-Coder.java $(GEN_CODER_SH) ...@@ -602,7 +602,7 @@ $(CS_GEN)/CharsetEncoder.java: $(CS_SRC)/Charset-X-Coder.java $(GEN_CODER_SH)
GEN_EX_SH = genExceptions.sh GEN_EX_SH = genExceptions.sh
GEN_EX_CMD = NAWK=$(NAWK) $(SHELL) $(GEN_EX_SH) GEN_EX_CMD = NAWK=$(NAWK) SH=$(SH) $(SH) $(GEN_EX_SH)
$(CH_GEN)/%Exception.java: genExceptions.sh $(CH_SRC)/exceptions $(CH_GEN)/%Exception.java: genExceptions.sh $(CH_SRC)/exceptions
$(prep-target) $(prep-target)
...@@ -635,8 +635,8 @@ $(SCS_GEN)/StandardCharsets.java: genCharsetProvider.sh \ ...@@ -635,8 +635,8 @@ $(SCS_GEN)/StandardCharsets.java: genCharsetProvider.sh \
$(HASHER_JARFILE) $(SCS_SRC)/standard-charsets $(HASHER_JARFILE) $(SCS_SRC)/standard-charsets
$(prep-target) $(prep-target)
@$(RM) $@.temp @$(RM) $@.temp
NAWK=$(NAWK) TEMPDIR=$(TEMPDIR) \ NAWK=$(NAWK) TEMPDIR=$(TEMPDIR) SH=$(SH) \
HASHER="$(BOOT_JAVA_CMD) -jar $(HASHER_JARFILE)" \ HASHER="$(BOOT_JAVA_CMD) -jar $(HASHER_JARFILE)" \
$(SHELL) -e genCharsetProvider.sh $(SCS_SRC)/standard-charsets $(SCS_GEN) $(SH) -e genCharsetProvider.sh $(SCS_SRC)/standard-charsets $(SCS_GEN)
.PHONY: sources .PHONY: sources
...@@ -48,7 +48,7 @@ echo '-->' $OUT ...@@ -48,7 +48,7 @@ echo '-->' $OUT
# Header # Header
# #
$SHELL addNotices.sh "$COPYRIGHT_YEARS" > $OUT $SH ./addNotices.sh "$COPYRIGHT_YEARS" > $OUT
cat <<__END__ >>$OUT cat <<__END__ >>$OUT
......
...@@ -41,7 +41,7 @@ gen() { ...@@ -41,7 +41,7 @@ gen() {
echo '-->' $DST/$ID.java echo '-->' $DST/$ID.java
out=$DST/${ID}.java out=$DST/${ID}.java
$SHELL addNotices.sh "$COPYRIGHT_YEARS" > $out $SH ./addNotices.sh "$COPYRIGHT_YEARS" > $out
cat >>$out <<__END__ cat >>$out <<__END__
......
# #
# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -31,7 +31,7 @@ include $(BUILDDIR)/common/Release.gmk ...@@ -31,7 +31,7 @@ include $(BUILDDIR)/common/Release.gmk
JCE_MANIFEST_FILE = $(TEMPDIR)/manifest.mf JCE_MANIFEST_FILE = $(TEMPDIR)/manifest.mf
$(JCE_MANIFEST_FILE): $(MAINMANIFEST) $(JCE_MANIFEST_FILE): $(MAINMANIFEST)
$(prep-target) $(prep-target)
( $(SED) "s/@@RELEASE@@/$(RELEASE)/" $(MAINMANIFEST); \ ( $(SED) "s/@@RELEASE@@/$(RELEASE)/" $<; \
$(ECHO) "Extension-Name: javax.crypto"; \ $(ECHO) "Extension-Name: javax.crypto"; \
$(ECHO) "Implementation-Vendor-Id: com.sun"; ) > $@ $(ECHO) "Implementation-Vendor-Id: com.sun"; ) > $@
...@@ -75,6 +75,7 @@ endef ...@@ -75,6 +75,7 @@ endef
define sign-target define sign-target
$(BOOT_JARSIGNER_CMD) -keystore $(SIGNING_KEYSTORE) \ $(BOOT_JARSIGNER_CMD) -keystore $(SIGNING_KEYSTORE) \
$@ $(SIGNING_ALIAS) < $(SIGNING_PASSPHRASE) $@ $(SIGNING_ALIAS) < $(SIGNING_PASSPHRASE)
@$(java-vm-cleanup)
@$(ECHO) "\nJar codesigning finished." @$(ECHO) "\nJar codesigning finished."
endef endef
...@@ -88,13 +89,15 @@ define release-warning ...@@ -88,13 +89,15 @@ define release-warning
endef endef
# #
# Convenience macro for steps needed to sign a jar file. # Convenience macros for signing a jar file.
#
# Call through $(call sign-file, target file)
# #
define sign-file define sign-file
$(presign) $(presign)
$(install-file) $(prep-target)
$(CP) $1 $@
$(sign-target) $(sign-target)
@$(java-vm-cleanup)
endef endef
# #
......
# #
# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
# sign-jar Builds/signs jce.jar file (no install) # sign-jar Builds/signs jce.jar file (no install)
# sign-policy Builds/signs policy files (no install) # sign-policy Builds/signs policy files (no install)
# #
# obfus Builds/obfuscates/signs/installs jce.jar # obfus Builds/obfuscates/signs jce.jar
# #
# release Builds all targets in preparation # release Builds all targets in preparation
# for workspace integration. # for workspace integration.
...@@ -110,8 +110,24 @@ BUILDDIR = ../.. ...@@ -110,8 +110,24 @@ BUILDDIR = ../..
PACKAGE = javax.crypto PACKAGE = javax.crypto
PRODUCT = sun PRODUCT = sun
#
# The following is for when we need to do postprocessing
# (signing/obfuscation) against a read-only build. If the OUTPUTDIR
# isn't writable, the build currently crashes out.
#
ifndef OPENJDK
ifdef ALT_JCE_BUILD_DIR
# =====================================================
# Where to place the output, in case we're building from a read-only
# build area. (e.g. a release engineering build.)
JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
IGNORE_WRITABLE_OUTPUTDIR_TEST=true
else
JCE_BUILD_DIR=${TEMPDIR}
endif
endif
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
include Defs-jce.gmk
# #
# Location for the newly built classfiles. # Location for the newly built classfiles.
...@@ -158,6 +174,8 @@ endif # OPENJDK ...@@ -158,6 +174,8 @@ endif # OPENJDK
# #
UNSIGNED_DIR = $(TEMPDIR)/unsigned UNSIGNED_DIR = $(TEMPDIR)/unsigned
include Defs-jce.gmk
# ===================================================== # =====================================================
# Build the unsigned jce.jar file. Signing/obfuscation comes later. # Build the unsigned jce.jar file. Signing/obfuscation comes later.
...@@ -299,7 +317,7 @@ ifndef OPENJDK ...@@ -299,7 +317,7 @@ ifndef OPENJDK
# Sign the various jar files. Not needed for OpenJDK. # Sign the various jar files. Not needed for OpenJDK.
# #
SIGNED_DIR = $(TEMPDIR)/signed SIGNED_DIR = $(JCE_BUILD_DIR)/signed
SIGNED_POLICY_BUILDDIR = $(SIGNED_DIR)/policy SIGNED_POLICY_BUILDDIR = $(SIGNED_DIR)/policy
SIGNED_POLICY_FILES = \ SIGNED_POLICY_FILES = \
...@@ -312,61 +330,87 @@ sign-jar: $(SIGNED_DIR)/jce.jar ...@@ -312,61 +330,87 @@ sign-jar: $(SIGNED_DIR)/jce.jar
sign-policy: $(SIGNED_POLICY_FILES) sign-policy: $(SIGNED_POLICY_FILES)
ifndef ALT_JCE_BUILD_DIR
$(SIGNED_DIR)/jce.jar: $(UNSIGNED_DIR)/jce.jar $(SIGNED_DIR)/jce.jar: $(UNSIGNED_DIR)/jce.jar
$(sign-file) else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(SIGNED_DIR)/jce.jar:
@if [ ! -r $(UNSIGNED_DIR)/jce.jar ] ; then \
$(ECHO) "Couldn't find $(UNSIGNED_DIR)/jce.jar"; \
exit 1; \
fi
endif
$(call sign-file, $(UNSIGNED_DIR)/jce.jar)
$(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar: \ $(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar: \
$(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar $(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar
$(sign-file) $(call sign-file, $<)
$(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar: \ $(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar: \
$(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar $(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar
$(sign-file) $(call sign-file, $<)
$(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar: \ $(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar: \
$(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar $(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar
$(sign-file) $(call sign-file, $<)
$(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar: \ $(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar: \
$(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar $(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar
$(sign-file) $(call sign-file, $<)
# ===================================================== # =====================================================
# Obfuscate/sign/install the JDK build. Not needed for OpenJDK. # Obfuscate/sign/install the JDK build. Not needed for OpenJDK.
# #
OBFUS_DIR = $(TEMPDIR)/obfus OBFUS_DIR = $(JCE_BUILD_DIR)/obfus/jce
CLOSED_DIR = $(BUILDDIR)/closed/javax/crypto CLOSED_DIR = $(BUILDDIR)/closed/javax/crypto
obfus: $(OBFUS_DIR)/jce.jar obfus: $(OBFUS_DIR)/jce.jar
$(release-warning) $(release-warning)
$(OBFUS_DIR)/jce.jar: build-jar $(JCE_MANIFEST_FILE) ifndef ALT_JCE_BUILD_DIR
$(OBFUS_DIR)/jce.jar: build-jar $(JCE_MANIFEST_FILE) $(OBFUS_DIR)/framework.dox
else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(OBFUS_DIR)/jce.jar: $(JCE_MANIFEST_FILE) $(OBFUS_DIR)/framework.dox
@if [ ! -d $(CLASSDESTDIR) ] ; then \
$(ECHO) "Couldn't find $(CLASSDESTDIR)"; \
exit 1; \
fi
endif
@$(ECHO) ">>>Obfuscating JCE framework..."
$(presign) $(presign)
$(preobfus) $(preobfus)
@$(ECHO) ">>>Obfuscating JCE framework..."
$(prep-target) $(prep-target)
$(CD) $(OBFUS_DIR); \ $(CD) $(OBFUS_DIR); \
$(OBFUSCATOR) -fv \ $(OBFUSCATOR) -fv framework.dox
$(CURRENT_DIRECTORY)/$(CLOSED_DIR)/obfus/framework.dox
@$(CD) $(OBFUS_DIR); $(java-vm-cleanup) @$(CD) $(OBFUS_DIR); $(java-vm-cleanup)
@#
@# The sun.security.internal classes are currently not obfuscated @# The sun.security.internal classes are currently not obfuscated
@# due to an obfus problem. Manually copy them to the build directory @# due to an obfus problem. Manually copy them to the build directory
@# so that they are included in the jce.jar file. @# so that they are included in the jce.jar file.
@#
$(CP) -r $(CLASSDESTDIR)/sun $(OBFUS_DIR)/build $(CP) -r $(CLASSDESTDIR)/sun $(OBFUS_DIR)/build
$(RM) $(UNSIGNED_DIR)/jce.jar
$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \ $(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \
-C $(OBFUS_DIR)/build javax \ -C $(OBFUS_DIR)/build javax \
-C $(OBFUS_DIR)/build sun \ -C $(OBFUS_DIR)/build sun \
$(JAR_JFLAGS) $(JAR_JFLAGS)
$(sign-target) $(sign-target)
$(MKDIR) -p $(dir $(JAR_DESTFILE))
$(RM) $(JAR_DESTFILE)
$(CP) $@ $(JAR_DESTFILE)
@$(java-vm-cleanup) @$(java-vm-cleanup)
$(OBFUS_DIR)/framework.dox: $(CLOSED_DIR)/obfus/framework.dox
@$(ECHO) ">>>Creating framework.dox"
$(prep-target)
$(SED) "s:@@TEMPDIR@@:$(ABS_TEMPDIR):" $< > $@
# #
# The current obfuscator has a limitation in that it currently only # The current obfuscator has a limitation in that it currently only
# supports up to v49 class file format. Force v49 classfiles in our # supports up to v49 class file format. Force v49 classfiles in our
...@@ -380,26 +424,27 @@ TARGET_CLASS_VERSION = 5 ...@@ -380,26 +424,27 @@ TARGET_CLASS_VERSION = 5
# unlimited policy file distribution, etc. # unlimited policy file distribution, etc.
# #
release: $(OBFUS_DIR)/jce.jar sign-policy release: $(OBFUS_DIR)/jce.jar sign-policy $(CLOSED_DIR)/doc/COPYRIGHT.html \
$(CLOSED_DIR)/doc/README.txt
$(RM) -r \ $(RM) -r \
$(RELEASE_DIR)/UnlimitedJCEPolicy \ $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy \
$(RELEASE_DIR)/jce.jar \ $(JCE_BUILD_DIR)/release/jce.jar \
$(RELEASE_DIR)/US_export_policy.jar \ $(JCE_BUILD_DIR)/release/US_export_policy.jar \
$(RELEASE_DIR)/local_policy.jar \ $(JCE_BUILD_DIR)/release/local_policy.jar \
$(RELEASE_DIR)/UnlimitedJCEPolicy.zip $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy.zip
$(MKDIR) -p $(RELEASE_DIR)/UnlimitedJCEPolicy $(MKDIR) -p $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy
$(CP) $(OBFUS_DIR)/jce.jar $(RELEASE_DIR) $(CP) $(OBFUS_DIR)/jce.jar $(JCE_BUILD_DIR)/release
$(CP) -r \ $(CP) \
$(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar \ $(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar \
$(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar \ $(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar \
$(RELEASE_DIR) $(JCE_BUILD_DIR)/release
$(CP) \ $(CP) \
$(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar \ $(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar \
$(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar \ $(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar \
$(RELEASE_DIR)/UnlimitedJCEPolicy $(CLOSED_DIR)/doc/COPYRIGHT.html \
$(CP) $(CLOSED_DIR)/doc/COPYRIGHT.html \ $(CLOSED_DIR)/doc/README.txt \
$(CLOSED_DIR)/doc/README.txt $(RELEASE_DIR)/UnlimitedJCEPolicy $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy
cd $(RELEASE_DIR) ; \ cd $(JCE_BUILD_DIR)/release ; \
$(ZIPEXE) -qr UnlimitedJCEPolicy.zip UnlimitedJCEPolicy $(ZIPEXE) -qr UnlimitedJCEPolicy.zip UnlimitedJCEPolicy
$(release-warning) $(release-warning)
...@@ -478,7 +523,8 @@ endif ...@@ -478,7 +523,8 @@ endif
clobber clean:: clobber clean::
$(RM) -r $(JAR_DESTFILE) $(POLICY_DESTDIR)/US_export_policy.jar \ $(RM) -r $(JAR_DESTFILE) $(POLICY_DESTDIR)/US_export_policy.jar \
$(POLICY_DESTDIR)/local_policy.jar $(DELETE_DIRS) $(TEMPDIR) $(POLICY_DESTDIR)/local_policy.jar $(DELETE_DIRS) $(TEMPDIR) \
$(JCE_BUILD_DIR)
.PHONY: build-jar jar build-policy unlimited limited install-jar \ .PHONY: build-jar jar build-policy unlimited limited install-jar \
install-limited install-unlimited install-limited install-unlimited
......
# #
# Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -92,8 +92,25 @@ BUILDDIR = ../../.. ...@@ -92,8 +92,25 @@ BUILDDIR = ../../..
PACKAGE = sun.security.mscapi PACKAGE = sun.security.mscapi
LIBRARY = sunmscapi LIBRARY = sunmscapi
PRODUCT = sun PRODUCT = sun
#
# The following is for when we need to do postprocessing
# (signing/obfuscation) against a read-only build. If the OUTPUTDIR
# isn't writable, the build currently crashes out.
#
ifndef OPENJDK
ifdef ALT_JCE_BUILD_DIR
# =====================================================
# Where to place the output, in case we're building from a read-only
# build area. (e.g. a release engineering build.)
JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
IGNORE_WRITABLE_OUTPUTDIR_TEST=true
else
JCE_BUILD_DIR=${TEMPDIR}
endif
endif
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
CPLUSPLUSLIBRARY=true CPLUSPLUSLIBRARY=true
...@@ -163,6 +180,8 @@ all: build-jar install-prebuilt ...@@ -163,6 +180,8 @@ all: build-jar install-prebuilt
$(build-warning) $(build-warning)
endif endif
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# ===================================================== # =====================================================
# Build the unsigned sunmscapi.jar file. # Build the unsigned sunmscapi.jar file.
...@@ -200,14 +219,26 @@ ifndef OPENJDK ...@@ -200,14 +219,26 @@ ifndef OPENJDK
# Sign the provider jar file. Not needed for OpenJDK. # Sign the provider jar file. Not needed for OpenJDK.
# #
SIGNED_DIR = $(TEMPDIR)/signed SIGNED_DIR = $(JCE_BUILD_DIR)/signed
sign: sign-jar sign: sign-jar
sign-jar: $(SIGNED_DIR)/sunmscapi.jar sign-jar: $(SIGNED_DIR)/sunmscapi.jar
ifndef ALT_JCE_BUILD_DIR
$(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar $(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar
$(sign-file) else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(SIGNED_DIR)/sunmscapi.jar:
@if [ ! -r $(UNSIGNED_DIR)/sunmscapi.jar ] ; then \
$(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunmscapi.jar"; \
exit 1; \
fi
endif
$(call sign-file, $(UNSIGNED_DIR)/sunmscapi.jar)
# ===================================================== # =====================================================
...@@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar ...@@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar
# #
release: $(SIGNED_DIR)/sunmscapi.jar release: $(SIGNED_DIR)/sunmscapi.jar
$(RM) $(RELEASE_DIR)/sunmscapi.jar $(RM) $(JCE_BUILD_DIR)/release/sunmscapi.jar
$(MKDIR) -p $(RELEASE_DIR) $(MKDIR) -p $(JCE_BUILD_DIR)/release
$(CP) $(SIGNED_DIR)/sunmscapi.jar $(RELEASE_DIR) $(CP) $(SIGNED_DIR)/sunmscapi.jar $(JCE_BUILD_DIR)/release
$(release-warning) $(release-warning)
endif # OPENJDK endif # OPENJDK
...@@ -255,7 +286,7 @@ endif ...@@ -255,7 +286,7 @@ endif
# #
clobber clean:: clobber clean::
$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
.PHONY: build-jar jar install-jar .PHONY: build-jar jar install-jar
ifndef OPENJDK ifndef OPENJDK
......
# #
# Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -92,8 +92,25 @@ BUILDDIR = ../../.. ...@@ -92,8 +92,25 @@ BUILDDIR = ../../..
PACKAGE = sun.security.pkcs11 PACKAGE = sun.security.pkcs11
LIBRARY = j2pkcs11 LIBRARY = j2pkcs11
PRODUCT = sun PRODUCT = sun
#
# The following is for when we need to do postprocessing
# (signing/obfuscation) against a read-only build. If the OUTPUTDIR
# isn't writable, the build currently crashes out.
#
ifndef OPENJDK
ifdef ALT_JCE_BUILD_DIR
# =====================================================
# Where to place the output, in case we're building from a read-only
# build area. (e.g. a release engineering build.)
JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
IGNORE_WRITABLE_OUTPUTDIR_TEST=true
else
JCE_BUILD_DIR=${TEMPDIR}
endif
endif
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# #
# C and Java Files # C and Java Files
...@@ -163,6 +180,8 @@ all: build-jar install-prebuilt ...@@ -163,6 +180,8 @@ all: build-jar install-prebuilt
$(build-warning) $(build-warning)
endif endif
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# ===================================================== # =====================================================
# Build the unsigned sunpkcs11.jar file. # Build the unsigned sunpkcs11.jar file.
...@@ -200,14 +219,26 @@ ifndef OPENJDK ...@@ -200,14 +219,26 @@ ifndef OPENJDK
# Sign the provider jar file. Not needed for OpenJDK. # Sign the provider jar file. Not needed for OpenJDK.
# #
SIGNED_DIR = $(TEMPDIR)/signed SIGNED_DIR = $(JCE_BUILD_DIR)/signed
sign: sign-jar sign: sign-jar
sign-jar: $(SIGNED_DIR)/sunpkcs11.jar sign-jar: $(SIGNED_DIR)/sunpkcs11.jar
ifndef ALT_JCE_BUILD_DIR
$(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar $(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar
$(sign-file) else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(SIGNED_DIR)/sunpkcs11.jar:
@if [ ! -r $(UNSIGNED_DIR)/sunpkcs11.jar ] ; then \
$(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunpkcs11.jar"; \
exit 1; \
fi
endif
$(call sign-file, $(UNSIGNED_DIR)/sunpkcs11.jar)
# ===================================================== # =====================================================
...@@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar ...@@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar
# #
release: $(SIGNED_DIR)/sunpkcs11.jar release: $(SIGNED_DIR)/sunpkcs11.jar
$(RM) $(RELEASE_DIR)/sunpkcs11.jar $(RM) $(JCE_BUILD_DIR)/release/sunpkcs11.jar
$(MKDIR) -p $(RELEASE_DIR) $(MKDIR) -p $(JCE_BUILD_DIR)/release
$(CP) $(SIGNED_DIR)/sunpkcs11.jar $(RELEASE_DIR) $(CP) $(SIGNED_DIR)/sunpkcs11.jar $(JCE_BUILD_DIR)/release
$(release-warning) $(release-warning)
endif # OPENJDK endif # OPENJDK
...@@ -255,7 +286,7 @@ endif ...@@ -255,7 +286,7 @@ endif
# #
clobber clean:: clobber clean::
$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
.PHONY: build-jar jar install-jar .PHONY: build-jar jar install-jar
ifndef OPENJDK ifndef OPENJDK
......
...@@ -85,3 +85,13 @@ vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen ...@@ -85,3 +85,13 @@ vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen
CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen -I$(SHARE_SRC)/native/$(PKGDIR)/splashscreen CPPFLAGS += -I$(PLATFORM_SRC)/native/$(PKGDIR)/splashscreen -I$(SHARE_SRC)/native/$(PKGDIR)/splashscreen
CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/image/jpeg -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3 CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/image/jpeg -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
ifeq ($(PLATFORM), linux)
ifeq ($(ARCH_DATA_MODEL), 64)
# 64-bit gcc has problems compiling MMX instructions.
# Google it for more details. Possibly the newer versions of
# the PNG-library and/or the new compiler will not need this
# option in the future.
CPPFLAGS += -DPNG_NO_MMX_CODE
endif
endif
# #
# Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -246,7 +246,7 @@ $(SIZES): $(SIZERS) ...@@ -246,7 +246,7 @@ $(SIZES): $(SIZERS)
@if [ "$(DOCOMPARE)$(suffix $@)" = "true.64" ]; then \ @if [ "$(DOCOMPARE)$(suffix $@)" = "true.64" ]; then \
$(ECHO) COMPARING $@ and $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \ $(ECHO) COMPARING $@ and $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
$(DIFF) $@ $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \ $(DIFF) $@ $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
fi fi
$(TEMPDIR)/.gen.wrappers: $(SIZES) $(WRAPPER_GENERATOR_CLASS) $(XLIBTYPES) $(TEMPDIR)/.gen.wrappers: $(SIZES) $(WRAPPER_GENERATOR_CLASS) $(XLIBTYPES)
$(BOOT_JAVA_CMD) -cp $(WRAPPER_GENERATOR_TEMPDIR) WrapperGenerator \ $(BOOT_JAVA_CMD) -cp $(WRAPPER_GENERATOR_TEMPDIR) WrapperGenerator \
...@@ -256,10 +256,11 @@ touch.wrappers: $(TEMPDIR)/.gen.wrappers ...@@ -256,10 +256,11 @@ touch.wrappers: $(TEMPDIR)/.gen.wrappers
$(MKDIR) -p $(TEMPDIR) $(MKDIR) -p $(TEMPDIR)
$(TOUCH) $(TEMPDIR)/.gen.wrappers $(TOUCH) $(TEMPDIR)/.gen.wrappers
generated.clean: generated.clean:
$(RM) -r $(WRAPPER_GENERATOR_TEMPDIR) $(RM) -r $(WRAPPER_GENERATOR_TEMPDIR)
$(RM) -r $(WRAPPER_GENERATOR_DIR) $(RM) -r $(WRAPPER_GENERATOR_DIR)
$(RM) -r $(GEN_DIR)/*.java $(RM) -r $(GEN_DIR)/*.java
$(RM) -r $(TEMPDIR)/.gen_icons
ifdef OPENJDK ifdef OPENJDK
ICONS_PATH_PREFIX=$(PLATFORM_SRC) ICONS_PATH_PREFIX=$(PLATFORM_SRC)
......
...@@ -38,7 +38,14 @@ FT_TEST_PATH = $(TEMPDIR)/$(FT_TEST) ...@@ -38,7 +38,14 @@ FT_TEST_PATH = $(TEMPDIR)/$(FT_TEST)
all: $(FT_TEST_PATH) all: $(FT_TEST_PATH)
FT_OPTIONS = -I$(FT_HEADERS) -I$(FT_HEADERS)/freetype2 # Start with CFLAGS (which gets us the required -xarch setting on solaris)
ifeq ($(PLATFORM), windows)
FT_OPTIONS =
else
FT_OPTIONS = $(CFLAGS)
endif
FT_OPTIONS += -I$(FT_HEADERS) -I$(FT_HEADERS)/freetype2
FT_OPTIONS += $(XARCH) FT_OPTIONS += $(XARCH)
#add runtime library search path #add runtime library search path
......
...@@ -1118,11 +1118,11 @@ public abstract class OpenConverter { ...@@ -1118,11 +1118,11 @@ public abstract class OpenConverter {
final Class<ConstructorProperties> propertyNamesClass = ConstructorProperties.class; final Class<ConstructorProperties> propertyNamesClass = ConstructorProperties.class;
Class targetClass = getTargetClass(); Class targetClass = getTargetClass();
Constructor[] constrs = targetClass.getConstructors(); Constructor<?>[] constrs = targetClass.getConstructors();
// Applicable if and only if there are any annotated constructors // Applicable if and only if there are any annotated constructors
List<Constructor> annotatedConstrList = newList(); List<Constructor<?>> annotatedConstrList = newList();
for (Constructor constr : constrs) { for (Constructor<?> constr : constrs) {
if (Modifier.isPublic(constr.getModifiers()) if (Modifier.isPublic(constr.getModifiers())
&& constr.getAnnotation(propertyNamesClass) != null) && constr.getAnnotation(propertyNamesClass) != null)
annotatedConstrList.add(constr); annotatedConstrList.add(constr);
...@@ -1152,7 +1152,7 @@ public abstract class OpenConverter { ...@@ -1152,7 +1152,7 @@ public abstract class OpenConverter {
// Also remember the set of properties in that constructor // Also remember the set of properties in that constructor
// so we can test unambiguity. // so we can test unambiguity.
Set<BitSet> getterIndexSets = newSet(); Set<BitSet> getterIndexSets = newSet();
for (Constructor constr : annotatedConstrList) { for (Constructor<?> constr : annotatedConstrList) {
String[] propertyNames = String[] propertyNames =
constr.getAnnotation(propertyNamesClass).value(); constr.getAnnotation(propertyNamesClass).value();
...@@ -1309,10 +1309,10 @@ public abstract class OpenConverter { ...@@ -1309,10 +1309,10 @@ public abstract class OpenConverter {
} }
private static class Constr { private static class Constr {
final Constructor constructor; final Constructor<?> constructor;
final int[] paramIndexes; final int[] paramIndexes;
final BitSet presentParams; final BitSet presentParams;
Constr(Constructor constructor, int[] paramIndexes, Constr(Constructor<?> constructor, int[] paramIndexes,
BitSet presentParams) { BitSet presentParams) {
this.constructor = constructor; this.constructor = constructor;
this.paramIndexes = paramIndexes; this.paramIndexes = paramIndexes;
......
CTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html> <html>
<head> <head>
<!-- <!--
......
...@@ -621,8 +621,14 @@ public class ConfigFile extends javax.security.auth.login.Configuration { ...@@ -621,8 +621,14 @@ public class ConfigFile extends javax.security.auth.login.Configuration {
*/ */
private InputStream getInputStream(URL url) throws IOException { private InputStream getInputStream(URL url) throws IOException {
if ("file".equals(url.getProtocol())) { if ("file".equals(url.getProtocol())) {
String path = url.getFile().replace('/', File.separatorChar); try {
return new FileInputStream(path); File path = new File(url.toURI());
return new FileInputStream(path);
} catch (IOException ioe) {
throw ioe;
} catch (Exception ex) {
throw new IOException(ex.getMessage(), ex);
}
} else { } else {
return url.openStream(); return url.openStream();
} }
......
...@@ -634,6 +634,11 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -634,6 +634,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
*/ */
private PropertyChangeSupport changeSupport; private PropertyChangeSupport changeSupport;
private transient final Object changeSupportLock = new Object();
private Object getChangeSupportLock() {
return changeSupportLock;
}
boolean isPacked = false; boolean isPacked = false;
/** /**
...@@ -935,24 +940,26 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -935,24 +940,26 @@ public abstract class Component implements ImageObserver, MenuContainer,
*/ */
public GraphicsConfiguration getGraphicsConfiguration() { public GraphicsConfiguration getGraphicsConfiguration() {
synchronized(getTreeLock()) { synchronized(getTreeLock()) {
GraphicsConfiguration gc = graphicsConfig; if (graphicsConfig != null) {
Component parent = getParent(); return graphicsConfig;
while ((gc == null) && (parent != null)) { } else if (getParent() != null) {
gc = parent.getGraphicsConfiguration(); return getParent().getGraphicsConfiguration();
parent = parent.getParent(); } else {
return null;
} }
return gc;
} }
} }
final GraphicsConfiguration getGraphicsConfiguration_NoClientCode() { final GraphicsConfiguration getGraphicsConfiguration_NoClientCode() {
GraphicsConfiguration gc = this.graphicsConfig; GraphicsConfiguration graphicsConfig = this.graphicsConfig;
Component par = this.parent; Container parent = this.parent;
while ((gc == null) && (par != null)) { if (graphicsConfig != null) {
gc = par.getGraphicsConfiguration_NoClientCode(); return graphicsConfig;
par = par.parent; } else if (parent != null) {
return parent.getGraphicsConfiguration_NoClientCode();
} else {
return null;
} }
return gc;
} }
/** /**
...@@ -4602,7 +4609,8 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -4602,7 +4609,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
e.isPopupTrigger(), e.isPopupTrigger(),
e.getScrollType(), e.getScrollType(),
e.getScrollAmount(), e.getScrollAmount(),
e.getWheelRotation()); e.getWheelRotation(),
e.getPreciseWheelRotation());
((AWTEvent)e).copyPrivateDataInto(newMWE); ((AWTEvent)e).copyPrivateDataInto(newMWE);
// When dispatching a wheel event to // When dispatching a wheel event to
// ancestor, there is no need trying to find descendant // ancestor, there is no need trying to find descendant
...@@ -6484,7 +6492,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -6484,7 +6492,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
// will need some help. // will need some help.
Container parent = this.parent; Container parent = this.parent;
if (parent != null && parent.peer instanceof LightweightPeer) { if (parent != null && parent.peer instanceof LightweightPeer) {
nativeInLightFixer = new NativeInLightFixer(); relocateComponent();
} }
} }
invalidate(); invalidate();
...@@ -6595,10 +6603,6 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -6595,10 +6603,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
} }
} }
if (nativeInLightFixer != null) {
nativeInLightFixer.uninstall();
}
ComponentPeer p = peer; ComponentPeer p = peer;
if (p != null) { if (p != null) {
boolean isLightweight = isLightweight(); boolean isLightweight = isLightweight();
...@@ -7836,15 +7840,17 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7836,15 +7840,17 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @see #getPropertyChangeListeners * @see #getPropertyChangeListeners
* @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener) * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
*/ */
public synchronized void addPropertyChangeListener( public void addPropertyChangeListener(
PropertyChangeListener listener) { PropertyChangeListener listener) {
if (listener == null) { synchronized (getChangeSupportLock()) {
return; if (listener == null) {
} return;
if (changeSupport == null) { }
changeSupport = new PropertyChangeSupport(this); if (changeSupport == null) {
changeSupport = new PropertyChangeSupport(this);
}
changeSupport.addPropertyChangeListener(listener);
} }
changeSupport.addPropertyChangeListener(listener);
} }
/** /**
...@@ -7860,12 +7866,14 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7860,12 +7866,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @see #getPropertyChangeListeners * @see #getPropertyChangeListeners
* @see #removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener) * @see #removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
*/ */
public synchronized void removePropertyChangeListener( public void removePropertyChangeListener(
PropertyChangeListener listener) { PropertyChangeListener listener) {
if (listener == null || changeSupport == null) { synchronized (getChangeSupportLock()) {
return; if (listener == null || changeSupport == null) {
return;
}
changeSupport.removePropertyChangeListener(listener);
} }
changeSupport.removePropertyChangeListener(listener);
} }
/** /**
...@@ -7882,11 +7890,13 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7882,11 +7890,13 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @see java.beans.PropertyChangeSupport#getPropertyChangeListeners * @see java.beans.PropertyChangeSupport#getPropertyChangeListeners
* @since 1.4 * @since 1.4
*/ */
public synchronized PropertyChangeListener[] getPropertyChangeListeners() { public PropertyChangeListener[] getPropertyChangeListeners() {
if (changeSupport == null) { synchronized (getChangeSupportLock()) {
return new PropertyChangeListener[0]; if (changeSupport == null) {
return new PropertyChangeListener[0];
}
return changeSupport.getPropertyChangeListeners();
} }
return changeSupport.getPropertyChangeListeners();
} }
/** /**
...@@ -7920,16 +7930,18 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7920,16 +7930,18 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @see #getPropertyChangeListeners(java.lang.String) * @see #getPropertyChangeListeners(java.lang.String)
* @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener) * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
*/ */
public synchronized void addPropertyChangeListener( public void addPropertyChangeListener(
String propertyName, String propertyName,
PropertyChangeListener listener) { PropertyChangeListener listener) {
if (listener == null) { synchronized (getChangeSupportLock()) {
return; if (listener == null) {
} return;
if (changeSupport == null) { }
changeSupport = new PropertyChangeSupport(this); if (changeSupport == null) {
changeSupport = new PropertyChangeSupport(this);
}
changeSupport.addPropertyChangeListener(propertyName, listener);
} }
changeSupport.addPropertyChangeListener(propertyName, listener);
} }
/** /**
...@@ -7948,13 +7960,15 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7948,13 +7960,15 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @see #getPropertyChangeListeners(java.lang.String) * @see #getPropertyChangeListeners(java.lang.String)
* @see #removePropertyChangeListener(java.beans.PropertyChangeListener) * @see #removePropertyChangeListener(java.beans.PropertyChangeListener)
*/ */
public synchronized void removePropertyChangeListener( public void removePropertyChangeListener(
String propertyName, String propertyName,
PropertyChangeListener listener) { PropertyChangeListener listener) {
if (listener == null || changeSupport == null) { synchronized (getChangeSupportLock()) {
return; if (listener == null || changeSupport == null) {
return;
}
changeSupport.removePropertyChangeListener(propertyName, listener);
} }
changeSupport.removePropertyChangeListener(propertyName, listener);
} }
/** /**
...@@ -7971,12 +7985,14 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7971,12 +7985,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @see #getPropertyChangeListeners * @see #getPropertyChangeListeners
* @since 1.4 * @since 1.4
*/ */
public synchronized PropertyChangeListener[] getPropertyChangeListeners( public PropertyChangeListener[] getPropertyChangeListeners(
String propertyName) { String propertyName) {
if (changeSupport == null) { synchronized (getChangeSupportLock()) {
return new PropertyChangeListener[0]; if (changeSupport == null) {
return new PropertyChangeListener[0];
}
return changeSupport.getPropertyChangeListeners(propertyName);
} }
return changeSupport.getPropertyChangeListeners(propertyName);
} }
/** /**
...@@ -7991,7 +8007,10 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7991,7 +8007,10 @@ public abstract class Component implements ImageObserver, MenuContainer,
*/ */
protected void firePropertyChange(String propertyName, protected void firePropertyChange(String propertyName,
Object oldValue, Object newValue) { Object oldValue, Object newValue) {
PropertyChangeSupport changeSupport = this.changeSupport; PropertyChangeSupport changeSupport;
synchronized (getChangeSupportLock()) {
changeSupport = this.changeSupport;
}
if (changeSupport == null || if (changeSupport == null ||
(oldValue != null && newValue != null && oldValue.equals(newValue))) { (oldValue != null && newValue != null && oldValue.equals(newValue))) {
return; return;
...@@ -8491,8 +8510,6 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -8491,8 +8510,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
setComponentOrientation(orientation); setComponentOrientation(orientation);
} }
transient NativeInLightFixer nativeInLightFixer;
/** /**
* Checks that this component meets the prerequesites to be focus owner: * Checks that this component meets the prerequesites to be focus owner:
* - it is enabled, visible, focusable * - it is enabled, visible, focusable
...@@ -8518,188 +8535,25 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -8518,188 +8535,25 @@ public abstract class Component implements ImageObserver, MenuContainer,
} }
/** /**
* This odd class is to help out a native component that has been * Fix the location of the HW component in a LW container hierarchy.
* embedded in a lightweight component. Moving lightweight
* components around and changing their visibility is not seen
* by the native window system. This is a feature for lightweights,
* but a problem for native components that depend upon the
* lightweights. An instance of this class listens to the lightweight
* parents of an associated native component (the outer class).
*
* @author Timothy Prinzing
*/ */
final class NativeInLightFixer implements ComponentListener, ContainerListener { final void relocateComponent() {
synchronized (getTreeLock()) {
NativeInLightFixer() { if (peer == null) {
lightParents = new Vector(); return;
install(parent);
}
void install(Container parent) {
lightParents.clear();
Container p = parent;
boolean isLwParentsVisible = true;
// stash a reference to the components that are being observed so that
// we can reliably remove ourself as a listener later.
for (; p.peer instanceof LightweightPeer; p = p.parent) {
// register listeners and stash a reference
p.addComponentListener(this);
p.addContainerListener(this);
lightParents.addElement(p);
isLwParentsVisible &= p.isVisible();
}
// register with the native host (native parent of associated native)
// to get notified if the top-level lightweight is removed.
nativeHost = p;
p.addContainerListener(this);
// kick start the fixup. Since the event isn't looked at
// we can simulate movement notification.
componentMoved(null);
if (!isLwParentsVisible) {
synchronized (getTreeLock()) {
if (peer != null) {
peer.hide();
}
}
}
}
void uninstall() {
if (nativeHost != null) {
removeReferences();
}
}
// --- ComponentListener -------------------------------------------
/**
* Invoked when one of the lightweight parents has been resized.
* This doesn't change the position of the native child so it
* is ignored.
*/
public void componentResized(ComponentEvent e) {
}
/**
* Invoked when one of the lightweight parents has been moved.
* The native peer must be told of the new position which is
* relative to the native container that is hosting the
* lightweight components.
*/
public void componentMoved(ComponentEvent e) {
synchronized (getTreeLock()) {
int nativeX = x;
int nativeY = y;
for(Component c = parent; (c != null) &&
(c.peer instanceof LightweightPeer);
c = c.parent) {
nativeX += c.x;
nativeY += c.y;
}
if (peer != null) {
peer.setBounds(nativeX, nativeY, width, height,
ComponentPeer.SET_LOCATION);
}
}
}
/**
* Invoked when a lightweight parent component has been
* shown. The associated native component must also be
* shown if it hasn't had an overriding hide done on it.
*/
public void componentShown(ComponentEvent e) {
if (shouldShow()) {
synchronized (getTreeLock()) {
if (peer != null) {
peer.show();
}
}
} }
} int nativeX = x;
int nativeY = y;
/** for (Component cont = getContainer();
* Invoked when one of the lightweight parents become visible. cont != null && cont.isLightweight();
* Returns true if component and all its lightweight cont = cont.getContainer())
* parents are visible.
*/
private boolean shouldShow() {
boolean isLwParentsVisible = visible;
for (int i = lightParents.size() - 1;
i >= 0 && isLwParentsVisible;
i--)
{ {
isLwParentsVisible &= nativeX += cont.x;
((Container) lightParents.elementAt(i)).isVisible(); nativeY += cont.y;
}
return isLwParentsVisible;
}
/**
* Invoked when component has been hidden.
*/
public void componentHidden(ComponentEvent e) {
if (visible) {
synchronized (getTreeLock()) {
if (peer != null) {
peer.hide();
}
}
} }
peer.setBounds(nativeX, nativeY, width, height,
ComponentPeer.SET_LOCATION);
} }
// --- ContainerListener ------------------------------------
/**
* Invoked when a component has been added to a lightweight
* parent. This doesn't effect the native component.
*/
public void componentAdded(ContainerEvent e) {
}
/**
* Invoked when a lightweight parent has been removed.
* This means the services of this listener are no longer
* required and it should remove all references (ie
* registered listeners).
*/
public void componentRemoved(ContainerEvent e) {
Component c = e.getChild();
if (c == Component.this) {
removeReferences();
} else {
int n = lightParents.size();
for (int i = 0; i < n; i++) {
Container p = (Container) lightParents.elementAt(i);
if (p == c) {
removeReferences();
break;
}
}
}
}
/**
* Removes references to this object so it can be
* garbage collected.
*/
void removeReferences() {
int n = lightParents.size();
for (int i = 0; i < n; i++) {
Container c = (Container) lightParents.elementAt(i);
c.removeComponentListener(this);
c.removeContainerListener(this);
}
nativeHost.removeContainerListener(this);
lightParents.clear();
nativeHost = null;
}
Vector lightParents;
Container nativeHost;
} }
/** /**
...@@ -9452,6 +9306,19 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -9452,6 +9306,19 @@ public abstract class Component implements ImageObserver, MenuContainer,
// ************************** MIXING CODE ******************************* // ************************** MIXING CODE *******************************
/**
* Check whether we can trust the current bounds of the component.
* The return value of false indicates that the container of the
* component is invalid, and therefore needs to be layed out, which would
* probably mean changing the bounds of its children.
* Null-layout of the container or absence of the container mean
* the bounds of the component are final and can be trusted.
*/
private boolean areBoundsValid() {
Container cont = getContainer();
return cont == null || cont.isValid() || cont.getLayout() == null;
}
/** /**
* Applies the shape to the component * Applies the shape to the component
* @param shape Shape to be applied to the component * @param shape Shape to be applied to the component
...@@ -9475,7 +9342,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -9475,7 +9342,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
// to modify the object outside of the mixing code. // to modify the object outside of the mixing code.
this.compoundShape = shape; this.compoundShape = shape;
if (isValid()) { if (areBoundsValid()) {
Point compAbsolute = getLocationOnWindow(); Point compAbsolute = getLocationOnWindow();
if (mixingLog.isLoggable(Level.FINER)) { if (mixingLog.isLoggable(Level.FINER)) {
...@@ -9602,7 +9469,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -9602,7 +9469,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
void applyCurrentShape() { void applyCurrentShape() {
checkTreeLock(); checkTreeLock();
if (!isValid()) { if (!areBoundsValid()) {
return; // Because applyCompoundShape() ignores such components anyway return; // Because applyCompoundShape() ignores such components anyway
} }
if (mixingLog.isLoggable(Level.FINE)) { if (mixingLog.isLoggable(Level.FINE)) {
......
...@@ -832,16 +832,8 @@ public class Container extends Component { ...@@ -832,16 +832,8 @@ public class Container extends Component {
} }
if (!comp.isLightweight() && isLightweight()) { if (!comp.isLightweight() && isLightweight()) {
// If component is heavyweight and one of the containers is lightweight // If component is heavyweight and one of the containers is lightweight
// some NativeInLightFixer activity should be performed // the location of the component should be fixed.
if (!curParent.isLightweight()) { comp.relocateComponent();
// Moving from heavyweight container to lightweight container - should create NativeInLightFixer
// since addNotify does this
comp.nativeInLightFixer = new NativeInLightFixer();
} else {
// Component already has NativeInLightFixer - just reinstall it
// because hierarchy changed and he needs to rebuild list of parents to listen.
comp.nativeInLightFixer.install(this);
}
} }
} }
} }
...@@ -2267,53 +2259,56 @@ public class Container extends Component { ...@@ -2267,53 +2259,56 @@ public class Container extends Component {
EventTargetFilter filter, EventTargetFilter filter,
boolean searchHeavyweightChildren, boolean searchHeavyweightChildren,
boolean searchHeavyweightDescendants) { boolean searchHeavyweightDescendants) {
int ncomponents = this.ncomponents; synchronized (getTreeLock()) {
Component component[] = this.component; int ncomponents = this.ncomponents;
Component component[] = this.component;
for (int i = 0 ; i < ncomponents ; i++) { for (int i = 0 ; i < ncomponents ; i++) {
Component comp = component[i]; Component comp = component[i];
if (comp != null && comp.visible && if (comp != null && comp.visible &&
((!searchHeavyweightChildren && ((!searchHeavyweightChildren &&
comp.peer instanceof LightweightPeer) || comp.peer instanceof LightweightPeer) ||
(searchHeavyweightChildren && (searchHeavyweightChildren &&
!(comp.peer instanceof LightweightPeer))) && !(comp.peer instanceof LightweightPeer))) &&
comp.contains(x - comp.x, y - comp.y)) { comp.contains(x - comp.x, y - comp.y)) {
// found a component that intersects the point, see if there is // found a component that intersects the point, see if there
// a deeper possibility. // is a deeper possibility.
if (comp instanceof Container) { if (comp instanceof Container) {
Container child = (Container) comp; Container child = (Container) comp;
Component deeper = child.getMouseEventTarget(x - child.x, Component deeper = child.getMouseEventTarget(
y - child.y, x - child.x,
includeSelf, y - child.y,
filter, includeSelf,
searchHeavyweightDescendants); filter,
if (deeper != null) { searchHeavyweightDescendants);
return deeper; if (deeper != null) {
} return deeper;
} else { }
if (filter.accept(comp)) { } else {
// there isn't a deeper target, but this component is a if (filter.accept(comp)) {
// target // there isn't a deeper target, but this component
return comp; // is a target
return comp;
}
} }
} }
} }
}
boolean isPeerOK; boolean isPeerOK;
boolean isMouseOverMe; boolean isMouseOverMe;
isPeerOK = (peer instanceof LightweightPeer) || includeSelf; isPeerOK = (peer instanceof LightweightPeer) || includeSelf;
isMouseOverMe = contains(x,y); isMouseOverMe = contains(x,y);
// didn't find a child target, return this component if it's a possible // didn't find a child target, return this component if it's
// target // a possible target
if (isMouseOverMe && isPeerOK && filter.accept(this)) { if (isMouseOverMe && isPeerOK && filter.accept(this)) {
return this; return this;
}
// no possible target
return null;
} }
// no possible target
return null;
} }
static interface EventTargetFilter { static interface EventTargetFilter {
...@@ -3950,6 +3945,83 @@ public class Container extends Component { ...@@ -3950,6 +3945,83 @@ public class Container extends Component {
} }
} }
private void recursiveShowHeavyweightChildren() {
if (!hasHeavyweightDescendants() || !isVisible()) {
return;
}
for (int index = 0; index < getComponentCount(); index++) {
Component comp = getComponent(index);
if (comp.isLightweight()) {
if (comp instanceof Container) {
((Container)comp).recursiveShowHeavyweightChildren();
}
} else {
if (comp.isVisible()) {
ComponentPeer peer = comp.getPeer();
if (peer != null) {
peer.show();
}
}
}
}
}
private void recursiveHideHeavyweightChildren() {
if (!hasHeavyweightDescendants()) {
return;
}
for (int index = 0; index < getComponentCount(); index++) {
Component comp = getComponent(index);
if (comp.isLightweight()) {
if (comp instanceof Container) {
((Container)comp).recursiveHideHeavyweightChildren();
}
} else {
if (comp.isVisible()) {
ComponentPeer peer = comp.getPeer();
if (peer != null) {
peer.hide();
}
}
}
}
}
private void recursiveRelocateHeavyweightChildren(Point origin) {
for (int index = 0; index < getComponentCount(); index++) {
Component comp = getComponent(index);
if (comp.isLightweight()) {
if (comp instanceof Container &&
((Container)comp).hasHeavyweightDescendants())
{
final Point newOrigin = new Point(origin);
newOrigin.translate(comp.getX(), comp.getY());
((Container)comp).recursiveRelocateHeavyweightChildren(newOrigin);
}
} else {
ComponentPeer peer = comp.getPeer();
if (peer != null) {
peer.setBounds(origin.x + comp.getX(), origin.y + comp.getY(),
comp.getWidth(), comp.getHeight(),
ComponentPeer.SET_LOCATION);
}
}
}
}
/*
* Consider the heavyweight container hides or shows the HW descendants
* automatically. Therefore we care of LW containers' visibility only.
*/
private boolean isRecursivelyVisibleUpToHeavyweightContainer() {
if (!isLightweight()) {
return true;
}
return isVisible() && (getContainer() == null ||
getContainer().isRecursivelyVisibleUpToHeavyweightContainer());
}
@Override
void mixOnShowing() { void mixOnShowing() {
synchronized (getTreeLock()) { synchronized (getTreeLock()) {
if (mixingLog.isLoggable(Level.FINE)) { if (mixingLog.isLoggable(Level.FINE)) {
...@@ -3958,6 +4030,10 @@ public class Container extends Component { ...@@ -3958,6 +4030,10 @@ public class Container extends Component {
boolean isLightweight = isLightweight(); boolean isLightweight = isLightweight();
if (isLightweight && isRecursivelyVisibleUpToHeavyweightContainer()) {
recursiveShowHeavyweightChildren();
}
if (!isLightweight || (isLightweight && hasHeavyweightDescendants())) { if (!isLightweight || (isLightweight && hasHeavyweightDescendants())) {
recursiveApplyCurrentShape(); recursiveApplyCurrentShape();
} }
...@@ -3966,6 +4042,42 @@ public class Container extends Component { ...@@ -3966,6 +4042,42 @@ public class Container extends Component {
} }
} }
@Override
void mixOnHiding(boolean isLightweight) {
synchronized (getTreeLock()) {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this +
"; isLightweight=" + isLightweight);
}
if (isLightweight) {
recursiveHideHeavyweightChildren();
}
super.mixOnHiding(isLightweight);
}
}
@Override
void mixOnReshaping() {
synchronized (getTreeLock()) {
if (mixingLog.isLoggable(Level.FINE)) {
mixingLog.fine("this = " + this);
}
if (isLightweight() && hasHeavyweightDescendants()) {
final Point origin = new Point(getX(), getY());
for (Container cont = getContainer();
cont != null && cont.isLightweight();
cont = cont.getContainer())
{
origin.translate(cont.getX(), cont.getY());
}
recursiveRelocateHeavyweightChildren(origin);
}
super.mixOnReshaping();
}
}
@Override
void mixOnZOrderChanging(int oldZorder, int newZorder) { void mixOnZOrderChanging(int oldZorder, int newZorder) {
synchronized (getTreeLock()) { synchronized (getTreeLock()) {
if (mixingLog.isLoggable(Level.FINE)) { if (mixingLog.isLoggable(Level.FINE)) {
...@@ -4431,7 +4543,8 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener { ...@@ -4431,7 +4543,8 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
e.isPopupTrigger(), e.isPopupTrigger(),
((MouseWheelEvent)e).getScrollType(), ((MouseWheelEvent)e).getScrollType(),
((MouseWheelEvent)e).getScrollAmount(), ((MouseWheelEvent)e).getScrollAmount(),
((MouseWheelEvent)e).getWheelRotation()); ((MouseWheelEvent)e).getWheelRotation(),
((MouseWheelEvent)e).getPreciseWheelRotation());
} }
else { else {
retargeted = new MouseEvent(target, retargeted = new MouseEvent(target,
......
...@@ -154,7 +154,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager { ...@@ -154,7 +154,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent, private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
boolean clearOnFailure) boolean clearOnFailure)
{ {
if (toFocus.isShowing() && toFocus.isFocusable() && if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.isFocusable() &&
toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK)) { toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK)) {
return true; return true;
} else { } else {
......
/* /*
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
*/ */
package java.awt; package java.awt;
import java.applet.Applet;
import java.awt.event.*; import java.awt.event.*;
import java.awt.im.InputContext; import java.awt.im.InputContext;
import java.awt.image.BufferStrategy; import java.awt.image.BufferStrategy;
...@@ -355,18 +354,21 @@ public class Window extends Container implements Accessible { ...@@ -355,18 +354,21 @@ public class Window extends Container implements Accessible {
static class WindowDisposerRecord implements sun.java2d.DisposerRecord { static class WindowDisposerRecord implements sun.java2d.DisposerRecord {
final WeakReference<Window> owner; final WeakReference<Window> owner;
final WeakReference weakThis; final WeakReference weakThis;
final AppContext context; final WeakReference<AppContext> context;
WindowDisposerRecord(AppContext context, Window victim) { WindowDisposerRecord(AppContext context, Window victim) {
owner = new WeakReference<Window>(victim.getOwner()); owner = new WeakReference<Window>(victim.getOwner());
weakThis = victim.weakThis; weakThis = victim.weakThis;
this.context = context; this.context = new WeakReference<AppContext>(context);
} }
public void dispose() { public void dispose() {
Window parent = owner.get(); Window parent = owner.get();
if (parent != null) { if (parent != null) {
parent.removeOwnedWindow(weakThis); parent.removeOwnedWindow(weakThis);
} }
Window.removeFromWindowList(context, weakThis); AppContext ac = context.get();
if (null != ac) {
Window.removeFromWindowList(ac, weakThis);
}
} }
} }
...@@ -824,7 +826,10 @@ public class Window extends Container implements Accessible { ...@@ -824,7 +826,10 @@ public class Window extends Container implements Accessible {
static private final AtomicBoolean static private final AtomicBoolean
beforeFirstWindowShown = new AtomicBoolean(true); beforeFirstWindowShown = new AtomicBoolean(true);
static final void closeSplashScreen() { final void closeSplashScreen() {
if (isTrayIconWindow) {
return;
}
if (beforeFirstWindowShown.getAndSet(false)) { if (beforeFirstWindowShown.getAndSet(false)) {
SunToolkit.closeSplashScreen(); SunToolkit.closeSplashScreen();
} }
......
/* /*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -49,7 +49,6 @@ import java.util.WeakHashMap; ...@@ -49,7 +49,6 @@ import java.util.WeakHashMap;
import sun.awt.datatransfer.DataTransferer; import sun.awt.datatransfer.DataTransferer;
/** /**
* The SystemFlavorMap is a configurable map between "natives" (Strings), which * The SystemFlavorMap is a configurable map between "natives" (Strings), which
* correspond to platform-specific data formats, and "flavors" (DataFlavors), * correspond to platform-specific data formats, and "flavors" (DataFlavors),
...@@ -117,15 +116,50 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -117,15 +116,50 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
/** /**
* Maps native Strings to Lists of DataFlavors (or base type Strings for * Maps native Strings to Lists of DataFlavors (or base type Strings for
* text DataFlavors). * text DataFlavors).
* Do not use the field directly, use getNativeToFlavor() instead.
*/ */
private Map nativeToFlavor = new HashMap(); private Map nativeToFlavor = new HashMap();
/**
* Accessor to nativeToFlavor map. Since we use lazy initialization we must
* use this accessor instead of direct access to the field which may not be
* initialized yet. This method will initialize the field if needed.
*
* @return nativeToFlavor
*/
private Map getNativeToFlavor() {
if (!isMapInitialized) {
initSystemFlavorMap();
}
return nativeToFlavor;
}
/** /**
* Maps DataFlavors (or base type Strings for text DataFlavors) to Lists of * Maps DataFlavors (or base type Strings for text DataFlavors) to Lists of
* native Strings. * native Strings.
* Do not use the field directly, use getFlavorToNative() instead.
*/ */
private Map flavorToNative = new HashMap(); private Map flavorToNative = new HashMap();
/**
* Accessor to flavorToNative map. Since we use lazy initialization we must
* use this accessor instead of direct access to the field which may not be
* initialized yet. This method will initialize the field if needed.
*
* @return flavorToNative
*/
private synchronized Map getFlavorToNative() {
if (!isMapInitialized) {
initSystemFlavorMap();
}
return flavorToNative;
}
/**
* Shows if the object has been initialized.
*/
private boolean isMapInitialized = false;
/** /**
* Caches the result of getNativesForFlavor(). Maps DataFlavors to * Caches the result of getNativesForFlavor(). Maps DataFlavors to
* SoftReferences which reference Lists of String natives. * SoftReferences which reference Lists of String natives.
...@@ -169,15 +203,24 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -169,15 +203,24 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
return fm; return fm;
} }
private SystemFlavorMap() {
}
/** /**
* Constructs a SystemFlavorMap by reading flavormap.properties and * Initializes a SystemFlavorMap by reading flavormap.properties and
* AWT.DnD.flavorMapFileURL. * AWT.DnD.flavorMapFileURL.
* For thread-safety must be called under lock on this.
*/ */
private SystemFlavorMap() { private void initSystemFlavorMap() {
BufferedReader flavormapDotProperties = (BufferedReader) if (isMapInitialized) {
return;
}
isMapInitialized = true;
BufferedReader flavormapDotProperties =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<BufferedReader>() {
public Object run() { public BufferedReader run() {
String fileName = String fileName =
System.getProperty("java.home") + System.getProperty("java.home") +
File.separator + File.separator +
...@@ -197,12 +240,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -197,12 +240,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
}); });
BufferedReader flavormapURL = (BufferedReader) BufferedReader flavormapURL =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<BufferedReader>() {
public Object run() { public BufferedReader run() {
String url = Toolkit.getDefaultToolkit().getProperty String url = Toolkit.getProperty("AWT.DnD.flavorMapFileURL", null);
("AWT.DnD.flavorMapFileURL", null);
if (url == null) { if (url == null) {
return null; return null;
...@@ -237,7 +279,6 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -237,7 +279,6 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
} }
} }
/** /**
* Copied code from java.util.Properties. Parsing the data ourselves is the * Copied code from java.util.Properties. Parsing the data ourselves is the
* only way to handle duplicate keys and values. * only way to handle duplicate keys and values.
...@@ -388,11 +429,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -388,11 +429,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
// For text/* flavors, store mappings in separate maps to // For text/* flavors, store mappings in separate maps to
// enable dynamic mapping generation at a run-time. // enable dynamic mapping generation at a run-time.
if ("text".equals(flavor.getPrimaryType())) { if ("text".equals(flavor.getPrimaryType())) {
store(value, key, flavorToNative); store(value, key, getFlavorToNative());
store(key, value, nativeToFlavor); store(key, value, getNativeToFlavor());
} else { } else {
store(flavor, key, flavorToNative); store(flavor, key, getFlavorToNative());
store(key, flavor, nativeToFlavor); store(key, flavor, getNativeToFlavor());
} }
} }
} }
...@@ -494,7 +535,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -494,7 +535,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* only if the specified native is encoded as a Java MIME type. * only if the specified native is encoded as a Java MIME type.
*/ */
private List nativeToFlavorLookup(String nat) { private List nativeToFlavorLookup(String nat) {
List flavors = (List)nativeToFlavor.get(nat); List flavors = (List)getNativeToFlavor().get(nat);
if (nat != null && !disabledMappingGenerationKeys.contains(nat)) { if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
DataTransferer transferer = DataTransferer.getInstance(); DataTransferer transferer = DataTransferer.getInstance();
...@@ -530,15 +571,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -530,15 +571,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
if (flavor != null) { if (flavor != null) {
flavors = new ArrayList(1); flavors = new ArrayList(1);
nativeToFlavor.put(nat, flavors); getNativeToFlavor().put(nat, flavors);
flavors.add(flavor); flavors.add(flavor);
getFlavorsForNativeCache.remove(nat); getFlavorsForNativeCache.remove(nat);
getFlavorsForNativeCache.remove(null); getFlavorsForNativeCache.remove(null);
List natives = (List)flavorToNative.get(flavor); List natives = (List)getFlavorToNative().get(flavor);
if (natives == null) { if (natives == null) {
natives = new ArrayList(1); natives = new ArrayList(1);
flavorToNative.put(flavor, natives); getFlavorToNative().put(flavor, natives);
} }
natives.add(nat); natives.add(nat);
getNativesForFlavorCache.remove(flavor); getNativesForFlavorCache.remove(flavor);
...@@ -559,7 +600,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -559,7 +600,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*/ */
private List flavorToNativeLookup(final DataFlavor flav, private List flavorToNativeLookup(final DataFlavor flav,
final boolean synthesize) { final boolean synthesize) {
List natives = (List)flavorToNative.get(flav); List natives = (List)getFlavorToNative().get(flav);
if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
DataTransferer transferer = DataTransferer.getInstance(); DataTransferer transferer = DataTransferer.getInstance();
...@@ -584,15 +625,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -584,15 +625,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
if (synthesize) { if (synthesize) {
String encoded = encodeDataFlavor(flav); String encoded = encodeDataFlavor(flav);
natives = new ArrayList(1); natives = new ArrayList(1);
flavorToNative.put(flav, natives); getFlavorToNative().put(flav, natives);
natives.add(encoded); natives.add(encoded);
getNativesForFlavorCache.remove(flav); getNativesForFlavorCache.remove(flav);
getNativesForFlavorCache.remove(null); getNativesForFlavorCache.remove(null);
List flavors = (List)nativeToFlavor.get(encoded); List flavors = (List)getNativeToFlavor().get(encoded);
if (flavors == null) { if (flavors == null) {
flavors = new ArrayList(1); flavors = new ArrayList(1);
nativeToFlavor.put(encoded, flavors); getNativeToFlavor().put(encoded, flavors);
} }
flavors.add(flav); flavors.add(flav);
getFlavorsForNativeCache.remove(encoded); getFlavorsForNativeCache.remove(encoded);
...@@ -645,7 +686,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -645,7 +686,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
if (flav == null) { if (flav == null) {
retval = new ArrayList(nativeToFlavor.keySet()); retval = new ArrayList(getNativeToFlavor().keySet());
} else if (disabledMappingGenerationKeys.contains(flav)) { } else if (disabledMappingGenerationKeys.contains(flav)) {
// In this case we shouldn't synthesize a native for this flavor, // In this case we shouldn't synthesize a native for this flavor,
// since its mappings were explicitly specified. // since its mappings were explicitly specified.
...@@ -655,7 +696,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -655,7 +696,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
// For text/* flavors, flavor-to-native mappings specified in // For text/* flavors, flavor-to-native mappings specified in
// flavormap.properties are stored per flavor's base type. // flavormap.properties are stored per flavor's base type.
if ("text".equals(flav.getPrimaryType())) { if ("text".equals(flav.getPrimaryType())) {
retval = (List)flavorToNative.get(flav.mimeType.getBaseType()); retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType());
if (retval != null) { if (retval != null) {
// To prevent the List stored in the map from modification. // To prevent the List stored in the map from modification.
retval = new ArrayList(retval); retval = new ArrayList(retval);
...@@ -663,7 +704,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -663,7 +704,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
// Also include text/plain natives, but don't duplicate Strings // Also include text/plain natives, but don't duplicate Strings
List textPlainList = (List)flavorToNative.get(TEXT_PLAIN_BASE_TYPE); List textPlainList = (List)getFlavorToNative().get(TEXT_PLAIN_BASE_TYPE);
if (textPlainList != null && !textPlainList.isEmpty()) { if (textPlainList != null && !textPlainList.isEmpty()) {
// To prevent the List stored in the map from modification. // To prevent the List stored in the map from modification.
...@@ -699,7 +740,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -699,7 +740,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
} }
} else if (DataTransferer.isFlavorNoncharsetTextType(flav)) { } else if (DataTransferer.isFlavorNoncharsetTextType(flav)) {
retval = (List)flavorToNative.get(flav.mimeType.getBaseType()); retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType());
if (retval == null || retval.isEmpty()) { if (retval == null || retval.isEmpty()) {
retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
...@@ -1025,10 +1066,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1025,10 +1066,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
throw new NullPointerException("null arguments not permitted"); throw new NullPointerException("null arguments not permitted");
} }
List natives = (List)flavorToNative.get(flav); List natives = (List)getFlavorToNative().get(flav);
if (natives == null) { if (natives == null) {
natives = new ArrayList(1); natives = new ArrayList(1);
flavorToNative.put(flav, natives); getFlavorToNative().put(flav, natives);
} else if (natives.contains(nat)) { } else if (natives.contains(nat)) {
return; return;
} }
...@@ -1071,7 +1112,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1071,7 +1112,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
throw new NullPointerException("null arguments not permitted"); throw new NullPointerException("null arguments not permitted");
} }
flavorToNative.remove(flav); getFlavorToNative().remove(flav);
for (int i = 0; i < natives.length; i++) { for (int i = 0; i < natives.length; i++) {
addUnencodedNativeForFlavor(flav, natives[i]); addUnencodedNativeForFlavor(flav, natives[i]);
} }
...@@ -1105,10 +1146,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1105,10 +1146,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
throw new NullPointerException("null arguments not permitted"); throw new NullPointerException("null arguments not permitted");
} }
List flavors = (List)nativeToFlavor.get(nat); List flavors = (List)getNativeToFlavor().get(nat);
if (flavors == null) { if (flavors == null) {
flavors = new ArrayList(1); flavors = new ArrayList(1);
nativeToFlavor.put(nat, flavors); getNativeToFlavor().put(nat, flavors);
} else if (flavors.contains(flav)) { } else if (flavors.contains(flav)) {
return; return;
} }
...@@ -1150,7 +1191,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1150,7 +1191,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
throw new NullPointerException("null arguments not permitted"); throw new NullPointerException("null arguments not permitted");
} }
nativeToFlavor.remove(nat); getNativeToFlavor().remove(nat);
for (int i = 0; i < flavors.length; i++) { for (int i = 0; i < flavors.length; i++) {
addFlavorForUnencodedNative(nat, flavors[i]); addFlavorForUnencodedNative(nat, flavors[i]);
} }
......
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -110,7 +110,11 @@ public class DropTarget implements DropTargetListener, Serializable { ...@@ -110,7 +110,11 @@ public class DropTarget implements DropTargetListener, Serializable {
setActive(act); setActive(act);
} }
if (fm != null) flavorMap = fm; if (fm != null) {
flavorMap = fm;
} else {
flavorMap = SystemFlavorMap.getDefaultFlavorMap();
}
} }
/** /**
...@@ -850,5 +854,5 @@ public class DropTarget implements DropTargetListener, Serializable { ...@@ -850,5 +854,5 @@ public class DropTarget implements DropTargetListener, Serializable {
* The FlavorMap * The FlavorMap
*/ */
private transient FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap(); private transient FlavorMap flavorMap;
} }
/* /*
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -74,6 +74,19 @@ import java.awt.Component; ...@@ -74,6 +74,19 @@ import java.awt.Component;
* methods for conforming to the underlying platform settings. These * methods for conforming to the underlying platform settings. These
* platform settings can be changed at any time by the user. MouseWheelEvents * platform settings can be changed at any time by the user. MouseWheelEvents
* reflect the most recent settings. * reflect the most recent settings.
* <P>
* The <code>MouseWheelEvent</code> class includes methods for
* getting the number of "clicks" by which the mouse wheel is rotated.
* The {@link #getWheelRotation} method returns the integer number
* of "clicks" corresponding to the number of notches by which the wheel was
* rotated. In addition to this method, the <code>MouseWheelEvent</code>
* class provides the {@link #getPreciseWheelRotation} method which returns
* a double number of "clicks" in case a partial rotation occurred.
* The {@link #getPreciseWheelRotation} method is useful if a mouse supports
* a high-resolution wheel, such as a freely rotating wheel with no
* notches. Applications can benefit by using this method to process
* mouse wheel events more precisely, and thus, making visual perception
* smoother.
* *
* @author Brent Christian * @author Brent Christian
* @see MouseWheelListener * @see MouseWheelListener
...@@ -131,6 +144,13 @@ public class MouseWheelEvent extends MouseEvent { ...@@ -131,6 +144,13 @@ public class MouseWheelEvent extends MouseEvent {
*/ */
int wheelRotation; int wheelRotation;
/**
* Indicates how far the mouse wheel was rotated.
*
* @see #getPreciseWheelRotation
*/
double preciseWheelRotation;
/* /*
* serialVersionUID * serialVersionUID
*/ */
...@@ -165,8 +185,8 @@ public class MouseWheelEvent extends MouseEvent { ...@@ -165,8 +185,8 @@ public class MouseWheelEvent extends MouseEvent {
* <code>WHEEL_BLOCK_SCROLL</code> * <code>WHEEL_BLOCK_SCROLL</code>
* @param scrollAmount for scrollType <code>WHEEL_UNIT_SCROLL</code>, * @param scrollAmount for scrollType <code>WHEEL_UNIT_SCROLL</code>,
* the number of units to be scrolled * the number of units to be scrolled
* @param wheelRotation the amount that the mouse wheel was rotated (the * @param wheelRotation the integer number of "clicks" by which the mouse
* number of "clicks") * wheel was rotated
* *
* @throws IllegalArgumentException if <code>source</code> is null * @throws IllegalArgumentException if <code>source</code> is null
* @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean) * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean)
...@@ -211,8 +231,8 @@ public class MouseWheelEvent extends MouseEvent { ...@@ -211,8 +231,8 @@ public class MouseWheelEvent extends MouseEvent {
* <code>WHEEL_BLOCK_SCROLL</code> * <code>WHEEL_BLOCK_SCROLL</code>
* @param scrollAmount for scrollType <code>WHEEL_UNIT_SCROLL</code>, * @param scrollAmount for scrollType <code>WHEEL_UNIT_SCROLL</code>,
* the number of units to be scrolled * the number of units to be scrolled
* @param wheelRotation the amount that the mouse wheel was rotated (the * @param wheelRotation the integer number of "clicks" by which the mouse
* number of "clicks") * wheel was rotated
* *
* @throws IllegalArgumentException if <code>source</code> is null * @throws IllegalArgumentException if <code>source</code> is null
* @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean) * @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean)
...@@ -223,12 +243,68 @@ public class MouseWheelEvent extends MouseEvent { ...@@ -223,12 +243,68 @@ public class MouseWheelEvent extends MouseEvent {
int x, int y, int xAbs, int yAbs, int clickCount, boolean popupTrigger, int x, int y, int xAbs, int yAbs, int clickCount, boolean popupTrigger,
int scrollType, int scrollAmount, int wheelRotation) { int scrollType, int scrollAmount, int wheelRotation) {
this(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount, popupTrigger,
scrollType, scrollAmount, wheelRotation, wheelRotation);
}
/**
* Constructs a <code>MouseWheelEvent</code> object with the specified
* source component, type, modifiers, coordinates, absolute coordinates,
* scroll type, scroll amount, and wheel rotation.
* <p>Note that passing in an invalid <code>id</code> parameter results
* in unspecified behavior. This method throws an
* <code>IllegalArgumentException</code> if <code>source</code> equals
* <code>null</code>.
* <p>Even if inconsistent values for relative and absolute coordinates
* are passed to the constructor, a <code>MouseWheelEvent</code> instance
* is still created and no exception is thrown.
*
* @param source the <code>Component</code> that originated the event
* @param id the integer value that identifies the event
* @param when a long value that gives the time when the event occurred
* @param modifiers the modifier keys down during event
* (shift, ctrl, alt, meta)
* @param x the horizontal <code>x</code> coordinate for the
* mouse location
* @param y the vertical <code>y</code> coordinate for the
* mouse location
* @param xAbs the absolute horizontal <code>x</code> coordinate for
* the mouse location
* @param yAbs the absolute vertical <code>y</code> coordinate for
* the mouse location
* @param clickCount the number of mouse clicks associated with the event
* @param popupTrigger a boolean value, <code>true</code> if this event is a trigger
* for a popup-menu
* @param scrollType the type of scrolling which should take place in
* response to this event; valid values are
* <code>WHEEL_UNIT_SCROLL</code> and
* <code>WHEEL_BLOCK_SCROLL</code>
* @param scrollAmount for scrollType <code>WHEEL_UNIT_SCROLL</code>,
* the number of units to be scrolled
* @param wheelRotation the integer number of "clicks" by which the mouse wheel
* was rotated
* @param preciseWheelRotation the double number of "clicks" by which the mouse wheel
* was rotated
*
* @throws IllegalArgumentException if <code>source</code> is null
* @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, boolean)
* @see MouseEvent#MouseEvent(java.awt.Component, int, long, int, int, int, int, int, int, boolean, int)
* @since 1.7
*/
public MouseWheelEvent (Component source, int id, long when, int modifiers,
int x, int y, int xAbs, int yAbs, int clickCount, boolean popupTrigger,
int scrollType, int scrollAmount, int wheelRotation, double preciseWheelRotation) {
super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount, super(source, id, when, modifiers, x, y, xAbs, yAbs, clickCount,
popupTrigger, MouseEvent.NOBUTTON); popupTrigger, MouseEvent.NOBUTTON);
this.scrollType = scrollType; this.scrollType = scrollType;
this.scrollAmount = scrollAmount; this.scrollAmount = scrollAmount;
this.wheelRotation = wheelRotation; this.wheelRotation = wheelRotation;
this.preciseWheelRotation = preciseWheelRotation;
} }
/** /**
...@@ -267,16 +343,34 @@ public class MouseWheelEvent extends MouseEvent { ...@@ -267,16 +343,34 @@ public class MouseWheelEvent extends MouseEvent {
} }
/** /**
* Returns the number of "clicks" the mouse wheel was rotated. * Returns the number of "clicks" the mouse wheel was rotated, as an integer.
* A partial rotation may occur if the mouse supports a high-resolution wheel.
* In this case, the method returns zero until a full "click" has been accumulated.
* *
* @return negative values if the mouse wheel was rotated up/away from * @return negative values if the mouse wheel was rotated up/away from
* the user, and positive values if the mouse wheel was rotated down/ * the user, and positive values if the mouse wheel was rotated down/
* towards the user * towards the user
* @see #getPreciseWheelRotation
*/ */
public int getWheelRotation() { public int getWheelRotation() {
return wheelRotation; return wheelRotation;
} }
/**
* Returns the number of "clicks" the mouse wheel was rotated, as a double.
* A partial rotation may occur if the mouse supports a high-resolution wheel.
* In this case, the return value will include a fractional "click".
*
* @return negative values if the mouse wheel was rotated up or away from
* the user, and positive values if the mouse wheel was rotated down or
* towards the user
* @see #getWheelRotation
* @since 1.7
*/
public double getPreciseWheelRotation() {
return preciseWheelRotation;
}
/** /**
* This is a convenience method to aid in the implementation of * This is a convenience method to aid in the implementation of
* the common-case MouseWheelListener - to scroll a ScrollPane or * the common-case MouseWheelListener - to scroll a ScrollPane or
...@@ -348,6 +442,6 @@ public class MouseWheelEvent extends MouseEvent { ...@@ -348,6 +442,6 @@ public class MouseWheelEvent extends MouseEvent {
} }
return super.paramString()+",scrollType="+scrollTypeStr+ return super.paramString()+",scrollType="+scrollTypeStr+
",scrollAmount="+getScrollAmount()+",wheelRotation="+ ",scrollAmount="+getScrollAmount()+",wheelRotation="+
getWheelRotation(); getWheelRotation()+",preciseWheelRotation="+getPreciseWheelRotation();
} }
} }
...@@ -1553,7 +1553,7 @@ class MetaData { ...@@ -1553,7 +1553,7 @@ class MetaData {
private static String[] getConstructorProperties(Class type) { private static String[] getConstructorProperties(Class type) {
String[] names = null; String[] names = null;
int length = 0; int length = 0;
for (Constructor constructor : type.getConstructors()) { for (Constructor<?> constructor : type.getConstructors()) {
String[] value = getAnnotationValue(constructor); String[] value = getAnnotationValue(constructor);
if ((value != null) && (length < value.length) && isValid(constructor, value)) { if ((value != null) && (length < value.length) && isValid(constructor, value)) {
names = value; names = value;
...@@ -1563,14 +1563,14 @@ class MetaData { ...@@ -1563,14 +1563,14 @@ class MetaData {
return names; return names;
} }
private static String[] getAnnotationValue(Constructor constructor) { private static String[] getAnnotationValue(Constructor<?> constructor) {
ConstructorProperties annotation = constructor.getAnnotation(ConstructorProperties.class); ConstructorProperties annotation = constructor.getAnnotation(ConstructorProperties.class);
return (annotation != null) return (annotation != null)
? annotation.value() ? annotation.value()
: null; : null;
} }
private static boolean isValid(Constructor constructor, String[] names) { private static boolean isValid(Constructor<?> constructor, String[] names) {
Class[] parameters = constructor.getParameterTypes(); Class[] parameters = constructor.getParameterTypes();
if (names.length != parameters.length) { if (names.length != parameters.length) {
return false; return false;
......
...@@ -636,7 +636,11 @@ public interface Instrumentation { ...@@ -636,7 +636,11 @@ public interface Instrumentation {
* @param transformer * @param transformer
* The ClassFileTransformer which wraps using this prefix. * The ClassFileTransformer which wraps using this prefix.
* @param prefix * @param prefix
* The prefix which has been applied to wrapped native methods. * The prefix to apply to wrapped native methods when
* retrying a failed native method resolution. If prefix
* is either <code>null</code> or the empty string, then
* failed native method resolutions are not retried for
* this transformer.
* @throws java.lang.NullPointerException if passed a <code>null</code> transformer. * @throws java.lang.NullPointerException if passed a <code>null</code> transformer.
* @throws java.lang.UnsupportedOperationException if the current configuration of * @throws java.lang.UnsupportedOperationException if the current configuration of
* the JVM does not allow setting a native method prefix * the JVM does not allow setting a native method prefix
......
/* /*
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -253,7 +253,8 @@ class Socket implements java.io.Closeable { ...@@ -253,7 +253,8 @@ class Socket implements java.io.Closeable {
* *
* @param host the name of the remote host, or <code>null</code> for the loopback address. * @param host the name of the remote host, or <code>null</code> for the loopback address.
* @param port the remote port * @param port the remote port
* @param localAddr the local address the socket is bound to * @param localAddr the local address the socket is bound to, or
* <code>null</code> for the <code>anyLocal</code> address.
* @param localPort the local port the socket is bound to, or * @param localPort the local port the socket is bound to, or
* <code>zero</code> for a system selected free port. * <code>zero</code> for a system selected free port.
* @exception IOException if an I/O error occurs when creating the socket. * @exception IOException if an I/O error occurs when creating the socket.
......
...@@ -50,7 +50,7 @@ import javax.management.loading.ClassLoaderRepository; ...@@ -50,7 +50,7 @@ import javax.management.loading.ClassLoaderRepository;
* server. A Java object cannot be registered in the MBean server * server. A Java object cannot be registered in the MBean server
* unless it is a JMX compliant MBean.</p> * unless it is a JMX compliant MBean.</p>
* *
* <p>When an MBean is registered or unregistered in the MBean server * <p id="notif">When an MBean is registered or unregistered in the MBean server
* a {@link javax.management.MBeanServerNotification * a {@link javax.management.MBeanServerNotification
* MBeanServerNotification} Notification is emitted. To register an * MBeanServerNotification} Notification is emitted. To register an
* object as listener to MBeanServerNotifications you should call the * object as listener to MBeanServerNotifications you should call the
...@@ -258,27 +258,43 @@ import javax.management.loading.ClassLoaderRepository; ...@@ -258,27 +258,43 @@ import javax.management.loading.ClassLoaderRepository;
*/ */
public interface MBeanServer extends MBeanServerConnection { public interface MBeanServer extends MBeanServerConnection {
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
* <p>If this method successfully creates an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public ObjectInstance createMBean(String className, ObjectName name) public ObjectInstance createMBean(String className, ObjectName name)
throws ReflectionException, InstanceAlreadyExistsException, throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException, MBeanRegistrationException, MBeanException,
NotCompliantMBeanException; NotCompliantMBeanException;
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
* <p>If this method successfully creates an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public ObjectInstance createMBean(String className, ObjectName name, public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName) ObjectName loaderName)
throws ReflectionException, InstanceAlreadyExistsException, throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException, MBeanRegistrationException, MBeanException,
NotCompliantMBeanException, InstanceNotFoundException; NotCompliantMBeanException, InstanceNotFoundException;
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
* <p>If this method successfully creates an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public ObjectInstance createMBean(String className, ObjectName name, public ObjectInstance createMBean(String className, ObjectName name,
Object params[], String signature[]) Object params[], String signature[])
throws ReflectionException, InstanceAlreadyExistsException, throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException, MBeanRegistrationException, MBeanException,
NotCompliantMBeanException; NotCompliantMBeanException;
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
* <p>If this method successfully creates an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public ObjectInstance createMBean(String className, ObjectName name, public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName, Object params[], ObjectName loaderName, Object params[],
String signature[]) String signature[])
...@@ -287,12 +303,15 @@ public interface MBeanServer extends MBeanServerConnection { ...@@ -287,12 +303,15 @@ public interface MBeanServer extends MBeanServerConnection {
NotCompliantMBeanException, InstanceNotFoundException; NotCompliantMBeanException, InstanceNotFoundException;
/** /**
* Registers a pre-existing object as an MBean with the MBean * <p>Registers a pre-existing object as an MBean with the MBean
* server. If the object name given is null, the MBean must * server. If the object name given is null, the MBean must
* provide its own name by implementing the {@link * provide its own name by implementing the {@link
* javax.management.MBeanRegistration MBeanRegistration} interface * javax.management.MBeanRegistration MBeanRegistration} interface
* and returning the name from the {@link * and returning the name from the {@link
* MBeanRegistration#preRegister preRegister} method. * MBeanRegistration#preRegister preRegister} method.</p>
*
* <p>If this method successfully registers an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
* *
* @param object The MBean to be registered as an MBean. * @param object The MBean to be registered as an MBean.
* @param name The object name of the MBean. May be null. * @param name The object name of the MBean. May be null.
...@@ -319,7 +338,12 @@ public interface MBeanServer extends MBeanServerConnection { ...@@ -319,7 +338,12 @@ public interface MBeanServer extends MBeanServerConnection {
throws InstanceAlreadyExistsException, MBeanRegistrationException, throws InstanceAlreadyExistsException, MBeanRegistrationException,
NotCompliantMBeanException; NotCompliantMBeanException;
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
*
* <p>If this method successfully unregisters an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public void unregisterMBean(ObjectName name) public void unregisterMBean(ObjectName name)
throws InstanceNotFoundException, MBeanRegistrationException; throws InstanceNotFoundException, MBeanRegistrationException;
......
...@@ -48,6 +48,7 @@ import java.util.logging.Level; ...@@ -48,6 +48,7 @@ import java.util.logging.Level;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Vector;
import javax.management.Attribute; import javax.management.Attribute;
import javax.management.AttributeChangeNotification; import javax.management.AttributeChangeNotification;
import javax.management.AttributeChangeNotificationFilter; import javax.management.AttributeChangeNotificationFilter;
...@@ -132,8 +133,6 @@ public class RequiredModelMBean ...@@ -132,8 +133,6 @@ public class RequiredModelMBean
* and operations will be executed */ * and operations will be executed */
private Object managedResource = null; private Object managedResource = null;
private static final String currClass = "RequiredModelMBean";
/* records the registering in MBeanServer */ /* records the registering in MBeanServer */
private boolean registered = false; private boolean registered = false;
private transient MBeanServer server = null; private transient MBeanServer server = null;
...@@ -2488,10 +2487,13 @@ public class RequiredModelMBean ...@@ -2488,10 +2487,13 @@ public class RequiredModelMBean
} }
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
Vector<String> enabledAttrs = currFilter.getEnabledAttributes();
String s = (enabledAttrs.size() > 1) ?
"[" + enabledAttrs.firstElement() + ", ...]" :
enabledAttrs.toString();
MODELMBEAN_LOGGER.logp(Level.FINER, MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(), mth, RequiredModelMBean.class.getName(), mth,
"Set attribute change filter to " + "Set attribute change filter to " + s);
currFilter.getEnabledAttributes().firstElement());
} }
attributeBroadcaster.addNotificationListener(inlistener,currFilter, attributeBroadcaster.addNotificationListener(inlistener,currFilter,
......
/* /*
* Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -134,6 +134,7 @@ public class SSLContext { ...@@ -134,6 +134,7 @@ public class SSLContext {
* @exception NoSuchAlgorithmException if no Provider supports a * @exception NoSuchAlgorithmException if no Provider supports a
* TrustManagerFactorySpi implementation for the * TrustManagerFactorySpi implementation for the
* specified protocol. * specified protocol.
* @exception NullPointerException if protocol is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -175,6 +176,7 @@ public class SSLContext { ...@@ -175,6 +176,7 @@ public class SSLContext {
* registered in the security provider list. * registered in the security provider list.
* *
* @throws IllegalArgumentException if the provider name is null or empty. * @throws IllegalArgumentException if the provider name is null or empty.
* @throws NullPointerException if protocol is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -210,6 +212,7 @@ public class SSLContext { ...@@ -210,6 +212,7 @@ public class SSLContext {
* from the specified Provider object. * from the specified Provider object.
* *
* @throws IllegalArgumentException if the provider name is null. * @throws IllegalArgumentException if the provider name is null.
* @throws NullPointerException if protocol is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
......
/* /*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -212,8 +212,10 @@ public abstract class SSLSocket extends Socket ...@@ -212,8 +212,10 @@ public abstract class SSLSocket extends Socket
* @param host name of the host with which to connect, or * @param host name of the host with which to connect, or
* <code>null</code> for the loopback address. * <code>null</code> for the loopback address.
* @param port number of the server's port * @param port number of the server's port
* @param clientAddress the client's host * @param clientAddress the client's address the socket is bound to, or
* @param clientPort number of the client's port * <code>null</code> for the <code>anyLocal</code> address.
* @param clientPort the client's port the socket is bound to, or
* <code>zero</code> for a system selected free port.
* @throws IOException if an I/O error occurs when creating the socket * @throws IOException if an I/O error occurs when creating the socket
* @throws SecurityException if a security manager exists and its * @throws SecurityException if a security manager exists and its
* <code>checkConnect</code> method doesn't allow the operation. * <code>checkConnect</code> method doesn't allow the operation.
...@@ -241,8 +243,10 @@ public abstract class SSLSocket extends Socket ...@@ -241,8 +243,10 @@ public abstract class SSLSocket extends Socket
* *
* @param address the server's host * @param address the server's host
* @param port its port * @param port its port
* @param clientAddress the client's host * @param clientAddress the client's address the socket is bound to, or
* @param clientPort number of the client's port * <code>null</code> for the <code>anyLocal</code> address.
* @param clientPort the client's port the socket is bound to, or
* <code>zero</code> for a system selected free port.
* @throws IOException if an I/O error occurs when creating the socket * @throws IOException if an I/O error occurs when creating the socket
* @throws SecurityException if a security manager exists and its * @throws SecurityException if a security manager exists and its
* <code>checkConnect</code> method doesn't allow the operation. * <code>checkConnect</code> method doesn't allow the operation.
......
/* /*
* Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -129,6 +129,7 @@ public class TrustManagerFactory { ...@@ -129,6 +129,7 @@ public class TrustManagerFactory {
* @exception NoSuchAlgorithmException if no Provider supports a * @exception NoSuchAlgorithmException if no Provider supports a
* TrustManagerFactorySpi implementation for the * TrustManagerFactorySpi implementation for the
* specified algorithm. * specified algorithm.
* @exception NullPointerException if algorithm is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -171,6 +172,7 @@ public class TrustManagerFactory { ...@@ -171,6 +172,7 @@ public class TrustManagerFactory {
* registered in the security provider list. * registered in the security provider list.
* *
* @throws IllegalArgumentException if the provider name is null or empty. * @throws IllegalArgumentException if the provider name is null or empty.
* @throws NullPointerException if algorithm is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -208,6 +210,7 @@ public class TrustManagerFactory { ...@@ -208,6 +210,7 @@ public class TrustManagerFactory {
* from the specified Provider object. * from the specified Provider object.
* *
* @throws IllegalArgumentException if the provider is null. * @throws IllegalArgumentException if the provider is null.
* @throws NullPointerException if algorithm is null.
* *
* @see java.security.Provider * @see java.security.Provider
*/ */
...@@ -274,6 +277,8 @@ public class TrustManagerFactory { ...@@ -274,6 +277,8 @@ public class TrustManagerFactory {
/** /**
* Returns one trust manager for each type of trust material. * Returns one trust manager for each type of trust material.
* *
* @throws IllegalStateException if the factory is not initialized.
*
* @return the trust managers * @return the trust managers
*/ */
public final TrustManager[] getTrustManagers() { public final TrustManager[] getTrustManagers() {
......
/* /*
* Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -74,6 +74,8 @@ public abstract class TrustManagerFactorySpi { ...@@ -74,6 +74,8 @@ public abstract class TrustManagerFactorySpi {
/** /**
* Returns one trust manager for each type of trust material. * Returns one trust manager for each type of trust material.
* *
* @throws IllegalStateException if the factory is not initialized.
*
* @return the trust managers * @return the trust managers
*/ */
protected abstract TrustManager[] engineGetTrustManagers(); protected abstract TrustManager[] engineGetTrustManagers();
......
/* /*
* Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,6 +40,8 @@ import java.util.IdentityHashMap; ...@@ -40,6 +40,8 @@ import java.util.IdentityHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
...@@ -126,6 +128,7 @@ import java.beans.PropertyChangeListener; ...@@ -126,6 +128,7 @@ import java.beans.PropertyChangeListener;
* @author Fred Ecks * @author Fred Ecks
*/ */
public final class AppContext { public final class AppContext {
private static final Logger log = Logger.getLogger("sun.awt.AppContext");
/* Since the contents of an AppContext are unique to each Java /* Since the contents of an AppContext are unique to each Java
* session, this class should never be serialized. */ * session, this class should never be serialized. */
...@@ -143,13 +146,15 @@ public final class AppContext { ...@@ -143,13 +146,15 @@ public final class AppContext {
* Returns a set containing all <code>AppContext</code>s. * Returns a set containing all <code>AppContext</code>s.
*/ */
public static Set<AppContext> getAppContexts() { public static Set<AppContext> getAppContexts() {
return new HashSet<AppContext>(threadGroup2appContext.values()); synchronized (threadGroup2appContext) {
return new HashSet<AppContext>(threadGroup2appContext.values());
}
} }
/* The main "system" AppContext, used by everything not otherwise /* The main "system" AppContext, used by everything not otherwise
contained in another AppContext. contained in another AppContext.
*/ */
private static AppContext mainAppContext = null; private static volatile AppContext mainAppContext = null;
/* /*
* The hash map associated with this AppContext. A private delegate * The hash map associated with this AppContext. A private delegate
...@@ -174,31 +179,30 @@ public final class AppContext { ...@@ -174,31 +179,30 @@ public final class AppContext {
public static final String DISPOSED_PROPERTY_NAME = "disposed"; public static final String DISPOSED_PROPERTY_NAME = "disposed";
public static final String GUI_DISPOSED = "guidisposed"; public static final String GUI_DISPOSED = "guidisposed";
private boolean isDisposed = false; // true if AppContext is disposed private volatile boolean isDisposed = false; // true if AppContext is disposed
public boolean isDisposed() { public boolean isDisposed() {
return isDisposed; return isDisposed;
} }
static { static {
// On the main Thread, we get the ThreadGroup, make a corresponding // On the main Thread, we get the ThreadGroup, make a corresponding
// AppContext, and instantiate the Java EventQueue. This way, legacy // AppContext, and instantiate the Java EventQueue. This way, legacy
// code is unaffected by the move to multiple AppContext ability. // code is unaffected by the move to multiple AppContext ability.
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction() {
public Object run() { public Object run() {
ThreadGroup currentThreadGroup = ThreadGroup currentThreadGroup =
Thread.currentThread().getThreadGroup(); Thread.currentThread().getThreadGroup();
ThreadGroup parentThreadGroup = currentThreadGroup.getParent(); ThreadGroup parentThreadGroup = currentThreadGroup.getParent();
while (parentThreadGroup != null) { while (parentThreadGroup != null) {
// Find the root ThreadGroup to construct our main AppContext // Find the root ThreadGroup to construct our main AppContext
currentThreadGroup = parentThreadGroup; currentThreadGroup = parentThreadGroup;
parentThreadGroup = currentThreadGroup.getParent(); parentThreadGroup = currentThreadGroup.getParent();
}
mainAppContext = new AppContext(currentThreadGroup);
numAppContexts = 1;
return mainAppContext;
} }
mainAppContext = new AppContext(currentThreadGroup);
numAppContexts = 1;
return mainAppContext;
}
}); });
} }
...@@ -209,7 +213,7 @@ public final class AppContext { ...@@ -209,7 +213,7 @@ public final class AppContext {
* number is 1. If so, it returns the sole AppContext without * number is 1. If so, it returns the sole AppContext without
* checking Thread.currentThread(). * checking Thread.currentThread().
*/ */
private static int numAppContexts; private static volatile int numAppContexts;
/* /*
* The context ClassLoader that was used to create this AppContext. * The context ClassLoader that was used to create this AppContext.
...@@ -236,14 +240,15 @@ public final class AppContext { ...@@ -236,14 +240,15 @@ public final class AppContext {
threadGroup2appContext.put(threadGroup, this); threadGroup2appContext.put(threadGroup, this);
this.contextClassLoader = this.contextClassLoader =
(ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
public Object run() { public ClassLoader run() {
return Thread.currentThread().getContextClassLoader(); return Thread.currentThread().getContextClassLoader();
} }
}); });
} }
private static MostRecentThreadAppContext mostRecentThreadAppContext = null; private static final ThreadLocal<AppContext> threadAppContext =
new ThreadLocal<AppContext>();
/** /**
* Returns the appropriate AppContext for the caller, * Returns the appropriate AppContext for the caller,
...@@ -260,59 +265,46 @@ public final class AppContext { ...@@ -260,59 +265,46 @@ public final class AppContext {
if (numAppContexts == 1) // If there's only one system-wide, if (numAppContexts == 1) // If there's only one system-wide,
return mainAppContext; // return the main system AppContext. return mainAppContext; // return the main system AppContext.
final Thread currentThread = Thread.currentThread(); AppContext appContext = threadAppContext.get();
AppContext appContext = null; if (null == appContext) {
appContext = AccessController.doPrivileged(new PrivilegedAction<AppContext>()
// Note: this most recent Thread/AppContext caching is thread-hot. {
// A simple test using SwingSet found that 96.8% of lookups public AppContext run() {
// were matched using the most recent Thread/AppContext. By // Get the current ThreadGroup, and look for it and its
// instantiating a simple MostRecentThreadAppContext object on // parents in the hash from ThreadGroup to AppContext --
// cache misses, the cache hits can be processed without // it should be found, because we use createNewContext()
// synchronization. // when new AppContext objects are created.
ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup();
ThreadGroup threadGroup = currentThreadGroup;
AppContext context = threadGroup2appContext.get(threadGroup);
while (context == null) {
threadGroup = threadGroup.getParent();
if (threadGroup == null) {
// If we get here, we're running under a ThreadGroup that
// has no AppContext associated with it. This should never
// happen, because createNewContext() should be used by the
// toolkit to create the ThreadGroup that everything runs
// under.
throw new RuntimeException("Invalid ThreadGroup");
}
context = threadGroup2appContext.get(threadGroup);
}
// In case we did anything in the above while loop, we add
// all the intermediate ThreadGroups to threadGroup2appContext
// so we won't spin again.
for (ThreadGroup tg = currentThreadGroup; tg != threadGroup; tg = tg.getParent()) {
threadGroup2appContext.put(tg, context);
}
// Now we're done, so we cache the latest key/value pair.
// (we do this before checking with any AWTSecurityManager, so if
// this Thread equates with the main AppContext in the cache, it
// still will)
threadAppContext.set(context);
MostRecentThreadAppContext recent = mostRecentThreadAppContext; return context;
if ((recent != null) && (recent.thread == currentThread)) {
appContext = recent.appContext; // Cache hit
} else {
appContext = (AppContext)AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
// Get the current ThreadGroup, and look for it and its
// parents in the hash from ThreadGroup to AppContext --
// it should be found, because we use createNewContext()
// when new AppContext objects are created.
ThreadGroup currentThreadGroup = currentThread.getThreadGroup();
ThreadGroup threadGroup = currentThreadGroup;
AppContext context = threadGroup2appContext.get(threadGroup);
while (context == null) {
threadGroup = threadGroup.getParent();
if (threadGroup == null) {
// If we get here, we're running under a ThreadGroup that
// has no AppContext associated with it. This should never
// happen, because createNewContext() should be used by the
// toolkit to create the ThreadGroup that everything runs
// under.
throw new RuntimeException("Invalid ThreadGroup");
} }
context = threadGroup2appContext.get(threadGroup); });
}
// In case we did anything in the above while loop, we add
// all the intermediate ThreadGroups to threadGroup2appContext
// so we won't spin again.
for (ThreadGroup tg = currentThreadGroup; tg != threadGroup; tg = tg.getParent()) {
threadGroup2appContext.put(tg, context);
}
// Now we're done, so we cache the latest key/value pair.
// (we do this before checking with any AWTSecurityManager, so if
// this Thread equates with the main AppContext in the cache, it
// still will)
mostRecentThreadAppContext =
new MostRecentThreadAppContext(currentThread, context);
return context;
}
});
} }
if (appContext == mainAppContext) { if (appContext == mainAppContext) {
...@@ -321,9 +313,9 @@ public final class AppContext { ...@@ -321,9 +313,9 @@ public final class AppContext {
// allow it to choose the AppContext to return. // allow it to choose the AppContext to return.
SecurityManager securityManager = System.getSecurityManager(); SecurityManager securityManager = System.getSecurityManager();
if ((securityManager != null) && if ((securityManager != null) &&
(securityManager instanceof AWTSecurityManager)) { (securityManager instanceof AWTSecurityManager))
AWTSecurityManager awtSecMgr = {
(AWTSecurityManager)securityManager; AWTSecurityManager awtSecMgr = (AWTSecurityManager)securityManager;
AppContext secAppContext = awtSecMgr.getAppContext(); AppContext secAppContext = awtSecMgr.getAppContext();
if (secAppContext != null) { if (secAppContext != null) {
appContext = secAppContext; // Return what we're told appContext = secAppContext; // Return what we're told
...@@ -385,7 +377,13 @@ public final class AppContext { ...@@ -385,7 +377,13 @@ public final class AppContext {
public void run() { public void run() {
Window[] windowsToDispose = Window.getOwnerlessWindows(); Window[] windowsToDispose = Window.getOwnerlessWindows();
for (Window w : windowsToDispose) { for (Window w : windowsToDispose) {
w.dispose(); try {
w.dispose();
} catch (Throwable t) {
if (log.isLoggable(Level.FINER)) {
log.log(Level.FINER, "exception occured while disposing app context", t);
}
}
} }
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction() {
public Object run() { public Object run() {
...@@ -444,7 +442,7 @@ public final class AppContext { ...@@ -444,7 +442,7 @@ public final class AppContext {
// Threads in the ThreadGroup to exit. // Threads in the ThreadGroup to exit.
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
long endTime = startTime + (long)THREAD_INTERRUPT_TIMEOUT; long endTime = startTime + THREAD_INTERRUPT_TIMEOUT;
while ((this.threadGroup.activeCount() > 0) && while ((this.threadGroup.activeCount() > 0) &&
(System.currentTimeMillis() < endTime)) { (System.currentTimeMillis() < endTime)) {
try { try {
...@@ -459,7 +457,7 @@ public final class AppContext { ...@@ -459,7 +457,7 @@ public final class AppContext {
// Threads in the ThreadGroup to die. // Threads in the ThreadGroup to die.
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
endTime = startTime + (long)THREAD_INTERRUPT_TIMEOUT; endTime = startTime + THREAD_INTERRUPT_TIMEOUT;
while ((this.threadGroup.activeCount() > 0) && while ((this.threadGroup.activeCount() > 0) &&
(System.currentTimeMillis() < endTime)) { (System.currentTimeMillis() < endTime)) {
try { try {
...@@ -478,10 +476,7 @@ public final class AppContext { ...@@ -478,10 +476,7 @@ public final class AppContext {
} }
threadGroup2appContext.remove(this.threadGroup); threadGroup2appContext.remove(this.threadGroup);
MostRecentThreadAppContext recent = mostRecentThreadAppContext; threadAppContext.set(null);
if ((recent != null) && (recent.appContext == this))
mostRecentThreadAppContext = null;
// If the "most recent" points to this, clear it for GC
// Finally, we destroy the ThreadGroup entirely. // Finally, we destroy the ThreadGroup entirely.
try { try {
...@@ -664,6 +659,7 @@ public final class AppContext { ...@@ -664,6 +659,7 @@ public final class AppContext {
* Returns a string representation of this AppContext. * Returns a string representation of this AppContext.
* @since 1.2 * @since 1.2
*/ */
@Override
public String toString() { public String toString() {
return getClass().getName() + "[threadGroup=" + threadGroup.getName() + "]"; return getClass().getName() + "[threadGroup=" + threadGroup.getName() + "]";
} }
...@@ -769,15 +765,6 @@ public final class AppContext { ...@@ -769,15 +765,6 @@ public final class AppContext {
} }
} }
final class MostRecentThreadAppContext {
final Thread thread;
final AppContext appContext;
MostRecentThreadAppContext(Thread key, AppContext value) {
thread = key;
appContext = value;
}
}
final class MostRecentKeyValue { final class MostRecentKeyValue {
Object key; Object key;
Object value; Object value;
......
/* /*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -270,62 +270,58 @@ public abstract class DataTransferer { ...@@ -270,62 +270,58 @@ public abstract class DataTransferer {
* instead, null will be returned. * instead, null will be returned.
*/ */
public static DataTransferer getInstance() { public static DataTransferer getInstance() {
if (transferer == null) { synchronized (DataTransferer.class) {
synchronized (DataTransferer.class) { if (transferer == null) {
if (transferer == null) { final String name = SunToolkit.getDataTransfererClassName();
final String name = SunToolkit. if (name != null) {
getDataTransfererClassName(); PrivilegedAction<DataTransferer> action = new PrivilegedAction<DataTransferer>()
if (name != null) { {
PrivilegedAction action = new PrivilegedAction() { public DataTransferer run() {
public Object run() { Class cls = null;
Class cls = null; Method method = null;
Method method = null; DataTransferer ret = null;
Object ret = null;
try {
try { cls = Class.forName(name);
cls = Class.forName(name); } catch (ClassNotFoundException e) {
} catch (ClassNotFoundException e) { ClassLoader cl = ClassLoader.
ClassLoader cl = ClassLoader. getSystemClassLoader();
getSystemClassLoader(); if (cl != null) {
if (cl != null) {
try {
cls = cl.loadClass(name);
} catch (ClassNotFoundException ee) {
ee.printStackTrace();
throw new AWTError("DataTransferer not found: " + name);
}
}
}
if (cls != null) {
try { try {
method = cls.getDeclaredMethod cls = cl.loadClass(name);
("getInstanceImpl"); } catch (ClassNotFoundException ee) {
method.setAccessible(true); ee.printStackTrace();
} catch (NoSuchMethodException e) { throw new AWTError("DataTransferer not found: " + name);
e.printStackTrace();
throw new AWTError("Cannot instantiate DataTransferer: " + name);
} catch (SecurityException e) {
e.printStackTrace();
throw new AWTError("Access is denied for DataTransferer: " + name);
} }
} }
if (method != null) { }
try { if (cls != null) {
ret = method.invoke(null); try {
} catch (InvocationTargetException e) { method = cls.getDeclaredMethod("getInstanceImpl");
e.printStackTrace(); method.setAccessible(true);
throw new AWTError("Cannot instantiate DataTransferer: " + name); } catch (NoSuchMethodException e) {
} catch (IllegalAccessException e) { e.printStackTrace();
e.printStackTrace(); throw new AWTError("Cannot instantiate DataTransferer: " + name);
throw new AWTError("Cannot access DataTransferer: " + name); } catch (SecurityException e) {
} e.printStackTrace();
throw new AWTError("Access is denied for DataTransferer: " + name);
} }
return ret;
} }
}; if (method != null) {
transferer = (DataTransferer) try {
AccessController.doPrivileged(action); ret = (DataTransferer) method.invoke(null);
} } catch (InvocationTargetException e) {
e.printStackTrace();
throw new AWTError("Cannot instantiate DataTransferer: " + name);
} catch (IllegalAccessException e) {
e.printStackTrace();
throw new AWTError("Cannot access DataTransferer: " + name);
}
}
return ret;
}
};
transferer = AccessController.doPrivileged(action);
} }
} }
} }
......
...@@ -303,39 +303,78 @@ public class InstrumentationImpl implements Instrumentation { ...@@ -303,39 +303,78 @@ public class InstrumentationImpl implements Instrumentation {
NoSuchMethodException firstExc = null; NoSuchMethodException firstExc = null;
boolean twoArgAgent = false; boolean twoArgAgent = false;
// The agent class has a premain or agentmain method that has 1 or 2 // The agent class must have a premain or agentmain method that
// arguments. We first check for a signature of (String, Instrumentation), // has 1 or 2 arguments. We check in the following order:
// and if not found we check for (String). If neither is found then we //
// throw the NoSuchMethodException from the first attempt so that the // 1) declared with a signature of (String, Instrumentation)
// exception text indicates the lookup failed for the 2-arg method // 2) declared with a signature of (String)
// (same as JDK5.0). // 3) inherited with a signature of (String, Instrumentation)
// 4) inherited with a signature of (String)
//
// So the declared version of either 1-arg or 2-arg always takes
// primary precedence over an inherited version. After that, the
// 2-arg version takes precedence over the 1-arg version.
//
// If no method is found then we throw the NoSuchMethodException
// from the first attempt so that the exception text indicates
// the lookup failed for the 2-arg method (same as JDK5.0).
try { try {
m = javaAgentClass.getMethod( methodname, m = javaAgentClass.getDeclaredMethod( methodname,
new Class[] { new Class[] {
String.class, String.class,
java.lang.instrument.Instrumentation.class java.lang.instrument.Instrumentation.class
} }
); );
twoArgAgent = true; twoArgAgent = true;
} catch (NoSuchMethodException x) { } catch (NoSuchMethodException x) {
// remember the NoSuchMethodException // remember the NoSuchMethodException
firstExc = x; firstExc = x;
} }
// check for the 1-arg method
if (m == null) { if (m == null) {
// now try the declared 1-arg method
try { try {
m = javaAgentClass.getMethod(methodname, new Class[] { String.class }); m = javaAgentClass.getDeclaredMethod(methodname,
new Class[] { String.class });
} catch (NoSuchMethodException x) { } catch (NoSuchMethodException x) {
// Neither method exists so we throw the first NoSuchMethodException // ignore this exception because we'll try
// as per 5.0 // two arg inheritance next
}
}
if (m == null) {
// now try the inherited 2-arg method
try {
m = javaAgentClass.getMethod( methodname,
new Class[] {
String.class,
java.lang.instrument.Instrumentation.class
}
);
twoArgAgent = true;
} catch (NoSuchMethodException x) {
// ignore this exception because we'll try
// one arg inheritance next
}
}
if (m == null) {
// finally try the inherited 1-arg method
try {
m = javaAgentClass.getMethod(methodname,
new Class[] { String.class });
} catch (NoSuchMethodException x) {
// none of the methods exists so we throw the
// first NoSuchMethodException as per 5.0
throw firstExc; throw firstExc;
} }
} }
// the premain method should not be required to be public, // the premain method should not be required to be public,
// make it accessible so we can call it // make it accessible so we can call it
// Note: The spec says the following:
// The agent class must implement a public static premain method...
setAccessible(m, true); setAccessible(m, true);
// invoke the 1 or 2-arg method // invoke the 1 or 2-arg method
......
...@@ -64,7 +64,8 @@ class Flag { ...@@ -64,7 +64,8 @@ class Flag {
} }
VMOption getVMOption() { VMOption getVMOption() {
return new VMOption(name, value.toString(), writeable, origin); String val = value == null ? "" : value.toString();
return new VMOption(name, val, writeable, origin);
} }
static Flag getFlag(String name) { static Flag getFlag(String name) {
......
...@@ -72,7 +72,7 @@ final class P11Cipher extends CipherSpi { ...@@ -72,7 +72,7 @@ final class P11Cipher extends CipherSpi {
// DEC: return the length of trailing padding bytes given the specified // DEC: return the length of trailing padding bytes given the specified
// padded data // padded data
int unpad(byte[] paddedData, int ofs, int len) int unpad(byte[] paddedData, int len)
throws BadPaddingException; throws BadPaddingException;
} }
...@@ -94,14 +94,17 @@ final class P11Cipher extends CipherSpi { ...@@ -94,14 +94,17 @@ final class P11Cipher extends CipherSpi {
return padLen; return padLen;
} }
public int unpad(byte[] paddedData, int ofs, int len) public int unpad(byte[] paddedData, int len)
throws BadPaddingException { throws BadPaddingException {
byte padValue = paddedData[ofs + len - 1]; if (len < 1 || len > paddedData.length) {
throw new BadPaddingException("Invalid pad array length!");
}
byte padValue = paddedData[len - 1];
if (padValue < 1 || padValue > blockSize) { if (padValue < 1 || padValue > blockSize) {
throw new BadPaddingException("Invalid pad value!"); throw new BadPaddingException("Invalid pad value!");
} }
// sanity check padding bytes // sanity check padding bytes
int padStartIndex = ofs + len - padValue; int padStartIndex = len - padValue;
for (int i = padStartIndex; i < len; i++) { for (int i = padStartIndex; i < len; i++) {
if (paddedData[i] != padValue) { if (paddedData[i] != padValue) {
throw new BadPaddingException("Invalid pad bytes!"); throw new BadPaddingException("Invalid pad bytes!");
...@@ -712,7 +715,7 @@ final class P11Cipher extends CipherSpi { ...@@ -712,7 +715,7 @@ final class P11Cipher extends CipherSpi {
} }
k += token.p11.C_DecryptFinal(session.id(), 0, padBuffer, k, k += token.p11.C_DecryptFinal(session.id(), 0, padBuffer, k,
padBuffer.length - k); padBuffer.length - k);
int actualPadLen = paddingObj.unpad(padBuffer, 0, k); int actualPadLen = paddingObj.unpad(padBuffer, k);
k -= actualPadLen; k -= actualPadLen;
System.arraycopy(padBuffer, 0, out, outOfs, k); System.arraycopy(padBuffer, 0, out, outOfs, k);
} else { } else {
...@@ -781,7 +784,7 @@ final class P11Cipher extends CipherSpi { ...@@ -781,7 +784,7 @@ final class P11Cipher extends CipherSpi {
} }
k += token.p11.C_DecryptFinal(session.id(), k += token.p11.C_DecryptFinal(session.id(),
0, padBuffer, k, padBuffer.length - k); 0, padBuffer, k, padBuffer.length - k);
int actualPadLen = paddingObj.unpad(padBuffer, 0, k); int actualPadLen = paddingObj.unpad(padBuffer, k);
k -= actualPadLen; k -= actualPadLen;
outArray = padBuffer; outArray = padBuffer;
outOfs = 0; outOfs = 0;
...@@ -814,7 +817,8 @@ final class P11Cipher extends CipherSpi { ...@@ -814,7 +817,8 @@ final class P11Cipher extends CipherSpi {
if (errorCode == CKR_BUFFER_TOO_SMALL) { if (errorCode == CKR_BUFFER_TOO_SMALL) {
throw (ShortBufferException) throw (ShortBufferException)
(new ShortBufferException().initCause(e)); (new ShortBufferException().initCause(e));
} else if (errorCode == CKR_DATA_LEN_RANGE) { } else if (errorCode == CKR_DATA_LEN_RANGE ||
errorCode == CKR_ENCRYPTED_DATA_LEN_RANGE) {
throw (IllegalBlockSizeException) throw (IllegalBlockSizeException)
(new IllegalBlockSizeException(e.toString()).initCause(e)); (new IllegalBlockSizeException(e.toString()).initCause(e));
} }
......
...@@ -87,6 +87,9 @@ class EndEntityChecker { ...@@ -87,6 +87,9 @@ class EndEntityChecker {
// the Microsoft Server-Gated-Cryptography EKU extension OID // the Microsoft Server-Gated-Cryptography EKU extension OID
private final static String OID_EKU_MS_SGC = "1.3.6.1.4.1.311.10.3.3"; private final static String OID_EKU_MS_SGC = "1.3.6.1.4.1.311.10.3.3";
// the recognized extension OIDs
private final static String OID_SUBJECT_ALT_NAME = "2.5.29.17";
private final static String NSCT_SSL_CLIENT = private final static String NSCT_SSL_CLIENT =
NetscapeCertTypeExtension.SSL_CLIENT; NetscapeCertTypeExtension.SSL_CLIENT;
...@@ -171,6 +174,13 @@ class EndEntityChecker { ...@@ -171,6 +174,13 @@ class EndEntityChecker {
throws CertificateException { throws CertificateException {
// basic constraints irrelevant in EE certs // basic constraints irrelevant in EE certs
exts.remove(SimpleValidator.OID_BASIC_CONSTRAINTS); exts.remove(SimpleValidator.OID_BASIC_CONSTRAINTS);
// If the subject field contains an empty sequence, the subjectAltName
// extension MUST be marked critical.
// We do not check the validity of the critical extension, just mark
// it recognizable here.
exts.remove(OID_SUBJECT_ALT_NAME);
if (!exts.isEmpty()) { if (!exts.isEmpty()) {
throw new CertificateException("Certificate contains unsupported " throw new CertificateException("Certificate contains unsupported "
+ "critical extensions: " + exts); + "critical extensions: " + exts);
......
...@@ -626,6 +626,7 @@ appendClassPath( JPLISAgent* agent, ...@@ -626,6 +626,7 @@ appendClassPath( JPLISAgent* agent,
jvmtiError jvmtierr; jvmtiError jvmtierr;
jvmtierr = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, jarfile); jvmtierr = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, jarfile);
check_phase_ret_1(jvmtierr);
if (jvmtierr == JVMTI_ERROR_NONE) { if (jvmtierr == JVMTI_ERROR_NONE) {
return 0; return 0;
...@@ -634,6 +635,7 @@ appendClassPath( JPLISAgent* agent, ...@@ -634,6 +635,7 @@ appendClassPath( JPLISAgent* agent,
jvmtiError err; jvmtiError err;
err = (*jvmtienv)->GetPhase(jvmtienv, &phase); err = (*jvmtienv)->GetPhase(jvmtienv, &phase);
/* can be called from any phase */
jplis_assert(err == JVMTI_ERROR_NONE); jplis_assert(err == JVMTI_ERROR_NONE);
if (phase == JVMTI_PHASE_LIVE) { if (phase == JVMTI_PHASE_LIVE) {
...@@ -805,6 +807,8 @@ appendBootClassPath( JPLISAgent* agent, ...@@ -805,6 +807,8 @@ appendBootClassPath( JPLISAgent* agent,
/* print warning if boot class path not updated */ /* print warning if boot class path not updated */
if (jvmtierr != JVMTI_ERROR_NONE) { if (jvmtierr != JVMTI_ERROR_NONE) {
check_phase_blob_ret(jvmtierr, free(path));
fprintf(stderr, "WARNING: %s not added to bootstrap class loader search: ", path); fprintf(stderr, "WARNING: %s not added to bootstrap class loader search: ", path);
switch (jvmtierr) { switch (jvmtierr) {
case JVMTI_ERROR_ILLEGAL_ARGUMENT : case JVMTI_ERROR_ILLEGAL_ARGUMENT :
......
...@@ -179,6 +179,7 @@ getJPLISEnvironment(jvmtiEnv * jvmtienv) { ...@@ -179,6 +179,7 @@ getJPLISEnvironment(jvmtiEnv * jvmtienv) {
jvmtierror = (*jvmtienv)->GetEnvironmentLocalStorage( jvmtierror = (*jvmtienv)->GetEnvironmentLocalStorage(
jvmtienv, jvmtienv,
(void**)&environment); (void**)&environment);
/* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
if (jvmtierror == JVMTI_ERROR_NONE) { if (jvmtierror == JVMTI_ERROR_NONE) {
...@@ -230,6 +231,7 @@ createNewJPLISAgent(JavaVM * vm, JPLISAgent **agent_ptr) { ...@@ -230,6 +231,7 @@ createNewJPLISAgent(JavaVM * vm, JPLISAgent **agent_ptr) {
/* don't leak envs */ /* don't leak envs */
if ( initerror != JPLIS_INIT_ERROR_NONE ) { if ( initerror != JPLIS_INIT_ERROR_NONE ) {
jvmtiError jvmtierror = (*jvmtienv)->DisposeEnvironment(jvmtienv); jvmtiError jvmtierror = (*jvmtienv)->DisposeEnvironment(jvmtienv);
/* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
} }
} }
...@@ -259,7 +261,7 @@ initializeJPLISAgent( JPLISAgent * agent, ...@@ -259,7 +261,7 @@ initializeJPLISAgent( JPLISAgent * agent,
agent->mNormalEnvironment.mIsRetransformer = JNI_FALSE; agent->mNormalEnvironment.mIsRetransformer = JNI_FALSE;
agent->mRetransformEnvironment.mJVMTIEnv = NULL; /* NULL until needed */ agent->mRetransformEnvironment.mJVMTIEnv = NULL; /* NULL until needed */
agent->mRetransformEnvironment.mAgent = agent; agent->mRetransformEnvironment.mAgent = agent;
agent->mRetransformEnvironment.mIsRetransformer = JNI_TRUE; agent->mRetransformEnvironment.mIsRetransformer = JNI_FALSE; /* JNI_FALSE until mJVMTIEnv is set */
agent->mAgentmainCaller = NULL; agent->mAgentmainCaller = NULL;
agent->mInstrumentationImpl = NULL; agent->mInstrumentationImpl = NULL;
agent->mPremainCaller = NULL; agent->mPremainCaller = NULL;
...@@ -277,18 +279,25 @@ initializeJPLISAgent( JPLISAgent * agent, ...@@ -277,18 +279,25 @@ initializeJPLISAgent( JPLISAgent * agent,
jvmtierror = (*jvmtienv)->SetEnvironmentLocalStorage( jvmtierror = (*jvmtienv)->SetEnvironmentLocalStorage(
jvmtienv, jvmtienv,
&(agent->mNormalEnvironment)); &(agent->mNormalEnvironment));
/* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
/* check what capabilities are available */ /* check what capabilities are available */
checkCapabilities(agent); checkCapabilities(agent);
/* check phase - if live phase then we don't need the VMInit event */ /* check phase - if live phase then we don't need the VMInit event */
jvmtierror == (*jvmtienv)->GetPhase(jvmtienv, &phase); jvmtierror = (*jvmtienv)->GetPhase(jvmtienv, &phase);
/* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
if (phase == JVMTI_PHASE_LIVE) { if (phase == JVMTI_PHASE_LIVE) {
return JPLIS_INIT_ERROR_NONE; return JPLIS_INIT_ERROR_NONE;
} }
if (phase != JVMTI_PHASE_ONLOAD) {
/* called too early or called too late; either way bail out */
return JPLIS_INIT_ERROR_FAILURE;
}
/* now turn on the VMInit event */ /* now turn on the VMInit event */
if ( jvmtierror == JVMTI_ERROR_NONE ) { if ( jvmtierror == JVMTI_ERROR_NONE ) {
jvmtiEventCallbacks callbacks; jvmtiEventCallbacks callbacks;
...@@ -298,6 +307,7 @@ initializeJPLISAgent( JPLISAgent * agent, ...@@ -298,6 +307,7 @@ initializeJPLISAgent( JPLISAgent * agent,
jvmtierror = (*jvmtienv)->SetEventCallbacks( jvmtienv, jvmtierror = (*jvmtienv)->SetEventCallbacks( jvmtienv,
&callbacks, &callbacks,
sizeof(callbacks)); sizeof(callbacks));
check_phase_ret_blob(jvmtierror, JPLIS_INIT_ERROR_FAILURE);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
} }
...@@ -307,6 +317,7 @@ initializeJPLISAgent( JPLISAgent * agent, ...@@ -307,6 +317,7 @@ initializeJPLISAgent( JPLISAgent * agent,
JVMTI_ENABLE, JVMTI_ENABLE,
JVMTI_EVENT_VM_INIT, JVMTI_EVENT_VM_INIT,
NULL /* all threads */); NULL /* all threads */);
check_phase_ret_blob(jvmtierror, JPLIS_INIT_ERROR_FAILURE);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
} }
...@@ -622,6 +633,7 @@ setLivePhaseEventHandlers( JPLISAgent * agent) { ...@@ -622,6 +633,7 @@ setLivePhaseEventHandlers( JPLISAgent * agent) {
jvmtierror = (*jvmtienv)->SetEventCallbacks( jvmtienv, jvmtierror = (*jvmtienv)->SetEventCallbacks( jvmtienv,
&callbacks, &callbacks,
sizeof(callbacks)); sizeof(callbacks));
check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
...@@ -632,6 +644,7 @@ setLivePhaseEventHandlers( JPLISAgent * agent) { ...@@ -632,6 +644,7 @@ setLivePhaseEventHandlers( JPLISAgent * agent) {
JVMTI_DISABLE, JVMTI_DISABLE,
JVMTI_EVENT_VM_INIT, JVMTI_EVENT_VM_INIT,
NULL /* all threads */); NULL /* all threads */);
check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
} }
...@@ -642,6 +655,7 @@ setLivePhaseEventHandlers( JPLISAgent * agent) { ...@@ -642,6 +655,7 @@ setLivePhaseEventHandlers( JPLISAgent * agent) {
JVMTI_ENABLE, JVMTI_ENABLE,
JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, JVMTI_EVENT_CLASS_FILE_LOAD_HOOK,
NULL /* all threads */); NULL /* all threads */);
check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
} }
...@@ -660,6 +674,7 @@ checkCapabilities(JPLISAgent * agent) { ...@@ -660,6 +674,7 @@ checkCapabilities(JPLISAgent * agent) {
memset(&potentialCapabilities, 0, sizeof(potentialCapabilities)); memset(&potentialCapabilities, 0, sizeof(potentialCapabilities));
jvmtierror = (*jvmtienv)->GetPotentialCapabilities(jvmtienv, &potentialCapabilities); jvmtierror = (*jvmtienv)->GetPotentialCapabilities(jvmtienv, &potentialCapabilities);
check_phase_ret(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
if ( jvmtierror == JVMTI_ERROR_NONE ) { if ( jvmtierror == JVMTI_ERROR_NONE ) {
...@@ -681,9 +696,11 @@ enableNativeMethodPrefixCapability(jvmtiEnv * jvmtienv) { ...@@ -681,9 +696,11 @@ enableNativeMethodPrefixCapability(jvmtiEnv * jvmtienv) {
jvmtiError jvmtierror; jvmtiError jvmtierror;
jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities); jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities);
/* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
desiredCapabilities.can_set_native_method_prefix = 1; desiredCapabilities.can_set_native_method_prefix = 1;
jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities); jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities);
check_phase_ret(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
} }
...@@ -715,9 +732,11 @@ addOriginalMethodOrderCapability(JPLISAgent * agent) { ...@@ -715,9 +732,11 @@ addOriginalMethodOrderCapability(JPLISAgent * agent) {
jvmtiError jvmtierror; jvmtiError jvmtierror;
jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities); jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities);
/* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
desiredCapabilities.can_maintain_original_method_order = 1; desiredCapabilities.can_maintain_original_method_order = 1;
jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities); jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities);
check_phase_ret(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
} }
...@@ -732,9 +751,11 @@ addRedefineClassesCapability(JPLISAgent * agent) { ...@@ -732,9 +751,11 @@ addRedefineClassesCapability(JPLISAgent * agent) {
if (agent->mRedefineAvailable && !agent->mRedefineAdded) { if (agent->mRedefineAvailable && !agent->mRedefineAdded) {
jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities); jvmtierror = (*jvmtienv)->GetCapabilities(jvmtienv, &desiredCapabilities);
/* can be called from any phase */
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
desiredCapabilities.can_redefine_classes = 1; desiredCapabilities.can_redefine_classes = 1;
jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities); jvmtierror = (*jvmtienv)->AddCapabilities(jvmtienv, &desiredCapabilities);
check_phase_ret(jvmtierror);
/* /*
* With mixed premain/agentmain agents then it's possible that the * With mixed premain/agentmain agents then it's possible that the
...@@ -998,6 +1019,7 @@ retransformableEnvironment(JPLISAgent * agent) { ...@@ -998,6 +1019,7 @@ retransformableEnvironment(JPLISAgent * agent) {
if (jvmtierror == JVMTI_ERROR_NONE) { if (jvmtierror == JVMTI_ERROR_NONE) {
// install the retransforming environment // install the retransforming environment
agent->mRetransformEnvironment.mJVMTIEnv = retransformerEnv; agent->mRetransformEnvironment.mJVMTIEnv = retransformerEnv;
agent->mRetransformEnvironment.mIsRetransformer = JNI_TRUE;
// Make it for ClassFileLoadHook handling // Make it for ClassFileLoadHook handling
jvmtierror = (*retransformerEnv)->SetEnvironmentLocalStorage( jvmtierror = (*retransformerEnv)->SetEnvironmentLocalStorage(
...@@ -1025,6 +1047,7 @@ isModifiableClass(JNIEnv * jnienv, JPLISAgent * agent, jclass clazz) { ...@@ -1025,6 +1047,7 @@ isModifiableClass(JNIEnv * jnienv, JPLISAgent * agent, jclass clazz) {
jvmtierror = (*jvmtienv)->IsModifiableClass( jvmtienv, jvmtierror = (*jvmtienv)->IsModifiableClass( jvmtienv,
clazz, clazz,
&is_modifiable); &is_modifiable);
check_phase_ret_false(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
return is_modifiable; return is_modifiable;
...@@ -1032,7 +1055,7 @@ isModifiableClass(JNIEnv * jnienv, JPLISAgent * agent, jclass clazz) { ...@@ -1032,7 +1055,7 @@ isModifiableClass(JNIEnv * jnienv, JPLISAgent * agent, jclass clazz) {
jboolean jboolean
isRetransformClassesSupported(JNIEnv * jnienv, JPLISAgent * agent) { isRetransformClassesSupported(JNIEnv * jnienv, JPLISAgent * agent) {
return retransformableEnvironment(agent) != NULL; return agent->mRetransformEnvironment.mIsRetransformer;
} }
void void
...@@ -1075,6 +1098,12 @@ retransformClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classes) { ...@@ -1075,6 +1098,12 @@ retransformClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classes) {
numClasses = (*jnienv)->GetArrayLength(jnienv, classes); numClasses = (*jnienv)->GetArrayLength(jnienv, classes);
errorOccurred = checkForThrowable(jnienv); errorOccurred = checkForThrowable(jnienv);
jplis_assert(!errorOccurred); jplis_assert(!errorOccurred);
if (!errorOccurred && numClasses == 0) {
jplis_assert(numClasses != 0);
errorOccurred = JNI_TRUE;
errorCode = JVMTI_ERROR_NULL_POINTER;
}
} }
if (!errorOccurred) { if (!errorOccurred) {
...@@ -1096,6 +1125,13 @@ retransformClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classes) { ...@@ -1096,6 +1125,13 @@ retransformClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classes) {
if (errorOccurred) { if (errorOccurred) {
break; break;
} }
if (classArray[index] == NULL) {
jplis_assert(classArray[index] != NULL);
errorOccurred = JNI_TRUE;
errorCode = JVMTI_ERROR_NULL_POINTER;
break;
}
} }
} }
...@@ -1217,6 +1253,7 @@ redefineClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classDefinitio ...@@ -1217,6 +1253,7 @@ redefineClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classDefinitio
if (!errorOccurred) { if (!errorOccurred) {
jvmtiError errorCode = JVMTI_ERROR_NONE; jvmtiError errorCode = JVMTI_ERROR_NONE;
errorCode = (*jvmtienv)->RedefineClasses(jvmtienv, numDefs, classDefs); errorCode = (*jvmtienv)->RedefineClasses(jvmtienv, numDefs, classDefs);
check_phase_blob_ret(errorCode, deallocate(jvmtienv, (void*)classDefs));
errorOccurred = (errorCode != JVMTI_ERROR_NONE); errorOccurred = (errorCode != JVMTI_ERROR_NONE);
if ( errorOccurred ) { if ( errorOccurred ) {
createAndThrowThrowableFromJVMTIErrorCode(jnienv, errorCode); createAndThrowThrowableFromJVMTIErrorCode(jnienv, errorCode);
...@@ -1250,6 +1287,7 @@ commonGetClassList( JNIEnv * jnienv, ...@@ -1250,6 +1287,7 @@ commonGetClassList( JNIEnv * jnienv,
classLoader, classLoader,
&classCount, &classCount,
&classes); &classes);
check_phase_ret_blob(jvmtierror, localArray);
errorOccurred = (jvmtierror != JVMTI_ERROR_NONE); errorOccurred = (jvmtierror != JVMTI_ERROR_NONE);
jplis_assert(!errorOccurred); jplis_assert(!errorOccurred);
...@@ -1311,6 +1349,7 @@ getObjectSize(JNIEnv * jnienv, JPLISAgent * agent, jobject objectToSize) { ...@@ -1311,6 +1349,7 @@ getObjectSize(JNIEnv * jnienv, JPLISAgent * agent, jobject objectToSize) {
jvmtiError jvmtierror = JVMTI_ERROR_NONE; jvmtiError jvmtierror = JVMTI_ERROR_NONE;
jvmtierror = (*jvmtienv)->GetObjectSize(jvmtienv, objectToSize, &objectSize); jvmtierror = (*jvmtienv)->GetObjectSize(jvmtienv, objectToSize, &objectSize);
check_phase_ret_0(jvmtierror);
jplis_assert(jvmtierror == JVMTI_ERROR_NONE); jplis_assert(jvmtierror == JVMTI_ERROR_NONE);
if ( jvmtierror != JVMTI_ERROR_NONE ) { if ( jvmtierror != JVMTI_ERROR_NONE ) {
createAndThrowThrowableFromJVMTIErrorCode(jnienv, jvmtierror); createAndThrowThrowableFromJVMTIErrorCode(jnienv, jvmtierror);
...@@ -1360,6 +1399,7 @@ appendToClassLoaderSearch(JNIEnv * jnienv, JPLISAgent * agent, jstring jarFile, ...@@ -1360,6 +1399,7 @@ appendToClassLoaderSearch(JNIEnv * jnienv, JPLISAgent * agent, jstring jarFile,
} else { } else {
jvmtierror = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, platformChars); jvmtierror = (*jvmtienv)->AddToSystemClassLoaderSearch(jvmtienv, platformChars);
} }
check_phase_ret(jvmtierror);
if ( jvmtierror != JVMTI_ERROR_NONE ) { if ( jvmtierror != JVMTI_ERROR_NONE ) {
createAndThrowThrowableFromJVMTIErrorCode(jnienv, jvmtierror); createAndThrowThrowableFromJVMTIErrorCode(jnienv, jvmtierror);
...@@ -1450,6 +1490,7 @@ setNativeMethodPrefixes(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray prefix ...@@ -1450,6 +1490,7 @@ setNativeMethodPrefixes(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray prefix
} }
err = (*jvmtienv)->SetNativeMethodPrefixes(jvmtienv, inx, (char**)prefixes); err = (*jvmtienv)->SetNativeMethodPrefixes(jvmtienv, inx, (char**)prefixes);
/* can be called from any phase */
jplis_assert(err == JVMTI_ERROR_NONE); jplis_assert(err == JVMTI_ERROR_NONE);
for (i = 0; i < inx; i++) { for (i = 0; i < inx; i++) {
......
...@@ -266,6 +266,48 @@ setNativeMethodPrefixes(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray prefix ...@@ -266,6 +266,48 @@ setNativeMethodPrefixes(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray prefix
#define jvmti(a) a->mNormalEnvironment.mJVMTIEnv #define jvmti(a) a->mNormalEnvironment.mJVMTIEnv
/*
* A set of macros for insulating the JLI method callers from
* JVMTI_ERROR_WRONG_PHASE return codes.
*/
/* for a JLI method where "blob" is executed before simply returning */
#define check_phase_blob_ret(ret, blob) \
if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
blob; \
return; \
}
/* for a JLI method where simply returning is benign */
#define check_phase_ret(ret) \
if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
return; \
}
/* for a JLI method where returning zero (0) is benign */
#define check_phase_ret_0(ret) \
if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
return 0; \
}
/* for a JLI method where returning one (1) is benign */
#define check_phase_ret_1(ret) \
if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
return 1; \
}
/* for a case where a specific "blob" must be returned */
#define check_phase_ret_blob(ret, blob) \
if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
return (blob); \
}
/* for a JLI method where returning false is benign */
#define check_phase_ret_false(ret) \
if ((ret) == JVMTI_ERROR_WRONG_PHASE) { \
return (jboolean) 0; \
}
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif /* __cplusplus */ #endif /* __cplusplus */
......
...@@ -23,6 +23,14 @@ ...@@ -23,6 +23,14 @@
* have any questions. * have any questions.
*/ */
#ifdef _WIN32
/*
* Win* needs this include. However, Linux and Solaris do not.
* Having this include on Solaris SPARC breaks having non US-ASCII
* characters in the value of the Premain-Class attribute.
*/
#include <ctype.h>
#endif /* _WIN32 */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -45,11 +53,37 @@ doAttribute(const char* name, const char* value, void* user_data) { ...@@ -45,11 +53,37 @@ doAttribute(const char* name, const char* value, void* user_data) {
if (attribute->name == NULL) { if (attribute->name == NULL) {
free(attribute); free(attribute);
} else { } else {
attribute->value = strdup(value); char *begin = (char *)value;
char *end;
size_t value_len;
/* skip any leading white space */
while (isspace(*begin)) {
begin++;
}
/* skip any trailing white space */
end = &begin[strlen(begin)];
while (end > begin && isspace(end[-1])) {
end--;
}
if (begin == end) {
/* no value so skip this attribute */
free(attribute->name);
free(attribute);
return;
}
value_len = (size_t)(end - begin);
attribute->value = malloc(value_len + 1);
if (attribute->value == NULL) { if (attribute->value == NULL) {
free(attribute->name); free(attribute->name);
free(attribute); free(attribute);
} else { } else {
/* save the value without leading or trailing whitespace */
strncpy(attribute->value, begin, value_len);
attribute->value[value_len] = '\0';
attribute->next = NULL; attribute->next = NULL;
if (context->head == NULL) { if (context->head == NULL) {
context->head = attribute; context->head = attribute;
......
...@@ -74,6 +74,7 @@ confirmingTLSSet( jvmtiEnv * jvmtienv, ...@@ -74,6 +74,7 @@ confirmingTLSSet( jvmtiEnv * jvmtienv,
jvmtienv, jvmtienv,
thread, thread,
newValue); newValue);
check_phase_ret_blob(error, error);
#if JPLISASSERT_ENABLEASSERTIONS #if JPLISASSERT_ENABLEASSERTIONS
assertTLSValue( jvmtienv, assertTLSValue( jvmtienv,
...@@ -96,6 +97,7 @@ assertTLSValue( jvmtiEnv * jvmtienv, ...@@ -96,6 +97,7 @@ assertTLSValue( jvmtiEnv * jvmtienv,
jvmtienv, jvmtienv,
thread, thread,
&test); &test);
check_phase_ret(error);
jplis_assert(error == JVMTI_ERROR_NONE); jplis_assert(error == JVMTI_ERROR_NONE);
jplis_assert(test == expected); jplis_assert(test == expected);
} }
...@@ -111,6 +113,7 @@ tryToAcquireReentrancyToken( jvmtiEnv * jvmtienv, ...@@ -111,6 +113,7 @@ tryToAcquireReentrancyToken( jvmtiEnv * jvmtienv,
jvmtienv, jvmtienv,
thread, thread,
&storedValue); &storedValue);
check_phase_ret_false(error);
jplis_assert(error == JVMTI_ERROR_NONE); jplis_assert(error == JVMTI_ERROR_NONE);
if ( error == JVMTI_ERROR_NONE ) { if ( error == JVMTI_ERROR_NONE ) {
/* if this thread is already inside, just return false and short-circuit */ /* if this thread is already inside, just return false and short-circuit */
......
...@@ -46,6 +46,7 @@ allocate(jvmtiEnv * jvmtienv, size_t bytecount) { ...@@ -46,6 +46,7 @@ allocate(jvmtiEnv * jvmtienv, size_t bytecount) {
error = (*jvmtienv)->Allocate(jvmtienv, error = (*jvmtienv)->Allocate(jvmtienv,
bytecount, bytecount,
(unsigned char**) &resultBuffer); (unsigned char**) &resultBuffer);
/* may be called from any phase */
jplis_assert(error == JVMTI_ERROR_NONE); jplis_assert(error == JVMTI_ERROR_NONE);
if ( error != JVMTI_ERROR_NONE ) { if ( error != JVMTI_ERROR_NONE ) {
resultBuffer = NULL; resultBuffer = NULL;
...@@ -66,6 +67,7 @@ deallocate(jvmtiEnv * jvmtienv, void * buffer) { ...@@ -66,6 +67,7 @@ deallocate(jvmtiEnv * jvmtienv, void * buffer) {
error = (*jvmtienv)->Deallocate(jvmtienv, error = (*jvmtienv)->Deallocate(jvmtienv,
(unsigned char*)buffer); (unsigned char*)buffer);
/* may be called from any phase */
jplis_assert_msg(error == JVMTI_ERROR_NONE, "Can't deallocate memory"); jplis_assert_msg(error == JVMTI_ERROR_NONE, "Can't deallocate memory");
return; return;
} }
......
/* /*
* Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -39,6 +39,8 @@ import sun.misc.Unsafe; ...@@ -39,6 +39,8 @@ import sun.misc.Unsafe;
* @since 1.5 * @since 1.5
*/ */
class MotifDnDConstants { class MotifDnDConstants {
// utility class can not be instantiated
private MotifDnDConstants() {}
// Note that offsets in all native structures below do not depend on the // Note that offsets in all native structures below do not depend on the
// architecture. // architecture.
private static final Unsafe unsafe = XlibWrapper.unsafe; private static final Unsafe unsafe = XlibWrapper.unsafe;
...@@ -55,8 +57,7 @@ class MotifDnDConstants { ...@@ -55,8 +57,7 @@ class MotifDnDConstants {
XAtom.get("XmTRANSFER_SUCCESS"); XAtom.get("XmTRANSFER_SUCCESS");
static final XAtom XA_XmTRANSFER_FAILURE = static final XAtom XA_XmTRANSFER_FAILURE =
XAtom.get("XmTRANSFER_FAILURE"); XAtom.get("XmTRANSFER_FAILURE");
static final XSelection MotifDnDSelection = static final XSelection MotifDnDSelection = new XSelection(XA_MOTIF_ATOM_0);
new XSelection(XA_MOTIF_ATOM_0, null);
public static final byte MOTIF_DND_PROTOCOL_VERSION = 0; public static final byte MOTIF_DND_PROTOCOL_VERSION = 0;
...@@ -231,6 +232,9 @@ class MotifDnDConstants { ...@@ -231,6 +232,9 @@ class MotifDnDConstants {
} }
public static final class Swapper { public static final class Swapper {
// utility class can not be instantiated
private Swapper() {}
public static short swap(short s) { public static short swap(short s) {
return (short)(((s & 0xFF00) >>> 8) | ((s & 0xFF) << 8)); return (short)(((s & 0xFF00) >>> 8) | ((s & 0xFF) << 8));
} }
......
/* /*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -933,7 +933,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -933,7 +933,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
XSelection selection = XSelection.getSelection(selectionAtom); XSelection selection = XSelection.getSelection(selectionAtom);
if (selection == null) { if (selection == null) {
selection = new XSelection(selectionAtom, null); selection = new XSelection(selectionAtom);
} }
return selection.getData(format, time_stamp); return selection.getData(format, time_stamp);
...@@ -1056,7 +1056,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol { ...@@ -1056,7 +1056,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
// the original structure can be freed before this // the original structure can be freed before this
// SunDropTargetEvent is dispatched. // SunDropTargetEvent is dispatched.
if (xclient != null) { if (xclient != null) {
int size = new XClientMessageEvent(nativeCtxt).getSize(); int size = XClientMessageEvent.getSize();
nativeCtxt = unsafe.allocateMemory(size + 4 * Native.getLongSize()); nativeCtxt = unsafe.allocateMemory(size + 4 * Native.getLongSize());
......
/*
* 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.awt.X11;
interface OwnershipListener {
public void ownershipChanged(final boolean isOwner);
}
/* /*
* Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -58,7 +58,7 @@ package sun.awt.X11; ...@@ -58,7 +58,7 @@ package sun.awt.X11;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import java.util.HashMap; import java.util.HashMap;
public class XAtom { public final class XAtom {
// Order of lock: XAWTLock -> XAtom.class // Order of lock: XAWTLock -> XAtom.class
...@@ -175,7 +175,7 @@ public class XAtom { ...@@ -175,7 +175,7 @@ public class XAtom {
public static XAtom get(String name) { public static XAtom get(String name) {
XAtom xatom = lookup(name); XAtom xatom = lookup(name);
if (xatom == null) { if (xatom == null) {
xatom = new XAtom(name); xatom = new XAtom(XToolkit.getDisplay(), name);
} }
return xatom; return xatom;
} }
...@@ -232,10 +232,6 @@ public class XAtom { ...@@ -232,10 +232,6 @@ public class XAtom {
this(display, name, true); this(display, name, true);
} }
private XAtom(String name) {
this(XToolkit.getDisplay(), name, true);
}
public XAtom(String name, boolean autoIntern) { public XAtom(String name, boolean autoIntern) {
this(XToolkit.getDisplay(), name, autoIntern); this(XToolkit.getDisplay(), name, autoIntern);
} }
...@@ -262,7 +258,7 @@ public class XAtom { ...@@ -262,7 +258,7 @@ public class XAtom {
* @since 1.5 * @since 1.5
*/ */
public XAtom(long display, String name, boolean autoIntern) { private XAtom(long display, String name, boolean autoIntern) {
this.name = name; this.name = name;
this.display = display; this.display = display;
if (autoIntern) { if (autoIntern) {
...@@ -651,28 +647,6 @@ public class XAtom { ...@@ -651,28 +647,6 @@ public class XAtom {
} }
} }
/**
* Initializes atom with name and display values
*/
public void setValues(long display, String name, boolean autoIntern) {
this.display = display;
this.name = name;
if (autoIntern) {
XToolkit.awtLock();
try {
atom = XlibWrapper.InternAtom(display,name,0);
} finally {
XToolkit.awtUnlock();
}
}
register();
}
public void setValues(long display, long atom) {
this.display = display;
this.atom = atom;
register();
}
public void setValues(long display, String name, long atom) { public void setValues(long display, String name, long atom) {
this.display = display; this.display = display;
this.atom = atom; this.atom = atom;
......
/* /*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,30 +26,32 @@ ...@@ -26,30 +26,32 @@
package sun.awt.X11; package sun.awt.X11;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.Set;
import java.util.Iterator;
import java.util.HashSet;
import java.io.IOException; import java.io.IOException;
import java.security.AccessController; import java.security.AccessController;
import java.util.HashMap;
import java.util.Map;
import sun.awt.UNIXToolkit;
import sun.awt.datatransfer.DataTransferer; import sun.awt.datatransfer.DataTransferer;
import sun.awt.datatransfer.SunClipboard; import sun.awt.datatransfer.SunClipboard;
import sun.awt.datatransfer.ClipboardTransferable; import sun.awt.datatransfer.ClipboardTransferable;
import sun.security.action.GetIntegerAction; import sun.security.action.GetIntegerAction;
/** /**
* A class which interfaces with the X11 selection service in order to support * A class which interfaces with the X11 selection service in order to support
* data transfer via Clipboard operations. * data transfer via Clipboard operations.
*/ */
public class XClipboard extends SunClipboard implements Runnable { public final class XClipboard extends SunClipboard implements OwnershipListener
{
private final XSelection selection; private final XSelection selection;
// Time of calling XConvertSelection().
private long convertSelectionTime;
// The flag used not to call XConvertSelection() if the previous SelectionNotify
// has not been processed by checkChange().
private volatile boolean isSelectionNotifyProcessed;
// The property in which the owner should place requested targets
// when tracking changes of available data flavors (practically targets).
private volatile XAtom targetsPropertyAtom;
private static final Object classLock = new Object(); private static final Object classLock = new Object();
...@@ -57,31 +59,33 @@ public class XClipboard extends SunClipboard implements Runnable { ...@@ -57,31 +59,33 @@ public class XClipboard extends SunClipboard implements Runnable {
private static int pollInterval; private static int pollInterval;
private static Set listenedClipboards; private static Map<Long, XClipboard> targetsAtom2Clipboard;
/** /**
* Creates a system clipboard object. * Creates a system clipboard object.
*/ */
public XClipboard(String name, String selectionName) { public XClipboard(String name, String selectionName) {
super(name); super(name);
selection = new XSelection(XAtom.get(selectionName), this); selection = new XSelection(XAtom.get(selectionName));
selection.registerOwershipListener(this);
} }
/** /*
* The action to be run when we lose ownership
* NOTE: This method may be called by privileged threads. * NOTE: This method may be called by privileged threads.
* DO NOT INVOKE CLIENT CODE ON THIS THREAD! * DO NOT INVOKE CLIENT CODE ON THIS THREAD!
*/ */
public void run() { public void ownershipChanged(final boolean isOwner) {
lostOwnershipImpl(); if (isOwner) {
checkChangeHere(contents);
} else {
lostOwnershipImpl();
}
} }
protected synchronized void setContentsNative(Transferable contents) { protected synchronized void setContentsNative(Transferable contents) {
SortedMap formatMap = DataTransferer.getInstance().getFormatsForTransferable SortedMap formatMap = DataTransferer.getInstance().getFormatsForTransferable
(contents, DataTransferer.adaptFlavorMap(flavorMap)); (contents, DataTransferer.adaptFlavorMap(flavorMap));
long[] formats = long[] formats = DataTransferer.keysToLongArray(formatMap);
DataTransferer.getInstance().keysToLongArray(formatMap);
if (!selection.setOwner(contents, formatMap, formats, if (!selection.setOwner(contents, formatMap, formats,
XToolkit.getCurrentServerTime())) { XToolkit.getCurrentServerTime())) {
...@@ -94,6 +98,7 @@ public class XClipboard extends SunClipboard implements Runnable { ...@@ -94,6 +98,7 @@ public class XClipboard extends SunClipboard implements Runnable {
return selection.getSelectionAtom().getAtom(); return selection.getSelectionAtom().getAtom();
} }
@Override
public synchronized Transferable getContents(Object requestor) { public synchronized Transferable getContents(Object requestor) {
if (contents != null) { if (contents != null) {
return contents; return contents;
...@@ -115,62 +120,163 @@ public class XClipboard extends SunClipboard implements Runnable { ...@@ -115,62 +120,163 @@ public class XClipboard extends SunClipboard implements Runnable {
return selection.getData(format, XToolkit.getCurrentServerTime()); return selection.getData(format, XToolkit.getCurrentServerTime());
} }
// Called on the toolkit thread under awtLock. private void checkChangeHere(Transferable contents) {
public void checkChange(long[] formats) {
if (!selection.isOwner()) {
super.checkChange(formats);
}
}
void checkChangeHere(Transferable contents) {
if (areFlavorListenersRegistered()) { if (areFlavorListenersRegistered()) {
super.checkChange(DataTransferer.getInstance(). checkChange(DataTransferer.getInstance().
getFormatsForTransferableAsArray(contents, flavorMap)); getFormatsForTransferableAsArray(contents, flavorMap));
} }
} }
protected void registerClipboardViewerChecked() { private static int getPollInterval() {
if (pollInterval <= 0) { synchronized (XClipboard.classLock) {
pollInterval = ((Integer)AccessController.doPrivileged(
new GetIntegerAction("awt.datatransfer.clipboard.poll.interval",
defaultPollInterval))).intValue();
if (pollInterval <= 0) { if (pollInterval <= 0) {
pollInterval = defaultPollInterval; pollInterval = AccessController.doPrivileged(
new GetIntegerAction("awt.datatransfer.clipboard.poll.interval",
defaultPollInterval));
if (pollInterval <= 0) {
pollInterval = defaultPollInterval;
}
} }
return pollInterval;
}
}
private XAtom getTargetsPropertyAtom() {
if (null == targetsPropertyAtom) {
targetsPropertyAtom =
XAtom.get("XAWT_TARGETS_OF_SELECTION:" + selection.getSelectionAtom().getName());
} }
selection.initializeSelectionForTrackingChanges(); return targetsPropertyAtom;
}
protected void registerClipboardViewerChecked() {
// for XConvertSelection() to be called for the first time in getTargetsDelayed()
isSelectionNotifyProcessed = true;
boolean mustSchedule = false; boolean mustSchedule = false;
synchronized (XClipboard.classLock) { synchronized (XClipboard.classLock) {
if (listenedClipboards == null) { if (targetsAtom2Clipboard == null) {
listenedClipboards = new HashSet(2); targetsAtom2Clipboard = new HashMap<Long, XClipboard>(2);
}
mustSchedule = targetsAtom2Clipboard.isEmpty();
targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this);
if (mustSchedule) {
XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(),
new SelectionNotifyHandler());
} }
mustSchedule = listenedClipboards.isEmpty();
listenedClipboards.add(this);
} }
if (mustSchedule) { if (mustSchedule) {
XToolkit.schedule(new CheckChangeTimerTask(), pollInterval); XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval());
} }
} }
private static class CheckChangeTimerTask implements Runnable { private static class CheckChangeTimerTask implements Runnable {
public void run() { public void run() {
for (Iterator iter = listenedClipboards.iterator(); iter.hasNext();) { for (XClipboard clpbrd : targetsAtom2Clipboard.values()) {
XClipboard clpbrd = (XClipboard)iter.next(); clpbrd.getTargetsDelayed();
clpbrd.selection.getTargetsDelayed();
} }
synchronized (XClipboard.classLock) { synchronized (XClipboard.classLock) {
if (listenedClipboards != null && !listenedClipboards.isEmpty()) { if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) {
XToolkit.schedule(this, pollInterval); XToolkit.schedule(this, XClipboard.getPollInterval());
}
}
}
}
private static class SelectionNotifyHandler implements XEventDispatcher {
public void dispatchEvent(XEvent ev) {
if (ev.get_type() == XlibWrapper.SelectionNotify) {
final XSelectionEvent xse = ev.get_xselection();
XClipboard clipboard = null;
synchronized (XClipboard.classLock) {
if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) {
XToolkit.removeEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), this);
return;
}
final long propertyAtom = xse.get_property();
clipboard = targetsAtom2Clipboard.get(propertyAtom);
}
if (null != clipboard) {
clipboard.checkChange(xse);
} }
} }
} }
} }
protected void unregisterClipboardViewerChecked() { protected void unregisterClipboardViewerChecked() {
selection.deinitializeSelectionForTrackingChanges(); isSelectionNotifyProcessed = false;
synchronized (XClipboard.classLock) { synchronized (XClipboard.classLock) {
listenedClipboards.remove(this); targetsAtom2Clipboard.remove(getTargetsPropertyAtom().getAtom());
} }
} }
// checkChange() will be called on SelectionNotify
private void getTargetsDelayed() {
XToolkit.awtLock();
try {
long curTime = System.currentTimeMillis();
if (isSelectionNotifyProcessed || curTime >= (convertSelectionTime + UNIXToolkit.getDatatransferTimeout()))
{
convertSelectionTime = curTime;
XlibWrapper.XConvertSelection(XToolkit.getDisplay(),
selection.getSelectionAtom().getAtom(),
XDataTransferer.TARGETS_ATOM.getAtom(),
getTargetsPropertyAtom().getAtom(),
XWindow.getXAWTRootWindow().getWindow(),
XlibWrapper.CurrentTime);
isSelectionNotifyProcessed = false;
}
} finally {
XToolkit.awtUnlock();
}
}
/*
* Tracks changes of available formats.
* NOTE: This method may be called by privileged threads.
* DO NOT INVOKE CLIENT CODE ON THIS THREAD!
*/
private void checkChange(XSelectionEvent xse) {
final long propertyAtom = xse.get_property();
if (propertyAtom != getTargetsPropertyAtom().getAtom()) {
// wrong atom
return;
}
final XAtom selectionAtom = XAtom.get(xse.get_selection());
final XSelection changedSelection = XSelection.getSelection(selectionAtom);
if (null == changedSelection || changedSelection != selection) {
// unknown selection - do nothing
return;
}
isSelectionNotifyProcessed = true;
if (selection.isOwner()) {
// selection is owner - do not need formats
return;
}
long[] formats = null;
if (propertyAtom == XlibWrapper.None) {
// We treat None property atom as "empty selection".
formats = new long[0];
} else {
WindowPropertyGetter targetsGetter =
new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(),
XAtom.get(propertyAtom), 0,
XSelection.MAX_LENGTH, true,
XlibWrapper.AnyPropertyType);
try {
targetsGetter.execute();
formats = XSelection.getFormats(targetsGetter);
} finally {
targetsGetter.dispose();
}
}
checkChange(formats);
}
} }
/* /*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,17 +31,13 @@ import java.awt.Color; ...@@ -31,17 +31,13 @@ import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.DefaultKeyboardFocusManager;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font; import java.awt.Font;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image; import java.awt.Image;
import java.awt.Insets; import java.awt.Insets;
import java.awt.KeyboardFocusManager; import java.awt.KeyboardFocusManager;
import java.awt.MenuBar;
import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.SystemColor; import java.awt.SystemColor;
import java.awt.Toolkit; import java.awt.Toolkit;
...@@ -60,12 +56,9 @@ import java.awt.event.InvocationEvent; ...@@ -60,12 +56,9 @@ import java.awt.event.InvocationEvent;
import java.awt.image.ImageObserver; import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer; import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage; import java.awt.image.VolatileImage;
import java.awt.peer.CanvasPeer;
import java.awt.peer.ComponentPeer; import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer; import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer; import java.awt.peer.LightweightPeer;
import java.awt.peer.PanelPeer;
import java.awt.peer.WindowPeer;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.security.*; import java.security.*;
import java.util.Collection; import java.util.Collection;
...@@ -821,7 +814,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget ...@@ -821,7 +814,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
public void setFont(Font f) { public void setFont(Font f) {
synchronized (getStateLock()) { synchronized (getStateLock()) {
if (f == null) { if (f == null) {
f = defaultFont; f = XWindow.getDefaultFont();
} }
font = f; font = f;
} }
......
/* /*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -39,16 +39,37 @@ import sun.awt.ComponentAccessor; ...@@ -39,16 +39,37 @@ import sun.awt.ComponentAccessor;
* This class implements window which serves as content window for decorated frames. * This class implements window which serves as content window for decorated frames.
* Its purpose to provide correct events dispatching for the complex * Its purpose to provide correct events dispatching for the complex
* constructs such as decorated frames. * constructs such as decorated frames.
*
* It should always be located at (- left inset, - top inset) in the associated
* decorated window. So coordinates in it would be the same as java coordinates.
*/ */
public class XContentWindow extends XWindow implements XConstants { public final class XContentWindow extends XWindow implements XConstants {
private static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XContentWindow"); private static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XContentWindow");
XDecoratedPeer parentFrame; static XContentWindow createContent(XDecoratedPeer parentFrame) {
final WindowDimensions dims = parentFrame.getDimensions();
Rectangle rec = dims.getBounds();
// Fix for - set the location of the content window to the (-left inset, -top inset)
Insets ins = dims.getInsets();
if (ins != null) {
rec.x = -ins.left;
rec.y = -ins.top;
} else {
rec.x = 0;
rec.y = 0;
}
final XContentWindow cw = new XContentWindow(parentFrame, rec);
cw.xSetVisible(true);
return cw;
}
private final XDecoratedPeer parentFrame;
// A list of expose events that come when the parentFrame is iconified // A list of expose events that come when the parentFrame is iconified
private java.util.List<SavedExposeEvent> iconifiedExposeEvents = new java.util.ArrayList<SavedExposeEvent>(); private final java.util.List<SavedExposeEvent> iconifiedExposeEvents =
new java.util.ArrayList<SavedExposeEvent>();
XContentWindow(XDecoratedPeer parentFrame, Rectangle bounds) { private XContentWindow(XDecoratedPeer parentFrame, Rectangle bounds) {
super((Component)parentFrame.getTarget(), parentFrame.getShell(), bounds); super((Component)parentFrame.getTarget(), parentFrame.getShell(), bounds);
this.parentFrame = parentFrame; this.parentFrame = parentFrame;
} }
...@@ -63,9 +84,6 @@ public class XContentWindow extends XWindow implements XConstants { ...@@ -63,9 +84,6 @@ public class XContentWindow extends XWindow implements XConstants {
} }
} }
void initialize() {
xSetVisible(true);
}
protected String getWMName() { protected String getWMName() {
return "Content window"; return "Content window";
} }
......
...@@ -36,7 +36,7 @@ import java.util.logging.Logger; ...@@ -36,7 +36,7 @@ import java.util.logging.Logger;
import sun.awt.ComponentAccessor; import sun.awt.ComponentAccessor;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
class XDecoratedPeer extends XWindowPeer { abstract class XDecoratedPeer extends XWindowPeer {
private static final Logger log = Logger.getLogger("sun.awt.X11.XDecoratedPeer"); private static final Logger log = Logger.getLogger("sun.awt.X11.XDecoratedPeer");
private static final Logger insLog = Logger.getLogger("sun.awt.X11.insets.XDecoratedPeer"); private static final Logger insLog = Logger.getLogger("sun.awt.X11.insets.XDecoratedPeer");
private static final Logger focusLog = Logger.getLogger("sun.awt.X11.focus.XDecoratedPeer"); private static final Logger focusLog = Logger.getLogger("sun.awt.X11.focus.XDecoratedPeer");
...@@ -98,8 +98,7 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -98,8 +98,7 @@ class XDecoratedPeer extends XWindowPeer {
// happen after the X window is created. // happen after the X window is created.
initResizability(); initResizability();
updateSizeHints(dimensions); updateSizeHints(dimensions);
content = createContent(dimensions); content = XContentWindow.createContent(this);
content.initialize();
if (warningWindow != null) { if (warningWindow != null) {
warningWindow.toFront(); warningWindow.toFront();
} }
...@@ -160,20 +159,6 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -160,20 +159,6 @@ class XDecoratedPeer extends XWindowPeer {
} }
} }
XContentWindow createContent(WindowDimensions dims) {
Rectangle rec = dims.getBounds();
// Fix for - set the location of the content window to the (-left inset, -top inset)
Insets ins = dims.getInsets();
if (ins != null) {
rec.x = -ins.left;
rec.y = -ins.top;
} else {
rec.x = 0;
rec.y = 0;
}
return new XContentWindow(this, rec);
}
XFocusProxyWindow createFocusProxy() { XFocusProxyWindow createFocusProxy() {
return new XFocusProxyWindow(this); return new XFocusProxyWindow(this);
} }
...@@ -286,7 +271,7 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -286,7 +271,7 @@ class XDecoratedPeer extends XWindowPeer {
return; return;
} }
Component t = (Component)target; Component t = (Component)target;
if (getDecorations() == winAttr.AWT_DECOR_NONE) { if (getDecorations() == XWindowAttributesData.AWT_DECOR_NONE) {
setReparented(true); setReparented(true);
insets_corrected = true; insets_corrected = true;
reshape(dimensions, SET_SIZE, false); reshape(dimensions, SET_SIZE, false);
...@@ -471,6 +456,15 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -471,6 +456,15 @@ class XDecoratedPeer extends XWindowPeer {
if (insLog.isLoggable(Level.FINE)) { if (insLog.isLoggable(Level.FINE)) {
insLog.fine("Reshaping " + this + " to " + newDimensions + " op " + op + " user reshape " + userReshape); insLog.fine("Reshaping " + this + " to " + newDimensions + " op " + op + " user reshape " + userReshape);
} }
if (userReshape) {
// We handle only userReshape == true cases. It means that
// if the window manager or any other part of the windowing
// system sets inappropriate size for this window, we can
// do nothing but accept it.
Rectangle reqBounds = newDimensions.getBounds();
Rectangle newBounds = constrainBounds(reqBounds.x, reqBounds.y, reqBounds.width, reqBounds.height);
newDimensions = new WindowDimensions(newBounds, newDimensions.getInsets(), newDimensions.isClientSizeSet());
}
XToolkit.awtLock(); XToolkit.awtLock();
try { try {
if (!isReparented() || !isVisible()) { if (!isReparented() || !isVisible()) {
...@@ -586,6 +580,49 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -586,6 +580,49 @@ class XDecoratedPeer extends XWindowPeer {
reshape(dims, operation, userReshape); reshape(dims, operation, userReshape);
} }
// This method gets overriden in XFramePeer & XDialogPeer.
abstract boolean isTargetUndecorated();
@Override
Rectangle constrainBounds(int x, int y, int width, int height) {
// We don't restrict the setBounds() operation if the code is trusted.
if (!hasWarningWindow()) {
return new Rectangle(x, y, width, height);
}
// If it's undecorated or is not currently visible,
// apply the same constraints as for the Window.
if (!isVisible() || isTargetUndecorated()) {
return super.constrainBounds(x, y, width, height);
}
// If it's visible & decorated, constraint the size only
int newX = x;
int newY = y;
int newW = width;
int newH = height;
GraphicsConfiguration gc = ((Window)target).getGraphicsConfiguration();
Rectangle sB = gc.getBounds();
Insets sIn = ((Window)target).getToolkit().getScreenInsets(gc);
Rectangle curBounds = getBounds();
int maxW = Math.max(sB.width - sIn.left - sIn.right, curBounds.width);
int maxH = Math.max(sB.height - sIn.top - sIn.bottom, curBounds.height);
// First make sure the size is withing the visible part of the screen
if (newW > maxW) {
newW = maxW;
}
if (newH > maxH) {
newH = maxH;
}
return new Rectangle(newX, newY, newW, newH);
}
/** /**
* @see java.awt.peer.ComponentPeer#setBounds * @see java.awt.peer.ComponentPeer#setBounds
*/ */
...@@ -651,12 +688,12 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -651,12 +688,12 @@ class XDecoratedPeer extends XWindowPeer {
} }
if (!isReparented() && isVisible() && runningWM != XWM.NO_WM if (!isReparented() && isVisible() && runningWM != XWM.NO_WM
&& !XWM.isNonReparentingWM() && !XWM.isNonReparentingWM()
&& getDecorations() != winAttr.AWT_DECOR_NONE) { && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
insLog.fine("- visible but not reparented, skipping"); insLog.fine("- visible but not reparented, skipping");
return; return;
} }
//Last chance to correct insets //Last chance to correct insets
if (!insets_corrected && getDecorations() != winAttr.AWT_DECOR_NONE) { if (!insets_corrected && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
long parent = XlibUtil.getParentWindow(window); long parent = XlibUtil.getParentWindow(window);
Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null; Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null;
if (insLog.isLoggable(Level.FINER)) { if (insLog.isLoggable(Level.FINER)) {
...@@ -824,7 +861,7 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -824,7 +861,7 @@ class XDecoratedPeer extends XWindowPeer {
fs &= ~(MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); fs &= ~(MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE);
} }
winAttr.functions = fs; winAttr.functions = fs;
XWM.setShellNotResizable(this, dimensions, dimensions.getScreenBounds(), false); XWM.setShellNotResizable(this, dimensions, dimensions.getBounds(), false);
} }
} }
...@@ -870,7 +907,7 @@ class XDecoratedPeer extends XWindowPeer { ...@@ -870,7 +907,7 @@ class XDecoratedPeer extends XWindowPeer {
return getSize().height; return getSize().height;
} }
public WindowDimensions getDimensions() { final public WindowDimensions getDimensions() {
return dimensions; return dimensions;
} }
......
...@@ -88,7 +88,8 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer { ...@@ -88,7 +88,8 @@ class XDialogPeer extends XDecoratedPeer implements DialogPeer {
} }
} }
private boolean isTargetUndecorated() { @Override
boolean isTargetUndecorated() {
if (undecorated != null) { if (undecorated != null) {
return undecorated.booleanValue(); return undecorated.booleanValue();
} else { } else {
......
/* /*
* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -48,8 +48,7 @@ class XDnDConstants { ...@@ -48,8 +48,7 @@ class XDnDConstants {
static final XAtom XA_XdndStatus = XAtom.get("XdndStatus"); static final XAtom XA_XdndStatus = XAtom.get("XdndStatus");
static final XAtom XA_XdndFinished = XAtom.get("XdndFinished"); static final XAtom XA_XdndFinished = XAtom.get("XdndFinished");
static final XSelection XDnDSelection = static final XSelection XDnDSelection = new XSelection(XA_XdndSelection);
new XSelection(XA_XdndSelection, null);
public static final int XDND_MIN_PROTOCOL_VERSION = 3; public static final int XDND_MIN_PROTOCOL_VERSION = 3;
public static final int XDND_PROTOCOL_VERSION = 5; public static final int XDND_PROTOCOL_VERSION = 5;
......
...@@ -647,12 +647,6 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener ...@@ -647,12 +647,6 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener
} }
if (isXEmbedActive()) { if (isXEmbedActive()) {
switch ((int)msg.get_data(1)) { switch ((int)msg.get_data(1)) {
case _SUN_XEMBED_START:
// Child has finished initialization and waits for notify
xembed.processXEmbedInfo();
notifyChildEmbedded();
break;
case XEMBED_REQUEST_FOCUS: case XEMBED_REQUEST_FOCUS:
requestXEmbedFocus(); requestXEmbedFocus();
break; break;
......
...@@ -74,7 +74,6 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher ...@@ -74,7 +74,6 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher
XToolkit.awtUnlock(); XToolkit.awtUnlock();
} }
} }
notifyReady();
} }
void handleClientMessage(XEvent xev) { void handleClientMessage(XEvent xev) {
...@@ -84,7 +83,6 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher ...@@ -84,7 +83,6 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher
if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Embedded message: " + msgidToString((int)msg.get_data(1))); if (xembedLog.isLoggable(Level.FINE)) xembedLog.fine("Embedded message: " + msgidToString((int)msg.get_data(1)));
switch ((int)msg.get_data(1)) { switch ((int)msg.get_data(1)) {
case XEMBED_EMBEDDED_NOTIFY: // Notification about embedding protocol start case XEMBED_EMBEDDED_NOTIFY: // Notification about embedding protocol start
// NOTE: May be called two times because we send _SUN_XEMBED_START
active = true; active = true;
server = getEmbedder(embedded, msg); server = getEmbedder(embedded, msg);
// Check if window is reparented. If not - it was created with // Check if window is reparented. If not - it was created with
...@@ -223,13 +221,4 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher ...@@ -223,13 +221,4 @@ public class XEmbedClientHelper extends XEmbedHelper implements XEventDispatcher
long getX11Mods(AWTKeyStroke stroke) { long getX11Mods(AWTKeyStroke stroke) {
return XWindow.getXModifiers(stroke); return XWindow.getXModifiers(stroke);
} }
void notifyReady() {
long wnd = server;
if (wnd == 0) {
// Server is still 0, get the parent
wnd = embedded.getParentWindowHandle();
}
sendMessage(wnd, _SUN_XEMBED_START);
}
} }
...@@ -58,7 +58,6 @@ public class XEmbedHelper { ...@@ -58,7 +58,6 @@ public class XEmbedHelper {
final static int XEMBED_REGISTER_ACCELERATOR = 12; final static int XEMBED_REGISTER_ACCELERATOR = 12;
final static int XEMBED_UNREGISTER_ACCELERATOR= 13; final static int XEMBED_UNREGISTER_ACCELERATOR= 13;
final static int XEMBED_ACTIVATE_ACCELERATOR = 14; final static int XEMBED_ACTIVATE_ACCELERATOR = 14;
final static int _SUN_XEMBED_START = 1119;
final static int NON_STANDARD_XEMBED_GTK_GRAB_KEY = 108; final static int NON_STANDARD_XEMBED_GTK_GRAB_KEY = 108;
final static int NON_STANDARD_XEMBED_GTK_UNGRAB_KEY = 109; final static int NON_STANDARD_XEMBED_GTK_UNGRAB_KEY = 109;
...@@ -151,8 +150,6 @@ public class XEmbedHelper { ...@@ -151,8 +150,6 @@ public class XEmbedHelper {
return "NON_STANDARD_XEMBED_GTK_UNGRAB_KEY"; return "NON_STANDARD_XEMBED_GTK_UNGRAB_KEY";
case NON_STANDARD_XEMBED_GTK_GRAB_KEY: case NON_STANDARD_XEMBED_GTK_GRAB_KEY:
return "NON_STANDARD_XEMBED_GTK_GRAB_KEY"; return "NON_STANDARD_XEMBED_GTK_GRAB_KEY";
case _SUN_XEMBED_START:
return "XEMBED_START";
case XConstants.KeyPress | XEmbedServerTester.SYSTEM_EVENT_MASK: case XConstants.KeyPress | XEmbedServerTester.SYSTEM_EVENT_MASK:
return "KeyPress"; return "KeyPress";
case XConstants.MapNotify | XEmbedServerTester.SYSTEM_EVENT_MASK: case XConstants.MapNotify | XEmbedServerTester.SYSTEM_EVENT_MASK:
......
...@@ -177,13 +177,6 @@ public class XEmbedServerTester implements XEventDispatcher { ...@@ -177,13 +177,6 @@ public class XEmbedServerTester implements XEventDispatcher {
embedCompletely(); embedCompletely();
} }
public void test3_2() {
embedCompletely();
int res = getEventPos();
sendMessage(XEmbedHelper._SUN_XEMBED_START);
waitEmbeddedNotify(res);
}
public void test3_3() { public void test3_3() {
reparent = true; reparent = true;
embedCompletely(); embedCompletely();
......
...@@ -184,6 +184,12 @@ public class XEmbeddedFramePeer extends XFramePeer { ...@@ -184,6 +184,12 @@ public class XEmbeddedFramePeer extends XFramePeer {
} }
} }
@Override
Rectangle constrainBounds(int x, int y, int width, int height) {
// We don't constrain the bounds of the EmbeddedFrames
return new Rectangle(x, y, width, height);
}
// don't use getBounds() inherited from XDecoratedPeer // don't use getBounds() inherited from XDecoratedPeer
public Rectangle getBounds() { public Rectangle getBounds() {
return new Rectangle(x, y, width, height); return new Rectangle(x, y, width, height);
......
/* /*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,15 +24,18 @@ ...@@ -24,15 +24,18 @@
*/ */
package sun.awt.X11; package sun.awt.X11;
import java.util.Vector; import java.awt.Color;
import java.awt.*; import java.awt.Dimension;
import java.awt.peer.*; import java.awt.Font;
import java.awt.event.*; import java.awt.FontMetrics;
import sun.awt.im.*; import java.awt.Frame;
import sun.awt.*; import java.awt.Graphics;
import java.util.logging.*; import java.awt.Insets;
import java.lang.reflect.Field; import java.awt.MenuBar;
import java.util.*; import java.awt.Rectangle;
import java.awt.peer.FramePeer;
import java.util.logging.Level;
import java.util.logging.Logger;
class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants {
private static Logger log = Logger.getLogger("sun.awt.X11.XFramePeer"); private static Logger log = Logger.getLogger("sun.awt.X11.XFramePeer");
...@@ -92,7 +95,8 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { ...@@ -92,7 +95,8 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants {
} }
} }
private boolean isTargetUndecorated() { @Override
boolean isTargetUndecorated() {
if (undecorated != null) { if (undecorated != null) {
return undecorated.booleanValue(); return undecorated.booleanValue();
} else { } else {
...@@ -285,19 +289,20 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants { ...@@ -285,19 +289,20 @@ class XFramePeer extends XDecoratedPeer implements FramePeer, XConstants {
* Let's see if this is a window state protocol message, and * Let's see if this is a window state protocol message, and
* if it is - decode a new state in terms of java constants. * if it is - decode a new state in terms of java constants.
*/ */
Integer newState = XWM.getWM().isStateChange(this, ev); if (!XWM.getWM().isStateChange(this, ev)) {
if (newState == null) { stateLog.finer("either not a state atom or state has not been changed");
return; return;
} }
int changed = state ^ newState.intValue(); final int newState = XWM.getWM().getState(this);
int changed = state ^ newState;
if (changed == 0) { if (changed == 0) {
stateLog.finer("State is the same: " + state); stateLog.finer("State is the same: " + state);
return; return;
} }
int old_state = state; int old_state = state;
state = newState.intValue(); state = newState;
if ((changed & Frame.ICONIFIED) != 0) { if ((changed & Frame.ICONIFIED) != 0) {
if ((state & Frame.ICONIFIED) != 0) { if ((state & Frame.ICONIFIED) != 0) {
......
/* /*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -218,7 +218,7 @@ public class XMenuItemPeer implements MenuItemPeer { ...@@ -218,7 +218,7 @@ public class XMenuItemPeer implements MenuItemPeer {
Font getTargetFont() { Font getTargetFont() {
if (target == null) { if (target == null) {
return XWindow.defaultFont; return XWindow.getDefaultFont();
} }
try { try {
return (Font)m_getFont.invoke(target, new Object[0]); return (Font)m_getFont.invoke(target, new Object[0]);
...@@ -227,7 +227,7 @@ public class XMenuItemPeer implements MenuItemPeer { ...@@ -227,7 +227,7 @@ public class XMenuItemPeer implements MenuItemPeer {
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
return XWindow.defaultFont; return XWindow.getDefaultFont();
} }
String getTargetLabel() { String getTargetLabel() {
......
/* /*
* Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,17 +26,15 @@ ...@@ -26,17 +26,15 @@
package sun.awt.X11; package sun.awt.X11;
import java.awt.*; import java.awt.Frame;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.logging.LogManager;
import java.awt.*;
import java.awt.image.*;
import java.util.*;
class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { final class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol
final static Logger log = Logger.getLogger("sun.awt.X11.XNETProtocol"); {
private final static Logger log = Logger.getLogger("sun.awt.X11.XNETProtocol");
private final static Logger iconLog = Logger.getLogger("sun.awt.X11.icon.XNETProtocol"); private final static Logger iconLog = Logger.getLogger("sun.awt.X11.icon.XNETProtocol");
private static Logger stateLog = Logger.getLogger("sun.awt.X11.states.XNETProtocol");
/** /**
* XStateProtocol * XStateProtocol
...@@ -276,6 +274,7 @@ class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol { ...@@ -276,6 +274,7 @@ class XNETProtocol extends XProtocol implements XStateProtocol, XLayerProtocol {
boolean doStateProtocol() { boolean doStateProtocol() {
boolean res = active() && checkProtocol(XA_NET_SUPPORTED, XA_NET_WM_STATE); boolean res = active() && checkProtocol(XA_NET_SUPPORTED, XA_NET_WM_STATE);
stateLog.finer("doStateProtocol() returns " + res);
return res; return res;
} }
......
/* /*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -187,7 +187,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer { ...@@ -187,7 +187,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer {
//Fix for 6267144: PIT: Popup menu label is not shown, XToolkit //Fix for 6267144: PIT: Popup menu label is not shown, XToolkit
Font getTargetFont() { Font getTargetFont() {
if (popupMenuTarget == null) { if (popupMenuTarget == null) {
return XWindow.defaultFont; return XWindow.getDefaultFont();
} }
try { try {
return (Font)m_getFont.invoke(popupMenuTarget, new Object[0]); return (Font)m_getFont.invoke(popupMenuTarget, new Object[0]);
...@@ -196,7 +196,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer { ...@@ -196,7 +196,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer {
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
return XWindow.defaultFont; return XWindow.getDefaultFont();
} }
String getTargetLabel() { String getTargetLabel() {
......
/* /*
* Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,11 +25,9 @@ ...@@ -25,11 +25,9 @@
package sun.awt.X11; package sun.awt.X11;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.InputEvent;
import java.awt.peer.*; import java.awt.event.MouseEvent;
import java.beans.PropertyChangeListener; import java.awt.datatransfer.Clipboard;
import sun.awt.*;
import java.util.*;
import java.awt.dnd.DragSource; import java.awt.dnd.DragSource;
import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureEvent;
...@@ -37,20 +35,27 @@ import java.awt.dnd.DragGestureRecognizer; ...@@ -37,20 +35,27 @@ import java.awt.dnd.DragGestureRecognizer;
import java.awt.dnd.MouseDragGestureRecognizer; import java.awt.dnd.MouseDragGestureRecognizer;
import java.awt.dnd.InvalidDnDOperationException; import java.awt.dnd.InvalidDnDOperationException;
import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.image.*;
import java.security.*;
import java.awt.im.InputMethodHighlight; import java.awt.im.InputMethodHighlight;
import java.awt.im.spi.InputMethodDescriptor; import java.awt.im.spi.InputMethodDescriptor;
import java.awt.datatransfer.Clipboard; import java.awt.image.ColorModel;
import java.awt.peer.*;
import java.beans.PropertyChangeListener;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.LookAndFeel; import javax.swing.LookAndFeel;
import javax.swing.UIDefaults; import javax.swing.UIDefaults;
import java.util.logging.*; import sun.awt.*;
import sun.font.FontManager; import sun.font.FontManager;
import sun.misc.PerformanceLogger; import sun.misc.PerformanceLogger;
import sun.print.PrintJob2D; import sun.print.PrintJob2D;
import java.lang.reflect.*;
public class XToolkit extends UNIXToolkit implements Runnable, XConstants { public final class XToolkit extends UNIXToolkit implements Runnable, XConstants
{
private static Logger log = Logger.getLogger("sun.awt.X11.XToolkit"); private static Logger log = Logger.getLogger("sun.awt.X11.XToolkit");
private static Logger eventLog = Logger.getLogger("sun.awt.X11.event.XToolkit"); private static Logger eventLog = Logger.getLogger("sun.awt.X11.event.XToolkit");
private static final Logger timeoutTaskLog = Logger.getLogger("sun.awt.X11.timeoutTask.XToolkit"); private static final Logger timeoutTaskLog = Logger.getLogger("sun.awt.X11.timeoutTask.XToolkit");
...@@ -1871,9 +1876,7 @@ public class XToolkit extends UNIXToolkit implements Runnable, XConstants { ...@@ -1871,9 +1876,7 @@ public class XToolkit extends UNIXToolkit implements Runnable, XConstants {
} }
public boolean isAlwaysOnTopSupported() { public boolean isAlwaysOnTopSupported() {
Iterator iter = XWM.getWM().getProtocols(XLayerProtocol.class).iterator(); for (XLayerProtocol proto : XWM.getWM().getProtocols(XLayerProtocol.class)) {
while (iter.hasNext()) {
XLayerProtocol proto = (XLayerProtocol)iter.next();
if (proto.supportsLayer(XLayerProtocol.LAYER_ALWAYS_ON_TOP)) { if (proto.supportsLayer(XLayerProtocol.LAYER_ALWAYS_ON_TOP)) {
return true; return true;
} }
......
/* /*
* Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,11 +31,8 @@ import java.awt.peer.TrayIconPeer; ...@@ -31,11 +31,8 @@ import java.awt.peer.TrayIconPeer;
import sun.awt.*; import sun.awt.*;
import java.awt.image.*; import java.awt.image.*;
import java.text.BreakIterator; import java.text.BreakIterator;
import java.util.Vector;
import java.lang.reflect.Field;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.AbstractQueue;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
...@@ -629,7 +626,7 @@ public class XTrayIconPeer implements TrayIconPeer { ...@@ -629,7 +626,7 @@ public class XTrayIconPeer implements TrayIconPeer {
final static int TOOLTIP_MAX_LENGTH = 64; final static int TOOLTIP_MAX_LENGTH = 64;
final static int TOOLTIP_MOUSE_CURSOR_INDENT = 5; final static int TOOLTIP_MOUSE_CURSOR_INDENT = 5;
final static Color TOOLTIP_BACKGROUND_COLOR = new Color(255, 255, 220); final static Color TOOLTIP_BACKGROUND_COLOR = new Color(255, 255, 220);
final static Font TOOLTIP_TEXT_FONT = XWindow.defaultFont; final static Font TOOLTIP_TEXT_FONT = XWindow.getDefaultFont();
Tooltip(XTrayIconPeer xtiPeer, Frame parent) { Tooltip(XTrayIconPeer xtiPeer, Frame parent) {
super(parent, Color.black); super(parent, Color.black);
......
...@@ -102,4 +102,9 @@ class MDialogPeer extends MWindowPeer implements DialogPeer, MInputMethodControl ...@@ -102,4 +102,9 @@ class MDialogPeer extends MWindowPeer implements DialogPeer, MInputMethodControl
public void blockWindows(java.util.List<Window> toBlock) { public void blockWindows(java.util.List<Window> toBlock) {
// do nothing // do nothing
} }
@Override
final boolean isTargetUndecorated() {
return ((Dialog)target).isUndecorated();
}
} }
...@@ -204,4 +204,10 @@ public class MEmbeddedFramePeer extends MFramePeer { ...@@ -204,4 +204,10 @@ public class MEmbeddedFramePeer extends MFramePeer {
} }
public native Rectangle getBoundsPrivate(); public native Rectangle getBoundsPrivate();
@Override
Rectangle constrainBounds(int x, int y, int width, int height) {
// We don't constrain the bounds of the EmbeddedFrames
return new Rectangle(x, y, width, height);
}
} }
...@@ -503,4 +503,9 @@ class MFramePeer extends MWindowPeer implements FramePeer, MInputMethodControl { ...@@ -503,4 +503,9 @@ class MFramePeer extends MWindowPeer implements FramePeer, MInputMethodControl {
public Rectangle getBoundsPrivate() { public Rectangle getBoundsPrivate() {
return getBounds(); return getBounds();
} }
@Override
final boolean isTargetUndecorated() {
return ((Frame)target).isUndecorated();
}
} }
...@@ -63,15 +63,8 @@ ...@@ -63,15 +63,8 @@
#define CLOSEIO #define CLOSEIO
#endif /* NO_INTERRUPTIBLE_IO */ #endif /* NO_INTERRUPTIBLE_IO */
/* /* Get typedef for rlim_t */
* Linux <sys/resource.h> does not define rlim_t (solaris #include <sys/resource.h>
* does). THIS IS PROBABLY NOT THE RIGHT THING TO DO, so
* somebody please fix this.
*/
#ifdef __linux__
typedef int rlim_t ;
#endif
#ifdef CLOSEIO #ifdef CLOSEIO
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册