I need to repost my original patch for two reasons: 1. it doesn't apply cleanly (only with some fuzz), 2. it also has this init-loop problem. Find attached the correct version. I'd be happy to see it committed ASAP.
/Roman Am Mittwoch, den 10.09.2008, 21:04 +0200 schrieb Roman Kennke: > Hi Dmitri and Oleg, > > > > I understand than you do not want to add questionable code in 2D, > > > but I do not like the idea to make this by adding questionable code > > > to Swing. So before falliwing back to hack I'd suggest to thinkabout > > > > I'm not sure what you mean by "adding questionable code > > to Swing" - the code was already there. Now instead of > > directly calling sun internal API it will call a better > > defined internal API. > > Yeah, I agree. > > > > possible API, otherwise we have a good chance to keep this hack > > > in Swing code forever :( > > > > Swing is part of the platform, and will always have to > > use some APIs in the implementation which are not available > > to external developers. > > > > I don't see a problem with that. In this particular case > > I really don't see any benefit in exposing this very > > platform-specific API to the developers. > > Yeah. It looks like most (all?) Sun-specific code is in SwingUtilities2 > anyway, so this is more or less the porting interface for Swing for > people who really need to port OpenJDK Swing to a different JDK. If it > is a goal to support that, it might make sense to find all remaining > uses of Sun-specific code in Swing and refactor that to also use > SwingUtilities2. Or even better, create a separate interface and factory > for implementations of that interface that would be provided by the > developer who ports Swing. But that seems a little over the top right > now. I also suggest to get the original patch through. > > /Roman -- http://kennke.org/blog/
diff -r 7e10774d2a29 src/share/classes/sun/java2d/SunGraphicsEnvironment.java
--- a/src/share/classes/sun/java2d/SunGraphicsEnvironment.java Thu Aug 07 09:42:31 2008 -0700
+++ b/src/share/classes/sun/java2d/SunGraphicsEnvironment.java Wed Sep 10 23:52:15 2008 +0200
@@ -1290,6 +1290,13 @@
displayChanger.notifyPaletteChanged();
}
+ /**
+ * Returns true when the display is local, false for remote displays.
+ *
+ * @return true when the display is local, false for remote displays
+ */
+ public abstract boolean isDisplayLocal();
+
/*
* ----DISPLAY CHANGE SUPPORT----
*/
diff -r 7e10774d2a29 src/share/classes/sun/swing/SwingUtilities2.java
--- a/src/share/classes/sun/swing/SwingUtilities2.java Thu Aug 07 09:42:31 2008 -0700
+++ b/src/share/classes/sun/swing/SwingUtilities2.java Wed Sep 10 23:52:15 2008 +0200
@@ -55,6 +55,7 @@
import java.util.*;
import sun.font.FontDesignMetrics;
import sun.font.FontManager;
+import sun.java2d.SunGraphicsEnvironment;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
@@ -1482,22 +1483,14 @@
* appear capable of performing gamma correction needed for LCD text.
*/
public static boolean isLocalDisplay() {
- try {
- // On Windows just return true. Permission to read os.name
- // is granted to all code but wrapped in try to be safe.
- if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
- return true;
- }
- // Else probably Solaris or Linux in which case may be remote X11
- Class x11Class = Class.forName("sun.awt.X11GraphicsEnvironment");
- Method isDisplayLocalMethod = x11Class.getMethod(
- "isDisplayLocal", new Class[0]);
- return (Boolean)isDisplayLocalMethod.invoke(null, (Object[])null);
- } catch (Throwable t) {
+ boolean isLocal;
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ if (ge instanceof SunGraphicsEnvironment) {
+ isLocal = ((SunGraphicsEnvironment) ge).isDisplayLocal();
+ } else {
+ isLocal = true;
}
- // If we get here we're most likely being run on some other O/S
- // or we didn't properly detect Windows.
- return true;
+ return isLocal;
}
/**
diff -r 7e10774d2a29 src/solaris/classes/sun/awt/X11GraphicsEnvironment.java
--- a/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java Thu Aug 07 09:42:31 2008 -0700
+++ b/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java Wed Sep 10 23:52:15 2008 +0200
@@ -209,7 +209,7 @@
private static native int checkShmExt();
private static native String getDisplayString();
- private static Boolean isDisplayLocal;
+ private Boolean isDisplayLocal;
/**
* This should only be called from the static initializer, so no need for
@@ -234,7 +234,7 @@
return getScreenDevices()[getDefaultScreenNum()];
}
- public static boolean isDisplayLocal() {
+ public boolean isDisplayLocal() {
if (isDisplayLocal == null) {
SunToolkit.awtLock();
try {
diff -r 7e10774d2a29 src/solaris/native/sun/awt/fontpath.c
--- a/src/solaris/native/sun/awt/fontpath.c Thu Aug 07 09:42:31 2008 -0700
+++ b/src/solaris/native/sun/awt/fontpath.c Wed Sep 10 23:52:15 2008 +0200
@@ -156,7 +156,7 @@
isLocal = JNU_CallStaticMethodByName(env, NULL,
"sun/awt/X11GraphicsEnvironment",
- "isDisplayLocal",
+ "_isDisplayLocal",
"()Z").z;
isLocalSet = True;
return isLocal;
diff -r 7e10774d2a29 src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
--- a/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java Thu Aug 07 09:42:31 2008 -0700
+++ b/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java Wed Sep 10 23:52:15 2008 +0200
@@ -393,4 +393,8 @@
private static void dwmCompositionChanged(boolean enabled) {
isDWMCompositionEnabled = enabled;
}
+
+ public boolean isDisplayLocal() {
+ return true;
+ }
}
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
