You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running with -Xep:ConstructorInvokesOverridable:ERROR yields:
Container.java:11: error: [ConstructorInvokesOverridable] Constructors should not invoke overridable methods.
private final Class<?> type = myType();
^
(see http://errorprone.info/bugpattern/ConstructorInvokesOverridable)
Container.java:19: error: [ConstructorInvokesOverridable] Constructors should not invoke overridable methods.
myType();
^
(see http://errorprone.info/bugpattern/ConstructorInvokesOverridable)
2 errors
As you can see, no error is emitted for Test1. But for the other two classes @SuppressWarnings("ConstructorInvokesOverridable") has no effect.
For classes with many fields or much code in initializer blocks/constructors, it'd be nice if ConstructorInvokesOverridable could be suppressed at a scope smaller than the whole class. (Refactoring the affected classes would be even better, of course, but alas.)
The text was updated successfully, but these errors were encountered:
Do not match methods of anonymous classes. Those methods can't be
overriden because those classes can't be extended.
Do not match methods of certain enum classes. It is not possible to
override the methods of an enum class except in the (anonymous) class
bodies of its enum constants. If all the enum constants lack class
bodies, then the enum class's methods can't be overridden.
Fix cases where the bug pattern would become confused about the receiver
of unqualified or this-qualified method invocations, and where it would
wrongly conclude that the method belonged to the instance under
construction and issue a warning.
Support @SuppressWarnings("ConstructorInvokesOverridable") on more
elements. Fixesgoogle#656.
Consider the following code:
Running with
-Xep:ConstructorInvokesOverridable:ERROR
yields:As you can see, no error is emitted for
Test1
. But for the other two classes@SuppressWarnings("ConstructorInvokesOverridable")
has no effect.For classes with many fields or much code in initializer blocks/constructors, it'd be nice if
ConstructorInvokesOverridable
could be suppressed at a scope smaller than the whole class. (Refactoring the affected classes would be even better, of course, but alas.)The text was updated successfully, but these errors were encountered: