Bug 376351 - attribute problems with Java 7 compilation
Summary: attribute problems with Java 7 compilation
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P2 critical (vote)
Target Milestone: 1.7.0   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-09 15:13 EDT by Andrew Clement CLA
Modified: 2012-04-09 17:20 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2012-04-09 15:13:54 EDT
From the mailing list, this goes wrong:

***R.java***
public class R{ 
  public static void main(String[] args) {System.out.println(new R().getClass().getName());}
}

***R1.java***
public class R1 extends R {}

***RAj.aj***
public aspect RAj
{
    private ThreadLocal<Object> inAspect = new ThreadLocal<Object>();
    
    pointcut createR() : execution(R.new());
    Object around() : createR()
    {
        System.out.println("aspect:" + inAspect.get() + ":" + this);
        if (inAspect.get() != null)
        {
            return proceed();
        }
        else
        {
            inAspect.set(this);
            return new R1();
        }
    }
}


compile command:
/cygdrive/c/Program\ Files/Java/aspectj-1.6.12/bin/ajc.bat -source 1.7 -outxml -outjar araj.jar -classpath "aspectjrt.jar;." RAj.aj 

run:

/cygdrive/c/Program\ Files/Java/aspectj-1.6.12/bin/aj5.bat  -classpath ".;./araj.jar" R

errors:
Apr 06, 2012 1:37:40 PM org.aspectj.weaver.tools.Jdk14Trace error
SEVERE: register definition failed
java.lang.RuntimeException: Problem processing attributes in RAj
    at org.aspectj.weaver.bcel.BcelObjectType.ensureAspectJAttributesUnpacked(BcelObjectType.java:385)
Comment 1 Andrew Clement CLA 2012-04-09 16:48:26 EDT
this is caused by asm trying to be too clever for its own good and damaging the constant pool when it adds the stack map entries.  This leaves us with attributes that refer to constant pool entries that have 'moved'.
Comment 2 Andrew Clement CLA 2012-04-09 17:20:41 EDT
There is a way to turn off this asm behaviour by passing the classreader into the classwriter.  I've done this and the exception is fixed.