Bug 374325 - AJC fails with: Dont call getValueString() on a non STRING ElementValue
Summary: AJC fails with: Dont call getValueString() on a non STRING ElementValue
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-14 19:10 EDT by Steve Ash CLA
Modified: 2012-03-15 14:53 EDT (History)
1 user (show)

See Also:


Attachments
sample eclipse AJDT project showing the problem (17.50 KB, application/x-zip-compressed)
2012-03-14 19:11 EDT, Steve Ash CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Ash CLA 2012-03-14 19:10:13 EDT
Build Identifier: 

I'm trying to build two aspects such that one or the other will be woven depending on a boolean value in an attribute.  So if logArgs is true then it will weave TraceAspect and if logArgs is false it will weave TraceWithoutArgsAspect.

@Trace(logArgs=true)
public void someMethod(String someArg) {
   ...
}

And I have the aspects setup like so:

public abstract aspect AbstractTraceAspect {

    abstract pointcut MethodsToLog();
    
    pointcut MethodsMarkedTraceAndLevel(TraceLevel level) : 
        MethodsToLog() && @annotation(Trace(level));

}

public aspect TraceWithoutArgsAspect extends AbstractTraceAspect {

    pointcut MethodsToLog() : execution(@Trace(logArgs=false) * *.*(..));

    before(TraceLevel level) : MethodsMarkedTraceAndLevel(level) {
       ...
    }
    ...
}

Note that my annotation definition is like:

public @interface Trace {
    TraceLevel value() default TraceLevel.INFO;
    boolean logArgs() default true;
}
    
Everything works wonderfully with AJDT -- everything compiles all of my unit tests work perfectly.  The correct aspect is woven and the behaviors work as expected.

When I try to do a maven build, it blows up in the compiler producing the dump which I have attached.

Here is the beginning of the stack trace from the compiler (for future googlers):

[ERROR] -- (RuntimeException) Dont call getValueString() on a non STRING ElementValue
[ERROR] Dont call getValueString() on a non STRING ElementValue
[ERROR] java.lang.RuntimeException: Dont call getValueString() on a non STRING ElementValue
[ERROR] at org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue.getValueString(SimpleElementValue.java:204)
[ERROR] at org.aspectj.weaver.bcel.AnnotationAccessFieldVar.appendLoadAndConvert(AnnotationAccessFieldVar.java:79)
[ERROR] at org.aspectj.weaver.bcel.BcelAdvice.getAdviceArgSetup(BcelAdvice.java:605)
[ERROR] at org.aspectj.weaver.bcel.BcelAdvice.getAdviceInstructions(BcelAdvice.java:476)
[ERROR] at org.aspectj.weaver.bcel.BcelShadow.weaveBefore(BcelShadow.java:1667)
[ERROR] at org.aspectj.weaver.bcel.BcelAdvice.implementOn(BcelAdvice.java:316)
[ERROR] at org.aspectj.weaver.Shadow.implementMungers(Shadow.java:630)
[ERROR] at org.aspectj.weaver.Shadow.implement(Shadow.java:544)
[ERROR] at org.aspectj.weaver.bcel.BcelClassWeaver.implement(BcelClassWeaver.java:3147)

I have tried this with the 1.6.11 release, the 1.6.12 release, and the 1.7.0 snapshot build from the spring repo and all fail with this.  

Here are my AJDT version numbers:

   AJDT version: 2.2.0.e37x-20120302-1100
   AspectJ Compiler version: DEVELOPMENT


Any clues as to what going wrong here?

#

I have attached a sample project that recreates the issue.  The exact aspect name and annotation name are different, but its the same problem.  If you clean this and let AJDT build it then the JUnit test runs fine with expected aspect advice being woven in.  If you try to run this through maven command line then AJC blows up with the stack trace above.

Also in the zip are the AJC dumps showing all of the details.

Reproducible: Always

Steps to Reproduce:
1. Import the attached project.  
2. Right click on Run As -> Maven Build... run with clean package and it will fail in compilation
3. Run Junit test inside of eclipse (compiled by AJDT) and it passes with advice behavior as expected.
Comment 1 Steve Ash CLA 2012-03-14 19:11:33 EDT
Created attachment 212692 [details]
sample eclipse AJDT project showing the problem
Comment 2 Andrew Clement CLA 2012-03-15 14:53:57 EDT
How were you telling it to try with 1.6.12?  I just added this to your pom:

                 <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjrt</artifactId>
                        <version>1.6.12</version>
                    </dependency>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>1.6.12</version>
                    </dependency>
                </dependencies>

In the plugin section for the aspectj maven plugin, and it started working for me (mvn clean test).  If I remove it again, it goes back to failing with an ajcore?

I've only been trying on the command line though, let me try that change in eclipse.