< prev index next >
src/solaris/classes/sun/awt/X11/XBaseWindow.java
Print this page
rev 1571 : 8010297: Missing isLoggable() checks in logging code
Summary: Add isLoggable() checks
Reviewed-by: anthony, mchung, serb
Contributed-by: Laurent Bourges <bourges.laurent@gmail.com>
@@ -158,11 +158,13 @@
/**
* Called after window creation, descendants should override to initialize Window
* with class-specific values and perform post-initialization actions.
*/
void postInit(XCreateWindowParams params) {
- if (log.isLoggable(Level.FINE)) log.fine("WM name is " + getWMName());
+ if (log.isLoggable(Level.FINE)) {
+ log.fine("WM name is " + getWMName());
+ }
updateWMName();
// Set WM_CLIENT_LEADER property
initClientLeader();
}
@@ -196,11 +198,13 @@
initialising = InitialiseState.FAILED_INITIALISATION;
awtLockNotifyAll();
awtUnlock();
throw re;
} catch (Throwable t) {
+ if (log.isLoggable(Level.WARNING)) {
log.log(Level.WARNING, "Exception during peer initialization", t);
+ }
awtLock();
initialising = InitialiseState.FAILED_INITIALISATION;
awtLockNotifyAll();
awtUnlock();
}
@@ -478,11 +482,13 @@
}
return hints;
}
public void setSizeHints(long flags, int x, int y, int width, int height) {
- if (insLog.isLoggable(Level.FINER)) insLog.finer("Setting hints, flags " + XlibWrapper.hintsToString(flags));
+ if (insLog.isLoggable(Level.FINER)) {
+ insLog.finer("Setting hints, flags " + XlibWrapper.hintsToString(flags));
+ }
XToolkit.awtLock();
try {
XSizeHints hints = getHints();
// Note: if PPosition is not set in flags this means that
// we want to reset PPosition in hints. This is necessary
@@ -539,12 +545,14 @@
}
}
flags |= XlibWrapper.PWinGravity;
hints.set_flags(flags);
hints.set_win_gravity((int)XlibWrapper.NorthWestGravity);
- if (insLog.isLoggable(Level.FINER)) insLog.finer("Setting hints, resulted flags " + XlibWrapper.hintsToString(flags) +
+ if (insLog.isLoggable(Level.FINER)) {
+ insLog.finer("Setting hints, resulted flags " + XlibWrapper.hintsToString(flags) +
", values " + hints);
+ }
XlibWrapper.XSetWMNormalHints(XToolkit.getDisplay(), getWindow(), hints.pData);
} finally {
XToolkit.awtUnlock();
}
}
@@ -591,20 +599,24 @@
}
}
public void xRequestFocus(long time) {
XToolkit.awtLock();
try {
- if (focusLog.isLoggable(Level.FINER)) focusLog.finer("XSetInputFocus on " + Long.toHexString(getWindow()) + " with time " + time);
+ if (focusLog.isLoggable(Level.FINER)) {
+ focusLog.finer("XSetInputFocus on " + Long.toHexString(getWindow()) + " with time " + time);
+ }
XlibWrapper.XSetInputFocus2(XToolkit.getDisplay(), getWindow(), time);
} finally {
XToolkit.awtUnlock();
}
}
public void xRequestFocus() {
XToolkit.awtLock();
try {
- if (focusLog.isLoggable(Level.FINER)) focusLog.finer("XSetInputFocus on " + Long.toHexString(getWindow()));
+ if (focusLog.isLoggable(Level.FINER)) {
+ focusLog.finer("XSetInputFocus on " + Long.toHexString(getWindow()));
+ }
XlibWrapper.XSetInputFocus(XToolkit.getDisplay(), getWindow());
} finally {
XToolkit.awtUnlock();
}
}
@@ -617,11 +629,13 @@
XToolkit.awtUnlock();
}
}
public void xSetVisible(boolean visible) {
- if (log.isLoggable(Level.FINE)) log.fine("Setting visible on " + this + " to " + visible);
+ if (log.isLoggable(Level.FINE)) {
+ log.fine("Setting visible on " + this + " to " + visible);
+ }
XToolkit.awtLock();
try {
this.visible = visible;
if (visible) {
XlibWrapper.XMapWindow(XToolkit.getDisplay(), getWindow());
@@ -702,11 +716,13 @@
public void xSetBounds(int x, int y, int width, int height) {
if (getWindow() == 0) {
insLog.warning("Attempt to resize uncreated window");
throw new IllegalStateException("Attempt to resize uncreated window");
}
+ if (insLog.isLoggable(Level.FINE)) {
insLog.fine("Setting bounds on " + this + " to (" + x + ", " + y + "), " + width + "x" + height);
+ }
if (width <= 0) {
width = 1;
}
if (height <= 0) {
height = 1;
@@ -904,13 +920,15 @@
}
static void checkSecurity() {
if (XToolkit.isSecurityWarningEnabled() && XToolkit.isToolkitThread()) {
StackTraceElement stack[] = (new Throwable()).getStackTrace();
+ if (log.isLoggable(Level.WARNING)) {
log.warning(stack[1] + ": Security violation: calling user code on toolkit thread");
}
}
+ }
public Set<Long> getChildren() {
synchronized (getStateLock()) {
return new HashSet<Long>(children);
}
@@ -1063,11 +1081,13 @@
target.dispatchEvent(ev);
}
}
public void dispatchEvent(XEvent xev) {
- if (eventLog.isLoggable(Level.FINEST)) eventLog.finest(xev.toString());
+ if (eventLog.isLoggable(Level.FINEST)) {
+ eventLog.finest(xev.toString());
+ }
int type = xev.get_type();
if (isDisposed()) {
return;
}
< prev index next >