RFR: 8274505: Too weak variable type leads to unnecessary cast in java.desktop
Sergey Bylokhov
serb at openjdk.java.net
Wed Sep 29 11:17:48 UTC 2021
On Tue, 28 Sep 2021 08:02:12 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:
> Such casts are actually redundant, but they are inserted, because variable is declared with too weak type.
src/java.desktop/share/classes/javax/swing/JTree.java line 2046:
> 2044: // expensive!
> 2045: if(path != parent && value != null &&
> 2046: value.booleanValue() &&
here and bellow, unboxing is not needed as well?
src/java.desktop/share/classes/javax/swing/text/html/AccessibleHTML.java line 745:
> 743: JTextComponent comp = getTextComponent();
> 744: if (comp != null) {
> 745: if (comp.isEditable()) {
is it possible to merge two "if"? or even "return comp != null && comp.isEditable();"?
src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java line 4233:
> 4231: newAttrs = new SimpleAttributeSet();
> 4232: newAttrs.addAttribute
> 4233: (StyleConstants.NameAttribute,
Looks like this parameter can be moved one line above?
src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java line 857:
> 855: bounds = lBounds.getBounds();
> 856: bounds.add((rBounds instanceof Rectangle) ?
> 857: (Rectangle)rBounds : rBounds.getBounds());
You can eliminate the "lBounds.getBounds()" as well.
src/java.desktop/share/classes/javax/swing/text/rtf/RTFGenerator.java line 523:
> 521: }
> 522: if (newStyle != null) {
> 523: writeControlWord("ds", newStyle.intValue());
unboxing can be removed as well?
-------------
PR: https://git.openjdk.java.net/jdk/pull/5731
More information about the client-libs-dev
mailing list