Skip to main content

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

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.


Back to the top