Annotation on public method does not work if annotation is placed before public modifier
Nikolay Botev
bono8106 at gmail.com
Sat Jul 11 20:41:09 UTC 2015
(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