diff --git a/.hgtags b/.hgtags index 0181b2d733a0905203d7d0cc60d729e6ebdf4ec4..d941bf4d50e9a546c50ebc2f2abfb037a8b7df01 100644 --- a/.hgtags +++ b/.hgtags @@ -188,3 +188,5 @@ f117a3e06f78a258074674ad17601f99bcb1ce0d jdk8-b63 26dbd73fb7662a29b3e47179fdc88a0bfa4e231e jdk8-b64 130d3a54d28becaac0846137256c2684adb34c33 jdk8-b65 4d337fae2250135729ee9ed2bf8baf3c60da5d6d jdk8-b66 +ce9b02a3a17edd1983201002cfa0f364e4ab7524 jdk8-b67 +53fb43e4d614c92310e1fb00ec41d1960fd9facf jdk8-b68 diff --git a/makefiles/CompileDemos.gmk b/makefiles/CompileDemos.gmk index bf67ff124bd5de5b609b336367e8bf0f5713e3c5..949dcab03059ad6b007264971710a2c412f14c75 100644 --- a/makefiles/CompileDemos.gmk +++ b/makefiles/CompileDemos.gmk @@ -194,15 +194,6 @@ endif ################################################################################################## -# Why do we install a demo jar into the main jre/lib/ext???????????????? -$(JDK_OUTPUTDIR)/lib/ext/zipfs.jar : $(JDK_OUTPUTDIR)/demo/nio/zipfs/zipfs.jar - $(MKDIR) -p $(@D) - $(CP) $< $@ - -BUILD_DEMOS += $(JDK_OUTPUTDIR)/lib/ext/zipfs.jar - -################################################################################################## - # In the old makefiles, j2dbench was not compiled. #$(eval $(call SetupDemo,J2DBench,java2d,/src,,j2dbench/J2DBench)) diff --git a/makefiles/CompileJavaClasses.gmk b/makefiles/CompileJavaClasses.gmk index 93ab2f25a357607890d3a9e8dda644a08542659b..2a7f4def4263d047cde04b856c042b122ea3aee8 100644 --- a/makefiles/CompileJavaClasses.gmk +++ b/makefiles/CompileJavaClasses.gmk @@ -221,24 +221,10 @@ endif EXFILES+=-linux-arm.java \ -linux-ppc.java -# TODO: Is this necessary? ifeq ($(OPENJDK_TARGET_OS), windows) EXFILES+=sun/nio/ch/AbstractPollSelectorImpl.java \ - sun/nio/ch/DevPollArrayWrapper.java \ - sun/nio/ch/DevPollSelectorImpl.java \ - sun/nio/ch/DevPollSelectorProvider.java \ - sun/nio/ch/InheritedChannel.java \ sun/nio/ch/PollSelectorProvider.java \ - sun/nio/ch/PollSelectorImpl.java \ - sun/nio/ch/Port.java \ - sun/nio/ch/SimpleAsynchronousFileChannelImpl.java \ - sun/nio/ch/SolarisAsynchronousChannelProvider.java \ - sun/nio/ch/SolarisEventPort.java \ - sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \ - sun/nio/ch/UnixAsynchronousSocketChannelImpl.java - EXFILES+=sun/net/sdp/SdpProvider.java -else - EXFILES+=sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java + sun/nio/ch/SimpleAsynchronousFileChannelImpl.java endif # Exclude nimbus files from rt.jar @@ -339,29 +325,14 @@ $(JDK_OUTPUTDIR)/gensrc_headers/_the.jdk.base.headers: $(JDK_BASE_HEADER_JAVA_FI ########################################################################################## -# -# This is an empty jar (only contains manifest) and fits poorly into framework... -# create simple rule instead -# -MANAGEMENT_AGENT_JAR_DEPS := $(JDK_TOPDIR)/src/share/classes/sun/management/manifest - -$(JDK_OUTPUTDIR)/lib/management-agent.jar : $(JDK_TOPDIR)/src/share/classes/sun/management/manifest - $(JAR) cfm $@ $(JDK_TOPDIR)/src/share/classes/sun/management/manifest - -JARS += $(JDK_OUTPUTDIR)/lib/management-agent.jar - -########################################################################################## - ifndef OPENJDK -$(eval $(call SetupJavaCompilation,BUILD_ALTCLASSES_JAR,\ + $(eval $(call SetupJavaCompilation,BUILD_ALTCLASSES,\ SETUP:=GENERATE_JDKBYTECODE,\ SRC:=$(JDK_TOPDIR)/src/closed/share/altclasses, \ - BIN:=$(JDK_OUTPUTDIR)/altclasses_classes,\ - JAR:=$(JDK_OUTPUTDIR)/lib/alt-rt.jar)) + BIN:=$(JDK_OUTPUTDIR)/altclasses_classes)) -$(BUILD_ALTCLASSES_JAR): $(BUILD_JDK) -JARS += $(JDK_OUTPUTDIR)/lib/alt-rt.jar + $(BUILD_ALTCLASSES): $(BUILD_JDK) endif @@ -384,7 +355,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_15BYTECODE,\ SERVER_DIR:=$(SJAVAC_SERVER_DIR),\ SERVER_JVM:=$(SJAVAC_SERVER_JAVA))) -$(eval $(call SetupJavaCompilation,BUILD_JOBJC_JAR,\ +$(eval $(call SetupJavaCompilation,BUILD_JOBJC,\ SETUP:=GENERATE_15BYTECODE,\ DISABLE_SJAVAC:=true,\ SRC:=$(JDK_TOPDIR)/src/macosx/native/jobjc/src/core/java \ @@ -396,11 +367,9 @@ $(eval $(call SetupJavaCompilation,BUILD_JOBJC_JAR,\ JAR:=$(JDK_OUTPUTDIR)/lib/JObjC.jar, \ JARINDEX := true)) -$(BUILD_JOBJC_JAR) : $(BUILD_JDK) +$(BUILD_JOBJC) : $(BUILD_JDK) -JARS += $(JDK_OUTPUTDIR)/lib/JObjC.jar - -$(eval $(call SetupJavaCompilation,BUILD_JOBJC_HEADERS_JAR,\ +$(eval $(call SetupJavaCompilation,BUILD_JOBJC_HEADERS,\ SETUP:=GENERATE_JDKBYTECODE,\ SRC:=$(JDK_TOPDIR)/src/macosx/native/jobjc/src/core/java \ $(JDK_TOPDIR)/src/macosx/native/jobjc/src/runtime-additions/java \ @@ -410,16 +379,15 @@ $(eval $(call SetupJavaCompilation,BUILD_JOBJC_HEADERS_JAR,\ BIN:=$(JDK_OUTPUTDIR)/jobjc_classes_headers,\ HEADERS:=$(JDK_OUTPUTDIR)/gensrc_headers_jobjc)) -$(BUILD_JOBJC_HEADERS_JAR) : $(BUILD_JDK) - -JARS += $(BUILD_JOBJC_HEADERS_JAR) +$(BUILD_JOBJC_HEADERS) : $(BUILD_JDK) endif ########################################################################################## # copy with -a to preserve timestamps so dependencies down the line aren't messed up -all: $(BUILD_JDK) $(JARS) $(COPY_EXTRA) $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin \ +all: $(BUILD_JDK) $(BUILD_ALTCLASSES) $(BUILD_JOBJC) $(BUILD_JOBJC_HEADERS) $(COPY_EXTRA) \ + $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin \ $(JDK_OUTPUTDIR)/gensrc_headers/_the.jdk.base.headers .PHONY: all diff --git a/makefiles/CompileNativeLibraries.gmk b/makefiles/CompileNativeLibraries.gmk index 1bc8f9203550186fb9f8058b14808022c8887788..06abfab9406b12d444210d4f378d15c3b89bfec5 100644 --- a/makefiles/CompileNativeLibraries.gmk +++ b/makefiles/CompileNativeLibraries.gmk @@ -125,7 +125,7 @@ endif LIBVERIFY_OPTIMIZATION:=HIGH ifneq ($(findstring $(OPENJDK_TARGET_OS),solaris linux),) - ifeq ($(ENABLE_DEBUG_SYMBOLS), yes) + ifeq ($(ENABLE_DEBUG_SYMBOLS), true) LIBVERIFY_OPTIMIZATION:=LOW endif endif @@ -1645,7 +1645,7 @@ endif LIBMANAGEMENT_OPTIMIZATION:=HIGH ifneq ($(findstring $(OPENJDK_TARGET_OS),solaris linux),) - ifeq ($(ENABLE_DEBUG_SYMBOLS), yes) + ifeq ($(ENABLE_DEBUG_SYMBOLS), true) LIBMANAGEMENT_OPTIMIZATION:=LOW endif endif @@ -1688,7 +1688,7 @@ BUILD_LIBHPROF_LDFLAGS:= LIBHPROF_OPTIMIZATION:=HIGHEST ifneq ($(findstring $(OPENJDK_TARGET_OS),solaris linux),) - ifeq ($(ENABLE_DEBUG_SYMBOLS), yes) + ifeq ($(ENABLE_DEBUG_SYMBOLS), true) LIBHPROF_OPTIMIZATION:=LOW endif endif @@ -2236,7 +2236,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBKCMS,\ $(call SET_SHARED_LIBRARY_ORIGIN),\ LDFLAGS_SUFFIX_linux:=-lc -lpthread,\ LDFLAGS_SUFFIX_windows:=$(WIN_JAVA_LIB) advapi32.lib user32.lib version.lib, \ - LDFLAGS_SUFFIX:=-lm $(LDFLAGS_JDKLIB_SUFFIX),\ + LDFLAGS_SUFFIX_posix:=-lm -ljava -ljvm,\ VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/closed/share/native/sun/java2d/cmm/kcms/cmm.rc,\ VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/closed/share/native/sun/java2d/cmm/kcms/cmm.rc,\ RC_FLAGS:=$(RC_FLAGS)\ diff --git a/makefiles/CreateJars.gmk b/makefiles/CreateJars.gmk index c317d8d795c95e895280561c4a4cd190c2f700ef..cd5ec1fd2583f9be3e7b3a0b94a65fdd7b663782 100644 --- a/makefiles/CreateJars.gmk +++ b/makefiles/CreateJars.gmk @@ -446,9 +446,7 @@ ifndef OPENJDK $(SUNPKCS11_JAR_DST) : $(SUNPKCS11_JAR_SRC) @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunPKCS11 provider..." - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(install-file) else @@ -476,9 +474,7 @@ ifndef OPENJDK $(SUNEC_JAR_DST) : $(SUNEC_JAR_SRC) @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunEC provider..." - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(install-file) else @@ -518,9 +514,8 @@ ifndef OPENJDK $(SUNJCE_PROVIDER_JAR_DST) : $(SUNJCE_PROVIDER_JAR_SRC) @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunJCE provider..." - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(install-file) + else $(eval $(call SetupArchive,BUILD_SUNJCE_PROVIDER_JAR,,\ @@ -545,9 +540,7 @@ ifndef OPENJDK $(JCE_JAR_DST) : $(JCE_JAR_SRC) @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt jce.jar..." - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(install-file) else @@ -567,76 +560,86 @@ JARS += $(JCE_JAR_DST) ########################################################################################## -ifdef OPENJDK - -# -# TODO fix so that SetupArchive does not write files into SRCS -# then we don't need this extra copying -# -# NOTE: We currently do not place restrictions on our limited export -# policy. This was not a typo. -# US_EXPORT_POLICY_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/security/US_export_policy.jar -US_EXPORT_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited -US_EXPORT_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/US_export_policy_jar.tmp -$(US_EXPORT_POLICY_JAR_TMP)/% : $(US_EXPORT_POLICY_JAR_SRC_DIR)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ +ifndef OPENJDK + + + $(US_EXPORT_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/US_export_policy.jar + $(ECHO) $(LOG_INFO) Copying $(@F) + $(install-file) + +else + + # + # TODO fix so that SetupArchive does not write files into SRCS + # then we don't need this extra copying + # + # NOTE: We currently do not place restrictions on our limited export + # policy. This was not a typo. + # + US_EXPORT_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited + US_EXPORT_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/US_export_policy_jar.tmp -US_EXPORT_POLICY_JAR_DEPS := $(US_EXPORT_POLICY_JAR_TMP)/default_US_export.policy + $(US_EXPORT_POLICY_JAR_TMP)/% : $(US_EXPORT_POLICY_JAR_SRC_DIR)/% + $(install-file) -$(eval $(call SetupArchive,BUILD_US_EXPORT_POLICY_JAR,$(US_EXPORT_POLICY_JAR_DEPS),\ + US_EXPORT_POLICY_JAR_DEPS := $(US_EXPORT_POLICY_JAR_TMP)/default_US_export.policy + + $(eval $(call SetupArchive,BUILD_US_EXPORT_POLICY_JAR,$(US_EXPORT_POLICY_JAR_DEPS),\ SRCS:=$(US_EXPORT_POLICY_JAR_TMP), \ SUFFIXES:= .policy,\ JAR:=$(US_EXPORT_POLICY_JAR_DST), \ EXTRA_MANIFEST_ATTR := Crypto-Strength: unlimited, \ SKIP_METAINF := true)) -JARS += $(US_EXPORT_POLICY_JAR_DST) - endif +JARS += $(US_EXPORT_POLICY_JAR_DST) + ########################################################################################## +LOCAL_POLICY_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/security/local_policy.jar -ifdef OPENJDK +ifndef OPENJDK -# -# TODO fix so that SetupArchive does not write files into SRCS -# then we don't need this extra copying -# -LOCAL_POLICY_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/security/local_policy.jar -LOCAL_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/local_policy_jar.tmp + $(LOCAL_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/local_policy.jar + $(ECHO) $(LOG_INFO) Copying $(@F) + $(install-file) -ifeq ($(UNLIMITED_CRYPTO), true) - LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited - LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/default_local.policy - LOCAL_POLICY_JAR_ATTR := Crypto-Strength: unlimited else - LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/limited - LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/exempt_local.policy \ - $(LOCAL_POLICY_JAR_TMP)/default_local.policy - LOCAL_POLICY_JAR_ATTR := Crypto-Strength: limited -endif -$(LOCAL_POLICY_JAR_TMP)/% : $(LOCAL_POLICY_JAR_SRC_DIR)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ - -$(eval $(call SetupArchive,BUILD_LOCAL_POLICY_JAR,$(LOCAL_POLICY_JAR_DEPS),\ + # + # TODO fix so that SetupArchive does not write files into SRCS + # then we don't need this extra copying + # + LOCAL_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/local_policy_jar.tmp + + ifeq ($(UNLIMITED_CRYPTO), true) + LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited + LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/default_local.policy + LOCAL_POLICY_JAR_ATTR := Crypto-Strength: unlimited + else + LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/limited + LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/exempt_local.policy \ + $(LOCAL_POLICY_JAR_TMP)/default_local.policy + LOCAL_POLICY_JAR_ATTR := Crypto-Strength: limited + endif + + $(LOCAL_POLICY_JAR_TMP)/% : $(LOCAL_POLICY_JAR_SRC_DIR)/% + $(install-file) + + $(eval $(call SetupArchive,BUILD_LOCAL_POLICY_JAR,$(LOCAL_POLICY_JAR_DEPS),\ SRCS:=$(LOCAL_POLICY_JAR_TMP),\ SUFFIXES:= .policy,\ JAR:=$(LOCAL_POLICY_JAR_DST), \ EXTRA_MANIFEST_ATTR := $(LOCAL_POLICY_JAR_ATTR), \ SKIP_METAINF := true)) -JARS += $(LOCAL_POLICY_JAR_DST) - endif +JARS += $(LOCAL_POLICY_JAR_DST) + ########################################################################################## ifeq ($(OPENJDK_TARGET_OS),windows) @@ -648,9 +651,7 @@ SUNMSCAPI_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/mscapi/sunmscapi.jar $(SUNMSCAPI_JAR_DST) : $(SUNMSCAPI_JAR_SRC) @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunMSCAPI provider..." - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(install-file) else @@ -676,9 +677,7 @@ UCRYPTO_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/ucrypto/ucrypto.jar $(UCRYPTO_JAR_DST) : $(UCRYPTO_JAR_SRC) @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt OracleUcrypto provider..." - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(install-file) JARS += $(UCRYPTO_JAR_DST) @@ -897,14 +896,10 @@ LAUNCHER_ZIP_SRC := $(patsubst $(JDK_TOPDIR)/src/share/bin/%,$(IMAGES_OUTPUTDIR) $(LAUNCHER_SRC_FILES))) $(IMAGES_OUTPUTDIR)/src/launcher/%: $(JDK_TOPDIR)/src/share/bin/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(install-file) $(IMAGES_OUTPUTDIR)/src/launcher/%: $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/bin/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(install-file) $(IMAGES_OUTPUTDIR)/src.zip: $(LAUNCHER_ZIP_SRC) @@ -922,6 +917,55 @@ JARS+=$(IMAGES_OUTPUTDIR)/src.zip ########################################################################################## +# +# This is an empty jar (only contains manifest) and fits poorly into framework... +# create simple rule instead +# +$(IMAGES_OUTPUTDIR)/lib/management-agent.jar : $(JDK_TOPDIR)/src/share/classes/sun/management/manifest + $(JAR) cfm $@ $< + +JARS += $(IMAGES_OUTPUTDIR)/lib/management-agent.jar + +########################################################################################## + +$(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar : $(JDK_OUTPUTDIR)/demo/nio/zipfs/zipfs.jar + $(install-file) + +JARS += $(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar + +########################################################################################## + +ifeq ($(OPENJDK_TARGET_OS),macosx) + $(eval $(call SetupArchive,BUILD_JOBJC_JAR,,\ + SRCS:=$(JDK_OUTPUTDIR)/jobjc_classes,\ + JAR:=$(IMAGES_OUTPUTDIR)/lib/JObjC.jar, \ + JARINDEX:=true)) + + JARS += $(IMAGES_OUTPUTDIR)/lib/JObjC.jar +endif + +########################################################################################## + +ifndef OPENJDK + $(eval $(call SetupArchive,BUILD_ALT_RT_JAR,,\ + SRCS:=$(JDK_OUTPUTDIR)/altclasses_classes,\ + JAR:=$(IMAGES_OUTPUTDIR)/lib/alt-rt.jar)) + + JARS += $(IMAGES_OUTPUTDIR)/lib/alt-rt.jar +endif + +########################################################################################## + +# This file is imported from hotspot in Import.gmk. Copying it into images/lib so that +# all jars can be found in one place when creating images in Images.gmk. It needs to be +# done here so that clean targets can be simple and accurate. +$(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar: $(JDK_OUTPUTDIR)/lib/sa-jdi.jar + $(install-file) + +JARS += $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar + +########################################################################################## + -include $(CUSTOM_MAKE_DIR)/CreateJars.gmk ########################################################################################## diff --git a/makefiles/Images.gmk b/makefiles/Images.gmk index 64d8bb19a226231590efae6d7aa74b1efaeb0c51..5a85e6c37f3ab3b1da259b9adbae6d3fa608fc4e 100644 --- a/makefiles/Images.gmk +++ b/makefiles/Images.gmk @@ -211,10 +211,11 @@ ifeq ($(OPENJDK_TARGET_OS), linux) endif # Find all files to copy from $(JDK_OUTPUTDIR)/lib +# Jar files are not expected to be here ALL_JDKOUT_LIB_LIST := $(shell $(FIND) $(JDK_OUTPUTDIR)/lib \( -type f -o -type l \) -a ! \ - \( -name "_the*" -o -name "javac_state " \) ) + \( -name "_the*" -o -name "javac_state " -o -name "*.jar" \) ) # Find all files to copy from $(IMAGES_OUTPUTDIR)/lib -# This might not exist if building overlay-images +# This is were the jar files are and might not exist if building overlay-images ifneq ($(wildcard $(IMAGES_OUTPUTDIR)/lib),) ALL_IMAGES_LIB_LIST := $(shell $(FIND) $(IMAGES_OUTPUTDIR)/lib \( -type f -o -type l \) -a ! \ \( -name "_the*" -o -name "javac_state " \) ) diff --git a/makefiles/Import.gmk b/makefiles/Import.gmk index 692c6ee2a9c2b53573cdda3b640c1d5a4891d9e8..6d7673e0e0cdbae6b1c55c2f467a1776fb727699 100644 --- a/makefiles/Import.gmk +++ b/makefiles/Import.gmk @@ -231,22 +231,6 @@ define install-file endef endif -ifndef OPENJDK - -IMPORT_TARGET_FILES += \ - $(JDK_OUTPUTDIR)/lib/security/US_export_policy.jar \ - $(JDK_OUTPUTDIR)/lib/security/local_policy.jar - -$(JDK_OUTPUTDIR)/lib/security/local_policy.jar: $(JDK_TOPDIR)/make/closed/tools/crypto/jce/local_policy.jar - $(ECHO) $(LOG_INFO) Copying $(@F) - $(install-file) - -$(JDK_OUTPUTDIR)/lib/security/US_export_policy.jar: $(JDK_TOPDIR)/make/closed/tools/crypto/jce/US_export_policy.jar - $(ECHO) $(LOG_INFO) Copying $(@F) - $(install-file) - -endif # OPENJDK - ####### all: $(IMPORT_TARGET_FILES) diff --git a/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java b/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java index 3c872df2b26b6123e7185e4868b5212429480aaf..4f108da2df053aa5d2cce99dd39ef48dba16c2e0 100644 --- a/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java +++ b/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java @@ -714,7 +714,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel { "PopupMenu.font", menuFont, "PopupMenu.background", menuBackgroundColor, - "PopupMenu.translucentBackground", translucentWhite, + // Fix for 7154516: make popups opaque + "PopupMenu.translucentBackground", white, "PopupMenu.foreground", menuForegroundColor, "PopupMenu.selectionBackground", menuSelectedBackgroundColor, "PopupMenu.selectionForeground", menuSelectedForegroundColor, diff --git a/src/macosx/classes/sun/awt/CGraphicsConfig.java b/src/macosx/classes/sun/awt/CGraphicsConfig.java index 01409a5bb0a106976a86f1e85dfd08a4cdd7335e..fb37d01209ccd803cdb855e803be220972be6a8a 100644 --- a/src/macosx/classes/sun/awt/CGraphicsConfig.java +++ b/src/macosx/classes/sun/awt/CGraphicsConfig.java @@ -31,13 +31,16 @@ import java.awt.image.*; import sun.java2d.SurfaceData; import sun.java2d.opengl.CGLLayer; +import sun.lwawt.LWGraphicsConfig; import sun.lwawt.macosx.CPlatformView; -public class CGraphicsConfig extends GraphicsConfiguration { +public abstract class CGraphicsConfig extends GraphicsConfiguration + implements LWGraphicsConfig { + private final CGraphicsDevice device; private ColorModel colorModel; - public CGraphicsConfig(CGraphicsDevice device) { + protected CGraphicsConfig(CGraphicsDevice device) { this.device = device; } @@ -84,88 +87,20 @@ public class CGraphicsConfig extends GraphicsConfiguration { return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0); } - - /** - * The following methods are invoked from CToolkit.java and - * LWWindowPeer.java rather than having the native - * implementations hardcoded in those classes. This way the appropriate - * actions are taken based on the peer's GraphicsConfig, whether it is - * an CGLGraphicsConfig or something else. - */ - /** * Creates a new SurfaceData that will be associated with the given * LWWindowPeer. */ - public SurfaceData createSurfaceData(CPlatformView pView) { - throw new UnsupportedOperationException("not implemented"); - } + public abstract SurfaceData createSurfaceData(CPlatformView pView); /** * Creates a new SurfaceData that will be associated with the given * CGLLayer. */ - public SurfaceData createSurfaceData(CGLLayer layer) { - throw new UnsupportedOperationException("not implemented"); - } - - /** - * Creates a new hidden-acceleration image of the given width and height - * that is associated with the target Component. - */ - public Image createAcceleratedImage(Component target, - int width, int height) - { - throw new UnsupportedOperationException("not implemented"); - } - - /** - * The following methods correspond to the multibuffering methods in - * LWWindowPeer.java... - */ - - /** - * Attempts to create a native backbuffer for the given peer. If - * the requested configuration is not natively supported, an AWTException - * is thrown. Otherwise, if the backbuffer creation is successful, a - * handle to the native backbuffer is returned. - */ - public long createBackBuffer(CPlatformView pView, - int numBuffers, BufferCapabilities caps) - throws AWTException - { - throw new UnsupportedOperationException("not implemented"); - } - - public void destroyBackBuffer(long backBuffer) - throws AWTException - { - throw new UnsupportedOperationException("not implemented"); - } - - /** - * Creates a VolatileImage that essentially wraps the target Component's - * backbuffer, using the provided backbuffer handle. - */ - public VolatileImage createBackBufferImage(Component target, - long backBuffer) - { - throw new UnsupportedOperationException("not implemented"); - } - - /** - * Performs the native flip operation for the given target Component. - */ - public void flip(CPlatformView delegate, - Component target, VolatileImage xBackBuffer, - int x1, int y1, int x2, int y2, - BufferCapabilities.FlipContents flipAction) - { - throw new UnsupportedOperationException("not implemented"); - } + public abstract SurfaceData createSurfaceData(CGLLayer layer); @Override - public boolean isTranslucencyCapable() { + public final boolean isTranslucencyCapable() { //we know for sure we have capable config :) return true; } diff --git a/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java b/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java index 8c36ddc6614c16acfa9be8acb5786c1ef4526b09..230f7057927ec828836e563effeab6dc0dba7023 100644 --- a/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java +++ b/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java @@ -27,7 +27,6 @@ package sun.java2d.opengl; import java.awt.AWTException; import java.awt.BufferCapabilities; -import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; @@ -48,13 +47,10 @@ import java.awt.image.WritableRaster; import sun.awt.CGraphicsConfig; import sun.awt.CGraphicsDevice; -import sun.awt.TextureSizeConstraining; import sun.awt.image.OffScreenImage; import sun.awt.image.SunVolatileImage; -import sun.awt.image.SurfaceManager; import sun.java2d.Disposer; import sun.java2d.DisposerRecord; -import sun.java2d.SunGraphics2D; import sun.java2d.Surface; import sun.java2d.SurfaceData; import sun.java2d.opengl.OGLContext.OGLContextCaps; @@ -63,18 +59,19 @@ import sun.java2d.pipe.hw.AccelTypedVolatileImage; import sun.java2d.pipe.hw.ContextCapabilities; import static sun.java2d.opengl.OGLSurfaceData.*; import static sun.java2d.opengl.OGLContext.OGLContextCaps.*; -import sun.java2d.opengl.CGLSurfaceData.CGLVSyncOffScreenSurfaceData; import sun.java2d.pipe.hw.AccelDeviceEventListener; import sun.java2d.pipe.hw.AccelDeviceEventNotifier; +import sun.lwawt.LWComponentPeer; import sun.lwawt.macosx.CPlatformView; -public class CGLGraphicsConfig extends CGraphicsConfig - implements OGLGraphicsConfig, TextureSizeConstraining +public final class CGLGraphicsConfig extends CGraphicsConfig + implements OGLGraphicsConfig { - //private static final int kOpenGLSwapInterval = RuntimeOptions.getCurrentOptions().OpenGLSwapInterval; + //private static final int kOpenGLSwapInterval = + // RuntimeOptions.getCurrentOptions().OpenGLSwapInterval; private static final int kOpenGLSwapInterval = 0; // TODO - protected static boolean cglAvailable; + private static boolean cglAvailable; private static ImageCapabilities imageCaps = new CGLImageCaps(); private int pixfmt; @@ -82,7 +79,7 @@ public class CGLGraphicsConfig extends CGraphicsConfig private long pConfigInfo; private ContextCapabilities oglCaps; private OGLContext context; - private Object disposerReferent = new Object(); + private final Object disposerReferent = new Object(); public static native int getDefaultPixFmt(int screennum); private static native boolean initCGL(); @@ -94,7 +91,7 @@ public class CGLGraphicsConfig extends CGraphicsConfig cglAvailable = initCGL(); } - protected CGLGraphicsConfig(CGraphicsDevice device, int pixfmt, + private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt, long configInfo, ContextCapabilities oglCaps) { super(device); @@ -170,11 +167,13 @@ public class CGLGraphicsConfig extends CGraphicsConfig * Returns true if the provided capability bit is present for this config. * See OGLContext.java for a list of supported capabilities. */ - public final boolean isCapPresent(int cap) { + @Override + public boolean isCapPresent(int cap) { return ((oglCaps.getCaps() & cap) != 0); } - public final long getNativeConfigInfo() { + @Override + public long getNativeConfigInfo() { return pConfigInfo; } @@ -183,7 +182,8 @@ public class CGLGraphicsConfig extends CGraphicsConfig * * @see sun.java2d.pipe.hw.BufferedContextProvider#getContext */ - public final OGLContext getContext() { + @Override + public OGLContext getContext() { return context; } @@ -257,145 +257,83 @@ public class CGLGraphicsConfig extends CGraphicsConfig return ("CGLGraphicsConfig[dev="+screen+",pixfmt="+pixfmt+"]"); } - - /** - * The following methods are invoked from ComponentModel.java rather - * than having the Mac OS X-dependent implementations hardcoded in that - * class. This way the appropriate actions are taken based on the peer's - * GraphicsConfig, whether it is a CGraphicsConfig or a - * CGLGraphicsConfig. - */ - - /** - * Creates a new SurfaceData that will be associated with the given - * LWWindowPeer. - */ @Override public SurfaceData createSurfaceData(CPlatformView pView) { return CGLSurfaceData.createData(pView); } - /** - * Creates a new SurfaceData that will be associated with the given - * CGLLayer. - */ @Override public SurfaceData createSurfaceData(CGLLayer layer) { return CGLSurfaceData.createData(layer); } - /** - * Creates a new hidden-acceleration image of the given width and height - * that is associated with the target Component. - */ @Override public Image createAcceleratedImage(Component target, int width, int height) { ColorModel model = getColorModel(Transparency.OPAQUE); - WritableRaster wr = - model.createCompatibleWritableRaster(width, height); + WritableRaster wr = model.createCompatibleWritableRaster(width, height); return new OffScreenImage(target, model, wr, model.isAlphaPremultiplied()); } - /** - * The following methods correspond to the multibuffering methods in - * CWindowPeer.java... - */ - - /** - * Attempts to create a OGL-based backbuffer for the given peer. If - * the requested configuration is not natively supported, an AWTException - * is thrown. Otherwise, if the backbuffer creation is successful, a - * value of 1 is returned. - */ @Override - public long createBackBuffer(CPlatformView pView, - int numBuffers, BufferCapabilities caps) - throws AWTException - { - if (numBuffers > 2) { - throw new AWTException( - "Only double or single buffering is supported"); + public void assertOperationSupported(final int numBuffers, + final BufferCapabilities caps) + throws AWTException { + // Assume this method is never called with numBuffers != 2, as 0 is + // unsupported, and 1 corresponds to a SingleBufferStrategy which + // doesn't depend on the peer. Screen is considered as a separate + // "buffer". + if (numBuffers != 2) { + throw new AWTException("Only double buffering is supported"); } - BufferCapabilities configCaps = getBufferCapabilities(); + final BufferCapabilities configCaps = getBufferCapabilities(); if (!configCaps.isPageFlipping()) { throw new AWTException("Page flipping is not supported"); } if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) { throw new AWTException("FlipContents.PRIOR is not supported"); } - - // non-zero return value means backbuffer creation was successful - // (checked in CPlatformWindow.flip(), etc.) - return 1; } - /** - * Destroys the backbuffer object represented by the given handle value. - */ @Override - public void destroyBackBuffer(long backBuffer) { + public Image createBackBuffer(final LWComponentPeer peer) { + final Rectangle r = peer.getBounds(); + // It is possible for the component to have size 0x0, adjust it to + // be at least 1x1 to avoid IAE + final int w = Math.max(1, r.width); + final int h = Math.max(1, r.height); + final int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT + : Transparency.OPAQUE; + return new SunVolatileImage(this, w, h, transparency, null); } - /** - * Creates a VolatileImage that essentially wraps the target Component's - * backbuffer (the provided backbuffer handle is essentially ignored). - */ @Override - public VolatileImage createBackBufferImage(Component target, - long backBuffer) - { - return new SunVolatileImage(target, - target.getWidth(), target.getHeight(), - Boolean.TRUE); + public void destroyBackBuffer(final Image backBuffer) { + if (backBuffer != null) { + backBuffer.flush(); + } } - /** - * Performs the native OGL flip operation for the given target Component. - */ @Override - public void flip(CPlatformView pView, - Component target, VolatileImage xBackBuffer, - int x1, int y1, int x2, int y2, - BufferCapabilities.FlipContents flipAction) - { - if (flipAction == BufferCapabilities.FlipContents.COPIED) { - SurfaceManager vsm = SurfaceManager.getManager(xBackBuffer); - SurfaceData sd = vsm.getPrimarySurfaceData(); - - if (sd instanceof CGLVSyncOffScreenSurfaceData) { - CGLVSyncOffScreenSurfaceData vsd = - (CGLVSyncOffScreenSurfaceData)sd; - SurfaceData bbsd = vsd.getFlipSurface(); - Graphics2D bbg = - new SunGraphics2D(bbsd, Color.black, Color.white, null); - try { - bbg.drawImage(xBackBuffer, 0, 0, null); - } finally { - bbg.dispose(); - } - } else { - pView.drawImageOnPeer(xBackBuffer, x1, y1, x2, y2); - return; - } - } else if (flipAction == BufferCapabilities.FlipContents.PRIOR) { - // not supported by CGL... - return; + public void flip(final LWComponentPeer peer, final Image backBuffer, + final int x1, final int y1, final int x2, final int y2, + final BufferCapabilities.FlipContents flipAction) { + final Graphics g = peer.getGraphics(); + try { + g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null); + } finally { + g.dispose(); } - - OGLSurfaceData.swapBuffers(pView.getAWTView()); - if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) { - Graphics g = xBackBuffer.getGraphics(); + final Graphics2D bg = (Graphics2D) backBuffer.getGraphics(); try { - g.setColor(target.getBackground()); - g.fillRect(0, 0, - xBackBuffer.getWidth(), - xBackBuffer.getHeight()); + bg.setBackground(peer.getBackground()); + bg.clearRect(0, 0, backBuffer.getWidth(null), + backBuffer.getHeight(null)); } finally { - g.dispose(); + bg.dispose(); } } } @@ -429,15 +367,10 @@ public class CGLGraphicsConfig extends CGraphicsConfig return imageCaps; } - /** - * {@inheritDoc} - * - * @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage - */ - public VolatileImage - createCompatibleVolatileImage(int width, int height, - int transparency, int type) - { + @Override + public VolatileImage createCompatibleVolatileImage(int width, int height, + int transparency, + int type) { if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED || transparency == Transparency.BITMASK) { @@ -473,15 +406,18 @@ public class CGLGraphicsConfig extends CGraphicsConfig * * @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities */ + @Override public ContextCapabilities getContextCapabilities() { return oglCaps; } + @Override public void addDeviceEventListener(AccelDeviceEventListener l) { int screen = getDevice().getCoreGraphicsScreen(); AccelDeviceEventNotifier.addListener(l, screen); } + @Override public void removeDeviceEventListener(AccelDeviceEventListener l) { AccelDeviceEventNotifier.removeListener(l); } diff --git a/src/macosx/classes/sun/lwawt/LWCanvasPeer.java b/src/macosx/classes/sun/lwawt/LWCanvasPeer.java index f61b978d23030f16237b2c2d11d9d02155773097..0c80ff0af0db0d1264ba2dafff162152b566f782 100644 --- a/src/macosx/classes/sun/lwawt/LWCanvasPeer.java +++ b/src/macosx/classes/sun/lwawt/LWCanvasPeer.java @@ -26,12 +26,9 @@ package sun.lwawt; -import java.awt.AWTException; -import java.awt.BufferCapabilities; import java.awt.Component; import java.awt.Dimension; import java.awt.GraphicsConfiguration; -import java.awt.Image; import java.awt.peer.CanvasPeer; import javax.swing.JComponent; @@ -42,35 +39,10 @@ class LWCanvasPeer LWCanvasPeer(final T target, final PlatformComponent platformComponent) { super(target, platformComponent); } - // ---- PEER METHODS ---- // - - @Override - public void createBuffers(int numBuffers, BufferCapabilities caps) - throws AWTException { - // TODO - } - - @Override - public Image getBackBuffer() { - // TODO - return null; - } - - @Override - public void flip(int x1, int y1, int x2, int y2, - BufferCapabilities.FlipContents flipAction) { - // TODO - } - - @Override - public void destroyBuffers() { - // TODO - } @Override public final GraphicsConfiguration getAppropriateGraphicsConfiguration( - GraphicsConfiguration gc) - { + final GraphicsConfiguration gc) { // TODO return gc; } diff --git a/src/macosx/classes/sun/lwawt/LWComponentPeer.java b/src/macosx/classes/sun/lwawt/LWComponentPeer.java index db6d2dd4430cec56a4677999033536e94e896721..55b4665a7521f80f8b35d89346b97a07ae93202d 100644 --- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java +++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java @@ -138,6 +138,11 @@ public abstract class LWComponentPeer */ static final char WIDE_CHAR = '0'; + /** + * The back buffer provide user with a BufferStrategy. + */ + private Image backBuffer; + private final class DelegateContainer extends Container { { enableEvents(0xFFFFFFFF); @@ -389,6 +394,7 @@ public abstract class LWComponentPeer } protected void disposeImpl() { + destroyBuffers(); LWContainerPeer cp = getContainerPeer(); if (cp != null) { cp.removeChildPeer(this); @@ -415,6 +421,12 @@ public abstract class LWComponentPeer return getWindowPeer().getGraphicsConfiguration(); } + + // Just a helper method + public final LWGraphicsConfig getLWGC() { + return (LWGraphicsConfig) getGraphicsConfiguration(); + } + /* * Overridden in LWWindowPeer to replace its surface * data and back buffer. @@ -506,31 +518,45 @@ public abstract class LWComponentPeer return getGraphicsConfiguration().getColorModel(); } + public boolean isTranslucent() { + // Translucent windows of the top level are supported only + return false; + } + @Override - public void createBuffers(int numBuffers, BufferCapabilities caps) + public final void createBuffers(int numBuffers, BufferCapabilities caps) throws AWTException { - throw new AWTException("Back buffers are only supported for " + - "Window or Canvas components."); + getLWGC().assertOperationSupported(numBuffers, caps); + final Image buffer = getLWGC().createBackBuffer(this); + synchronized (getStateLock()) { + backBuffer = buffer; + } } - /* - * To be overridden in LWWindowPeer and LWCanvasPeer. - */ @Override - public Image getBackBuffer() { - // Return null or throw AWTException? - return null; + public final Image getBackBuffer() { + synchronized (getStateLock()) { + if (backBuffer != null) { + return backBuffer; + } + } + throw new IllegalStateException("Buffers have not been created"); } @Override - public void flip(int x1, int y1, int x2, int y2, + public final void flip(int x1, int y1, int x2, int y2, BufferCapabilities.FlipContents flipAction) { - // Skip silently or throw AWTException? + getLWGC().flip(this, getBackBuffer(), x1, y1, x2, y2, flipAction); } @Override - public void destroyBuffers() { - // Do nothing + public final void destroyBuffers() { + final Image oldBB; + synchronized (getStateLock()) { + oldBB = backBuffer; + backBuffer = null; + } + getLWGC().destroyBackBuffer(oldBB); } // Helper method @@ -642,7 +668,7 @@ public abstract class LWComponentPeer } } - protected final Color getBackground() { + public final Color getBackground() { synchronized (getStateLock()) { return background; } @@ -982,19 +1008,17 @@ public abstract class LWComponentPeer } @Override - public Image createImage(ImageProducer producer) { + public final Image createImage(final ImageProducer producer) { return new ToolkitImage(producer); } @Override - public Image createImage(int w, int h) { - CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration(); - return gc.createAcceleratedImage(getTarget(), w, h); + public final Image createImage(final int width, final int height) { + return getLWGC().createAcceleratedImage(getTarget(), width, height); } @Override - public VolatileImage createVolatileImage(int w, int h) { - // TODO: is it a right/complete implementation? + public final VolatileImage createVolatileImage(final int w, final int h) { return new SunVolatileImage(getTarget(), w, h); } @@ -1105,8 +1129,6 @@ public abstract class LWComponentPeer * of target.setLocation() or as a result of user actions (window is * dragged with mouse). * - * To be overridden in LWWindowPeer to update its GraphicsConfig. - * * This method could be called on the toolkit thread. */ protected final void handleMove(final int x, final int y, @@ -1122,13 +1144,19 @@ public abstract class LWComponentPeer * Called when this peer's size has been changed either as a result of * target.setSize() or as a result of user actions (window is resized). * - * To be overridden in LWWindowPeer to update its SurfaceData and - * GraphicsConfig. - * * This method could be called on the toolkit thread. */ protected final void handleResize(final int w, final int h, final boolean updateTarget) { + Image oldBB = null; + synchronized (getStateLock()) { + if (backBuffer != null) { + oldBB = backBuffer; + backBuffer = getLWGC().createBackBuffer(this); + } + } + getLWGC().destroyBackBuffer(oldBB); + if (updateTarget) { AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h); } diff --git a/src/macosx/classes/sun/lwawt/LWGraphicsConfig.java b/src/macosx/classes/sun/lwawt/LWGraphicsConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..d556ea759952d9334ae832c972f17123dd3d9864 --- /dev/null +++ b/src/macosx/classes/sun/lwawt/LWGraphicsConfig.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.lwawt; + +import java.awt.AWTException; +import java.awt.BufferCapabilities; +import java.awt.Component; +import java.awt.Image; + +/** + * As lwawt can be used on different platforms with different graphic + * configurations, the general set of methods is necessary. This interface + * collects the methods that should be provided by GraphicsConfiguration, + * simplifying use by the LWAWT. + * + * @author Sergey Bylokhov + */ +public interface LWGraphicsConfig { + + /* + * A GraphicsConfiguration must implements following methods to indicate + * that it imposes certain limitations on the maximum size of supported + * textures. + */ + + /** + * Returns the maximum width of any texture image. By default return {@code + * Integer.MAX_VALUE}. + */ + int getMaxTextureWidth(); + + /** + * Returns the maximum height of any texture image. By default return {@code + * Integer.MAX_VALUE}. + */ + int getMaxTextureHeight(); + + /* + * The following methods correspond to the multi-buffering methods in + * LWComponentPeer.java. + */ + + /** + * Checks that the requested configuration is natively supported; if not, an + * AWTException is thrown. + */ + void assertOperationSupported(int numBuffers, BufferCapabilities caps) + throws AWTException; + + /** + * Creates a back buffer for the given peer and returns the image wrapper. + */ + Image createBackBuffer(LWComponentPeer peer); + + /** + * Destroys the back buffer object. + */ + void destroyBackBuffer(Image backBuffer); + + /** + * Performs the native flip operation for the given target Component. Our + * flip is implemented through normal drawImage() to the graphic object, + * because of our components uses a graphic object of the container(in this + * case we also apply necessary constrains) + */ + void flip(LWComponentPeer peer, Image backBuffer, int x1, int y1, + int x2, int y2, BufferCapabilities.FlipContents flipAction); + + /** + * Creates a new hidden-acceleration image of the given width and height + * that is associated with the target Component. + */ + Image createAcceleratedImage(Component target, int width, int height); +} diff --git a/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/src/macosx/classes/sun/lwawt/LWWindowPeer.java index 5d3c88295e4e0b3ca2cca81065e3a37ae2f55732..02dcaaf02858cf6eb155a67b751afc7338981a1f 100644 --- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -27,7 +27,6 @@ package sun.lwawt; import java.awt.*; import java.awt.event.*; -import java.awt.image.BufferedImage; import java.awt.peer.*; import java.util.List; @@ -75,17 +74,6 @@ public class LWWindowPeer private SurfaceData surfaceData; private final Object surfaceDataLock = new Object(); - private int backBufferCount; - private BufferCapabilities backBufferCaps; - - // The back buffer is used for two purposes: - // 1. To render all the lightweight peers - // 2. To provide user with a BufferStrategy - // Need to check if a single back buffer can be used for both -// TODO: VolatileImage -// private VolatileImage backBuffer; - private volatile BufferedImage backBuffer; - private volatile int windowState = Frame.NORMAL; // check that the mouse is over the window @@ -227,7 +215,6 @@ public class LWWindowPeer if (isGrabbing()) { ungrab(); } - destroyBuffers(); platformWindow.dispose(); super.disposeImpl(); } @@ -258,8 +245,10 @@ public class LWWindowPeer } @Override - public GraphicsConfiguration getGraphicsConfiguration() { - return graphicsConfig; + public final GraphicsConfiguration getGraphicsConfiguration() { + synchronized (getStateLock()) { + return graphicsConfig; + } } @Override @@ -284,48 +273,6 @@ public class LWWindowPeer return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f)); } - @Override - public void createBuffers(int numBuffers, BufferCapabilities caps) - throws AWTException - { - try { - // Assume this method is never called with numBuffers <= 1, as 0 is - // unsupported, and 1 corresponds to a SingleBufferStrategy which - // doesn't depend on the peer. Screen is considered as a separate - // "buffer", that's why numBuffers - 1 - assert numBuffers > 1; - - replaceSurfaceData(numBuffers - 1, caps, false); - } catch (InvalidPipeException z) { - throw new AWTException(z.toString()); - } - } - - @Override - public final Image getBackBuffer() { - synchronized (getStateLock()) { - return backBuffer; - } - } - - @Override - public void flip(int x1, int y1, int x2, int y2, - BufferCapabilities.FlipContents flipAction) - { - platformWindow.flip(x1, y1, x2, y2, flipAction); - } - - @Override - public final void destroyBuffers() { - final Image oldBB = getBackBuffer(); - synchronized (getStateLock()) { - backBuffer = null; - } - if (oldBB != null) { - oldBB.flush(); - } - } - @Override public void setBounds(int x, int y, int w, int h, int op) { if ((op & SET_CLIENT_SIZE) != 0) { @@ -343,16 +290,14 @@ public class LWWindowPeer h = MINIMUM_HEIGHT; } - if (graphicsConfig instanceof TextureSizeConstraining) { - final int maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth(); - final int maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight(); + final int maxW = getLWGC().getMaxTextureWidth(); + final int maxH = getLWGC().getMaxTextureHeight(); - if (w > maxW) { - w = maxW; - } - if (h > maxH) { - h = maxH; - } + if (w > maxW) { + w = maxW; + } + if (h > maxH) { + h = maxH; } // Don't post ComponentMoved/Resized and Paint events @@ -431,21 +376,14 @@ public class LWWindowPeer min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT); } - final int maxW, maxH; - if (graphicsConfig instanceof TextureSizeConstraining) { - maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth(); - maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight(); - } else { - maxW = maxH = Integer.MAX_VALUE; - } - final Dimension max; if (getTarget().isMaximumSizeSet()) { max = getTarget().getMaximumSize(); - max.width = Math.min(max.width, maxW); - max.height = Math.min(max.height, maxH); + max.width = Math.min(max.width, getLWGC().getMaxTextureWidth()); + max.height = Math.min(max.height, getLWGC().getMaxTextureHeight()); } else { - max = new Dimension(maxW, maxH); + max = new Dimension(getLWGC().getMaxTextureWidth(), + getLWGC().getMaxTextureHeight()); } platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height); @@ -1014,21 +952,10 @@ public class LWWindowPeer replaceSurfaceData(true); } - private void replaceSurfaceData(boolean blit) { - replaceSurfaceData(backBufferCount, backBufferCaps, blit); - } - - private void replaceSurfaceData(int newBackBufferCount, - BufferCapabilities newBackBufferCaps, - boolean blit) { + private void replaceSurfaceData(final boolean blit) { synchronized (surfaceDataLock) { final SurfaceData oldData = getSurfaceData(); surfaceData = platformWindow.replaceSurfaceData(); - // TODO: volatile image - // VolatileImage oldBB = backBuffer; - BufferedImage oldBB = backBuffer; - backBufferCount = newBackBufferCount; - backBufferCaps = newBackBufferCaps; final Rectangle size = getSize(); if (getSurfaceData() != null && oldData != getSurfaceData()) { clearBackground(size.width, size.height); @@ -1043,35 +970,6 @@ public class LWWindowPeer // This can only happen when this peer is being created oldData.flush(); } - - // TODO: volatile image - // backBuffer = (VolatileImage)delegate.createBackBuffer(); - backBuffer = (BufferedImage) platformWindow.createBackBuffer(); - if (backBuffer != null) { - Graphics g = backBuffer.getGraphics(); - try { - Rectangle r = getBounds(); - if (g instanceof Graphics2D) { - ((Graphics2D) g).setComposite(AlphaComposite.Src); - } - g.setColor(nonOpaqueBackground); - g.fillRect(0, 0, r.width, r.height); - if (g instanceof SunGraphics2D) { - SG2DConstraint((SunGraphics2D) g, getRegion()); - } - if (!isTextured()) { - g.setColor(getBackground()); - g.fillRect(0, 0, r.width, r.height); - } - if (oldBB != null) { - // Draw the old back buffer to the new one - g.drawImage(oldBB, 0, 0, null); - oldBB.flush(); - } - } finally { - g.dispose(); - } - } } } @@ -1092,14 +990,6 @@ public class LWWindowPeer } } - public int getBackBufferCount() { - return backBufferCount; - } - - public BufferCapabilities getBackBufferCaps() { - return backBufferCaps; - } - /* * Request the window insets from the delegate and compares it * with the current one. This method is mostly called by the diff --git a/src/macosx/classes/sun/lwawt/PlatformWindow.java b/src/macosx/classes/sun/lwawt/PlatformWindow.java index d4a470de5cf3e5c98b58d667b45b955252d95c09..8b8e54de1b200a2c2e7ef757944435cc8313614a 100644 --- a/src/macosx/classes/sun/lwawt/PlatformWindow.java +++ b/src/macosx/classes/sun/lwawt/PlatformWindow.java @@ -97,17 +97,6 @@ public interface PlatformWindow { */ public SurfaceData replaceSurfaceData(); - /* - * Creates a new image to serve as a back buffer. - */ - public Image createBackBuffer(); - - /* - * Move the given part of the back buffer to the front buffer. - */ - public void flip(int x1, int y1, int x2, int y2, - BufferCapabilities.FlipContents flipAction); - public void setModalBlocked(boolean blocked); public void toFront(); diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java index e93f1ec4b9f758a1ddebab97449c5a960cee778b..6a26b50ae81df370afaa02e87608d6f489d1886b 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java @@ -31,12 +31,9 @@ import sun.lwawt.LWWindowPeer; import sun.java2d.opengl.CGLLayer; import sun.java2d.SurfaceData; -import sun.awt.CGraphicsConfig; -import sun.awt.CGraphicsDevice; import sun.awt.CausedFocusEvent; import java.awt.*; -import java.awt.BufferCapabilities.FlipContents; import sun.util.logging.PlatformLogger; @@ -112,22 +109,6 @@ public class CPlatformEmbeddedFrame implements PlatformWindow { return windowLayer.replaceSurfaceData(); } - @Override - public Image createBackBuffer() { - Rectangle r = peer.getBounds(); - Image im = null; - if (!r.isEmpty()) { - int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT : Transparency.OPAQUE; - im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency); - } - return im; - } - - @Override - public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) { - throw new RuntimeException("Not implemented"); - } - @Override public void setVisible(boolean visible) {} diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java index 1fc247f1c3ed62c0e662971ad51144461981cd5f..a7cdfd37d437fc2fd04d97ef7b03fb8691085c02 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java @@ -26,7 +26,6 @@ package sun.lwawt.macosx; import java.awt.*; -import java.awt.image.VolatileImage; import sun.awt.CGraphicsConfig; import sun.lwawt.LWWindowPeer; @@ -115,26 +114,6 @@ public class CPlatformView extends CFRetainedResource { // ---------------------------------------------------------------------- // PAINTING METHODS // ---------------------------------------------------------------------- - - public void drawImageOnPeer(VolatileImage xBackBuffer, int x1, int y1, int x2, int y2) { - Graphics g = peer.getGraphics(); - try { - g.drawImage(xBackBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null); - } finally { - g.dispose(); - } - } - - public Image createBackBuffer() { - Rectangle r = peer.getBounds(); - Image im = null; - if (!r.isEmpty()) { - int transparency = (isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT); - im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency); - } - return im; - } - public SurfaceData replaceSurfaceData() { if (!LWCToolkit.getSunAwtDisableCALayers()) { surfaceData = windowLayer.replaceSurfaceData(); diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java index 7fbc64c4f8dfd3c98d3665419bb9fda743a04bb4..e6ab69635ec4391c59a35b38cd2012a3acac09be 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java @@ -25,7 +25,6 @@ package sun.lwawt.macosx; -import java.awt.BufferCapabilities.FlipContents; import java.awt.*; import java.awt.Dialog.ModalityType; import java.awt.event.*; @@ -258,7 +257,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor validateSurface(); } - protected int getInitialStyleBits() { + private int getInitialStyleBits() { // defaults style bits int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE; @@ -285,7 +284,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false); styleBits = SET(styleBits, RESIZABLE, resizable); if (!resizable) { - styleBits = SET(styleBits, RESIZABLE, false); styleBits = SET(styleBits, ZOOMABLE, false); } } @@ -380,7 +378,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor } // this is the counter-point to -[CWindow _nativeSetStyleBit:] - protected void setStyleBits(final int mask, final boolean value) { + private void setStyleBits(final int mask, final boolean value) { nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0); } @@ -401,11 +399,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor } } - @Override // PlatformWindow - public Image createBackBuffer() { - return contentView.createBackBuffer(); - } - @Override // PlatformWindow public void dispose() { if (owner != null) { @@ -416,12 +409,6 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor CPlatformWindow.super.dispose(); } - @Override // PlatformWindow - public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) { - // TODO: not implemented - (new RuntimeException("unimplemented")).printStackTrace(); - } - @Override // PlatformWindow public FontMetrics getFontMetrics(Font f) { // TODO: not implemented @@ -668,15 +655,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor } @Override - public void setResizable(boolean resizable) { + public void setResizable(final boolean resizable) { setStyleBits(RESIZABLE, resizable); - - // Re-apply the size constraints and the size to ensure the space - // occupied by the grow box is counted properly - peer.updateMinimumSize(); - - Rectangle bounds = peer.getBounds(); - setBounds(bounds.x, bounds.y, bounds.width, bounds.height); } @Override @@ -889,7 +869,8 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor responder.handleWindowFocusEvent(gained, oppositePeer); } - private void deliverMoveResizeEvent(int x, int y, int width, int height) { + private void deliverMoveResizeEvent(int x, int y, int width, int height, + boolean byUser) { // when the content view enters the full-screen mode, the native // move/resize notifications contain a bounds smaller than // the whole screen and therefore we ignore the native notifications @@ -901,7 +882,7 @@ public final class CPlatformWindow extends CFRetainedResource implements Platfor final Rectangle oldB = nativeBounds; nativeBounds = new Rectangle(x, y, width, height); peer.notifyReshape(x, y, width, height); - if (!oldB.getSize().equals(nativeBounds.getSize()) ) { + if (byUser && !oldB.getSize().equals(nativeBounds.getSize())) { flushBuffers(); } //TODO validateSurface already called from notifyReshape diff --git a/src/macosx/native/sun/awt/AWTWindow.m b/src/macosx/native/sun/awt/AWTWindow.m index 3e25a6cb63c98fca83495271c5a5c5a91e2943b0..4b526ee81a77552b5c6a25f7e970e7d22962d374 100644 --- a/src/macosx/native/sun/awt/AWTWindow.m +++ b/src/macosx/native/sun/awt/AWTWindow.m @@ -160,6 +160,10 @@ AWT_NS_WINDOW_IMPLEMENTATION BOOL resizable = IS(bits, RESIZABLE); [self updateMinMaxSize:resizable]; [self.nsWindow setShowsResizeIndicator:resizable]; + // Zoom button should be disabled, if the window is not resizable, + // otherwise button should be restored to initial state. + BOOL zoom = resizable && IS(bits, ZOOMABLE); + [[self.nsWindow standardWindowButton:NSWindowZoomButton] setEnabled:zoom]; } if (IS(mask, HAS_SHADOW)) { @@ -445,12 +449,13 @@ AWT_ASSERT_APPKIT_THREAD; NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]); - static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIII)V"); + static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V"); JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent, (jint)frame.origin.x, (jint)frame.origin.y, (jint)frame.size.width, - (jint)frame.size.height); + (jint)frame.size.height, + (jboolean)[self.nsWindow inLiveResize]); (*env)->DeleteLocalRef(env, platformWindow); } @@ -784,7 +789,7 @@ AWT_ASSERT_NOT_APPKIT_THREAD; // calls methods on NSWindow to change other properties, based on the mask if (mask & MASK(_METHOD_PROP_BITMASK)) { - [window setPropertiesForStyleBits:bits mask:mask]; + [window setPropertiesForStyleBits:newBits mask:mask]; } window.styleBits = newBits; diff --git a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java index 36c78a4ede12e11e614ed3835ecf5957976c8640..d281e11c8c8a5431a3522362412c5bcbf68b771d 100644 --- a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java +++ b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java @@ -30,14 +30,10 @@ import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.awt.image.DataBuffer; import java.awt.image.WritableRaster; -import java.io.BufferedInputStream; -import java.io.DataInputStream; import java.io.EOFException; -import java.io.InputStream; import java.io.IOException; import java.nio.ByteOrder; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.List; import javax.imageio.IIOException; @@ -48,6 +44,11 @@ import javax.imageio.metadata.IIOMetadata; import javax.imageio.spi.ImageReaderSpi; import javax.imageio.stream.ImageInputStream; import com.sun.imageio.plugins.common.ReaderUtil; +import java.awt.image.ColorModel; +import java.awt.image.IndexColorModel; +import java.awt.image.MultiPixelPackedSampleModel; +import java.awt.image.PixelInterleavedSampleModel; +import java.awt.image.SampleModel; public class GIFImageReader extends ImageReader { @@ -194,6 +195,36 @@ public class GIFImageReader extends ImageReader { return imageMetadata.imageHeight; } + // We don't check all parameters as ImageTypeSpecifier.createIndexed do + // since this method is private and we pass consistent data here + private ImageTypeSpecifier createIndexed(byte[] r, byte[] g, byte[] b, + int bits) { + ColorModel colorModel; + if (imageMetadata.transparentColorFlag) { + // Some files erroneously have a transparent color index + // of 255 even though there are fewer than 256 colors. + int idx = Math.min(imageMetadata.transparentColorIndex, + r.length - 1); + colorModel = new IndexColorModel(bits, r.length, r, g, b, idx); + } else { + colorModel = new IndexColorModel(bits, r.length, r, g, b); + } + + SampleModel sampleModel; + if (bits == 8) { + int[] bandOffsets = {0}; + sampleModel = + new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, + 1, 1, 1, 1, + bandOffsets); + } else { + sampleModel = + new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE, + 1, 1, bits); + } + return new ImageTypeSpecifier(colorModel, sampleModel); + } + public Iterator getImageTypes(int imageIndex) throws IIOException { checkIndex(imageIndex); @@ -239,22 +270,7 @@ public class GIFImageReader extends ImageReader { b[i] = colorTable[rgbIndex++]; } - byte[] a = null; - if (imageMetadata.transparentColorFlag) { - a = new byte[lutLength]; - Arrays.fill(a, (byte)255); - - // Some files erroneously have a transparent color index - // of 255 even though there are fewer than 256 colors. - int idx = Math.min(imageMetadata.transparentColorIndex, - lutLength - 1); - a[idx] = (byte)0; - } - - int[] bitsPerSample = new int[1]; - bitsPerSample[0] = bits; - l.add(ImageTypeSpecifier.createIndexed(r, g, b, a, bits, - DataBuffer.TYPE_BYTE)); + l.add(createIndexed(r, g, b, bits)); return l.iterator(); } diff --git a/src/share/classes/java/awt/color/ICC_Profile.java b/src/share/classes/java/awt/color/ICC_Profile.java index 6a785805b5aa113ca181d1f194c3e87a669d5904..321db6ca664da35c2ccb59370fc694c526e29af1 100644 --- a/src/share/classes/java/awt/color/ICC_Profile.java +++ b/src/share/classes/java/awt/color/ICC_Profile.java @@ -1435,7 +1435,15 @@ public class ICC_Profile implements Serializable { int renderingIntent = intFromBigEndian(theHeader, icHdrRenderingIntent); /* set the rendering intent */ - return renderingIntent; + + /* According to ICC spec, only the least-significant 16 bits shall be + * used to encode the rendering intent. The most significant 16 bits + * shall be set to zero. Thus, we are ignoring two most significant + * bytes here. + * + * See http://www.color.org/ICC1v42_2006-05.pdf, section 7.2.15. + */ + return (0xffff & renderingIntent); } diff --git a/src/share/classes/java/awt/image/ColorConvertOp.java b/src/share/classes/java/awt/image/ColorConvertOp.java index 3f25ebbefde77d2030ac64cf2e4c1093b593c1ed..7ba11582be98595791bb9a93c61beccb7f20330c 100644 --- a/src/share/classes/java/awt/image/ColorConvertOp.java +++ b/src/share/classes/java/awt/image/ColorConvertOp.java @@ -732,10 +732,16 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp { private int getRenderingIntent (ICC_Profile profile) { byte[] header = profile.getData(ICC_Profile.icSigHead); int index = ICC_Profile.icHdrRenderingIntent; - return (((header[index] & 0xff) << 24) | - ((header[index+1] & 0xff) << 16) | - ((header[index+2] & 0xff) << 8) | - (header[index+3] & 0xff)); + + /* According to ICC spec, only the least-significant 16 bits shall be + * used to encode the rendering intent. The most significant 16 bits + * shall be set to zero. Thus, we are ignoring two most significant + * bytes here. + * + * See http://www.color.org/ICC1v42_2006-05.pdf, section 7.2.15. + */ + return ((header[index+2] & 0xff) << 8) | + (header[index+3] & 0xff); } /** diff --git a/src/share/classes/java/lang/invoke/BoundMethodHandle.java b/src/share/classes/java/lang/invoke/BoundMethodHandle.java index dfc6e9d41fe407a3cad7b9153cea2536369aab16..9bbc09c32ce60a042e7eb1d3b03e3f989fff2bd3 100644 --- a/src/share/classes/java/lang/invoke/BoundMethodHandle.java +++ b/src/share/classes/java/lang/invoke/BoundMethodHandle.java @@ -25,7 +25,7 @@ package java.lang.invoke; -import static com.sun.xml.internal.ws.org.objectweb.asm.Opcodes.*; +import static jdk.internal.org.objectweb.asm.Opcodes.*; import static java.lang.invoke.LambdaForm.basicTypes; import static java.lang.invoke.MethodHandleNatives.Constants.REF_invokeStatic; import static java.lang.invoke.MethodHandleStatics.*; @@ -40,9 +40,9 @@ import java.util.HashMap; import sun.invoke.util.ValueConversions; import sun.invoke.util.Wrapper; -import com.sun.xml.internal.ws.org.objectweb.asm.ClassWriter; -import com.sun.xml.internal.ws.org.objectweb.asm.MethodVisitor; -import com.sun.xml.internal.ws.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Type; /** * The flavor of method handle which emulates an invoke instruction diff --git a/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index 0def847d38cfe17a1fd84436e2ccfb88dcdcf6fa..b669b6e2d95aba39433a1cfcf378ef3a70e1373d 100644 --- a/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -34,7 +34,7 @@ import sun.invoke.util.Wrapper; import java.io.*; import java.util.*; -import com.sun.xml.internal.ws.org.objectweb.asm.*; +import jdk.internal.org.objectweb.asm.*; import java.lang.reflect.*; import static java.lang.invoke.MethodHandleStatics.*; diff --git a/src/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html b/src/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html index e7374ea24d91b05f1b2896186402049d81ad34f4..679fb322ddfa8a924327cbcae4461b1867ceed48 100644 --- a/src/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html +++ b/src/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html @@ -90,7 +90,7 @@ images that do not have their own local color table. <!-- Max value: 8 (inclusive) --> <!ATTLIST "LogicalScreenDescriptor" "pixelAspectRatio" #CDATA #REQUIRED> - <!-- If 0, indicates square pixels, else W/H = (value + 16)/64 --> + <!-- If 0, indicates square pixels, else W/H = (value + 15)/64 --> <!-- Data type: Integer --> <!-- Min value: 0 (inclusive) --> <!-- Max value: 255 (inclusive) --> diff --git a/src/share/classes/javax/swing/JColorChooser.java b/src/share/classes/javax/swing/JColorChooser.java index 05270e61c97b470532a05b8cf544ef47dbb174fe..07a72791fa5c4e3b6814e45cf455f493b8dbd0ce 100644 --- a/src/share/classes/javax/swing/JColorChooser.java +++ b/src/share/classes/javax/swing/JColorChooser.java @@ -182,6 +182,7 @@ public class JColorChooser extends JComponent implements Accessible { dialog = new ColorChooserDialog((Dialog)window, title, modal, c, chooserPane, okListener, cancelListener); } + dialog.getAccessibleContext().setAccessibleDescription(title); return dialog; } @@ -647,6 +648,7 @@ class ColorChooserDialog extends JDialog { buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton(okString); getRootPane().setDefaultButton(okButton); + okButton.getAccessibleContext().setAccessibleDescription(okString); okButton.setActionCommand("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -659,6 +661,7 @@ class ColorChooserDialog extends JDialog { buttonPane.add(okButton); cancelButton = new JButton(cancelString); + cancelButton.getAccessibleContext().setAccessibleDescription(cancelString); // The following few lines are used to register esc to close the dialog Action cancelKeyAction = new AbstractAction() { @@ -688,6 +691,7 @@ class ColorChooserDialog extends JDialog { buttonPane.add(cancelButton); JButton resetButton = new JButton(resetString); + resetButton.getAccessibleContext().setAccessibleDescription(resetString); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { reset(); diff --git a/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java b/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java index 12f6bc2d23996e66bb47f91cd50f04e4eff10f33..37e713592b4e02b1f9f909f86bbf48e8b6312bcd 100644 --- a/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java +++ b/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java @@ -135,6 +135,7 @@ final class ColorChooserPanel extends AbstractColorChooserPanel implements Prope String label = this.model.getText(this, "HexCode"); // NON-NLS: suffix boolean visible = label != null; this.text.setVisible(visible); + this.text.getAccessibleContext().setAccessibleDescription(label); this.label.setVisible(visible); if (visible) { this.label.setText(label); diff --git a/src/share/classes/javax/swing/colorchooser/ColorPanel.java b/src/share/classes/javax/swing/colorchooser/ColorPanel.java index 1070d1f086f1dd976976497793b815c5bf90ac40..b1f992ae1f859fc27bae395114bb5e877de680f6 100644 --- a/src/share/classes/javax/swing/colorchooser/ColorPanel.java +++ b/src/share/classes/javax/swing/colorchooser/ColorPanel.java @@ -37,6 +37,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.border.EmptyBorder; +import javax.swing.JSpinner.DefaultEditor; final class ColorPanel extends JPanel implements ActionListener { @@ -119,17 +120,26 @@ final class ColorPanel extends JPanel implements ActionListener { int count = this.model.getCount(); this.spinners[4].setVisible(count > 4); for (int i = 0; i < count; i++) { + String text = this.model.getLabel(this, i); Object object = this.spinners[i].getLabel(); if (object instanceof JRadioButton) { JRadioButton button = (JRadioButton) object; - button.setText(this.model.getLabel(this, i)); + button.setText(text); + button.getAccessibleContext().setAccessibleDescription(text); } else if (object instanceof JLabel) { JLabel label = (JLabel) object; - label.setText(this.model.getLabel(this, i)); + label.setText(text); } this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i)); this.spinners[i].setValue(this.values[i]); + this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text); + this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text); + DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor(); + editor.getTextField().getAccessibleContext().setAccessibleName(text); + this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text); + this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text); + editor.getTextField().getAccessibleContext().setAccessibleDescription(text); } } diff --git a/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java b/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java index 8d01287e2957b89bfe0ebdf412391dbac05d94ca..944048f5fd8d8ad0c00bc190f66929908e1f901e 100644 --- a/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java +++ b/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java @@ -94,6 +94,7 @@ public class BasicColorChooserUI extends ColorChooserUI tabbedPane = new JTabbedPane(); tabbedPane.setName("ColorChooser.tabPane"); tabbedPane.setInheritsPopupMenu(true); + tabbedPane.getAccessibleContext().setAccessibleDescription(tabbedPane.getName()); singlePanel = new JPanel(new CenterLayout()); singlePanel.setName("ColorChooser.panel"); singlePanel.setInheritsPopupMenu(true); diff --git a/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java b/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java index f74edaf1ce4c17cbfe175e1ba422486f96770dce..497c0d6cac0150145609d936d42d2d17ff1b7a0b 100644 --- a/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java +++ b/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java @@ -1941,6 +1941,9 @@ public class BasicTreeUI extends TreeUI for(int counter = beginRow + 1; counter <= endRow; counter++) { testRect = getPathBounds(tree, getPathForRow(tree, counter)); + if (testRect == null) { + return; + } if((testRect.y + testRect.height) > maxY) counter = endRow; } @@ -2069,7 +2072,7 @@ public class BasicTreeUI extends TreeUI treeState.invalidatePathBounds(oldPath); updateSize(); } - else { + else if (editingBounds != null) { editingBounds.x = 0; editingBounds.width = tree.getSize().width; tree.repaint(editingBounds); @@ -2114,6 +2117,9 @@ public class BasicTreeUI extends TreeUI tree.isPathSelected(path), tree.isExpanded(path), treeModel.isLeaf(path.getLastPathComponent()), row); Rectangle nodeBounds = getPathBounds(tree, path); + if (nodeBounds == null) { + return false; + } editingRow = row; @@ -2134,6 +2140,9 @@ public class BasicTreeUI extends TreeUI // To make sure x/y are updated correctly, fetch // the bounds again. nodeBounds = getPathBounds(tree, path); + if (nodeBounds == null) { + return false; + } } else editorHasDifferentSize = false; @@ -3570,7 +3579,7 @@ public class BasicTreeUI extends TreeUI if(pressedPath != null) { Rectangle bounds = getPathBounds(tree, pressedPath); - if(e.getY() >= (bounds.y + bounds.height)) { + if (bounds == null || e.getY() >= (bounds.y + bounds.height)) { return; } @@ -3832,6 +3841,10 @@ public class BasicTreeUI extends TreeUI // And repaint Rectangle newMinBounds = getPathBounds(tree, minPath); + if (minBounds == null || newMinBounds == null) { + return; + } + if (indices.length == 1 && newMinBounds.height == minBounds.height) { tree.repaint(0, minBounds.y, tree.getWidth(), @@ -4466,27 +4479,28 @@ public class BasicTreeUI extends TreeUI } } Rectangle newRect = ui.getPathBounds(tree, newPath); + if (newRect != null) { + newRect.x = visRect.x; + newRect.width = visRect.width; + if(direction == -1) { + newRect.height = visRect.height; + } + else { + newRect.y -= (visRect.height - newRect.height); + newRect.height = visRect.height; + } - newRect.x = visRect.x; - newRect.width = visRect.width; - if(direction == -1) { - newRect.height = visRect.height; - } - else { - newRect.y -= (visRect.height - newRect.height); - newRect.height = visRect.height; - } - - if(addToSelection) { - ui.extendSelection(newPath); - } - else if(changeSelection) { - tree.setSelectionPath(newPath); - } - else { - ui.setLeadSelectionPath(newPath, true); + if(addToSelection) { + ui.extendSelection(newPath); + } + else if(changeSelection) { + tree.setSelectionPath(newPath); + } + else { + ui.setLeadSelectionPath(newPath, true); + } + tree.scrollRectToVisible(newRect); } - tree.scrollRectToVisible(newRect); } } diff --git a/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java b/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java index fb3d2c9ebed3ff6bb8ebbdfbb769721db1539c8d..684f6fc56cc8e4079a2f6722b5e5c1630f080fae 100644 --- a/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java +++ b/src/share/classes/sun/java2d/opengl/OGLBlitLoops.java @@ -25,6 +25,7 @@ package sun.java2d.opengl; +import java.awt.AlphaComposite; import java.awt.Composite; import java.awt.Transparency; import java.awt.geom.AffineTransform; @@ -99,6 +100,8 @@ class OGLBlitLoops { CompositeType.AnyAlpha, blitIntArgbPreToSurface), + new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLSurface), + new OGLSwToSurfaceScale(SurfaceType.IntRgb, OGLSurfaceData.PF_INT_RGB), new OGLSwToSurfaceScale(SurfaceType.IntRgbx, @@ -175,6 +178,9 @@ class OGLBlitLoops { new OGLGeneralBlit(OGLSurfaceData.OpenGLTexture, CompositeType.SrcNoEa, blitIntArgbPreToTexture), + + new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLTexture), + }; GraphicsPrimitiveMgr.register(primitives); } @@ -763,3 +769,49 @@ class OGLGeneralBlit extends Blit { } } } + +class OGLAnyCompositeBlit extends Blit { + private WeakReference dstTmp; + + public OGLAnyCompositeBlit(SurfaceType dstType) { + super(SurfaceType.Any, CompositeType.Any, dstType); + } + public synchronized void Blit(SurfaceData src, SurfaceData dst, + Composite comp, Region clip, + int sx, int sy, int dx, int dy, + int w, int h) + { + Blit convertdst = Blit.getFromCache(dst.getSurfaceType(), + CompositeType.SrcNoEa, + SurfaceType.IntArgbPre); + + SurfaceData cachedDst = null; + + if (dstTmp != null) { + // use cached intermediate surface, if available + cachedDst = dstTmp.get(); + } + + // convert source to IntArgbPre + SurfaceData dstBuffer = convertFrom(convertdst, dst, dx, dy, w, h, + cachedDst, BufferedImage.TYPE_INT_ARGB_PRE); + + Blit performop = Blit.getFromCache(src.getSurfaceType(), + CompositeType.Any, dstBuffer.getSurfaceType()); + + performop.Blit(src, dstBuffer, comp, clip, + sx, sy, 0, 0, w, h); + + if (dstBuffer != cachedDst) { + // cache the intermediate surface + dstTmp = new WeakReference(dstBuffer); + } + + // now blit the buffer back to the destination + convertdst = Blit.getFromCache(dstBuffer.getSurfaceType(), + CompositeType.SrcNoEa, + dst.getSurfaceType()); + convertdst.Blit(dstBuffer, dst, AlphaComposite.Src, + clip, 0, 0, dx, dy, w, h); + } +} diff --git a/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java b/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java index 755044eb9f4fd47b26b72f4f95568cf8624091a5..a2dfd5b90d16a72d77b947eb8cd64da86ac6037b 100644 --- a/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java +++ b/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java @@ -76,6 +76,7 @@ public class OGLSurfaceDataProxy extends SurfaceDataProxy { CompositeType comp, Color bgColor) { - return (bgColor == null || transparency == Transparency.OPAQUE); + return comp.isDerivedFrom(CompositeType.AnyAlpha) && + (bgColor == null || transparency == Transparency.OPAQUE); } } diff --git a/src/share/classes/sun/print/PathGraphics.java b/src/share/classes/sun/print/PathGraphics.java index bec4319e60f2eb4f2dd5c8d508e579a62f2b9f2c..7613fc13493aa00bfff156a3d166cc06b5f342de 100644 --- a/src/share/classes/sun/print/PathGraphics.java +++ b/src/share/classes/sun/print/PathGraphics.java @@ -1025,7 +1025,8 @@ public abstract class PathGraphics extends ProxyGraphics2D { continue; } glyph = font2D.charToGlyph(c); - if (glyph != missingGlyph && glyph < numGlyphs && + if (glyph != missingGlyph && + glyph >= 0 && glyph < numGlyphs && (glyphToCharMap[glyph] == CharToGlyphMapper.INVISIBLE_GLYPH_ID)) { glyphToCharMap[glyph] = c; diff --git a/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java b/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java index 8db267465fffb10045df2e93e8cc3840b54c5c8e..085a9999dc32bb5e1e35646553a9ea0214fa4147 100644 --- a/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java +++ b/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java @@ -256,6 +256,7 @@ public abstract class SynthFileChooserUI extends BasicFileChooserUI implements if (getFileChooser().getControlButtonsAreShown()) { approveButton.setText(getApproveButtonText(getFileChooser())); approveButton.setToolTipText(getApproveButtonToolTipText(getFileChooser())); + approveButton.setMnemonic(getApproveButtonMnemonic(getFileChooser())); } } diff --git a/src/solaris/classes/sun/awt/X11/XToolkit.java b/src/solaris/classes/sun/awt/X11/XToolkit.java index 23939a572b6a7bedee08041cb6e995a7b7985dcd..4084ca4b24e33819b48508ab7d8975957b75a38a 100644 --- a/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -1332,6 +1332,15 @@ public final class XToolkit extends UNIXToolkit implements Runnable { return new XInputMethodDescriptor(); } + /** + * Returns whether enableInputMethods should be set to true for peered + * TextComponent instances on this platform. True by default. + */ + @Override + public boolean enableInputMethodsForTextComponent() { + return true; + } + static int getMultiClickTime() { if (awt_multiclick_time == 0) { initializeMultiClickTime(); diff --git a/src/solaris/native/sun/xawt/XlibWrapper.c b/src/solaris/native/sun/xawt/XlibWrapper.c index 18930fecb1544e76558d678a0a5e08d50dcd383e..f48e833ad2d1ddb6b7d6a9db091956644c2f768d 100644 --- a/src/solaris/native/sun/xawt/XlibWrapper.c +++ b/src/solaris/native/sun/xawt/XlibWrapper.c @@ -1260,13 +1260,15 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_IsKanaKeyboard JavaVM* jvm = NULL; static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) { + JNIEnv * env; if (jvm != NULL) { - JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); - return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I", - ptr_to_jlong(dpy), ptr_to_jlong(event)).i; - } else { - return 0; + env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); + if (env) { + return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I", + ptr_to_jlong(dpy), ptr_to_jlong(event)).i; + } } + return 0; } /* diff --git a/src/share/classes/sun/awt/TextureSizeConstraining.java b/test/java/awt/Frame/FrameSetSizeStressTest/FrameSetSizeStressTest.java similarity index 67% rename from src/share/classes/sun/awt/TextureSizeConstraining.java rename to test/java/awt/Frame/FrameSetSizeStressTest/FrameSetSizeStressTest.java index 306c3e762c088d55d639d8d94ec3d07cdf8b802e..9a3b2f06f5e00253ba849dce114d51e3cc5f806c 100644 --- a/src/share/classes/sun/awt/TextureSizeConstraining.java +++ b/test/java/awt/Frame/FrameSetSizeStressTest/FrameSetSizeStressTest.java @@ -23,23 +23,26 @@ * questions. */ -package sun.awt; +import java.awt.Frame; -/** - * A GraphicsConfiguration implements the TextureSizeConstraining - * interface to indicate that it imposes certain limitations on the - * maximum size of supported textures. - */ -public interface TextureSizeConstraining { - - /** - * Returns the maximum width of any texture image. - */ - public int getMaxTextureWidth(); - - /** - * Returns the maximum height of any texture image. - */ - public int getMaxTextureHeight(); +/* + @test + @bug 7177173 + @summary setBounds can cause StackOverflow in case of the considerable loading + @author Sergey Bylokhov +*/ +public final class FrameSetSizeStressTest { + public static void main(final String[] args) { + final Frame frame = new Frame(); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + for (int i = 0; i < 1000; ++i) { + frame.setSize(100, 100); + frame.setSize(200, 200); + frame.setSize(300, 300); + } + frame.dispose(); + } } diff --git a/test/javax/swing/JTree/8003830/bug8003830.java b/test/javax/swing/JTree/8003830/bug8003830.java new file mode 100644 index 0000000000000000000000000000000000000000..785154624960e30d594a9cec986d3e65577a7a2a --- /dev/null +++ b/test/javax/swing/JTree/8003830/bug8003830.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.EventQueue; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import javax.swing.JTree; +import javax.swing.plaf.basic.BasicTreeUI; +import javax.swing.tree.TreePath; + + +/* Originally reported as NetBeans bug 222081. + * + * @test + * @bug 8003830 + * @summary NullPointerException in BasicTreeUI.Actions when getPathBounds returns null + * @author Jaroslav Tulach + * @run main bug8003830 + */ + +public class bug8003830 implements Runnable { + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(new bug8003830()); + } + @Override + public void run() { + testNPEAtActionsPage(); + } + + public void testNPEAtActionsPage() { + JTree tree = new JTree(); + BasicTreeUI ui = new NullReturningTreeUI(); + tree.setUI(ui); + BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down"); + tpa.actionPerformed(new ActionEvent(tree, 0, "")); + } + + private static final class NullReturningTreeUI extends BasicTreeUI { + @Override + public Rectangle getPathBounds(JTree tree, TreePath path) { + // the method can return null and callers have to be ready for + // that. Simulate the case by returning null for unknown reason. + return null; + } + } +} diff --git a/test/javax/swing/dnd/7171812/JListWithScroll.java b/test/javax/swing/dnd/7171812/JListWithScroll.java new file mode 100644 index 0000000000000000000000000000000000000000..4e11ce841b497dd5da80db254af31a68987e8a3a --- /dev/null +++ b/test/javax/swing/dnd/7171812/JListWithScroll.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.*; +import java.awt.*; +import java.awt.dnd.Autoscroll; + +public class JListWithScroll extends JList implements Autoscroll { + private Insets scrollInsets; + + public JListWithScroll(E[] listData) { + super(listData); + scrollInsets = new Insets(50, 50, 50, 50); + } + + @Override + public Insets getAutoscrollInsets() { + return scrollInsets; + } + + @Override + public void autoscroll(Point cursorLoc) { + JViewport viewport = getViewport(); + + if (viewport == null) { + return; + } + + Point viewPos = viewport.getViewPosition(); + int viewHeight = viewport.getExtentSize().height; + int viewWidth = viewport.getExtentSize().width; + + if ((cursorLoc.y - viewPos.y) < scrollInsets.top) { + viewport.setViewPosition(new Point(viewPos.x, Math.max(viewPos.y - scrollInsets.top, 0))); + } else if (((viewPos.y + viewHeight) - cursorLoc.y) < scrollInsets.bottom) { + viewport.setViewPosition( + new Point(viewPos.x, Math.min(viewPos.y + scrollInsets.bottom, this.getHeight() - viewHeight)) + ); + } else if ((cursorLoc.x - viewPos.x) < scrollInsets.left) { + viewport.setViewPosition(new Point(Math.max(viewPos.x - scrollInsets.left, 0), viewPos.y)); + } else if (((viewPos.x + viewWidth) - cursorLoc.x) < scrollInsets.right) { + viewport.setViewPosition( + new Point(Math.min(viewPos.x + scrollInsets.right, this.getWidth() - viewWidth), viewPos.y) + ); + } + + } + + public JViewport getViewport() { + Component curComp = this; + + while (!(curComp instanceof JViewport) && (curComp != null)) { + curComp = curComp.getParent(); + } + if(curComp instanceof JViewport) { + return (JViewport) curComp; + } else { + return null; + } + } +} diff --git a/test/javax/swing/dnd/7171812/bug7171812.java b/test/javax/swing/dnd/7171812/bug7171812.java new file mode 100644 index 0000000000000000000000000000000000000000..a550d5e3cf99c4614a9924d196c36bb82afb6b9a --- /dev/null +++ b/test/javax/swing/dnd/7171812/bug7171812.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 7171812 + @summary [macosx] Views keep scrolling back to the drag position after DnD + @author Alexander Zuev + @run main bug7171812 + */ + +import sun.awt.SunToolkit; + +import java.awt.*; +import java.awt.dnd.*; +import java.awt.event.InputEvent; +import javax.swing.*; + +public class bug7171812 { + static JFrame mainFrame; + static String listData[]; + static JListWithScroll list; + static JScrollPane scrollPane; + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws Exception{ + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + setupGUI(); + } + }); + toolkit.realSync(); + + Robot robot = new Robot(); + robot.setAutoDelay(10); + robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + 5); + robot.mousePress(InputEvent.BUTTON1_MASK); + for(int offset = 5; offset < scrollPane.getHeight()-20; offset++) { + robot.mouseMove(scrollPane.getLocationOnScreen().x+5, scrollPane.getLocationOnScreen().y+offset); + } + for(int offset = 5; offset < 195; offset++) { + robot.mouseMove(scrollPane.getLocationOnScreen().x+offset, scrollPane.getLocationOnScreen().y+scrollPane.getHeight()-20); + } + robot.mouseRelease(InputEvent.BUTTON1_MASK); + try { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + if(scrollPane.getViewport().getViewPosition().getY() < 30) { + throw new RuntimeException("Incorrect view position."); + }; + } + }); + } catch (java.lang.reflect.InvocationTargetException ite) { + throw new RuntimeException("Test failed, scroll on drag doesn't work!"); + } + } + + public static void setupGUI() { + listData = new String[100]; + for (int i=0; i<100; i++) { + listData[i] = "Long Line With Item "+i; + } + mainFrame = new JFrame("Rest frame"); + mainFrame.setSize(300, 500); + mainFrame.setLayout(new BorderLayout()); + list = new JListWithScroll(listData); + list.setDragEnabled(true); + list.setAutoscrolls(true); + final DropTarget dropTarget = new DropTarget(list, DnDConstants.ACTION_MOVE, new DropTargetListener() { + @Override + public void dragEnter(DropTargetDragEvent dtde) { + dragOver(dtde); + } + + @Override + public void dragOver(DropTargetDragEvent dtde) { + dtde.acceptDrag(DnDConstants.ACTION_MOVE); + } + + @Override + public void dropActionChanged(DropTargetDragEvent dtde) { + } + + @Override + public void dragExit(DropTargetEvent dte) { + } + + @Override + public void drop(DropTargetDropEvent dtde) { + } + }, true); + scrollPane = new JScrollPane(list); + mainFrame.add(scrollPane, BorderLayout.CENTER); + mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + mainFrame.setLocation(100, 100); + mainFrame.setVisible(true); + } +} diff --git a/test/javax/swing/text/CSSBorder/6796710/bug6796710.java b/test/javax/swing/text/CSSBorder/6796710/bug6796710.java index b59ba9fd9bb65f0eea467c3d693b6a0efb455787..dd8508b39977de0dcc9c3f3ee4402b92f87a2afb 100644 --- a/test/javax/swing/text/CSSBorder/6796710/bug6796710.java +++ b/test/javax/swing/text/CSSBorder/6796710/bug6796710.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. 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 6796710 + * @bug 6796710 7124242 * @summary Html content in JEditorPane is overlapping on swing components while resizing the application. * @library ../../../regtesthelpers * @build Util @@ -31,11 +31,10 @@ @run main bug6796710 */ -import sun.awt.SunToolkit; - -import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; +import javax.swing.*; +import sun.awt.SunToolkit; public class bug6796710 { // The page is inlined because we want to be sure that the JEditorPane filled synchronously @@ -68,9 +67,12 @@ public class bug6796710 { robot = new Robot(); SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame = new JFrame(); + frame.setUndecorated(true); + pnBottom = new JPanel(); pnBottom.add(new JLabel("Some label")); pnBottom.add(new JButton("A button")); @@ -95,9 +97,13 @@ public class bug6796710 { ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync(); + // This delay should be added for MacOSX, realSync is not enough + Thread.sleep(1000); + BufferedImage bufferedImage = getPnBottomImage(); SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { frame.setSize(400, 150); } diff --git a/test/sun/java2d/OpenGL/CustomCompositeTest.java b/test/sun/java2d/OpenGL/CustomCompositeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3977270d45774b65a6943e0ad133f716e71b18ec --- /dev/null +++ b/test/sun/java2d/OpenGL/CustomCompositeTest.java @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7124347 + * @summary Verifies that rendering with XOR composite, and arbitraty + * custom composite doesn not cause internal errors. + * + * @run main/othervm -Dsun.java2d.opengl=True CustomCompositeTest + */ + +import java.awt.AWTException; +import java.awt.Color; +import java.awt.Composite; +import java.awt.CompositeContext; +import java.awt.Dimension; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.ImageCapabilities; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.DataBufferInt; +import java.awt.image.Raster; +import java.awt.image.SinglePixelPackedSampleModel; +import java.awt.image.VolatileImage; +import java.awt.image.WritableRaster; +import java.util.concurrent.CountDownLatch; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class CustomCompositeTest { + + private static JFrame frame; + private static CountDownLatch paintLatch; + private static Throwable paintError; + + public static void main(String[] args) { + + paintLatch = new CountDownLatch(1); + paintError = null; + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + initGUI(); + } + }); + + try { + paintLatch.await(); + } catch (InterruptedException e) { + }; + System.out.println("Paint is done!"); + if (paintError != null) { + frame.dispose(); + throw new RuntimeException("Test FAILED.", paintError); + } + + System.out.println("Phase 1: PASSED."); + + // now resise the frame in order to cause re-paint with accelerated + // source images. + paintError = null; + paintLatch = new CountDownLatch(1); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + Dimension size = frame.getSize(); + size.width += 50; + size.height += 50; + + frame.setSize(size); + } + }); + + try { + paintLatch.await(); + } catch (InterruptedException e) { + }; + if (paintError != null) { + frame.dispose(); + throw new RuntimeException("Resize test FAILED.", paintError); + } + frame.dispose(); + System.out.println("Phase 2: PASSED."); + + GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsConfiguration cfg = env.getDefaultScreenDevice().getDefaultConfiguration(); + // test rendering to accelerated volatile image + testVolatileImage(cfg, true); + System.out.println("Phase 3: PASSED."); + + // test rendering to unaccelerated volatile image + testVolatileImage(cfg, false); + System.out.println("Phase 4: PASSED."); + } + + private static void testVolatileImage(GraphicsConfiguration cfg, + boolean accelerated) + { + VolatileImage dst = null; + try { + dst = cfg.createCompatibleVolatileImage(640, 480, + new ImageCapabilities(accelerated)); + } catch (AWTException e) { + System.out.println("Unable to create volatile image, skip the test."); + return; + } + renderToVolatileImage(dst); + } + + private static void renderToVolatileImage(VolatileImage dst) { + Graphics2D g = dst.createGraphics(); + do { + System.out.println("Render to volatile image.."); + try { + MyComp.renderTest(g, dst.getHeight(), dst.getHeight()); + } catch (Throwable e) { + throw new RuntimeException("Test FAILED.", e); + } + } while (dst.contentsLost()); + System.out.println("Done."); + } + + private static void initGUI() { + frame = new JFrame("Silly composite"); + frame.getContentPane().add(new MyComp()); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + } + + private static class MyComp extends JComponent { + + private static BufferedImage theImage; + + public MyComp() { + } + + private static BufferedImage getTestImage() { + if (theImage == null) { + theImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = theImage.createGraphics(); + g2d.setColor(Color.red); + g2d.fillRect(0, 0, 256, 256); + + g2d.setPaint(new GradientPaint(0, 0, Color.red, 256, 256, Color.blue)); + g2d.fillRect(0, 100, 256, 256); + g2d.dispose(); + } + return theImage; + } + + public Dimension getPreferredSize() { + return new Dimension(640, 375); + } + + public void paintComponent(Graphics g) { + + + Graphics2D g2d = (Graphics2D) g; + try { + renderTest(g2d, getWidth(), getHeight()); + } catch (Throwable e) { + paintError = e; + } + if (paintLatch != null) { + paintLatch.countDown(); + } + } + + public static void renderTest(Graphics2D g2d, int w, int h) { + g2d.setColor(Color.yellow); + g2d.fillRect(0, 0, w, h); + + BufferedImage image = getTestImage(); + // draw original image + g2d.drawRenderedImage(image, null); + + // draw image with custom composite + g2d.translate(175, 25); + Composite currentComposite = g2d.getComposite(); + g2d.setComposite(new TestComposite()); + g2d.drawRenderedImage(image, null); + g2d.setComposite(currentComposite); + + // draw image with XOR + g2d.translate(175, 25); + g2d.setXORMode(Color.red); + g2d.drawRenderedImage(image, null); + + + System.out.println("Painting is done..."); + } + } + + // A silly custom Composite to demonstrate the problem - just inverts the RGB + private static class TestComposite implements Composite { + + public CompositeContext createContext(ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints hints) { + return new TestCompositeContext(); + } + } + + private static class TestCompositeContext implements CompositeContext { + + public void dispose() { + } + + public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { + int w = src.getWidth(); + int h = src.getHeight(); + + DataBufferInt srcDB = (DataBufferInt) src.getDataBuffer(); + DataBufferInt dstOutDB = (DataBufferInt) dstOut.getDataBuffer(); + int srcRGB[] = srcDB.getBankData()[0]; + int dstOutRGB[] = dstOutDB.getBankData()[0]; + int srcOffset = srcDB.getOffset(); + int dstOutOffset = dstOutDB.getOffset(); + int srcScanStride = ((SinglePixelPackedSampleModel) src.getSampleModel()).getScanlineStride(); + int dstOutScanStride = ((SinglePixelPackedSampleModel) dstOut.getSampleModel()).getScanlineStride(); + int srcAdjust = srcScanStride - w; + int dstOutAdjust = dstOutScanStride - w; + + int si = srcOffset; + int doi = dstOutOffset; + + for (int i = 0; i < h; i++) { + for (int j = 0; j < w; j++) { + dstOutRGB[doi] = srcRGB[si] ^ 0x00ffffff; + si++; + doi++; + } + + si += srcAdjust; + doi += dstOutAdjust; + } + } + } +} diff --git a/test/sun/java2d/cmm/ColorConvertOp/InvalidRenderIntentTest.java b/test/sun/java2d/cmm/ColorConvertOp/InvalidRenderIntentTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9140e3c4c1baf5506d8bfabddd7e3a8ea59be0d6 --- /dev/null +++ b/test/sun/java2d/cmm/ColorConvertOp/InvalidRenderIntentTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 7064516 + * @summary Test verifies that incorrect profile rendering intent + * does not cause an failure of color conversion op. + * @run main InvalidRenderIntentTest + */ + +import java.awt.color.CMMException; +import java.awt.color.ColorSpace; +import java.awt.color.ICC_ColorSpace; +import java.awt.color.ICC_Profile; +import java.awt.image.ColorConvertOp; +import java.awt.image.BufferedImage; + +import static java.awt.color.ColorSpace.CS_sRGB; +import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR; + +public class InvalidRenderIntentTest { + + public static void main(String[] args) { + ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB); + + byte[] raw_data = pSRGB.getData(); + + setRenderingIntent(0x1000000, raw_data); + + ICC_Profile p = ICC_Profile.getInstance(raw_data); + + ICC_ColorSpace cs = new ICC_ColorSpace(p); + + // perfrom test color conversion + ColorConvertOp op = new ColorConvertOp(cs, + ColorSpace.getInstance(CS_sRGB), null); + BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR); + BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR); + + try { + op.filter(src.getRaster(), dst.getRaster()); + } catch (CMMException e) { + throw new RuntimeException("Test failed.", e); + } + System.out.println("Test passed."); + } + + private static void setRenderingIntent(int intent, byte[] data) { + final int pos = ICC_Profile.icHdrRenderingIntent; + + data[pos + 0] = (byte) (0xff & (intent >> 24)); + data[pos + 1] = (byte) (0xff & (intent >> 16)); + data[pos + 2] = (byte) (0xff & (intent >> 8)); + data[pos + 3] = (byte) (0xff & (intent)); + } +}