Re:JVM exceptions are weird: a decompiler perspective
by o11c on Monday November 10, 2025 @12:37AM
(#45872787)
What about throwing an exception from the finally clause?
Re:JVM exceptions are weird: a decompiler perspective
by messe on Monday November 10, 2025 @04:31AM
(#45874200)
This loops, if that's what you're asking:
while (true)
{
try
{
try { return; }
finally { throw new Exception(); }
}
catch { }
}
Re:JVM exceptions are weird: a decompiler perspective
by ziml77 on Monday November 10, 2025 @09:20AM
(#45876276)
Yes that is the one exception (heh) to the rule unfortunately. You can throw from anywhere so it must support unwinding from any point. So if you were really intent on abusing the finally you could wrap the try-finally in a try-catch and then throw from the finally and put your continue in the catch.
Re:JVM exceptions are weird: a decompiler perspective
by kant2002 on Monday November 10, 2025 @05:18AM
(#45874456)
The finally behave slightly different in CIL. You have protected regions and finally/fault/catch/filters handlers attached. So in order to support continue inside finally you should introduce some state machine , which is complication and generally against Roslyn design limitation.
Re:JVM exceptions are weird: a decompiler perspective
by MaxBarraclough on Monday November 10, 2025 @09:08AM
(#45876166)
ziml77's point is about the behaviour of the C# language. You seem to be talking about implementation concerns. They're not relevant.
CS0157 Control cannot leave the body of a finally clause