[
https://issues.apache.org/jira/browse/GROOVY-7918?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jason Winnebeck resolved GROOVY-7918.
-------------------------------------
Resolution: Duplicate
> Line number debug annotation missing on final return
> ----------------------------------------------------
>
> Key: GROOVY-7918
> URL: https://issues.apache.org/jira/browse/GROOVY-7918
> Project: Groovy
> Issue Type: Bug
> Components: bytecode
> Affects Versions: 2.4.7
> Reporter: Jason Winnebeck
>
> When debugging code in Groovy, if a method ends with a branching statement,
> the debugger will appear to step into the method. In Groovy 2.4.7 and
> IntelliJ 2016.2.2, if you run the class below with no arguments and place a
> breakpoint on line a, then choose to step one line, the debugger will appear
> to stop on line b.
> {code}
> class Debugging {
> public static void main(String[] args) {
> a: if (args.length > 0) {
> b: println "args"
> }
> } //line 6
> }
> {code}
> The reason for this is in the bytecode:
> {code}
> L3
> LINENUMBER 4 L3
> ALOAD 1
> LDC 1
> AALOAD
> LDC LDebugging;.class
> LDC "args"
> INVOKEINTERFACE org/codehaus/groovy/runtime/callsite/CallSite.callStatic
> (Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object;
> POP
> L2
> RETURN
> {code}
> There's no LINENUMBER annotation on the final return, so the LINENUMBER 4
> from earlier is used, which is inside the if block, even though the if block
> does not run.
> In Java, the final return is annotated with the line number of the closing
> brace, which in the example above is line 6.
> A workaround is to add an explicit "return" statement at the end of the
> method, which generates the line number annotation without changing the
> semantics.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)