Explicit inference: the type of the variable with the upper bound, which is the type of the array

I have a question regarding the third edition of JLS and the output engine. Section 15.12.2.7 states that:

If F = U [], where the type U includes Tj, then if A is the type of the array V [], or a variable of the type with an upper bound, which is the type of the array V []

I tried to create a type variable with an upper bound on the array type, but this does not seem to be accepted by the compiler. Sort of:

public class MyClass<T extends String []> { } 

My question is: the wrong JLS in this snippet, or am I missing something? The last part of the sentence seems to me unsatisfactory.

thanks

+5
source share
1 answer

From the information in the following error:

https://bugs.openjdk.java.net/browse/JDK-6557960

JLS is slightly incoherent, as described in section 4.4:

Type variables have an optional boundary, T and i 1 ... i n. The bound consists of either a type variable or a class or T interface

A type variable cannot have a binding, which is an array type, which contradicts the part mentioned above in my question (from section 15.12.2.7):

or a type variable with an upper bound, which is an array type V []

This part can simply be ignored, as it will never be feasible.

Thanks a lot biziclop for the link

+2
source

Source: https://habr.com/ru/post/1236061/


All Articles