-
Bug
-
Resolution: Fixed
-
P4
-
repo-valhalla
-
generic
-
generic
http://cr.openjdk.java.net/~dlsmith/jep8277163/jep8277163-20220519/specs/value-objects-jls.html says:
A class with neither the modifier identity nor value is implicitly an identity class if it ...
... is abstract and declares a nontrivial constructor (8.8) or an instance initializer (8.6). A constructor is considered "nontrivial" for the purpose of this rule if its level of access is more restrictive than the class (8.8.3), it declares formal parameters (8.8.1) or type parameters (8.8.4), it has a throws clause (8.8.5), or its body contains something other than an explicit constructor invocation of the form super(); (8.8.7).
Given
abstract class I0 {
public I0() { // trivial ctor.
super();
}
}
abstract class I1 {
private I1() {} // non-trivial, more restrictive access than the class.
}
abstract class I2 {
public I2(int x) {} // non-trivial ctor as it declares formal parameters.
}
abstract class I3 {
<T> I3() {} // non trivial as it declares type parameters.
}
abstract class I4 {
I4() throws Exception {} // non-trivial as it throws
}
abstract class I5 {
I5() {
System.out.println("");
} // non-trivial as it has a body.
}
javac marks I2 and I5 as having identity but fails in the case of I1, I3 and I4
A class with neither the modifier identity nor value is implicitly an identity class if it ...
... is abstract and declares a nontrivial constructor (8.8) or an instance initializer (8.6). A constructor is considered "nontrivial" for the purpose of this rule if its level of access is more restrictive than the class (8.8.3), it declares formal parameters (8.8.1) or type parameters (8.8.4), it has a throws clause (8.8.5), or its body contains something other than an explicit constructor invocation of the form super(); (8.8.7).
Given
abstract class I0 {
public I0() { // trivial ctor.
super();
}
}
abstract class I1 {
private I1() {} // non-trivial, more restrictive access than the class.
}
abstract class I2 {
public I2(int x) {} // non-trivial ctor as it declares formal parameters.
}
abstract class I3 {
<T> I3() {} // non trivial as it declares type parameters.
}
abstract class I4 {
I4() throws Exception {} // non-trivial as it throws
}
abstract class I5 {
I5() {
System.out.println("");
} // non-trivial as it has a body.
}
javac marks I2 and I5 as having identity but fails in the case of I1, I3 and I4