这可以由Eclipse编译,但不能由javac编译:
Set<ConstraintViolation<Object>> violations = new HashSet<>();
Set<ConstraintViolation<Class1>> validateClass1 = null;
violations.addAll((Set<? extends ConstraintViolation<Object>>) validateClass1);
javac说:
error: incompatible types: Set<ConstraintViolation<Class1>>
cannot be converted to Set<? extends ConstraintViolation<Object>>
生成的Eclipse代码是可执行的。