I have a question regarding the JLS 3rd edition, and the inference mechanism. It is stated in the section 15.12.2.7 that:
If F = U[], where the type U involves Tj, then if A is an array type V[], or a type variable with an upper bound that is an array type V[]
I tried to create a type variable with an array type upper bound, but this does not seem to be accepted by the compiler. Something like:
public class MyClass<T extends String []> {
}
My question is: is the JLS wrong in this fragment, or did I miss something ? The last part of the sentence seems unsatisfiable for me.
Thanks
From the details in the following bug:
https://bugs.openjdk.java.net/browse/JDK-6557960
The JLS is a bit incoherent, as it states in section 4.4:
Type variables have an optional bound, T & I 1 ... I n . The bound consists of either a type variable, or a class or interface type T
The type variable cannot have a bound that is an array type, which is contradictory with the part mentioned above in my question (from the section 15.12.2.7):
or a type variable with an upper bound that is an array type V[]
This part can simply be ignored as it will never be satisfiable.
Many thanks biziclop for the link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With