Community
Participate
Working Groups
I found this problem at: http://stackoverflow.com/questions/27498660/aspectj-for-anotations-with-classes-not-working You need the following Spring JARs on your classpath: - spring-core-4.1.0.RELEASE.jar - spring-context-4.1.0.RELEASE.jar - spring-beans-4.1.0.RELEASE.jar Now create an AspectJ project in Eclipse (I used Luna 4.4.1 and AJDT 1.8.5.20141117171500). Add this one class (no aspect necessary): import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ConfigurationCondition; import org.springframework.context.annotation.ImportResource; import org.springframework.core.type.AnnotatedTypeMetadata; @Configuration @Conditional(ConditionalConfiguration.Condition.class) @ImportResource("/com/example/context-fragment.xml") public class ConditionalConfiguration { static class Condition implements ConfigurationCondition { @Override public ConfigurationPhase getConfigurationPhase() { return ConfigurationPhase.PARSE_CONFIGURATION; } @Override public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { // only load context-fragment.xml if the system property is defined return System.getProperty("com.example.context-fragment") != null; } } } It compiles just fine. Now remove ".class" from this annotation value: @Conditional(ConditionalConfiguration.Condition) This kills Ajc and yields: org.aspectj.weaver.BCException at org.aspectj.ajdt.internal.core.builder.AjState.recordClassFile(AjState.java:1519) at org.aspectj.ajdt.internal.core.builder.AjState.noteResult(AjState.java:1325) at org.aspectj.ajdt.internal.core.builder.AjBuildManager$3.acceptResult(AjBuildManager.java:1066) at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:426) at org.aspectj.ajdt.intern ... pkcs11.jar;C:\Program Files\Java\jre8\lib\ext\zipfs.jar;C:\Program Files\Java\eclipse\\plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar;
Smells like another manifestation of bug 377096, JDT seeing incorrect annotation values and producing broken class files.
I have recreated it in AJDT - so I suspect similar problem, just somewhere else in JDT that needs fixing.
Raised JDT bug 456960
*** Bug 455293 has been marked as a duplicate of this bug. ***