Main method with generic parameter; why does it work?

This is because a type parameter has a bound:

<T extends String>                  =>  String

<T extends String & AutoCloseable>  =>  String & AutoCloseable

And the bytecode after erasure is the same as for the regular main declaration in both cases:

public static main([Ljava/lang/String;)V

JLS ยง4.4. Type Variables:

The order of types in a bound is only significant in that the erasure
of a type variable is determined by the first type in its bound
, and
that a class type or type variable may only appear in the first
position.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)