changeset 55979:badfa812b82a

8226785: MandatoryWarningHandler.java contains implementation of Objects.equals functionality Reviewed-by: jjg
author darcy
date Tue, 25 Jun 2019 18:46:51 -0700
parents 1e63cdb2b2ba
children 8e0ae3830fca
files src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java
diffstat 1 files changed, 4 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Tue Jun 25 18:20:21 2019 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Tue Jun 25 18:46:51 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
@@ -26,6 +26,7 @@
 package com.sun.tools.javac.util;
 
 import java.util.HashSet;
+import java.util.Objects;
 import java.util.Set;
 import javax.tools.JavaFileObject;
 
@@ -147,7 +148,7 @@
                 deferredDiagnosticArg = currentSource;
             } else if ((deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE
                         || deferredDiagnosticKind == DeferredDiagnosticKind.ADDITIONAL_IN_FILE)
-                       && !equal(deferredDiagnosticSource, currentSource)) {
+                       && !Objects.equals(deferredDiagnosticSource, currentSource)) {
                 // additional errors in more than one source file
                 deferredDiagnosticKind = DeferredDiagnosticKind.ADDITIONAL_IN_FILES;
                 deferredDiagnosticArg = null;
@@ -159,7 +160,7 @@
                 deferredDiagnosticSource = currentSource;
                 deferredDiagnosticArg = currentSource;
             }  else if (deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE &&
-                        !equal(deferredDiagnosticSource, currentSource)) {
+                        !Objects.equals(deferredDiagnosticSource, currentSource)) {
                 // warnings in multiple source files
                 deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILES;
                 deferredDiagnosticArg = null;
@@ -183,13 +184,6 @@
     }
 
     /**
-     * Check two objects, each possibly null, are either both null or are equal.
-     */
-    private static boolean equal(Object o1, Object o2) {
-        return ((o1 == null || o2 == null) ? (o1 == o2) : o1.equals(o2));
-    }
-
-    /**
      * The log to which to report warnings.
      */
     private Log log;