netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Inline methods make the try-catch block empty, causing compilation errors

Open assdfsdafasfa opened this issue 1 year ago • 0 comments

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

assdfsdafasfa avatar Oct 08 '24 13:10 assdfsdafasfa