8274806: Simplify equals() call on nullable variable and a constant in java.desktop

Reviewed-by: serb, pbansal
This commit is contained in:
Andrey Turbanov 2021-10-09 00:46:20 +00:00 committed by Sergey Bylokhov
parent 9c431dd168
commit f640c7aaa8
11 changed files with 16 additions and 17 deletions
src/java.desktop
macosx/classes/sun/lwawt/macosx
share/classes
unix/classes/sun
windows/classes/sun/awt/windows

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2021, 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
@ -55,7 +55,7 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer {
private boolean isSeparator() {
String label = ((MenuItem)getTarget()).getLabel();
return (label != null && label.equals("-"));
return "-".equals(label);
}
@Override

@ -417,11 +417,11 @@ public class Window extends Container implements Accessible {
@SuppressWarnings("removal")
String s = java.security.AccessController.doPrivileged(
new GetPropertyAction("java.awt.syncLWRequests"));
systemSyncLWRequests = (s != null && s.equals("true"));
systemSyncLWRequests = "true".equals(s);
@SuppressWarnings("removal")
String s2 = java.security.AccessController.doPrivileged(
new GetPropertyAction("java.awt.Window.locationByPlatform"));
locationByPlatformProp = (s2 != null && s2.equals("true"));
locationByPlatformProp = "true".equals(s2);
}
/**

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@ -328,9 +328,9 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab
Window window = SwingUtilities.getWindowAncestor(f);
if (window != null && !window.isOpaque()) {
dragMode = DEFAULT_DRAG_MODE;
} else if (mode != null && mode.equals("outline")) {
} else if ("outline".equals(mode)) {
dragMode = OUTLINE_DRAG_MODE;
} else if (mode != null && mode.equals("faster")
} else if ("faster".equals(mode)
&& f instanceof JInternalFrame
&& ((JInternalFrame)f).isOpaque() &&
(parent == null || parent.isOpaque())) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@ -205,7 +205,7 @@ public class JLayeredPane extends JComponent implements Accessible {
(layer = (Integer)((JComponent)c).
getClientProperty(LAYER_PROPERTY)) != null))
{
if(layer != null && layer.equals(FRAME_CONTENT_LAYER))
if (FRAME_CONTENT_LAYER.equals(layer))
continue;
layeredComponentFound = true;
break;

@ -824,7 +824,7 @@ class UnixFileSystemView extends FileSystemView {
public boolean isComputerNode(File dir) {
if (dir != null) {
String parent = dir.getParent();
if (parent != null && parent.equals("/net")) {
if ("/net".equals(parent)) {
return true;
}
}

@ -1326,7 +1326,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
} else if (kind == HTML.Tag.IMPLIED) {
String ws = (String) elem.getAttributes().getAttribute(
CSS.Attribute.WHITE_SPACE);
if ((ws != null) && ws.equals("pre")) {
if ("pre".equals(ws)) {
return new LineView(elem);
}
return new javax.swing.text.html.ParagraphView(elem);

@ -37,7 +37,6 @@ import sun.java2d.loops.SurfaceType;
import sun.java2d.loops.Blit;
import sun.java2d.loops.BlitBg;
import sun.awt.image.SurfaceManager;
import sun.awt.image.SurfaceManager.FlushableCacheData;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
@ -74,7 +73,7 @@ public abstract class SurfaceDataProxy
@SuppressWarnings("removal")
String manimg = AccessController.doPrivileged(
new GetPropertyAction("sun.java2d.managedimages"));
if (manimg != null && manimg.equals("false")) {
if ("false".equals(manimg)) {
cachingAllowed = false;
System.out.println("Disabling managed images");
}

@ -1547,7 +1547,7 @@ public abstract class RasterPrinterJob extends PrinterJob {
* PrintRequestAttributeSet while calling print(attributes)
*/
JobSheets js = (JobSheets)psvc.getDefaultAttributeValue(JobSheets.class);
if (js != null && js.equals(JobSheets.NONE)) {
if (JobSheets.NONE.equals(js)) {
noJobSheet = true;
}

@ -48,7 +48,7 @@ final class XTaskbarPeer implements TaskbarPeer {
String de = AccessController.doPrivileged(
(PrivilegedAction<String>) ()
-> System.getenv("XDG_CURRENT_DESKTOP"));
isUnity = de != null && de.equals("Unity");
isUnity = "Unity".equals(de);
}
private static void initWithLock() {

@ -128,7 +128,7 @@ public class UnixPrintJob implements CancelablePrintJob {
mDestType = UnixPrintJob.DESTPRINTER;
JobSheets js = (JobSheets)(service.
getDefaultAttributeValue(JobSheets.class));
if (js != null && js.equals(JobSheets.NONE)) {
if (JobSheets.NONE.equals(js)) {
mNoJobSheet = true;
}
}

@ -268,7 +268,7 @@ final class WDesktopProperties {
Boolean smoothingOn = (Boolean)map.get("win.text.fontSmoothingOn");
if (smoothingOn != null && smoothingOn.equals(Boolean.TRUE)) {
if (Boolean.TRUE.equals(smoothingOn)) {
Integer typeID = (Integer)map.get("win.text.fontSmoothingType");
/* "1" is GASP/Standard but we'll also use that if the return
* value is anything other than "2" for LCD.