Annotation on public method does not work if annotation is placed before public modifier
Andrei Eremeev
andrei.eremeev at oracle.com
Sun Jul 12 15:08:07 UTC 2015
Duplicate: https://bugs.openjdk.java.net/browse/JDK-8129559
Andrei Eremeev
----- Original Message -----
From: robert.field at oracle.com
To: bono8106 at gmail.com, kulla-dev at openjdk.java.net
Cc: arungupta at gmail.com, borisov.bai at gmail.com
Sent: Sunday, July 12, 2015 2:30:03 AM GMT +03:00 Iraq
Subject: Re: Annotation on public method does not work if annotation is placed before public modifier
Thank you!
Submitted: https://bugs.openjdk.java.net/browse/JDK-8131028
-Robert
On 07/11/15 13:41, Nikolay Botev wrote:
> (on behalf of Alex Borisov)
>
> Nikolays-MacBook-Air:bin nbotev$ uname -a
> Darwin Nikolays-MacBook-Air.local 14.4.0 Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
>
> Nikolays-MacBook-Air:bin nbotev$ java -version
> java version "1.9.0-ea"
> Java(TM) SE Runtime Environment (build 1.9.0-ea-b72)
> Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b72, mixed mode)
>
> JShell verison: kulla-0.610-20150709005843 (also reproducible on kulla-0.710)
>
> ——
>
> Summary: Using an annotation on a public method does not work if the annotation is placed before the public modifier, but it works if the annotation is placed after the public modifier.
>
> Reproduction steps:
>
> -> @interface MyTest {}
> | Added annotation interface MyTest
>
> -> @MyTest void boo() {}
> | Added method boo()
>
> -> @MyTest public void foo() {}
> | Error:
> | repeated modifier
> | @MyTest public void foo() {}
> | ^
> | Warning:
> | Modifier 'public' not permitted in top-level declarations, ignored
> | @MyTest public void foo() {}
> | ^------------^
>
> -> public @MyPublic void foo() {}
> | Warning:
> | Modifier 'public' not permitted in top-level declarations, ignored
> | public @MyPublic void foo() {}
> | ^--------------^
> | Added method foo(), however, it cannot be referenced until class MyPublic is declared
>
> ->
>
More information about the kulla-dev
mailing list