JDK-6888633 : test/closed/javax/swing/JPopupMenu/4786415/bug4786415.java fails
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-10-06
  • Updated: 2013-09-12
  • Resolved: 2011-07-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b142Fixed
Related Reports
Relates :  
Description
The regression test fails with JDK 7b73 on X11 (linux-i586, Gnome/Metacity 2.24) with the following output:

----------System.err:(15/843)----------
java.lang.RuntimeException: Popup shown on the left side of screen, should be on the right.

	at bug4786415.main(bug4786415.java:75)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:617)
	at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
	at java.lang.Thread.run(Thread.java:717)

Comments
EVALUATION This is a regression caused by CR 6694823. There was a logic calculating bottom/right bounds available for the popup menu given the menu's size and screen bounds: - size = JPopupMenu.this.getPreferredSize(); - - // Use long variables to prevent overflow - long pw = (long) p.x + (long) size.width; - long ph = (long) p.y + (long) size.height; - - if( pw > screenBounds.x + screenBounds.width ) - p.x = screenBounds.x + screenBounds.width - size.width; - - if( ph > screenBounds.y + screenBounds.height) - p.y = screenBounds.y + screenBounds.height - size.height; And now we have: + // Calculate the screen size that popup should fit + Dimension popupSize = JPopupMenu.this.getPreferredSize(); + int popupRightX = popupLocation.x + popupSize.width; + int popupBottomY = popupLocation.y + popupSize.height; which is vulnerable to the typerange overflow. See src/share/classes/javax/swing/JPopupMenu.java
25-04-2011

EVALUATION The test assigns an Integer.MAX_VALUE to the popup x-value (or x-value) and expects it to be shown on the right (or the bottom) edge of the screen. Although it appears aligned to the left edge and has x=-1 (or y=-1) value. The test is intermittently passes with jdk7 whereas the actual popup location is wrong. With jdk6u25 the test positions a popup at the valid places and thus works fine.
25-04-2011