apache / apache/netbeans

“Pull Down Field” refactoring caused a change in the code behavior

Open
#8,301 1 comment 0 reactions 0 assignees View on GitHub
kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 25

### What happened

When the "Pull Down Field" refactoring is performed using NetBeans, it causes changes to the code's behavior.

### Language / Project Type / NetBeans Component

_No response_

### How to reproduce

Code before refactoring:
```java
class A extends C {
}

class B {
void main() {
final int b = 2;
new A() {
void m() {
System.out.println(b);
}
};
}
}
class C {
protected final int b = 1;
}
```

Code after refactoring:
```java
class A extends C {
protected final int b = 1;
}

class B {
void main() {
final int b = 2;
new A() {
void m() {
System.out.println(b);
}
};
}
}
class C {
}
```
The output before code refactoring is 1, and the output after refactoring is 2. The code behavior has changed.

### Did this work correctly in an earlier version?

Apache NetBeans 25

### Operating System

windows11

### JDK

17

### Apache NetBeans packaging

Apache NetBeans platform

### Anything else

_No response_

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue by running the Pull Down Field refactoring on the supplied Java example and compare the output before and after. Start at the Pull Down Field refactoring entry point and trace how field references in the anonymous class are resolved. Done means the refactoring preserves the original behavior and the example still outputs 1.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.