This feed does not validate.
line 36, column 2: (10 occurrences) [help]
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/03/Blog_ ...
^
... ed_blog_1280x720-5.png</featuredImage> <product ><![CDATA[ai]]></product>
^
In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
line 47, column 0: (125 occurrences) [help]
line 59, column 0: (10 occurrences) [help]
line 59, column 0: (10 occurrences) [help]
line 394, column 0: (22 occurrences) [help]
line 394, column 0: (8 occurrences) [help]
line 394, column 0: (8 occurrences) [help]
line 394, column 0: (8 occurrences) [help]
line 394, column 0: (8 occurrences) [help]
line 394, column 0: (8 occurrences) [help]
line 394, column 0: (8 occurrences) [help]
line 540, column 0: (54 occurrences) [help]
<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:media="http://search.yahoo.com/mrss/" >
<channel>
<title>The IntelliJ IDEA Blog : IntelliJ IDEA – the Leading Java and Kotlin IDE, by JetBrains | The JetBrains Blog</title>
<atom:link href="https://blog.jetbrains.com/idea/feed/" rel="self" type="application/rss+xml" />
<link>https://blog.jetbrains.com</link>
<description>Developer Tools for Professionals and Teams</description>
<lastBuildDate>Tue, 19 Mar 2024 09:56:22 +0000</lastBuildDate>
<language>en-US</language>
<sy:updatePeriod>
hourly </sy:updatePeriod>
<sy:updateFrequency>
1 </sy:updateFrequency>
<image>
<url>https://blog.jetbrains.com/wp-content/uploads/2024/01/cropped-mstile-310x310-1-32x32.png</url>
<title>The IntelliJ IDEA Blog : IntelliJ IDEA – the Leading Java and Kotlin IDE, by JetBrains | The JetBrains Blog</title>
<link>https://blog.jetbrains.com</link>
<width>32</width>
<height>32</height>
</image>
<item>
<title>IntelliJ IDEA 2024.1 Beta 2 Is Out!</title>
<link>https://blog.jetbrains.com/idea/2024/03/intellij-idea-2024-1-beta-2/</link>
<dc:creator><![CDATA[Maria Kosukhina]]></dc:creator>
<pubDate>Mon, 18 Mar 2024 15:24:33 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/03/Blog_Featured_image_IntelliJIDEA-2024.1-Beta.png</featuredImage> <category><![CDATA[eap]]></category>
<category><![CDATA[2024-1-eap]]></category>
<category><![CDATA[intellij-idea-2024-1]]></category>
<category><![CDATA[intellij-idea-2024-1-eap]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=456598</guid>
<description><![CDATA[IntelliJ IDEA 2024.1 Beta 2 has just arrived! Packed with all of the latest enhancements introduced during the Early Access Program, this build is now accessible via our website, the free Toolbox App, or through snaps for Ubuntu. Download IntelliJ IDEA 2024.1 Beta 2 As we approach the final stages of development and testing for […]]]></description>
<content:encoded><![CDATA[
<p>IntelliJ IDEA 2024.1 Beta 2 has just arrived! Packed with all of the latest enhancements introduced during the Early Access Program, this build is now accessible via our <a href="https://www.jetbrains.com/idea/nextversion/" target="_blank" rel="noopener">website</a>, the free <a href="https://www.jetbrains.com/toolbox-app/" target="_blank" rel="noopener">Toolbox App</a>, or through snaps for Ubuntu.</p>
<figure class="wp-block-image size-full"><img decoding="async" fetchpriority="high" width="1280" height="720" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/Blog_Featured_image_IntelliJIDEA-2024.1-Beta.png" alt="" class="wp-image-454484"/></figure>
<p align="center"><a class="jb-download-button" href="https://www.jetbrains.com/idea/nextversion/" target="_blank" rel="noopener">Download IntelliJ IDEA 2024.1 Beta 2</a></p>
<p>As we approach the final stages of development and testing for version 2024.1, this latest build represents a significant stride towards delivering a stable and efficient release.</p>
<p>With the Early Access Program winding down, there’s still time to explore the new features introduced since its launch. We invite you to learn about these latest updates in the <a href="https://blog.jetbrains.com/idea/tag/2024-1-eap/">dedicated section</a> of our blog and then try them out while working with the IntelliJ IDEA 2024.1 Beta 2 build. Let us know if you encounter any <a href="https://youtrack.jetbrains.com/issues/IDEA" data-type="link" data-id="https://youtrack.jetbrains.com/issues/IDEA" target="_blank" rel="noopener">issues</a> – your feedback is vital when it comes to shaping the final version.</p>
<p>Stay tuned for the official release! Thanks for being a part of perfecting IntelliJ IDEA for developers worldwide.</p>
<p>Happy developing!</p>
]]></content:encoded>
</item>
<item>
<title>Getting Started with Databases in IntelliJ IDEA </title>
<link>https://blog.jetbrains.com/idea/2024/03/getting-started-with-databases-in-intellij-idea/</link>
<dc:creator><![CDATA[Irina Mariasova]]></dc:creator>
<pubDate>Mon, 18 Mar 2024 11:03:42 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/03/ij-release-featured_blog_1280x720-1.png</featuredImage> <category><![CDATA[datagrip]]></category>
<category><![CDATA[idea]]></category>
<category><![CDATA[tutorials]]></category>
<category><![CDATA[intellijidea-2]]></category>
<category><![CDATA[databases]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=455855</guid>
<description><![CDATA[Have you ever wondered how IntelliJ IDEA handles databases? Well, today is the perfect opportunity to find out in our database tutorial on initial setups and first steps.   All of the features you’ll need when working with databases are available out of the box in IntelliJ IDEA Ultimate. You can perform various tasks like querying […]]]></description>
<content:encoded><![CDATA[
<p>Have you ever wondered how IntelliJ IDEA handles databases? Well, today is the perfect opportunity to find out in our database tutorial on initial setups and first steps. </p>
<p>All of the features you’ll need when working with databases are available out of the box in IntelliJ IDEA Ultimate. You can perform various tasks like querying data, creating new databases, and managing existing ones – all without leaving your IDE.</p>
<p>One of the best things about the database support is its versatility. Whether your databases are stored locally, on a server, or in the cloud, you’ll always be able to work with them seamlessly. It also supports most database systems, including MySQL, PostgreSQL, Microsoft SQL Server, SQLite, MariaDB, Oracle, MongoDB, Redis, and more.</p>
<p>In fact, IntelliJ IDEA Ultimate provides all of the functionality that is available in <a href="https://www.jetbrains.com/datagrip/" target="_blank" rel="noopener">DataGrip</a>, JetBrains’ standalone database management tool for developers.</p>
<h2 class="wp-block-heading">Set up a database</h2>
<p>IntelliJ IDEA Ultimate comes with a <em>Database</em> tool window where you can perform all the database actions you might need. You can access it quickly from the side toolbar.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/BtmbXqVaRVS1VwQIU3cOGCLRfsojEP0b40yTTXySaZ4CQu1XEBSrjXvXs9FHFH3QHfI5CTBtDqcX2tgWzw0qghJ645_4qGUO0s1AWb4WJ2oi1n3Cg-IaascqseTl4EBBYi_RRANiuIDyH1HfWRWpOSs" alt=""/></figure>
<p>When working with databases, it may be a good idea to create a dedicated shortcut for this tool window. To do so, go to <em>Preferences/Settings | Appearance & Behavior | Keymap</em> and type <em>Database </em>in the search field. Select it from the list and assign the desired shortcut. You’ll now be able access the tool window quickly and conveniently.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/yIpv9zWUG2d2bxvGBZmtu3oKBjqRx_x8cV4wgaGfhhvV0hML5tYXpIAKqKBbz1mRGPbnRkaKjX0tTIsfPXlKjWWFeSo8EdxoJZHOJTckbYCtNNzyrGX7wLjtizwhZiMLBJsTvradIHNxboUIlaDPKjQ" alt=""/></figure>
<p>Now, in the <em>Database</em> tool window, click the <em>+</em> sign to add our first data source. From there, select the type of database you’re connecting to and provide the necessary connection details such as host, port, database name, user, and password. Once you’ve entered all the necessary information, click the <em>Test Connection </em>button to ensure everything is set up correctly before finalizing the setup.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/sPrQ1xtF4IOqGXPbzZqJf0jjUpxpwP-smqAjQ6jH8MXWHvyi5AWMkhhT-7ChZo4TR1RBnihc14Y-hdZdQE_3J0TXYq9Hm6SINyT0iq7iXTQB31QeDWjKo0euq9rnAS9hoPFl46d1Ep_DtpfcCQfpcXg" alt=""/></figure>
<p>The <em>Data Sources and Drivers</em> dialog features multiple tabs with additional settings. For instance, the <em>Options</em> tab allows you to set transaction control to manual or automatic. If you check the <em>Read-only</em> box, the IDE will prevent any modifications to your data source, which is desirable when handling production data. Additionally, it offers various other functionalities, such as keep-alive queries, auto-disconnect, and more.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/X-zvVU1QTcXTZLC8Iyc_Ry_3NDv2QOCzWhBlcvQhfoCrp3Dm5TEB5-CY9YVhmCzmZQJlxu_yTlnEyRxduoBdAnmY4B_GiucvvUhN7g36nszwoZm8fo5HoI0wRnXvFAooE5jZKRuPXNa9QDmFXp5x5Lk" alt=""/></figure>
<p>After you connect your database, IntelliJ IDEA will gather metadata about all of the database objects to help you with code suggestions and navigation. This process is called introspection. By default, all the schemas shown in the <em>Database</em> tool window are introspected. If your database has lots of schemas and you only need a few, you can pick the ones you want to see and work with in the <em>Schemas</em> tab.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/6yrxFooywfBwgJAflYAegzJwlfoHoohJRK4s6bw8JI4vZCG-VW4uMNmi3rE7KznPPHCxe_I8ce5AeJZOoJLdcj_Kgm1X57LhztZifoalwPtOV7GyBkdA3rZG5zov7ChVEE0HXKwsqgIEYL0lN07HydA" alt=""/></figure>
<p>If you want to introspect all of your database schemas, just check the<em> All databases</em> box.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/9vz_kCwgiDVzd8nLqNaAREXPApH7XvO5hSNQL04PSge6p9NHa1k568XS47SAzvHd3MH5ahRuB2IIwu0L_cXbPYjH2_ZMZsiE5I8p3fLyJ2X6wJYr2t61IIDfxaKbSRiGNndOIr7L-Xd4p8od4e5wBSE" alt=""/></figure>
<p>Additionally, the <em>All Namespaces</em> option is available if you prefer to have all databases and schemas visible in the <em>Database</em> tool window without introspecting them. To enable it, go to<em> </em>View options <em>(eye icon) | All Namespaces</em> in the <em>Database</em> tool window. </p>
<p>To introspect a specific database or schema, simply select it and press the <em>Refresh</em> button. For more details, read <a href="https://blog.jetbrains.com/datagrip/2022/08/08/not-all-databases-schemas-are-displayed-by-default-why/">this blog post</a>. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/pEHNKEVRUbzg_G2kzQG7M-7x3Lx7XpKhz4E57-GxnPnhmywQovoHkiKPgx9Drt6tmNCNRCIdRZ2JBYNbDA7e0gBZh0bs2HM9nqyiGvgqP-ZBBT04P7K_xcoBEr3P3hAks9Xo5fhGBqoPqN4an3BirHU" alt=""/></figure>
<p>Once all the settings are applied and the connection is tested, click OK. The data source is now ready, and you’ll see it in the database tree. </p>
<h2 class="wp-block-heading">Explore the interface</h2>
<p>Now that you have a connected database, you can explore what you can do with it. For our examples, we’ll use a database that contains data about various planes, flight bookings, destination airports, etc. </p>
<h3 class="wp-block-heading">View</h3>
<p>When you click on your database, it reveals all tables, routines, and other database objects. If you select the button next to the data source name (<em>1 of 4</em>), you’ll be taken to the <em>Schemas </em>tab, where you can choose specific schemas and databases to display in the tree. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/0MSRZwypT4hODyTKNxKU_OrZrQeUBAfjUA31Ix7NgUX4jEL_OJVn5YZ8auUBvWSDKSVZZK3xdgETNBnfUVW6mWom_IbXPOhRTGa838RhHx2_DWKDA10L8FL30h3LGUtGdIirq7siqeiLHf4Jp7Fh4ls" alt=""/></figure>
<p>When you double-click on an object, you’ll see its content right away. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/mMPESCBJ2NkAz3wJGa2A-sgh_wtd80ZTcTqrPu8yz262ausrholkHtVX3uKkJN_8d9arH-K1Omx73LmA8G67qL6V6LTk76lPBY5iW37OpqwFaUVn6rJlT6yYWCDe0kxTKlg7VIaUtCbYWlKf1rweBBc" alt=""/></figure>
<p>Another interesting feature of database visualization is the ability to generate a diagram that will demonstrate the relationships of various objects within the database. To do so, go to the object you’re working with, right-click on it, and select <em>Diagrams…| Show Diagram Popup</em>. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/g_Eeq15hOVJU-9qH1gUGUaB8BqbEDUBugr2_j1tDyAEoiP1bNoO9ofA1m_RfK4tcfCcFPZR_7KDfR-F-e1U_70OxHVJtkTw8HGMXf6TSeLowvvrAbSkN6KYEo_G2l0Oj2MjIdgnNnuLlftmHN-F6BTo" alt=""/></figure>
<h3 class="wp-block-heading">Group and highlight</h3>
<p>In IntelliJ IDEA, you have the flexibility to arrange your data sources in whatever way best suits your workflow. If you’re dealing with multiple data sources, grouping them can enhance organization. Simply press <em>F6</em> and then drag and drop the desired data sources into a new folder.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/1sv5rxozp4PoEHYQhD7DDKBVCLJh5K1iKUtPynQ67wQyIUMYYBy-kZ2HErsGW1wsy66LQXLFktlG3VOHOxddg6fRe6IFUY57tM8Ckn3SuRUbqofORoiTHhjbv7SEOiliP6ejfmvLj2I_PYcUXSo-SJA" alt=""/></figure>
<p>Additionally, you can color-code each data source. This setting extends to all queries and files associated with that data source, ensuring you’re always aware of the production context you’re working within. To assign a color, right-click on any object and select <em>Tools | Set Color</em>.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/3Y6grac0rGViDrW0NWa7rWrRl1qGJziLAcNq3HCqYiYHkkORoEsyXro6Pmq8Ew7NQ1mQdRKOi0cgdR3D8rN60aL99kLbctiV9w4_xDrQYoAlybpCv_Lfscy-6IzOHCJqi1BniGcTo1nzUH2cJ7Z9HLQ" alt=""/></figure>
<h3 class="wp-block-heading">Search</h3>
<p>Speed search is a useful feature that lets you quickly find objects by typing the initial letters or abbreviations of table names. Press <em>⌘F</em> and see how it works. To toggle the <em>Speed Search</em> filter on and off, click the dedicated button in the search field.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/ZJ8djWYiaMp1Oumy5FdDgQhpmSUcF0iomJneeR5l04iDGdW5NHOJEi-fyGKLTvYutlMQdIilVDBlJsl-psIePmMgv2McPPH9Nw1HGPrHNlC-C229XazQ2j36KqGMkFvka_wtd5lF-bM4ZGF6p7_SUtE" alt=""/></figure>
<h2 class="wp-block-heading">Run your first queries </h2>
<p>Now that you’re familiar with the layout of your database and know how to tailor it to your preferences, let’s explore how to create and execute queries and then retrieve results from them.</p>
<p>To work with queries, you use a query console, which is like a special terminal where you type and run your code. To open it, right-click on the desired data source and navigate to <em>New | Query Console</em>.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/BPHPlpjue0z3ckPlRBPx7Sbw71CB0fptO5K2SGyY4xH25UwGI0--KMTa9AQft19yefo_WW-z-BQwjt_wHqMkW5CtV5SSOH6C2fQyMZIUccAKaCW7vdigrH8QphloDYKeTK-vsHVC6aHJkYum_Dy57JI" alt=""/></figure>
<p>Now it’s time to create multiple queries! One query displays all available plane models, their codes, and their quantity. The second one selects the 10 most expensive bookings.</p>
<p>Code completion is of immense help in this task. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/ARGPs3ZJkytZ4k4JDUwX4w3sAaU83Zt6mKh8Yr3H1LuRk0BvuPXdiME7YvH73DmuLTKnFZCjyITfJ6IOGE8oJ5fXWS6Xsr6DpNJaP9F4eLQJNTpVSiE4QP6ZNIGCGi6Cw9wZQWUMQbCaoDaZIgxFxKY" alt=""/></figure>
<p>When you run queries in IntelliJ IDEA, you don’t need to select the code because the IDE understands where your caret is. If you have several queries in your console and click the <em>Execute</em> button on the toolbar, you’ll be shown a list of the possible queries you can run. In the example below you can decide whether you need to run the current query or the whole script. If you select the <em>Customize</em> option in the <em>Statements</em> popup, you can further fine-tune the process of query execution.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/olw3L69qLcDWjAiq_Tc42GaDUOoFjg7JI9D581ebZIAJtCIRGJQ_CTn5jPJvx77Uj-FAMjkqjFpjlKgq-BkTwpcj3b45Kt_dYt6SbR_VL9lCYySS_SSRAlXvsr4jCWo9crZU4rBwWPjAeo6WLaMIDe8" alt=""/></figure>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/QD1Gf-4FOKnhxC6GRt09Jcc6KiqycW_5P41MlTnIRp7dlOrWHleM6VattvbDyCmknzHaXg__Q-zscSO5KW28T4WMw7-bd4jvneRuKIcvQCHAtHJnGwFDGxGN2uoVUsIuNuFQXbiisthCtsWOqLe42zo" alt=""/></figure>
<p>After the run has been executed, you’ll see the result appear in a separate tab in the <em>Services</em> tool window. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/dOYYLLsf2QvuwVJS0ZPERhHrUkppB_Yg8kHCnbxWv85Zp3Ni5pRmzxXdMXGWv5MscjYp6TsZyc4OOQ-VjcvOhZe6tpcGXOvndiTGsnVMArwcFgUA57q5s2Yzt1spXCbV07pUy8SAFzu22zB8Yq3i93g" alt=""/></figure>
<p>You can also view the query results within the editor. To do so, click the <em>In-Editor Results </em>icon on the toolbar. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/9kOah_sP52SSIie_J96YSIVUhDI0_qpz-1wIC0TDPsl0_2zgFR4NC9SDZoYZtmyXw_U5ZILKKqXqHM0dStMHggs5ZwHGRu64Ubj-xiJgxIQ79tZjtqsVoDxa2qkmTqvrsG4j0NI9RBQIAWfyK0JcrUk" alt=""/></figure>
<p>We hope you enjoyed your introduction to database management in IntelliJ IDEA! Keep an eye out for upcoming articles that will demonstrate more features designed to optimize and streamline your day-to-day database tasks.</p>
]]></content:encoded>
</item>
<item>
<title>IntelliJ IDEA 2023.3.5 Is Out!</title>
<link>https://blog.jetbrains.com/idea/2024/03/intellij-idea-2023-3-5/</link>
<dc:creator><![CDATA[Maria Kosukhina]]></dc:creator>
<pubDate>Tue, 12 Mar 2024 18:43:50 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/03/IntelliJ-IDEA-2023.3.5.png</featuredImage> <category><![CDATA[releases]]></category>
<category><![CDATA[bug-fix-update]]></category>
<category><![CDATA[intellij-idea-2023-3]]></category>
<category><![CDATA[intellij-idea-2023-3-5]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=453920</guid>
<description><![CDATA[We’ve just released one more bug-fix update for v2023.3. You can download the latest build from our website, via the Toolbox App, or by using snaps for Ubuntu. IntelliJ IDEA 2023.3.5. includes the following valuable fixes: For more details, please refer to the release notes. If you spot any bugs, submit a report to our issue tracker. Happy developing!]]></description>
<content:encoded><![CDATA[
<p>We’ve just released one more bug-fix update for v2023.3.</p>
<p>You can download the latest build from our <a href="https://www.jetbrains.com/idea/download/other.html" target="_blank" rel="noreferrer noopener">website</a>, via the <a href="https://www.jetbrains.com/toolbox-app/" target="_blank" rel="noreferrer noopener">Toolbox App</a>, or by using snaps for Ubuntu.</p>
<p>IntelliJ IDEA 2023.3.5. includes the following valuable fixes:</p>
<ul>
<li>We’ve fixed the issue causing erratic screen scaling on Linux. [<a href="https://youtrack.jetbrains.com/issue/IDEA-341318/" target="_blank" rel="noopener">IDEA-341318</a>]</li>
<li>The <em>Project Errors</em> tab in the <em>Problems</em> tool window no longer erroneously continues to display issues that have already been resolved. [<a href="https://youtrack.jetbrains.com/issue/IDEA-343358/Java-Problems-stuck-in-Project-Problems-view" target="_blank" rel="noopener">IDEA-343358</a>]</li>
<li>The <em>Select None</em> button in the <em>Generate Constructor</em> dialog is responsive again and works as expected. [<a href="https://youtrack.jetbrains.com/issue/IDEA-340046/UI-buttons-problem" target="_blank" rel="noopener">IDEA-340046</a>]</li>
<li>We’ve fixed the issue with Maven wrapper settings becoming invalid when installing or uninstalling language packs. [<a href="https://youtrack.jetbrains.com/issue/IDEA-338796/Maven-wrapper-settings-become-invalid-after-language-pack-installation-deinstallation" target="_blank" rel="noopener">IDEA-338796</a>] </li>
<li>The gutter icons once again display properly in GraphQL schema files. [<a href="https://youtrack.jetbrains.com/issue/IDEA-348051/" target="_blank" rel="noopener">IDEA-348051</a>]<br></li>
</ul>
<p>For more details, please refer to the <a href="https://youtrack.jetbrains.com/articles/IDEA-A-2100661888/IntelliJ-IDEA-2023.3.5-233.14808.21-build-Release-Notes" target="_blank" rel="noreferrer noopener">release notes</a>.</p>
<p>If you spot any bugs, submit a report to our <a href="https://youtrack.jetbrains.com/issues/IDEA" target="_blank" rel="noreferrer noopener">issue tracker</a>.</p>
<p>Happy developing!</p>
]]></content:encoded>
</item>
<item>
<title>Easy Hacks: How to Throw Java Exceptions</title>
<link>https://blog.jetbrains.com/idea/2024/03/easy-hacks-how-to-throw-java-exceptions/</link>
<dc:creator><![CDATA[Maarten Balliauw]]></dc:creator>
<pubDate>Tue, 12 Mar 2024 11:03:30 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/02/ij-release-featured_blog_1280x720-2.png</featuredImage> <category><![CDATA[idea]]></category>
<category><![CDATA[java]]></category>
<category><![CDATA[intellij-idea]]></category>
<category><![CDATA[learn]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=446227</guid>
<description><![CDATA[Exceptions in Java are used to indicate that an event occurred during the execution of a program and disrupted the normal flow of instructions. When an exception occurs, the Java runtime automatically stops the execution of the current method. It passes an exception object with information about the error to the nearest catch block that […]]]></description>
<content:encoded><![CDATA[
<p>Exceptions in Java are used to indicate that an event occurred during the execution of a program and disrupted the normal flow of instructions. When an exception occurs, the Java runtime automatically stops the execution of the current method. It passes an exception object with information about the error to the nearest <code>catch</code> block that can handle the exception.</p>
<p>While it’s important to catch and handle exceptions gracefully, it’s equally important to know how to throw them effectively. In this blog post, we’ll explore the ins and outs of throwing Java exceptions, including the different types of exceptions, how to create custom exceptions, and more.</p>
<h2 class="wp-block-heading">How to throw exceptions</h2>
<p>To let the Java runtime know an exception has occurred in your code, you have to <em>throw</em> one. In Java, you can use the <code>throw</code> keyword to invoke the exception machinery in the Java Virtual Machine (JVM):</p>
<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">throw new Exception("Something went wrong!");</pre>
<p>When throwing an exception, you’re creating a new exception object. This object contains information about the event that occurred. This information is reflected by the exception type and several other properties, such as the exception message, which can describe what happened in more detail. The runtime will also enrich the exception object with information about where the exception was thrown, this is done in the form of a stack trace.</p>
<p>To illustrate this, consider the following program:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public void main() throws Exception {
runFirstMethod();
}
public void runFirstMethod() throws Exception {
runSecondMethod();
}
public void runSecondMethod() throws Exception {
throw new Exception("Something went wrong!");
}</pre>
<p>The <code>main</code> method invokes <code>runFirstMethod</code>, which in turn invokes <code>runSecondMethod</code>. A new exception is thrown, with the message <code>"Something went wrong!"</code>. When you run this program, you’ll see the message printed in the output, and a stack trace of where the exception occurred is printed to the console:</p>
<figure class="wp-block-image size-full"><img decoding="async" width="1600" height="1137" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-70.png" alt="" class="wp-image-446264"/></figure>
<p>When an unhandled exception is thrown, the application will stop executing and return a non-zero exit code. To handle the exception, you can surround it with a <code>try</code>/<code>catch</code> block anywhere in the call stack. For example, you can “catch” the exception and log the error to the console in the <code>main()</code> method, or in <code>runFirstMethod()</code>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public void main() throws Exception {
try {
runFirstMethod();
} catch (Exception ex) { // can catch here...
System.out.println("An error occurred: " + ex.getMessage());
}
}
public void runFirstMethod() throws Exception {
try {
runSecondMethod();
} catch (Exception ex) { // ...or here
System.out.println("An error occurred: " + ex.getMessage());
}
}
public void runSecondMethod() throws Exception {
throw new Exception("Something went wrong!");
}</pre>
<p>We’ll look into catching exceptions in more detail in a future post. For now, keep in mind that it is possible to catch and gracefully handle exceptions.</p>
<p>Which classes can be used to represent an exception? In Java, only classes that inherit <code>java.lang.Throwable</code> can be thrown. If you look at the class hierarchy of <code>Throwable</code>, you’ll find two subtypes: <code>java.lang.Error</code>, and <code>java.lang.Exception</code>.</p>
<figure class="wp-block-image size-full"><img decoding="async" width="1020" height="782" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-71.png" alt="" class="wp-image-446275"/></figure>
<p>The <code>Error</code> class is used by the JVM and represents serious problems that applications usually should not try to catch, such as an <code>OutOfMemoryError</code> that may occur when the JVM is unable to allocate an object. There’s no recovering from that situation!</p>
<p>The <code>Exception</code> class is the typical ancestor for exceptions that can be recovered from using a <code>try</code>/<code>catch</code> block. For example, when an <code>IOException</code> is thrown because a file could not be found, your code can show a message to the user of your application or ask to specify the file path again. There’s no need for such an exception to end the execution of your application.</p>
<p>You’ll find that most exceptions in the Java platform are subclasses of the <code>Exception</code> class and indicate various types of exceptions that can occur. <code>IOException</code> signals that an I/O operation was interrupted or has failed. <code>FileNotFoundException</code> is a subclass of <code>IOException</code> that will be thrown when a file with a specific pathname does not exist. Custom exception types in your application will also typically inherit from the <code>Exception</code> class.</p>
<p>Some exceptions have a different superclass and inherit from <code>RuntimeException</code> instead. Implementations of <code>RuntimeException</code> are typically used to signal incorrect use of an API. <code>IndexOutOfBoundsException</code> is such an exception type, which may be thrown when you try to access an index in an array or string that is out of range. Another example is <code>NullPointerException</code>, which may be thrown when a variable that is not pointing to any object (and refers to nothing, or <code>null</code>) is accessed.</p>
<h2 class="wp-block-heading">Checked vs. unchecked exceptions</h2>
<p>In Java, there are two types of exceptions: checked and unchecked. These are closely related to which superclass is used by any particular exception.</p>
<p>Unchecked exceptions are exceptions that are <em>not </em>checked at compile time. Exceptions that inherit the <code>Error</code> or <code>RuntimeException</code> classes are unchecked exceptions, meaning that even if the compiler can determine that such exceptions can occur, your code will still compile.</p>
<p>Checked exceptions are exceptions that <em>are </em>checked at compile time. If a method contains code that throws an exception of type <code>Throwable</code>, <code>Exception</code>, or inheritors of <code>Exception</code>, then the method must either handle the exception itself or signal that the exception has to be handled by a calling method. If an exception is unhandled, your code will not compile.</p>
<p>Let’s take another look at the example code: you’ll see that all method signatures have the suffix <code>throws Exception</code>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public void main() throws Exception {
runFirstMethod();
}
public void runFirstMethod() throws Exception {
runSecondMethod();
}
public void runSecondMethod() throws Exception {
throw new Exception("Something went wrong!");
}</pre>
<p>The <code>throws Exception</code> syntax informs the Java compiler that any calling code will have to handle exceptions of the type <code>Exception</code>. In this example, the application’s <code>main()</code> method doesn’t handle the exception, which means the application doesn’t handle the potential exception from this call stack and may error out.</p>
<p>If you were to throw a <code>RuntimeException</code>, the compiler would not require you to list that exception using the <code>throws</code> keyword. The exception will be unchecked.</p>
<p>You can see how checked exceptions are visualized in the editor when you remove one of the <code>throws Exception</code> suffixes. Almost immediately, IntelliJ IDEA will display an error message saying there’s an “Unhandled exception” and that your code will not compile. </p>
<p>When you bring up the context menu (press <strong>⌥⏎ </strong>on macOS or <strong>Alt+Enter</strong> on Windows/Linux), the IDE will suggest either adding the exception type to the method signature or wrapping the call to <code>runSecondMethod()</code> in a <code>try</code>/<code>catch</code> block.</p>
<img decoding="async" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-72.png" data-gif-src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-13.gif" alt="Add exception to method signature"/>
<p>Note that this is also true for exceptions that may occur in third-party code, such as <code>java.nio</code>. In the following screenshot, you’ll see the <code>readString</code> method may throw an <code>IOException</code>, and IntelliJ IDEA again suggests either adding the exception to the method signature (<code>throws IOException</code>) or handling the exception using a <code>try</code>/<code>catch</code> block.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1600" height="1114" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-73.png" alt="" class="wp-image-446297"/></figure>
<p>Checked exceptions and the <code>throws</code> syntax are great ways to annotate your code’s programming interface. By making information about potential exceptions available, any caller can decide what to do with the exception: ignore it by adding a <code>throws</code> to the method signature or <code>catch</code> the exception and handle it.</p>
<h2 class="wp-block-heading">Creating custom Java exception classes</h2>
<p>The Java platform comes with a large number of exception classes you can use to signal when an error occurs in your code. However, if you need a specific exception type that isn’t already available, you may need to implement your own.</p>
<p>You can write custom exception classes that inherit from <code>java.lang.Exception</code> so they are checked by the compiler, or <code>java.lang.RuntimeException</code> if you want your custom exception to be unchecked. Most often, though, custom exception classes will be checked and will inherit <code>java.lang.Exception</code>. It’s also common for exception class names to end in “Exception”.</p>
<p>Let’s create a custom exception that represents a banking overdraft. For example, when a user attempts to withdraw more money from their account than the available balance, this exception will be thrown. In its simplest form, the <code>OverdraftException</code> could look like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public class OverdraftException extends Exception {
public OverdraftException(String message) {
super(message);
}
}</pre>
<p>Throwing the <code>OverdraftException</code> would be fairly straightforward: all this exception needs is a <code>message</code> to describe what went wrong:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">throw new OverdraftException("Attempt to withdraw $100 with balance of $50.");</pre>
<p>When implementing custom exception classes, you may want to provide calling code with some additional information. For example, <code>OverdraftException</code> could make the available balance and attempted withdrawal amount accessible through their corresponding properties:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public class OverdraftException extends Exception {
private final BigDecimal amount;
private final BigDecimal balance;
public OverdraftException(BigDecimal amount, BigDecimal balance, String message) {
super(message);
this.amount = amount;
this.balance = balance;
}
public BigDecimal getAmount() {
return withdrawalAmount;
}
public BigDecimal getBalance() {
return balance;
}
}</pre>
<p>When throwing the exception, the amount and balance have to be passed into the <code>OverdraftException</code> constructor. Calling code can now use the exception message, or use the extra information when handling the exception, for example, to prompt the user for a lower withdrawal amount:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="java" data-enlighter-theme="wpcustom" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">try {
throw new OverdraftException(
BigDecimal.valueOf(100),
BigDecimal.valueOf(5),
"Attempt to withdraw $100 with balance of $50.");
} catch (OverdraftException ex) {
System.out.println(ex.getMessage());
System.out.println("Would you like to withdraw another amount?");
System.out.println("You can withdraw up to $" + ex.accountBalance);
// ...
}</pre>
<h2 class="wp-block-heading">Conclusion</h2>
<p>In this post, we’ve seen that exceptions in Java are used to indicate errors in code. When an exception occurs, the Java runtime stops the execution of the current method and passes the exception object to the nearest <code>catch</code> block that can handle it. To throw an exception, you can use the <code>throw</code> keyword followed by the exception object. </p>
<p>There are two types of exceptions in Java: checked and unchecked. Checked exceptions are checked at compile time and must be handled or declared to be thrown. Unchecked exceptions, on the other hand, are not checked at compile time.</p>
<p>Custom exception classes can be created by inheriting from the <code>Exception</code> class. These custom exceptions can provide additional information about the error. By communicating information about exceptions, the code’s programming interface becomes clearer, and callers can decide how to handle the exceptions.</p>
<p>Give it a <a href="https://www.jetbrains.com/idea/" target="_blank" rel="noopener">try today with IntelliJ IDEA</a>!</p>
]]></content:encoded>
</item>
<item>
<title>New Livestream: Building Intelligent Applications With Spring AI</title>
<link>https://blog.jetbrains.com/idea/2024/03/new-livestream-building-intelligent-applications-with-spring-ai/</link>
<dc:creator><![CDATA[Anna Rovinskaia]]></dc:creator>
<pubDate>Mon, 11 Mar 2024 09:31:25 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/02/Featured_Blog_1280x720-2x-3.png</featuredImage> <category><![CDATA[livestreams]]></category>
<category><![CDATA[intellij-idea]]></category>
<category><![CDATA[live-streams]]></category>
<category><![CDATA[webinars]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=451279</guid>
<description><![CDATA[Join us for a new IntelliJ IDEA Livestream episode with Dan Vega to explore Spring AI. Date: March 28, 2024 Time: 3:00–4:00 pm UTC REGISTER FOR THE LIVESTREAM Session abstract It’s impossible to spend a day in tech without hearing the words “artificial intelligence”. In this presentation, we will embark on a journey into the […]]]></description>
<content:encoded><![CDATA[
<p>Join us for a new <a href="https://info.jetbrains.com/idea-livestream-march28-2024.html" target="_blank" rel="noopener">IntelliJ IDEA Livestream episode</a> with Dan Vega to explore Spring AI.</p>
<p>Date: March 28, 2024</p>
<p>Time: 3:00–4:00 pm UTC</p>
<p align="center"><a class="jb-download-button" href="https://info.jetbrains.com/idea-livestream-march28-2024.html" target="_blank" rel="noopener">REGISTER FOR THE LIVESTREAM</a></p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="2560" height="1440" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Featured_Blog_1280x720-2x-3.png" alt="" class="wp-image-451302"/></figure>
<h2 class="wp-block-heading">Session abstract</h2>
<p>It’s impossible to spend a day in tech without hearing the words “artificial intelligence”. In this presentation, we will embark on a journey into the world of artificial intelligence (AI) specifically designed for beginners. We’ll start by introducing the fundamental concepts of AI, demystifying its jargon, and exploring its potential impact on our everyday lives.</p>
<p>We’ll also explore Spring AI, whose goal is to simplify the development of applications that incorporate artificial intelligence functionality, without introducing unnecessary complexity. We will cover the basics of setting up a Spring AI project, how to integrate it with existing Spring Boot applications, and how to use its various components to implement common AI-based tasks.</p>
<p>Whether you want to add chatbots to your app, generate recommendations, or analyze sentiments in text, Spring AI provides a streamlined and efficient approach to integrating these features. By the end of this talk, you will have a solid grasp of AI basics and how to incorporate them into your Spring applications using Spring AI.</p>
<h2 class="wp-block-heading">Asking questions</h2>
<p>Dan will try to answer all of your questions during the session. If we run out of time, we’ll publish the answers to any remaining questions in a follow-up blog post.</p>
<h2 class="wp-block-heading">Your speaker and host</h2>
<h2 class="wp-block-heading">Speaker</h2>
<div class="about-author ">
<div class="about-author__box">
<div class="row">
<div class="about-author__box-img">
<img decoding="async" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Dan-Vega.png" alt="" loading="lazy">
</div>
<div class="about-author__box-text">
<h4>Dan Vega</h4>
<p><!-- wp:paragraph --></p>
<p><a href="https://twitter.com/therealdanvega" target="_blank" rel="noopener">Dan Vega</a> is a Java Champion and Spring Developer Advocate at Broadcom. He’s been developing software for the web for over 23 years, and his superpower is problem-solving. Dan is a blogger, YouTuber, course creator, podcaster, and speaker. He’s a lifelong learner, and his passion is sharing his knowledge with the developer community. Dan lives near Cleveland, Ohio, with his beautiful wife and two daughters. When he isn’t writing code or teaching, he enjoys spending time with his family, lifting weights, running, or reading a good book.<br />
<!-- /wp:paragraph --></p>
</div>
</div>
</div>
</div>
<h2 class="wp-block-heading">Host</h2>
<div class="about-author ">
<div class="about-author__box">
<div class="row">
<div class="about-author__box-img">
<img decoding="async" src="https://blog.jetbrains.com/wp-content/uploads/2022/11/Mala-Gupta-e1595919910139-edited.jpeg" alt="" loading="lazy">
</div>
<div class="about-author__box-text">
<h4>Mala Gupta</h4>
<p><!-- wp:paragraph --></p>
<p>A Java Champion and JUG leader, <a href="https://twitter.com/eMalaGupta" target="_blank" rel="noopener">Mala</a> has authored multiple books with Manning, Packt, and O’Reilly Publications. She has more than two decades of experience in the software industry and is a regular speaker at industry conferences around the world. She has been actively supporting Java certification as a path to career advancement.</p>
<p><!-- /wp:paragraph --></p>
</div>
</div>
</div>
</div>
<p>Happy developing!</p>
]]></content:encoded>
</item>
<item>
<title>Drop the Baggage: Use ‘_’ for Unnamed Local Variables and Patterns in Java 22</title>
<link>https://blog.jetbrains.com/idea/2024/03/drop-the-baggage-use-_-for-unnamed-local-variables-and-patterns-in-java-22/</link>
<dc:creator><![CDATA[Mala Gupta]]></dc:creator>
<pubDate>Fri, 08 Mar 2024 11:33:32 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/03/ij-release-featured_blog_1280x720.png</featuredImage> <category><![CDATA[idea]]></category>
<category><![CDATA[java]]></category>
<category><![CDATA[intellijidea]]></category>
<category><![CDATA[java22]]></category>
<category><![CDATA[whatisnew]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=448606</guid>
<description><![CDATA[How would you feel if you tried to understand a code snippet, only to realize that some of the variables you were trying to make sense of, were never used? This could be due to the programming syntax constraints, or an oversight as a result of changes to a codebase over time. Would you like […]]]></description>
<content:encoded><![CDATA[<p>How would you feel if you tried to understand a code snippet, only to realize that some of the variables you were trying to make sense of, were never used? This could be due to the programming syntax constraints, or an oversight as a result of changes to a codebase over time. Would you like it if there was a way to mark such unused variables in the code, not via comments, but by using a language constraint (because real developers don’t write comments)? Also, what happens if a maintainer uses these unused variables in a way they were not supposed to be? Errors, maybe?</p>
<p>Starting Java 22, using <a href="https://openjdk.org/jeps/456" target="_blank" rel="noopener">Unnamed Variables & Patterns</a> you can mark unused local variables, patterns and pattern variables to be ignored, by replacing their names (or their types and names) with an underscore, that is, <code>_</code>. Since such variables and patterns no longer have a name, they are referred to as Unnamed variables and patterns. Ignoring unused variables would reduce the time and energy anyone would need to understand a code snippet. In the future, this could prevent errors :-). This language feature doesn’t apply to instance or class variables.</p>
<p>Are you wondering if replacing unused variables with <code>_</code> is always a good idea, or do they imply code smells and should you consider refactoring your codebase to remove them? Those are good questions to ask. I’ll answer all these questions in the blog post, including how to spot unused local variables.</p>
<p>Before diving deep into the details, let’s take a quick look at one of the examples.</p>
<h2>A quick example</h2>
<p>The following gif gives a sneak peek into how an unused local variable, connection, is detected by IntelliJ IDEA, and could be replaced with an underscore, that is, <code>_</code>.</p>
<figure class="wp-block-image"><img decoding="async" class="wp-image-16062" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/unused-variable-trailer.gif" alt="" /></figure>
<p>The modified code shown in the preceding gif makes it clear that the local variable defined in the try-with-resources statement is unused, making it concise and easier to understand.</p>
<p>Before we discuss any further details, the next section includes basic IntelliJ IDEA Project Configuration you’d need for working with this feature in IntelliJ IDEA. If you are already familiar with it, feel free to skip to the next section.</p>
<h2>IntelliJ IDEA Configuration</h2>
<p>Java 22 support is available in <a href="https://www.jetbrains.com/idea/nextversion/" target="_blank" rel="noopener">IntelliJ IDEA 2024.1 EAP</a>. The final release of this version is planned for March 2024.</p>
<p>In your Project Settings, set the SDK to Java 22. For the language level, select ‘22 – Unnamed variables and patterns’ on both the Project and Modules tab, as shown in the below settings screenshot:</p>
<figure class="wp-block-image"><img decoding="async" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/config1.png" alt="" /></figure>
<p>Let’s start by talking about situations where an unused variable can’t be deleted from your codebase for some reason.</p>
<h2>Unused variables that can’t be dropped</h2>
<p>Local variables remain unused in some code snippets; but you might not be able to delete them. This could happen due to the language constraints or you might be using the side effect of those variables. In this section, I’ll talk about the use cases where deleting an unused variable is either not possible or not recommended. In such cases, replacing them with an unnamed variable, that is, <code>_</code>, would be a good way to make it obvious and clear. Unnamed variables can’t be used – they can’t be passed to methods or assigned values.</p>
<p>Let’s talk about a sample code in which pattern variables are unused in a switch expression.</p>
<h3>1. Unused Patterns and Pattern variables in switch constructs</h3>
<p>Imagine you defined a sealed interface, say, <code>GeometricShape</code>, and records to represent shapes, such as, <code>Point</code>, <code>Line</code>, <code>Triangle</code>, <code>Square</code>, as shown in the following code:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
sealed interface GeometricShape {}
record Point ( int x,
int y) implements GeometricShape { }
record Line ( Point start,
Point end) implements GeometricShape { }
record Triangle( Point pointA,
Point pointB,
Point PointC) implements GeometricShape { }
record Square ( Point pointA,
Point pointB,
Point PointC,
Point pointD) implements GeometricShape { }</pre>
<p>Now assume you need a method that accepts an instance of <code>GeometricShape</code> and returns its area. Since <code>Point</code> and a <code>Line</code> are considered one-dimensional shapes, they wouldn’t have an area. Following is one of the ways to define such method that calculates and returns area:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
int calcArea(GeometricShape figure) {
return switch (figure) {
case Point (int x, int y) -> 0;
case Line (Point a, Point b) -> 0;
case Triangle (Point a, Point b, Point c) -> areaTriangle(a, b, c);
case Square (Point a, Point b, Point c, Point d) -> areaSquare (a, b, c, d);
};
}</pre>
<p>In the previous example, the patterns <code>int x</code>, <code>int y</code>, <code>Point a</code> and <code>Point B</code> (for case label Line) remain unused as detected by IntelliJ IDEA. These could be replaced by an <code>_</code>. Also, since all the record components of the case Point remain unused, it could be replaced as <code>Point _</code>. This could also allow us to merge the first and second case labels. All of these steps are shown in the following gif:</p>
<figure class="wp-block-image"><img decoding="async" class="wp-image-16062" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/unused-pattern-variables1.gif" alt="" /></figure>
<p>Here’s the modified code for your reference:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
int calcArea(GeometricShape figure) {
return switch (figure) {
case Point _, Line _ -> 0;
case Triangle (Point a, Point b, Point c) -> areaTriangle(a, b, c);
case Square (Point a, Point b, Point c, Point d) -> areaSquare (a, b, c, d);
};
}</pre>
<p>In the preceding example, you can’t delete the pattern variables even if they are unused. The code must include the cases when the instance passed to the method <code>calcArea()</code> is of type <code>Point</code> and <code>Line</code>, so that it could return 0 for them.</p>
<h3>2. Unused Patterns or variables with nested records</h3>
<p>This feature also comes in quite handy for nested records with multiple unused patterns or pattern variables, as demonstrated using the following example code:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
record Name (String fName, String lName) { }
record PhoneNumber(String areaCode, String number) { }
record Country (String countryCode, String countryName) { }
record Passenger (Name name,
PhoneNumber phoneNumber,
Country from,
Country destination) { }
public class GeoMaps {
boolean checkFirstNameAndCountryCodeAgain (Object obj) {
if (obj instanceof Passenger(Name (String fName, _),
_,
_,
Country (String countryCode, _) )) {
if (fName != null && countryCode != null) {
return fName.startsWith("Simo") && countryCode.equals("PRG");
}
}
return false;
}
}</pre>
<p>In the preceding code, since the if condition in the method <code>checkFirstNameAndCountryCodeAgain</code> uses only two pattern variables, others could be replaced using <code>_</code>; it reduced the noise in the code too.</p>
<h3>3. Requirements change, but you need side effects of constructs like an enhanced for-loop</h3>
<p>Below is an example of sample code that prints elements of an array to the console in an animated manner (you don’t need to focus on the code logic. Just note that the local variable <code>num</code> is used within the for loop via a call to <code>System.out.println()</code>):</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
void animateArray() {
int[] numbers = {9, 7, 3, 8, 5, 2, 5};
int totalTimePerLine = 1000;
int count = 0;
// array element at first position is printed once,
// second is printed twice and so on
for (int num : numbers) {
count++;
// each line takes a total of ‘totalTimePerLine’ to print
int delayPerNumber = totalTimePerLine / count;
for (int i = 0; i < count; i++) {
System.out.print(num);
try {
Thread.sleep(delayPerNumber);
} catch (InterruptedException e) {
System.out.println(e);
}
}
System.out.println();
}
}</pre>
<p>Imagine, after some time, the author of the previous code modifies it to print a fixed number, say, 0, instead of the array values. In this case, the code might no longer use the local loop variable <code>num</code> and it might change to the following (showing only the changed line of code for conciseness):</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
void animateArray() {
//..code
System.out.print(0); // Remove the only usage of the variable num
//..code
}</pre>
<p>Anyone reading the method <code>animateArray()</code> might not be able to know that at the first glance or read. However, the variable <code>num</code> can’t be deleted, because it is defined as a loop variable in the enhanced for loop.</p>
<p>Shortening the variable name to <code>n</code>, or using an implicit type, that is, <code>var</code>, instead of <code>num</code>, won’t help much. A human must read a code snippet at least once to determine that a variable is unused. Time gone that would never come back!</p>
<p>Also, it doesn’t help much if you replace this enhanced for loop with the indexed loop, since the indexed loop variable wouldn’t be used in the code too. In this case, the code is more interested in executing the code multiple times in a loop, rather than using the loop index. One of the simplest ways would be to announce that a variable is unused, so it could be ignored by folks reading this code.</p>
<p>IDEs like IntelliJ IDEA were always able to determine this issue via their static code analysis (unused variables). With this new language feature, it can also suggest that you could replace an unused variable with an _. Here’s a gif that shows this:</p>
<figure class="wp-block-image"><img decoding="async" class="wp-image-16062" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/unused-variable1.gif" alt="" /></figure>
<p>The next example talks about another approach to address the issue of an unused local variable.</p>
<h3>4. Unused parameters in exception handlers; whose signature can’t be modified</h3>
<p>What happens when you use a method, say, <code>Thread.sleep()</code> that throws a checked exception, such as, <code>InterruptedException</code>? You must either handle the exception by enclosing the call to <code>Thread.sleep()</code> in an exception handler, or, add the <code>throws</code> clause to the method in which <code>Thread.sleep()</code> is called. In short, either you handle the exception yourself, or request the caller of this method to handle it.</p>
<p>Let’s consider handling an exception via a catch handler which receives an instance of the thrown exception. Though the information passed via the exception instance is useful, imagine a developer doesn’t use it, and writes their code as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
try {
Thread.sleep(delayPerNumber);
} catch (InterruptedException e) {
System.out.println("Sleep mode interrupted");
}</pre>
<p>In this case, the local variable <code>e</code> is unused. IntelliJ IDEA can determine it and suggest it to be replaced using <code>_</code>. You could also use the problems window to access the issues in your code base and apply the suggestions, as shown below:</p>
<figure class="wp-block-image"><img decoding="async" class="wp-image-16062" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/unused-variable2.gif" alt="" /></figure>
<h3>5. Unused auto-closeable resources in try-with-resources statements</h3>
<p>It is common to see code similar to the following which checks DB connection parameters, database server availability, or network issues (for hosted databases) by establishing a connection to a database. It logs success or warning messages, but doesn’t use the Connection instance, <code>connection</code>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
void checkConnection(String url, String user, String pwd) {
try (Connection connection = DriverManager.getConnection(url, user, pwd)) {
logger.info(STR."""
DB Connection successful
URL = \{url}
usr = \{user}
pwd = \{pwd}""");
} catch (SQLException e) {
logger.warning(e.toString());
}
}</pre>
<p>The preceeding code is a good candidate to replace the local variable <code>connection</code> within the try-with-resources, with an underscore, as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
void checkConnection(String url, String user, String pwd) {
try (Connection _ = DriverManager.getConnection(url, user, pwd)) {
logger.info(STR."""
DB Connection successful
URL = \{url}
usr = \{user}
pwd = \{pwd}""");
} catch (SQLException e) {
logger.warning(e.toString());
}
}</pre>
<p>With the examples in this section, I highlighted how to address the unused local variables, patterns and variables in your code, when they can’t be dropped from your code.</p>
<p>You could apply a similar approach to other unused local variables that are defined within methods, including constructors, instance and static initialisers, if, for or while constructs, and passed as method parameters.</p>
<p>Now, let’s walk through a few examples where unused variables could imply a code smell.</p>
<h2>When unused variables could be a code smell</h2>
<p>You might need tests or experience to determine if the unused variables should be addressed in a way other than replacing their name using an underscore, that is, <code>_</code>.</p>
<h3>1. Unused lambda parameter</h3>
<p>Imagine you define the following code in which one of the lambda parameters, that is, x, is used and y is not:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
BiFunction<Integer, Integer, Integer> add = (x, y) -> x + 0;</pre>
<p>The previous code seems to be a code smell. The name of the method seems to suggest that it returns the sum of the values passed to it. In this case the corrective step should be to modify it as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
BiFunction<Integer, Integer, Integer> add = (x, y) -> x + y;</pre>
<p>The preceding code is a simple example for demo purposes. When you refactor any code in your code, back them up using sufficient tests, so that the refactored code generates the same output.</p>
<p>Also, the preceding code example doesn’t imply that all unused method parameters are a code smell (as discussed previously in this blog post).</p>
<h3>2. Methods with multiple responsibilities</h3>
<p>As a good programming practice, a method should have a single responsibility. However, a method might not adhere to this practice. For instance, in the following code, the method <code>generateRandomNumbers()</code> prints a random number to the console, before returning it:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
public class RandomNumber {
public static void main(String[] args) {
var randomNumber = generateRandomNumber();
System.out.println(randomNumber);
}
public static int generateRandomNumber() {
int random = new Random().nextInt(100);
System.out.println(random);
return random;
}
}
<code></code></pre>
<p>On execution, a user might see two outputs for the same random number, due to the two <code>println()</code> method calls – one in the method <code>generateRandomNumbers()</code> and the other in method <code>main()</code>. What if another developer deletes the call to the <code>println()</code> statement in method <code>main()</code>. In this case, the local variable <code>radomNumber</code> becomes unused, as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
public static void main(String[] args) {
var randomNumber = generateRandomNumber();
}</pre>
<p>Should you replace the name of variable randomNumber using an <code>_</code>? Nah! This looks like a code smell since the method <code>generateRandomNumber()</code> includes code to accomplish unrelated tasks – returning a random number and printing a random number to the console. A better solution would be to refactor your code, extracting the code to print a number to another method, so that <code>generateRandomNumber()</code> only generates a random number:</p>
<figure class="wp-block-image"><img decoding="async" class="wp-image-16062" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/unused-variable3.gif" alt="" /></figure>
<p>Here’s the final code for your reference:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="">
public class RandomNumber {
public static void main(String[] args) {
printNumberToConsole(generateRandomNumber());
}
public static int generateRandomNumber() {
return new Random().nextInt(100);
}
private static void printNumberToConsole(int random) {
System.out.println(random);
}
}</pre>
<p>Having test methods to ensure that your method continues to serve their primary purpose is a good programming practice. I didn’t include that part specifically since it would take the blog post in a tangent.</p>
<p>In this blog post, I didn’t cover an extensive list of use cases where an unused local variable could be a code smell.</p>
<h2>Summary</h2>
<p>As the name suggests, unnamed variables are local to a code construct, they don’t have a name, and they are represented by using an underscore, that is, <code>_</code>. They can’t be passed to methods, or used in expressions.</p>
<p>By replacing unused local variables in a code base with <code>_</code> their intention is conveyed very clearly. It clearly communicates to anyone reading a code snippet that the variable is not used elsewhere. Until now, this intention could only be communicated via comments, which, unfortunately, all developers don’t write.</p>
<p>A production feature in Java 22, you could use this feature in your production code, without any fears of it being changed in one of the future versions.</p>
]]></content:encoded>
</item>
<item>
<title>IntelliJ IDEA 2024.1 Goes Beta!</title>
<link>https://blog.jetbrains.com/idea/2024/03/intellij-idea-2024-1-beta/</link>
<dc:creator><![CDATA[Maria Kosukhina]]></dc:creator>
<pubDate>Thu, 07 Mar 2024 20:17:19 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/03/Blog_Featured_image_IntelliJIDEA-2024.1-Beta.png</featuredImage> <category><![CDATA[eap]]></category>
<category><![CDATA[2024-1-eap]]></category>
<category><![CDATA[intellij-idea-2024-1]]></category>
<category><![CDATA[intellij-idea-2024-1-eap]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=454383</guid>
<description><![CDATA[The 2024.1 Beta version of IntelliJ IDEA has arrived! You can get the latest build from our website, through the free Toolbox App, or via snaps for Ubuntu. Download IntelliJ IDEA 2024.1 Beta Our latest build integrates all of the significant updates introduced during the IntelliJ IDEA 2024.1 Early Access Program. Here’s a short recap […]]]></description>
<content:encoded><![CDATA[
<p>The 2024.1 Beta version of IntelliJ IDEA has arrived!</p>
<p>You can get the latest build from our <a href="https://www.jetbrains.com/idea/nextversion/" target="_blank" rel="noopener">website</a>, through the free <a href="https://www.jetbrains.com/toolbox-app/" target="_blank" rel="noopener">Toolbox App</a>, or via snaps for Ubuntu.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1280" height="720" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/Blog_Featured_image_IntelliJIDEA-2024.1-Beta.png" alt="" class="wp-image-454484"/></figure>
<p align="center"><a class="jb-download-button" href="https://www.jetbrains.com/idea/nextversion/" target="_blank" rel="noopener">Download IntelliJ IDEA 2024.1 Beta</a></p>
<p>Our latest build integrates all of the significant updates introduced during the IntelliJ IDEA 2024.1 Early Access Program. Here’s a short recap of the new features aimed at enhancing various aspects of your development workflows: </p>
<ul>
<li>Support for Java 22 functionalities</li>
<li>Full line code completion</li>
<li>A revamped <em>Terminal</em> tool window</li>
<li>Conditional statements coverage</li>
<li>Sticky lines in the editor </li>
<li>Earlier availability of IDE features during project indexing </li>
<li>In-editor code reviews</li>
<li>Enriched support for GitHub Actions</li>
<li>Improved workflow for logs</li>
<li>Inline breakpoints for multiple statements </li>
<li>Opening speed boost for Maven projects</li>
<li>Support for OpenRewrite </li>
<li>WireMock server support </li>
<li>And many more </li>
</ul>
<p></p>
<p>To learn more about these and other improvements, check out the posts tagged under the <a href="https://blog.jetbrains.com/idea/tag/intellij-idea-2024-1-eap/">IntelliJ IDEA 2024.1 EAP</a> section on our blog.</p>
<p>Although the addition of new features has finished and the team is now refining those included in v2024.1, we still have updates to share. Take a closer look!</p>
<h2 class="wp-block-heading">Java </h2>
<h3 class="wp-block-heading">Revamped <em>Detected Conflicts</em> dialog </h3>
<p>In v2024.1, we’ve revamped the <em>Detected Conflicts</em> dialog to improve the user experience and readability. Now, the code context mirrors the editor, giving you clearer insight into conflicts. We’ve optimized text display, and the IDE now automatically saves window size adjustments for future use. We’ve also updated the buttons and their behavior to streamline the refactoring workflow. The dialog is now fully accessible via the keyboard, meaning that you can use shortcuts and arrows keys for seamless interaction. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1600" height="640" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-11.png" alt="" class="wp-image-454395"/></figure>
<h3 class="wp-block-heading">Rename refactoring inlay hint</h3>
<p>To make the renaming process easier and more intuitive, we’ve implemented a new inlay hint appearing atop the changed code element. To update all references to the new version within the codebase, you only need to click on the hint and confirm the change. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-1.gif" alt="" class="wp-image-454384"/></figure>
<h2 class="wp-block-heading">Kotlin</h2>
<h3 class="wp-block-heading">Official Kotlin code style propagated on all projects</h3>
<p>Starting from version 2024.1, the IDE uniformly applies the official Kotlin style guide as the default option for all projects, unless explicitly specified otherwise. If your existing project utilizes an older code style without explicit configuration, the IDE will automatically switch to the Kotlin Coding Conventions code style and provide a notification to alert you of this change. To prevent any undesired formatting alterations, we recommend familiarizing yourself with this <a href="https://kotlinlang.org/docs/code-style-migration-guide.html#migration-to-a-new-code-style-discussion" target="_blank" rel="noopener">code style migration guide</a>. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-12.png" alt="" class="wp-image-454417"/></figure>
<h3 class="wp-block-heading">Static imports preserved on copy-pasting</h3>
<p>In version 2024.1, we’ve introduced a long-awaited enhancement to the copy and paste functionality, particularly valuable when handling nested objects, enums, and Java static imports. The IDE now accurately preserves static imports, ensuring they are transferred exactly the same way as they appear in the source code.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-2.gif" alt="" class="wp-image-454406"/></figure>
<h2 class="wp-block-heading">Frameworks and technologies </h2>
<h3 class="wp-block-heading">Enhanced Terraform support</h3>
<p>In the upcoming 2024.1 update, we’re introducing significant improvements in support for infrastructure as code development for Terraform, aimed at developers, site reliability engineers (SREs), and DevOps. This update includes a series of new features and enhancements to simplify the process of creating, managing, and scaling your infrastructure. </p>
<h4 class="wp-block-heading">Suggestion to run <code>terraform init</code></h4>
<p>To initialize the working directory with Terraform code files, we must first run <code>terraform init</code>. This is often overlooked, leading to error messages from Terraform itself, as well as incomplete code autocompletion and only partial display of documentation. To avoid this, the IDE now explicitly suggests running <code>terraform init</code>.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-3.gif" alt="" class="wp-image-454428"/></figure>
<h4 class="wp-block-heading">Support for third-party providers from the Terraform Registry</h4>
<p>IntelliJ IDEA now offers extended code completion capabilities for more than 3,900 third-party Terraform providers, making it easier for developers to write code efficiently. Additionally, you’ll find the latest documentation for each of these providers, along with their specific versions, directly within the IDE. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-6.gif" alt="" class="wp-image-454975"/></figure>
<p>This allows you to explore new Terraform providers and learn their capabilities faster – all without leaving the IDE.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-4.gif" alt="" class="wp-image-454443"/></figure>
<h4 class="wp-block-heading">Terraform template language (tftpl) support</h4>
<p>In our latest update, we’re excited to unveil support for Terraform’s template language (tftpl), enhancing your workflow with configuration files, scripts, or any program code, such as web server, network, or service configurations. Templating just got easier! Now, you can dynamically fill in values within your templates at runtime, streamlining the process of rendering templates for specific uses.</p>
<p>By default, files with the <code>*.tftpl</code> extension are recognized as plain text with templating capabilities. However, if your requirements are more specific, we’ve added the option to seamlessly integrate with your preferred programming language. Simply right-click the file, select <em>Change plain text template to data language,</em> and choose the language that matches your <code>.tftpl</code> files. This feature is designed to enhance your templating experience, making it more flexible and powerful than ever before.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-13.png" alt="" class="wp-image-454471"/></figure>
<p><a href="https://developer.hashicorp.com/terraform/language/functions/templatefile" target="_blank" rel="noopener">Terraform’s template language</a> not only supports variable templating and control flow elements, it also encompasses lists and maps, along with the ability to generate JSON and YAML formats.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-5.gif" alt="" class="wp-image-454461"/></figure>
<h2 class="wp-block-heading">Build tools </h2>
<h3 class="wp-block-heading">Support for Maven Shade Plugin renaming workflow</h3>
<p>With the release of IntelliJ IDEA 2024.1, we’re adding long-awaited support for Maven Shade Plugin renaming. Now, IntelliJ IDEA is aware of the renaming workflow and seamlessly manages these scenarios to ensure accurate code highlighting and navigation when working with your shaded JAR and its dependencies.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/Shade_2024.1.png" alt="" class="wp-image-454496"/></figure>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/Shade_2023.3.png" alt="" class="wp-image-454507"/></figure>
<h3 class="wp-block-heading">Project Maven repositories in the <em>Maven</em> tool window</h3>
<p>To enhance its accessibility, the list of Maven repositories alongside their indexing status is now displayed in the <em>Maven</em> tool window, instead of its previous location within Maven settings.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-14.png" alt="" class="wp-image-454518"/></figure>
<h3 class="wp-block-heading"><br>Access source files directly from the <em>Quick Documentation</em> popup</h3>
<p>We’ve updated the <em>Quick Documentation</em> feature to easily download sources. Now, when you’re viewing documentation for a library or dependency and need to access its source code, you can easily do so with one press of the <em>F1</em> key. The updated popup provides a direct link to download the required source files, streamlining your workflow. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-15.png" alt="" class="wp-image-454529"/></figure>
<h3 class="wp-block-heading">Gradle version support update</h3>
<p>Starting from this version, IntelliJ IDEA no longer supports projects using Gradle versions older than 4.5. This means that the IDE will not perform Gradle sync for projects with unsupported Gradle versions.</p>
<h2 class="wp-block-heading">Version control systems </h2>
<h3 class="wp-block-heading">Visual indicators for pending GitHub updates</h3>
<p>We’ve introduced visual indicators to hint about pending updates within your code review workflow. When there are changes requiring your attention, a blue dot badge will appear on the tool window icon. Additionally, unseen pull requests will be marked with a blue dot, ensuring you don’t miss updates in your code review process.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/03/image-16.png" alt="" class="wp-image-454540"/></figure>
<h2 class="wp-block-heading">AI Assistant </h2>
<p>Beginning with the Beta version of IntelliJ IDEA 2024.1, AI Assistant has been unbundled and is now available as a separate <a href="https://plugins.jetbrains.com/plugin/22282-ai-assistant" target="_blank" rel="noopener">plugin</a>. This change is driven by the need to offer greater flexibility and control over your various preferences and requirements, enabling you to choose if and when you’d like to use AI-powered technologies in your working environments.</p>
<p>That’s a wrap! For the full list of updates in the latest build, please refer to the <a href="https://youtrack.jetbrains.com/articles/IDEA-A-2100661885/IntelliJ-IDEA-2024.1-Beta-241.14494.17-build-Release-Notes" target="_blank" data-type="link" data-id="https://youtrack.jetbrains.com/articles/IDEA-A-2100661885/IntelliJ-IDEA-2024.1-Beta-241.14494.17-build-Release-Notes" rel="noreferrer noopener">release notes</a>.</p>
<p>Our Early Access Program will be closing soon, so we encourage you to take your time testing out the new features and sharing your feedback with us. You can drop us a line in the comments below or reach out to us on <a href="https://twitter.com/intellijidea" data-type="link" data-id="https://twitter.com/intellijidea" target="_blank" rel="noopener">X (formerly Twitter)</a> – we’re always looking to benefit from your input. Finally, if you happen to spot any bugs, please report them using our <a href="https://youtrack.jetbrains.com/issues/IDEA" data-type="link" data-id="https://youtrack.jetbrains.com/issues/IDEA" target="_blank" rel="noopener">issue tracker</a>.</p>
<p>Stay tuned for more news next week!</p>
<p>Happy developing!</p>
]]></content:encoded>
</item>
<item>
<title>Java Annotated Monthly – March 2024</title>
<link>https://blog.jetbrains.com/idea/2024/03/java-annotated-monthly-march-2024/</link>
<dc:creator><![CDATA[Irina Mariasova]]></dc:creator>
<pubDate>Tue, 05 Mar 2024 08:29:50 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/03/java-annotated-featured_blog_1280x720.png</featuredImage> <category><![CDATA[java]]></category>
<category><![CDATA[news]]></category>
<category><![CDATA[java-annotated]]></category>
<category><![CDATA[spring]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=452418</guid>
<description><![CDATA[This month’s Java Annotated Monthly is packed with the latest Java news ahead of Java 22’s release in March. It’s also full of Kotlin updates, tutorials for Spring and Hibernate, and more. If all that wasn’t enough, there’s also a podcast featuring AI-generated music!  Simply put, it’s full of cool stuff for anyone interested in […]]]></description>
<content:encoded><![CDATA[
<p>This month’s Java Annotated Monthly is packed with the latest Java news ahead of Java 22’s release in March. It’s also full of Kotlin updates, tutorials for Spring and Hibernate, and more. If all that wasn’t enough, there’s also a podcast featuring AI-generated music! </p>
<p>Simply put, it’s full of cool stuff for anyone interested in tech. Let’s get started! </p>
<h2 class="wp-block-heading">Java News</h2>
<p>Java News Roundup <a href="https://www.infoq.com/news/2024/02/java-news-roundup-jan29-2024/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global" target="_blank" rel="noopener">1</a>, <a href="https://www.infoq.com/news/2024/02/java-news-roundup-feb05-2024/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global" target="_blank" rel="noopener">2</a>, <a href="https://www.infoq.com/news/2024/02/java-news-roundup-feb12-2024/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global" target="_blank" rel="noopener">3</a>, <a href="https://www.infoq.com/news/2024/02/java-news-roundup-feb19-2024/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global" target="_blank" rel="noopener">4</a> – All of the latest Java news is here. </p>
<p><a href="https://inside.java/2024/02/05/java-renaissance/" target="_blank" rel="noopener">Java Renaissance</a> – <a href="https://twitter.com/gsaab?lang=en" target="_blank" rel="noopener">Georges Saab</a> discusses the exciting developments brought by Java 21, highlighting a new wave of enthusiasm and prospects for the Java platform.</p>
<p><a href="https://www.infoq.com/news/2024/02/multi-file-program-launching/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global" target="_blank" rel="noopener">Simplifying Java Development: Introducing Multi-File Program Launching</a> – The new Java feature introduced in JEP 458 allows Java developers to run applications composed of multiple source code files directly, without needing a full project setup or explicit compilation. Get all of the details in this article. </p>
<p><a href="https://inside.java/2024/02/09/jdk-22-gc-updates/" target="_blank" rel="noopener">JDK 22 G1/Parallel/Serial GC changes</a> – <a href="https://tschatzl.github.io/about/" target="_blank" rel="noopener">Thomas Schatzl</a> presents the latest enhancements in JDK 22’s garbage collection, focusing on performance and efficiency improvements in G1, GC, and Parallel GC.</p>
<p><a href="https://inside.java/2024/02/10/voxxxeddaycern-java-21-and-beyond/" target="_blank" rel="noopener">Java 21 and Beyond: A Roadmap of Innovations</a> – <a href="https://inside.java/u/Ana-MariaMihalceanu/" target="_blank" rel="noopener">Ana-Maria Mihalceanu</a> discusses Java 21’s latest features, from String Templates to Generational ZGC. </p>
<p><a href="https://fosdem.org/2024/schedule/event/fosdem-2024-3255-virtual-thread-s-next-steps/" target="_blank" rel="noopener">Virtual Thread’s Next Steps</a> – In this talk, <a href="https://inside.java/u/AlanBateman/" target="_blank" rel="noopener">Alan Bateman</a> presents the ongoing enhancements to Virtual Threads, focusing on improvements in Java monitors, I/O, and other key areas for future JDK releases. He also outlines the next steps for developing this feature.</p>
<p><a href="https://inside.java/2024/02/18/java-language-update-early-2024-update/" target="_blank" rel="noopener">Java Language Update – Early 2024 Edition</a> – If you are searching for a comprehensive overview of the recent Java advancements and future developments, this article is for you. </p>
<p><a href="https://spring.io/blog/2024/02/15/a-bootiful-podcast-oracle-java-developer-advocate-nicolai-parlog-on-the" target="_blank" rel="noopener">A Bootiful Podcast: Oracle Java Developer Advocate Nicolai Parlog on the latest and greatest in Java</a> – In the podcast, Oracle Java Developer Advocate <a href="https://twitter.com/nipafx?lang=en" target="_blank" rel="noopener">Nicolai Parlog</a> discusses the latest developments and features in Java, providing insights and updates for the Java community. </p>
<h2 class="wp-block-heading">Java Tutorials and Tips</h2>
<p><a href="https://inside.java/2024/02/13/fosdem2024-ffm-api/" target="_blank" rel="noopener">Foreign Function & Memory API – A (quick) peek under the hood</a> – <a href="https://inside.java/u/MaurizioCimadamore/" target="_blank" rel="noopener">Maurizio Cimadamore </a>introduces the Foreign Function & Memory API in JDK 22, offering a simpler and more efficient alternative to JNI for accessing native libraries from Java.</p>
<p><a href="https://ionutbalosin.com/2024/02/jvm-performance-comparison-for-jdk-21/" target="_blank" rel="noopener">JVM Performance Comparison for JDK 21</a> – This article describes a series of Java Virtual Machine (JVM) benchmarks with a primary focus on top-tier Just-In-Time (JIT) compilers, such as C2 JIT, and Graal JIT. </p>
<p><a href="https://vladmihalcea.com/records-spring-data-jpa/" target="_blank" rel="noopener">How to use Java Records with Spring Data JPA</a> – In this article, <a href="https://vladmihalcea.com/" target="_blank" rel="noopener">Vlad Mihalcea</a> explains how to integrate Java Records with JPA entities using conversion methods for effective data management.</p>
<p><a href="https://foojay.io/today/foojay-podcast-43/" target="_blank" rel="noopener">Foojay Podcast #43: Modern Java Testing</a> – <a href="https://twitter.com/shelajev" target="_blank" rel="noopener">Oleg Šelajev</a>, <a href="https://twitter.com/doppleware" target="_blank" rel="noopener">Roni Dover</a>, <a href="https://twitter.com/jonas_grgt" target="_blank" rel="noopener">Jonas Geiregat</a>, and <a href="https://foojay.social/@frankdelporte" target="_blank" rel="noopener">Frank Delporte</a> discuss various testing-related topics including unit tests, test containers, flaky tests, and more. <strong> </strong></p>
<p><a href="https://blog.joda.org/2024/02/pattern-match-optional-in-java-21.html" target="_blank" rel="noopener">Pattern match Optional in Java 21</a> – <a href="https://www.blogger.com/profile/01454237967846880639" target="_blank" rel="noopener">Stephen Colebourne</a> describes a trick to get pattern matching on Optional in Java 21. Find out which one from this article.</p>
<p><a href="https://inside.java/2024/02/01/newscast-62/" target="_blank" rel="noopener">Java 22 Previews Statements Before super(…) and this(…) – Inside Java Newscast #62</a> – <a href="https://inside.java/u/NicolaiParlog/" target="_blank" rel="noopener">Nikolai Parlog</a> shows how JEP 447 allows previewing statements before the explicit constructor invocation.</p>
<p><a href="https://www.infoq.com/news/2024/02/java-enhances-pattern-matching/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global" target="_blank" rel="noopener">Java Enhances Pattern Matching with Primitive Type Support in JEP 455</a> – Find out how </p>
<p>JEP 455 enhances Java’s pattern matching by supporting primitive types in instanceof and switch, making code more readable and reducing conversion errors.</p>
<p><a href="https://foojay.io/today/sorting-text-in-java-how-complicated-can-it-be/" target="_blank" rel="noopener">Sorting Text in Java, How Complicated Can It Be?</a> – Sorting text should be easy, as String implements the Comparable interface. In this article, <a href="https://foojay.io/today/sorting-text-in-java-how-complicated-can-it-be/" target="_blank" rel="noopener">Anthony Goubard</a> demonstrates that it can be more complicated than that.</p>
<p><a href="https://inside.java/2024/02/07/automatic-differentiation-java-code-reflection/" target="_blank" rel="noopener">Automatic differentiation of Java code using Code Reflection</a> – In this article, you will find out what automatic differentiation is, why it’s useful, and how we can use Code Reflection to help implement automatic differentiation of Java methods.</p>
<p><a href="https://foojay.io/today/builders-withers-and-records-javas-path-to-immutability/" target="_blank" rel="noopener">Builders, Withers, and Records: Java’s path to immutability</a> – Immutable objects are easier to maintain, lead to fewer errors, and are multi-thread friendly. In this article, <a href="https://foojay.io/today/author/jonathan-vila/" target="_blank" rel="noopener">Jonathan Vila</a> talks about two different approaches to creating objects in Java: builders and withers, typically used in the context of immutable objects, along with Java records.</p>
<p><a href="https://openjdk.org/projects/babylon/articles/linq" target="_blank" rel="noopener">Emulating C# LINQ in Java using Code Reflection</a> – This article explores how to emulate C#’s Language Integrated Query (LINQ) in Java using Code Reflection.</p>
<p><a href="https://inside.java/2024/02/08/jepcafe22/" target="_blank" rel="noopener">Data Oriented Programming in Java 21, Solving the Countdown game – JEP Cafe #22</a> – In this JEP Café session, <a href="https://inside.java/u/JosePaumard" target="_blank" rel="noopener">José Paumard</a> demonstrates the latest JDK enhancements supporting Data-Oriented Programming, such as Records, Sealed Types, and Pattern Matching, and new Stream API features like mapMulti(). These tools are shown through the medium of the Countdown game.</p>
<p><a href="https://foojay.io/today/top-most-detected-issues-in-java-projects/" target="_blank" rel="noopener">Top Most Detected Issues in Java Projects</a> – Check out a list of the ten most common issues detected in Java projects according to <a href="https://foojay.io/today/author/jonathan-vila/" target="_blank" rel="noopener">Jonathan Vila</a>. Even seemingly minor issues can significantly affect software in terms of security, performance, and maintenance, so don’t ignore them. </p>
<p><a href="https://inside.java/2024/02/15/newscast-63/" target="_blank" rel="noopener">Does Java 22 Kill Build Tools? – Inside Java Newscast #63</a> – Java 22 brings multi-source-file execution to the platform. It allows us to run programs consisting of multiple source files and even dependencies with just a simple Java command. Will it be beneficial for seasoned developers and beginners? Find out in <a href="https://inside.java/u/NicolaiParlog" target="_blank" rel="noopener">Nicolai Parlog</a>’s Inside Java Newscast. </p>
<p><a href="https://www.infoq.com/presentations/aws-lambda-arch/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global" target="_blank" rel="noopener">Presentation: AWS Lambda Under the Hood</a> – <a href="https://www.linkedin.com/in/mikevdanilov/" target="_blank" rel="noopener">Mike Danilov</a> covers how Lambda is built and how they had to modify the architecture to support 10GiB payloads.</p>
<p><a href="https://tschatzl.github.io/2024/02/06/jdk22-g1-parallel-gc-changes.html" target="_blank" rel="noopener">JDK 22 G1/Parallel/Serial GC changes</a> – <a href="https://tschatzl.github.io/about/" target="_blank" rel="noopener">Thomas Schatzl</a> presents the improvements in G1, Parallel, and Serial garbage collectors, which enhance performance and reduce pause times. </p>
<p><a href="https://mydeveloperplanet.com/2024/02/07/how-to-embed-documents-for-semantic-search/" target="_blank" rel="noopener">How to Embed Documents for Semantic Search</a> – In this post, you’ll get a closer look at how to embed documents for use in a semantic search. Through the provided examples, you’ll discover how embedding impacts search results and how to enhance them.</p>
<p><a href="https://www.infoq.com/presentations/netflix-java/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global" target="_blank" rel="noopener">Presentation: How Netflix Really Uses Java</a> – <a href="https://www.linkedin.com/in/paulb01/" target="_blank" rel="noopener">Paul Bakker</a> demonstrates how Netflix is using Java, emphasizing the use of microservices, RxJava, Hystrix, and Spring Cloud.</p>
<p><a href="https://pretius.com/blog/java-21-features/" target="_blank" rel="noopener">Java 21 features: A detailed look at the most important changes in the new LTS release</a> – <a href="https://pretius.com/blog?user=7189" target="_blank" rel="noopener">Arkadiusz Rosłoniec</a> demonstrates the most exciting Java 21 features and tries to predict their significance.</p>
<h2 class="wp-block-heading">Languages, Frameworks, Libraries, and Technologies</h2>
<p>This Week in Spring <a href="https://spring.io/blog/2024/02/07/this-week-in-spring-february-6th" target="_blank" rel="noopener">1</a>, <a href="https://spring.io/blog/2024/02/13/this-week-in-spring-february-14th-2024" target="_blank" rel="noopener">2</a>, <a href="https://spring.io/blog/2024/02/20/this-week-in-spring-february-20th-2024" target="_blank" rel="noopener">3</a>, <a href="https://spring.io/blog/2024/02/28/this-week-in-spring-february-27th-2024" target="_blank" rel="noopener">4</a> – Catch up on all of the latest Spring updates from February.</p>
<p><a href="https://spring.io/blog/2024/02/01/a-bootiful-podcast-gunnar-morling-on-the-1brc-challenge-and-taking-java-to" target="_blank" rel="noopener">A Bootiful Podcast: Gunnar Morling on the 1BRC challenge and taking Java to BLAZING fast performance territory</a> – <a href="https://twitter.com/gunnarmorling" target="_blank" rel="noopener">Gunnar Morling</a> and <a href="https://twitter.com/starbuxman" target="_blank" rel="noopener">Josh Long</a> discuss how the 1BRC challenge significantly improved Java’s performance metrics. </p>
<p><a href="https://questdb.io/blog/billion-row-challenge-step-by-step/" target="_blank" rel="noopener">The Billion Row Challenge (1BRC) – Step-by-step from 71s to 1.7s</a> – <a href="https://twitter.com/mtopolnik" target="_blank" rel="noopener">Marko Topolnik</a> shares a detailed account of the Billion Row Challenge, showcasing how he dramatically improved data processing from 71 seconds to 1.7 seconds. That said, at 2.3 seconds, his official 1BRC result wasn’t quite as good. </p>
<p><a href="https://robcasloz.github.io/blog/2024/02/14/when-should-a-compiler-expand-garbage-collection-barriers.html" target="_blank" rel="noopener">When should a compiler expand garbage collection barriers?</a> – This article describes a case in a production compiler where <a href="https://robcasloz.github.io/" target="_blank" rel="noopener">Roberto Castañeda Lozano</a> had to reduce the amount of program information fed to the compiler instead of taking the more traditional approach of exposing it. </p>
<p><a href="https://www.petrikainulainen.net/programming/testing/writing-integration-tests-for-spring-boot-web-applications-build-setup/" target="_blank" rel="noopener">Writing Integration Tests for Spring Boot Web Applications: Build Setup</a> – This blog post explains how to set up a Maven build for Spring Boot integration tests. By creating a customized build, you can easily control the project’s build process.</p>
<p><a href="https://spring.io/blog/2024/02/08/spring-tips-spring-ai" target="_blank" rel="noopener">Spring Tips: Spring AI</a> – Have a look at the new Spring AI project, which provides convenient integrations with LLMs and tools to support the RAG (retrieval-augmented generation) pipeline. </p>
<p><a href="https://blog.jooq.org/an-efficient-way-to-check-for-existence-of-multiple-values-in-sql/" target="_blank" rel="noopener">An Efficient Way to Check for Existence of Multiple Values in SQL</a> – <a href="https://twitter.com/lukaseder" target="_blank" rel="noopener">Lukas Eder</a> explores efficient SQL strategies for checking the existence of multiple values.</p>
<p><a href="https://foojay.io/today/video-spring-boot-docker-compose-support/" target="_blank" rel="noopener">Spring Boot Docker Compose Support</a> – Check out this video by <a href="https://foojay.io/today/author/simon-martinelli/" target="_blank" rel="noopener">Simon Martinelli</a> in which he demonstrates the newly added Docker Compose support in Spring Boot 3.1.</p>
<p><a href="https://foojay.io/today/video-spring-boot-testcontainers-support-for-local-development/" target="_blank" rel="noopener">Video: Spring Boot Testcontainers Support for Local Development</a> – You might enjoy another video by <a href="https://foojay.io/today/author/simon-martinelli/" target="_blank" rel="noopener">Simon Martinelli</a>, showcasing how Testcontainers can be utilized both for testing your application and during development.</p>
<p><a href="https://www.infoq.com/podcasts/speech-music-ai-generated/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global" target="_blank" rel="noopener">Podcast: Generally AI Episode 2: AI-Generated Speech and Music</a> – In this podcast, <a href="https://www.infoq.com/profile/Roland-Meertens/" target="_blank" rel="noopener">Roland Meertens</a> and <a href="https://www.infoq.com/profile/Anthony-Alford/" target="_blank" rel="noopener">Anthony Alford</a> discuss AI-generated voices and music, including celebrity voices, ethical concerns about consent, and potential risks. As a bonus, they wrap up with a live demo of AI-generated music.</p>
<p><a href="https://vladmihalcea.com/hibernate-statelesssession-jdbc-batching/" target="_blank" rel="noopener">Hibernate StatelessSession JDBC Batching</a> – This article explains how to utilize Hibernate StatelessSession to enable JDBC Batching for INSERT, UPDATE, and DELETE statements. Despite being available for over 20 years, until Hibernate 6, its capabilities were limited without support for batching and other features like UPSERT.</p>
<p><a href="https://vladmihalcea.com/postgresql-performance-tuning-settings/" target="_blank" rel="noopener">PostgreSQL Performance Tuning Settings</a> – <a href="https://vladmihalcea.com/" target="_blank" rel="noopener">Vlad Mihalcea</a> explores various PostgreSQL performance tuning settings that you might want to configure since the default values are not suitable for a QA or production environment.</p>
<p><a href="https://www.morling.dev/blog/last-updated-columns-with-postgres/" target="_blank" rel="noopener">Last Updated Columns With Postgres</a> – Gunnar Morling’s article explores a straightforward method for automatically updating ‘last updated’ columns in PostgreSQL. </p>
<h2 class="wp-block-heading">Kotlin Corner</h2>
<p><a href="https://blog.jetbrains.com/amper/2024/02/amper-update-february-2024/">Amper Update – February 2024</a> – Amper, an experimental project configuration tool by JetBrains, has released version 0.2.0, introducing exciting features like support for Gradle version catalogs and enhanced completion for adding new dependencies. </p>
<p><a href="https://johnoreilly.dev/posts/amper-kmp-climatetrace/" target="_blank" rel="noopener">Using Amper and Fleet in a Kotlin/Compose KMP project</a> – <a href="https://johnoreilly.dev/" target="_blank" rel="noopener">John O’Reilly</a> is trying out the recently released Amper v 0.2.0 in a Kotlin Multiplatform sample. </p>
<p><a href="https://jakewharton.com/perils-of-duplicate-finding/" target="_blank" rel="noopener">Perils of duplicate finding</a> – <a href="https://jakewharton.com/" target="_blank" rel="noopener">Jake Wharton</a> discusses the challenges of identifying duplicate elements in an array of integers, and exploring different programming approaches to overcome them. </p>
<p><a href="https://funkymuse.dev/posts/sql-delight-kmp/" target="_blank" rel="noopener">Using SQLDelight in Kotlin Multiplatform (KMP) </a>– Persistent data storage is crucial for many apps, and SQLDelight is a popular library for managing database interactions in Kotlin projects. In this blog post, you can read about the integration of SQLDelight into a Kotlin Multiplatform project, which enables you to efficiently manage your database interactions across various platforms (Android, iOS, and Desktop).</p>
<p><a href="https://medium.com/@robert.baricevicpetrus/kotlin-flows-animated-55640aa48ac9" target="_blank" rel="noopener">Kotlin Flows Animated </a>– To a beginner developer, the concept of Flows can be quite confusing. What are they for? How do they make things easier for us? What do we do when we use collect() or emit(), and what are all those operator functions? In this article, <a href="https://medium.com/@robert.baricevicpetrus?source=post_page-----55640aa48ac9--------------------------------" target="_blank" rel="noopener">Robert Baricevic-Petrus</a> attempts to explain what Flows are in simple terms that everyone can understand. </p>
<p><a href="https://blog.rockthejvm.com/kotlin-type-classes/" target="_blank" rel="noopener">Type Classes in Kotlin: A Practical Guide</a> – Explore the concept of type classes in Kotlin, a powerful tool that allows developers to abstract logic for different data types. </p>
<p><a href="https://www.youtube.com/watch?v=KGh09zMNVEQ" target="_blank" rel="noopener">Simply your Kotlin by Refactoring Actions to Calculations </a>– In this episode, <a href="https://www.youtube.com/@RefactoringDuncan" target="_blank" rel="noopener">Duncan McGregor</a> demonstrates a refactoring technique that allows you to separate actions and calculations in a bowling simulator. As a result of refactoring, he demonstrates an entire 10-pin bowling game as calculations on immutable game state data, making the code cleaner and more testable.</p>
<h2 class="wp-block-heading">Conferences and Events</h2>
<p><a href="https://blog.jetbrains.com/idea/2024/02/you-re-invited-to-intellij-idea-conf-2024/">IntelliJ IDEA Conf 2024</a> – Do not miss IntelliJ IDEA Conf 2024, a developer-focused, live, online event that is free for all to attend!</p>
<p><a href="https://www.jug.ch/html/events/2024/idiomatic_kotlin.html" target="_blank" rel="noopener">Idiomatic Kotlin</a> – Bern, Switzerland, March 4</p>
<p><a href="https://www.jug.ch/html/events/2024/debugging_with_intellij_idea_lu.html" target="_blank" rel="noopener">Debugging With IntelliJ IDEA</a> – Lucerne, Switzerland, March 5</p>
<p><a href="https://www.jug.ch/html/events/2024/vector_api.html" target="_blank" rel="noopener">The Secrets of Vector API</a> – Zurich, Switzerland, March 6</p>
<p><a href="https://voxxeddays.com/zurich/" target="_blank" rel="noopener">Voxxed Days Zurich</a> – Zurich, Switzerland, March 7</p>
<p><a href="https://www.meetup.com/amsterdam-java-user-group/events/298904168" target="_blank" rel="noopener">JVM Ergonomics, Clean Code, and OpenTelemetry</a> – Amsterdam, the Netherlands, March 13</p>
<p><a href="https://www.meetup.com/atlantajug/events/298455293" target="_blank" rel="noopener">To Spring Boot 3 and Beyond!</a> – Atlanta, USA, March 19</p>
<p><a href="https://romania.voxxeddays.com/voxxed-days-bucharest-2024/" target="_blank" rel="noopener">Voxxed Days Bucharest</a> – Bucharest, Romania, March 27–29</p>
<p><a href="https://info.jetbrains.com/idea-livestream-march28-2024.html" target="_blank" rel="noopener">Building Intelligent Applications With Spring AI</a> – Online, March 28</p>
<h2 class="wp-block-heading">Culture and Community</h2>
<p><a href="https://inside.java/2024/02/23/fosdem2024-openjdk-state/" target="_blank" rel="noopener">The State of OpenJDK</a> – In his insightful talk, <a href="https://inside.java/u/DaliborTopic/" target="_blank" rel="noopener">Dalibor Topić</a> reviews four years of OpenJDK Community progress and anticipates future developments.</p>
<p><a href="https://www.javaspecialists.eu/archive/Issue314-Harnessing-the-Power-of-ChatGPT-4.0-From-Java.html" target="_blank" rel="noopener">Harnessing the Power of ChatGPT 4.0 From Java</a> – This article by <a href="https://www.javaspecialists.eu/about/heinz/" target="_blank" rel="noopener">Dr. Heinz Kabutz</a> demonstrates how ChatGPT 4.0 effectively translated a historical book from a Cretan dialect to English, outperforming Google Translate by preserving the text’s poetic quality.</p>
<p><a href="https://morethancoding.com/2024/02/16/how-to-keep-engineers-out-of-meeting-hell/" target="_blank" rel="noopener">How to keep engineers out of meeting hell </a>– For engineering managers, making meetings engaging for engineers is key. This article comes with some tips on how to do this.</p>
<h2 class="wp-block-heading">And Finally…</h2>
<p><a href="https://blog.jetbrains.com/idea/2024/02/the-new-terminal-beta-is-now-in-jetbrains-ides/">The New Terminal (Beta) Is Now in JetBrains IDEs</a> – We invite you to try out the new terminal (Beta) in JetBrains IDEs and read more about it in this blog post. </p>
<p><a href="https://blog.jetbrains.com/idea/2024/02/java-best-practices/">Java Best Practices</a> – Starting with Java? Check out our best practices guide, designed to assist beginners in creating clear, reusable, and efficient code.</p>
<p><a href="https://blog.jetbrains.com/idea/2024/02/helloworld-and-main-meet-minimalistic/">‘HelloWorld’ and ‘main()’ meet minimalistic</a> – <a href="https://twitter.com/eMalaGupta" target="_blank" rel="noopener">Mala Gupta</a> explains why <a href="https://openjdk.org/jeps/463" target="_blank" rel="noopener">JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)</a> is especially helpful to those starting to learn Java.</p>
<p><a href="https://blog.jetbrains.com/idea/2024/02/constructor-makeover-in-java-22/">Constructor Makeover in Java 22</a> – How can you benefit from statements before super(…), a preview language feature in Java 22? Read about it in this blog post by<a href="https://twitter.com/eMalaGupta" target="_blank" rel="noopener"> MalaGupta</a> to find out. </p>
<p><a href="https://blog.jetbrains.com/idea/2024/02/easy-hacks-how-to-implement-polymorphism-in-java/">Easy Hacks: How To Implement Polymorphism in Java</a> – Polymorphism in programming means that a variable or a method can have different behaviors depending on the type of object it represents. In this article, <a href="https://twitter.com/maartenballiauw" target="_blank" rel="noopener">Maarten Balliauw</a> demystifies polymorphism in Java, showing how it helps you reduce coupling, increases reusability, and helps to make your code easier to read.</p>
<p><a href="https://blog.jetbrains.com/idea/2024/02/build-a-spring-boot-app-with-ai-assistant/">Build a Spring Boot App with AI Assistant</a> – Check out this blog post to follow along with Marit van Dijk as she builds a compact Java Spring Boot application in IntelliJ IDEA with the help of JetBrains AI Assistant.</p>
<h3 class="wp-block-heading">Videos</h3>
<p><a href="https://www.youtube.com/watch?v=h6fZeocZHlI" target="_blank" rel="noopener">Qodana Code Analysis: From the IDE to Quality Gates</a> – Discover how Qodana helps you enhance code quality and learn how to integrate it into your CI pipeline for quality checks and project health monitoring.</p>
<p><a href="https://www.youtube.com/watch?v=hjGVJHOLSjA" target="_blank" rel="noopener">Reading Code Like a Pro | IntelliJ IDEA Tips</a> – This video offers strategies to improve code-reading skills in IntelliJ IDEA, emphasizing features like syntax highlighting, inlay hints, and code formatting to help you navigate and understand code more easily. </p>
<p><a href="https://www.youtube.com/watch?v=Ewb5nYRVlTA" target="_blank" rel="noopener">The State of IntelliJ Scala Plugin</a> – This talk provides an overview of IntelliJ Scala Plugin’s features, especially those that we’ve worked on over the last few years, our road to Scala 3 support, and some of the latest developments in IntelliJ IDEA. </p>
<p>That wraps up today’s edition!</p>
<p>We’re already gathering ideas for the next Java Annotated Monthly, so feel free to share your suggestions via email or tweet by March 20. Also, don’t forget to explore our archive of past JAM issues, which is perfect for catching up on any missed blog posts or articles.</p>
]]></content:encoded>
</item>
<item>
<title>IntelliJ IDEA 2024.1 EAP 7: Full Line Code Completion, Support for OpenRewrite, and More</title>
<link>https://blog.jetbrains.com/idea/2024/02/intellij-idea-2024-1-eap-7/</link>
<dc:creator><![CDATA[Maria Kosukhina]]></dc:creator>
<pubDate>Thu, 29 Feb 2024 12:45:14 +0000</pubDate>
<category><![CDATA[eap]]></category>
<category><![CDATA[2024-1-eap]]></category>
<category><![CDATA[intellij-idea-2024-1]]></category>
<category><![CDATA[intellij-idea-2024-1-eap]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=448961</guid>
<description><![CDATA[IntelliJ IDEA 2024.1 EAP 7 is now available, providing a sneak peek into some exciting new features planned for the next major release. Notable updates include full line code completion, new Java inspections, and support for OpenRewrite and WireMock. Additionally, this new build introduces enhancements for version control systems integration, along with a fresh set […]]]></description>
<content:encoded><![CDATA[
<p>IntelliJ IDEA 2024.1 EAP 7 is now available, providing a sneak peek into some exciting new features planned for the next major release. Notable updates include full line code completion, new Java inspections, and support for OpenRewrite and WireMock. Additionally, this new build introduces enhancements for version control systems integration, along with a fresh set of product icons. </p>
<p>You can download the new version from our <a href="https://www.jetbrains.com/idea/nextversion/" target="_blank" rel="noopener">website</a>, update directly from the IDE or via the free <a href="https://www.jetbrains.com/toolbox-app/" target="_blank" rel="noopener">Toolbox App</a>, or use snaps for Ubuntu.</p>
<p align="center"><a class="jb-download-button" href="https://www.jetbrains.com/idea/nextversion/" target="_blank" rel="noopener">Download IntelliJ IDEA 2024.1 EAP #7</a></p>
<p>Discover more about the latest features unveiled in the ongoing Early Access Program by exploring the 2024.1 EAP blog posts. Now, let’s take a look at what’s been added this week! </p>
<h2 class="wp-block-heading">Java</h2>
<h3 class="wp-block-heading">Full line code completion </h3>
<p>This IntelliJ IDEA 2024.1 EAP comes with full line code completion for Java that is powered by an advanced deep learning model seamlessly integrated within the IDE. This functionality enhances coding efficiency by predicting and suggesting entire lines of code based on contextual analysis. It runs entirely on your local device, ensuring your data remains secure without any need for external server communication.</p>
<p>You can control this feature and select the languages you’d like to get full line suggestions for in <em>Settings/Preferences | Editor | General | Code Completion | Machine Learning-Assisted Completion</em>.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/FLC.gif" alt="" class="wp-image-450767"/></figure>
<h3 class="wp-block-heading">New inspections and quick-fixes</h3>
<p>We’ve implemented new inspections and quick-fixes for Java to help keep your code neat and error-free. The IDE now detects bitwise operations that can be replaced with a call to the <code>Long.hashCode()</code> or <code>Double.hashCode()</code> methods for improved readability.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1350" height="540" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Screen-Shot-2024-02-27-at-16.05.12.png" alt="" class="wp-image-450560"/></figure>
<p>There’s a new quick-fix that simplifies switching between implicit and explicit class declarations, depending on the specific needs of your codebase.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-21.gif" alt="" class="wp-image-450277"/></figure>
<p>IntelliJ IDEA now suggests using existing static methods when it finds code fragments that match them exactly. This feature provides a simpler alternative to the <em>Extract duplicate </em>functionality, making it easier to reuse code and maintain clarity without introducing additional APIs.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Use-existing-method.gif" alt="" class="wp-image-450538"/></figure>
<p>In addition, the IDE now detects and reports unreachable code that will never be executed.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1350" height="540" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Unreachable-code.png" alt="" class="wp-image-450549"/></figure>
<h3 class="wp-block-heading">Enhanced user experience with multi-release JARs</h3>
<p>This build introduces an enhanced user experience with multi-release JAR libraries. When you use a class existing in different versions, the <em>Go to declaration</em> feature now selects the proper version from the JAR based on your current module’s language level. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-23.gif" alt="" class="wp-image-450299"/></figure>
<p>Moreover, the<em> Go to class</em> feature offers extra information about the version of the class. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1350" height="540" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Multirelease-JARs_Go-to-class.png" alt="" class="wp-image-450754"/></figure>
<p>When debugging and using <em>Step Into</em>, the IDE will navigate you to the class based on your JDK version, not the language level of your module.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-24.gif" alt="" class="wp-image-450310"/></figure>
<h2 class="wp-block-heading">Frameworks and technologies </h2>
<h3 class="wp-block-heading">Support for OpenRewrite </h3>
<p>IntelliJ IDEA integrates <a href="https://docs.openrewrite.org/" target="_blank" rel="noopener">OpenRewrite</a>, expanding the IDE’s existing refactoring capabilities and providing you with a toolkit to improve code quality, consistency, and maintainability. Using OpenRewrite’s recipes, you can modernize legacy code, optimize performance, and handle complex migration tasks such as, for example, upgrading to a new Spring Boot version.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-28.gif" alt="" class="wp-image-450574"/></figure>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-29.gif" alt="" class="wp-image-450585"/></figure>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-7-1.png" alt="" class="wp-image-450618"/></figure>
<h3 class="wp-block-heading">WireMock server support</h3>
<p>In IntelliJ IDEA 2024.1 EAP 7, we’re introducing <a href="https://wiremock.org/" target="_blank" rel="noopener">WireMock</a> support via a plugin that you can get from <a href="https://plugins.jetbrains.com/plugin/23695-wiremock/" target="_blank" rel="noopener">JetBrains Marketplace</a> or install from inside the IDE. This integration includes schema completion for JSON configurations, the ability to generate WireMock stub files from the <em>Endpoints</em> tool window, and a built-in server run configuration that allows users to spin up the server directly from the editor. This addition enables you to swiftly create test data servers or stubs, simplifying the development of web UIs and microservices.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Completion.png" alt="" class="wp-image-450697"/></figure>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Generate.png" alt="" class="wp-image-450719"/></figure>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-30.gif" alt="" class="wp-image-450630"/></figure>
<h2 class="wp-block-heading">User experience</h2>
<h3 class="wp-block-heading">Refreshed product icons</h3>
<p>The latest EAP build for IntelliJ IDEA 2024.1 introduces refreshed product icons, aligning with updates across all JetBrains IDEs and enhancing visual appeal and consistency across the ecosystem.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/IDEA.png" alt="" class="wp-image-450641"/></figure>
<h2 class="wp-block-heading">Version control systems</h2>
<h3 class="wp-block-heading">Option to exclude folders and files from comparison</h3>
<p>We’ve enhanced the diff viewer with an option to specify specific folders and files to be ignored during the comparison process so that you can focus solely on relevant changes. Just right-click on any file or folder you don’t want to appear in the comparison results and select <em>Exclude from results</em> from the context menu. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/ignore_in_dirdiff.png" alt="" class="wp-image-450674"/></figure>
<h3 class="wp-block-heading">Improved search in the <em>Branches </em>popup</h3>
<p>We’ve enhanced the search functionality available in the<em> Branches </em>popup. With this update, you can now filter search results by actions and repositories for quicker and more precise navigation within your version control system. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/widget_search_actions-2.png" alt="" class="wp-image-450685"/></figure>
<h3 class="wp-block-heading">Support for <code>--update-refs</code> for interactive rebase</h3>
<p>The <em>Rebase</em> dialog now features the <code>--update-refs</code> option, meaning that once it is selected, IntelliJ IDEA ensures that the Git repository’s history accurately reflects the modifications made during the rebase operation. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Rebase-dialog.png" alt="" class="wp-image-450731"/></figure>
<p>These are the most notable updates brought by this week’s EAP build. For a comprehensive overview of all the implemented changes, please refer to the <a href="https://youtrack.jetbrains.com/articles/IDEA-A-2100661882/IntelliJ-IDEA-2024.1-EAP-7-241.14024.14-build-Release-Notes" target="_blank" rel="noopener">release notes</a>. </p>
<p>As we approach the culmination of the IntelliJ IDEA 2024.1 Early Access Program, we highly value your feedback on the new features since your insights play an essential role in molding the final version of the release. Feel free to share your thoughts in the comments below or via <a href="https://twitter.com/intellijidea" target="_blank" rel="noopener">X (formerly Twitter)</a>. Should you encounter any bugs, please submit a report via our <a href="https://youtrack.jetbrains.com/issues/IDEA" target="_blank" rel="noopener">issue tracker</a>. </p>
<p>Happy developing! </p>
]]></content:encoded>
</item>
<item>
<title>Build a Spring Boot App with AI Assistant</title>
<link>https://blog.jetbrains.com/idea/2024/02/build-a-spring-boot-app-with-ai-assistant/</link>
<dc:creator><![CDATA[Marit van Dijk]]></dc:creator>
<pubDate>Wed, 28 Feb 2024 09:13:34 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/02/ij-release-featured_blog_1280x720-5.png</featuredImage> <product ><![CDATA[ai]]></product>
<category><![CDATA[features]]></category>
<category><![CDATA[idea]]></category>
<category><![CDATA[jetbrains-ai]]></category>
<category><![CDATA[intellijidea-2]]></category>
<category><![CDATA[ai-assistant]]></category>
<category><![CDATA[spring]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=449025</guid>
<description><![CDATA[In this article, we’ll be building a small Java Spring Boot web application in IntelliJ IDEA with the help of JetBrains AI Assistant. If you’d like to follow along with this tutorial, you’ll need IntelliJ IDEA Ultimate, as well as an active subscription to AI Assistant or the free seven-day trial license. Creating a new […]]]></description>
<content:encoded><![CDATA[
<p>In this article, we’ll be building a small Java Spring Boot web application in <a href="https://www.jetbrains.com/idea/" target="_blank" rel="noopener">IntelliJ IDEA</a> with the help of <a href="https://www.jetbrains.com/ai/" target="_blank" rel="noopener">JetBrains AI Assistant</a>.</p>
<p>If you’d like to follow along with this tutorial, you’ll need IntelliJ IDEA Ultimate, as well as an active subscription to AI Assistant or the free seven-day trial license.</p>
<h2 class="wp-block-heading"><strong>Creating a new Spring Boot application</strong></h2>
<p>Our first step is to create a new project, which we can do right from the <em>Welcome</em> screen by clicking the <em>New Project </em>button, or (if we already have a project open), from the main menu by selecting<strong> </strong><em>File | New | Project</em>.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/4ZHJG1GQMCo5bzArb7EqYxYSxLL2fHpUT6I7J8HJT6UAC8zefxO65icrAUvYv0RHVr2oV9KkThj3JygmpLHCxO3AoLZ3FZRRT7zWpfGEGFu4e_fmlpCPBK5KfMbnNFmLp2uB2-X2em9Gm73CdJ8iQdM" alt=""/></figure>
<p>In the <em>New Project</em> dialog, select <em>Spring Initializr</em> on the left. Change the name of the project to <code>greetings-app</code>, select <em>Create Git repository</em> to add the project to version control, select <em>Maven</em> as the type, and click <em>Next</em>.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/7OryyrAFdL2zbzYogx9d30EFg2kYu7GUFeIfL20eh3uQ5XKLS2CyDC1JMqJZ5y1b8P8eibhuyStlDLwL7z-7Q2tef19HZypBUnTBM0MX4w2JMKvkRcG6LphNYHlTmlrCRSr5bILkP1uREbY_PDkXKaU" alt=""/></figure>
<p>In the next screen, we can select which version of Spring Boot we want to use. We’ll go with the latest stable version, which currently is 3.2.2. We can also select the dependencies we want to add to our project here. Expand the <em>Web</em> section under <em>Dependencies</em>, select <em>Spring Web</em>, and then, click on <em>Create</em>.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/OTdFKlz70XCq0MRBWRKaxFYjR4TiasQhwimNQcX5r2gUVa7sBylhJBm0n9wSUjmjYAhFjcv9xHncnaPqwfASpNiqavqCioc0u4MYnlvEJavzFK69EUuxQZTK4J4dXOm0OLbIh4YvFpkr3mkeUxG32FU" alt=""/></figure>
<p>As you can see, IntelliJ IDEA has created the Spring Boot project for you, with a default Maven project directory structure, and a pom.xml that includes the dependency we selected when creating the project. Open the pom.xml to see the dependencies.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/AwXSadHL4iDjCG2mjCbO6tAm_CU2mlf8Mm4fOCHZc9zbXbt3PYP0cUi54Zo49UZdoqurYKbkfTsjR_lx-6N8WWi5rqd0D3rW1V_7VALel8AP0YDI0MTHwhmMqfw_t0lqyZjfJ8YvVcuUSXgqDa8NTJ0" alt=""/></figure>
<h2 class="wp-block-heading"><strong>Adding code using AI Assistant</strong></h2>
<p>Now, let’s add some code to this project. First, we need to add a class. In the <em>Project </em>tool window on the left, select the directory <code>src/main/java/com.example.greetings-app</code>. Add a new Java file using the shortcut <em>⌘N</em> (on macOS) or<strong> </strong><em>Alt+Insert</em> (on Windows/Linux). Alternatively, right-click the <em>Project </em>tool<strong> </strong>window to open the context menu and select <em>New | Java class</em>. Name this class <code>HomeController</code>.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/Ijtg6Ulgxvklsa1HcByK7dTTC648rJcxjym4KoeMAXJ2P8yty-ImqmajYFOwss5QPJEqPXGFW4DlnGyI38Ar-VKpnK6-FT_imX9MM6VvUpU6lACl_RWO6LVsMJxmUvZNUCr87YjLGTLRmhvXz0DWsQQ" alt=""/></figure>
<p>Add the following comment to the code:</p>
<pre class="EnlighterJSRAW">// Create a Java web rest controller for a web application containing a hello endpoint,
// which takes a String parameter called name and append this parameter
// to the String "Hello", using “World” as the name default value</pre>
<p>When you press <em>Enter</em> after the comment, AI Assistant will suggest code to you. To accept the suggested code, press the <em>Tab </em>key.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/c37WhDXRSVwuaiXzTsiFIm2WtUzywmtYop30WABblcrv7EaoTHirn6hiV2L8ZDwgMrpsdnm2btPzT-FLtY0dLEfNxfF4k9jCfvd1RbxiTVkMRIhgjHxqkitmlrdYupEJRe-zENk2kJ7QtUuGUsjf5Uw" alt=""/></figure>
<p>Some of the code is shown in red, which means there are some issues. IntelliJ IDEA can help you resolve them. Use <em>F2</em> to navigate to the next problem, or <em>Shift+F2</em><strong> </strong>to navigate to the previous problem, and <em>Show Context Actions (⌥⏎</em><strong> </strong>on macOS, or <em>Alt+Enter</em> on Windows/Linux) to see suggestions on how to solve the problem, for example, to import the relevant class.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/mBFwJBW8X47ydoVa40hK5LfhyouDEZENXsV82oO2ofTBkabAyuvPb6FURdN-5hCsDRrou6rTWuervVW_w0cA4uPnlp4vRUz4YIwl2jbIXH3MOU2Fj8wieR65lNfBM0X86sWhHtyPAqXQvMIgdzgAOSY" alt=""/></figure>
<p>At the moment, our code looks like this:</p>
<pre class="EnlighterJSRAW">package com.example.greetingsapp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
public class HomeController {
// Create a Java web rest controller for a web application containing a hello endpoint,
// which takes a String parameter called name and append this parameter
// to the String "Hello", using “World” as the name default value
@GetMapping("/hello")
public String hello(@RequestParam(defaultValue = "World") String name) {
return "Hello " + name;
}
}</pre>
<p>We can run the application by clicking the green <em>Run</em> button at the top right (or using <em>⌃R</em> on macOS, or <em>Shift+F10</em> on Windows/Linux). </p>
<p>Open the application on localhost: <a href="http://localhost:8080/hello" target="_blank" rel="noopener">http://localhost:8080/hello</a></p>
<p>As you can see, we get a Whitelabel Error Page. That means that something’s not quite right. Let’s see if we can solve this issue using AI Assistant.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/fSl7r6YccBmeoVhBqxhJRf_tptkeqZkYpnNAYuE-PRBzIqtP1YUzzG9tEZ4cNiTJsliG3SapNsBqhh3XJ1YNGcf5GxxlZpx7CqFDrD6wBcf1my6O_AaxNwhuk2mrcAtIRa9qkianbaxYH9ZcwhfUQnc" alt=""/></figure>
<h2 class="wp-block-heading"><strong>Find and fix problems</strong></h2>
<p>There are several ways we can ask AI Assistant to help us fix this problem.</p>
<p>First off, we can ask directly in the chat. Open the AI Assistant chat window on the right, and type your question. For example, “Why does this code return a Whitelabel Error Page?”. We see that (among other things) AI Assistant suggests we need to ensure that our class is annotated with <code>@RestController</code>.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/ikyHQ0lxSvCTE8gR1w8YFuViKfh7dTpisHg85OE6xlZNEx1H4qgFTA8JVKpKZEMErk_vTZnuxojgfr2ufq4yVv-2iB5xEOY5eG--N1XemITDurKUpWvh87BJQ0SHT4vm4h3NkCfPw1MkVGVXzjtz_5Q" alt=""/></figure>
<p>As AI Assistant is powered by LLMs, the result is not deterministic. For the same request, you might get a different response. It might also take some fine-tuning of the prompt to get the desired result. In general, the more detailed your question, the more specific the result will be.</p>
<p>Alternatively, we can use <em>AI Actions | Find Problems</em> to see whether this will include the solution to our problem. Right-click in the editor to open the context menu, including <em>AI Actions</em>, or select <em>AI Actions</em> in the floating toolbar and select the <em>Find Problems </em>option. This will open a chat window with a predefined prompt, including the selected code. Once again, AI Assistant suggests we need to add <code>@RestController</code> to our class. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/G1gjavBC2CWvA5aNd1Bg59aNKv-PRMAZpMkY5oxV5auQEf34U4SczONs06R81lbyUhEngpkFpPMetJL7N_aBoWP8wJ7pFHruG2Ox_F6rF92mDq_F3FVdxv2FrMZccKPe8uq3J0u-G4mSUzaEh677u5M" alt=""/></figure>
<p>We can copy the suggested code from the chat window into our code by clicking the <em>Insert Snippet at Caret</em> button.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/v_CBzs2NTfpxpKmwwu-xmdrRw65apiq0UzOKGo-iLxSpNTZ1-LCk3BHWhTnpvgjp17pqAvpDqBOSs6vcOJ4cUcKVqrdskd4VYPeESc4R1Hyss3wMVoST7rlM8_BBa9kziTJ7JTbNgXPTtddf6NKuKjM" alt=""/></figure>
<p>As we have seen, both the response in the <em>AI Assistant</em> chat and the answer for <em>Find Problems</em> suggest we should use the <code>@RestController</code> annotation on our controller. We can do so by inserting suggested code from the chat window, or we can do this ourselves.</p>
<p>The code should now look like this:</p>
<pre class="EnlighterJSRAW">package com.example.greetingsapp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController // Annotation needed to define it as a REST controller
public class HomeController {
@GetMapping("/hello")
public String hello(@RequestParam(defaultValue = "World") String name) {
return "Hello " + name;
}
}</pre>
<p>If you are following along and want to check if your code is the same, you can use <em>Compare with clipboard</em> to do so. To use this feature, first copy the code snippet above, then select your code in the IDE, and right-click on your code in the editor to open the context menu. Select the option <em>Compare with clipboard</em> from the context menu to open the diff between your code and the clipboard. The diff will say “contents are identical” if there are no differences, or it will highlight any differences found in the code.</p>
<p>Now, we can run the application and try localhost again: <a href="http://localhost:8080/hello" target="_blank" rel="noopener">http://localhost:8080/hello</a>.</p>
<p>You should get the following result:</p>
<p><img decoding="async" loading="lazy" src="https://lh7-us.googleusercontent.com/rro03rRRjmJvFWL22tLs3691mt5BprRk9gwZLtOrunHdNEvgmzxe-sDznOzsf7Vpwosj2MVHpLJJaOWnBt9Fu8oKQteNhQxjTHrJSDyfq-ml6UEM6om4p1C3Vkop32fZZ5dkrIiHFZEw0a6bJr6--Zk" width="624" height="209">We can also call the endpoint with a parameter: <a href="http://localhost:8080/hello?name=Marit" target="_blank" rel="noopener">http://localhost:8080/hello?name=Marit</a> </p>
<p>You should get the following result:</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/aEp-uXMWbmIz-mfo64MDYQx6PegFplZWvYUpMp4TrL0WOpEyblR39Hyw99HcdS0vSF7objex26eBwKFx9hztQ8czOHNBP5oX5RVeMGtgteyeV0ZNvYdfUM4Tkt46SaY_AJEGGGkxM_dKOmRDbMnVhd0" alt=""/></figure>
<p>I’m using my name here – feel free to use your own!</p>
<h2 class="wp-block-heading"><strong>Generate Unit Tests with AI Assistant</strong></h2>
<p>Next, let’s add some tests to our application. Of course, we can do so ourselves. We can navigate to tests, or create the test file if there aren’t any tests yet by using the shortcut <em>⇧⌘T</em> on macOS or <em>Ctrl+Shift+T</em> on Windows/Linux. IntelliJ IDEA supports a number of testing frameworks, including JUnit 5, which we will use here.</p>
<p>In the test class, we can use <em>Generate</em> (<em>⌘N</em> on macOS or<strong> </strong><em>Alt+Insert</em> on Windows/Linux) and select <em>Test Method</em> to add a test. Give the test a name that explains the intended behavior, and add the relevant test code.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/gQlw9Oaut3NBMhVM-dzpSJYs4A9819cbsAs0naK5aCsCtliOKtb4EOEGKiubwT62uHLS9IUwj5T1CJZDL9QwJk_HYVjUm8moSwgg5MBUyIbmo5UlaexyEI_YRr7x0nj9c6QY2jI-Ebp2npyvjBPpLX4" alt=""/></figure>
<p>Alternatively, we can have AI Assistant generate the unit tests for us! Let’s delete the class we just created and try again.</p>
<p>Open the context menu in the editor and select the <em>AI Actions | Generate unit tests </em>option. Note that AI Assistant can only generate unit tests for methods. If you get the “<em>Test generation is not supported for the target code element” </em>message, make sure to select the option <em>Generate unit tests</em> from a method in your code.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/A-OUTGAk2lUQ36_sAoXZpKAtbO5cfDFs2r53k9N8f7Z6UB8hLRvEc61N-okF0P-hgCbO-aDjNt8CKllwhc2iela8TCQgT5h5reDCokfuiBuCx2LSMUWPhU7qw5N3GKMqYGNw5QBOeeOpoAtdRwD6FQc" alt=""/></figure>
<p>If we’re happy with the tests that have been generated, we can select <em>Accept all</em>. If not, we can fine-tune them by selecting <em>Specify</em> and providing an additional prompt to ask AI to improve the result. Alternatively, we can click the <em>Regenerate</em> button to generate the tests again.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/9jeWftBa04JLpQrJ1I7D3GyVexPFkin6VSrSzwd7vfeCBSqGBjXAFWjVe2a9FQUMY3P9qNIRFC_yfE_zNlkVVA0bGuToAvbZb-uGdvUMlTPWmFjNjzO8nZxGhctBl3qh0VHRuuT_jZ1tU268arVsfv8" alt=""/></figure>
<p>When we accept the result, we can select <em>Run All Tests</em> (<em>⌃⇧R</em> on macOS or <em>Ctrl+Shift+F10</em> on Windows/Linux).</p>
<p>AI Assistant will then generate the tests in a new file. This file is created in the correct place in our project, as seen in the <em>Project</em> tool window on the left, using the default name <code>HomeControllerTest</code>. If a file by that name already exists, it will use an alternative name, like <code>HomeControllerUnitTest</code>.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/2T3ObHX0tMZnxZhOXwnXKuqB_0ASgANWlBom2_6GfudK3f7FhHJyZp3utfe9a1TstOd7pdIUh5nje4VT_e2iLM1FLZ-qUeb5xveU3HOOl44wZJqkGE7sYS4D4C5_vqICPLhkH_Qnp5qWDmvZsQRgYg4" alt=""/></figure>
<p>If the tests pass, we now know there are no compilation issues, and the tests can run.</p>
<p>However, never trust a test you haven’t seen fail! We want to ensure the tests will also fail if they get the wrong result. Let’s change the expected results in the tests and rerun them. Now we see they fail, we can undo the changes and keep the original tests.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/p6YMZNMbVmgkGBcJbF5XJzX8NRrmRnmUZbl9VgogA8VuXikdTbzRemo-P5VpfR9G59j06Rkw-DDewKAsU9ZcA2E-gQzrOw8JsSzhZvOnMLqDks5XA8c36BMRo-1utfTnWhERwuHQ0el_Kv9bylCMGXc" alt=""/></figure>
<p>You might want to think about whether the generated tests cover everything you want to cover. Do they include just happy flows as well as unhappy flows and exceptions? Are there any boundary cases you need to cover? We can either add additional tests ourselves or ask AI Assistant to generate specific test cases for us.</p>
<h2 class="wp-block-heading"><strong>Conclusions</strong></h2>
<p>We’ve now seen several ways IntelliJ IDEA and AI Assistant can help us build a simple Java Spring Boot application more quickly. To build something more complicated, we can use the same steps shown here, with different prompts – either in the comments in the editor to prompt code generation or by asking AI Assistant for specific code in the chat.</p>
<p>Give <a href="https://www.jetbrains.com/ai/" target="_blank" rel="noopener">AI Assistant</a> a try and see if you can expand the application we created in this blog post or build your own – and do let us know how it goes in the comments!</p>
<h2 class="wp-block-heading"><strong>Links</strong></h2>
<ul>
<li><a href="https://www.jetbrains.com/ai/" data-type="link" data-id="https://www.jetbrains.com/ai/" target="_blank" rel="noopener">JetBrains AI Assistant</a></li>
<li><a href="https://www.jetbrains.com/help/idea/ai-assistant.html" data-type="link" data-id="https://www.jetbrains.com/help/idea/ai-assistant.html" target="_blank" rel="noopener">IntelliJ IDEA – AI Assistant</a></li>
<li><a href="https://www.jetbrains.com/ai/#faq" data-type="link" data-id="https://www.jetbrains.com/ai/#faq" target="_blank" rel="noopener">JetBrains AI Assistant – FAQ</a></li>
<li><a href="https://www.jetbrains.com/help/idea/spring-support.html" data-type="link" data-id="https://www.jetbrains.com/help/idea/spring-support.html" target="_blank" rel="noopener">IntelliJ IDEA – Spring</a></li>
<li><a href="https://www.youtube.com/watch?v=5kOGdZmpSDI" target="_blank" rel="noopener">Creating a Spring Boot “Hello World” Application with IntelliJ IDEA</a></li>
<li><a href="https://www.jetbrains.com/guide/java/tutorials/your-first-spring-application/" data-type="link" data-id="https://www.jetbrains.com/guide/java/tutorials/your-first-spring-application/" target="_blank" rel="noopener">Your First Spring Boot Application</a></li>
</ul>
]]></content:encoded>
</item>
<item>
<title>Java Best Practices</title>
<link>https://blog.jetbrains.com/idea/2024/02/java-best-practices/</link>
<dc:creator><![CDATA[Irina Mariasova]]></dc:creator>
<pubDate>Sat, 24 Feb 2024 09:17:39 +0000</pubDate>
<featuredImage>https://blog.jetbrains.com/wp-content/uploads/2024/02/ij-release-featured_blog_1280x720-4.png</featuredImage> <category><![CDATA[idea]]></category>
<category><![CDATA[java]]></category>
<category><![CDATA[tips-tricks]]></category>
<category><![CDATA[best-practices]]></category>
<category><![CDATA[intelij-idea]]></category>
<category><![CDATA[learn]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=447091</guid>
<description><![CDATA[Good code follows certain rules, and knowing them increases your chances of success. We’d like to share some Java best practices that will help you on your way. We’ll cover the must-know tips and tricks, from broad advice on software development to Java- and project-specific know-how. Let’s get started! General Let’s keep the following general […]]]></description>
<content:encoded><![CDATA[
<p>Good code follows certain rules, and knowing them increases your chances of success. We’d like to share some Java best practices that will help you on your way. We’ll cover the must-know tips and tricks, from broad advice on software development to Java- and project-specific know-how. Let’s get started!</p>
<h2 class="wp-block-heading">General</h2>
<p>Let’s keep the following general rules about modern coding in mind. </p>
<h3 class="wp-block-heading">Be clear, not clever</h3>
<p>The primary purpose of code is to be understood and maintained, not to serve as a showcase of technical skills. Clear code leads to software that’s easier to debug, maintain, and extend, benefiting everyone involved in the project. Complexity isn’t a badge of honor – simplicity and readability are.</p>
<p>Consider the following examples.</p>
<ul>
<li><strong>Clever: </strong></li>
</ul>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/3Iunmb-I7GkBx119gey_37G_ik3T2PLeqLREXtgFcLNpgpHB_uyC9BgIN85kqbRYfrHDEJamv0rAVKINP-cgNg1So6TTiPWsIvS5RyAswNvhMkZY2y_Fj0tK0vQeNHhCqXXyDsLlhTdFLYOEr8K_rL0" alt=""/></figure>
<p>This is an unconventional way to swap the values of variables `a` and `b`. Though it’s clever, it can be confusing to understand at first glance.</p>
<ul>
<li><strong>Clear: </strong></li>
</ul>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/Ir3XdLdpAXqzvWGxEv6-9yZcHy39BvtsIV0YpkBPfKU3kpP9oEBqtZlsaPml3gw4csQILE4GYuKYppYfKptJMzXB-0FJsNLv1tMou-lcsud8o_K9kpb01GjqnZBLXCFLsi4iplTj31N28wHB-EX-bEk" alt=""/></figure>
<p>This is a more common approach. Even though it requires an additional line of code, its straightforwardness makes it easier to understand for most programmers. </p>
<h3 class="wp-block-heading">Keep it short</h3>
<p>Make sure your methods and classes aren’t too long. While there’s no strict rule regarding the exact number of lines or words for a class, it’s advisable to maintain a focused and cohesive structure. When it comes to methods, it’s generally suggested to aim for around 10 to 20 lines of code per method. If a method gets longer, it might be better to split it into smaller, more manageable parts.</p>
<p>If you’d like to practice recognizing methods that are too long, here is a <a href="https://www.youtube.com/watch?v=eqkqDn21OMI" target="_blank" rel="noopener">great video by technical coach Emily Bache</a>. </p>
<p>IntelliJ IDEA can also help you get rid of long methods and classes by providing various refactoring options. For example, it allows you to extract methods to break up a long method into shorter ones.</p>
<h3 class="wp-block-heading">Naming is hard, so do it with care</h3>
<p>Proper names for methods and variables serve as direct, intuitive guides to understanding the purpose and function of your code, which is essential for effective communication. Here is what you need to know about the most crucial naming conventions. </p>
<p>We advise staying away from single-letter variables, ensuring method names reflect their actions and aligning object and field names with the business domain to enhance clarity and communication. For instance, a method named calculateTotalPrice() instantly conveys its purpose, whereas a vague name like calculate() leaves its functionality ambiguous. Similarly, a variable named customerEmailAddress is clear right away, while an abbreviation like cea could refer to anything, leading to confusion.</p>
<p>As another example, instead of naming a variable timeout, it’s helpful to specify the unit to which it relates. Use timeoutInMs or timeoutInMilliseconds to avoid confusion about the units.</p>
<h3 class="wp-block-heading">Test, test, test </h3>
<p>Testing your code is necessary to ensure your app works as expected and will continue to work as it changes. Tests help spot issues early, making fixes cheaper and easier. They also guide you on how the code should work and minimize the possibility of breaking it when updating it later. </p>
<p>Good test names are important as they show what each test does and what it looks for. For example, a test called AlertWhenEmailIsMissing()checks for alerts when an email is missing, so you don’t need to dig into the details. </p>
<p>You can read this <a href="https://maritvandijk.com/use-testing-to-develop-better-software-faster/" target="_blank" rel="noopener">blog post by Marit van Dijk</a> for more information on tests. </p>
<h2 class="wp-block-heading">Language-specific</h2>
<p>The following tips and tricks will help you elevate your code by avoiding some common mistakes while writing in Java. </p>
<h3 class="wp-block-heading">Use switch expressions instead of excessive If statements</h3>
<p>Using switch expressions can make your code more readable and organized by consolidating multiple conditions into a single structure. This approach simplifies the code, making it easier to understand and maintain. </p>
<p>Let’s consider the following example with different types of ice cream and their key ingredients.</p>
<ul>
<li><strong>Excessive </strong><strong>else-if</strong></li>
</ul>
<p>In this example, the code uses a chain of else–if statements to match an ice cream flavor with its key ingredient. As the number of flavors grows, the number of if statements can become unmanageable, making the code harder to read.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/O42bfLsz8V-xOKeumhwXKG84Kvy_PJfJNyn_V8g4l3ZN7xAphISTqTpbc23amF4FOHE_ENnu2ogasrPBSWJS_DYgPMLDUQsS0SF4k7hl7VqfArgixZL5DW2Mns_6iHRBKTxkZ_7V4dk87mVF7RwG8gg" alt=""/></figure>
<ul>
<li><strong>Switch</strong></li>
</ul>
<p>In this alternative example, we achieve the same result using a switch expression instead of multiple if-else conditions. The switch expression is more compact, neater, and more easily understood when comparing a single variable against multiple constant values.</p>
<p>IntelliJ IDEA offers a special inspection that can transform your if statements into switch expressions in a matter of seconds. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/mUrqN3V_bwvcaHeZD-Cs3UNLpr9ea9br-OCsRcVE5OSxH00wjEsJotORFeWOKnMJH5yAC7hDFokZKGxDQdXEDX7AyPBTzdAHUyKUJmLeRjh76FuAzZrr7ZBnLrKzH60o0I0Fam3xsBE8VeNGQOmHpg8" alt=""/></figure>
<p>You can find more amazing examples of switch usage in a <a href="https://blog.jetbrains.com/idea/2024/01/evolution-of-the-switch-construct-in-java-why-should-you-care/">recent blog post</a> by Java Developer Advocate Mala Gupta. </p>
<h3 class="wp-block-heading">Avoid empty catch blocks</h3>
<p>Empty catch blocks in Java are catch clauses that don’t have any code inside them to handle exceptions. When an exception is caught by such a block, nothing happens and the program continues as if no error occurred. This can make it difficult to notice and debug issues.</p>
<ul>
<li><strong>Empty </strong><strong>Catch</strong><strong> Block</strong></li>
</ul>
<p>In this scenario, we catch the exception but do nothing about it. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/TYmE_ZGuBswQM8uELHewS3uETGX5X5oKnzmCpXSfaTTcQT6rGSRuEHXMfefmvCOPy-2ztGf-X7UYGgg8T_j6McP4TlbhGODH3YQ-he1vLls07TTCdIPz7CgR-u5o9sAOwxk8v8ANLM9i5-lxA0J8M2g" alt=""/></figure>
<p>IntelliJ IDEA highlights such cases with an inspection and offers solutions: </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/ytBSpIZYX4TPJdxB0uThGuMdvZ3K8rqCkY1_DRmGLwTvNcnARAdroSvojByJrXA1UhGdgxWCqPiA1kB6kiJ204TJqJ0zktt-HxB-l_Rue_O_RfSJhuEZRLmoVywYFh1skLf-GK_xQvJeoKnpotMjhZw" alt=""/></figure>
<ul>
<li><strong>Logging the exception</strong></li>
</ul>
<p>One way of handling the exception is to log it with the help of e.printStackTrace(), which prints the stack trace to the console, helping us identify and debug potential issues.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/myXLeXZGaTNzVrpj4IYDPdJvJ6PsoZIs8QGymwDOafZpp0IPnPS-5QzVKfkEcask9cpihqN2YkW2Zs17h6DB2I4sJzKpdKz7buvG6ANIC9Wi_ph7Br6bfVqnm4zjsLZTg-3rzedEU6o8f9_IPAv5su0" alt=""/></figure>
<ul>
<li><strong>Logging the exception and rethrowing it</strong></li>
</ul>
<p>In an ideal world, the catch block would identify IOException, then print an error message to the console and rethrow the exception to handle it later. </p>
<p>This way, you get the full picture of what went wrong.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/jN6h0J1bfXeaWoAqdNDyVJmFZvXkqbH4PSCD5BefpNZbeVahEkhvjN1UDj1444hvqV8Ly31rsNYpnujkuBIEznnCHBQuqNI3k2M8tsmhXxiaSfMyn1ngbpryfVB7GbYWkQJtuOL-MD8k-Xgw08xZQn8" alt=""/></figure>
<ul>
<li><strong>Logging the exception and returning an alternate value</strong></li>
</ul>
<p>Another way of solving the empty catch block issue is by logging the exception but returning a meaningful value. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/dbAWL1ZOLxfyOV-eQqkILKgvCGKX1P0ocwmLzJg6NBdlYpxmODP-svgsRt15ra__wGigDKoPRekSu4ie3dZr11n9-42C1UE1PYIUhGtysexNTnwelFiXE6afiiiRnppm5V0HcSDUkoXTDRqW7-lzkPE" alt=""/></figure>
<h3 class="wp-block-heading">Choose collections over arrays for greater flexibility</h3>
<p>While arrays in Java are efficient and easy to use, they are also fixed in size and offer limited operations, making them less adaptable for various data manipulations. </p>
<p>Collections in Java provide far more flexibility and utilities, such as ArrayList or HashSet. For example, ArrayList offers dynamic resizing and many utility methods, and is easier to work with, especially with generics. Let’s take a look at this through some code examples: </p>
<ul>
<li><strong>Arrays</strong></li>
</ul>
<p>We’ve created an array of Strings. Since arrays in Java are fixed size, if we wanted to add an eleventh element, we’d have to create a new array and copy over all of the elements.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/PAeQzfw-tXDRj-Maer1DkTXlfgPe3iBlrlYgCd7yGAKLYgtMDDc4FG1zRea8VHP8RZQyzX2dR1uu04UrIrTfxNKyBUr8S18bd94pA9QI01Wxx5IelfgfDCP8T2Ipr9071TlxjsM8g3_UAzbzVRczI7s" alt=""/></figure>
<ul>
<li><strong>Collections</strong></li>
</ul>
<p>As an alternative to the previous code, we can use a collection class called ArrayList. Collections like ArrayList can grow and shrink at runtime, providing greater flexibility. They also come with powerful methods to manipulate data, such as .add(), .remove(), .contains(), .size(), and more.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/cSPL0AYbF1BkspUa5unzGol2oR0yToIOq74-61dkzXM50lsP0amzlikMRefVmMYv6xYqEKr0nP2lM8I9mdwly2SjBAL2780Yem4FFyZcs9FplHonrxDNAu_K2DFZk_I9AEngA08ZR_73KYt7sJ2-r7w" alt=""/></figure>
<h3 class="wp-block-heading">Embrace immutability</h3>
<p>Immutable objects are objects whose state cannot be changed after creation. They help to write safer and cleaner code by removing the complexities associated with tracking mutable state changes. This minimizes the risk of bugs and unintended side effects, ensures consistent behavior, and simplifies the process of debugging and maintaining the application. In Java, we achieve immutability using final. </p>
<ul>
<li><strong>No </strong><strong>final</strong></li>
</ul>
<p>In this example, we’ll create a Car class and print its brand and model. After that, we’ll change the car’s model and print it again. The console output will show that the state of the Car class has been changed, illustrating mutable behavior.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/xYr8bZtYQhJkFhE_G1F_uaJvN2-DJzdw5yari28i4YaMrbut4NbpqU3UwE7tdur2GsUa--5juGyZnaYmy9RgjLNonR81E4Iusfr8TvqwdfFl9MMqYpbnbbbPNjsmA2uitLCdMRQt5V3ZD90veQdi0As" alt=""/></figure>
<ul>
<li><strong>With </strong><strong>final </strong></li>
</ul>
<p>In the improved code below, you can see that we’ve done the same, but we can’t change the car model or brand because we don’t have a setter method and the Car class is final. The console output will show that the state of the Car class remains the same, illustrating immutable behavior.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/pckS5OwMP5QiuXq7f3Rn7Di6h2OYuZdYga8-w9zl7B1GdKNP6E8e7bk6y9jpJ1RoXPKGJpLmQ7lSRp3cJtmpcTuG5UT3RK7b-JMkgEO15gjHI_k3Qu3J6PWQVN_uoWoXmgrN3lBx13Es8_vw51hAZcU" alt=""/></figure>
<h3 class="wp-block-heading">Favor composition over inheritance</h3>
<p>In Java, it’s usually better to use composition (having a reference or dependency on an object of another class) instead of inheritance (creating a subclass from a superclass). Composition makes the code more flexible and easier to test.</p>
<ul>
<li><strong>Inheritance</strong></li>
</ul>
<p>In our example, GamingComputer inherits from BasicComputer. This can cause problems because if BasicComputer changes, it might break GamingComputer. Also, GamingComputer is locked into being a type of BasicComputer, limiting its flexibility. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="530" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image6-2.png" alt="" class="wp-image-448583"/></figure>
<ul>
<li><strong>Composition </strong></li>
</ul>
<p>In the second example, the Computer class is composed of Memory and Processor which are separate class instances that act as fields. Each of these classes defines its methods and behaviors independently. This approach is more flexible as you can swap different Memory or Processor types or change their behavior at runtime without changing the Computer class. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="1430" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image4-1.png" alt="" class="wp-image-448594"/></figure>
<p>For more examples, take a look at <a href="https://blog.jetbrains.com/idea/2024/01/easy-hacks-how-to-create-inheritance-in-java/">Easy Hacks: How to Create Inheritance in Java</a>.</p>
<h3 class="wp-block-heading">Streamline functional interfaces with lambdas</h3>
<p>Functional interfaces in Java are a type of interface that has just one abstract method. Lambdas provide a sleek, expressive way to implement them without the boilerplate code of anonymous classes. </p>
<ul>
<li><strong>Without lambdas</strong></li>
</ul>
<p>Below we’ll use an anonymous inner class to implement the Comparator interface for sorting. This is bulky and may become unreadable with more complex interfaces.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/_t1KRobaEFNj4DeQDGxu3BdYq7A1aCGW-Rhep9fMMhEnwwLTs2FHyya6Q7xu7brzARuMIN0_sEC60tWRAa72KyeJmuxXmJgI0bcR_soCx815RD6Ae34cxm1hrytt3BfuSipKa74k-ZDllr-uV4dX-O4" alt=""/></figure>
<ul>
<li><strong>With lambdas</strong></li>
</ul>
<p>This code does the same as above, but we are using a lambda function instead of an anonymous class. This makes the code much more compact and intuitive.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/UBzRQ3Ff7P5gSIxxeODOPckuIrHH4sUR2p6yX5z-Ifh8WbOjD4PmfoXUCxMLcSbE4eUmzK9gdoOkqSUbnveMWUkif6Vsb55y1ivlXnuRJkOhDN3NyIQce_C76iJesU2xYaKqZXxGANSv5dsJM4OhmXo" alt=""/></figure>
<h3 class="wp-block-heading">Use enhanced for loops or streams</h3>
<p>Enhanced for loops (for-each loops) and streams in Java offer more readable and compact ways to iterate over collections or arrays compared to a traditional for loop.</p>
<ul>
<li><strong>Classic </strong><strong>for</strong><strong> loop </strong></li>
</ul>
<p>In this code, we’re using a for loop to go over the list. It requires a counter, handling the element index, and defining the stopping condition – all of which add to the complexity.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/WI-GIKvCK4d-oRi0PzDBY6Qp6jBLQH1N5mXRtyXwFnkbRE8tq216avDEwZpu5SMTX9WoMw3Hwegig5QGMvToF8kKA2iWhmEi6D7maJye8zcyjJL6IVDO7QRP3pcDUsJDL1Uzwh4bz_cMcN5SSe8_4qg" alt=""/></figure>
<ul>
<li><strong>Enhanced </strong><strong>for</strong><strong> loop</strong></li>
</ul>
<p>This loop (forEach) eliminates the need for counters and directly gives us each item in the list, simplifying code and reducing the potential for errors. You can apply it with the help of an inspection in IntelliJ IDEA. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/sWUaYw6oRg5VMJkWylh1Mxnutj6HY8kGlmtxZbl2n_IH3DWqUvSBOzRoNrmTqO_lQswN36X5GrmRz-TNRvajN0S1DvsEozVYIAFBSa6ZeAqAkrYf-p0jdiqqorvrXAhS3XH5p9hSPCAdoPDlw_8KUwM" alt=""/></figure>
<ul>
<li><strong>Streams</strong></li>
</ul>
<p>The usage of streams gives us each item, like the enhanced for loop, but also allows us to do complex operations like filtering and mapping.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/nxMdkTQc2mF7juvmfX8RbOE8ETRYnLHzXYNvnhhLwYa2gTDRUlPrAacHfi4AD60AGREF6zaFsvvaBnOkkBTesnpeiK_T3UNXWcYdDYgCzcOfcubUnTV-LKsSnAe_LT2Bu6VA1zPovSuFO7EV4XcVn5Q" alt=""/></figure>
<h3 class="wp-block-heading">Safeguard resources with try-with-resources statements</h3>
<p>Try-with-resources statements help you ensure that each resource is closed properly after use. Not closing resources in a try block can cause memory issues and application errors, impacting performance and reliability.</p>
<ul>
<li><strong>Closing resources manually</strong></li>
</ul>
<p>In the example below, we handle the system resource FileInputStream manually, which may lead to a resource leak and other problems if an exception is thrown while closing. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/x49U3KI5p86ZQbUPY6JpfZC1jYIjKP4Z3uBP07jV_U4YLmAQtjsrdVWnJPXfKP3OpHRHc87qTvfzjaKl6WEEiFmrmHKzwLweYHNYFfCNWXfWyPEQbaUlF5KWlkhGkA-KR4ZFOVgQV4Lky_CQIsKzEUw" alt=""/></figure>
<ul>
<li><strong>Using </strong>try<strong>-with-resources statements</strong></li>
</ul>
<p>In the improved version, declaring FileInputStream inside the try block means Java will automatically close it, regardless of whether we leave the try block normally or with an exception.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/HbGUZq71hznydgsQuT2yatcXPy0OtMnYY5-cY5Ca4Kf1qU8223aAEgWMI27nZtEGR-OyOhYSedugGDZnKXFojGsdhDDVFGxaQGxEZeOVNVGxXVoQD_qUjO75wE_bNW82mUoF6v0bNPvDhaklx7NEFe0" alt=""/></figure>
<h3 class="wp-block-heading">Untangle deeply nested code</h3>
<p>Deeply nested code highlights logical issues that can be difficult to notice initially. This often comes from using lots of conditionals, which are the coding essentials, so we can’t just get rid of them. However, we do need to find ways to simplify the code.</p>
<ul>
<li><strong>Numerous conditionals</strong></li>
</ul>
<p>You can see how strange abundant nested conditionals look. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/iaeo30p4MAEfEjJ0h6rgNuINiqQ3JqxuSciRhPXOCePdyzBBjHm0OI1l6fFBFGKEL6M_rTvhQMfI_BJyxeuylemzgFNL0byHe1OAYIBDcvaP2THPEyTTenpuMjMTwNYKE197mQA7qKA6iuZGIpxXAIg" alt=""/></figure>
<ul>
<li><strong>Refactored code</strong></li>
</ul>
<p>We’ve used a “guard clauses” technique to eliminate nested conditionals. By quickly exiting the function when certain conditions are met, we preserve the same logic with cleaner-looking code.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/E2o0prXGO0Fn1eqD8iXlAY6OZ2F5dcACV9mBESHTZ3AViQe7rVCGXPYsfV9wVNYKN8uOEcDgJ7MkpQ1Nx-eeVVhPirARWfK1K1gIkm88EtcXQviXTTYsezLYodgGGd8vHFlIbu7R5dBuI0x55Yw_C_0" alt=""/></figure>
<h2 class="wp-block-heading">Project-specific </h2>
<p>We also have some helpful dos and don’ts for working on projects that contain multiple dependencies. </p>
<h3 class="wp-block-heading">Keep dependencies up to date </h3>
<p>Remember to keep your project’s dependencies updated to enhance security, introduce new features, and fix bugs. Regular updates ensure your project runs smoothly and remains compatible with other tools. </p>
<p>IntelliJ IDEA can help you keep your dependencies up to date. First, install the Package Search plugin from JetBrains Marketplace via <em>Preferences/Settings | Plugins</em>. Then navigate to the <em>Dependencies</em> tool window to see all of the existing dependencies in your project and click the <em>Upgrade</em> link next to them. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/v7a_sygKJBUH46YdX72jda6_U82VCtfZ_kAV9_dVvAX96OypLlreOEV72rxX-rcqaItPN_ym94q9zL_XGTc5xGkLpLIhfXE6FQPqlln-Sii76FdyF9kgtFDY9UYnYfNUKgi94hI9TEI5fccmCMhf1VU" alt=""/></figure>
<h3 class="wp-block-heading">Check for vulnerable dependencies and APIs</h3>
<p>Regularly scanning your project for weak spots in dependencies and APIs helps you minimize security risks, stick to predefined rules, and keep things running smoothly. Addressing these vulnerabilities quickly helps protect your project and its users from potential threats.</p>
<p>To find vulnerable dependencies in IntelliJ IDEA, navigate to <em>Code | Analyze Code</em> and select <em>Show Vulnerable Dependencies</em>. The findings will appear in the <em>Vulnerable Dependencies</em> tab of the <em>Problems</em> tool window.</p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/c629wfGRdXWE_RNuEzc3UpRmalBuLps21aQ80EXyztqzCY-Heu96WM7GUHjKoi4MclMul7V1AP2WlWAMcx5kkHpaFrxMlB_-mGhaXTtouAK7_BrAK3J4AJH89mWADU-ZJiUCm3kv_PInMnfYVj9B_ZE" alt=""/></figure>
<p>You can also right-click a folder or file, like pom.xml or<em> </em>build.gradle, in the <em>Project</em> tool window and choose <em>Analyze Code | Show Vulnerable Dependencies</em> from the context menu. </p>
<p>Even without explicitly checking for vulnerabilities, IntelliJ IDEA will highlight vulnerabilities in pom.xml or<em> </em>build.gradle. </p>
<figure class="wp-block-image"><img decoding="async" src="https://lh7-us.googleusercontent.com/3gRj9n587wvDfr_pf1q0rB66cNqndiEZtxsmVdEnuCo0qUhhSA5NsvuXCgwAkePqOSW9_dgOUxIEIp2A4n4yKD8a79kuixHfYK1UMshpHPhav5XI0j5OfLHtDkYAivyIbMtzeBUzZfWz2sTjikEN0-s" alt=""/></figure>
<h3 class="wp-block-heading">Avoid circular dependencies </h3>
<p>Circular dependencies happen when parts of your project rely on each other in a loop. For example, part A needs something from part B, but part B also needs something from part A. This can make your project messy and hard to work on because it’s tough to figure out where one part starts and another ends. It’s best to avoid these loops to keep things clear and easy to manage.</p>
<p>To avoid circular dependencies, you can <a href="https://www.jetbrains.com/guide/java/tutorials/dependency-matrix/" target="_blank" rel="noopener">use the Dependency Matrix</a>. It helps you visualize dependencies between components in your projects.</p>
<h2 class="wp-block-heading">Conclusion </h2>
<p>We hope that our advice simplifies your daily tasks and encourages you to write simple, clear, and professional code, inspiring you to become a more efficient developer. </p>
<p>IntelliJ IDEA will help you find many of the items discussed in this blog post and provide automatic fixes. Give it a try and let us know what you think!</p>
]]></content:encoded>
</item>
<item>
<title>IntelliJ IDEA 2024.1 EAP 6: Improved Workflow for Logs, Inline Breakpoints, In-Editor Code Review, and More</title>
<link>https://blog.jetbrains.com/idea/2024/02/intellij-idea-2024-1-eap-6/</link>
<dc:creator><![CDATA[Maria Kosukhina]]></dc:creator>
<pubDate>Thu, 22 Feb 2024 16:16:05 +0000</pubDate>
<category><![CDATA[eap]]></category>
<category><![CDATA[2024-1-eap]]></category>
<category><![CDATA[intellij-idea-2024-1]]></category>
<category><![CDATA[intellij-idea-2024-1-eap]]></category>
<guid isPermaLink="false">https://blog.jetbrains.com/?post_type=idea&p=447285</guid>
<description><![CDATA[IntelliJ IDEA 2024.1 EAP 6 is here! This new build is packed with a bunch of updates anticipated for the next major release. Highlights include an enhanced user experience with logs, advanced debugging capabilities, and improved integration with version control systems. You can download the new version from our website, update directly from the IDE […]]]></description>
<content:encoded><![CDATA[
<p>IntelliJ IDEA 2024.1 EAP 6 is here! This new build is packed with a bunch of updates anticipated for the next major release. Highlights include an enhanced user experience with logs, advanced debugging capabilities, and improved integration with version control systems.</p>
<p>You can download the new version from our <a href="https://www.jetbrains.com/idea/nextversion/" target="_blank" rel="noopener">website</a>, update directly from the IDE or via the free <a href="https://www.jetbrains.com/toolbox-app/" target="_blank" rel="noopener">Toolbox App</a>, or use snaps for Ubuntu.</p>
<p align="center"><a class="jb-download-button" href="https://www.jetbrains.com/idea/nextversion/" target="_blank" rel="noopener">Download IntelliJ IDEA 2024.1 EAP #6</a></p>
<p>To learn about other new features introduced in the ongoing Early Access Program, browse through the <a href="https://blog.jetbrains.com/idea/tag/2024-1-eap/">2024.1 EAP blog posts</a>. Now, let’s dive into what this week’s EAP build has to offer!</p>
<h2 class="wp-block-heading">Java </h2>
<h3 class="wp-block-heading">Improved workflow for logs</h3>
<p>Logging is an important part of daily development, aiding in monitoring, troubleshooting, and optimizing applications. We’ve introduced a range of updates to enhance the user experience with logs.</p>
<p>First, we’ve implemented an option to navigate from a specific log message in the console to the code that generates the output. You can control this feature in <em>Settings/Preferences | Advanced Settings | JVM languages.</em></p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/logs-nav.gif" alt="" class="wp-image-448015"/></figure>
<p>To ensure the presence of loggers throughout your codebase, IntelliJ IDEA now suggests adding loggers that are potentially available in that location. Upon selection, the declaration of the corresponding logger will be inserted in the top-level class.</p>
<p>The IDE’s code completion functionality now suggests logger statements even when the logger instance is not currently in scope, eliminating the need for manual import or declaration.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-17.gif" alt="" class="wp-image-447321"/></figure>
<p>Alternatively, users can utilize code generation (<em>⌘N / Alt+Insert</em>) to insert loggers seamlessly.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-18.gif" alt="" class="wp-image-447332"/></figure>
<p>These features are supported for various popular logging systems, including JUL, Log4j 2, SLF4J, and lombok annotations (<code>@Slf4j</code>, <code>@Log2j</code>, etc.).</p>
<h2 class="wp-block-heading">Debugger</h2>
<h3 class="wp-block-heading">Inline breakpoints for multiple statements</h3>
<p>IntelliJ IDEA 2024.1 EAP 6 offers a more convenient workflow to set breakpoints in lines containing lambda functions or <code>return</code> statements. Once you set a breakpoint by clicking on the gutter, the IDE automatically displays inline markers where additional breakpoints can be set. Each breakpoint can be configured independently, unlocking advanced debugging capabilities.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Inline-breakpoints.gif" alt="" class="wp-image-447343"/></figure>
<h3 class="wp-block-heading">Folded library calls in the call stack</h3>
<p>Library calls are now folded by default in the call stack in the <em>Debug</em> tool window, which enables more focused browsing of your own code.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-80.png" alt="" class="wp-image-447354"/></figure>
<p>However, if you need to verify the library call sequence, you can expand the group and explore the frames accordingly. To reveal the list, use the<em> Filter</em> icon in the toolbar or call the context menu and disable the <em>Hide Frames from Libraries</em> option. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-81.png" alt="" class="wp-image-447365"/></figure>
<h2 class="wp-block-heading">Version control systems</h2>
<h3 class="wp-block-heading">In-editor code review</h3>
<p>IntelliJ IDEA 2024.1 EAP 6 introduces a more streamlined and agile code review workflow for both GitHub and GitLab users. Authors and reviewers can now seamlessly interact directly within the editor, thanks to the implementation of the new review mode.</p>
<p>Once the pull/merge request branch is checked, the review mode is automatically enabled. When you open a source file related to the pull/merge request, either from a diff or from the <em>Project</em> tool window, you’ll notice purple controls on the gutter. These indicate changes made to the lines of code that are available for the code review workflow. For both authors and reviewers, clicking on these markers reveals a popup showing the original code, making it easier to understand the change. Use the icons in the gutter to discuss changes by clicking the + icon appearing on hover to start a new discussion. Click the<em> Message</em> icon to open or hide existing comments where you can reply, react, and resolve threads.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="3743" height="2051" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/In-editor-code-review.png" alt="" class="wp-image-447366"/></figure>
<p>You can use the widget in the editor’s upper right corner to see only unresolved discussions or turn off the review mode completely. You can also toggle the review mode on and off from the VCS widget.</p>
<h3 class="wp-block-heading">Support for reactions on code review comments </h3>
<p>IntelliJ IDEA 2024.1 EAP 6 brings support for reactions to review comments for GitHub pull requests and GitLab merge requests. You can now select from a set of emojis to add reactions to your code review comments.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/reactions.png" alt="" class="wp-image-447476"/></figure>
<h3 class="wp-block-heading">CI check statuses in the <em>Git</em> tool window </h3>
<p>We’ve introduced a new column in the <em>Log</em> tab of the<em> Git</em> tool window, allowing you to easily review the results of GitHub commit checks performed by your CI system. Simply click on it to view the full details of the CI checks. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/CI.png" alt="" class="wp-image-447387"/></figure>
<h3 class="wp-block-heading">Create pull/merge requests from push notifications</h3>
<p>After successfully pushing your changes to the version control system, the IDE will now alert you with a single notification informing you about the successful push and suggesting an action to create a pull/merge request.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/Create_PR_on_push.png" alt="" class="wp-image-447420"/></figure>
<h3 class="wp-block-heading">Preventing large file commits to repositories</h3>
<p>To prevent instances where the version control system rejects pushes due to files exceeding size limits, we’ve introduced a mechanism that prohibits committing such files. The IDE will now perform a pre-commit check and notify you about the restriction. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-82.png" alt="" class="wp-image-447398"/></figure>
<h3 class="wp-block-heading"><em>Allow unrelated histories</em> merge option </h3>
<p>We’ve enhanced the <em>Merge into</em> dialog with the addition of the <em>Allow unrelated histories</em> option. When selected from the drop-down menu, this option enables the merge operation to proceed even if the two branches being merged have no common history.</p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1600" height="685" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-83.png" alt="" class="wp-image-447409"/></figure>
<h3 class="wp-block-heading">Branch filter for the <em>History</em> tab of the <em>Git </em>tool window</h3>
<p>We’ve revamped the user experience with file history in the <em>Git </em>tool window. First, the <em>Show all branches</em> button has been replaced with a branch filter, enabling you to review changes made to a file within a designated branch. We’ve also adjusted the toolbar orientation, positioning it horizontally for improved usability. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/History_filter.png" alt="" class="wp-image-447431"/></figure>
<h3 class="wp-block-heading"><em>Stash</em> tab in the <em>Commit </em>tool window</h3>
<p>For users who rely on stashes to store temporary uncommitted changes, we’ve introduced a dedicated tab within the <em>Commit</em> tool window for convenient access.</p>
<p>If you utilize both stashes and shelves, you have the option to enable a combined <em>Stashes and Shelves</em> tab via a corresponding checkbox in <em>Settings/Preferences | Version Control | Git</em>. </p>
<figure class="wp-block-image size-full"><img decoding="async" loading="lazy" width="1500" height="600" src="https://blog.jetbrains.com/wp-content/uploads/2024/02/image-84.png" alt="" class="wp-image-447464"/></figure>
<p>These are the most notable updates for this week. For the full list of implemented changes, refer to the <a href="https://youtrack.jetbrains.com/articles/IDEA-A-2100661868/IntelliJ-IDEA-2024.1-EAP-6-241.13688.18-build-Release-Notes" data-type="link" data-id="https://youtrack.jetbrains.com/articles/IDEA-A-2100661868/IntelliJ-IDEA-2024.1-EAP-6-241.13688.18-build-Release-Notes" target="_blank" rel="noopener">release notes</a>. </p>
<p>As the Early Access Program for v2024.1 is coming to its end, we encourage you to test out the new features and share your feedback with us – it helps us shape the final scope of the major release. You can use the comments section below or reach out to us on <a href="https://twitter.com/intellijidea" target="_blank" rel="noopener">X (formerly Twitter)</a>. If you spot a bug, please report it via our <a href="https://youtrack.jetbrains.com/issues/IDEA" target="_blank" rel="noopener">issue tracker</a>. </p>
<p>Happy developing! </p>
]]></content:encoded>
</item>
</channel>
</rss>