I could use some help with ASM. At the end of each constructor/method, the Groovy compiler executes the code below. The idea is to add a return in case return or throw is missing from the source code. However, if no paths can get to the extra return, NOP and ATHROW instructions are added instead. So the if/else should be skipped. If I add line number information to this return, it may result in uncoverable lines in some cases.
Is it possible to use the ASM API to determine if all paths in a method body have resulted in return or throw? org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(MethodNode, boolean, Parameter[], Statement) controller.getCompileStack().clear(); if (node.isVoidMethod()) { mv.visitInsn(RETURN); } else { // we make a dummy return for label ranges that reach here ClassNode type = node.getReturnType().redirect(); if (ClassHelper.isPrimitiveType(type)) { mv.visitLdcInsn(0); controller.getOperandStack().push(ClassHelper.int_TYPE); controller.getOperandStack().doGroovyCast(type); BytecodeHelper.doReturn(mv, type); controller.getOperandStack().remove(1); } else { mv.visitInsn(ACONST_NULL); BytecodeHelper.doReturn(mv, type); } } https://issues.apache.org/jira/browse/GROOVY-9373 This e-mail is for the sole use of the intended recipient and contains information that may be privileged and/or confidential. If you are not an intended recipient, please notify the sender by return e-mail and delete this e-mail and any attachments. Certain required legal entity disclosures can be accessed on our website: https://www.thomsonreuters.com/en/resources/disclosures.html