[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-compiler-dev
Subject:    Re: JDK 14 RFR of JDK-8226785: MandatoryWarningHandler.java contains implementation of Object.equals
From:       Jonathan Gibbons <jonathan.gibbons () oracle ! com>
Date:       2019-06-26 1:33:29
Message-ID: dc18fa25-8a0f-de22-5f80-9d3c376d9d3d () oracle ! com
[Download RAW message or body]

+1


On 06/25/2019 06:04 PM, Joe Darcy wrote:
> Hello,
>
> Noticed while doing some other work, the javac class 
> MandatoryWarningHandler.java contains a local copy of of the logic of 
> the two-argument Objects.equals method. As a refactoring, the library 
> code should be used instead.
>
> The method in MandatoryWarningHandler is named "equal" rather than 
> "equals" and escaped previous passes to replace independent 
> implementations of this logic (JDK-7041136).
>
> Patch below.
>
> Thanks,
>
> -Joe
>
> diff -r dd697048684f 
> src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java
> --- 
> a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java 
> Tue Jun 25 21:33:24 2019 +0000
> +++ 
> b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java 
> Tue Jun 25 18:02:43 2019 -0700
> @@ -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;
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic