@@ -320,7 +320,7 @@ static void moveToOverlap(Rectangle what, Rectangle where) {
320320 if (what .getMinY () >= where .getMaxY ()) {
321321 what .y -= what .getMinY () - where .getMaxY ();
322322 }
323- assert what .intersects (where );
323+ assert what .intersects (where ) : String . format ( "Failed to move %s to overlap %s" , what , where ) ;
324324 }
325325
326326 Point nativeLocationForPopup (Window popup , Component popupParent , Window toplevel ) {
@@ -387,7 +387,7 @@ protected void wlSetVisible(boolean v) {
387387 boolean isUnconstrained = isPopupPositionUnconstrained ();
388388
389389 performLocked (() -> {
390- assert wlSurface == null ;
390+ assert wlSurface == null : "Invisible window already has a Wayland surface attached" ;
391391 wlSurface = new WLMainSurface ((WLWindowPeer ) this );
392392 long wlSurfacePtr = wlSurface .getWlSurfacePtr ();
393393 if (isWlPopup ) {
@@ -477,7 +477,7 @@ public boolean isResizable() {
477477
478478 @ Override
479479 public void updateSurfaceSize () {
480- assert SunToolkit .isAWTLockHeldByCurrentThread ();
480+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
481481 // Note: must be called after a buffer of proper size has been attached to the surface,
482482 // but the surface has not yet been committed. Otherwise, the sizes will get out of sync,
483483 // which may result in visual artifacts.
@@ -910,7 +910,7 @@ void showWindowMenu(long serial, int x, int y) {
910910 // a button press, key press, or touch down event."
911911 // So 'serial' must appertain to such an event.
912912
913- assert serial != 0 ;
913+ assert serial != 0 : "The serial number of the event requesting the window menu must be non-zero" ;
914914
915915 int xNative = javaUnitsToSurfaceUnits (x );
916916 int yNative = javaUnitsToSurfaceUnits (y );
@@ -970,7 +970,7 @@ public void dispose() {
970970 WLToolkit .targetDisposedPeer (target , this );
971971
972972 performLocked (() -> {
973- assert !isVisible ();
973+ assert !isVisible () : "Disposed window must have been already hidden" ;
974974
975975 nativeDisposeFrame (nativePtr );
976976 nativePtr = 0 ;
@@ -1373,7 +1373,8 @@ void dispatchPointerEventInContext(WLPointerEvent e, WLInputState oldInputState,
13731373 }
13741374
13751375 if (verticalMWERoundRotations != 0 || verticalMWEPreciseRotations != 0 ) {
1376- assert (verticalMWEScrollAmount > 0 );
1376+ assert verticalMWEScrollAmount > 0
1377+ : String .format ("Vertical scrolling event has negative scroll amount: %d" , verticalMWEScrollAmount );
13771378
13781379 final MouseEvent mouseEvent = new MouseWheelEvent (getTarget (),
13791380 MouseEvent .MOUSE_WHEEL ,
@@ -1392,7 +1393,8 @@ void dispatchPointerEventInContext(WLPointerEvent e, WLInputState oldInputState,
13921393 }
13931394
13941395 if (horizontalMWERoundRotations != 0 || horizontalMWEPreciseRotations != 0 ) {
1395- assert (horizontalMWEScrollAmount > 0 );
1396+ assert horizontalMWEScrollAmount > 0
1397+ : String .format ("Horizontal scrolling event has negative scroll amount: %d" , horizontalMWEScrollAmount );;
13961398
13971399 final MouseEvent mouseEvent = new MouseWheelEvent (getTarget (),
13981400 MouseEvent .MOUSE_WHEEL ,
@@ -1603,7 +1605,7 @@ void startDrag(long serial) {
16031605 // "This request must be used in response to some sort of user action like a button press,
16041606 // key press, or touch down event. The passed serial is used to determine the type
16051607 // of interactive move (touch, pointer, etc)."
1606- assert serial != 0 ;
1608+ assert serial != 0 : "The serial number of the event requesting the drag must be non-zero" ;
16071609
16081610 performLocked (() -> nativeStartDrag (serial , nativePtr ));
16091611 }
@@ -1612,7 +1614,7 @@ void startResize(long serial, int edges) {
16121614 // "This request must be used in response to some sort of user action like a button press,
16131615 // key press, or touch down event. The passed serial is used to determine the type
16141616 // of interactive resize (touch, pointer, etc)."
1615- assert serial != 0 ;
1617+ assert serial != 0 : "The serial number of the event requesting the resize must be non-zero" ;
16161618
16171619 performLocked (() -> nativeStartResize (serial , nativePtr , edges ));
16181620 }
@@ -1692,7 +1694,7 @@ Point convertPontFromDeviceSpace(int x, int y) {
16921694
16931695 void notifyConfigured (int newSurfaceX , int newSurfaceY , int newSurfaceWidth , int newSurfaceHeight ,
16941696 boolean active , boolean maximized , boolean fullscreen ) {
1695- assert SunToolkit .isAWTLockHeldByCurrentThread ();
1697+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
16961698
16971699 // NB: The width and height, as well as X and Y arguments, specify the size and the location
16981700 // of the window in surface-local coordinates.
@@ -1773,12 +1775,12 @@ void notifyEnteredOutput(int wlOutputID) {
17731775 }
17741776
17751777 void notifyPopupDone () {
1776- assert ( targetIsWlPopup ()) ;
1778+ assert targetIsWlPopup () : "This method must be invoked only for popups" ;
17771779 target .setVisible (false );
17781780 }
17791781
17801782 void checkIfOnNewScreen () {
1781- assert SunToolkit .isAWTLockHeldByCurrentThread ();
1783+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
17821784
17831785 if (wlSurface == null ) return ;
17841786 final WLGraphicsDevice newDevice = wlSurface .getGraphicsDevice ();
@@ -2023,7 +2025,7 @@ public int getSize() {
20232025
20242026 @ Override
20252027 public void updateSurfaceSize () {
2026- assert SunToolkit .isAWTLockHeldByCurrentThread ();
2028+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
20272029
20282030 shadowSurface .updateSurfaceSize (shadowWlSize .getSurfaceWidth (), shadowWlSize .getSurfaceHeight ());
20292031 }
@@ -2035,22 +2037,22 @@ public void resizeToParentWindow() {
20352037 }
20362038
20372039 public void createSurface () {
2038- assert shadowSurface == null ;
2039- assert SunToolkit .isAWTLockHeldByCurrentThread ();
2040+ assert shadowSurface == null : "The shadow surface must not be created twice" ;
2041+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
20402042
20412043 int shadowOffset = -javaUnitsToSurfaceUnits (shadowSize );
20422044 shadowSurface = new WLSubSurface (wlSurface , shadowOffset , shadowOffset );
20432045 }
20442046
20452047 public void commitSurface () {
20462048 assert shadowSurface != null ;
2047- assert SunToolkit .isAWTLockHeldByCurrentThread ();
2049+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
20482050
20492051 shadowSurface .commit ();
20502052 }
20512053
20522054 public void dispose () {
2053- assert SunToolkit .isAWTLockHeldByCurrentThread ();
2055+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
20542056
20552057 if (shadowSurface != null ) {
20562058 shadowSurface .dispose ();
@@ -2065,7 +2067,7 @@ public void dispose() {
20652067 }
20662068
20672069 public void hide () {
2068- assert SunToolkit .isAWTLockHeldByCurrentThread ();
2070+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
20692071
20702072 if (shadowSurface != null ) {
20712073 shadowSurface .dispose ();
@@ -2074,15 +2076,15 @@ public void hide() {
20742076 }
20752077
20762078 public void updateSurfaceData () {
2077- assert SunToolkit .isAWTLockHeldByCurrentThread ();
2079+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
20782080
20792081 needsRepaint = true ;
20802082 SurfaceData .convertTo (WLSurfaceDataExt .class , shadowSurfaceData ).revalidate (
20812083 getGraphicsConfiguration (), shadowWlSize .getPixelWidth (), shadowWlSize .getPixelHeight (), getDisplayScale ());
20822084 }
20832085
20842086 public void paint () {
2085- assert SunToolkit .isAWTLockHeldByCurrentThread ();
2087+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
20862088
20872089 if (!needsRepaint ) {
20882090 return ;
@@ -2108,7 +2110,7 @@ public void commitSurfaceData() {
21082110
21092111 public void notifyConfigured (boolean active , boolean maximized , boolean fullscreen ) {
21102112 assert shadowSurface != null ;
2111- assert SunToolkit .isAWTLockHeldByCurrentThread ();
2113+ assert SunToolkit .isAWTLockHeldByCurrentThread () : "This method must be invoked while holding the AWT lock" ;
21122114
21132115 needsRepaint |= active ^ isActive ;
21142116
0 commit comments