google / error-prone

Catch common Java mistakes as compile-time errors
https://errorprone.info
Apache License 2.0
6.82k stars 740 forks source link

Raw Class is considered mutable? #549

Closed ZacSweers closed 7 years ago

ZacSweers commented 7 years ago

I have a final Class instance field in an enum, and found that error-prone does not consider it Immutable. I can't quite wrap my head around as to why though, as I don't see any mutative APIs.

cushon commented 7 years ago

The check does consider Class<T> to be immutable:

enum E {
  ;
  final Class<?> clazz = E.class;
}

do you have a repro?

ZacSweers commented 7 years ago

Ahh interesting, I've found it. This is the repro case

enum E {
  ;
  final Class clazz = E.class;
}

Remove the wildcard