-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8330462: StringIndexOutOfBoundException when typing anything into Tex…
…tField Reviewed-by: angorya, kcr, arapte
- Loading branch information
1 parent
35880ce
commit d3da033
Showing
5 changed files
with
147 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
modules/javafx.graphics/src/shims/java/com/sun/glass/ui/win/WinTextRangeProviderShim.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
package com.sun.glass.ui.win; | ||
|
||
/** | ||
* Provides access to the {@link WinTextRangeProvider} class by making its | ||
* package-private fields and methods public for test cases in | ||
* {@link test.com.sun.glass.ui.win.WinTextRangeProviderTest WinTextRangeProviderTest}. | ||
*/ | ||
public class WinTextRangeProviderShim { | ||
public static int getEndIndex(int start, int length, int maxEndIndex) { | ||
return WinTextRangeProvider.getEndIndex(start, length, maxEndIndex); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
tests/system/src/test/java/test/com/sun/glass/ui/win/WinTextRangeProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Oracle designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Oracle in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
package test.com.sun.glass.ui.win; | ||
|
||
import com.sun.javafx.PlatformUtil; | ||
import com.sun.glass.ui.win.WinTextRangeProviderShim; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.stream.Stream; | ||
|
||
import test.util.Util; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assumptions.assumeTrue; | ||
|
||
public class WinTextRangeProviderTest { | ||
|
||
private static final CountDownLatch startupLatch = new CountDownLatch(1); | ||
|
||
@BeforeAll | ||
static void initFX() throws Exception { | ||
assumeTrue(PlatformUtil.isWindows()); | ||
Util.startup(startupLatch, () -> startupLatch.countDown()); | ||
} | ||
|
||
@AfterAll | ||
static void shutdown() { | ||
assumeTrue(PlatformUtil.isWindows()); | ||
Util.shutdown(); | ||
} | ||
|
||
static Stream<Arguments> getEndIndexParameters() { | ||
return Stream.of( | ||
Arguments.of(1, 0, 1, 2), | ||
Arguments.of(1, 0, 2, 1), | ||
Arguments.of(55, 50, 10, 55), | ||
Arguments.of(60, 50, 10, Integer.MAX_VALUE), | ||
Arguments.of(1, 0, Integer.MAX_VALUE, 1), | ||
Arguments.of(50, 50, Integer.MAX_VALUE, 50), | ||
Arguments.of(Integer.MAX_VALUE, 0, Integer.MAX_VALUE, Integer.MAX_VALUE), | ||
Arguments.of(60, 50, -1, 60), | ||
Arguments.of(60, 50, Integer.MIN_VALUE, 60) | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("getEndIndexParameters") | ||
public void testGetEndIndex(Integer expected, Integer startIndex, Integer length, Integer maxEndIndex) { | ||
assumeTrue(PlatformUtil.isWindows()); | ||
assertEquals(expected, WinTextRangeProviderShim.getEndIndex(startIndex, length, maxEndIndex)); | ||
} | ||
} |
d3da033
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.
Review
Issues
d3da033
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.
/backport jfx22u
d3da033
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.
@arapte Could not automatically backport
d3da033a
to openjdk/jfx22u due to conflicts in the following files:Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jfx22u. Note: these commands are just some suggestions and you can use other equivalent commands you know.
Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jfx22u with the title
Backport d3da033a2dd5c287733545935242a8d1f71c0554
.Below you can find a suggestion for the pull request body:
d3da033
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.
/backport jfx21u
d3da033
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.
@jperedadnr Could not automatically backport
d3da033a
to openjdk/jfx21u due to conflicts in the following files:Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jfx21u. Note: these commands are just some suggestions and you can use other equivalent commands you know.
Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jfx21u with the title
Backport d3da033a2dd5c287733545935242a8d1f71c0554
.Below you can find a suggestion for the pull request body: