Eclipseでいくつかの新しい警告設定を行いました。これらの新しい設定で、私は奇妙な警告に直面しています。読んだ後、私はそれが何であるかを知るようになりましたが、それを削除する方法を見つけることができませんでした。
これがサンプルコードに関する私の問題です
public class Test {
private String testString;
public void performAction() {
new Thread( new Runnable() {
@Override
public void run() {
testString = "initialize"; // **
}
});
}
}
* *の行は、Eclipseで警告を表示します
Read access to enclosing field Test.testString is emulated by a synthetic accessor method.
Increasing its visibility will improve your performance.
問題は、のアクセス修飾子を変更したくないということですtestString
。また、そのためのゲッターを作成したくありません。
どのような変更を行う必要がありますか?
More descriptive example
public class Synthetic
{
private JButton testButton;
public Synthetic()
{
testButton = new JButton("Run");
testButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae)
{
/* Sample code */
if( testButton.getText().equals("Pause") ) {
resetButton(); // **
} else if( testButton.getText().equals("Run") ) {
testButton.setText("Pause"); // **
}
}
}
);
}
public void reset() {
//Some operations
resetButton();
}
private void resetButton() {
testButton.setText("Run");
}
}
の行**
は私に同じ警告を与えます。