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

Extract to method adds incorrectly static for nested class #709

Closed
yyoncho opened this issue Jun 23, 2018 · 0 comments
Closed

Extract to method adds incorrectly static for nested class #709

yyoncho opened this issue Jun 23, 2018 · 0 comments
Assignees
Labels
Milestone

Comments

@yyoncho
Copy link
Contributor

yyoncho commented Jun 23, 2018

Given the following code:

package some;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class App {
    public static void main(String[] args) {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.execute(new Runnable() {
            @Override
            public void run() {
                String inLocalThread = "SecondThreadValue";
                System.out.println(inLocalThread);
            }
        });
        String inMainThread = "MainThreadValue";

        extracted(executor, inMainThread);
    }

	private static void extracted(ExecutorService executor, String inMainThread) {
		System.out.println(inMainThread);
        executor.shutdownNow();
	}
}

if you select System.out.println(inLocalThread); and then perform "Extract to method" it will generate "static" method in nested class. The strange thing is that it fails only if there is method named extracted in the upper scope and if you select exactly this line.

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

No branches or pull requests

3 participants