Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ajdt-dev] AJDT and ITDs

Hi Andrew,
thanks again for taking the time to read and reply.

In fact, while testing and debugging, I've noticed that if I write the ITD (to a binary class contained in the in path) in the source project itself, and then consume it from the same source project, it still fails content assist and reconciling.

Using completely weaved jars would solve. The problem is that due to the highly dynamic composition I'm trying to achieve, it would have to weave all jars on the in path with all jars on the aspect path. This takes on an average project about 5/8 minutes, and has to be done again every time the composition change.

The solution you are talking about in the longer term would be THE solution (is this bug 265029 ?). It would also solve the problem of writing an advice or an ITD that weaves a class in a jar, and have proper Xlint messages without having to actually unpack and weave the entire in path, which makes it far from responsive.

An "LTW path", containing jars that does not have to be actually weaved (LTW, in the form of Equinox Aspects or anything else, will in the future weave them) but simply used to check current project syntax (advice, ITDs, use or ITDs etc..) against.

Linked source folders are a good solution when you have the source of the library. It would work for a number of use cases in my situation : since I need this for an Apache Lab which is an open source project, sources are paired with their jars in the Maven repository, as long as only those libraries are involved.

It does trigger complete compile and weaving also of the linked sources, but at least it does that incrementally. Since source folders supports the ability to drop compiled classes in a different output folder, read only access and being hidden, this also solves other problems.

As a (maybe) quick workaround for this problem (while waiting for THE solution :) ), AJDT could resolve to using the .java/.aj found in the source attachment of jars on the in path, if present.

This would greatly help a number of use cases for those who use open source libraries or internally developed libraries for which sources are present, but I have no idea if adding those plain java files to the model is easy or even possible without using all the infrastructure Eclipse offers with linked source folders.

If I'm not wrong there are/were a few places in JDT and AJDT where programmatic parsing of code extracted for sources different than the .java in the source folders.


Thanks for the clarifications (I was getting mad about it), and this also gave me the opportunity to have a look at AJDT code, with which I'll have to deal in a near future and raise/read/comment a few bugs.

Simone



Andrew Eisenberg wrote:
Although what you are trying to do sounds very reasonable, this is not
yet supported in AJDT.  The main reason why it doesn't work is that
the crosscutting model exposed to AJDT does not contain target
elements for crosscutting relationships when the target is binary (and
I don't know if it will contain the source elements either in your
situation).

In the short term, there is a work around, however.  If you can
perform the weaving of A & B in a separate project and have the source
project consume the woven jars, rather than try to weave them itself,
you should be working at least partially.  It may not be as clean as
you would like, but you should get proper content assist and
reconciling.

In the longer term, we are considering an  enhancement is something
that Andy has alluded to before.  This enhancement is to use
matching-without-weaving-capability in AspectJ.  This will allow AJDT
to find matches to pointcuts even if they sit somewhat outside the
model.  So, for example, you can show weaving matches between projects
when performing Load time weaving.  This can also likely be extended
to include matches between binary package roots.

hope this helps,
--a

On Wed, Jul 22, 2009 at 3:38 PM, Simone Gianni<simoneg@xxxxxxxxxx> wrote:
Hi Andrew,
thanks for the fast and in-depth answer. I arrived to
ITDAwareNameEnvironment and was following my way back to "the core" of it.
You gave me the right pointers.

I have basically this problem, and I was trying to understand internals of
AJDT to see if this is achievable at all, and if I could eventually
contribute somehow.

Suppose I have a User class, packaged in A.jar. Then I have an aspect ITD
getIQ() on user, packaged in B.jar.

Now, from a different project, that "depends" on A.jar and B.jar, I want to
call User.getIQ().

If I place A.jar on the inpath and B.jar on the aspectpath, AspectJ itself
gives no error at all, and in fact there is no error in the package view.
But if I open the .java or .aj file making the call, I can see
reconciliation errors, and no ITD content assist for user.getIQ(). (should I
raise a bug for this? I have it ready :D )

I'm using this construct (aspect libraries adding new functionalities to
classes in different libraries using ITDs) all the way around, and then they
are composed together on a third package that need to use the original
classes with the additional functionalities. It works in AspectJ, but it is
a pain while writing it in Eclipse, due to reconciliation errors and lack of
content assist.

I was hoping that bug 271269
<https://bugs.eclipse.org/bugs/show_bug.cgi?id=271269> was somehow going to
resolve this issue, but it seems that it adds "source->binary" ITDs, while
"binary->binary" ITDs are not handled, while they work in AspectJ.


I noticed that in ITDAwareNameEnvironment, in the find(String,String)
method, if the found type is a binary then no ITD interpolation is
performed, and it does not exist an ITDAwareBinaryType* class.

Exploring the AJProjectModelFacade however I can see many places where it
tries to access AJ data from resources in jar files or class files.

Is it a hard work to get that working? Theoretically if AJDT is able to
extract ITDs from binary aspects, and to apply ITDs to binary classes (for
bug 271269), the hardest pieces should be there.


Simone

Andrew Eisenberg wrote:
Sure.  AJDT uses the crosscutting model from AspectJ as the base.  The
entry point into the AspectJ model is the AJProjectModelFacade class
(and AJProjectModelFactory to create them).  This class allows you to
convert from IJavaElement handles to IProgramElement handles, as well
as ask interesting questions about what elements crosscut other
elements.

This information is used to seed content assist, gutter markers, the
crosscutting view, etc.  Gutter markers and crosscutting view are easy
since that is basically just taking a projection of the underlying
model and transforming it to the correct format.

ITD Aware content assist is a bit more complex because we need to
trick JDT into thinking that ITDs really exist in the target type.
ITDInserter and ITDAwareSourceTypeElementInfo are two classes that
handle this mocking up of ITDs.

There is a code sample on AJProjectModelFacade available on this wiki
page:

http://wiki.eclipse.org/Developer%27s_guide_to_building_tools_on_top_of_AJDT_and_AspectJ

I'm happy to go into more detail if you have any questions.

On Wed, Jul 22, 2009 at 1:14 PM, Simone Gianni<simoneg@xxxxxxxxxx> wrote:

Hi all,
this is the first time I have a serious look at AJDT internals, so please
forgive me if I ask stupid questions :)

I'm trying to figure out how AJDT fetches information from the underlying
AJ, especially regarding ITDs. Does AJDT "re-reads" the .class files
generated by AJ build? Or does it parses pointcuts and check them using
the
matcher? Or what else? :D

I'm talking about informations to display ITD content assist as well as
cross reference view, even if I think these use different methods.

If you can point me to relevant part of code I'll then try to figure it
out
on my own.

Simone

--
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/

_______________________________________________
ajdt-dev mailing list
ajdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ajdt-dev


_______________________________________________
ajdt-dev mailing list
ajdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ajdt-dev


--
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/




--
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
http://www.simonegianni.it/


Back to the top