[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] problem with declare annotation
|
Just to say, this is now fixed in the latest dev builds - the program
below works fine.
On 27/11/2007, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
> The error would appear to be a real bug, I put everything into one file:
>
> aspect ConfigureTracing {
> declare @type : MyPojo : @Tracing(level = LoggingLevel.DEBUG);
> // compile error!!!
> declare @method : * MyPojo.calculate() : @TestAnnotation;
> }
> @interface Tracing { LoggingLevel level(); }
> @interface TestAnnotation {}
> class Level {
> Level(int i) {}
> public final static Level ALL = new Level(1);
> public final static Level DEBUG = new Level(2);
> public final static Level ERROR = new Level(3);
> public final static Level FATAL = new Level(4);
> public final static Level INFO = new Level(5);
> public final static Level OFF = new Level(6);
> public final static Level WARN = new Level(7);
> }
> enum LoggingLevel {
> ALL(Level.ALL), DEBUG(Level.DEBUG), ERROR(Level.ERROR),
> FATAL(Level.FATAL), INFO(
> Level.INFO), OFF(Level.OFF), WARN(Level.WARN);
> private final Level level;
> private LoggingLevel(Level level) {
> this.level = level;
> }
> public Level getLevel() {
> return level;
> }
> }
> class MyPojo {
> public static void calculate() {
> }
> }
>
> and it still fails with the error you describe. I have raised it on
> bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=211052
>
> On the second situation, I don't think you can do what you want. You
> can raise an enhancement request and we can look at implementing
> something.
>
> Andy.
>
> On 26/11/2007, Ashley Williams <ashley.williams@xxxxxx> wrote:
> >
> > Hi,
> >
> > I'm trying to write a simple tracing annotation but have problems declaring
> > it against a type due to compile errors. Basically I get the error depending
> > on which combination of @Target annotation attributes I specify. For example
> > TYPE and CONSTRUCTOR work together but not TYPE and METHOD as shown below. I
> > would eventually like to apply the Tracing annotation to all ElementTypes.
> >
> > 1. The pojo I would like to declare the annotations against
> >
> > public class MyPojo {
> > public static void calculate() {
> > }
> > }
> >
> >
> > 2. The annotation I would like to apply is as follows:
> >
> > @Retention(RetentionPolicy.RUNTIME)
> > @Target( { ElementType.TYPE, ElementType.METHOD})
> > public @interface Tracing {
> > LoggingLevel level() default LoggingLevel.DEBUG;
> > }
> >
> >
> > 3. The aspect that applies the annotation to MyPojo and MyPojo.calculate()
> >
> > public aspect ConfigureTracing {
> > declare @type : MyPojo : @Tracing(level = LoggingLevel.DEBUG); //
> > compile error!!!
> > declare @method : * MyPojo.calculate() : @TestAnnotation;
> > }
> >
> >
> > 4. Here is the LoggingLevel enumeration I wrote, since I couldn't find one
> > in log4j:
> >
> > public enum LoggingLevel {
> > ALL(Level.ALL), DEBUG(Level.DEBUG), ERROR(Level.ERROR),
> > FATAL(Level.FATAL), INFO(
> > Level.INFO), OFF(Level.OFF), WARN(Level.WARN);
> > private final Level level;
> > private LoggingLevel(Level level) {
> > this.level = level;
> > }
> > public Level getLevel() {
> > return level;
> > }
> > }
> >
> > However when I compile it using aspectj tools 1.5.3 I get the following
> > error message: "[ERROR] DEBUG cannot be resolved", which refers to my
> > LoggingLevel.DEBUG enum constant. Could it be some sort of class loader
> > issue where only some of my enumeration constants aren't yet available?
> >
> > As a bonus question, I would like to specify something like the
> > ConfigureTracing aspect above in an aop.xml file for runtime weaving, this
> > way I don't have to hard code the annotations at build time. However in the
> > docs for aop.xml I couldn't find any way to declare annotations, so is there
> > some other strategy I can use to achive this?
> >
> > Thanks for any help
> > - Ashley
> > ---
> >
> > This e-mail may contain confidential and/or privileged information. If you
> > are not the intended recipient (or have received this e-mail in error)
> > please notify the sender immediately and delete this e-mail. Any
> > unauthorized copying, disclosure or distribution of the material in this
> > e-mail is strictly forbidden.
> >
> > Please refer to
> > http://www.db.com/en/content/eu_disclosures.htm for
> > additional EU corporate and regulatory disclosures.
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
>