Bug 455608 - org.aspectj.weaver.BCException upon type error in code
Summary: org.aspectj.weaver.BCException upon type error in code
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.8.4   Edit
Hardware: PC Windows 8
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 455293 (view as bug list)
Depends on: 456960
Blocks:
  Show dependency tree
 
Reported: 2014-12-18 06:52 EST by Alexander Kriegisch CLA
Modified: 2015-01-07 20:10 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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. ***