Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8274806: Simplify equals() call on nullable variable and a constant i…
…n java.desktop

Reviewed-by: serb, pbansal
  • Loading branch information
turbanoff authored and mrserb committed Oct 9, 2021
1 parent 9c431dd commit f640c7a
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 17 deletions.
@@ -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
Expand Down Expand Up @@ -55,7 +55,7 @@ protected void initialize(MenuItem target) {

private boolean isSeparator() {
String label = ((MenuItem)getTarget()).getLabel();
return (label != null && label.equals("-"));
return "-".equals(label);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/java.desktop/share/classes/java/awt/Window.java
Expand Up @@ -417,11 +417,11 @@ public static enum Type {
@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);
}

/**
Expand Down
@@ -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
Expand Down Expand Up @@ -328,9 +328,9 @@ private void setupDragMode(JComponent f) {
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())) {
Expand Down
4 changes: 2 additions & 2 deletions src/java.desktop/share/classes/javax/swing/JLayeredPane.java
@@ -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
Expand Down Expand Up @@ -205,7 +205,7 @@ private void validateOptimizedDrawing() {
(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;
Expand Down
Expand Up @@ -824,7 +824,7 @@ public boolean isFloppyDrive(File dir) {
public boolean isComputerNode(File dir) {
if (dir != null) {
String parent = dir.getParent();
if (parent != null && parent.equals("/net")) {
if ("/net".equals(parent)) {
return true;
}
}
Expand Down
Expand Up @@ -1326,7 +1326,7 @@ public View create(Element elem) {
} 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);
Expand Down
Expand Up @@ -37,7 +37,6 @@
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;
Expand Down Expand Up @@ -74,7 +73,7 @@
@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");
}
Expand Down
Expand Up @@ -1547,7 +1547,7 @@ public void print(PrintRequestAttributeSet attributes)
* 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;
}

Expand Down
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/java.desktop/unix/classes/sun/print/UnixPrintJob.java
Expand Up @@ -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;
}
}
Expand Down
Expand Up @@ -268,7 +268,7 @@ synchronized RenderingHints getDesktopAAHints() {

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.
Expand Down

1 comment on commit f640c7a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.