How does the Java compiler choose the runtime type for a parameterized type with multiple bounds?
问题 I would like to understand better what happens when the Java compiler encounters a call to a method like the one below. <T extends AutoCloseable & Cloneable> void printType(T... args) { System.out.println(args.getClass().getComponentType().getSimpleName()); } // printType() prints "AutoCloseable" It is clear to me that there is no type <T extends AutoCloseable & Cloneable> at runtime, so the compiler makes the least wrong thing it can do and creates an array with the type of one of the two