Community
Participate
Working Groups
import java.util.Random; public class Main { public static void main(String[] args) { 1 System.out.println(new Random(1L).nextLong()); 2 System.out.println(new Random(1L).nextLong()); } } Above is the target code. Below is what I did. 1. I select "new Random(1L)" in line 1 2. click Refactor->Extract Local Variable,variable name random Below is the result of refactoring. import java.util.Random; public class Main { public static void main(String[] args) { Random random = new Random(1L); System.out.println(random.nextLong()); System.out.println(random.nextLong()); } } Below is what I expected. import java.util.Random; public class Main { public static void main(String[] args) { Random random = new Random(1L); System.out.println(random.nextLong()); System.out.println(new Random(1L).nextLong()); } } This refactor change the "new Random(1L)" in line 2 too,so the program will not work correctlly. Here is the output of this program before refactoring: -4964420948893066024 -4964420948893066024 after refactoring: -4964420948893066024 7564655870752979346 I think this is a very serious bug. It break the correctness of the code