Community
Participate
Working Groups
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
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?
(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.
(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.
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?
Created attachment 236581 [details] With bytecode generated both by eclipse ajdt plugin, and aspectj 1.7.3
(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.
(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?
Created attachment 236585 [details] Screenshot of eclipse showing compile error
(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.
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.