Skip to content

Commit

Permalink
Bug 1247: Enhance JAWTWindow DEBUG output (not fixing any issues)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgothel committed Oct 9, 2015
1 parent 108ff45 commit 0abf3c0
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface,
*/
protected JAWTWindow(final Object comp, final AbstractGraphicsConfiguration config) {
if (config == null) {
throw new NativeWindowException("Error: AbstractGraphicsConfiguration is null");
throw new IllegalArgumentException("Error: AbstractGraphicsConfiguration is null");
}
if(! ( config instanceof AWTGraphicsConfiguration ) ) {
throw new NativeWindowException("Error: AbstractGraphicsConfiguration is not an AWTGraphicsConfiguration: "+config);
Expand All @@ -132,9 +132,13 @@ protected JAWTWindow(final Object comp, final AbstractGraphicsConfiguration conf
this.awtConfig = (AWTGraphicsConfiguration) config;
this.isApplet = false;
this.offscreenSurfaceLayer = 0;
if(DEBUG) {
System.err.println(jawtStr2("ctor"));
}
}
private static String id(final Object obj) { return ( null!=obj ? toHexString(obj.hashCode()) : "nil" ); }
private String jawtStr() { return "JAWTWindow["+id(JAWTWindow.this)+"]"; }
private String jawtStr1() { return "JAWTWindow["+id(JAWTWindow.this)+"]"; }
private String jawtStr2(final String sub) { return jawtStr1()+"."+sub+" @ Thread "+getThreadName(); }

private class JAWTComponentListener implements ComponentListener, HierarchyListener {
private volatile boolean isShowing;
Expand Down Expand Up @@ -180,7 +184,7 @@ private JAWTComponentListener() {
public void run() {
isShowing = component.isShowing(); // Bug 1161: Runnable might be deferred, hence need to update
if(DEBUG) {
System.err.println(jawtStr()+".attach @ Thread "+getThreadName()+": "+JAWTComponentListener.this.toString());
System.err.println(jawtStr2("attach")+": "+JAWTComponentListener.this.toString());
}
component.addComponentListener(JAWTComponentListener.this);
component.addHierarchyListener(JAWTComponentListener.this);
Expand All @@ -192,7 +196,7 @@ private final void detach() {
@Override
public void run() {
if(DEBUG) {
System.err.println(jawtStr()+".detach @ Thread "+getThreadName()+": "+JAWTComponentListener.this.toString());
System.err.println(jawtStr2("detach")+": "+JAWTComponentListener.this.toString());
}
component.removeComponentListener(JAWTComponentListener.this);
component.removeHierarchyListener(JAWTComponentListener.this);
Expand All @@ -202,31 +206,31 @@ public void run() {
@Override
public final void componentResized(final ComponentEvent e) {
if(DEBUG) {
System.err.println(jawtStr()+".componentResized: "+s(e));
System.err.println(jawtStr2("componentResized")+": "+s(e));
}
layoutSurfaceLayerIfEnabled(isShowing);
}

@Override
public final void componentMoved(final ComponentEvent e) {
if(DEBUG) {
System.err.println(jawtStr()+".componentMoved: "+s(e));
System.err.println(jawtStr2("componentMoved")+": "+s(e));
}
layoutSurfaceLayerIfEnabled(isShowing);
}

@Override
public final void componentShown(final ComponentEvent e) {
if(DEBUG) {
System.err.println(jawtStr()+".componentShown: "+s(e));
System.err.println(jawtStr2("componentShown")+": "+s(e));
}
layoutSurfaceLayerIfEnabled(isShowing);
}

@Override
public final void componentHidden(final ComponentEvent e) {
if(DEBUG) {
System.err.println(jawtStr()+".componentHidden: "+s(e));
System.err.println(jawtStr2("componentHidden")+": "+s(e));
}
layoutSurfaceLayerIfEnabled(isShowing);
}
Expand All @@ -248,7 +252,7 @@ public final void hierarchyChanged(final HierarchyEvent e) {
final java.awt.Component changed = e.getChanged();
final boolean displayable = changed.isDisplayable();
final boolean showing = changed.isShowing();
System.err.println(jawtStr()+".hierarchyChanged: action "+action+", displayable "+displayable+", showing [changed "+showing+", comp "+wasShowing+" -> "+isShowing+"], "+s(e));
System.err.println(jawtStr2("hierarchyChanged")+": action "+action+", displayable "+displayable+", showing [changed "+showing+", comp "+wasShowing+" -> "+isShowing+"], "+s(e));
}
}
}
Expand All @@ -257,7 +261,7 @@ public final void hierarchyChanged(final HierarchyEvent e) {

protected synchronized void invalidate() {
if(DEBUG) {
System.err.println(jawtStr()+".invalidate() - "+jawtComponentListener.toString());
System.err.println(jawtStr2("invalidate")+" - "+jawtComponentListener.toString());
if( isSurfaceLayerAttached() ) {
System.err.println("OffscreenSurfaceLayer still attached: 0x"+Long.toHexString(offscreenSurfaceLayer));
}
Expand Down Expand Up @@ -295,7 +299,7 @@ protected synchronized void invalidate() {
*/
public final void setAWTGraphicsConfiguration(final AWTGraphicsConfiguration config) {
if(DEBUG) {
System.err.println(jawtStr()+".setAWTGraphicsConfiguration(): "+this.awtConfig+" -> "+config);
System.err.println(jawtStr2("setAWTGraphicsConfiguration")+": "+this.awtConfig+" -> "+config);
// Thread.dumpStack();
}
this.awtConfig = config;
Expand Down Expand Up @@ -826,7 +830,7 @@ public void destroy() {
surfaceLock.lock();
try {
if(DEBUG) {
System.err.println(jawtStr()+".destroy @ Thread "+getThreadName());
System.err.println(jawtStr2("destroy"));
}
jawtComponentListener.detach();
invalidate();
Expand Down Expand Up @@ -930,7 +934,7 @@ protected StringBuilder jawt2String(StringBuilder sb) {
public String toString() {
final StringBuilder sb = new StringBuilder();

sb.append(jawtStr()+"[");
sb.append(jawtStr1()+"[");
jawt2String(sb);
sb.append( ", shallUseOffscreenLayer "+shallUseOffscreenLayer+", isOffscreenLayerSurface "+isOffscreenLayerSurface+
", attachedSurfaceLayer "+toHexString(getAttachedSurfaceLayer())+
Expand Down

0 comments on commit 0abf3c0

Please sign in to comment.