Skip to main content

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

Hello Dean,

I think this would be a possible solution but wouldn't be a "nice" way. The "beautiful" thing about AST modifying is, that you don't need to generate files for the compiler separatly, because I don't want to modify the original source files. It would be a charme to convert the files for the compiler "on the fly", means only in memory.

I have a working solution with AST-modification by a javax.annotation.Processor for Java6. But this uses the SUN Java6-Compiler. So, I can't get use of AspectJ, where my "access-enforcement-rules" are programmed.

The optimum would be a AspectJ solution, that in any way at first convert the private modifier to public modifier and then weaves in my aspects.

At the moment, I am trying to program something similar with the Eclipse AST parser org.eclipse.jdt.core.dom.ASTParser. This would be ok, because using Eclipse is a request to my framework to get use of AJDT.

Thank you
Timo



Am 18.02.2008, 17:02 Uhr, schrieb Dean Wampler <dean@xxxxxxxxxxxxxxxxxxxxx>:

You might even consider "the simplest thing that could possibly work";
preprocess the source file with a Perl script to change the "private"
to "public", then compile the output file with javac. Would that be
sufficient?

On Feb 18, 2008, at 9:48 AM, Timo Meinen wrote:

Hi Eric,

thank you for the hint. I will have a look at it. It might be a good
idea using an "own" Java compiler. Although, I wanted to learn AOP
and the access control seemed to be a nice playground. :-)

Timo

Am 18.02.2008, 16:38 Uhr, schrieb Eric Bodden <eric.bodden@xxxxxxxxxxxxxx
>:

Hi, Timo.

Just one question: Why are you using AspectJ for this? IMHO it would
be way easier to use an open Java compiler (e.g. JastAdd) and alter
its type checker.

Eric

On 18/02/2008, Timo Meinen <aspectj-users@xxxxxxxxxxxxx> wrote:
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)
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users




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

Dean Wampler, Ph.D.
dean at objectmentor.com
http://www.objectmentor.com
See also:
http://www.aspectprogramming.com  AOP advocacy site
http://aquarium.rubyforge.org     AOP for Ruby
http://www.contract4j.org         Design by Contract for Java5




Back to the top