<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Nataliia Dziubenko on foojay.io - Friends Of OpenJDK</title><link>https://foojay.io/today/author/nataliia/</link><description>Articles written by Nataliia Dziubenko on foojay.io - Friends Of OpenJDK</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 21 Jan 2025 14:45:12 +0000</lastBuildDate><atom:link href="https://foojay.io/today/author/nataliia/index.xml" rel="self" type="application/rss+xml"/><item><title>How JVM handles exceptions</title><link>https://foojay.io/today/how-jvm-handles-exceptions/</link><pubDate>Tue, 21 Jan 2025 14:45:12 +0000</pubDate><guid>https://foojay.io/today/how-jvm-handles-exceptions/</guid><description>&lt;p&gt;&lt;strong&gt;It&amp;rsquo;s interesting to know how the JVM runs bytecode instructions… But do you know what is going on when an exception is thrown? How does the JVM handle the delegation of control? What does it look like in the bytecode?&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Let me quickly show you!&lt;/p&gt;&#10;&lt;h3 id="example"&gt;Example&lt;/h3&gt;&#10;&lt;p&gt;Here&amp;rsquo;s a simple bit of Java code that includes all the important actors in the exception-throwing game (try-catch-finally):&lt;/p&gt;&#10;&lt;pre class="EnlighterJSRAW" data-enlighter-language="generic"&gt;int a = 0;&#10;try {&#10; if (a == 0) { // to make it less boring, let&amp;#39;s have some branching logic&#10; throw new Exception(&amp;#34;Exception message!&amp;#34;);&#10; }&#10;} catch (Exception e) {&#10; doSomethingOnException();&#10;} finally {&#10; doSomethingFinally();&#10;}&lt;/pre&gt;&lt;h3 id="exception-table"&gt;Exception table&lt;/h3&gt;&#10;&lt;p&gt;The resulting bytecode includes an interesting section in the Code attribute called the Exception table. Each method can have its own exception table, and it&amp;rsquo;s only present when relevant. If there is no exception-handling logic in the method, it won&amp;rsquo;t have an exception table.&lt;/p&gt;</description></item></channel></rss>