8037965: NullPointerException in TextLayout.getBaselineFromGraphic() for JTextComponents
Reviewed-by: prr, aivanov
This commit is contained in:
parent
d4d1fbc27a
commit
0402a288f3
src/java.desktop/share/classes/java/awt/font
test/jdk/javax/swing/JTextField
@ -2638,6 +2638,9 @@ public final class TextLayout implements Cloneable {
|
||||
|
||||
static byte getBaselineFromGraphic(GraphicAttribute graphic) {
|
||||
|
||||
if (graphic == null) {
|
||||
return (byte)GraphicAttribute.ROMAN_BASELINE;
|
||||
}
|
||||
byte alignment = (byte) graphic.getAlignment();
|
||||
|
||||
if (alignment == GraphicAttribute.BOTTOM_ALIGNMENT ||
|
||||
|
38
test/jdk/javax/swing/JTextField/SwingUnicodeTest.java
Normal file
38
test/jdk/javax/swing/JTextField/SwingUnicodeTest.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8037965
|
||||
* @summary Verifies NPE in TextLayout.getBaselineFromGraphic() for invalid
|
||||
* Unicode characters
|
||||
*/
|
||||
public class SwingUnicodeTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(() ->
|
||||
new JTextField(new StringBuilder().appendCodePoint(0xFFFF).
|
||||
appendCodePoint(0x10000).toString()));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user