Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » Inconsistent workspace state with declare parents
Inconsistent workspace state with declare parents [message #897700] Wed, 25 July 2012 06:56 Go to next message
Jaime Metcher is currently offline Jaime Metcher
Messages: 6
Registered: July 2012
Junior Member
I'm using declare parents to insert base classes at the top of a class hierarchy. I'm then getting inconsistent results as to whether the methods in those base classes are actually visible to subclasses a couple of layers down the inheritance tree. The end result is that for some, but not all, inserted parent classes:



    * I get an undefined method error decoration in the AJ editor wherever I call one of the new methods on a derived class
    * Verbose ajbuilder compiler messages show the same undefined method error
    * The Problems view shows the same undefined method error


However:

    * The expected inheritance hierarchy exists in the generated class files
    * The outline quick view (ctrl+O, ctrl+O) shows the method present as expected
    * I can highlight one of the problem method calls marked with the red squiggly, and navigate to the method definition using F3
    * Compilation in stages using ANT and iajc does work. I.e. I compile some of the sources to a jar, then compile the next set with that jar on the classpath.
    * iajc compilation in one stage shows the similar (but slightly different) errors to ajbuilder


From the little I know of Eclipse internals, it seems to me that the emitted class files and the java model are consistent with each other but different to the AST.

All this is too vague to troubleshoot, I know. However, right now my only reproducible test case is a 500MB set of sources and libraries, so what I'm after is any insight into possible underlying mechanisms so as to help me narrow things down to a manageable test case.

I've speculated that there's something about the project structure that is causing ajbuilder to incorrectly calculate dependencies and therefore get the compilation and weaving order wrong. To test this, I turned on verbose compiler messages and compared the output before and after inserting an empty inner class to a particular source file. The result was:


    * Every inner class in the project went from being woven before its enclosing class to being woven after the enclosing class
    * Another class which was a sibling in the class hierarchy to the one I edited was suddenly able to expose the new methods from the inserted base class i.e. one of the undefined method errors in its callers went away.


Other than that, the compile and weaving order was identical.



Re: Inconsistent workspace state with declare parents [message #898113 is a reply to message #897700] Wed, 25 July 2012 20:04 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew Eisenberg
Messages: 368
Registered: July 2009
Senior Member
Without a reproducible test case, there's not much help I can give. The fact that compiling everything with iajc in ant is giving an error suggests either a compiler bug or a problem with your code. The problem message inside of Eclipse should be the same as on the command line. And because both are failing, but in different ways, this is pointing to a compiler bug.

You'd be best off raising a aspectj bugzilla issue for this. Try to provide a simple way to reproduce. If you can't do that, at least sketch out the problem with some pseudo code.
Re: Inconsistent workspace state with declare parents [message #898138 is a reply to message #898113] Wed, 25 July 2012 21:30 Go to previous messageGo to next message
Jaime Metcher is currently offline Jaime Metcher
Messages: 6
Registered: July 2012
Junior Member
Thanks Andrew. I will try to find a simpler way to reproduce. Given that the error moves around with minor code changes I'm a bit stumped as to how to do that, so any suggestions from anyone would be much appreciated. Specifically, I'm wondering if the fact that the outline view and code navigation are showing the inserted parents is a clue that we can use?

[Updated on: Wed, 25 July 2012 21:33]

Report message to a moderator

Re: Inconsistent workspace state with declare parents [message #898166 is a reply to message #898138] Wed, 25 July 2012 23:36 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew Eisenberg
Messages: 368
Registered: July 2009
Senior Member
Well, you would only see the extra elements in the outline view if you are looking at the class file, not the source file.

I would guess that your problem has something to do with weaving everything from source vs weaving a pre-compiled jar. Is it the case that iajc is working when you first compile your java and then run the weaver over it?
Re: Inconsistent workspace state with declare parents [message #898862 is a reply to message #898166] Sat, 28 July 2012 11:45 Go to previous messageGo to next message
Jaime Metcher is currently offline Jaime Metcher
Messages: 6
Registered: July 2012
Junior Member
Definitely seeing extra elements in the outline view when looking at the source file. See the attached screenshot - you can see the red squiggly on the get(Integer) method call, alongside the outline view showing that method as being defined in a superclass. So it's pretty clear that the structure model is not consistent with the AST that's driving the compile error markings. Still, it's the compile errors that are the main problem so I mention that only in case it's of interest to you as perhaps representing an issue in the tooling.

What does seem to get rid of the compile errors is compiling the sources that make my original class hierarchy and then weaving in the "declare parents" aspects that add the new base classes. Then as a separate compilation step, compile the sources that use the new extended hierarchy. Now that I have a clearer view of how to do that I've managed to set up a pair of related Eclipse projects that work well. So I'm in a happier place at the moment.

So the remaining question is whether there is there a compiler issue. Assuming for the sake of argument that my code isn't just plain wrong, I guess it comes down to whether AspectJ should be able to work out all dependencies so as to compile any possible sources in one run, like javac does. Given the strange things we can do to code using AJ, that sounds like a hard ask to me. So I'm happy to just put this down to an intractable dependency graph.

Obviously you can't do much more without a test case, and in three days of trying I've been completely unable to find a simpler case than my full project. So I don't blame you if you just want to tune out at this point, but I'm also happy to send you my full project or try any other troubleshooting steps you want to suggest.
Re: Inconsistent workspace state with declare parents [message #898891 is a reply to message #898862] Sat, 28 July 2012 20:25 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew Eisenberg
Messages: 368
Registered: July 2009
Senior Member
I'm guessing that the error marker you are seeing exists only in the editor, but doesn't appear in the error log or in the package explorer. And I am also guessing that this problem has something to do with generics.

I don't think there is a compiler problem, but there might be a reconciling error (ie- the pseudo-compile that happens each time you type).

You can send me the project, but I may not be able to look at this for a few days. It would be much better if you could narrow this down. I think the problem has something to do with generic ITDs.
Re: Inconsistent workspace state with declare parents [message #912785 is a reply to message #898891] Fri, 14 September 2012 07:25 Go to previous message
Jaime Metcher is currently offline Jaime Metcher
Messages: 6
Registered: July 2012
Junior Member
Just got back to this after being too busy for a couple of months. The error definitely appears in the error log and the package explorer. But I agree that generic ITDs are probably implicated somehow. I'll keep trying to narrow it down.
Previous Topic:AspectJ: would it work in this case?
Next Topic:AJDT slooooow/hanging on clean rebuild
Goto Forum:
  


Current Time: Tue Oct 21 00:41:23 GMT 2014

Powered by FUDForum. Page generated in 0.01884 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software