Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Field name mangling when introducing into inner interface?

Hey,

> As of 1.6.9, name mangling was supposed to go away.  Is it still present
> when introducing fields into interfaces in the manner described above?  I'm
> using 1.6.11 & still seeing name mangling, making persistence setup more
> difficult.

Not quite, name mangling for a particular use case was supposed to go
away.  That use case was ITD of fields onto classes, not onto
interfaces, they are rather distinct and the former is much more
straightforward than the latter.

The interface case is covered by open bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=73507 - looks like I
added a patch to it 5 years ago (yikes!) that partially addressed
things, leaving the mangled accessors around (getters/setters) but
leaving the name on the target interface implementor unmangled.  I
wonder if applying that patch now might get you going, I'm presuming
you particularly care about the field name - the existence of the
mangled accessors is perhaps annoying but not causing a real problem?

cheers
Andy

On 9 May 2011 10:00, Matthew Adams <matthew@xxxxxxxxxxxxxxx> wrote:
> Hi all,
>
> I've been using a certain pattern to introduce implementations of an
> interface into persistent classes I want to implement the interface.  Here's
> the basic pattern:
> * define a POJI (plain, old Java interface),
> * define an annotation that is used to drive type-pattern matching
> * define an aspect representing the default implementation of the interface
> and introduce the implementation onto another interface,
> * use a "declare parents" statement to introduce the implementation of the
> interface onto the annotated target classes
>
> As of 1.6.9, name mangling was supposed to go away.  Is it still present
> when introducing fields into interfaces in the manner described above?  I'm
> using 1.6.11 & still seeing name mangling, making persistence setup more
> difficult.
>
> Here's some source to play with that is a concrete example of the pattern.
>
> ===== Flaggable.java
> package org.example.foo.interfaces;
>
> public interface Flaggable {
>
>    boolean isFlagged();
>    void setFlagged(boolean flagged);
>
> }
> ===== FlaggedAspectj.aj
> package org.example.foo.aspects;
>
> import org.example.foo.interfaces.Flaggable;
>
> privileged aspect FlaggableAspect {
>
>        // this allows for other implementations of Flaggable
>    public interface I extends Flaggable {}
>
>    declare parents : (@MakeMeFlaggable *) implements I;
>
>    private boolean FlaggableAspect.I.flagged;
>
>    public boolean FlaggableAspect.I.isFlagged() {
>        return flagged;
>    }
>
>    public void FlaggableAspect.I.setFlagged(boolean flagged) {
>        this.flagged = flagged;
>    }
> }
> ===== MakeMeFlaggable.java
> package org.example.foo.annotations;
>
> import java.lang.annotation.ElementType;
> import java.lang.annotation.Retention;
> import java.lang.annotation.RetentionPolicy;
> import java.lang.annotation.Target;
>
> @Retention(RetentionPolicy.RUNTIME)
> @Target(ElementType.TYPE)
> public @interface MakeMeFlaggable {}
>
> ===== Thing.java
>
> package org.example.foo;
>
> import org.example.foo.annotations.MakeMeFlaggable;
>
> @MakeMeFlaggable
> public class Thing {}
> =====
>
> Thanks,
> Matthew
>
>
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/Field-name-mangling-when-introducing-into-inner-interface-tp3509794p3509794.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top