File: TypeEquals.md

package info (click to toggle)
error-prone-java 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,076 kB
  • sloc: java: 171,398; xml: 1,459; sh: 34; makefile: 7
file content (11 lines) | stat: -rw-r--r-- 695 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
[`TypeMirror`](https://docs.oracle.com/en/java/javase/11/docs/api/java.compiler/javax/lang/model/type/TypeMirror.html)
doesn't override `Object.equals` and instances are not interned by javac, so
testing types for equality should be done with
[`Types#isSameType`](https://docs.oracle.com/en/java/javase/11/docs/api/java.compiler/javax/lang/model/util/Types.html#isSameType\(javax.lang.model.type.TypeMirror,javax.lang.model.type.TypeMirror\))
instead.

If you're implementing an Error Prone `BugChecker`, you can get a `Types`
instance from `VisitorState`.

If you're implementing `AnnotationProcessor`, you can get the `Types` instance
from `javax.annotation.processing.ProcessingEnvironment`.