提交 86f3d091 编写于 作者: S sherman

Merge

......@@ -66,3 +66,6 @@ b3c69282f6d3c90ec21056cd1ab70dc0c895b069 jdk7-b88
4a6abb7e224cc8d9a583c23c5782e4668739a119 jdk7-b89
7f90d0b9dbb7ab4c60d0b0233e4e77fb4fac597c jdk7-b90
08a31cab971fcad4695e913d0f3be7bde3a90747 jdk7-b91
f2dce7210cc00453c23e53edeec7156f112ca382 jdk7-b92
219b84b9533ae4fe3c6c2083f8a8962cb579f1de jdk7-b93
cf44386c8fe3fbdb9da14346be25d19fd1092f71 jdk7-b94
......@@ -152,7 +152,7 @@ $(UNPACK_EXE): $(UNPACK_EXE_FILES_o) updatefiles winres
$(prep-target)
$(LINKER) $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
ifdef MT
$(MT) /manifest $(TEMPDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
$(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
endif
$(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE)
$(install-module-file)
......
......@@ -86,6 +86,11 @@ ifeq ($(ARCH_DATA_MODEL), 32)
MSVCPNN_DLL = msvcp90.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
endif
ifeq ($(COMPILER_VERSION), VS2010)
MSVCRNN_DLL = msvcr100.dll
MSVCPNN_DLL = msvcp100.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
endif
endif
ifeq ($(ARCH_DATA_MODEL), 64)
......@@ -94,6 +99,11 @@ ifeq ($(ARCH_DATA_MODEL), 64)
MSVCPNN_DLL = msvcp90.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
endif
ifeq ($(COMPILER_VERSION), VS2010)
MSVCRNN_DLL = msvcr100.dll
MSVCPNN_DLL = msvcp100.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
endif
endif
EXTRA_LFLAGS += /LIBPATH:$(DXSDK_LIB_PATH)
......@@ -155,6 +165,7 @@ ifeq ($(CC_VERSION),msvc)
# Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
AUTOMATIC_PCH_OPTION =
GX_OPTION = -GX
GZ_OPTION = -GZ
ifeq ($(ARCH_DATA_MODEL), 32)
CC_OPT/HIGHEST = -Ox -Gy -Os -GB
CC_OPT/HIGHER = -Ox -Gy -Os -GB
......@@ -171,6 +182,7 @@ ifeq ($(CC_VERSION),msvc)
AUTOMATIC_PCH_OPTION = -YX
# Also known as VC7 compiler
GX_OPTION = -GX
GZ_OPTION = -GZ
ifeq ($(ARCH_DATA_MODEL), 32)
# Lowered opt level to try and reduce footprint, dll size especially.
# Was: CC_OPT/HIGHEST = -O2 -G6
......@@ -190,6 +202,7 @@ ifeq ($(CC_VERSION),msvc)
AUTOMATIC_PCH_OPTION =
# VS2005 compiler, only with Platform SDK right now?
GX_OPTION = -EHsc
GZ_OPTION = -RTC1
ifeq ($(ARCH_DATA_MODEL), 32)
CC_OPT/HIGHEST = -O2
CC_OPT/HIGHER = -O1
......@@ -204,6 +217,23 @@ ifeq ($(CC_VERSION),msvc)
# Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
AUTOMATIC_PCH_OPTION =
GX_OPTION = -EHsc
GZ_OPTION = -RTC1
ifeq ($(ARCH_DATA_MODEL), 32)
CC_OPT/HIGHEST = -O2
CC_OPT/HIGHER = -O1
CC_OPT/LOWER = -O1
else
CC_OPT/HIGHEST = -O2
CC_OPT/HIGHER = -O1
CC_OPT/LOWER = -O1
endif
endif
ifeq ($(COMPILER_VERSION), VS2010)
# Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
AUTOMATIC_PCH_OPTION =
GX_OPTION = -EHsc
GZ_OPTION = -RTC1
ifeq ($(ARCH_DATA_MODEL), 32)
CC_OPT/HIGHEST = -O2
CC_OPT/HIGHER = -O1
......@@ -282,6 +312,13 @@ ifeq ($(CC_VERSION),msvc)
CFLAGS_OPT = $(CC_OPT)
CFLAGS_DBG = -Od $(MS_RUNTIME_DEBUG_OPTION)
# REMIND: I don't see where CFLAGS_VS2005 is used. I suspect its
# pulled in as a combined "CFLAGS_$(COMPILER_VERSION)" string
# but the lack of this isn't causing any apparent build problems
# with VS 2010 but it could be causing compiler warnings.
# For now, I will add it for all cases :
CFLAGS_VS2010 += -Zc:wchar_t-
#
# Starting from VS2005 the wchar_t is handled as a built-in C/C++ data type
# by default. However, we expect the wchar_t to be a typedef to the
# unsigned short data type. The -Zc:wchar_t- option restores the old
......@@ -317,6 +354,7 @@ ifeq ($(CC_VERSION),msvc)
# VS2008 has bufferoverflow baked in:
LFLAGS_VS2008 =
LFLAGS_VS2010 =
# LFLAGS are the flags given to $(LINK) and used to build the actual DLL file
BASELFLAGS = -nologo /opt:REF /incremental:no
......
......@@ -357,6 +357,9 @@ initial-module-image-jdk:: initial-module-image-jdk-setup \
$(MKDIR) -p $(JDK_MODULE_IMAGE_DIR)/bin
$(CP) $(BINDIR)/*$(EXE_SUFFIX) $(JDK_MODULE_IMAGE_DIR)/bin
$(CP) $(BINDIR)/jli.$(LIBRARY_SUFFIX) $(JDK_MODULE_IMAGE_DIR)/bin
ifeq ($(COMPILER_VERSION), VS2010)
$(CP) $(BINDIR)/msvc*100.$(LIBRARY_SUFFIX) $(JDK_MODULE_IMAGE_DIR)/bin
endif
ifeq ($(ARCH_DATA_MODEL), 32)
ifeq ($(COMPILER_VERSION), VS2003)
$(CP) $(BINDIR)/msvc*71.$(LIBRARY_SUFFIX) $(JDK_MODULE_IMAGE_DIR)/bin
......
......@@ -749,6 +749,8 @@ initial-image-jre-sol64:: initial-image-jre-setup \
$(RM) `$(FIND) $(JRE_IMAGE_DIR)/lib -name 'ir.idl'`
# Construct an initial jre image (initial jdk jre) no trimming or stripping
# See "initial-image-jdk-setup" for an explanation of the rm of
# drive names like C:
initial-image-jre:: initial-image-jre-setup \
$(JRE_LICENSES) $(JRE_DOCFILES) \
$(RT_JAR) $(RESOURCES_JAR) $(JSSE_JAR) \
......@@ -759,6 +761,10 @@ initial-image-jre:: initial-image-jre-setup \
$(MKDIR) -p $(JRE_IMAGE_DIR)/lib/applet
@# Copy in lib directory
$(CD) $(OUTPUTDIR) && $(FIND) lib -depth | $(CPIO) -pdum $(JRE_IMAGE_DIR)
ifeq ($(USING_CYGWIN),true)
$(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]:
$(RM) -rf $(OUTPUTDIR)/[A-Za-z]:
endif
@# Make sure all directories are read/execute for everyone
$(CHMOD) a+rx `$(FIND) $(JRE_IMAGE_DIR) -type d`
@# Remove some files from the jre area
......@@ -858,11 +864,27 @@ endif
######################################################
# Note: cpio ($(CPIO)) sometimes leaves directories without rx access.
# REMIND: the $(RM) calls for patterns like c:, d: following $(CPIO)
# are because the 1.7.x versions of cygwin's cpio command drops these
# in the working directory if the output path begins with that pattern
# The one for the output jre subdirectory gets there because cpio sees its
# own dropping in the input jre subdirectory. Need to remove both of these.
# We can remove these RM's if someone figures out how to stop cpio from
# leaving these there.
# Note that its a real problem not because this directory can end up in the
# bundle (I think it won't since it not in bin or lib and those are the
# only places from which we copy everything), but because the presence
# of this file causes cygwin's find to bomb out, thus breaking the build
# in "install".
initial-image-jdk-setup:
$(RM) -r $(JDK_IMAGE_DIR)
$(MKDIR) -p $(JDK_IMAGE_DIR)/jre
($(CD) $(JRE_IMAGE_DIR) && $(FIND) . -depth -print \
| $(CPIO) -pdum $(JDK_IMAGE_DIR)/jre )
ifeq ($(USING_CYGWIN),true)
$(RM) -rf $(JRE_IMAGE_DIR)/[A-Za-z]:
$(RM) -rf $(JDK_IMAGE_DIR)/jre/[A-Za-z]:
endif
$(RM) -rf $(JDK_IMAGE_DIR)/jre/man
$(CHMOD) a+rx `$(FIND) $(JDK_IMAGE_DIR) -type d`
......@@ -923,6 +945,9 @@ initial-image-jdk:: initial-image-jdk-setup \
$(MKDIR) -p $(JDK_IMAGE_DIR)/bin
$(CP) $(BINDIR)/*$(EXE_SUFFIX) $(JDK_IMAGE_DIR)/bin
$(CP) $(BINDIR)/jli.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin
ifeq ($(COMPILER_VERSION), VS2010)
$(CP) $(BINDIR)/msvc*100.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin
endif
ifeq ($(ARCH_DATA_MODEL), 32)
ifeq ($(COMPILER_VERSION), VS2003)
$(CP) $(BINDIR)/msvc*71.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin
......
......@@ -67,7 +67,7 @@ ifeq ($(PLATFORM), windows)
COMPILER_VERSION=VS2005
REBASE = $(COMPILER_PATH)../../Common8/Tools/Bin/rebase
MTL = $(COMPILER_PATH)../../Common8/Tools/Bin/midl
MT = $(MSDEVTOOLS_PATH)mt
MT = $(MSDEVTOOLS_PATH)/mt
ifndef COMPILER_PATH
COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
endif
......@@ -83,6 +83,17 @@ ifeq ($(PLATFORM), windows)
COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
endif
endif
ifeq ($(CC_MAJORVER), 16)
COMPILER_NAME=Visual Studio 10
COMPILER_VERSION=VS2010
#rebase and midl moved out of Visual Studio into the SDK:
REBASE = $(MSDEVTOOLS_PATH)/rebase
MTL = $(MSDEVTOOLS_PATH)/midl.exe
MT = $(MSDEVTOOLS_PATH)mt
ifndef COMPILER_PATH
COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
endif
endif
else
# else ARCH_DATA_MODEL is 64
LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
......@@ -122,6 +133,15 @@ ifeq ($(PLATFORM), windows)
COMPILER_VERSION=VS2008
RC = $(MSSDK61)/Bin/X64/rc.exe
MT = $(MSSDK61)/Bin/X64/mt.exe
MTL = $(MSSDK61)/Bin/X64/midl.exe
endif
ifeq ($(CC_MAJORVER), 16)
COMPILER_NAME=Microsoft Visual Studio 10 (16.00.30319.01)
COMPILER_VERSION=VS2010
RC = $(MSDEVTOOLS_PATH)/Bin/x64/rc.exe
RSC = $(MSDEVTOOLS_PATH)/Bin/x64/rc.exe
MT = $(MSDEVTOOLS_PATH)/Bin/x64/mt.exe
MTL = $(MSDEVTOOLS_PATH)/Bin/X64/midl.exe
endif
# This will cause problems if ALT_COMPILER_PATH is defined to ""
# which is a directive to use the PATH.
......
......@@ -165,10 +165,10 @@ ifeq ($(PLATFORM), windows)
REQUIRED_DXSDK_VER = 0x0900
ifeq ($(CC_VERSION),msvc)
ifeq ($(ARCH_DATA_MODEL), 32)
REQUIRED_COMPILER_NAME = Visual Studio 9
REQUIRED_COMPILER_VERSION = VS2008
REQUIRED_CC_VER = 15.00.21022.08
REQUIRED_LINK_VER = 9.00.21022.08
REQUIRED_COMPILER_NAME = Visual Studio 10
REQUIRED_COMPILER_VERSION = VS2010
REQUIRED_CC_VER = 16.00.30319.01
REQUIRED_LINK_VER = 10.00.30319.01
else
ifeq ($(ARCH), ia64)
REQUIRED_COMPILER_NAME = Microsoft Platform SDK - November 2001 Edition
......@@ -177,10 +177,10 @@ ifeq ($(PLATFORM), windows)
REQUIRED_LINK_VER = 7.00.9337.7
endif
ifeq ($(ARCH), amd64)
REQUIRED_COMPILER_NAME = Microsoft Windows SDK with Visual Studio 9 (6001.18000.367)
REQUIRED_COMPILER_VERSION = VS2008
REQUIRED_CC_VER = 15.00.21022.08
REQUIRED_LINK_VER = 9.00.21022.08
REQUIRED_COMPILER_NAME = Visual Studio 10
REQUIRED_COMPILER_VERSION = VS2010
REQUIRED_CC_VER = 16.00.30319.01
REQUIRED_LINK_VER = 10.00.30319.01
endif
endif
endif
......
......@@ -248,26 +248,34 @@ ifeq ($(ARCH_DATA_MODEL), 32)
# If we still don't have it, look for VSnnCOMNTOOLS (newest first),
# set by installer?
ifeq ($(_msvc_dir),)
ifdef VS90COMNTOOLS # /Common/Tools directory, use ../../Vc
xVS90COMNTOOLS :="$(subst \,/,$(VS90COMNTOOLS))"
_vs90tools :=$(call FullPath,$(xVS90COMNTOOLS))
ifdef VS100COMNTOOLS # /Common/Tools directory, use ../../Vc
xVS100COMNTOOLS :="$(subst \,/,$(VS100COMNTOOLS))"
_vs100tools :=$(call FullPath,$(xVS100COMNTOOLS))
endif
ifneq ($(_vs90tools),)
_msvc_dir :=$(_vs90tools)/../../Vc
ifneq ($(_vs100tools),)
_msvc_dir :=$(_vs100tools)/../../Vc
else
ifdef VS80COMNTOOLS # /Common/Tools directory, use ../../Vc
xVS80COMNTOOLS :="$(subst \,/,$(VS80COMNTOOLS))"
_vs80tools :=$(call FullPath,$(xVS80COMNTOOLS))
ifdef VS90COMNTOOLS # /Common/Tools directory, use ../../Vc
xVS90COMNTOOLS :="$(subst \,/,$(VS90COMNTOOLS))"
_vs90tools :=$(call FullPath,$(xVS90COMNTOOLS))
endif
ifneq ($(_vs80tools),)
_msvc_dir :=$(_vs80tools)/../../Vc
ifneq ($(_vs90tools),)
_msvc_dir :=$(_vs90tools)/../../Vc
else
ifdef VS71COMNTOOLS # /Common/Tools directory, use ../../Vc7
xVS71COMNTOOLS :="$(subst \,/,$(VS71COMNTOOLS))"
_vs71tools :=$(call FullPath,$(xVS71COMNTOOLS))
ifdef VS80COMNTOOLS # /Common/Tools directory, use ../../Vc
xVS80COMNTOOLS :="$(subst \,/,$(VS80COMNTOOLS))"
_vs80tools :=$(call FullPath,$(xVS80COMNTOOLS))
endif
ifneq ($(_vs71tools),)
_msvc_dir :=$(_vs71tools)/../../Vc7
ifneq ($(_vs80tools),)
_msvc_dir :=$(_vs80tools)/../../Vc
else
ifdef VS71COMNTOOLS # /Common/Tools directory, use ../../Vc7
xVS71COMNTOOLS :="$(subst \,/,$(VS71COMNTOOLS))"
_vs71tools :=$(call FullPath,$(xVS71COMNTOOLS))
endif
ifneq ($(_vs71tools),)
_msvc_dir :=$(_vs71tools)/../../Vc7
endif
endif
endif
endif
......@@ -276,12 +284,19 @@ ifeq ($(ARCH_DATA_MODEL), 32)
_compiler_bin :=$(_msvc_dir)/Bin
# Assume PlatformSDK is in VS71 (will be empty if VS90)
_ms_sdk :=$(call FullPath,$(_msvc_dir)/PlatformSDK)
# Assume VS90, then VS80, then VS71
_redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC90.CRT)
# Assume VS100, then VS90, then VS80, then VS71
_redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC100.CRT)
ifeq ($(_redist_sdk),)
_redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC80.CRT)
ifeq ($(_redist_sdk),)
_redist_sdk :=$(call FullPath,$(_msvc_dir)/../SDK/v1.1/Bin)
ifneq ($(VS100COMNTOOLS),)
_redist_sdk :=c:/windows/system32
else
_redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC90.CRT)
ifeq ($(_redist_sdk),)
_redist_sdk :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC80.CRT)
ifeq ($(_redist_sdk),)
_redist_sdk :=$(call FullPath,$(_msvc_dir)/../SDK/v1.1/Bin)
endif
endif
endif
endif
endif
......@@ -316,23 +331,40 @@ ifeq ($(_ms_sdk),)
endif
endif
# Compilers for 64bit are from SDK
# Compilers for 64bit may be from SDK. For VS 2010 we use those.
# The Express compilers don't contain 64 bit compilers, so in
# that case, you additionally need the SDK. At this time,
# there's no 64 bit SDK available that has VS 2010.
# Presumably SDK v7.1 will provide that and we may want to update
# the logic here to work with that.
# However official builds will use the Professional version.
ifeq ($(ARCH_DATA_MODEL), 64)
xVS2008 :="$(_program_files32)/Microsoft Visual Studio 9.0/"
VS2008 :=$(call FullPath,$(xVS2008))
ifneq ($(VS2008),)
_compiler_bin :=$(VS2008)/VC/Bin/$(ARCH)
xMSSDK61 :="$(_program_files)/Microsoft SDKs/Windows/v6.1/"
MSSDK61 :=$(call FullPath,$(xMSSDK61))
_redist_sdk :=$(VS2008)/VC/redist/x86/Microsoft.VC90.CRT
ifdef VS100COMNTOOLS # /Common7/Tools directory, use ../../Vc
xVS100COMNTOOLS :="$(subst \,/,$(VS100COMNTOOLS))"
_vs100tools :=$(call FullPath,$(xVS100COMNTOOLS))
endif
ifneq ($(_vs100tools),)
_compiler_bin :=$(_vs100tools)/../../Vc/bin/amd64
_redist_sdk :=$(_vs100tools)/../../Vc/redist/x64/Microsoft.VC100.CRT
xMSSDK70 :="$(_program_files32)/Microsoft SDKs/Windows/v7.0a/"
MSSDK70 :=$(call FullPath,$(xMSSDK70))
else
ifneq ($(_ms_sdk),)
ifeq ($(ARCH), ia64)
_compiler_bin :=$(_ms_sdk)/Bin/Win64
endif
ifeq ($(ARCH), amd64)
_compiler_bin :=$(_ms_sdk)/Bin/Win64/x86/$(ARCH)
_redist_sdk :=$(_ms_sdk)/redist/win64/AMD64
xVS2008 :="$(_program_files32)/Microsoft Visual Studio 9.0/"
VS2008 :=$(call FullPath,$(xVS2008))
ifneq ($(VS2008),)
_compiler_bin :=$(VS2008)/VC/Bin/$(ARCH)
xMSSDK61 :="$(_program_files)/Microsoft SDKs/Windows/v6.1/"
MSSDK61 :=$(call FullPath,$(xMSSDK61))
_redist_sdk :=$(VS2008)/VC/redist/x86/Microsoft.VC90.CRT
else
ifneq ($(_ms_sdk),)
ifeq ($(ARCH), ia64)
_compiler_bin :=$(_ms_sdk)/Bin/Win64
endif
ifeq ($(ARCH), amd64)
_compiler_bin :=$(_ms_sdk)/Bin/Win64/x86/$(ARCH)
_redist_sdk :=$(_ms_sdk)/redist/win64/AMD64
endif
endif
endif
endif
......@@ -454,10 +486,14 @@ MSVCRT_DLL_PATH:=$(call AltCheckValue,MSVCRT_DLL_PATH)
ifeq ($(ARCH_DATA_MODEL), 32)
_NEEDS_MSVCRNN = true
else
ifeq ($(VS2008),)
_NEEDS_MSVCRNN = false
else
ifneq ($(VS2010),)
_NEEDS_MSVCRNN = true
else
ifneq ($(VS2008),)
_NEEDS_MSVCRNN = true
else
_NEEDS_MSVCRNN = false
endif
endif
endif
......@@ -557,6 +593,17 @@ else
endif
CSCRIPT:=$(call AltCheckSpaces,CSCRIPT)
# CABARC: path to cabarc.exe (used in creating install bundles)
ifdef ALT_CABARC
xALT_CABARC :="$(subst \,/,$(ALT_CABARC))"
CABARC =$(xALT_CABARC)
else
_CABARC1 :=$(_system_root)/system32/cabarc.exe
_CABARC2 :=$(DEVTOOLS_PATH)cabarc.exe
CABARC :=$(call FileExists,$(_CABARC1),$(_CABARC2))
endif
CABARC:=$(call AltCheckSpaces,CABARC)
# MSIVAL2: path to msival2.exe (used in validating install msi files)
ifdef ALT_MSIVAL2
xALT_MSIVAL2 :="$(subst \,/,$(ALT_MSIVAL2))"
......
......@@ -295,7 +295,12 @@ ifeq ($(PLATFORM), windows)
endif
ARCH_FAMILY = $(ARCH)
# Where is unwanted output to be delivered?
DEV_NULL = NUL
# MKS uses the special file "NUL", cygwin uses the customary unix file.
ifeq ($(USING_CYGWIN),true)
DEV_NULL = /dev/null
else
DEV_NULL = NUL
endif
export DEV_NULL
# Classpath separator
CLASSPATH_SEPARATOR = ;
......
......@@ -52,6 +52,11 @@ ifeq ($(ARCH_DATA_MODEL), 32)
ifeq ($(PLATFORM), windows)
# If this is the VS Express compiler it will lack vc/atlmfc/
ATL_MFC_DIR :=$(call DirExists,$(COMPILER_PATH)/../atlmfc,,)
ifneq ($(ATL_MFC_DIR),)
include FILES_c_windows.gmk
vpath %.cpp $(PLATFORM_SRC)/native/sun/jkernel
......@@ -67,6 +72,8 @@ endif
endif
endif
#
# Resources
#
......
......@@ -79,4 +79,5 @@ FILES_c = \
gtk2_interface.c \
swing_GTKEngine.c \
swing_GTKStyle.c \
rect.c
rect.c \
sun_awt_X11_GtkFileDialogPeer.c
......@@ -33,4 +33,5 @@ FILES_export = \
sun/awt/X11/XDesktopPeer.java \
sun/awt/X11/XToolkit.java \
sun/awt/X11/XComponentPeer.java \
sun/awt/X11/XInputMethod.java
sun/awt/X11/XInputMethod.java \
sun/awt/X11/GtkFileDialogPeer.java
......@@ -172,6 +172,7 @@ SUNWprivate_1.1 {
Java_sun_awt_UNIXToolkit_load_1stock_1icon;
Java_sun_awt_UNIXToolkit_load_1gtk_1icon;
Java_sun_awt_UNIXToolkit_nativeSync;
Java_sun_awt_UNIXToolkit_gtkCheckVersionImpl;
Java_java_awt_AWTEvent_initIDs;
Java_java_awt_event_InputEvent_initIDs;
Java_java_awt_event_KeyEvent_initIDs;
......@@ -396,6 +397,9 @@ SUNWprivate_1.1 {
Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue;
Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName;
Java_sun_awt_X11_GtkFileDialogPeer_run;
Java_sun_awt_X11_GtkFileDialogPeer_quit;
Java_sun_print_CUPSPrinter_initIDs;
Java_sun_print_CUPSPrinter_getCupsServer;
Java_sun_print_CUPSPrinter_getCupsPort;
......
......@@ -33,14 +33,16 @@
#include "defines.h"
#ifdef _MSC_VER
#if _MSC_VER > 1400
#if _MSC_VER > 1400 && _MSC_VER < 1600
/*
* When building for Microsoft Windows, main has a dependency on msvcr??.dll.
*
* When using Visual Studio 2005 or later, that must be recorded in
* When using Visual Studio 2005 or 2008, that must be recorded in
* the [java,javaw].exe.manifest file.
*
* As of VS2010 (ver=1600), the runtimes again no longer need manifests.
*
* Reference:
* C:/Program Files/Microsoft SDKs/Windows/v6.1/include/crtdefs.h
*/
......@@ -67,7 +69,7 @@
"publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
#endif /* _M_AMD64 */
#endif /* _MSC_VER > 1400 */
#endif /* _MSC_VER > 1400 && _MSC_VER < 1600 */
#endif /* _MSC_VER */
/*
......
......@@ -1163,8 +1163,14 @@ public final class NumericShaper implements java.io.Serializable {
lastkey = newkey;
ctxKey = newkey;
if (((mask & EASTERN_ARABIC) != 0) && (ctxKey == ARABIC_KEY || ctxKey == EASTERN_ARABIC_KEY)) {
if (((mask & EASTERN_ARABIC) != 0) &&
(ctxKey == ARABIC_KEY ||
ctxKey == EASTERN_ARABIC_KEY)) {
ctxKey = EASTERN_ARABIC_KEY;
} else if (((mask & ARABIC) != 0) &&
(ctxKey == ARABIC_KEY ||
ctxKey == EASTERN_ARABIC_KEY)) {
ctxKey = ARABIC_KEY;
} else if ((mask & (1<<ctxKey)) == 0) {
ctxKey = EUROPEAN_KEY;
}
......
......@@ -1330,8 +1330,9 @@ public class JEditorPane extends JTextComponent {
*/
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
JViewport port = (JViewport) parent;
TextUI ui = getUI();
int prefWidth = d.width;
int prefHeight = d.height;
......@@ -1452,8 +1453,9 @@ public class JEditorPane extends JTextComponent {
* match its own, false otherwise
*/
public boolean getScrollableTracksViewportWidth() {
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
JViewport port = (JViewport) parent;
TextUI ui = getUI();
int w = port.getWidth();
Dimension min = ui.getMinimumSize(this);
......@@ -1474,8 +1476,9 @@ public class JEditorPane extends JTextComponent {
* false otherwise
*/
public boolean getScrollableTracksViewportHeight() {
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
JViewport port = (JViewport) parent;
TextUI ui = getUI();
int h = port.getHeight();
Dimension min = ui.getMinimumSize(this);
......
......@@ -163,18 +163,6 @@ public final class JLayer<V extends Component>
private static final LayerEventController eventController =
new LayerEventController();
private static final long ACCEPTED_EVENTS =
AWTEvent.COMPONENT_EVENT_MASK |
AWTEvent.CONTAINER_EVENT_MASK |
AWTEvent.FOCUS_EVENT_MASK |
AWTEvent.KEY_EVENT_MASK |
AWTEvent.MOUSE_WHEEL_EVENT_MASK |
AWTEvent.MOUSE_MOTION_EVENT_MASK |
AWTEvent.MOUSE_EVENT_MASK |
AWTEvent.INPUT_METHOD_EVENT_MASK |
AWTEvent.HIERARCHY_EVENT_MASK |
AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK;
/**
* Creates a new {@code JLayer} object with a {@code null} view component
* and {@code null} {@link javax.swing.plaf.LayerUI}.
......@@ -396,24 +384,14 @@ public final class JLayer<V extends Component>
}
/**
* Sets the bitmask of event types to receive by this {@code JLayer}.
* Here is the list of the supported event types:
* <ul>
* <li>AWTEvent.COMPONENT_EVENT_MASK</li>
* <li>AWTEvent.CONTAINER_EVENT_MASK</li>
* <li>AWTEvent.FOCUS_EVENT_MASK</li>
* <li>AWTEvent.KEY_EVENT_MASK</li>
* <li>AWTEvent.MOUSE_WHEEL_EVENT_MASK</li>
* <li>AWTEvent.MOUSE_MOTION_EVENT_MASK</li>
* <li>AWTEvent.MOUSE_EVENT_MASK</li>
* <li>AWTEvent.INPUT_METHOD_EVENT_MASK</li>
* <li>AWTEvent.HIERARCHY_EVENT_MASK</li>
* <li>AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK</li>
* </ul>
* Enables the events from JLayer and <b>all its descendants</b>
* defined by the specified event mask parameter
* to be delivered to the
* {@link LayerUI#eventDispatched(AWTEvent, JLayer)} method.
* <p/>
* If {@code LayerUI} is installed,
* {@link javax.swing.plaf.LayerUI#eventDispatched(AWTEvent, JLayer)} method
* will only receive events that match the event mask.
* Events are delivered provided that {@code LayerUI} is set
* for this {@code JLayer} and the {@code JLayer}
* is displayable.
* <p/>
* The following example shows how to correclty use this method
* in the {@code LayerUI} implementations:
......@@ -433,19 +411,15 @@ public final class JLayer<V extends Component>
* }
* </pre>
*
* By default {@code JLayer} receives no events.
* By default {@code JLayer} receives no events and its event mask is {@code 0}.
*
* @param layerEventMask the bitmask of event types to receive
*
* @throws IllegalArgumentException if the {@code layerEventMask} parameter
* contains unsupported event types
* @see #getLayerEventMask()
* @see LayerUI#eventDispatched(AWTEvent, JLayer)
* @see Component#isDisplayable()
*/
public void setLayerEventMask(long layerEventMask) {
if (layerEventMask != (layerEventMask & ACCEPTED_EVENTS)) {
throw new IllegalArgumentException(
"The event bitmask contains unsupported event types");
}
long oldEventMask = getLayerEventMask();
this.eventMask = layerEventMask;
firePropertyChange("layerEventMask", oldEventMask, layerEventMask);
......@@ -629,6 +603,18 @@ public final class JLayer<V extends Component>
private long currentEventMask;
private static final long ACCEPTED_EVENTS =
AWTEvent.COMPONENT_EVENT_MASK |
AWTEvent.CONTAINER_EVENT_MASK |
AWTEvent.FOCUS_EVENT_MASK |
AWTEvent.KEY_EVENT_MASK |
AWTEvent.MOUSE_WHEEL_EVENT_MASK |
AWTEvent.MOUSE_MOTION_EVENT_MASK |
AWTEvent.MOUSE_EVENT_MASK |
AWTEvent.INPUT_METHOD_EVENT_MASK |
AWTEvent.HIERARCHY_EVENT_MASK |
AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK;
@SuppressWarnings("unchecked")
public void eventDispatched(AWTEvent event) {
Object source = event.getSource();
......@@ -660,6 +646,8 @@ public final class JLayer<V extends Component>
for (Long mask : layerMaskList) {
combinedMask |= mask;
}
// filter out all unaccepted events
combinedMask &= ACCEPTED_EVENTS;
if (combinedMask == 0) {
removeAWTEventListener();
} else if (getCurrentEventMask() != combinedMask) {
......
......@@ -25,17 +25,7 @@
package javax.swing;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
......@@ -2779,9 +2769,9 @@ public class JList<E> extends JComponent implements Scrollable, Accessible
getVisibleRowCount() <= 0) {
return true;
}
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
return port.getWidth() > getPreferredSize().width;
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
return parent.getWidth() > getPreferredSize().width;
}
return false;
}
......@@ -2805,9 +2795,9 @@ public class JList<E> extends JComponent implements Scrollable, Accessible
getVisibleRowCount() <= 0) {
return true;
}
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
return port.getHeight() > getPreferredSize().height;
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
return parent.getHeight() > getPreferredSize().height;
}
return false;
}
......
......@@ -719,8 +719,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #addNotify
*/
protected void configureEnclosingScrollPane() {
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
JViewport port = (JViewport) parent;
Container gp = port.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)gp;
......@@ -752,8 +753,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* from configureEnclosingScrollPane() and updateUI() in a safe manor.
*/
private void configureEnclosingScrollPaneUI() {
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
JViewport port = (JViewport) parent;
Container gp = port.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)gp;
......@@ -822,8 +824,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @since 1.3
*/
protected void unconfigureEnclosingScrollPane() {
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
JViewport port = (JViewport) parent;
Container gp = port.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane)gp;
......@@ -5217,10 +5220,10 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #getFillsViewportHeight
*/
public boolean getScrollableTracksViewportHeight() {
JViewport port = SwingUtilities.getParentViewport(this);
Container parent = SwingUtilities.getUnwrappedParent(this);
return getFillsViewportHeight()
&& port != null
&& port.getHeight() > getPreferredSize().height;
&& parent instanceof JViewport
&& parent.getHeight() > getPreferredSize().height;
}
/**
......
......@@ -292,7 +292,7 @@ public class JTextField extends JTextComponent implements SwingConstants {
*/
@Override
public boolean isValidateRoot() {
return SwingUtilities.getParentViewport(this) == null;
return !(SwingUtilities.getUnwrappedParent(this) instanceof JViewport);
}
......
......@@ -3498,9 +3498,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportWidth
*/
public boolean getScrollableTracksViewportWidth() {
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
return port.getWidth() > getPreferredSize().width;
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
return parent.getWidth() > getPreferredSize().width;
}
return false;
}
......@@ -3515,9 +3515,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportHeight
*/
public boolean getScrollableTracksViewportHeight() {
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
return port.getHeight() > getPreferredSize().height;
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
return parent.getHeight() > getPreferredSize().height;
}
return false;
}
......
......@@ -1969,58 +1969,53 @@ public class SwingUtilities implements SwingConstants
}
/**
* Looks for the first ancestor of the {@code component}
* Returns the first ancestor of the {@code component}
* which is not an instance of {@link JLayer}.
* If this ancestor is an instance of {@code JViewport},
* this {@code JViewport} is returned, otherwise returns {@code null}.
* The following way of obtaining the parent {@code JViewport}
* is not recommended any more:
* <pre>
* JViewport port = null;
* Container parent = component.getParent();
* // not recommended any more
* if(parent instanceof JViewport) {
* port = (JViewport) parent;
* }
* </pre>
* Here is the way to go:
* <pre>
* // the correct way:
* JViewport port = SwingUtilities.getParentViewport(component);
* </pre>
* @param component {@code Component} to get the parent {@code JViewport} of.
* @return the {@code JViewport} instance for the {@code component}
* or {@code null}
*
* @param component {@code Component} to get
* the first ancestor of, which is not a {@link JLayer} instance.
*
* @return the first ancestor of the {@code component}
* which is not an instance of {@link JLayer}.
* If such an ancestor can not be found, {@code null} is returned.
*
* @throws NullPointerException if {@code component} is {@code null}
* @see JLayer
*
* @since 1.7
*/
public static JViewport getParentViewport(Component component) {
do {
component = component.getParent();
if (component instanceof JViewport) {
return (JViewport) component;
}
} while(component instanceof JLayer);
return null;
public static Container getUnwrappedParent(Component component) {
Container parent = component.getParent();
while(parent instanceof JLayer) {
parent = parent.getParent();
}
return parent;
}
/**
* Returns the first {@code JViewport}'s descendant
* which is not an instance of {@code JLayer} or {@code null}.
* which is not an instance of {@code JLayer}.
* If such a descendant can not be found, {@code null} is returned.
*
* If the {@code viewport}'s view component is not a {@code JLayer},
* this method is equal to {@link JViewport#getView()}
* otherwise {@link JLayer#getView()} will be recursively tested
* this method is equivalent to {@link JViewport#getView()}
* otherwise {@link JLayer#getView()} will be recursively
* called on all descending {@code JLayer}s.
*
* @param viewport {@code JViewport} to get the first descendant of,
* which in not a {@code JLayer} instance.
*
* @return the first {@code JViewport}'s descendant
* which is not an instance of {@code JLayer} or {@code null}.
* which is not an instance of {@code JLayer}.
* If such a descendant can not be found, {@code null} is returned.
*
* @throws NullPointerException if {@code viewport} is {@code null}
* @see JViewport#getView()
* @see JLayer
*
* @since 1.7
*/
static Component getUnwrappedView(JViewport viewport) {
public static Component getUnwrappedView(JViewport viewport) {
Component view = viewport.getView();
while (view instanceof JLayer) {
view = ((JLayer)view).getView();
......
/*
* Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2005-2010 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
......@@ -42,9 +42,10 @@ import sun.awt.AppContext;
import sun.swing.AccumulativeRunnable;
/**
* An abstract class to perform lengthy GUI-interacting tasks in a
* dedicated thread.
*
* An abstract class to perform lengthy GUI-interaction tasks in a
* background thread. Several background threads can be used to execute such
* tasks. However, the exact strategy of choosing a thread for any particular
* {@code SwingWorker} is unspecified and should not be relied on.
* <p>
* When writing a multi-threaded application using Swing, there are
* two constraints to keep in mind:
......@@ -772,7 +773,7 @@ public abstract class SwingWorker<T, V> implements RunnableFuture<T> {
};
executorService =
new ThreadPoolExecutor(1, MAX_WORKER_THREADS,
new ThreadPoolExecutor(MAX_WORKER_THREADS, MAX_WORKER_THREADS,
10L, TimeUnit.MINUTES,
new LinkedBlockingQueue<Runnable>(),
threadFactory);
......
......@@ -72,58 +72,18 @@ public class LayerUI<V extends Component>
* the specified {@code Graphics} object to
* render the content of the component.
* <p/>
* If {@code g} is not an instance of {@code Graphics2D},
* this method is no-op.
* The default implementation paints the passed component as is.
*
* @param g the {@code Graphics} context in which to paint;
* @param c the component being painted;
* it can be safely cast to {@code JLayer<? extends V>}
*
* @see #configureGraphics(Graphics2D, JLayer)
* @see #paintLayer(Graphics2D, JLayer)
* @param g the {@code Graphics} context in which to paint
* @param c the component being painted
*/
public void paint(Graphics g, JComponent c) {
if (g instanceof Graphics2D) {
Graphics2D g2 = (Graphics2D) g.create();
JLayer<? extends V> l = (JLayer<? extends V>) c;
configureGraphics(g2, l);
paintLayer(g2, l);
g2.dispose();
}
}
/**
* This method is called by the {@link #paint} method prior to
* {@link #paintLayer} to configure the {@code Graphics2D} object.
* The default implementation is empty.
*
* @param g2 the {@code Graphics2D} object to configure
* @param l the {@code JLayer} being painted
*
* @see #paintLayer(Graphics2D, JLayer)
*/
protected void configureGraphics(Graphics2D g2, JLayer<? extends V> l) {
}
/**
* Called by the {@link #paint} method,
* subclasses should override this method
* to perform any custom painting operations.
* <p/>
* The default implementation paints the passed {@code JLayer} as is.
*
* @param g2 the {@code Graphics2D} context in which to paint
* @param l the {@code JLayer} being painted
*
* @see #configureGraphics(Graphics2D, JLayer)
*/
protected void paintLayer(Graphics2D g2, JLayer<? extends V> l) {
l.paint(g2);
c.paint(g);
}
/**
* Dispatches {@code AWTEvent}s for {@code JLayer}
* and <b>all its subcomponents</b> to this {@code LayerUI} instance.
* Processes {@code AWTEvent}s for {@code JLayer}
* and <b>all its descendants</b> to this {@code LayerUI} instance.
* <p/>
* To enable the {@code AWTEvent}s of a particular type,
* you call {@link JLayer#setLayerEventMask}
......@@ -133,13 +93,14 @@ public class LayerUI<V extends Component>
* By default this method calls the appropriate
* {@code process&lt;event&nbsp;type&gt;Event}
* method for the given class of event.
* <p/>
* <b>Note:</b> Events are processed only for displayable {@code JLayer}s.
*
* @param e the event to be dispatched
* @param l the layer this LayerUI is set to
*
* @see JLayer#setLayerEventMask(long)
* @see #installUI(javax.swing.JComponent)
* @see #uninstallUI(javax.swing.JComponent)
* @see Component#isDisplayable()
* @see #processComponentEvent
* @see #processFocusEvent
* @see #processKeyEvent
......@@ -627,17 +588,6 @@ public class LayerUI<V extends Component>
propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
/**
* Repaints all {@code JLayer} instances this {@code LayerUI} is set to.
* Call this method when the state of this {@code LayerUI} is changed
* and the visual appearance of its {@code JLayer} objects needs to be updated.
*
* @see Component#repaint()
*/
protected void repaintLayer() {
firePropertyChange("dirty", null, null);
}
/**
* Notifies the {@code LayerUI} when any of its property are changed
* and enables updating every {@code JLayer}
......@@ -647,9 +597,6 @@ public class LayerUI<V extends Component>
* @param l the {@code JLayer} this LayerUI is set to
*/
public void applyPropertyChange(PropertyChangeEvent evt, JLayer<? extends V> l) {
if ("dirty".equals(evt.getPropertyName())) {
l.repaint();
}
}
/**
......
......@@ -38,6 +38,7 @@ import javax.swing.plaf.synth.SynthStyle;
import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
......@@ -193,7 +194,7 @@ public final class NimbusStyle extends SynthStyle {
* UIDefaults which overrides (or supplements) those defaults found in
* UIManager.
*/
private JComponent component;
private WeakReference<JComponent> component;
/**
* Create a new NimbusStyle. Only the prefix must be supplied. At the
......@@ -209,7 +210,9 @@ public final class NimbusStyle extends SynthStyle {
* should be null otherwise.
*/
NimbusStyle(String prefix, JComponent c) {
this.component = c;
if (c != null) {
this.component = new WeakReference<JComponent>(c);
}
this.prefix = prefix;
this.painter = new SynthPainterImpl(this);
}
......@@ -251,9 +254,11 @@ public final class NimbusStyle extends SynthStyle {
// value is an instance of UIDefaults, then these defaults are used
// in place of, or in addition to, the defaults in UIManager.
if (component != null) {
Object o = component.getClientProperty("Nimbus.Overrides");
// We know component.get() is non-null here, as if the component
// were GC'ed, we wouldn't be processing its style.
Object o = component.get().getClientProperty("Nimbus.Overrides");
if (o instanceof UIDefaults) {
Object i = component.getClientProperty(
Object i = component.get().getClientProperty(
"Nimbus.Overrides.InheritDefaults");
boolean inherit = i instanceof Boolean ? (Boolean)i : true;
UIDefaults d = (UIDefaults)o;
......
......@@ -2069,9 +2069,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* width to match its own
*/
public boolean getScrollableTracksViewportWidth() {
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
return port.getWidth() > getPreferredSize().width;
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
return parent.getWidth() > getPreferredSize().width;
}
return false;
}
......@@ -2090,9 +2090,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* to match its own
*/
public boolean getScrollableTracksViewportHeight() {
JViewport port = SwingUtilities.getParentViewport(this);
if (port != null) {
return (port.getHeight() > getPreferredSize().height);
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
return parent.getHeight() > getPreferredSize().height;
}
return false;
}
......
......@@ -314,4 +314,27 @@ public abstract class UNIXToolkit extends SunToolkit
}
return new RenderingHints(KEY_TEXT_ANTIALIASING, aaHint);
}
private native boolean gtkCheckVersionImpl(int major, int minor,
int micro);
/**
* Returns {@code true} if the GTK+ library is compatible with the given
* version.
*
* @param major
* The required major version.
* @param minor
* The required minor version.
* @param micro
* The required micro version.
* @return {@code true} if the GTK+ library is compatible with the given
* version.
*/
public boolean checkGtkVersion(int major, int minor, int micro) {
if (loadGTK()) {
return gtkCheckVersionImpl(major, minor, micro);
}
return false;
}
}
/*
* Copyright 2010 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;
import java.awt.Dialog;
import java.awt.FileDialog;
import java.awt.peer.FileDialogPeer;
import java.io.File;
import java.io.FilenameFilter;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import sun.awt.AWTAccessor;
/**
* FileDialogPeer for the GtkFileChooser.
*
* @author Costantino Cerbo (c.cerbo@gmail.com)
*/
class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
private FileDialog fd;
public GtkFileDialogPeer(FileDialog fd) {
super((Dialog) fd);
this.fd = fd;
}
private native void run(String title, int mode, String dir, String file,
FilenameFilter filter, boolean isMultipleMode);
private native void quit();
/**
* Called exclusively by the native C code.
*/
private void setFileInternal(String directory, String[] filenames) {
AWTAccessor.FileDialogAccessor accessor = AWTAccessor
.getFileDialogAccessor();
if (filenames == null) {
accessor.setDirectory(fd, null);
accessor.setFile(fd, null);
accessor.setFiles(fd, null, null);
} else {
accessor.setDirectory(fd, directory);
accessor.setFile(fd, filenames[0]);
accessor.setFiles(fd, directory, filenames);
}
}
/**
* Called exclusively by the native C code.
*/
private boolean filenameFilterCallback(String fullname) {
if (fd.getFilenameFilter() == null) {
// no filter, accept all.
return true;
}
File filen = new File(fullname);
return fd.getFilenameFilter().accept(new File(filen.getParent()),
filen.getName());
}
@Override
public void setVisible(boolean b) {
XToolkit.awtLock();
try {
if (b) {
Thread t = new Thread() {
public void run() {
GtkFileDialogPeer.this.run(fd.getTitle(), fd.getMode(),
fd.getDirectory(), fd.getFile(), fd
.getFilenameFilter(), fd
.isMultipleMode());
fd.setVisible(false);
}
};
t.start();
} else {
quit();
fd.setVisible(false);
}
} finally {
XToolkit.awtUnlock();
}
}
@Override
public void dispose() {
quit();
super.dispose();
}
@Override
public void setDirectory(String dir) {
// We do not implement this method because we
// have delegated to FileDialog#setDirectory
}
@Override
public void setFile(String file) {
// We do not implement this method because we
// have delegated to FileDialog#setFile
}
@Override
public void setFilenameFilter(FilenameFilter filter) {
// We do not implement this method because we
// have delegated to FileDialog#setFilenameFilter
}
}
......@@ -1054,7 +1054,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
public FileDialogPeer createFileDialog(FileDialog target) {
FileDialogPeer peer = new XFileDialogPeer(target);
// The current GtkFileChooser is available from GTK+ 2.4
FileDialogPeer peer = checkGtkVersion(2, 4, 0) ? new GtkFileDialogPeer(
target) : new XFileDialogPeer(target);
targetCreatedPeer(target, peer);
return peer;
}
......
......@@ -260,3 +260,23 @@ Java_sun_awt_SunToolkit_closeSplashScreen(JNIEnv *env, jclass cls)
}
dlclose(hSplashLib);
}
/*
* Class: sun_awt_UNIXToolkit
* Method: gtkCheckVersionImpl
* Signature: (III)Ljava/lang/String;
*/
JNIEXPORT jboolean JNICALL
Java_sun_awt_UNIXToolkit_gtkCheckVersionImpl(JNIEnv *env, jobject this,
jint major, jint minor, jint micro)
{
char *ret;
ret = fp_gtk_check_version(major, minor, micro);
if (ret == NULL) {
return TRUE;
}
free(ret);
return FALSE;
}
......@@ -32,6 +32,7 @@
#include "java_awt_Transparency.h"
#define GTK2_LIB "libgtk-x11-2.0.so.0"
#define GTHREAD_LIB "libgthread-2.0.so.0"
#define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0)
#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1)
......@@ -75,6 +76,8 @@ const gint SELECTED = 1 << 9;
const gint DEFAULT = 1 << 10;
static void *gtk2_libhandle = NULL;
static void *gthread_libhandle = NULL;
static gboolean flag_g_thread_get_initialized = FALSE;
static jmp_buf j;
/* Widgets */
......@@ -150,7 +153,6 @@ static GtkWidget *gtk2_widgets[_GTK_WIDGET_TYPE_SIZE];
/*************************
* Glib function pointers
*************************/
static void (*fp_g_free)(gpointer mem);
static gboolean (*fp_g_main_context_iteration)(GMainContext *context,
gboolean may_block);
......@@ -204,9 +206,6 @@ static void (*fp_gdk_drawable_get_size)(GdkDrawable *drawable,
/************************
* Gtk function pointers
************************/
static gchar* (*fp_gtk_check_version)(guint required_major,
guint required_minor,
guint required_micro);
static gboolean (*fp_gtk_init_check)(int* argc, char** argv);
/* Painting */
......@@ -330,7 +329,6 @@ static void (*fp_gtk_menu_shell_append)(GtkMenuShell *menu_shell,
static void (*fp_gtk_menu_item_set_submenu)(GtkMenuItem *menu_item,
GtkWidget *submenu);
static void (*fp_gtk_widget_realize)(GtkWidget *widget);
static void (*fp_gtk_widget_destroy)(GtkWidget *widget);
static GdkPixbuf* (*fp_gtk_widget_render_icon)(GtkWidget *widget,
const gchar *stock_id, GtkIconSize size, const gchar *detail);
static void (*fp_gtk_widget_set_name)(GtkWidget *widget, const gchar *name);
......@@ -388,6 +386,15 @@ static void* dl_symbol(const char* name)
return result;
}
static void* dl_symbol_gthread(const char* name)
{
void* result = dlsym(gthread_libhandle, name);
if (!result)
longjmp(j, NO_SYMBOL_EXCEPTION);
return result;
}
gboolean gtk2_check_version()
{
if (gtk2_libhandle != NULL) {
......@@ -414,6 +421,35 @@ gboolean gtk2_check_version()
}
}
/**
* Functions for sun_awt_X11_GtkFileDialogPeer.c
*/
void gtk2_file_chooser_load()
{
fp_gtk_file_chooser_get_filename = dl_symbol(
"gtk_file_chooser_get_filename");
fp_gtk_file_chooser_dialog_new = dl_symbol("gtk_file_chooser_dialog_new");
fp_gtk_file_chooser_set_current_folder = dl_symbol(
"gtk_file_chooser_set_current_folder");
fp_gtk_file_chooser_set_filename = dl_symbol(
"gtk_file_chooser_set_filename");
fp_gtk_file_filter_add_custom = dl_symbol("gtk_file_filter_add_custom");
fp_gtk_file_chooser_set_filter = dl_symbol("gtk_file_chooser_set_filter");
fp_gtk_file_chooser_get_type = dl_symbol("gtk_file_chooser_get_type");
fp_gtk_file_filter_new = dl_symbol("gtk_file_filter_new");
if (fp_gtk_check_version(2, 8, 0) == NULL) {
fp_gtk_file_chooser_set_do_overwrite_confirmation = dl_symbol(
"gtk_file_chooser_set_do_overwrite_confirmation");
}
fp_gtk_file_chooser_set_select_multiple = dl_symbol(
"gtk_file_chooser_set_select_multiple");
fp_gtk_file_chooser_get_current_folder = dl_symbol(
"gtk_file_chooser_get_current_folder");
fp_gtk_file_chooser_get_filenames = dl_symbol(
"gtk_file_chooser_get_filenames");
fp_gtk_g_slist_length = dl_symbol("g_slist_length");
}
gboolean gtk2_load()
{
gboolean result;
......@@ -423,7 +459,9 @@ gboolean gtk2_load()
char *gtk_modules_env;
gtk2_libhandle = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL);
if (gtk2_libhandle == NULL)
gthread_libhandle = dlopen(GTHREAD_LIB, RTLD_LAZY | RTLD_LOCAL);
if (gtk2_libhandle == NULL || gthread_libhandle == NULL)
return FALSE;
if (setjmp(j) == 0)
......@@ -597,6 +635,28 @@ gboolean gtk2_load()
fp_gtk_range_get_adjustment =
dl_symbol("gtk_range_get_adjustment");
fp_gtk_widget_hide = dl_symbol("gtk_widget_hide");
fp_gtk_main_quit = dl_symbol("gtk_main_quit");
fp_g_signal_connect_data = dl_symbol("g_signal_connect_data");
fp_gtk_widget_show = dl_symbol("gtk_widget_show");
fp_gtk_main = dl_symbol("gtk_main");
/**
* GLib thread system
*/
fp_g_thread_init = dl_symbol_gthread("g_thread_init");
fp_gdk_threads_init = dl_symbol("gdk_threads_init");
fp_gdk_threads_enter = dl_symbol("gdk_threads_enter");
fp_gdk_threads_leave = dl_symbol("gdk_threads_leave");
/**
* Functions for sun_awt_X11_GtkFileDialogPeer.c
*/
if (fp_gtk_check_version(2, 4, 0) == NULL) {
// The current GtkFileChooser is available from GTK+ 2.4
gtk2_file_chooser_load();
}
/* Some functions may be missing in pre-2.4 GTK.
We handle them specially here.
*/
......@@ -626,6 +686,10 @@ gboolean gtk2_load()
{
dlclose(gtk2_libhandle);
gtk2_libhandle = NULL;
dlclose(gthread_libhandle);
gthread_libhandle = NULL;
return FALSE;
}
......@@ -678,6 +742,19 @@ gboolean gtk2_load()
*/
handler = XSetErrorHandler(NULL);
io_handler = XSetIOErrorHandler(NULL);
if (fp_gtk_check_version(2, 2, 0) == NULL) {
// Init the thread system to use GLib in a thread-safe mode
if (!flag_g_thread_get_initialized) {
flag_g_thread_get_initialized = TRUE;
fp_g_thread_init(NULL);
//According the GTK documentation, gdk_threads_init() should be
//called before gtk_init() or gtk_init_check()
fp_gdk_threads_init();
}
}
result = (*fp_gtk_init_check)(NULL, NULL);
XSetErrorHandler(handler);
......@@ -722,6 +799,7 @@ int gtk2_unload()
dlerror();
dlclose(gtk2_libhandle);
dlclose(gthread_libhandle);
if ((gtk2_error = dlerror()) != NULL)
{
return FALSE;
......
......@@ -28,6 +28,21 @@
#include <stdlib.h>
#include <jni.h>
#define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip)
#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type))
#define GTK_TYPE_FILE_CHOOSER (fp_gtk_file_chooser_get_type ())
#define GTK_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser))
#define fp_g_signal_connect(instance, detailed_signal, c_handler, data) \
fp_g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
#define G_CALLBACK(f) ((GCallback) (f))
#define G_TYPE_FUNDAMENTAL_SHIFT (2)
#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
#define GTK_STOCK_CANCEL "gtk-cancel"
#define GTK_STOCK_SAVE "gtk-save"
#define GTK_STOCK_OPEN "gtk-open"
typedef enum _WidgetType
{
BUTTON, /* GtkButton */
......@@ -254,7 +269,13 @@ typedef enum
/* We define all structure pointers to be void* */
typedef void GError;
typedef void GMainContext;
typedef void GSList;
typedef struct _GSList GSList;
struct _GSList
{
gpointer data;
GSList *next;
};
typedef void GdkColormap;
typedef void GdkDrawable;
......@@ -556,6 +577,65 @@ struct _GtkProgressBar
guint ellipsize : 3;
};
typedef enum {
GTK_RESPONSE_NONE = -1,
GTK_RESPONSE_REJECT = -2,
GTK_RESPONSE_ACCEPT = -3,
GTK_RESPONSE_DELETE_EVENT = -4,
GTK_RESPONSE_OK = -5,
GTK_RESPONSE_CANCEL = -6,
GTK_RESPONSE_CLOSE = -7,
GTK_RESPONSE_YES = -8,
GTK_RESPONSE_NO = -9,
GTK_RESPONSE_APPLY = -10,
GTK_RESPONSE_HELP = -11
} GtkResponseType;
typedef struct _GtkWindow GtkWindow;
typedef struct _GtkFileChooser GtkFileChooser;
typedef enum {
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
} GtkFileChooserAction;
typedef struct _GtkFileFilter GtkFileFilter;
typedef enum {
GTK_FILE_FILTER_FILENAME = 1 << 0,
GTK_FILE_FILTER_URI = 1 << 1,
GTK_FILE_FILTER_DISPLAY_NAME = 1 << 2,
GTK_FILE_FILTER_MIME_TYPE = 1 << 3
} GtkFileFilterFlags;
typedef struct {
GtkFileFilterFlags contains;
const gchar *filename;
const gchar *uri;
const gchar *display_name;
const gchar *mime_type;
} GtkFileFilterInfo;
typedef gboolean (*GtkFileFilterFunc)(const GtkFileFilterInfo *filter_info,
gpointer data);
typedef void (*GDestroyNotify)(gpointer data);
typedef void (*GCallback)(void);
typedef struct _GClosure GClosure;
typedef void (*GClosureNotify)(gpointer data, GClosure *closure);
typedef enum {
G_CONNECT_AFTER = 1 << 0, G_CONNECT_SWAPPED = 1 << 1
} GConnectFlags;
typedef struct _GThreadFunctions GThreadFunctions;
/*
* Converts java.lang.String object to UTF-8 character string.
*/
......@@ -569,6 +649,13 @@ const char *getStrFor(JNIEnv *env, jstring value);
*/
gboolean gtk2_check_version();
/**
* Returns :
* NULL if the GTK+ library is compatible with the given version, or a string
* describing the version mismatch.
*/
gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
guint required_micro);
/*
* Load the gtk2 library. If the library is already loaded this method has no
* effect and returns success.
......@@ -651,6 +738,7 @@ jobject gtk2_get_setting(JNIEnv *env, Setting property);
void gtk2_set_range_value(WidgetType widget_type, jdouble value,
jdouble min, jdouble max, jdouble visible);
void (*fp_g_free)(gpointer mem);
void (*fp_g_object_unref)(gpointer object);
int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
......@@ -660,5 +748,47 @@ int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
void (*fp_gtk_widget_destroy)(GtkWidget *widget);
/**
* Function Pointers for GtkFileChooser
*/
gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
void (*fp_gtk_widget_hide)(GtkWidget *widget);
void (*fp_gtk_main_quit)(void);
GtkWidget* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
GtkWindow *parent, GtkFileChooserAction action,
const gchar *first_button_text, ...);
gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
const gchar *filename);
gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
const char *filename);
void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
GDestroyNotify notify);
void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
GtkFileFilter *filter);
GType (*fp_gtk_file_chooser_get_type)(void);
GtkFileFilter* (*fp_gtk_file_filter_new)(void);
void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
void (*fp_gtk_file_chooser_set_select_multiple)(
GtkFileChooser *chooser, gboolean select_multiple);
gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
guint (*fp_gtk_g_slist_length)(GSList *list);
gulong (*fp_g_signal_connect_data)(gpointer instance,
const gchar *detailed_signal, GCallback c_handler, gpointer data,
GClosureNotify destroy_data, GConnectFlags connect_flags);
void (*fp_gtk_widget_show)(GtkWidget *widget);
void (*fp_gtk_main)(void);
guint (*fp_gtk_main_level)(void);
void (*fp_g_thread_init)(GThreadFunctions *vtable);
void (*fp_gdk_threads_init)(void);
void (*fp_gdk_threads_enter)(void);
void (*fp_gdk_threads_leave)(void);
#endif /* !_GTK2_INTERFACE_H */
#include <jni.h>
#include <stdio.h>
#include <jni_util.h>
#include <string.h>
#include "gtk2_interface.h"
#include "sun_awt_X11_GtkFileDialogPeer.h"
static JavaVM *jvm;
static GtkWidget *dialog = NULL;
/* To cache some method IDs */
static jmethodID filenameFilterCallbackMethodID = NULL;
static jmethodID setFileInternalMethodID = NULL;
static gboolean filenameFilterCallback(const GtkFileFilterInfo * filter_info, gpointer obj)
{
JNIEnv *env;
jclass cx;
jstring filename;
env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (filenameFilterCallbackMethodID == NULL) {
cx = (*env)->GetObjectClass(env, (jobject) obj);
if (cx == NULL) {
JNU_ThrowInternalError(env, "Could not get file filter class");
return 0;
}
filenameFilterCallbackMethodID = (*env)->GetMethodID(env, cx,
"filenameFilterCallback", "(Ljava/lang/String;)Z");
if (filenameFilterCallbackMethodID == NULL) {
JNU_ThrowInternalError(env,
"Could not get filenameFilterCallback method id");
return 0;
}
}
filename = (*env)->NewStringUTF(env, filter_info->filename);
return (*env)->CallBooleanMethod(env, obj, filenameFilterCallbackMethodID,
filename);
}
/*
* Class: sun_awt_X11_GtkFileDialogPeer
* Method: quit
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit
(JNIEnv * env, jobject jpeer)
{
if (dialog != NULL)
{
fp_gtk_widget_hide (dialog);
fp_gtk_widget_destroy (dialog);
fp_gtk_main_quit ();
dialog = NULL;
}
}
/**
* Convert a GSList to an array of filenames (without the parent folder)
*/
static jobjectArray toFilenamesArray(JNIEnv *env, GSList* list)
{
jstring str;
jclass stringCls;
GSList *iterator;
jobjectArray array;
int i;
char* entry;
if (NULL == list) {
return NULL;
}
stringCls = (*env)->FindClass(env, "java/lang/String");
if (stringCls == NULL) {
JNU_ThrowInternalError(env, "Could not get java.lang.String class");
return NULL;
}
array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
NULL);
if (array == NULL) {
JNU_ThrowInternalError(env, "Could not instantiate array files array");
return NULL;
}
i = 0;
for (iterator = list; iterator; iterator = iterator->next) {
entry = (char*) iterator->data;
entry = strrchr(entry, '/') + 1;
str = (*env)->NewStringUTF(env, entry);
(*env)->SetObjectArrayElement(env, array, i, str);
i++;
}
return array;
}
static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
{
JNIEnv *env;
char *current_folder;
GSList *filenames;
jclass cx;
jstring jcurrent_folder;
jobjectArray jfilenames;
env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
current_folder = NULL;
filenames = NULL;
if (responseId == GTK_RESPONSE_ACCEPT) {
current_folder = fp_gtk_file_chooser_get_current_folder(
GTK_FILE_CHOOSER(dialog));
filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
}
if (setFileInternalMethodID == NULL) {
cx = (*env)->GetObjectClass(env, (jobject) obj);
if (cx == NULL) {
JNU_ThrowInternalError(env, "Could not get GTK peer class");
return;
}
setFileInternalMethodID = (*env)->GetMethodID(env, cx,
"setFileInternal", "(Ljava/lang/String;[Ljava/lang/String;)V");
if (setFileInternalMethodID == NULL) {
JNU_ThrowInternalError(env,
"Could not get setFileInternalMethodID method id");
return;
}
}
jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
jfilenames = toFilenamesArray(env, filenames);
(*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder,
jfilenames);
fp_g_free(current_folder);
Java_sun_awt_X11_GtkFileDialogPeer_quit(NULL, NULL);
}
/*
* Class: sun_awt_X11_GtkFileDialogPeer
* Method: run
* Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;Z;)V
*/
JNIEXPORT void JNICALL
Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
jstring jtitle, jint mode, jstring jdir, jstring jfile,
jobject jfilter, jboolean multiple)
{
GtkFileFilter *filter;
if (jvm == NULL) {
(*env)->GetJavaVM(env, &jvm);
}
fp_gdk_threads_init();
fp_gdk_threads_enter();
const char *title = (*env)->GetStringUTFChars(env, jtitle, 0);
if (mode == 1) {
/* Save action */
dialog = fp_gtk_file_chooser_dialog_new(title, NULL,
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
}
else {
/* Default action OPEN */
dialog = fp_gtk_file_chooser_dialog_new(title, NULL,
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
/* Set multiple selection mode, that is allowed only in OPEN action */
if (multiple) {
fp_gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog),
multiple);
}
}
(*env)->ReleaseStringUTFChars(env, jtitle, title);
/* Set the directory */
if (jdir != NULL) {
const char *dir = (*env)->GetStringUTFChars(env, jdir, 0);
fp_gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir);
(*env)->ReleaseStringUTFChars(env, jdir, dir);
}
/* Set the filename */
if (jfile != NULL) {
const char *filename = (*env)->GetStringUTFChars(env, jfile, 0);
fp_gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename);
(*env)->ReleaseStringUTFChars(env, jfile, filename);
}
/* Set the file filter */
if (jfilter != NULL) {
filter = fp_gtk_file_filter_new();
fp_gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
filenameFilterCallback, jpeer, NULL);
fp_gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
}
/* Other Properties */
if (fp_gtk_check_version(2, 8, 0) == NULL) {
fp_gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(
dialog), TRUE);
}
fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
handle_response), jpeer);
fp_gtk_widget_show(dialog);
fp_gtk_main();
fp_gdk_threads_leave();
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class sun_awt_X11_GtkFileDialogPeer */
#ifndef _Included_sun_awt_X11_GtkFileDialogPeer
#define _Included_sun_awt_X11_GtkFileDialogPeer
#ifdef __cplusplus
extern "C"
{
#endif
/*
* Class: sun_awt_X11_GtkFileDialogPeer
* Method: run
* Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;Z;)V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_run
(JNIEnv *, jobject, jstring, jint, jstring, jstring, jobject, jboolean);
/*
* Class: sun_awt_X11_GtkFileDialogPeer
* Method: quit
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
......@@ -38,8 +38,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow(
jint widget_type, jint state, jint shadow_type, jstring detail,
jint x, jint y, jint w, jint h, jint arrow_type)
{
fp_gdk_threads_enter();
gtk2_paint_arrow(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, arrow_type, TRUE);
fp_gdk_threads_leave();
}
/*
......@@ -54,8 +56,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box(
jint x, jint y, jint w, jint h,
jint synth_state, jint dir)
{
fp_gdk_threads_enter();
gtk2_paint_box(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, synth_state, dir);
fp_gdk_threads_leave();
}
/*
......@@ -70,8 +74,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box_1gap(
jint x, jint y, jint w, jint h,
jint gap_side, jint gap_x, jint gap_w)
{
fp_gdk_threads_enter();
gtk2_paint_box_gap(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, gap_side, gap_x, gap_w);
fp_gdk_threads_leave();
}
/*
......@@ -85,8 +91,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1check(
jint widget_type, jint synth_state, jstring detail,
jint x, jint y, jint w, jint h)
{
fp_gdk_threads_enter();
gtk2_paint_check(widget_type, synth_state, getStrFor(env, detail),
x, y, w, h);
fp_gdk_threads_leave();
}
/*
......@@ -100,8 +108,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1expander(
jint widget_type, jint state, jstring detail,
jint x, jint y, jint w, jint h, jint expander_style)
{
fp_gdk_threads_enter();
gtk2_paint_expander(widget_type, state, getStrFor(env, detail),
x, y, w, h, expander_style);
fp_gdk_threads_leave();
}
/*
......@@ -115,8 +125,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1extension(
jint widget_type, jint state, jint shadow_type, jstring detail,
jint x, jint y, jint w, jint h, jint placement)
{
fp_gdk_threads_enter();
gtk2_paint_extension(widget_type, state, shadow_type,
getStrFor(env, detail), x, y, w, h, placement);
fp_gdk_threads_leave();
}
/*
......@@ -130,8 +142,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1flat_1box(
jint widget_type, jint state, jint shadow_type, jstring detail,
jint x, jint y, jint w, jint h, jboolean has_focus)
{
fp_gdk_threads_enter();
gtk2_paint_flat_box(widget_type, state, shadow_type,
getStrFor(env, detail), x, y, w, h, has_focus);
fp_gdk_threads_leave();
}
/*
......@@ -145,8 +159,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1focus(
jint widget_type, jint state, jstring detail,
jint x, jint y, jint w, jint h)
{
fp_gdk_threads_enter();
gtk2_paint_focus(widget_type, state, getStrFor(env, detail),
x, y, w, h);
fp_gdk_threads_leave();
}
/*
......@@ -160,8 +176,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1handle(
jint widget_type, jint state, jint shadow_type, jstring detail,
jint x, jint y, jint w, jint h, jint orientation)
{
fp_gdk_threads_enter();
gtk2_paint_handle(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, orientation);
fp_gdk_threads_leave();
}
/*
......@@ -175,8 +193,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1hline(
jint widget_type, jint state, jstring detail,
jint x, jint y, jint w, jint h)
{
fp_gdk_threads_enter();
gtk2_paint_hline(widget_type, state, getStrFor(env, detail),
x, y, w, h);
fp_gdk_threads_leave();
}
/*
......@@ -190,8 +210,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1option(
jint widget_type, jint synth_state, jstring detail,
jint x, jint y, jint w, jint h)
{
fp_gdk_threads_enter();
gtk2_paint_option(widget_type, synth_state, getStrFor(env, detail),
x, y, w, h);
fp_gdk_threads_leave();
}
/*
......@@ -206,8 +228,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1shadow(
jint x, jint y, jint w, jint h,
jint synth_state, jint dir)
{
fp_gdk_threads_enter();
gtk2_paint_shadow(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, synth_state, dir);
fp_gdk_threads_leave();
}
/*
......@@ -221,8 +245,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1slider(
jint widget_type, jint state, jint shadow_type, jstring detail,
jint x, jint y, jint w, jint h, jint orientation)
{
fp_gdk_threads_enter();
gtk2_paint_slider(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, orientation);
fp_gdk_threads_leave();
}
/*
......@@ -236,8 +262,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1vline(
jint widget_type, jint state, jstring detail,
jint x, jint y, jint w, jint h)
{
fp_gdk_threads_enter();
gtk2_paint_vline(widget_type, state, getStrFor(env, detail),
x, y, w, h);
fp_gdk_threads_leave();
}
/*
......@@ -250,7 +278,9 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1background(
JNIEnv *env, jobject this, jint widget_type, jint state,
jint x, jint y, jint w, jint h)
{
fp_gdk_threads_enter();
gtk_paint_background(widget_type, state, x, y, w, h);
fp_gdk_threads_leave();
}
/*
......@@ -262,7 +292,9 @@ JNIEXPORT void JNICALL
Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting(
JNIEnv *env, jobject this, jint w, jint h)
{
fp_gdk_threads_enter();
gtk2_init_painting(w, h);
fp_gdk_threads_leave();
}
/*
......@@ -276,7 +308,9 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting(
{
jint transparency;
gint *buffer = (gint*) (*env)->GetPrimitiveArrayCritical(env, dest, 0);
fp_gdk_threads_enter();
transparency = gtk2_copy_image(buffer, width, height);
fp_gdk_threads_leave();
(*env)->ReleasePrimitiveArrayCritical(env, dest, buffer, 0);
return transparency;
}
......@@ -289,7 +323,9 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting(
JNIEXPORT void JNICALL Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1switch_1theme(
JNIEnv *env, jobject this)
{
fp_gdk_threads_enter();
flush_gtk_event_loop();
fp_gdk_threads_leave();
}
/*
......@@ -300,7 +336,11 @@ JNIEXPORT void JNICALL Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1switch
JNIEXPORT jobject JNICALL Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1get_1gtk_1setting(
JNIEnv *env, jobject this, jint property)
{
return gtk2_get_setting(env, property);
jobject obj;
fp_gdk_threads_enter();
obj = gtk2_get_setting(env, property);
fp_gdk_threads_leave();
return obj;
}
/*
......@@ -313,5 +353,7 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeSetRangeValue(
JNIEnv *env, jobject this, jint widget_type,
jdouble value, jdouble min, jdouble max, jdouble visible)
{
fp_gdk_threads_enter();
gtk2_set_range_value(widget_type, value, min, max, visible);
fp_gdk_threads_leave();
}
......@@ -36,7 +36,11 @@ JNIEXPORT jint JNICALL
Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetXThickness(
JNIEnv *env, jclass klass, jint widget_type)
{
return gtk2_get_xthickness(env, widget_type);
jint ret;
fp_gdk_threads_enter();
ret = gtk2_get_xthickness(env, widget_type);
fp_gdk_threads_leave();
return ret;
}
/*
......@@ -48,7 +52,11 @@ JNIEXPORT jint JNICALL
Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetYThickness(
JNIEnv *env, jclass klass, jint widget_type)
{
return gtk2_get_ythickness(env, widget_type);
jint ret;
fp_gdk_threads_enter();
ret = gtk2_get_ythickness(env, widget_type);
fp_gdk_threads_leave();
return ret;
}
/*
......@@ -61,7 +69,11 @@ Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetColorForState(
JNIEnv *env, jclass klass, jint widget_type,
jint state_type, jint type_id)
{
return gtk2_get_color_for_state(env, widget_type, state_type, type_id);
jint ret;
fp_gdk_threads_enter();
ret = gtk2_get_color_for_state(env, widget_type, state_type, type_id);
fp_gdk_threads_leave();
return ret;
}
/*
......@@ -73,7 +85,11 @@ JNIEXPORT jobject JNICALL
Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue(
JNIEnv *env, jclass klass, jint widget_type, jstring key)
{
return gtk2_get_class_value(env, widget_type, key);
jobject ret;
fp_gdk_threads_enter();
ret = gtk2_get_class_value(env, widget_type, key);
fp_gdk_threads_leave();
return ret;
}
/*
......@@ -85,5 +101,9 @@ JNIEXPORT jstring JNICALL
Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName(
JNIEnv *env, jclass klass, jint widget_type)
{
return gtk2_get_pango_font_name(env, widget_type);
jstring ret;
fp_gdk_threads_enter();
ret = gtk2_get_pango_font_name(env, widget_type);
fp_gdk_threads_leave();
return ret;
}
......@@ -148,11 +148,18 @@ LoadMSVCRT()
* assumed to be present in the "JRE path" directory. If it is not found
* there (or "JRE path" fails to resolve), skip the explicit load and let
* nature take its course, which is likely to be a failure to execute.
* This is clearly completely specific to the exact compiler version
* which isn't very nice, but its hardly the only place.
* No attempt to look for compiler versions in between 2003 and 2010
* as we aren't supporting building with those.
*/
#ifdef _MSC_VER
#if _MSC_VER < 1400
#define CRT_DLL "msvcr71.dll"
#endif
#if _MSC_VER >= 1600
#define CRT_DLL "msvcr100.dll"
#endif
#ifdef CRT_DLL
if (GetJREPath(crtpath, MAXPATHLEN)) {
(void)JLI_StrCat(crtpath, "\\bin\\" CRT_DLL); /* Add crt dll */
......
......@@ -403,9 +403,14 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
}
}
String path = dir.getPath();
return (path.length() == 3
&& path.charAt(1) == ':'
&& Arrays.asList(drives.listFiles()).contains(dir));
if (path.length() != 3 || path.charAt(1) != ':') {
return false;
}
File[] files = drives.listFiles();
return files != null && Arrays.asList(files).contains(dir);
}
return false;
}
......
......@@ -29,7 +29,10 @@
#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
/* REMIND : 0x500 means Windows 2000 .. seems like we can update
* for Windows XP when we move the SDK and build platform
*/
#define _WIN32_WINNT 0x0500
#endif
#define _ATL_APARTMENT_THREADED
......
......@@ -29,7 +29,10 @@
#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
/* REMIND : 0x500 means Windows 2000 .. seems like we can update
* for Windows XP when we move the SDK and build platform
*/
#define _WIN32_WINNT 0x0500
#endif
#define _ATL_APARTMENT_THREADED
......
......@@ -36,7 +36,10 @@
#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
/* REMIND : 0x500 means Windows 2000 .. seems like we can update
* for Windows XP when we move the SDK and build platform
*/
#define _WIN32_WINNT 0x0500
#endif
#define _ATL_APARTMENT_THREADED
......
......@@ -233,7 +233,19 @@ void AwtDesktopProperties::GetNonClientParameters() {
//
NONCLIENTMETRICS ncmetrics;
ncmetrics.cbSize = sizeof(ncmetrics);
// Fix for 6944516: specify correct size for ncmetrics on WIN2K/XP
// Microsoft recommend to subtract the size of 'iPaddedBorderWidth' field
// when running on XP. However this can't be referenced at compile time
// with the older SDK, so there use 'lfMessageFont' plus its size.
if (!IS_WINVISTA) {
#if defined(_MSC_VER) && (_MSC_VER >= 1600) {
ncmetrics.cbSize = offsetof(NONCLIENTMETRICS, iPaddedBorderWidth);
#else
ncmetrics.cbSize = offsetof(NONCLIENTMETRICS,lfMessageFont) + sizeof(LOGFONT);
#endif
} else {
ncmetrics.cbSize = sizeof(ncmetrics);
}
VERIFY( SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncmetrics.cbSize, &ncmetrics, FALSE) );
SetFontProperty( TEXT("win.frame.captionFont"), ncmetrics.lfCaptionFont );
......
......@@ -29,21 +29,16 @@
//we need <new> inclusion for STL "new" oprators set.
#define bad_alloc zbad_alloc
#include <new>
#pragma pop_macro("bad_alloc")
//"bad_alloc" is undefined from here
//we need to include any STL container before <awt.h> inclusion due to
//"new" re-redefinition that is in conflict with in-place new allocator
//applied in STL.
#if defined(_DEBUG) || defined(DEBUG)
//forward declaration of "new" operator from <awt.h>
extern void * operator new(size_t size, const char * filename, int linenumber);
//"new" operator definition that is consistent with re-defined
//in <awt.h> "delete" operator
void * operator new(size_t size) {return operator new(size, "stl", 1);}
extern void * operator new(size_t size, const char * filename, int linenumber);
void * operator new(size_t size) {return operator new(size, "stl", 1);}
#endif
#include <map>
#pragma pop_macro("bad_alloc")
//"bad_alloc" is undefined from here
#include <awt.h>
#include <shlobj.h>
......
......@@ -758,7 +758,7 @@ AwtTextArea::HandleEvent(MSG *msg, BOOL synthetic)
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
int actualScrollLines =
abs(platfScrollLines * (*delta_accum / WHEEL_DELTA));
abs((int)(platfScrollLines * (*delta_accum / WHEEL_DELTA)));
for (int i = 0; i < actualScrollLines; i++) {
if (::GetScrollInfo(hWnd, sb_type, &si)) {
if ((wm_msg == WM_VSCROLL)
......
/*
* Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 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
......@@ -23,7 +23,7 @@
/*
* @test
* @bug 6843181
* @bug 6843181 6943963
* @summary Confirm that NumericShaper is thread-safe.
* @run main/timeout=300/othervm MTTest
*/
......@@ -37,33 +37,34 @@ public class MTTest {
static volatile boolean runrun = true;
static volatile boolean err = false;
final static String text = "-123 (English) 456.00 (Arabic) \u0641\u0642\u0643 -789 (Thai) \u0e01\u0e33 01.23";
static char[] t1, t2;
final static String text = "-123 (English) 456.00 (Arabic) \u0641\u0642\u0643 -456 (Thai) \u0e01\u0e33 01.23";
final static char[] expected1 = "-123 (English) 456.00 (Arabic) \u0641\u0642\u0643 -\u06f4\u06f5\u06f6 (Thai) \u0e01\u0e33 \u0e50\u0e51.\u0e52\u0e53".toCharArray(); // for EASTERN_ARABIC
final static char[] expected2 = "-123 (English) 456.00 (Arabic) \u0641\u0642\u0643 -\u0664\u0665\u0666 (Thai) \u0e01\u0e33 \u0e50\u0e51.\u0e52\u0e53".toCharArray(); // for ARABIC
static NumericShaper ns1, ns2, ns3, ns4;
public static void main(String[] args) {
System.out.println(" original: " + text);
ns1 = getContextualShaper(EnumSet.of(Range.ARABIC), Range.ARABIC);
t1 = text.toCharArray();
ns1.shape(t1, 0, t1.length);
System.out.println("expected t1: " + String.valueOf(t1));
ns2 = getContextualShaper(EnumSet.of(Range.THAI), Range.THAI);
t2 = text.toCharArray();
ns2.shape(t2, 0, t2.length);
System.out.println("expected t2: " + String.valueOf(t2));
System.out.println("original: " + text);
ns1 = getContextualShaper(EnumSet.of(Range.EASTERN_ARABIC, Range.THAI),
Range.EUROPEAN);
ns2 = getContextualShaper(EnumSet.of(Range.ARABIC, Range.THAI),
Range.EUROPEAN);
System.out.println("expected for Eastern-Arabic & Thai: " +
String.valueOf(expected1));
System.out.println("expected for Arabic & Thai: " +
String.valueOf(expected2));
ns3 = getContextualShaper(ARABIC, ARABIC);
ns4 = getContextualShaper(THAI, THAI);
ns3 = getContextualShaper(EASTERN_ARABIC|THAI, EUROPEAN);
ns4 = getContextualShaper(ARABIC|THAI, EUROPEAN);
Thread th1 = new Thread(new Work(ns1, t1));
Thread th2 = new Thread(new Work(ns2, t2));
Thread th3 = new Thread(new Work(ns1, t1));
Thread th4 = new Thread(new Work(ns2, t2));
Thread th5 = new Thread(new Work(ns3, t1));
Thread th6 = new Thread(new Work(ns4, t2));
Thread th7 = new Thread(new Work(ns3, t1));
Thread th8 = new Thread(new Work(ns4, t2));
Thread th1 = new Thread(new Work(ns1, expected1));
Thread th2 = new Thread(new Work(ns2, expected2));
Thread th3 = new Thread(new Work(ns1, expected1));
Thread th4 = new Thread(new Work(ns2, expected2));
Thread th5 = new Thread(new Work(ns3, expected1));
Thread th6 = new Thread(new Work(ns4, expected2));
Thread th7 = new Thread(new Work(ns3, expected1));
Thread th8 = new Thread(new Work(ns4, expected2));
th1.start();
th2.start();
......@@ -110,8 +111,8 @@ public class MTTest {
int count = 0;
while (runrun) {
char[] t = text.toCharArray();
count++;
try {
count++;
ns.shape(t, 0, t.length);
} catch (Exception e) {
System.err.println("Error: Unexpected exception: " + e);
......
/*
* Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 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
......@@ -23,7 +23,7 @@
/*
* @test
* @bug 6842557
* @bug 6842557 6943963
* @summary confirm that shaping works as expected. (Mainly for new characters which were added in Unicode 5)
* used where appropriate.
*/
......@@ -33,15 +33,25 @@ import java.util.EnumSet;
import static java.awt.font.NumericShaper.*;
public class ShapingTest {
private static boolean err = false;
public static void main(String[] args) {
test6842557();
test6943963();
if (err) {
throw new RuntimeException("shape() returned unexpected value.");
}
}
private static void test6842557() {
NumericShaper ns_old = getContextualShaper(ARABIC | TAMIL | ETHIOPIC,
EUROPEAN);
NumericShaper ns_new = getContextualShaper(EnumSet.of(
Range.ARABIC, Range.TAMIL, Range.ETHIOPIC),
Range.EUROPEAN);
boolean err = false;
String[][] data = {
// Arabic "October 10"
{"\u0623\u0643\u062a\u0648\u0628\u0631 10",
......@@ -60,45 +70,62 @@ public class ShapingTest {
};
for (int i = 0; i < data.length; i++) {
String expected = data[i][1];
char[] text = data[i][0].toCharArray();
ns_old.shape(text, 0, text.length);
String got = new String(text);
if (!expected.equals(got)) {
err = true;
System.err.println("Error with traditional range.");
System.err.println(" text = " + data[i][0]);
System.err.println(" got = " + got);
System.err.println(" expected = " + expected);
} else {
System.err.println("OK with traditional range.");
System.err.println(" text = " + data[i][0]);
System.err.println(" got = " + got);
System.err.println(" expected = " + expected);
}
text = data[i][0].toCharArray();
ns_new.shape(text, 0, text.length);
got = new String(text);
if (!expected.equals(got)) {
err = true;
System.err.println("Error with new Enum range.");
System.err.println(" text = " + data[i][0]);
System.err.println(" got = " + got);
System.err.println(" expected = " + expected);
} else {
System.err.println("OK with new Enum range.");
System.err.println(" text = " + data[i][0]);
System.err.println(" got = " + got);
System.err.println(" expected = " + expected);
}
checkResult("ARABIC | TAMIL | ETHIOPIC",
ns_old, data[i][0], data[i][1]);
checkResult("Range.ARABIC, Range.TAMIL, Range.ETHIOPIC",
ns_new, data[i][0], data[i][1]);
}
}
if (err) {
throw new RuntimeException("shape() returned unexpected value.");
private static void test6943963() {
// Needed to reproduce this bug.
NumericShaper ns_dummy = getContextualShaper(ARABIC | TAMIL | ETHIOPIC,
EUROPEAN);
char[] c = "\u1200 1".toCharArray();
ns_dummy.shape(c, 0, c.length);
String given = "\u0627\u0628 456";
String expected_ARABIC = "\u0627\u0628 \u0664\u0665\u0666";
String expected_EASTERN_ARABIC = "\u0627\u0628 \u06f4\u06f5\u06f6";
NumericShaper ns = getContextualShaper(ARABIC);
checkResult("ARABIC", ns, given, expected_ARABIC);
ns = getContextualShaper(EnumSet.of(Range.ARABIC));
checkResult("Range.ARABIC", ns, given, expected_ARABIC);
ns = getContextualShaper(EASTERN_ARABIC);
checkResult("EASTERN_ARABIC", ns, given, expected_EASTERN_ARABIC);
ns = getContextualShaper(EnumSet.of(Range.EASTERN_ARABIC));
checkResult("Range.EASTERN_ARABIC", ns, given, expected_EASTERN_ARABIC);
ns = getContextualShaper(ARABIC | EASTERN_ARABIC);
checkResult("ARABIC | EASTERN_ARABIC", ns, given, expected_EASTERN_ARABIC);
ns = getContextualShaper(EnumSet.of(Range.ARABIC, Range.EASTERN_ARABIC));
checkResult("Range.ARABIC, Range.EASTERN_ARABIC", ns, given, expected_EASTERN_ARABIC);
}
private static void checkResult(String ranges, NumericShaper ns,
String given, String expected) {
char[] text = given.toCharArray();
ns.shape(text, 0, text.length);
String got = new String(text);
if (!expected.equals(got)) {
err = true;
System.err.println("Error with range(s) <" + ranges + ">.");
System.err.println(" text = " + given);
System.err.println(" got = " + got);
System.err.println(" expected = " + expected);
} else {
System.out.println("OK with range(s) <" + ranges + ">.");
System.out.println(" text = " + given);
System.out.println(" got = " + got);
System.out.println(" expected = " + expected);
}
}
......
/*
* Copyright 2010 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.
*
* 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.
*/
/* @test
@bug 6945316
@summary The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
@author Pavel Porvatov
@run main bug6945316
*/
import sun.awt.OSInfo;
import sun.awt.shell.ShellFolder;
import java.awt.*;
import java.io.File;
import java.util.concurrent.CountDownLatch;
public class bug6945316 {
public static void main(String[] args) throws Exception {
if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
System.out.println("The test is suitable only for Windows OS. Skipped.");
return;
}
// Init toolkit because it shouldn't be interrupted while initialization
Toolkit.getDefaultToolkit();
// Init the sun.awt.shell.Win32ShellFolderManager2.drives field
ShellFolder.get("fileChooserComboBoxFolders");
// To get NPE the path must obey the following rules:
// path.length() == 3 && path.charAt(1) == ':'
final File tempFile = new File("c:\\");
for (int i = 0; i < 10000; i++) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final Thread thread = new Thread() {
public void run() {
countDownLatch.countDown();
ShellFolder.isFileSystemRoot(tempFile);
}
};
thread.start();
countDownLatch.await();
thread.interrupt();
}
}
}
/*
* Copyright 2010 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.
*
* 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.
*/
/* @test
* @bug 6880336
* @summary Test for nested SwingWorkers, i.e. when the second worker is
started from the first's doInBackground() method. A timeout when running
* this test is an indication of failure.
* @author Artem Ananiev
* @run main/timeout=32 NestedWorkers
*/
import javax.swing.*;
public class NestedWorkers extends SwingWorker<String, Void> {
private final static int MAX_LEVEL = 2;
private int level;
public NestedWorkers(int level) {
super();
this.level = level;
}
@Override
public String doInBackground() throws Exception {
if (level < MAX_LEVEL) {
SwingWorker<String, Void> nested = new NestedWorkers(level + 1);
nested.execute();
nested.get();
}
System.out.println("doInBackground " + level + " is complete");
return String.valueOf(level);
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
SwingWorker<String, Void> sw = new NestedWorkers(0);
sw.execute();
try {
System.err.println(sw.get());
} catch (Exception z) {
throw new RuntimeException(z);
}
}
});
}
}
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* 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.
*/
/* @test
@bug 6919629
@summary Tests that components with Nimbus.Overrides are GC'ed properly
@author Peter Zhelezniakov
@run main Test6919629
*/
import java.awt.Color;
import java.lang.ref.WeakReference;
import javax.swing.*;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
public class Test6919629
{
JFrame f;
WeakReference<JLabel> ref;
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(new NimbusLookAndFeel());
Test6919629 t = new Test6919629();
t.test();
System.gc();
t.check();
}
void test() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
UIDefaults d = new UIDefaults();
d.put("Label.textForeground", Color.MAGENTA);
JLabel l = new JLabel();
ref = new WeakReference<JLabel>(l);
l.putClientProperty("Nimbus.Overrides", d);
f = new JFrame();
f.getContentPane().add(l);
f.pack();
f.setVisible(true);
}
});
Thread.sleep(2000);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
f.getContentPane().removeAll();
f.setVisible(false);
f.dispose();
}
});
Thread.sleep(2000);
}
void check() {
if (ref.get() != null) {
throw new RuntimeException("Failed: an unused component wasn't collected");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册