#Java findbugs may expose internal.
12 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @proud tulip! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
since it's private and should never change, having a mutable reference be assigned to it in the constructor is dangerous since you're able to change the data of the reference even if you don't specify a way to access it in your class.
especially if stuff in your class is using the reference for private work, a client could change the objects properties and therefore change the private work done in the class which is a no no.
you're probably provide the arguments to create the object instead of passing in the object itself.
I have into KeyBoardInputs all the methods of keyeventListener
private final ApplicationPanel panel;
public KeyboardInputs(final ApplicationPanel p) {
this.panel= p;
}
@Override
public void keyPressed(final KeyEvent key) {
this.panel.getApplication().keyPressed(key);
}
how can I link like this KeyBoardInputs and ApplicationPanel
well the application probably doesn't change, so see if you couldn't pass the application instead.
Otherwise you may have to first build the ApplicationPanel with its constructor, and only after bind a KeyboardInputs object to it. Nonideal, but that's how you avoid the encapsulation circumvention that findbug is complaining about.
it works passing directly the application instead of the panel and then getting application