7030063: AWT support for SE-Embedded integration
Summary: AWT support for SE-Embedded
Reviewed-by: anthony, art, bobv, collins, alanb
--- a/jdk/make/launchers/Makefile Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/make/launchers/Makefile Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 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
@@ -44,8 +44,17 @@
endef
# Run MAKE $@ for all generic launchers
+ifndef BUILD_HEADLESS_ONLY
+define make-appletviewer
+$(call make-launcher, appletviewer, sun.applet.Main, , )
+endef
+else
+define make-appletviewer
+endef
+endif
+
define make-all-launchers
-$(call make-launcher, appletviewer, sun.applet.Main, , )
+$(make-appletviewer)
$(call make-launcher, apt, com.sun.tools.apt.Main, , )
$(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , )
$(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , )
--- a/jdk/make/sun/Makefile Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/make/sun/Makefile Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1995, 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
@@ -69,10 +69,17 @@
# nio need to be compiled before awt to have all charsets ready
SUBDIRS = jar security javazic misc net nio text launcher
+
+ifdef BUILD_HEADLESS_ONLY
+ DISPLAY_LIBS = awt $(HEADLESS_SUBDIR)
+ DISPLAY_TOOLS =
+else
+ DISPLAY_LIBS = awt splashscreen $(XAWT_SUBDIR) $(HEADLESS_SUBDIR)
+ DISPLAY_TOOLS = applet
+endif
SUBDIRS_desktop = audio $(RENDER_SUBDIR) image \
- awt splashscreen $(XAWT_SUBDIR) \
- $(HEADLESS_SUBDIR) $(DGA_SUBDIR) \
- jawt font jpeg cmm applet beans
+ $(DISPLAY_LIBS) $(DGA_SUBDIR) \
+ jawt font jpeg cmm $(DISPLAY_TOOLS) beans
SUBDIRS_management = management
SUBDIRS_misc = $(ORG_SUBDIR) rmi $(JDBC_SUBDIR) tracing
SUBDIRS_tools = native2ascii serialver tools jconsole
--- a/jdk/make/sun/awt/mawt.gmk Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/make/sun/awt/mawt.gmk Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 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
@@ -149,13 +149,13 @@
LIBXT = -lXt
else
# Allows for builds on Debian GNU Linux, X11 is in a different place
- LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \
+ LIBXT = $(firstword $(wildcard $(OPENWIN_LIB)/libXt.a) \
$(wildcard /usr/lib/libXt.a))
- LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
+ LIBSM = $(firstword $(wildcard $(OPENWIN_LIB)/libSM.a) \
$(wildcard /usr/lib/libSM.a))
- LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \
+ LIBICE = $(firstword $(wildcard $(OPENWIN_LIB)/libICE.a) \
$(wildcard /usr/lib/libICE.a))
- LIBXTST = $(firstword $(wildcard /usr/X11R6/lib/libXtst.a) \
+ LIBXTST = $(firstword $(wildcard $(OPENWIN_LIB)/libXtst.a) \
$(wildcard /usr/lib/libXtst.a))
endif
endif
@@ -224,9 +224,9 @@
$(EVENT_MODEL)
ifeq ($(PLATFORM), linux)
-# Checking for the X11/extensions headers at the additional location
- CPPFLAGS += -I/X11R6/include/X11/extensions \
- -I/usr/include/X11/extensions
+ # Checking for the X11/extensions headers at the additional location
+ CPPFLAGS += -I$(firstword $(wildcard $(OPENWIN_HOME)/include/X11/extensions) \
+ $(wildcard /usr/include/X11/extensions))
endif
ifeq ($(PLATFORM), solaris)
--- a/jdk/make/sun/jawt/Makefile Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/make/sun/jawt/Makefile Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 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
@@ -112,11 +112,20 @@
# Libraries to link in.
#
ifeq ($(PLATFORM), solaris)
-OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
+ ifndef BUILD_HEADLESS_ONLY
+ OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
+ else
+ OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/headless -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
+ endif
endif # PLATFORM
ifeq ($(PLATFORM), linux)
-OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt
+ ifndef BUILD_HEADLESS_ONLY
+ OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt
+ else
+ OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/headless -lmawt
+ CFLAGS += -DHEADLESS
+ endif
endif # PLATFORM
endif # PLATFORM
--- a/jdk/make/sun/jpeg/Makefile Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/make/sun/jpeg/Makefile Fri Mar 25 07:09:38 2011 -0400
@@ -73,9 +73,10 @@
# Recommended way to avoid such warning is to declare the variable as
# volatile to prevent the optimization. However, this approach does not
# work because we have to declare all variables as volatile in result.
-
+ifndef CROSS_COMPILE_ARCH
OTHER_CFLAGS += -Wno-clobbered
endif
+endif
include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk
--- a/jdk/make/sun/security/tools/Makefile Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/make/sun/security/tools/Makefile Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 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
@@ -46,5 +46,7 @@
build:
$(call make-launcher, keytool, sun.security.tools.KeyTool, , )
+ifndef BUILD_HEADLESS_ONLY
$(call make-launcher, policytool, sun.security.tools.policytool.PolicyTool, , )
+endif
--- a/jdk/make/sun/xawt/Makefile Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/make/sun/xawt/Makefile Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -129,10 +129,17 @@
-I$(PLATFORM_SRC)/native/sun/awt
ifeq ($(PLATFORM), linux)
-# Allows for builds on Debian GNU Linux, X11 is in a different place
- CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
- -I/usr/include/X11/extensions \
- -I$(OPENWIN_HOME)/include
+ ifndef CROSS_COMPILE_ARCH
+ # Allows for builds on Debian GNU Linux, X11 is in a different place
+ # This should really be handled at a higher-level so we don't have to
+ # work-around this when cross-compiling
+ CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
+ -I/usr/include/X11/extensions \
+ -I$(OPENWIN_HOME)/include
+ else
+ CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions \
+ -I$(OPENWIN_HOME)/include
+ endif
endif
# We have some odd logic here because some Solaris 10 updates
@@ -245,7 +252,11 @@
$(SIZERS): $(SIZERS_C)
$(prep-target)
+ifndef CROSS_COMPILE_ARCH
$(CC) $(CFLAGS_$(subst .,,$(suffix $@))) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
+else
+ $(HOST_CC) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
+endif
$(WRAPPER_GENERATOR_CLASS): $(WRAPPER_GENERATOR_JAVA)
$(prep-target)
--- a/jdk/src/share/classes/java/awt/Toolkit.java Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/src/share/classes/java/awt/Toolkit.java Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -858,7 +858,7 @@
String nm = null;
Class cls = null;
try {
- nm = System.getProperty("awt.toolkit", "sun.awt.X11.XToolkit");
+ nm = System.getProperty("awt.toolkit");
try {
cls = Class.forName(nm);
} catch (ClassNotFoundException e) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/awt/HToolkit.java Fri Mar 25 07:09:38 2011 -0400
@@ -0,0 +1,378 @@
+/*
+ * 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. 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.awt;
+
+import java.awt.*;
+import java.awt.dnd.*;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.im.InputMethodHighlight;
+import java.awt.im.spi.InputMethodDescriptor;
+import java.awt.image.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.peer.*;
+import java.util.Map;
+import java.util.Properties;
+
+/*
+ * HToolkit is a platform independent Toolkit used
+ * with the HeadlessToolkit. It is primarily used
+ * in embedded JRE's that do not have sun/awt/X11 classes.
+ */
+public class HToolkit extends SunToolkit
+ implements ComponentFactory {
+
+ public HToolkit() {
+ }
+
+ /*
+ * Component peer objects - unsupported.
+ */
+
+ public WindowPeer createWindow(Window target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public FramePeer createFrame(Frame target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public DialogPeer createDialog(Dialog target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ButtonPeer createButton(Button target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public TextFieldPeer createTextField(TextField target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ChoicePeer createChoice(Choice target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public LabelPeer createLabel(Label target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ListPeer createList(List target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public CheckboxPeer createCheckbox(Checkbox target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ScrollbarPeer createScrollbar(Scrollbar target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ScrollPanePeer createScrollPane(ScrollPane target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public TextAreaPeer createTextArea(TextArea target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public FileDialogPeer createFileDialog(FileDialog target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public MenuBarPeer createMenuBar(MenuBar target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public MenuPeer createMenu(Menu target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public PopupMenuPeer createPopupMenu(PopupMenu target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public MenuItemPeer createMenuItem(MenuItem target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public DragSourceContextPeer createDragSourceContextPeer(
+ DragGestureEvent dge)
+ throws InvalidDnDOperationException {
+ throw new InvalidDnDOperationException("Headless environment");
+ }
+
+ public RobotPeer createRobot(Robot target, GraphicsDevice screen)
+ throws AWTException, HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
+ // See 6833019.
+ return
+ new KeyboardFocusManagerPeer() {
+ public Window getCurrentFocusedWindow() { return null; }
+ public void setCurrentFocusOwner(Component comp) {}
+ public Component getCurrentFocusOwner() { return null; }
+ public void clearGlobalFocusOwner(Window activeWindow) {}
+ };
+ }
+
+ public TrayIconPeer createTrayIcon(TrayIcon target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public SystemTrayPeer createSystemTray(SystemTray target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public boolean isTraySupported() {
+ return false;
+ }
+
+ public GlobalCursorManager getGlobalCursorManager()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ /*
+ * Headless toolkit - unsupported.
+ */
+ protected void loadSystemColors(int[] systemColors)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ColorModel getColorModel()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public int getScreenResolution()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public int getMenuShortcutKeyMask()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public boolean getLockingKeyState(int keyCode)
+ throws UnsupportedOperationException {
+ throw new HeadlessException();
+ }
+
+ public void setLockingKeyState(int keyCode, boolean on)
+ throws UnsupportedOperationException {
+ throw new HeadlessException();
+ }
+
+ public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
+ throws IndexOutOfBoundsException, HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public int getMaximumCursorColors()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public <T extends DragGestureRecognizer> T
+ createDragGestureRecognizer(Class<T> abstractRecognizerClass,
+ DragSource ds, Component c,
+ int srcActions, DragGestureListener dgl)
+ {
+ return null;
+ }
+
+ public int getScreenHeight()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public int getScreenWidth()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Dimension getScreenSize()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Insets getScreenInsets(GraphicsConfiguration gc)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public void setDynamicLayout(boolean dynamic)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ protected boolean isDynamicLayoutSet()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public boolean isDynamicLayoutActive()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Clipboard getSystemClipboard()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ /*
+ * Printing
+ */
+ public PrintJob getPrintJob(Frame frame, String jobtitle,
+ JobAttributes jobAttributes,
+ PageAttributes pageAttributes) {
+ if (frame != null) {
+ // Should never happen
+ throw new HeadlessException();
+ }
+ throw new IllegalArgumentException(
+ "PrintJob not supported in a headless environment");
+ }
+
+ public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
+ {
+ if (frame != null) {
+ // Should never happen
+ throw new HeadlessException();
+ }
+ throw new IllegalArgumentException(
+ "PrintJob not supported in a headless environment");
+ }
+
+ /*
+ * Headless toolkit - supported.
+ */
+
+ public void sync() {
+ // Do nothing
+ }
+
+ protected boolean syncNativeQueue(final long timeout) {
+ return false;
+ }
+
+ public void beep() {
+ // Send alert character
+ System.out.write(0x07);
+ }
+
+
+ /*
+ * Fonts
+ */
+ public FontPeer getFontPeer(String name, int style) {
+ return (FontPeer)null;
+ }
+
+ /*
+ * Modality
+ */
+ public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
+ return false;
+ }
+
+ public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
+ return false;
+ }
+
+ public boolean isDesktopSupported() {
+ return false;
+ }
+
+ public DesktopPeer createDesktopPeer(Desktop target)
+ throws HeadlessException{
+ throw new HeadlessException();
+ }
+
+ public boolean isWindowOpacityControlSupported() {
+ return false;
+ }
+
+ public boolean isWindowShapingSupported() {
+ return false;
+ }
+
+ public boolean isWindowTranslucencySupported() {
+ return false;
+ }
+
+ public void grab(Window w) { }
+
+ public void ungrab(Window w) { }
+
+ protected boolean syncNativeQueue() { return false; }
+
+ public InputMethodDescriptor getInputMethodAdapterDescriptor()
+ throws AWTException
+ {
+ return (InputMethodDescriptor)null;
+ }
+}
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -135,6 +135,12 @@
noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));
}
+ /*
+ * Return (potentially) platform specific display timeout for the
+ * tray icon
+ */
+ static native long getTrayIconDisplayTimeout();
+
//---- ERROR HANDLER CODE ----//
/*
--- a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -230,7 +230,7 @@
// Wait till the EmbeddedFrame is reparented
long start = System.currentTimeMillis();
- final long PERIOD = 2000L;
+ final long PERIOD = XToolkit.getTrayIconDisplayTimeout();
XToolkit.awtLock();
try {
while (!isTrayIconDisplayed) {
--- a/jdk/src/solaris/native/java/lang/java_props_md.c Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/src/solaris/native/java/lang/java_props_md.c Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -55,6 +55,11 @@
#endif
#endif
+#ifdef JAVASE_EMBEDDED
+#include <dlfcn.h>
+#include <sys/stat.h>
+#endif
+
/* Take an array of string pairs (map of key->value) and a string (key).
* Examine each pair in the map to see if the first string (key) matches the
* string. If so, store the second string of the pair (value) in the value and
@@ -304,6 +309,36 @@
return 1;
}
+#ifdef JAVASE_EMBEDDED
+/* Determine the default embedded toolkit based on whether lib/xawt/
+ * exists in the JRE. This can still be overridden by -Dawt.toolkit=XXX
+ */
+static char* getEmbeddedToolkit() {
+ Dl_info dlinfo;
+ char buf[MAXPATHLEN];
+ int32_t len;
+ char *p;
+ struct stat statbuf;
+
+ /* Get address of this library and the directory containing it. */
+ dladdr((void *)getEmbeddedToolkit, &dlinfo);
+ realpath((char *)dlinfo.dli_fname, buf);
+ len = strlen(buf);
+ p = strrchr(buf, '/');
+ /* Default AWT Toolkit on Linux and Solaris is XAWT. */
+ strncpy(p, "/xawt/", MAXPATHLEN-len-1);
+ /* Check if it exists */
+ if (stat(buf, &statbuf) == -1 && errno == ENOENT) {
+ /* No - this is a reduced-headless-jre so use special HToolkit */
+ return "sun.awt.HToolkit";
+ }
+ else {
+ /* Yes - this is a headful JRE so fallback to SE defaults */
+ return NULL;
+ }
+}
+#endif
+
/* This function gets called very early, before VM_CALLS are setup.
* Do not use any of the VM_CALLS entries!!!
*/
@@ -328,7 +363,12 @@
/* Java 2D properties */
sprops.graphics_env = "sun.awt.X11GraphicsEnvironment";
- sprops.awt_toolkit = NULL;
+
+#ifdef JAVASE_EMBEDDED
+ sprops.awt_toolkit = getEmbeddedToolkit();
+ if (sprops.awt_toolkit == NULL) // default as below
+#endif
+ sprops.awt_toolkit = "sun.awt.X11.XToolkit";
/* This is used only for debugging of font problems. */
v = getenv("JAVA2D_FONTPATH");
--- a/jdk/src/solaris/native/sun/awt/jawt.c Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/src/solaris/native/sun/awt/jawt.c Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -33,6 +33,10 @@
*/
JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
{
+#if defined(JAVASE_EMBEDDED) && defined(HEADLESS)
+ /* there are no AWT libs available at all */
+ return JNI_FALSE;
+#else
if (awt == NULL) {
return JNI_FALSE;
}
@@ -51,4 +55,5 @@
}
return JNI_TRUE;
+#endif
}
--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c Fri Mar 25 11:58:30 2011 +0800
+++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c Fri Mar 25 07:09:38 2011 -0400
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -112,6 +112,21 @@
/*
* Class: sun_awt_X11_XToolkit
+ * Method: getTrayIconDisplayTimeout
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout
+ (JNIEnv *env, jclass clazz)
+{
+#ifndef JAVASE_EMBEDDED
+ return (jlong) 2000;
+#else
+ return (jlong) 10000;
+#endif
+}
+
+/*
+ * Class: sun_awt_X11_XToolkit
* Method: getDefaultXColormap
* Signature: ()J
*/
@@ -340,15 +355,34 @@
#define AWT_READPIPE (awt_pipe_fds[0])
#define AWT_WRITEPIPE (awt_pipe_fds[1])
-#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */
+#ifdef JAVASE_EMBEDDED
+ #define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)4000000000) /* milliseconds */
+#else
+ #define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */
+#endif
+
#define DEF_AWT_FLUSH_TIMEOUT ((uint32_t)100) /* milliseconds */
#define AWT_MIN_POLL_TIMEOUT ((uint32_t)0) /* milliseconds */
#define TIMEOUT_TIMEDOUT 0
#define TIMEOUT_EVENTS 1
+/* awt_poll_alg - AWT Poll Events Aging Algorithms */
+#define AWT_POLL_FALSE 1
+#define AWT_POLL_AGING_SLOW 2
+#define AWT_POLL_AGING_FAST 3
+
+#define AWT_POLL_THRESHOLD 1000 // msec, Block if delay is larger
+#define AWT_POLL_BLOCK -1 // cause poll() block
+
// Static fields
+#ifdef JAVASE_EMBEDDED
+ static int awt_poll_alg = AWT_POLL_AGING_FAST;
+#else
+ static int awt_poll_alg = AWT_POLL_AGING_SLOW;
+#endif
+
static uint32_t AWT_FLUSH_TIMEOUT = DEF_AWT_FLUSH_TIMEOUT; /* milliseconds */
static uint32_t AWT_MAX_POLL_TIMEOUT = DEF_AWT_MAX_POLL_TIMEOUT; /* milliseconds */
static pthread_t awt_MainThread = 0;
@@ -417,6 +451,7 @@
*/
static void readEnv() {
char * value;
+ int tmp_poll_alg;
static Boolean env_read = False;
if (env_read) return;
@@ -451,6 +486,23 @@
if (static_poll_timeout != 0) {
curPollTimeout = static_poll_timeout;
}
+
+ // non-blocking poll()
+ value = getenv("_AWT_POLL_ALG");
+ if (value != NULL) {
+ tmp_poll_alg = atoi(value);
+ switch(tmp_poll_alg) {
+ case AWT_POLL_FALSE:
+ case AWT_POLL_AGING_SLOW:
+ case AWT_POLL_AGING_FAST:
+ awt_poll_alg = tmp_poll_alg;
+ break;
+ default:
+ PRINT("Unknown value of _AWT_POLL_ALG, assuming Slow Aging Algorithm by default");
+ awt_poll_alg = AWT_POLL_AGING_SLOW;
+ break;
+ }
+ }
}
/**
@@ -478,14 +530,29 @@
if (static_poll_timeout != 0) return;
// Update it otherwise
- if (timeout_control == TIMEOUT_TIMEDOUT) {
- /* add 1/4 (plus 1, in case the division truncates to 0) */
- curPollTimeout += ((curPollTimeout>>2) + 1);
- curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
- } else if (timeout_control == TIMEOUT_EVENTS) {
- /* subtract 1/4 (plus 1, in case the division truncates to 0) */
- curPollTimeout -= ((curPollTimeout>>2) + 1);
- curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, curPollTimeout);
+
+ switch(awt_poll_alg) {
+ case AWT_POLL_AGING_SLOW:
+ if (timeout_control == TIMEOUT_TIMEDOUT) {
+ /* add 1/4 (plus 1, in case the division truncates to 0) */
+ curPollTimeout += ((curPollTimeout>>2) + 1);
+ curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
+ } else if (timeout_control == TIMEOUT_EVENTS) {
+ /* subtract 1/4 (plus 1, in case the division truncates to 0) */
+ curPollTimeout -= ((curPollTimeout>>2) + 1);
+ curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, curPollTimeout);
+ }
+ break;
+ case AWT_POLL_AGING_FAST:
+ if (timeout_control == TIMEOUT_TIMEDOUT) {
+ curPollTimeout += ((curPollTimeout>>2) + 1);
+ curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
+ if((int)curPollTimeout > AWT_POLL_THRESHOLD || (int)curPollTimeout == AWT_POLL_BLOCK)
+ curPollTimeout = AWT_POLL_BLOCK;
+ } else if (timeout_control == TIMEOUT_EVENTS) {
+ curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, 1);
+ }
+ break;
}
}
@@ -497,16 +564,37 @@
*/
static uint32_t get_poll_timeout(jlong nextTaskTime)
{
+ uint32_t ret_timeout;
+ uint32_t timeout;
+ uint32_t taskTimeout;
+ uint32_t flushTimeout;
+
jlong curTime = awtJNI_TimeMillis();
- uint32_t timeout = curPollTimeout;
- uint32_t taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
- uint32_t flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
+ timeout = curPollTimeout;
+ switch(awt_poll_alg) {
+ case AWT_POLL_AGING_SLOW:
+ case AWT_POLL_AGING_FAST:
+ taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
+ flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
+
+ PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
- PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
+ // Adjust timeout to flush_time and task_time
+ ret_timeout = min(flushTimeout, min(taskTimeout, timeout));
+ if((int)curPollTimeout == AWT_POLL_BLOCK)
+ ret_timeout = AWT_POLL_BLOCK;
+ break;
- // Adjust timeout to flush_time and task_time
- return min(flushTimeout, min(taskTimeout, timeout));
-} /* awt_get_poll_timeout() */
+ case AWT_POLL_FALSE:
+ ret_timeout = (nextTaskTime > curTime) ?
+ (nextTaskTime - curTime) :
+ ((nextTaskTime == -1) ? -1 : 0);
+ break;
+ }
+
+ return ret_timeout;
+
+} /* get_poll_timeout() */
/*
* Waits for X/Xt events to appear on the pipe. Returns only when
@@ -598,6 +686,8 @@
if (result == 0) {
/* poll() timed out -- update timeout value */
update_poll_timeout(TIMEOUT_TIMEDOUT);
+ PRINT2("%s(): TIMEOUT_TIMEDOUT curPollTimeout = %d \n",
+ performPoll, curPollTimeout);
}
if (pollFds[1].revents) {
int count;
@@ -606,10 +696,14 @@
do {
count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE );
} while (count == AWT_POLL_BUFSIZE );
+ PRINT2("%s(): data on the AWT pipe: curPollTimeout = %d \n",
+ performPoll, curPollTimeout);
}
if (pollFds[0].revents) {
// Events in X pipe
update_poll_timeout(TIMEOUT_EVENTS);
+ PRINT2("%s(): TIMEOUT_EVENTS curPollTimeout = %ld \n",
+ performPoll, curPollTimeout);
}
return;