eclipse-jdt / eclipse-jdt/eclipse.jdt.ui
[Bug][Extract Method Refactoring] Extract method refactoring for Generics in Local Class produces uncompilable program
- Dominant language
- Java
- Stars
- 59
- Forks
- 127
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 35
Description
## Steps to reproduce
1. Create a class named A:
```
public class A {
void foo(Integer value) {
class Local {
void bar(T param) {
Runnable runnable = () -> {
System.out.println(param); // Extract method on this statement
};
}
}
}
}
```
2. Select the statement `System.out.println(param);` like I comment. Then, right click -> Refactor -> Extract Method. Choose the Destination Type as `A`, the configuration to extract 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 {
void foo(Integer value) {
class Local {
void bar(T param) {
Runnable runnable = () -> {
extracted(param); // Extract method on this statement
};
}
}
}
private void extracted(T param) {// syntax error
System.out.println(param);
}
}
```
## 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)
Contributor guide
Research direction
Start by reproducing the Extract Method refactoring with the provided Java example in Eclipse JDT UI. Investigate how extraction from a lambda inside a generic local class handles the type parameter when the destination is A. Done means the refactored program compiles without an unresolved T, and a regression test covers this scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100