Summary: | ITD on inner class: missing accessor method | ||
---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Oege de Moor <oege> |
Component: | Compiler | Assignee: | aspectj inbox <aspectj-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | normal | ||
Priority: | P5 | CC: | aclement, piveta |
Version: | DEVELOPMENT | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Linux | ||
Whiteboard: |
Description
Oege de Moor
2004-09-14 07:05:30 EDT
investigate for M4 What a realistic program ;) Here's a shorter version that still fails: class A { int x = 1; class B { } B b = new B(); } aspect Aspect { int A.B.foo() { class C { int bar() { return A.this.x;} } return new C().bar(); } } public class MissingAccessor { public static void main(String[] args) { A a = new A(); System.out.println(a.b.foo()); } } it may not print 1024 but it fails with the same error. Given that the reference to the access$0 method is generated OK, my suspicion was that it was a type order processing thing, and indeed, if you move 'A' to after the aspect, then it runs fine: aspect Aspect { int A.B.foo() { class C { int bar() { return A.this.x;} } return new C().bar(); } } class A { int x = 1; class B { } B b = new B(); } public class MissingAccessor { public static void main(String[] args) { A a = new A(); System.out.println(a.b.foo()); } } now, what on earth we can do about that, hmmmmmmmmm putting on my TODO list, testcase added to CVS. moving to 1.5.1 - not because it's not important, but because it's very seldom seen in the wild and we need to close out the release. (In reply to comment #2) I don't know it if might help, but I tried to narrow the example down to a single unit: aspect Aspect { class B {} int B.foo() { class C { int bar() { return Aspect.this.hashCode(); } } return new C().bar(); } public static void main(String[] args) { System.out.println(aspectOf().new B().foo()); } } The exception raised is almost the same: ---------------------------------------------------------------------- Exception in thread "main" java.lang.NoSuchMethodError: Aspect$B.access$0(LAspect$B;)LAspect; at Aspect$1C.bar(Aspect.aj:5) at Aspect.ajc$interMethod$Aspect$Aspect$B$foo(Aspect.aj:7) at Aspect$B.ajc$interMethodDispatch2$$foo(Aspect.aj:1) at Aspect.ajc$interMethodDispatch1$Aspect$Aspect$B$foo(Aspect.aj) at Aspect.main(Aspect.aj:10) ---------------------------------------------------------------------- Note that (in line 3 of exception) The mangled name itmd is 'Aspect.ajc$interMethod$Aspect$Aspect$B$foo'. If the line: return Aspect.this.hashCode(); is changed to: return this.hashCode(); the code works (whatever this actually means...). that possibly helps - thanks. I think I know what the fix is but its a large implementation cost when there are simple workarounds... basically the compiler doesn't get the time to add the necessary accessors so the weaver would have to do it. |