Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How can i change modifier from private to public? AST? Preprocessor? Java6 Processor?

Hi,

I am writing my master's thesis and using AspectJ for a special access control enforcement due to the thesis' challenge. I want to loosen the access control of the 'private' modifier. For example it is possible to realize a friendship-concept of classes. My problem is, that objects shall have access to private-fields and -methods, but then, the compiler won't compile. My solution is to preprocess these private modifiers and convert them into public. The correct access control enforcement is done by an aspect.

@AccessControl
private int foo;

shall be converted to

@AccessControl
public int foo;

After this covnersion, the appropriate aspects should work on the annotated, public fields and methods.

The affected modifiers are identified by an annotation. At the moment I am using a Java-6 processor and modify the abstract syntax tree (AST), which is on the one hand complex and on the other not AspectJ compatible (I think).

How can I solve this problem with AspectJ?

Some ideas/questions:
1) Is AspectJ able to process annotations with an Javac-6-Processor?
2) Can AspectJ change the access modifier before compilation?
3) Is it possible that AspectJ converts private to public "on the fly" before compiling? It is important, that the original source file isn't modificated.
4) Can I modify the AST of the AspectJ-Compiler? Is there a API available?
5) Do I have to use a preprocessor? Does anyone know a preprocessor with this annotation capabilities? I wasn't able to get it to work with APT. But I would love to have a all-in-one-AspectJ-solution.

Thank you very much for your ideas.

Timo Meinen (timomeinen@xxxxxxxxx)


Back to the top