Bug 419584 - [itd] [markers] Cannot directly invoke the abstract method hello() for the type HelloInterface
Summary: [itd] [markers] Cannot directly invoke the abstract method hello() for the ty...
Status: NEW
Alias: None
Product: AJDT
Classification: Tools
Component: UI (show other bugs)
Version: 2.1.2   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-16 08:52 EDT by nipun jawalkar CLA
Modified: 2016-01-05 05:54 EST (History)
1 user (show)

See Also:


Attachments
Eclipse project with sources (7.44 KB, application/zip)
2013-10-16 08:52 EDT, nipun jawalkar CLA
no flags Details
With bytecode generated both by eclipse ajdt plugin, and aspectj 1.7.3 (11.36 MB, application/zip)
2013-10-17 05:30 EDT, nipun jawalkar CLA
no flags Details
Screenshot of eclipse showing compile error (65.01 KB, image/png)
2013-10-17 06:38 EDT, nipun jawalkar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description nipun jawalkar CLA 2013-10-16 08:52:12 EDT
Created attachment 236541 [details]
Eclipse project with sources

Eclipse compiler issues an error when compiling attached sources. However, oracle's javac works fine with the aspectj 1.6x .

Bug 198120 is similar to this, and was fixed. But the issue reoccurs if an aspect is applied to the parent class, and includes an InterType Declaration.

I'm using eclipse 4.3sr1 for linux x64 with the AJDT plugin v2.2.3.e43x-RELEASE. This problem does *not* occur in eclipse 3.5sr2 with AJDT plugin v2.0.2.e35x-20100105-0900
Comment 1 Stephan Herrmann CLA 2013-10-16 12:12:20 EDT
To check I understand your situation correctly:
- you have an abstract method
- using an AspectJ intertype declaration an implementation is added
- the Java compiler should consume byte codes from AspectJ and be able
  to invoke the method added by AspectJ?

If so: does the attached project contain the class files produced / woven
by AspectJ?

