-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8327007: javax/swing/JSpinner/8008657/bug8008657.java fails #18054
Conversation
👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into |
Webrevs
|
@@ -134,9 +134,20 @@ static String getOrientation(ComponentOrientation orientation) { | |||
static void createDateSpinner() { | |||
Calendar calendar = Calendar.getInstance(); | |||
Date initDate = calendar.getTime(); | |||
int year = calendar.get(Calendar.YEAR); | |||
boolean isLeapYear = ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to use java.tim.Year.isLeap(long)?
Can this test be changed to test multiple different dates, some of which are Feb 29th? |
The problem comes down to this public class LeapDayBug { % java LeapDayBug.java So I'm not sure what the Calendar class could do about this since both |
Surely this just needs a one line fix diff --git a/test/jdk/javax/swing/JSpinner/8008657/bug8008657.java b/test/jdk/javax/swing/JSpinner/8008657/bug8008657.java index cbeb0c185bb..49918278e34 100644 --- a/test/jdk/javax/swing/JSpinner/8008657/bug8008657.java +++ b/test/jdk/javax/swing/JSpinner/8008657/bug8008657.java @@ -137,6 +137,7 @@ static void createDateSpinner() { calendar.add(Calendar.YEAR, -1); Date earliestDate = calendar.getTime(); calendar.add(Calendar.YEAR, 1); + calendar.add(Calendar.DAY_OF_MONTH, 1); Date latestDate = calendar.getTime(); SpinnerModel dateModel = new SpinnerDateModel(initDate, earliestDate, |
Yes, I did thought about that but thought should we do it irrespectively of leap year or not, so atlast I thought of doing it for leapyear only so that it doesn't affect anyother scenarios... |
Done minimal change as suggested... |
@prsadhuk This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 46 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit b7540df.
Your commit was automatically rebased without conflicts. |
Test failed with the exception java.lang.IllegalArgumentException: (start <= value <= end) with no history of failing till date.
Investigation shows SpinnerDateModel constructor condition is not satisfied because
It seems it's a leap year problem that is being manifested..
As per test,
initDate Thu Feb 29 13:49:08 IST 2024 [ obtained by calendar.getTime();]
earliestDate Tue Feb 28 13:49:08 IST 2023 [obtained by calendar.add(Calendar.YEAR, -1);]
latestDate Wed Feb 28 13:49:08 IST 2024 [obtained by calendar.add(Calendar.YEAR, 1);]
Now, as per SpinnerDateModel constructor
earliestDate <= initDate condition is satisfied
but
latestDate >= initDate is not
so start <= value <= end condition fails
Not sure it anything can be done in Calendar class for this but fix is done in test taking leapyear into account so that we add a day if it's a leapyear when we consecutively do Calendar.add(YEAR, -1) and Calendar.add(YEAR,1) on leapyear date of 29Feb
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18054/head:pull/18054
$ git checkout pull/18054
Update a local copy of the PR:
$ git checkout pull/18054
$ git pull https://git.openjdk.org/jdk.git pull/18054/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18054
View PR using the GUI difftool:
$ git pr show -t 18054
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18054.diff
Webrev
Link to Webrev Comment