{"id":3357,"date":"2025-12-24T10:00:50","date_gmt":"2025-12-24T15:00:50","guid":{"rendered":"https:\/\/www.mymiller.name\/wordpress\/?p=3357"},"modified":"2025-12-24T10:00:50","modified_gmt":"2025-12-24T15:00:50","slug":"nullpointerexcepiton-enhancements","status":"publish","type":"post","link":"https:\/\/www.mymiller.name\/wordpress\/java_new_features\/nullpointerexcepiton-enhancements\/","title":{"rendered":"NullPointerExcepiton enhancements"},"content":{"rendered":"\n<p>The NullPointerException is a common exception in Java that occurs when a null reference is dereferenced. This exception can make debugging difficult, as it does not provide any information about which variable was null, making it harder to pinpoint the cause of the issue. However, starting from Java 14, a new feature was introduced that makes it easier to identify the null reference that caused the exception. In this blog article, we will discuss how to use this feature to identify the variable that was null.<\/p>\n\n\n\n<p>Before Java 14, when a NullPointerException occurred, the error message simply stated &#8220;null pointer exception&#8221;. For example, if you were to run the following code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>String s = null; int length = s.length();\n<\/code><\/pre>\n\n\n\n<p>you would receive the following error message:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Exception in thread \"main\" java.lang.NullPointerException     at com.example.MyClass.main(MyClass.java:5)\n<\/code><\/pre>\n\n\n\n<p>This error message does not provide any information about which variable was null, making it difficult to debug the issue.<\/p>\n\n\n\n<p>Starting from Java 14, the NullPointerException now includes additional information that identifies the variable that was null. The error message now includes a message that specifies which variable was null. For example, if you were to run the same code as before on Java 14 or later, you would receive the following error message:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Exception in thread \"main\" java.lang.NullPointerException: Cannot invoke \"String.length()\" because \"s\" is null     at com.example.MyClass.main(MyClass.java:5)\n<\/code><\/pre>\n\n\n\n<p>This error message now includes the variable name &#8220;s&#8221;, making it easier to identify the null reference that caused the exception.<\/p>\n\n\n\n<p>To take advantage of this feature, you simply need to update your Java version to 14 or later. Once you have done so, any NullPointerException that occurs in your code will include the name of the variable that was null, making it easier to pinpoint and debug the issue.<\/p>\n\n\n\n<p>In summary, the NullPointerException in Java 14 and later now includes additional information that identifies the variable that was null, making it easier to debug issues caused by null references. By updating to Java 14 or later, you can take advantage of this feature and improve your debugging experience.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The NullPointerException is a common exception in Java that occurs when a null reference is dereferenced. This exception can make debugging difficult, as it does not provide any information about which variable was null, making it harder to pinpoint the cause of the issue. However, starting from Java 14, a new feature was introduced that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3360,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[458],"tags":[],"series":[],"class_list":["post-3357","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java_new_features"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2023\/06\/paper-g580d50d6b_640-1.jpg?fit=640%2C453&ssl=1","jetpack-related-posts":[{"id":3111,"url":"https:\/\/www.mymiller.name\/wordpress\/java_tips\/java-tips-part-1\/","url_meta":{"origin":3357,"position":0},"title":"Java Tips Part 1","author":"Jeffery Miller","date":"December 24, 2025","format":false,"excerpt":"Over the years I have done a number of code reviews there have been a number of common mistakes that I have found. So here are my Java tips a series of posts going over these tips. Tip 1: Throw original Exception Many times in our code we will catch\u2026","rel":"","context":"In &quot;Java Tips&quot;","block_context":{"text":"Java Tips","link":"https:\/\/www.mymiller.name\/wordpress\/category\/java_tips\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2021\/12\/sam-dan-truong-rF4kuvgHhU-unsplash-scaled-e1640791434235.jpg?fit=640%2C427&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2021\/12\/sam-dan-truong-rF4kuvgHhU-unsplash-scaled-e1640791434235.jpg?fit=640%2C427&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2021\/12\/sam-dan-truong-rF4kuvgHhU-unsplash-scaled-e1640791434235.jpg?fit=640%2C427&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":3909,"url":"https:\/\/www.mymiller.name\/wordpress\/spring\/making-injected-parameters-optional-in-spring-boot\/","url_meta":{"origin":3357,"position":1},"title":"Making Injected Parameters Optional in Spring Boot","author":"Jeffery Miller","date":"December 24, 2025","format":false,"excerpt":"As a software architect building solutions with Spring Boot, you'll often encounter scenarios where a component or service needs to consume another dependency that may not always be available. This could be due to a feature toggle, an environment-specific configuration, or a third-party integration that is only present in certain\u2026","rel":"","context":"In &quot;Spring&quot;","block_context":{"text":"Spring","link":"https:\/\/www.mymiller.name\/wordpress\/category\/spring\/"},"img":{"alt_text":"","src":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/09\/option-1010899_1280.avif","width":350,"height":200,"srcset":"https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/09\/option-1010899_1280.avif 1x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/09\/option-1010899_1280.avif 1.5x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/09\/option-1010899_1280.avif 2x, https:\/\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2025\/09\/option-1010899_1280.avif 3x"},"classes":[]},{"id":3614,"url":"https:\/\/www.mymiller.name\/wordpress\/java\/lombok-annotations-that-do-the-heavy-lifting\/","url_meta":{"origin":3357,"position":2},"title":"Lombok: Annotations That Do the Heavy Lifting","author":"Jeffery Miller","date":"December 23, 2025","format":false,"excerpt":"If you\u2019re a Java developer who\u2019s tired of writing repetitive boilerplate code, Lombok is your new best friend. This clever library uses annotations to automatically generate common code elements, making your classes cleaner, more concise, and less error-prone. Why Lombok? The Benefits Reduced Boilerplate: Lombok takes care of getters, setters,\u2026","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.mymiller.name\/wordpress\/category\/java\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/04\/ai-generated-8314612_640.jpg?fit=640%2C480&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/04\/ai-generated-8314612_640.jpg?fit=640%2C480&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/04\/ai-generated-8314612_640.jpg?fit=640%2C480&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":3569,"url":"https:\/\/www.mymiller.name\/wordpress\/spring_ai\/integrating-prolog-with-spring-boot\/","url_meta":{"origin":3357,"position":3},"title":"Integrating Prolog with Spring Boot","author":"Jeffery Miller","date":"September 22, 2025","format":false,"excerpt":"Prolog, a declarative logic programming language, shines in solving specific types of problems that require knowledge representation and logical inference. Integrating Prolog with Spring Boot can bring the power of logic programming to your Java applications. 1. Setting Up Your Environment Add JPL Dependency: Include the Java Prolog Interface (JPL)\u2026","rel":"","context":"In &quot;Spring AI&quot;","block_context":{"text":"Spring AI","link":"https:\/\/www.mymiller.name\/wordpress\/category\/spring_ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/06\/Gemini_Generated_Image_avkkoeavkkoeavkk.jpg?fit=1200%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/06\/Gemini_Generated_Image_avkkoeavkkoeavkk.jpg?fit=1200%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/06\/Gemini_Generated_Image_avkkoeavkkoeavkk.jpg?fit=1200%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/06\/Gemini_Generated_Image_avkkoeavkkoeavkk.jpg?fit=1200%2C1200&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/06\/Gemini_Generated_Image_avkkoeavkkoeavkk.jpg?fit=1200%2C1200&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2023,"url":"https:\/\/www.mymiller.name\/wordpress\/java\/simplifying-javafx-display-management-with-displaymanager\/","url_meta":{"origin":3357,"position":4},"title":"Simplifying JavaFX Display Management with DisplayManager","author":"Jeffery Miller","date":"April 20, 2026","format":false,"excerpt":"JavaFX provides a powerful platform for creating rich graphical user interfaces (GUIs) in Java applications. However, managing multiple displays and screens within a JavaFX application can be a complex task. To simplify this process and provide a flexible solution, we've developed the DisplayManager framework. In this article, we'll explore how\u2026","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.mymiller.name\/wordpress\/category\/java\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2016\/12\/board-1364650_640.jpg?fit=640%2C452&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2016\/12\/board-1364650_640.jpg?fit=640%2C452&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2016\/12\/board-1364650_640.jpg?fit=640%2C452&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":2866,"url":"https:\/\/www.mymiller.name\/wordpress\/java_extra\/complex-queries-for-java-data\/","url_meta":{"origin":3357,"position":5},"title":"Complex Queries for Java data","author":"Jeffery Miller","date":"December 24, 2025","format":false,"excerpt":"Recently a project I was working on called for a complex filter that was needed for selecting specific elements from a large data set. Looking at various methods of doing this, none provided a simple method to do so. First I wrote out my own Predicate<T> that was ugly with\u2026","rel":"","context":"In &quot;Java Extras&quot;","block_context":{"text":"Java Extras","link":"https:\/\/www.mymiller.name\/wordpress\/category\/java_extra\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/10\/maze-2264_640.jpg?fit=640%2C256&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/10\/maze-2264_640.jpg?fit=640%2C256&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/10\/maze-2264_640.jpg?fit=640%2C256&ssl=1&resize=525%2C300 1.5x"},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts\/3357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/comments?post=3357"}],"version-history":[{"count":2,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts\/3357\/revisions"}],"predecessor-version":[{"id":3361,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts\/3357\/revisions\/3361"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/media\/3360"}],"wp:attachment":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/media?parent=3357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/categories?post=3357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/tags?post=3357"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/series?post=3357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}