eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
164 stars 130 forks source link

[4.35+][Internal] TryStatement's secret return value location is useless #3251

Open srikanth-sankaran opened 15 hours ago

srikanth-sankaran commented 15 hours ago

org.eclipse.jdt.internal.compiler.ast.TryStatement creates a secret variable where a return statement in the the try block can stash away the value to be returned which can then be picked up by the finally block.

This mechanism is for the jsr/ret days and has no place in the JDK6+ code generation scheme.

Only impediment to this significant clean up will likely be many test failures due to bytecode disassembly differences and comparator differences :(

srikanth-sankaran commented 15 hours ago

See that neither org.eclipse.jdt.internal.compiler.ast.TryStatement.generateFinallyBlock(BlockScope, CodeStream, Object, int, LocalVariableBinding) nor org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement.generateFinallyBlock(BlockScope, CodeStream, Object, int, LocalVariableBinding) touches the last parameter corresponding to the secret variable.

ReturnStatement goes to some lengths to process and plumb this secret variable through to finally code generation, all for nothing!

iloveeclipse commented 15 hours ago

Only impediment to this significant clean up will likely be many test failures due to bytecode disassembly differences and comparator differences :(

Shouldn't be a problem, we've managed to fo through this in the past. So this shouldn't be a reason to not cleanup code generation.