spoon icon indicating copy to clipboard operation
spoon copied to clipboard

class objects as annotation parameters are not correctly pretty-printed

Open maxcleme opened this issue 10 years ago • 3 comments

@Foo(value=Bar.class) is rewritten @Foo(value=Bar)

maxcleme avatar Feb 08 '16 14:02 maxcleme

Hi @maxcleme,

With 5.1.0-SNAPSHOT and with this class:

public class Foo {
    @Bar(value = Foo.class)
    public void m() {
    }
}

The Spoon output is:

public class Foo {
    @spoon.test.annotation.testclasses2.Bar(value = spoon.test.annotation.testclasses2.Foo.class)
    public void m() {
    }
}
  • Which version of Spoon do you use?
  • Can you give us more context?

Thanks.

GerardPaligot avatar Feb 10 '16 10:02 GerardPaligot

Hi @GerardPaligot

When I'm running this code with the 5.0.1 version :

getFactory().Annotation().annotate(parentTestClass, RunWith.class, "value", _CollectorRunner.class)

The output is :

@RunWith(value = _CollectorRunner)

Obviously, it doesn't compile. ( the .class is missing )

maxcleme avatar Feb 10 '16 11:02 maxcleme

Ok, I see the issue. Before Spoon 5, a class access was a CtFieldRead and now, it is a CtTypeAccess. Factories haven't been updated. PR soon.

GerardPaligot avatar Feb 10 '16 15:02 GerardPaligot