Bug 473583 - AspectJ compiler throws IllegalStateException at org.aspectj.apache.bcel.generic.MethodGen.getMethod (MethodGen.java:699)
Summary: AspectJ compiler throws IllegalStateException at org.aspectj.apache.bcel.gene...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Build (show other bugs)
Version: 1.8.6   Edit
Hardware: PC Linux
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-26 06:38 EDT by C Clauson CLA
Modified: 2015-08-10 14:56 EDT (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 C Clauson CLA 2015-07-26 06:38:32 EDT
Converted a large, legacy Java project to and AspectJ project, attempted to build and received the following error:

java.lang.IllegalStateException
at org.aspectj.apache.bcel.generic.MethodGen.getMethod(MethodGen.java:699)
at org.aspectj.weaver.bcel.LazyMethodGen.getMethod(LazyMethodGen.java:491)
at org.aspectj.weaver.bcel.LazyClassGen.writeBack(LazyClassGen.java:515)
at org.aspectj.weaver.bcel.LazyClassGen.getJavaClassBytesIncludingReweavable(LazyClassGen.java:697)
at org.aspectj.weaver.bcel.BcelWeaver.getClassFilesFor(BcelWeaver.java:1440)
at org.aspect ... va/lang/String;Ljava/util/Map;Ljava/util/Map;[Lcom/orora/arcade/design/netlist/model/INetlistTerminal;Ljava/util/List;Ljava/util/Map;Ljava/util/Set;)V

Eclipse version: Luna SR2 (4.4.2)
I used the following link to install: http://download.eclipse.org/tools/ajdt/44/dev/update
Comment 1 C Clauson CLA 2015-07-26 16:07:37 EDT
Just to give some additional information the weaver plugin jar is:
org.aspectj.weaver_1.8.6.20150608154244.jar
Comment 2 Andrew Clement CLA 2015-08-07 17:45:27 EDT
When that exception is thrown it includes the underlying exception that triggered the failure - was there some more to that stack trace? it would be logged after the stack trace for the IllegalStateException. My only initial thought is that the method may be too big (sometimes advising it can blow the 64k byte code limit depending on the original method size and the amount of advice being applied to it).
Comment 3 C Clauson CLA 2015-08-08 02:28:52 EDT
This is a good point.  I glanced at the source code and noticed that when this exception is thrown, it includes the underlying exception that causes it.  However, there was no additional stack trace information printed.  I thought that the reason might be that I was using a version of the jar that was out of sync with the current source.

If this is true and you guys want to update the jar in the eclipse repository, I could update, try again, hopefully get a better stack trace.

The only AspectJ that is being applied is this:

*****************************************************************
import javax.swing.*;

aspect EdtRuleChecker {
    private boolean isStressChecking = true;
    
    public pointcut anySwingMethods(JComponent c):
         target(c) && call(* *(..));

    public pointcut threadSafeMethods():         
         call(* repaint(..)) || 
         call(* revalidate()) ||
         call(* invalidate()) ||
         call(* getListeners(..)) ||
         call(* add*Listener(..)) ||
         call(* remove*Listener(..));

    //calls of any JComponent method, including subclasses
    before(JComponent c): anySwingMethods(c) && 
                          !threadSafeMethods() &&
                          !within(EdtRuleChecker) {
     if(!SwingUtilities.isEventDispatchThread() &&
         (isStressChecking || c.isShowing())) 
     {
             System.err.println(thisJoinPoint.getSourceLocation());
             System.err.println(thisJoinPoint.getSignature());
             System.err.println();
      }
    }

    //calls of any JComponent constructor, including subclasses
    before(): call(JComponent+.new(..)) {
      if (isStressChecking && !SwingUtilities.isEventDispatchThread()) {
          System.err.println(thisJoinPoint.getSourceLocation());
          System.err.println(thisJoinPoint.getSignature() +
                                " *constructor*");
          System.err.println();
      }
    }
}
*****************************************************************

I copied from this site:
https://weblogs.java.net/blog/2006/02/16/debugging-swing-final-summary

Also, it's not clear which particular method is causing this error, so I can't comment on how large it is.

Thanks so much!
Comment 4 Andrew Clement CLA 2015-08-10 14:56:00 EDT
That code hasn't changed for a while so I don't think you could be picking up an old version. I note your stack trace also didn't include the text of the IllegalStateException message - I've seen this sometimes vary across JVMs. What JVM are you on, is there a more recent one to try it on?