eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Compiler not flagging a throws statement as an error when exception is not possible

Open
#2,432 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 10h
Merged PRs (30d)
49

Description

Eclipse version:2023-9

Repeat the steps:

1. select “originalMethod()”
2. click “Refactor-inline method”

class OriginalClass {
public void originalMethod() throws IOException {
// Some logic here
}
}
class OtherClass {

public void callerMethod(){
OriginalClass obj = new OriginalClass();
try {
obj.originalMethod();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

Refefctoring result;

![image](https://github.com/eclipse-jdt/eclipse.jdt.ui/assets/77560508/07ebefff-f70d-4865-812b-cb7e08068073)

Expected behavior: Check for syntax errors before inline method refactoring, and provide a prompt if any exist

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.