以下代码:
@Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.METHOD,ElementType.FIELD,ElementType.ANNOTATION_TYPE }) @Constraint(validatedBy = { MinTimeIntCoConstraintValidator.class,MinTimeIntCoListConstraintValidator.class,MinTimeDoubleCoConstraintValidator.class,MinTimeDoubleCoListConstraintValidator.class,}) @Documented public @interface MinTimeValueCo { int value(); String message() default "value does not match minimum requirements"; Class<?>[] groups() default { }; Class<? extends Payload>[] payload() default {}; }
在eclipse中编译但无法在sun / oracle编译器中编译:
> MinTimeValueCo.java:19: illegal start of expression > [javac] }) > [javac] ^ > [javac] 1 error
这是因为MinTimeDoubleCoListConstraintValidator.class之后的逗号.
当我删除逗号时它工作正常:
@Constraint(validatedBy = { MinTimeIntCoConstraintValidator.class,MinTimeDoubleCoListConstraintValidator.class })
我使用的是jdk 1.6.0.10.
你知道为什么这是非法的并且在eclipse中编译吗?