Annotation processor fails in Eclipse when evaluating custom constraints not defined in
the current project
-----------------------------------------------------------------------------------------------------------
Key: HV-293
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-293
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.1.0-Beta-1
Reporter: Gunnar Morling
Assignee: Hardy Ferentschik
In certain situations the AP fails when being integrated in Eclipse with the following
exception:
java.lang.AssertionError: Class org.hibernate.validator.constraints.impl.LengthValidator
specified in @Constraint.validatedBy doesn't implement ConstraintValidator.
at
org.hibernate.validator.ap.util.ConstraintHelper.getConstraintValidatorSuperType(ConstraintHelper.java:497)
at
org.hibernate.validator.ap.util.ConstraintHelper.getSupportedType(ConstraintHelper.java:426)
at
org.hibernate.validator.ap.util.ConstraintHelper.getSupportedTypes(ConstraintHelper.java:402)
at
org.hibernate.validator.ap.util.ConstraintHelper.checkCustomConstraint(ConstraintHelper.java:356)
at
org.hibernate.validator.ap.util.ConstraintHelper.checkConstraint(ConstraintHelper.java:295)
at
org.hibernate.validator.ap.ConstraintAnnotationVisitor.checkConstraintAtField(ConstraintAnnotationVisitor.java:290)
at
org.hibernate.validator.ap.ConstraintAnnotationVisitor.visitVariableAsField(ConstraintAnnotationVisitor.java:174)
at
org.hibernate.validator.ap.ConstraintAnnotationVisitor.visitVariableAsField(ConstraintAnnotationVisitor.java:45)
at javax.lang.model.util.ElementKindVisitor6.visitVariable(ElementKindVisitor6.java:199)
at
org.eclipse.jdt.internal.compiler.apt.model.VariableElementImpl.accept(VariableElementImpl.java:55)
at
org.hibernate.validator.ap.ConstraintValidationProcessor.process(ConstraintValidationProcessor.java:84)
at
org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:139)
at
org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:121)
at
org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159)
at
org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:134)
at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:810)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:364)
at
org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:321)
at
org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:301)
at
org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:134)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:265)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:193)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
This happens, if the AP examines a constraint annotation, which is not defined in the
currently built project itself, but is imported from some other JAR (e.g. @Length from
HV):
public class TestModel {
@Length
private String test;
}
The problem occurs, regardless whether the JAR containing the constraint is on the AP
classpath or not.
The AP works as expected when running on javac.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira