相关疑难解决方法(0)

合成访问器方法警告

我在eclipse中做了一些新的警告设置.有了这些新设置,我面临一个奇怪的警告.阅读后我知道它是什么,但找不到删除它的方法.

这是我的示例代码问题

public class Test {
    private String testString;

    public void performAction() {

        new Thread( new Runnable() {
            @Override
            public void run() {
                testString = "initialize"; // **
            }
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

**的行在eclipse中给我一个警告

Read access to enclosing field Test.testString is emulated by a synthetic accessor method. 
Increasing its visibility will improve your performance.
Run Code Online (Sandbox Code Playgroud)

问题是,我不想更改访问修饰符testString.另外,不想为它创建一个getter.

应该做些什么改变?


More descriptive example 

public class Synthetic
{
    private JButton testButton;

    public Synthetic()
    {
        testButton = new JButton("Run");
        testButton.addActionListener(new ActionListener() {
                public …
Run Code Online (Sandbox Code Playgroud)

java eclipse performance java-synthetic-methods

14
推荐指数
2
解决办法
9432
查看次数