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

Remove redundant modifiers from fields within interfaces #24

Closed
markiewb opened this issue Dec 4, 2013 · 8 comments
Closed

Remove redundant modifiers from fields within interfaces #24

markiewb opened this issue Dec 4, 2013 · 8 comments

Comments

@markiewb
Copy link
Owner

markiewb commented Dec 4, 2013

Reported by https://netbeans.org/bugzilla/show_bug.cgi?id=184673#c5

  • ‘public’ and/or ‘static’ on nested classes.
@jglick
Copy link

jglick commented Dec 4, 2013

public, static, and/or final on fields in an interface are also redundant.

@markiewb
Copy link
Owner Author

markiewb commented Dec 7, 2013

@jglick ‘public’ and/or ‘static’ on nested classes.: Are you sure about public?

@jglick
Copy link

jglick commented Dec 9, 2013

Yup, anything inside an interface is implicitly public, even fields and nested classes. I found this out the hard way years ago in org/openide/windows/InputOutput.java, when browsing Javadoc I saw to my alarm that what were intended to be implementation internals were in fact public. Better IMHO to warn people about this when they are first writing the code, so that they can decide consciously whether to add the public keyword or move the member elsewhere.

@markiewb
Copy link
Owner Author

markiewb commented Dec 9, 2013

So it would be better to create an errorhint when there is no public
modifier? This way the user will be notified that he exports the nested
class. He can make it public or can move the nested class.

BTW 90% guess there is already such a hint in findbugs
Am 09.12.2013 17:14 schrieb "Jesse Glick" notifications@github.com:

Yup, anything inside an interface is implicitly public, even fields and
nested classes. I found this out the hard way years ago in
org/openide/windows/InputOutput.java, when browsing Javadoc I saw to my
alarm that what were intended to be implementation internals were in fact
public. Better IMHO to warn people about this when they are first writing
the code, so that they can decide consciously whether to add the publickeyword or move the member elsewhere.


Reply to this email directly or view it on GitHubhttps://github.com//issues/24#issuecomment-30145218
.

@jglick
Copy link

jglick commented Dec 9, 2013

So it would be better to create an errorhint when there is no public modifier?

Maybe, but my thought was that having a hint to remove such modifiers as redundant would suffice to drill it into programmers’ minds that it is implicit. Like you until now, I had no idea that the Java compiler would add an implicit public to a nested class, but after being alerted to this, I now think about it when writing code. I suppose it could go either way.

@markiewb
Copy link
Owner Author

@jglick : Cannot fix the request because of a probable NetBeans bug.
-> isolated into separate issue - #26 Have a look at it if you are interested

@markiewb
Copy link
Owner Author

Note for myself: Need to merge b25ab47

@markiewb markiewb modified the milestone: 1.2 Apr 23, 2014
@markiewb
Copy link
Owner Author

markiewb commented May 4, 2014

Already merged. Closing. 1.2

@markiewb markiewb closed this as completed May 4, 2014
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