Change of the toString implementation for annotations

joe darcy joe.darcy at oracle.com
Tue Jul 19 02:13:01 UTC 2016


Hello Rafael,

On 7/18/2016 5:43 PM, Rafael Winterhalter wrote:
> Hello,
> I recognized a failing test on Java 9 caused by a changed return value
> returned by toString on an annotation with a class-property.
>
> When calling toString on an annotation: @interface Foo { Class<?> value();
> } instantiated as @Foo(Bar.class) with Java 8 it would be printed as:
>
> @Foo(class Bar)
>
> while in Java 9 it is printed as:
>
> @Foo(Bar.class)
>
> Is this change intended? I do not see a big benefit of this implementation
> change and it could break code. In my case, the problem is not that big, it
> is an easy fix but still, I found it a bit surprising.
>

I pushed the change your test noticed; it was done as part of

     JDK-5040830: (ann) please improve toString() for annotations 
containing exception proxies
     https://bugs.openjdk.java.net/browse/JDK-5040830

The basic rationale for the change is that "Foo.class" is the syntax 
that appears when annotations are in source code so the toString() form 
should generally reflect that.

Thanks for running your project against JDK 9 builds; HTH,

-Joe


More information about the core-libs-dev mailing list