Inline methods make the try-catch block empty, causing compilation errors
Apache NetBeans version
Apache NetBeans 23
What happened
When the "methodToBeInlined()" method is selected for the Inline method refactoring, it causes a refactoring bug, because empty try catch block content cannot trigger an exception, resulting in a syntax error.
class SourceClass{
public void methodToBeInlined() throws IOException{}
public void callerMethod(){
try{
methodToBeInlined()
}catch(IOException e){
e.printStackTrace();
}
}
}
Language / Project Type / NetBeans Component
No response
How to reproduce
When the "methodToBeInlined()" method is selected for the Inline method refactoring, it causes a refactoring bug, because empty try catch block content cannot trigger an exception, resulting in a syntax error.
class SourceClass{
public void methodToBeInlined() throws IOException{}
public void callerMethod(){
try{
methodToBeInlined()
}catch(IOException e){
e.printStackTrace();
}
}
}
Did this work correctly in an earlier version?
Apache NetBeans 23
Operating System
Windows11
JDK
20
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
No response
Are you willing to submit a pull request?
No