提交 93d8737c 编写于 作者: D darcy

7041251: Use j.u.Objects utility methods in langtools

Reviewed-by: jjg
上级 a6775058
/* /*
* Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2013, 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
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package com.sun.tools.javac.util; package com.sun.tools.javac.util;
import java.util.Objects;
/** A generic class for pairs. /** A generic class for pairs.
* *
* <p><b>This is NOT part of any supported API. * <p><b>This is NOT part of any supported API.
...@@ -46,15 +48,11 @@ public class Pair<A, B> { ...@@ -46,15 +48,11 @@ public class Pair<A, B> {
return "Pair[" + fst + "," + snd + "]"; return "Pair[" + fst + "," + snd + "]";
} }
private static boolean equals(Object x, Object y) {
return (x == null && y == null) || (x != null && x.equals(y));
}
public boolean equals(Object other) { public boolean equals(Object other) {
return return
other instanceof Pair<?,?> && other instanceof Pair<?,?> &&
equals(fst, ((Pair<?,?>)other).fst) && Objects.equals(fst, ((Pair<?,?>)other).fst) &&
equals(snd, ((Pair<?,?>)other).snd); Objects.equals(snd, ((Pair<?,?>)other).snd);
} }
public int hashCode() { public int hashCode() {
......
/* /*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2013, 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
...@@ -28,6 +28,7 @@ package javax.annotation.processing; ...@@ -28,6 +28,7 @@ package javax.annotation.processing;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.Collections; import java.util.Collections;
import java.util.Objects;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.lang.model.SourceVersion; import javax.lang.model.SourceVersion;
import javax.tools.Diagnostic; import javax.tools.Diagnostic;
...@@ -146,8 +147,7 @@ public abstract class AbstractProcessor implements Processor { ...@@ -146,8 +147,7 @@ public abstract class AbstractProcessor implements Processor {
public synchronized void init(ProcessingEnvironment processingEnv) { public synchronized void init(ProcessingEnvironment processingEnv) {
if (initialized) if (initialized)
throw new IllegalStateException("Cannot call init more than once."); throw new IllegalStateException("Cannot call init more than once.");
if (processingEnv == null) Objects.requireNonNull(processingEnv, "Tool provided null ProcessingEnvironment");
throw new NullPointerException("Tool provided null ProcessingEnvironment");
this.processingEnv = processingEnv; this.processingEnv = processingEnv;
initialized = true; initialized = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册