<?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://foojayio.github.io/website/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://foojayio.github.io/website/today/author/nataliia/index.xml" rel="self" type="application/rss+xml"/><item><title>How JVM handles exceptions</title><link>https://foojayio.github.io/website/today/how-jvm-handles-exceptions/</link><pubDate>Tue, 21 Jan 2025 14:45:12 +0000</pubDate><guid>https://foojayio.github.io/website/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&amp;hellip; 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;
&lt;p&gt;Let me quickly show you!&lt;/p&gt;
&lt;h3 id="h3-0-example"&gt;Example&lt;/h3&gt;
&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;
&lt;pre class="EnlighterJSRAW" data-enlighter-language="generic"&gt;int a = 0;
try {
 if (a == 0) { // to make it less boring, let's have some branching logic
 throw new Exception("Exception message!");
 }
} catch (Exception e) {
 doSomethingOnException();
} finally {
 doSomethingFinally();
}&lt;/pre&gt;
&lt;h3 id="h3-1-exception-table"&gt;Exception table&lt;/h3&gt;
&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>