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
{{{
public class MutableSupertype {
public int mutableField;
public MutableSupertype(int num) {
this.mutableField = num;
}
}
final class ImmutableSubtypeOfMutableSupertype extends MutableSupertype {
private final int immutableField = 2;
public ImmutableSubtypeOfMutableSupertype(int immutableField) {
super(immutableField);
}
}
}}}
The class ImmutableSubtypeOfMutableSupertype will be reported as definitely
immutable. This is incorrect because the mutability of MutableSupertype is
inherited, ie the value for mutableField can be changed in instances of
the subclass.
The mutability status of the superclass should be inherited.
Original author: Grundlefleck@gmail.com (December 23, 2009 00:38:41)
Given the following classes:
{{{
public class MutableSupertype {
public int mutableField;
}
final class ImmutableSubtypeOfMutableSupertype extends MutableSupertype {
private final int immutableField = 2;
public ImmutableSubtypeOfMutableSupertype(int immutableField) {
super(immutableField);
}
}
}}}
The class ImmutableSubtypeOfMutableSupertype will be reported as definitely
immutable. This is incorrect because the mutability of MutableSupertype is
inherited, ie the value for
mutableField
can be changed in instances ofthe subclass.
The mutability status of the superclass should be inherited.
Original issue: http://code.google.com/p/mutability-detector/issues/detail?id=4
The text was updated successfully, but these errors were encountered: