JBR-9730 Wayland: to add a secondary expression in assertions

This commit is contained in:
Maxim Kartashev
2025-12-02 17:58:28 +04:00
committed by jbrbot
parent 682558af02
commit e1a7d9ea65
19 changed files with 124 additions and 119 deletions

View File

@@ -164,7 +164,7 @@ public abstract class FullFrameDecorationHelper extends FrameDecoration {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
assert isRepaintNeeded(); assert isRepaintNeeded() : "paint() called when no repaint needed";
int width = peer.getWidth(); int width = peer.getWidth();
int height = peer.getHeight(); int height = peer.getHeight();
@@ -196,7 +196,7 @@ public abstract class FullFrameDecorationHelper extends FrameDecoration {
} }
private boolean isSignificantDrag(Point p) { private boolean isSignificantDrag(Point p) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
Objects.requireNonNull(p); Objects.requireNonNull(p);
return pressedLocation != null && isSignificantDragDistance(pressedLocation, p); return pressedLocation != null && isSignificantDragDistance(pressedLocation, p);
@@ -208,7 +208,7 @@ public abstract class FullFrameDecorationHelper extends FrameDecoration {
@Override @Override
boolean processMouseEvent(MouseEvent e) { boolean processMouseEvent(MouseEvent e) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (super.processMouseEvent(e)) return true; if (super.processMouseEvent(e)) return true;
@@ -326,7 +326,7 @@ public abstract class FullFrameDecorationHelper extends FrameDecoration {
} }
private boolean processMouseEvent(MouseEvent e) { private boolean processMouseEvent(MouseEvent e) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
Rectangle buttonBounds = bounds.get(); Rectangle buttonBounds = bounds.get();
boolean ourLocation = buttonBounds != null && e.getID() != MouseEvent.MOUSE_EXITED && boolean ourLocation = buttonBounds != null && e.getID() != MouseEvent.MOUSE_EXITED &&

View File

@@ -68,7 +68,7 @@ public class GtkFrameDecoration extends FullFrameDecorationHelper {
public GtkFrameDecoration(WLDecoratedPeer peer, boolean showMinimize, boolean showMaximize) { public GtkFrameDecoration(WLDecoratedPeer peer, boolean showMinimize, boolean showMaximize) {
super(peer, showMinimize, showMaximize); super(peer, showMinimize, showMaximize);
nativePtr = nativeCreateDecoration(showMinimize, showMaximize, isDarkTheme()); nativePtr = nativeCreateDecoration(showMinimize, showMaximize, isDarkTheme());
assert nativePtr != 0; assert nativePtr != 0 : "Failed to create the native part of the decoration";
int t = nativeGetIntProperty(nativePtr, "gtk-dnd-drag-threshold"); int t = nativeGetIntProperty(nativePtr, "gtk-dnd-drag-threshold");
dndThreshold = t > 0 ? t : 4; dndThreshold = t > 0 ? t : 4;
} }
@@ -87,8 +87,8 @@ public class GtkFrameDecoration extends FullFrameDecorationHelper {
int width = peer.getWidth(); int width = peer.getWidth();
int height = titleBarHeight; int height = titleBarHeight;
assert width >= titleBarMinWidth; assert width >= titleBarMinWidth : "The frame width is too small to display the title bar";
assert peer.getHeight() >= titleBarHeight; assert peer.getHeight() >= titleBarHeight : "The frame height is too small to display the title bar";
double scale = ((WLGraphicsConfig) peer.getGraphicsConfiguration()).getEffectiveScale(); double scale = ((WLGraphicsConfig) peer.getGraphicsConfiguration()).getEffectiveScale();
g2d.setBackground(new Color(0, true)); g2d.setBackground(new Color(0, true));

View File

@@ -96,7 +96,7 @@ public class ServerSideFrameDecoration extends FrameDecoration {
@Override @Override
public void dispose() { public void dispose() {
// Native resources must have been already disposed when the window was hidden // Native resources must have been already disposed when the window was hidden
assert nativeDecorPtr == 0; assert nativeDecorPtr == 0 : "Native resources must have been already disposed";
} }
private native long createToplevelDecorationImpl(long nativeFramePtr); private native long createToplevelDecorationImpl(long nativeFramePtr);

View File

@@ -320,7 +320,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
if (what.getMinY() >= where.getMaxY()) { if (what.getMinY() >= where.getMaxY()) {
what.y -= what.getMinY() - where.getMaxY(); what.y -= what.getMinY() - where.getMaxY();
} }
assert what.intersects(where); assert what.intersects(where) : String.format("Failed to move %s to overlap %s", what, where);
} }
Point nativeLocationForPopup(Window popup, Component popupParent, Window toplevel) { Point nativeLocationForPopup(Window popup, Component popupParent, Window toplevel) {
@@ -387,7 +387,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
boolean isUnconstrained = isPopupPositionUnconstrained(); boolean isUnconstrained = isPopupPositionUnconstrained();
performLocked(() -> { performLocked(() -> {
assert wlSurface == null; assert wlSurface == null : "Invisible window already has a Wayland surface attached";
wlSurface = new WLMainSurface((WLWindowPeer) this); wlSurface = new WLMainSurface((WLWindowPeer) this);
long wlSurfacePtr = wlSurface.getWlSurfacePtr(); long wlSurfacePtr = wlSurface.getWlSurfacePtr();
if (isWlPopup) { if (isWlPopup) {
@@ -477,7 +477,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
@Override @Override
public void updateSurfaceSize() { public void updateSurfaceSize() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
// Note: must be called after a buffer of proper size has been attached to the surface, // Note: must be called after a buffer of proper size has been attached to the surface,
// but the surface has not yet been committed. Otherwise, the sizes will get out of sync, // but the surface has not yet been committed. Otherwise, the sizes will get out of sync,
// which may result in visual artifacts. // which may result in visual artifacts.
@@ -910,7 +910,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
// a button press, key press, or touch down event." // a button press, key press, or touch down event."
// So 'serial' must appertain to such an event. // So 'serial' must appertain to such an event.
assert serial != 0; assert serial != 0 : "The serial number of the event requesting the window menu must be non-zero";
int xNative = javaUnitsToSurfaceUnits(x); int xNative = javaUnitsToSurfaceUnits(x);
int yNative = javaUnitsToSurfaceUnits(y); int yNative = javaUnitsToSurfaceUnits(y);
@@ -970,7 +970,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
WLToolkit.targetDisposedPeer(target, this); WLToolkit.targetDisposedPeer(target, this);
performLocked(() -> { performLocked(() -> {
assert !isVisible(); assert !isVisible() : "Disposed window must have been already hidden";
nativeDisposeFrame(nativePtr); nativeDisposeFrame(nativePtr);
nativePtr = 0; nativePtr = 0;
@@ -1373,7 +1373,8 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
} }
if (verticalMWERoundRotations != 0 || verticalMWEPreciseRotations != 0) { if (verticalMWERoundRotations != 0 || verticalMWEPreciseRotations != 0) {
assert(verticalMWEScrollAmount > 0); assert verticalMWEScrollAmount > 0
: String.format("Vertical scrolling event has negative scroll amount: %d", verticalMWEScrollAmount);
final MouseEvent mouseEvent = new MouseWheelEvent(getTarget(), final MouseEvent mouseEvent = new MouseWheelEvent(getTarget(),
MouseEvent.MOUSE_WHEEL, MouseEvent.MOUSE_WHEEL,
@@ -1392,7 +1393,8 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
} }
if (horizontalMWERoundRotations != 0 || horizontalMWEPreciseRotations != 0) { if (horizontalMWERoundRotations != 0 || horizontalMWEPreciseRotations != 0) {
assert(horizontalMWEScrollAmount > 0); assert horizontalMWEScrollAmount > 0
: String.format("Horizontal scrolling event has negative scroll amount: %d", horizontalMWEScrollAmount);;
final MouseEvent mouseEvent = new MouseWheelEvent(getTarget(), final MouseEvent mouseEvent = new MouseWheelEvent(getTarget(),
MouseEvent.MOUSE_WHEEL, MouseEvent.MOUSE_WHEEL,
@@ -1603,7 +1605,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
// "This request must be used in response to some sort of user action like a button press, // "This request must be used in response to some sort of user action like a button press,
// key press, or touch down event. The passed serial is used to determine the type // key press, or touch down event. The passed serial is used to determine the type
// of interactive move (touch, pointer, etc)." // of interactive move (touch, pointer, etc)."
assert serial != 0; assert serial != 0 : "The serial number of the event requesting the drag must be non-zero";
performLocked(() -> nativeStartDrag(serial, nativePtr)); performLocked(() -> nativeStartDrag(serial, nativePtr));
} }
@@ -1612,7 +1614,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
// "This request must be used in response to some sort of user action like a button press, // "This request must be used in response to some sort of user action like a button press,
// key press, or touch down event. The passed serial is used to determine the type // key press, or touch down event. The passed serial is used to determine the type
// of interactive resize (touch, pointer, etc)." // of interactive resize (touch, pointer, etc)."
assert serial != 0; assert serial != 0 : "The serial number of the event requesting the resize must be non-zero";
performLocked(() -> nativeStartResize(serial, nativePtr, edges)); performLocked(() -> nativeStartResize(serial, nativePtr, edges));
} }
@@ -1692,7 +1694,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
void notifyConfigured(int newSurfaceX, int newSurfaceY, int newSurfaceWidth, int newSurfaceHeight, void notifyConfigured(int newSurfaceX, int newSurfaceY, int newSurfaceWidth, int newSurfaceHeight,
boolean active, boolean maximized, boolean fullscreen) { boolean active, boolean maximized, boolean fullscreen) {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
// NB: The width and height, as well as X and Y arguments, specify the size and the location // NB: The width and height, as well as X and Y arguments, specify the size and the location
// of the window in surface-local coordinates. // of the window in surface-local coordinates.
@@ -1773,12 +1775,12 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
} }
void notifyPopupDone() { void notifyPopupDone() {
assert(targetIsWlPopup()); assert targetIsWlPopup() : "This method must be invoked only for popups";
target.setVisible(false); target.setVisible(false);
} }
void checkIfOnNewScreen() { void checkIfOnNewScreen() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
if (wlSurface == null) return; if (wlSurface == null) return;
final WLGraphicsDevice newDevice = wlSurface.getGraphicsDevice(); final WLGraphicsDevice newDevice = wlSurface.getGraphicsDevice();
@@ -2023,7 +2025,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
@Override @Override
public void updateSurfaceSize() { public void updateSurfaceSize() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
shadowSurface.updateSurfaceSize(shadowWlSize.getSurfaceWidth(), shadowWlSize.getSurfaceHeight()); shadowSurface.updateSurfaceSize(shadowWlSize.getSurfaceWidth(), shadowWlSize.getSurfaceHeight());
} }
@@ -2035,8 +2037,8 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
} }
public void createSurface() { public void createSurface() {
assert shadowSurface == null; assert shadowSurface == null : "The shadow surface must not be created twice";
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
int shadowOffset = -javaUnitsToSurfaceUnits(shadowSize); int shadowOffset = -javaUnitsToSurfaceUnits(shadowSize);
shadowSurface = new WLSubSurface(wlSurface, shadowOffset, shadowOffset); shadowSurface = new WLSubSurface(wlSurface, shadowOffset, shadowOffset);
@@ -2044,13 +2046,13 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
public void commitSurface() { public void commitSurface() {
assert shadowSurface != null; assert shadowSurface != null;
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
shadowSurface.commit(); shadowSurface.commit();
} }
public void dispose() { public void dispose() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
if (shadowSurface != null) { if (shadowSurface != null) {
shadowSurface.dispose(); shadowSurface.dispose();
@@ -2065,7 +2067,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
} }
public void hide() { public void hide() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
if (shadowSurface != null) { if (shadowSurface != null) {
shadowSurface.dispose(); shadowSurface.dispose();
@@ -2074,7 +2076,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
} }
public void updateSurfaceData() { public void updateSurfaceData() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
needsRepaint = true; needsRepaint = true;
SurfaceData.convertTo(WLSurfaceDataExt.class, shadowSurfaceData).revalidate( SurfaceData.convertTo(WLSurfaceDataExt.class, shadowSurfaceData).revalidate(
@@ -2082,7 +2084,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
} }
public void paint() { public void paint() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
if (!needsRepaint) { if (!needsRepaint) {
return; return;
@@ -2108,7 +2110,7 @@ public class WLComponentPeer implements ComponentPeer, WLSurfaceSizeListener {
public void notifyConfigured(boolean active, boolean maximized, boolean fullscreen) { public void notifyConfigured(boolean active, boolean maximized, boolean fullscreen) {
assert shadowSurface != null; assert shadowSurface != null;
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
needsRepaint |= active ^ isActive; needsRepaint |= active ^ isActive;

View File

@@ -77,7 +77,8 @@ public class WLDataOffer {
fd = openReceivePipe(nativePtr, mime); fd = openReceivePipe(nativePtr, mime);
assert(fd != -1); // Otherwise an exception should be thrown from native code // Otherwise an exception should be thrown from native code
assert fd != -1 : "An invalid file descriptor received from the native code";
FileDescriptor javaFD = new FileDescriptor(); FileDescriptor javaFD = new FileDescriptor();
jdk.internal.access.SharedSecrets.getJavaIOFileDescriptorAccess().set(javaFD, fd); jdk.internal.access.SharedSecrets.getJavaIOFileDescriptorAccess().set(javaFD, fd);

View File

@@ -53,7 +53,7 @@ public class WLDataSource {
var wlDataTransferer = (WLDataTransferer) WLDataTransferer.getInstance(); var wlDataTransferer = (WLDataTransferer) WLDataTransferer.getInstance();
nativePtr = initNative(dataDevice.getNativePtr(), protocol); nativePtr = initNative(dataDevice.getNativePtr(), protocol);
assert nativePtr != 0; // should've already thrown in native assert nativePtr != 0 : "Failed to initialize the native part of the source"; // should've already thrown in native
this.data = data; this.data = data;
try { try {

View File

@@ -128,10 +128,10 @@ public class WLGraphicsDevice extends GraphicsDevice {
int widthLogical, int heightLogical, int widthLogical, int heightLogical,
int widthMm, int heightMm, int widthMm, int heightMm,
int displayScale) { int displayScale) {
assert width > 0 && height > 0; assert width > 0 && height > 0 : String.format("Invalid device size: %dx%d", width, height);
assert widthLogical > 0 && heightLogical > 0; assert widthLogical > 0 && heightLogical > 0 : String.format("Invalid logical device size: %dx%d", widthLogical, heightLogical);
assert widthMm > 0 && heightMm > 0; assert widthMm > 0 && heightMm > 0 : String.format("Invalid physical device size: %dx%d", widthMm, heightMm);
assert displayScale > 0; assert displayScale > 0 : String.format("Invalid display scale: %d", displayScale);
this.wlID = id; this.wlID = id;
this.name = name; this.name = name;
@@ -176,10 +176,10 @@ public class WLGraphicsDevice extends GraphicsDevice {
int widthLogical, int heightLogical, int widthLogical, int heightLogical,
int widthMm, int heightMm, int widthMm, int heightMm,
int scale) { int scale) {
assert width > 0 && height > 0; assert width > 0 && height > 0 : String.format("Invalid device size: %dx%d", width, height);
assert widthLogical > 0 && heightLogical > 0; assert widthLogical > 0 && heightLogical > 0 : String.format("Invalid logical device size: %dx%d", widthLogical, heightLogical);
assert widthMm > 0 && heightMm > 0; assert widthMm > 0 && heightMm > 0 : String.format("Invalid physical device size: %dx%d", widthMm, heightMm);
assert scale > 0; assert scale > 0 : String.format("Invalid display scale: %d", scale);
this.name = name; this.name = name;
this.x = x; this.x = x;

View File

@@ -242,7 +242,9 @@ record WLInputState(WLPointerEvent eventWithSurface,
WLPointerEvent newEventWithTimestamp, WLPointerEvent newEventWithTimestamp,
WLPointerEvent newEventWithPosition) { WLPointerEvent newEventWithPosition) {
if (pointerEvent.hasButtonEvent() && pointerEvent.getIsButtonPressed() && newEventWithSurface != null) { if (pointerEvent.hasButtonEvent() && pointerEvent.getIsButtonPressed() && newEventWithSurface != null) {
assert newEventWithTimestamp != null && newEventWithPosition != null; assert newEventWithTimestamp != null && newEventWithPosition != null
: "Events with timestamp and position are both required to be present";
int clickCount = 1; int clickCount = 1;
final boolean pressedSameButton = pointerButtonPressedEvent != null final boolean pressedSameButton = pointerButtonPressedEvent != null
&& pointerEvent.getButtonCode() == pointerButtonPressedEvent.linuxCode; && pointerEvent.getButtonCode() == pointerButtonPressedEvent.linuxCode;

View File

@@ -48,7 +48,7 @@ class WLKeyboard {
// called from native code // called from native code
void setRepeatInfo(int charsPerSecond, int delayMillis) { void setRepeatInfo(int charsPerSecond, int delayMillis) {
// this function receives (0, 0) when key repeat is disabled // this function receives (0, 0) when key repeat is disabled
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
this.delayBeforeRepeatMillis = delayMillis; this.delayBeforeRepeatMillis = delayMillis;
if (charsPerSecond > 0) { if (charsPerSecond > 0) {
this.delayBetweenRepeatMillis = (int) (1000.0 / charsPerSecond); this.delayBetweenRepeatMillis = (int) (1000.0 / charsPerSecond);
@@ -64,7 +64,7 @@ class WLKeyboard {
} }
void cancelRepeat() { void cancelRepeat() {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (currentRepeatTask != null) { if (currentRepeatTask != null) {
currentRepeatTask.cancel(); currentRepeatTask.cancel();
currentRepeatTask = null; currentRepeatTask = null;
@@ -74,7 +74,7 @@ class WLKeyboard {
// called from native code // called from native code
void stopRepeat(int keycode) { void stopRepeat(int keycode) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (currentRepeatKeycode == keycode) { if (currentRepeatKeycode == keycode) {
cancelRepeat(); cancelRepeat();
} }
@@ -82,7 +82,7 @@ class WLKeyboard {
// called from native code // called from native code
void startRepeat(long serial, long timestamp, int keycode) { void startRepeat(long serial, long timestamp, int keycode) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
cancelRepeat(); cancelRepeat();
if (keycode == 0 || !isRepeatEnabled()) { if (keycode == 0 || !isRepeatEnabled()) {
return; return;
@@ -123,7 +123,7 @@ class WLKeyboard {
public native boolean isNumLockPressed(); public native boolean isNumLockPressed();
public void onLostFocus() { public void onLostFocus() {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
keyRepeatManager.cancelRepeat(); keyRepeatManager.cancelRepeat();
cancelCompose(); cancelCompose();
} }

View File

@@ -91,7 +91,7 @@ public class WLMainSurface extends WLSurface {
} }
public void activateByAnotherSurface(long serial, long activatingSurfacePtr) { public void activateByAnotherSurface(long serial, long activatingSurfacePtr) {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assertIsValid(); assertIsValid();
nativeActivate(getNativePtr(), serial, activatingSurfacePtr); nativeActivate(getNativePtr(), serial, activatingSurfacePtr);

View File

@@ -217,37 +217,37 @@ class WLPointerEvent {
} }
public long getSurface() { public long getSurface() {
assert hasSurface(); assert hasSurface() : "The event must have a valid surface";
return surface; return surface;
} }
public long getSerial() { public long getSerial() {
assert hasSerial(); assert hasSerial() : "The event must have a valid serial";
return serial; return serial;
} }
public long getTimestamp() { public long getTimestamp() {
assert hasTimestamp(); assert hasTimestamp() : "The event must have a valid timestamp";
return timestamp; return timestamp;
} }
public int getSurfaceX() { public int getSurfaceX() {
assert hasCoordinates(); assert hasCoordinates() : "The event must have valid coordinates";
return surface_x; return surface_x;
} }
public int getSurfaceY() { public int getSurfaceY() {
assert hasCoordinates(); assert hasCoordinates() : "The event must have valid coordinates";
return surface_y; return surface_y;
} }
public int getButtonCode() { public int getButtonCode() {
assert hasButtonEvent(); assert hasButtonEvent() : "Must have a button event to get the button code";
return buttonCode; return buttonCode;
} }
public boolean getIsButtonPressed() { public boolean getIsButtonPressed() {
assert hasButtonEvent(); assert hasButtonEvent() : "Must have a button event to get the button state";
return isButtonPressed; return isButtonPressed;
} }
@@ -270,12 +270,12 @@ class WLPointerEvent {
} }
public double getXAxisVectorValue() { public double getXAxisVectorValue() {
assert xAxisHasVectorValue(); assert xAxisHasVectorValue() : "Must have an X axis vector value";
return xAxis_vectorValue; return xAxis_vectorValue;
} }
public int getXAxisSteps120Value() { public int getXAxisSteps120Value() {
assert xAxisHasSteps120Value(); assert xAxisHasSteps120Value() : "Must have an X axis steps120 value";
return xAxis_steps120Value; return xAxis_steps120Value;
} }
@@ -298,12 +298,12 @@ class WLPointerEvent {
} }
public double getYAxisVectorValue() { public double getYAxisVectorValue() {
assert yAxisHasVectorValue(); assert yAxisHasVectorValue() : "Must have an Y axis vector value";
return yAxis_vectorValue; return yAxis_vectorValue;
} }
public int getYAxisSteps120Value() { public int getYAxisSteps120Value() {
assert yAxisHasSteps120Value(); assert yAxisHasSteps120Value(): "Must have an Y axis steps120 value";
return yAxis_steps120Value; return yAxis_steps120Value;
} }

View File

@@ -171,7 +171,7 @@ public class WLRobotPeer implements RobotPeer {
static Point getLocationOfWLSurface(WLSurface wlSurface) { static Point getLocationOfWLSurface(WLSurface wlSurface) {
checkExtensionPresent(); checkExtensionPresent();
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
final long wlSurfacePtr = wlSurface.getWlSurfacePtr(); final long wlSurfacePtr = wlSurface.getWlSurfacePtr();
// The native implementation allows for just one such request at a time // The native implementation allows for just one such request at a time

View File

@@ -57,7 +57,7 @@ public class WLSurface {
} }
public void dispose() { public void dispose() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
if (isValid) { if (isValid) {
hide(); hide();
@@ -67,7 +67,7 @@ public class WLSurface {
} }
public void hide() { public void hide() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assertIsValid(); assertIsValid();
if (surfaceData == null) return; if (surfaceData == null) return;
@@ -85,14 +85,14 @@ public class WLSurface {
} }
public boolean hasSurfaceData() { public boolean hasSurfaceData() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assertIsValid(); assertIsValid();
return surfaceData != null; return surfaceData != null;
} }
public void associateWithSurfaceData(SurfaceData data) { public void associateWithSurfaceData(SurfaceData data) {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
Objects.requireNonNull(data); Objects.requireNonNull(data);
assertIsValid(); assertIsValid();
@@ -103,7 +103,7 @@ public class WLSurface {
} }
public void commit() { public void commit() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assertIsValid(); assertIsValid();
nativeCommitWlSurface(nativePtr); nativeCommitWlSurface(nativePtr);
@@ -115,28 +115,28 @@ public class WLSurface {
* @return a pointer to wl_surface native object * @return a pointer to wl_surface native object
*/ */
public long getWlSurfacePtr() { public long getWlSurfacePtr() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assertIsValid(); assertIsValid();
return wlSurfacePtr; return wlSurfacePtr;
} }
protected long getNativePtr() { protected long getNativePtr() {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assertIsValid(); assertIsValid();
return nativePtr; return nativePtr;
} }
public void setSize(int width, int height) { public void setSize(int width, int height) {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assertIsValid(); assertIsValid();
nativeSetSize(nativePtr, width, height); nativeSetSize(nativePtr, width, height);
} }
public void setOpaqueRegion(int x, int y, int width, int height) { public void setOpaqueRegion(int x, int y, int width, int height) {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assertIsValid(); assertIsValid();
nativeSetOpaqueRegion(nativePtr, x, y, width, height); nativeSetOpaqueRegion(nativePtr, x, y, width, height);
@@ -151,7 +151,7 @@ public class WLSurface {
} }
public void updateSurfaceSize(int surfaceWidth, int surfaceHeight) { public void updateSurfaceSize(int surfaceWidth, int surfaceHeight) {
assert SunToolkit.isAWTLockHeldByCurrentThread(); assert SunToolkit.isAWTLockHeldByCurrentThread() : "This method must be invoked while holding the AWT lock";
assertIsValid(); assertIsValid();
setSize(surfaceWidth, surfaceHeight); setSize(surfaceWidth, surfaceHeight);

View File

@@ -311,7 +311,7 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
private static void dispatchPointerEvent(WLPointerEvent e) { private static void dispatchPointerEvent(WLPointerEvent e) {
// Invoked from the native code // Invoked from the native code
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (log.isLoggable(PlatformLogger.Level.FINE)) log.fine("dispatchPointerEvent: " + e); if (log.isLoggable(PlatformLogger.Level.FINE)) log.fine("dispatchPointerEvent: " + e);
@@ -342,7 +342,7 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
char keyChar, char keyChar,
int modifiers) { int modifiers) {
// Invoked from the native code // Invoked from the native code
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
inputState = inputState.updatedFromKeyEvent(serial); inputState = inputState.updatedFromKeyEvent(serial);
@@ -405,14 +405,14 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
} }
private static void dispatchKeyboardModifiersEvent(long serial) { private static void dispatchKeyboardModifiersEvent(long serial) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
inputState = inputState.updatedFromKeyboardModifiersEvent(serial, keyboard.getModifiers()); inputState = inputState.updatedFromKeyboardModifiersEvent(serial, keyboard.getModifiers());
WLDropTargetContextPeer.getInstance().handleModifiersUpdate(); WLDropTargetContextPeer.getInstance().handleModifiersUpdate();
} }
private static void dispatchKeyboardEnterEvent(long serial, long surfacePtr) { private static void dispatchKeyboardEnterEvent(long serial, long surfacePtr) {
// Invoked from the native code // Invoked from the native code
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (logKeys.isLoggable(PlatformLogger.Level.FINE)) { if (logKeys.isLoggable(PlatformLogger.Level.FINE)) {
logKeys.fine("dispatchKeyboardEnterEvent: " + serial + ", surface 0x" logKeys.fine("dispatchKeyboardEnterEvent: " + serial + ", surface 0x"
@@ -441,7 +441,7 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
private static void dispatchKeyboardLeaveEvent(long serial, long surfacePtr) { private static void dispatchKeyboardLeaveEvent(long serial, long surfacePtr) {
// Invoked from the native code // Invoked from the native code
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (logKeys.isLoggable(PlatformLogger.Level.FINE)) { if (logKeys.isLoggable(PlatformLogger.Level.FINE)) {
logKeys.fine("dispatchKeyboardLeaveEvent: " + serial + ", surface 0x" logKeys.fine("dispatchKeyboardLeaveEvent: " + serial + ", surface 0x"

View File

@@ -67,7 +67,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
public void startTracking(final Component component) { public void startTracking(final Component component) {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (log.isLoggable(PlatformLogger.Level.FINER)) { if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer( log.finer(
@@ -108,7 +108,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
} }
public void stopTrackingCurrentComponent() { public void stopTrackingCurrentComponent() {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (log.isLoggable(PlatformLogger.Level.FINER)) { if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer(String.format("stopTrackingCurrentComponent(): this=%s.", this), new Throwable("Stacktrace")); log.finer(String.format("stopTrackingCurrentComponent(): this=%s.", this), new Throwable("Stacktrace"));
@@ -160,7 +160,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
} }
public Component getTrackedComponentIfTracking() { public Component getTrackedComponentIfTracking() {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
final Component trackedComponentStrong; final Component trackedComponentStrong;
if (trackedComponent == null) { if (trackedComponent == null) {
@@ -188,7 +188,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
public void deferUpdates() { public void deferUpdates() {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (log.isLoggable(PlatformLogger.Level.FINER)) { if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer(String.format("deferUpdates(): this=%s.", this), new Throwable("Stacktrace")); log.finer(String.format("deferUpdates(): this=%s.", this), new Throwable("Stacktrace"));
@@ -198,7 +198,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
} }
public void resumeUpdates(final boolean discardDeferredUpdates) { public void resumeUpdates(final boolean discardDeferredUpdates) {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (log.isLoggable(PlatformLogger.Level.FINER)) { if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer(String.format("resumeUpdates(%b): this=%s.", discardDeferredUpdates, this), new Throwable("Stacktrace")); log.finer(String.format("resumeUpdates(%b): this=%s.", discardDeferredUpdates, this), new Throwable("Stacktrace"));
@@ -215,7 +215,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
} }
public boolean areUpdatesDeferred() { public boolean areUpdatesDeferred() {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
return updatesAreDeferred; return updatesAreDeferred;
} }
@@ -225,7 +225,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
/** This method is intended to be called from the owning IM's {@link java.awt.im.spi.InputMethod#dispatchEvent(AWTEvent)}. */ /** This method is intended to be called from the owning IM's {@link java.awt.im.spi.InputMethod#dispatchEvent(AWTEvent)}. */
public void onIMDispatchEvent(AWTEvent event) { public void onIMDispatchEvent(AWTEvent event) {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (log.isLoggable(PlatformLogger.Level.FINER)) { if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("onIMDispatchEvent(event={0}): this={1}.", event, this); log.finer("onIMDispatchEvent(event={0}): this={1}.", event, this);
@@ -254,7 +254,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
/** This method is intended to be called from the owning IM's {@link java.awt.im.spi.InputMethod#notifyClientWindowChange(Rectangle)}. */ /** This method is intended to be called from the owning IM's {@link java.awt.im.spi.InputMethod#notifyClientWindowChange(Rectangle)}. */
public void onIMNotifyClientWindowChange(Rectangle location) { public void onIMNotifyClientWindowChange(Rectangle location) {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (log.isLoggable(PlatformLogger.Level.FINER)) { if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("onIMNotifyClientWindowChange(location={0}): this={1}.", location, this); log.finer("onIMNotifyClientWindowChange(location={0}): this={1}.", location, this);
@@ -333,7 +333,7 @@ class ClientComponentCaretPositionTracker implements ComponentListener, CaretLis
private WLInputMethodZwpTextInputV3 getOwnerIm() { private WLInputMethodZwpTextInputV3 getOwnerIm() {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
final WLInputMethodZwpTextInputV3 thisImStrong; final WLInputMethodZwpTextInputV3 thisImStrong;
if (this.im == null) { if (this.im == null) {

View File

@@ -40,7 +40,7 @@ final class InputContextState {
public InputContextState(long nativeContextPtr) { public InputContextState(long nativeContextPtr) {
assert(nativeContextPtr != 0); assert nativeContextPtr != 0 : "Cannot create an input context from a NULL pointer";
this.nativeContextPtr = nativeContextPtr; this.nativeContextPtr = nativeContextPtr;
} }

View File

@@ -82,8 +82,8 @@ record JavaPreeditString(String text, int cursorBeginCodeUnit, int cursorEndCode
} }
if (resultText == null) { if (resultText == null) {
assert(fixedCursorBeginUtf8Byte == 0); assert fixedCursorBeginUtf8Byte == 0 : "Cursor begin byte must be zero for an empty string";
assert(fixedCursorEndUtf8Byte == 0); assert fixedCursorEndUtf8Byte == 0 : "Cursor end byte must be zero for an empty string";
return JavaPreeditString.EMPTY; return JavaPreeditString.EMPTY;
} }

View File

@@ -71,7 +71,7 @@ public final class WLInputMethodDescriptorZwpTextInputV3 implements InputMethodD
@Override @Override
public String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) { public String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) {
assert isAvailableOnPlatform(); assert isAvailableOnPlatform() : "IM must be available on the platform";
// This is how it's implemented in all other Toolkits. // This is how it's implemented in all other Toolkits.
// //
@@ -183,7 +183,7 @@ public final class WLInputMethodDescriptorZwpTextInputV3 implements InputMethodD
private WLInputMethodDescriptorZwpTextInputV3() { private WLInputMethodDescriptorZwpTextInputV3() {
assert isAvailableOnPlatform(); assert isAvailableOnPlatform() : "IM must be available on the platform";
initAndGetToolkitStartupLocale(); initAndGetToolkitStartupLocale();
} }

View File

@@ -243,7 +243,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
} }
// "The method is only called when the input method is inactive." // "The method is only called when the input method is inactive."
assert(this.awtActivationStatus != AWTActivationStatus.ACTIVATED); assert this.awtActivationStatus != AWTActivationStatus.ACTIVATED : "The method is called when the IM is active";
// The protocol doesn't provide a separate method for hiding the IM window(s), // The protocol doesn't provide a separate method for hiding the IM window(s),
// but this effect can be achieved by disabling the native context. // but this effect can be achieved by disabling the native context.
@@ -259,7 +259,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
} }
// "The method is only called when the input method is inactive." // "The method is only called when the input method is inactive."
assert(this.awtActivationStatus != AWTActivationStatus.ACTIVATED); assert this.awtActivationStatus != AWTActivationStatus.ACTIVATED : "The method is called when the IM is active";
wlDisableContextNow(); wlDisableContextNow();
} }
@@ -374,10 +374,10 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/* AWT-side methods section */ /* AWT-side methods section */
private static void awtFillWlContentTypeOf(Component component, OutgoingChanges out) { private static void awtFillWlContentTypeOf(Component component, OutgoingChanges out) {
assert(component != null); assert component != null : "Component must not be null";
assert(out != null); assert out != null : "OutgoingChanges must not be null";
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
// TODO: there's no dedicated AWT/Swing API for that, but we can make a few guesses, e.g. // TODO: there's no dedicated AWT/Swing API for that, but we can make a few guesses, e.g.
// (component instanceof JPasswordField) ? ContentPurpose.PASSWORD // (component instanceof JPasswordField) ? ContentPurpose.PASSWORD
@@ -389,7 +389,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* compatible with {@code zwp_text_input_v3::set_cursor_rectangle} API; * compatible with {@code zwp_text_input_v3::set_cursor_rectangle} API;
*/ */
private static Rectangle awtGetWlCursorRectangleOf(Component component) { private static Rectangle awtGetWlCursorRectangleOf(Component component) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
Rectangle result = null; Rectangle result = null;
@@ -434,7 +434,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* @throws IllegalArgumentException if {@code visibleComponent} is {@code null} or isn't showing on the screen. * @throws IllegalArgumentException if {@code visibleComponent} is {@code null} or isn't showing on the screen.
*/ */
private static Rectangle awtGetCaretOf(Component visibleComponent) { private static Rectangle awtGetCaretOf(Component visibleComponent) {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (!Objects.requireNonNull(visibleComponent, "visibleComponent").isShowing()) { if (!Objects.requireNonNull(visibleComponent, "visibleComponent").isShowing()) {
throw new IllegalArgumentException("visibleComponent must be showing"); throw new IllegalArgumentException("visibleComponent must be showing");
@@ -474,7 +474,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
} }
private static Rectangle awtGetVisibleRectOf(final Component component) { private static Rectangle awtGetVisibleRectOf(final Component component) {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (component instanceof javax.swing.JComponent jComponent) { if (component instanceof javax.swing.JComponent jComponent) {
return jComponent.getVisibleRect(); return jComponent.getVisibleRect();
@@ -488,7 +488,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* or {@code null} if the rectangle couldn't be determined. * or {@code null} if the rectangle couldn't be determined.
*/ */
private static Rectangle awtConvertRectOnComponentToRectOnWlSurface(Component component, Rectangle rectOnComponent) { private static Rectangle awtConvertRectOnComponentToRectOnWlSurface(Component component, Rectangle rectOnComponent) {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
Objects.requireNonNull(component, "component"); Objects.requireNonNull(component, "component");
@@ -536,7 +536,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* or its closest ancestor meeting these requirements. * or its closest ancestor meeting these requirements.
*/ */
private static Window awtGetWlSurfaceComponentOf(Component component) { private static Window awtGetWlSurfaceComponentOf(Component component) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
return WLComponentPeer.getToplevelFor(component); return WLComponentPeer.getToplevelFor(component);
} }
@@ -557,8 +557,8 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
log.finer("awtPostIMESafely(preeditString={0}, commitString={1}): this={2}.", preeditString, commitString, this); log.finer("awtPostIMESafely(preeditString={0}, commitString={1}): this={2}.", preeditString, commitString, this);
} }
assert(preeditString != null); assert preeditString != null : "Pre-edit string must be present";
assert(commitString != null); assert commitString != null : "Commit string must be present";
try { try {
if (awtActivationStatus != AWTActivationStatus.ACTIVATED) { if (awtActivationStatus != AWTActivationStatus.ACTIVATED) {
@@ -769,8 +769,8 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
specialPreeditHighlightingBegin = swapTemp; specialPreeditHighlightingBegin = swapTemp;
} }
assert(specialPreeditHighlightingBegin >= 0); assert specialPreeditHighlightingBegin >= 0 : "specialPreeditHighlightingBegin is invalid";
assert(specialPreeditHighlightingEnd <= preeditTextLength); assert specialPreeditHighlightingEnd <= preeditTextLength : "specialPreeditHighlightingEnd is out of range";
// v // v
// |BASIC+SPECIAL...| // |BASIC+SPECIAL...|
@@ -827,10 +827,10 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
// The methods in this section implement the core logic of working with the "text-input-unstable-v3" protocol. // The methods in this section implement the core logic of working with the "text-input-unstable-v3" protocol.
private void wlInitializeContext() throws AWTException { private void wlInitializeContext() throws AWTException {
assert(wlInputContextState == null); assert wlInputContextState == null : "Must not initialize input context twice";
assert(wlPendingChanges == null); assert wlPendingChanges == null : "Must not initialize pending changes twice";
assert(wlBeingCommittedChanges == null); assert wlBeingCommittedChanges == null : "Must not initialize being-committed changes twice";
assert(wlIncomingChanges == null); assert wlIncomingChanges == null : "Must not initialize incoming changes twice";
long nativeCtxPtr = 0; long nativeCtxPtr = 0;
@@ -878,7 +878,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
* followed by a {@code zwp_text_input_v3::commit} request. * followed by a {@code zwp_text_input_v3::commit} request.
*/ */
private void wlSendPendingChangesNow() { private void wlSendPendingChangesNow() {
assert(wlCanSendChangesNow()); assert wlCanSendChangesNow() : "Must be able to send pending changes now";
final OutgoingChanges changesToSend = wlPendingChanges; final OutgoingChanges changesToSend = wlPendingChanges;
wlPendingChanges = null; wlPendingChanges = null;
@@ -997,7 +997,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
throw new IllegalStateException("Attempt to enable an input context which hasn't entered any surface"); throw new IllegalStateException("Attempt to enable an input context which hasn't entered any surface");
} }
assert(wlContextCanBeEnabledNow()); assert wlContextCanBeEnabledNow() : "Can't enable InputContext";
// This way we guarantee the context won't accidentally get disabled because such a change has been scheduled earlier. // This way we guarantee the context won't accidentally get disabled because such a change has been scheduled earlier.
// Anyway we consider any previously scheduled changes outdated because an 'enable' request is supposed to // Anyway we consider any previously scheduled changes outdated because an 'enable' request is supposed to
@@ -1029,7 +1029,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
awtFillWlContentTypeOf(getClientComponent(), changeSet); awtFillWlContentTypeOf(getClientComponent(), changeSet);
wlScheduleContextNewChanges(changeSet); wlScheduleContextNewChanges(changeSet);
assert(wlPendingChanges != null); assert wlPendingChanges != null : "Must have non-empty pending changes";
// Pretending there are no committed, but not applied yet changes, so that wlCanSendChangesNow() is true. // Pretending there are no committed, but not applied yet changes, so that wlCanSendChangesNow() is true.
// We can do that because the assumption #1 and because any previously committed changes get lost when a // We can do that because the assumption #1 and because any previously committed changes get lost when a
@@ -1038,7 +1038,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
// set_surrounding_text, set_text_change_cause, set_content_type, and set_cursor_rectangle requests [...]" // set_surrounding_text, set_text_change_cause, set_content_type, and set_cursor_rectangle requests [...]"
wlBeingCommittedChanges = null; wlBeingCommittedChanges = null;
assert(wlCanSendChangesNow()); assert wlCanSendChangesNow() : "Must be able to send pending changes now";
wlSendPendingChangesNow(); wlSendPendingChangesNow();
// See the assumption #2 above. // See the assumption #2 above.
@@ -1103,10 +1103,10 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
} }
} }
assert(wlInputContextState.getCurrentWlSurfacePtr() != 0); assert wlInputContextState.getCurrentWlSurfacePtr() != 0 : "InputContext must have a valid current surface pointer";
wlScheduleContextNewChanges(new OutgoingChanges().setEnabledState(false)); wlScheduleContextNewChanges(new OutgoingChanges().setEnabledState(false));
assert(wlPendingChanges != null); assert wlPendingChanges != null : "Must have non-empty pending changes";
// Pretending there are no committed, but not applied yet changes, so that wlCanSendChangesNow() is true. // Pretending there are no committed, but not applied yet changes, so that wlCanSendChangesNow() is true.
// We can do that because the assumption #1 and because any previously committed changes get lost when a // We can do that because the assumption #1 and because any previously committed changes get lost when a
@@ -1114,7 +1114,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
// "After an enter event or disable request all state information is invalidated and needs to be resent by the client." // "After an enter event or disable request all state information is invalidated and needs to be resent by the client."
wlBeingCommittedChanges = null; wlBeingCommittedChanges = null;
assert(wlCanSendChangesNow()); assert wlCanSendChangesNow() : "Must be able to send pending changes now";
wlSendPendingChangesNow(); wlSendPendingChangesNow();
// See the assumption #2 above. // See the assumption #2 above.
@@ -1206,7 +1206,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called by {@link ClientComponentCaretPositionTracker} */ /** Called by {@link ClientComponentCaretPositionTracker} */
boolean wlUpdateCursorRectangle(final boolean forceUpdate) { boolean wlUpdateCursorRectangle(final boolean forceUpdate) {
assert(EventQueue.isDispatchThread()); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
if (log.isLoggable(PlatformLogger.Level.FINER)) { if (log.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("wlUpdateCursorRectangle(): forceUpdate={0}, this={1}.", forceUpdate, this); log.finer("wlUpdateCursorRectangle(): forceUpdate={0}, this={1}.", forceUpdate, this);
@@ -1290,7 +1290,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::enter} events. */ /** Called in response to {@code zwp_text_input_v3::enter} events. */
private void zwp_text_input_v3_onEnter(long enteredWlSurfacePtr) { private void zwp_text_input_v3_onEnter(long enteredWlSurfacePtr) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
try { try {
if (log.isLoggable(PlatformLogger.Level.FINE)) { if (log.isLoggable(PlatformLogger.Level.FINE)) {
@@ -1312,7 +1312,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::leave} events. */ /** Called in response to {@code zwp_text_input_v3::leave} events. */
private void zwp_text_input_v3_onLeave(long leftWlSurfacePtr) { private void zwp_text_input_v3_onLeave(long leftWlSurfacePtr) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
try { try {
if (log.isLoggable(PlatformLogger.Level.FINE)) { if (log.isLoggable(PlatformLogger.Level.FINE)) {
@@ -1335,7 +1335,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::preedit_string} events. */ /** Called in response to {@code zwp_text_input_v3::preedit_string} events. */
private void zwp_text_input_v3_onPreeditString(byte[] preeditStrUtf8, int cursorBeginUtf8Byte, int cursorEndUtf8Byte) { private void zwp_text_input_v3_onPreeditString(byte[] preeditStrUtf8, int cursorBeginUtf8Byte, int cursorEndUtf8Byte) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
try { try {
if (log.isLoggable(PlatformLogger.Level.FINE)) { if (log.isLoggable(PlatformLogger.Level.FINE)) {
@@ -1355,7 +1355,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::commit_string} events. */ /** Called in response to {@code zwp_text_input_v3::commit_string} events. */
private void zwp_text_input_v3_onCommitString(byte[] commitStrUtf8) { private void zwp_text_input_v3_onCommitString(byte[] commitStrUtf8) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
try { try {
if (log.isLoggable(PlatformLogger.Level.FINE)) { if (log.isLoggable(PlatformLogger.Level.FINE)) {
@@ -1375,7 +1375,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::delete_surrounding_text} events. */ /** Called in response to {@code zwp_text_input_v3::delete_surrounding_text} events. */
private void zwp_text_input_v3_onDeleteSurroundingText(long numberOfUtf8BytesBeforeToDelete, long numberOfUtf8BytesAfterToDelete) { private void zwp_text_input_v3_onDeleteSurroundingText(long numberOfUtf8BytesBeforeToDelete, long numberOfUtf8BytesAfterToDelete) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
// TODO: support the surrounding text API (set_surrounding_text + set_text_change_cause | delete_surrounding text) // TODO: support the surrounding text API (set_surrounding_text + set_text_change_cause | delete_surrounding text)
// at least for particular cases. // at least for particular cases.
@@ -1394,7 +1394,7 @@ final class WLInputMethodZwpTextInputV3 extends InputMethodAdapter {
/** Called in response to {@code zwp_text_input_v3::done} events. */ /** Called in response to {@code zwp_text_input_v3::done} events. */
private void zwp_text_input_v3_onDone(long doneSerial) { private void zwp_text_input_v3_onDone(long doneSerial) {
assert EventQueue.isDispatchThread(); assert EventQueue.isDispatchThread() : "Method must only be invoked on EDT";
try { try {
if (log.isLoggable(PlatformLogger.Level.FINE)) { if (log.isLoggable(PlatformLogger.Level.FINE)) {