If this is not your situation, can you reproduce the problem without AspectJ?
Comment 2 nipun jawalkar CLA 2013-10-16 17:29:33 EDT
(In reply to Stephan Herrmann from comment #1)
> To check I understand your situation correctly:
> - you have an abstract method
> - using an AspectJ intertype declaration an implementation is added
> - the Java compiler should consume byte codes from AspectJ and be able
>   to invoke the method added by AspectJ?
> 
> If so: does the attached project contain the class files produced / woven
> by AspectJ?
> 
> If this is not your situation, can you reproduce the problem without AspectJ?

I'll try to explain the best I can.

-I have an abstract method in a parent class (which is from an interface)
-A child class should be able to call super.method() without issue.
(so far it works fine)
-Now use an aspect which adds an IntertypeDeclaration to the parent class. This adds bytecode to the parent class.
-The bytecode added by the ITD causes the eclipse java compiler to fail. The compiler now thinks that the super.method() call in the child class is invalid, and issues an error.

If you take a look at Bug 198120, you'll see the same exact thing happening (but without the aspect). In the old bug, the compiler thought the super.method() call was invalid. But the fix solved this.

Now if you take that same testcase from 198120, and add an aspect with introduces an ITD in the parent, the same error happens again.

If you open the attached project in Eclipse 3.6+, you might see more easily. As it is given, eclipse will show a compilation error. If you disable the ITD in the aspect, the compilation error goes away. But Oracle's javac will compile both versions without any issues.
Comment 3 nipun jawalkar CLA 2013-10-16 17:32:28 EDT
(In reply to nipun jawalkar from comment #2)
> (In reply to Stephan Herrmann from comment #1)
> > To check I understand your situation correctly:
> > - you have an abstract method
> > - using an AspectJ intertype declaration an implementation is added
> > - the Java compiler should consume byte codes from AspectJ and be able
> >   to invoke the method added by AspectJ?
> > 
> > If so: does the attached project contain the class files produced / woven
> > by AspectJ?
> > 
> > If this is not your situation, can you reproduce the problem without AspectJ?
> 
> I'll try to explain the best I can.
> 
> -I have an abstract method in a parent class (which is from an interface)
> -A child class should be able to call super.method() without issue.
> (so far it works fine)
> -Now use an aspect which adds an IntertypeDeclaration to the parent class.
> This adds bytecode to the parent class.
> -The bytecode added by the ITD causes the eclipse java compiler to fail. The
> compiler now thinks that the super.method() call in the child class is
> invalid, and issues an error.
> 
> If you take a look at Bug 198120, you'll see the same exact thing happening
> (but without the aspect). In the old bug, the compiler thought the
> super.method() call was invalid. But the fix solved this.
> 
> Now if you take that same testcase from 198120, and add an aspect with
> introduces an ITD in the parent, the same error happens again.
> 
> If you open the attached project in Eclipse 3.6+, you might see more easily.
> As it is given, eclipse will show a compilation error. If you disable the
> ITD in the aspect, the compilation error goes away. But Oracle's javac will
> compile both versions without any issues.

Just to clarify, the ITD that is added to the parent class has nothing to do with the abstract method.
Comment 4 Stephan Herrmann CLA 2013-10-16 19:22:44 EDT
In order to fix this in JDT we must be able to reproduce without AspectJ.
If you explain what bytecodes the ITD adds then perhaps we can recreate
the same situtation in plain java.
If this cannot reproduced from plain Java maybe it's a regression in AspectJ,
meaning they might perhaps produce wrong/illegal bytecode?
Comment 5 nipun jawalkar CLA 2013-10-17 05:30:40 EDT
Created attachment 236581 [details]
With bytecode generated both by eclipse ajdt plugin, and aspectj 1.7.3
Comment 6 nipun jawalkar CLA 2013-10-17 06:00:31 EDT
(In reply to Stephan Herrmann from comment #4)
> In order to fix this in JDT we must be able to reproduce without AspectJ.
> If you explain what bytecodes the ITD adds then perhaps we can recreate
> the same situtation in plain java.
> If this cannot reproduced from plain Java maybe it's a regression in AspectJ,
> meaning they might perhaps produce wrong/illegal bytecode?

The bytecode generated by AspectJ is correct (I can load the classes and execute them with Oracle Jave 1.6). In fact, even in Eclipse, the main package browser shows no errors on the project or the ParentClass.java file (there is no red X). The "Problems" View doesn't show any errors either.

BUT, the editor shows a red circle with an X in the margin on the problematic line (where the child class calls super.hello() ). This leads me to believe that the bytecode generated by AspectJ is not at fault. The Eclipse gui that displays the source file, on the other hand, is unable to parse the bytecode of the parent class correctly, and shows a "compilation error".

Please take a look at the screenshot.
Comment 7 Stephan Herrmann CLA 2013-10-17 06:29:31 EDT
(In reply to nipun jawalkar from comment #5)
> Created attachment 236581 [details]
> With bytecode generated both by eclipse ajdt plugin, and aspectj 1.7.3

OK, I see nothing dangerous in there.

(In reply to nipun jawalkar from comment #6)
> BUT, the editor shows a red circle with an X in the margin on the
> problematic line (where the child class calls super.hello() ). This leads me
> to believe that the bytecode generated by AspectJ is not at fault. The
> Eclipse gui that displays the source file, on the other hand, is unable to
> parse the bytecode of the parent class correctly, and shows a "compilation
> error".

Do you have "JDT Weaving" enabled in the AJDT preferences?
AFAIK that's how the AJDT makes the IDE aware of ITDs.
I'm moving the bug to AJDT for comment... 

> Please take a look at the screenshot.

Where should I find the screenshot?
Comment 8 nipun jawalkar CLA 2013-10-17 06:38:56 EDT
Created attachment 236585 [details]
Screenshot of eclipse showing compile error
Comment 9 nipun jawalkar CLA 2013-10-17 06:42:10 EDT
(In reply to Stephan Herrmann from comment #7)
> (In reply to nipun jawalkar from comment #5)
> > Created attachment 236581 [details]
> > With bytecode generated both by eclipse ajdt plugin, and aspectj 1.7.3
> 
> OK, I see nothing dangerous in there.
> 
> (In reply to nipun jawalkar from comment #6)
> > BUT, the editor shows a red circle with an X in the margin on the
> > problematic line (where the child class calls super.hello() ). This leads me
> > to believe that the bytecode generated by AspectJ is not at fault. The
> > Eclipse gui that displays the source file, on the other hand, is unable to
> > parse the bytecode of the parent class correctly, and shows a "compilation
> > error".
> 
> Do you have "JDT Weaving" enabled in the AJDT preferences?
> AFAIK that's how the AJDT makes the IDE aware of ITDs.
> I'm moving the bug to AJDT for comment... 
> 
> > Please take a look at the screenshot.
> 
> Where should I find the screenshot?

Yes, JDT weaving is turned on.

The screenshot is attached to this report now. I missed it earlier.
Comment 10 nipun jawalkar CLA 2014-01-24 04:24:39 EST
I looked at this a little more, and it turns out the bug was introduced in AJDT v2.1.2, and is present in every subsequent version of the plugin.

If I use Eclipse 3.6.2 with AJDT plugin 2.1.1, the problem does not occur. But if I use Eclipse 3.6.2 with AJDT plugin 2.1.2, the bug is triggered.