Bug 455608

Summary: org.aspectj.weaver.BCException upon type error in code
Product: [Tools] AspectJ Reporter: Alexander Kriegisch <Alexander>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: aclement, afattahi
Version: 1.8.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows 8   
Whiteboard:
Bug Depends on: 456960    
Bug Blocks:    

Description Alexander Kriegisch CLA 2014-12-18 06:52:00 EST
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;
Comment 1 Andrew Clement CLA 2015-01-05 18:33:23 EST
Smells like another manifestation of bug 377096, JDT seeing incorrect annotation values and producing broken class files.
Comment 2 Andrew Clement CLA 2015-01-05 19:53:43 EST
I have recreated it in AJDT - so I suspect similar problem, just somewhere else in JDT that needs fixing.
Comment 3 Andrew Clement CLA 2015-01-07 14:19:56 EST
Raised JDT bug 456960
Comment 4 Andrew Clement CLA 2015-01-07 20:10:35 EST
*** Bug 455293 has been marked as a duplicate of this bug. ***