8226785: MandatoryWarningHandler.java contains implementation of Objects.equals functionality

Reviewed-by: jjg
This commit is contained in:
Joe Darcy 2019-06-25 18:46:51 -07:00
parent c9ca2c7a90
commit 3d4d89b2ae

View File

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
package com.sun.tools.javac.util; package com.sun.tools.javac.util;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import javax.tools.JavaFileObject; import javax.tools.JavaFileObject;
@ -147,7 +148,7 @@ public class MandatoryWarningHandler {
deferredDiagnosticArg = currentSource; deferredDiagnosticArg = currentSource;
} else if ((deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE } else if ((deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE
|| deferredDiagnosticKind == DeferredDiagnosticKind.ADDITIONAL_IN_FILE) || deferredDiagnosticKind == DeferredDiagnosticKind.ADDITIONAL_IN_FILE)
&& !equal(deferredDiagnosticSource, currentSource)) { && !Objects.equals(deferredDiagnosticSource, currentSource)) {
// additional errors in more than one source file // additional errors in more than one source file
deferredDiagnosticKind = DeferredDiagnosticKind.ADDITIONAL_IN_FILES; deferredDiagnosticKind = DeferredDiagnosticKind.ADDITIONAL_IN_FILES;
deferredDiagnosticArg = null; deferredDiagnosticArg = null;
@ -159,7 +160,7 @@ public class MandatoryWarningHandler {
deferredDiagnosticSource = currentSource; deferredDiagnosticSource = currentSource;
deferredDiagnosticArg = currentSource; deferredDiagnosticArg = currentSource;
} else if (deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE && } else if (deferredDiagnosticKind == DeferredDiagnosticKind.IN_FILE &&
!equal(deferredDiagnosticSource, currentSource)) { !Objects.equals(deferredDiagnosticSource, currentSource)) {
// warnings in multiple source files // warnings in multiple source files
deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILES; deferredDiagnosticKind = DeferredDiagnosticKind.IN_FILES;
deferredDiagnosticArg = null; deferredDiagnosticArg = null;
@ -182,13 +183,6 @@ public class MandatoryWarningHandler {
} }
} }
/**
* 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. * The log to which to report warnings.
*/ */