You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bug][Inline Method Refactoring] Inline Method refactoring for Multiple anonymous classes interacting within the method to be inlined produces uncompilable program
#1781
Open
RETester66 opened this issue
Nov 6, 2024
· 0 comments
public class A {
int data = 100;
void superClassMethod() {
System.out.println("Data: " + data);
}
static void callingMethod(A instance) {
instance.methodToBeInlined(); // inline call to methodToBeInlined()
}
void methodToBeInlined() {
Runnable r1 = new Runnable() {
public void run() {
data += 20;
}
};
Runnable r2 = new Runnable() {
public void run() {
A.this.superClassMethod();
r1.run();
}
};
r2.run();
}
}
Left click methodToBeInlined() in instance.methodToBeInlined(); like I comment. Then, right click -> Refactor -> Inline. Use the default configuration to inline this method like following, click ok:
The program is successfully refactored without any warning or exception. The refactored program is following, which contains syntax error:
public class A {
int data = 100;
void superClassMethod() {
System.out.println("Data: " + data);
}
static void callingMethod(A instance) {
Runnable r1 = instance.new Runnable() {// syntax error
public void run() {
instance.data += 20;
}
};
Runnable r2 = instance.new Runnable() {// syntax error
public void run() {
A.this.superClassMethod();
r1.run();
}
};
r2.run(); // inline call to methodToBeInlined()
}
void methodToBeInlined() {
Runnable r1 = new Runnable() {
public void run() {
data += 20;
}
};
Runnable r2 = new Runnable() {
public void run() {
A.this.superClassMethod();
r1.run();
}
};
r2.run();
}
}
Environment
OS Version
Windows 10, 64-bit Operating System, x64-based processor
Eclipse Version
Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)
Version: 2024-09 (4.33.0)
Build id: 20240905-0614
JDK Version
java version "22.0.1" 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
The text was updated successfully, but these errors were encountered:
Steps to reproduce
methodToBeInlined()
ininstance.methodToBeInlined();
like I comment. Then, right click -> Refactor -> Inline. Use the default configuration to inline this method like following, click ok:The program is successfully refactored without any warning or exception. The refactored program is following, which contains syntax error:
Environment
OS Version
Windows 10, 64-bit Operating System, x64-based processor
Eclipse Version
Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)
Version: 2024-09 (4.33.0)
Build id: 20240905-0614
JDK Version
java version "22.0.1" 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
The text was updated successfully, but these errors were encountered: