Bug 92053 - @args causes a VerifyError: Unable to pop operand off an empty stack
Summary: @args causes a VerifyError: Unable to pop operand off an empty stack
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.5.0 M3   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-20 07:19 EDT by Michal Stochmialek CLA
Modified: 2005-04-21 03:35 EDT (History)
0 users

See Also:


Attachments
Test3.java (421 bytes, text/plain)
2005-04-20 07:26 EDT, Michal Stochmialek CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Stochmialek CLA 2005-04-20 07:19:59 EDT
I'm getting a VerifyError exception when I try to use @args
in following code:

------------------ Test3.java -------------------------
import java.lang.annotation.*;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@interface Ann {}

@Ann
class AClass{}

public class Test3 {
        void abc(AClass y) {}

        public static void main(String[] args) {
                new Test3().abc(new AClass());
        }
}


aspect Annotations {
        before(Ann ann) : call(* Test3.*(..)) && @args(ann) {
                System.out.println("Before: " + thisJoinPoint);
        }
}
----

On JRockIt5 jre and AspectJ 1.5.0M2 I get following result:
-----------
java.lang.VerifyError: (class: Test3, method: main signature:
([Ljava/lang/String;)V) Unable to pop operand off an empty stack
-----------

I'm getting similar error with sun jre and with older versions
of AspectJ5 (20050324155000 and from 10th feb).
Comment 1 Michal Stochmialek CLA 2005-04-20 07:26:33 EDT
Created attachment 20114 [details]
Test3.java
Comment 2 Andrew Clement CLA 2005-04-20 09:18:31 EDT
I'm currently looking into this one ...
Comment 3 Andrew Clement CLA 2005-04-20 10:43:23 EDT
Fixed - the bug is due to an 'optimization' in ArgsAnnotationPointcut.  Normally
all annotation binding consists of two generated bits of code:

1. a 'hasAnnotation()' call to check if the element has the annotation
2. a 'getAnnotation()' call to retrieve the annotation of the element

Obviously there are some cases where we can statically determine that an element
will always have the annotation at runtime, so we could skip generating part (1)
and just generate the retrieval code.  Unfortunately we were being a bit too
clever and skipped generating both bits of code in this case.  I've fixed it so
that we only skip the test now and always generate the retrieval code.

The exception that occurred indicated that when the advice ran the annotation
wasn't on the stack to be passed as a parameter...

Fix checked in, waiting on build before closing.
Comment 4 Andrew Clement CLA 2005-04-21 03:35:25 EDT
Fix available, see AspectJ downloads:

BUILD COMPLETE -  build.470
Date of build: 04/20/2005 16:29:28
Time to build: 142 minutes 34 seconds
Last changed: 04/20/2005 15:58:14