1. *Some* forms of static analysis are possible. See declare error and declare warning. I can't say if it will address your specific need, however.
2. There is a long history to this and this question occasionally crops up on this list. There are at least two answers to this (and Andy may be able to give some more detail than I can). First, it is difficult to implement properly and cleanly. From a language design point of view, picking out join points on code blocks is difficult to specify succinctly since they are not named. Second, when pressed for details, most people who request the language feature do not have a general purpose reason for wanting it (rather it is quite specific to the feature requestor's purposes. Because of answer #1, there must be a very strong use case. That being said, there may be some strong use cases that have not been considered and you may know what they are. --a On Tue, Jul 22, 2008 at 6:32 PM, 100ji <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a few novice questions about aspectj. > > 1) Why can't aspectj be used to perform *some* forms of static > analysis? For example, for a given source code, I need to find if the > code has any calls to java.io.ObjectInputStream.readObject and the > type of object being read if any calls exist. I can use a static > analysis tool like PMD to find this out, but writing a tree walker is > extra work when aspectj knows how to do it. Why can I not write > something like a compile_time_pointcut and compile_time_advice to > specify this? Since aspectj already knows how to match patterns it can > give me the points I am interested in during compile time and run the > compile_time_advice. I understand that this approach is not as > powerful as one would like it to be, but this seems like a better > approach then the existing tools. I am not aware if any of the static > analysis tools can match patterns using a pointcut like syntax, so > this seemed like a useful addition. > > 2) Why is there no support for join points at a line level? For > example, I want to write an advice before or after the true condition > block of the if clause. Is there any fundamental reason why this is > not possible in aspectj? IIRC I can do this using BCEL or other byte > code engineering libraries. But, I heard that using 2 instrumentation > tools on the same code is a bad idea (ex: aspectj and BCEL) since > either of them may not understand the instrumentation made by the > other. What do people do when they have to instrument code at a low > level and still have to use aspectj. What libraries should I use, if > I want to do some bytecode level engineering and still use aspectj? > > TIA, > -S- > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
