Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type annotations enforce visibility of properties (aka private fields) #336

Closed
mpiggott opened this issue Sep 5, 2017 · 7 comments
Closed

Comments

@mpiggott
Copy link

mpiggott commented Sep 5, 2017

Minimal test case:

@SuppressWarnings(Broken.FOO)
class Broken {
  static final String FOO = 'unchecked'
}

Works in maven CLI builds and other IDEs

@eric-milles
Copy link
Member

eric-milles commented Sep 5, 2017 via email

@mpiggott
Copy link
Author

mpiggott commented Sep 5, 2017

In your example, FOO is actually a property. If you add public modifier, it is a static final field and will be inlined properly with no warnings or issues.

Yep, I knew public removes the error but this did work in earlier versions of the Eclipse plugin (e.g. 2.9.2.xx-20150327...) and perpetually reminding (and convincing) non-Eclipse developers to use public instead of package in this particular case isn't a great solution. This is also valid in Java.

@eric-milles
Copy link
Member

eric-milles commented Sep 5, 2017 via email

@mpiggott
Copy link
Author

mpiggott commented Sep 5, 2017

@eric-milles shouldn't this match CLI behaviour? Does it really make sense for one IDE to need entirely different code?

@eric-milles
Copy link
Member

eric-milles commented Sep 5, 2017

The error is emitted by Eclipse JDT, not the compiler.

If you leave off the modifier, you are also getting a method generated. Do you really need getFOO() to access the constant value? I would say it is a better practice to require developers to use public in the case of static finals.

@mpiggott
Copy link
Author

mpiggott commented Sep 5, 2017

The error is emitted by Eclipse JDT, not the compiler.

Not sure where the error is coming from matters exactly? We're talking about something that is apparently syntactically valid in both Java & Groovy but groovy-eclipse throws an error on.

@eric-milles
Copy link
Member

eric-milles commented Sep 5, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants