VOOZH about

URL: https://thenewstack.io/trash-pandas-love-enterprise-java-code/

⇱ Trash Pandas Love Enterprise Java Code - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-06-13 08:16:47
Trash Pandas Love Enterprise Java Code
sponsor-azul,sponsored-post-contributed,
CI/CD / Java / Operations

Trash Pandas Love Enterprise Java Code

Garbage code — a raccoon's favorite — is a maintenance burden that developers must work around to keep passing tests while other major changes are made.
Jun 13th, 2024 8:16am by Erik Costlow
👁 Featued image for: Trash Pandas Love Enterprise Java Code
Image from HappyPictures on Shutterstock.
Azul sponsored this post.

If raccoons were software engineers, they would feel at home inside many enterprise systems. These systems are often full of unused and dead code that was written, fully tested, then altered in a way that prevents teams from ever running it.

This garbage code — a raccoon’s favorite — is a maintenance burden that developers must work around to keep passing tests while other major changes are made. This code often doesn’t end up in the trash because it’s hard to know what can be safely removed without breaking the application. But you can better identify bad code if you understand how to look for it.

The typical way to identify dead or unused code is through static analysis or log review. Modern IDEs can detect unused and dead code via reachability analysis, but there is a soundness problem for classes and methods that aren’t 100% private. If the code has a public access modifier, then it could load so your tools will never report it.

Other times when code is tracked, it runs in a unit test — technically, this code is not dead. Unfortunately, while test-driven design is a good practice, there are portions of code that are alive only because a unit test fails when that code is removed. All this testing does is verify that unnecessary baggage fulfills its original design.

Although removing the unused and dead code makes the test go red, developers can also remove this test and speed up the overall build pipeline by not having to run it anymore. The best way to get a full picture of which code can be thrown away is to separately monitor test and production environments and see what happens.

Unused and Dead Code Is Clutter

Many teams have a “why worry” attitude: How much unused and dead code can there actually be, and why does it matter? Unused and dead code is clutter that slows down the present and future. Every time someone works on the application, they have to work around that code. When a major change is made, like upgrading from Java 11 to 17 or 21, all that unnecessary code needs to be maintained. The build pipeline takes time to ensure that the code works, regardless of whether the code matters.

When a major U.S. financial institution set out to identify and remove unused code, it was able to “reduce the size of a codebase by 67%.” The reduced complexity improved developer experience so much that developers released updates to the application over 250 times in a year and finally upgraded some of the older libraries that had held them back.

A similar IEEE study of an industrial software system found that up to 50 percent of a large codebase was unused or dead, and the overall average was 5% to 10% of code was unused or dead. The larger and older an application is, the higher the percentage.

Unused and Dead Code in Java

Java engineers can treat unused and dead code detection similar to garbage collection: Choose your setting and let the JVM do the rest. The question of whether code is used in production is answered by whether the method is ever called (or inlined). The recording of this decision is made in one of three places: the bytecode interpreter, AppCDS (Application Class Data Sharing) or the ReadyNow feature of Azul Platform Prime. If the method is used again, there’s no need to affect performance beyond recording the first call. The method was used in production, so the code is not unused or dead. In this scenario, JVM runs are tagged with the “application environment” to help record which application called the method for a given environment. Keeping these environments separate helps identify cases where the code and unit tests only serve to keep each other alive.

Monitoring code to see what you can throw away requires the added dimension of time. Until you’ve watched the application for a bit, plenty of the code hasn’t run. Here teams often separate dead code into two parts: things they think they can get rid of but just aren’t sure about, and things that need a longer time to see — often based on some type of periodic activity associated with the business cycle.

Developers may be suspicious that certain parts of the code are unused or dead, but not confident enough to delete it. The path would be to track code inventory, perform some actions in the application and see if those methods were reported as running. If they were, then the code is live; if not, it’s probably unused or dead. Other functionality, like a year-end report, needs to run its course to do detection. This is why monitoring the live-ness of code is best done over time. The short victories can be won early, then more code can be tossed aside later.

Code Inventory Reduces Code Clutter

Azul’s Code Inventory differs from typical static analysis tools and IDEs that detect unreachable code. The monitoring from Code Inventory occurs from the running JVM to identify entire classes or public methods that are present but don’t run. It’s a clutter finder — a raccoon repellant. It accurately identifies unused and dead code for removal by precisely detailing what custom and third-party code is running.

Dead code detection improves developer productivity and developer happiness. It’s a burdensome chore to maintain code whose sole purpose is to satisfy a test that ensures that the unnecessary code works. By detecting unused and dead code, developers can safely throw it into the trash — a tasty treat for our raccoon friends.

Azul provides the Java platform for the modern cloud enterprise. Millions of Java developers, hundreds of millions of devices, and the world’s most highly regarded businesses trust Azul to power their applications with exceptional capabilities, performance, security, value and success.
Learn More
The latest from Azul
TRENDING STORIES
Erik Costlow is a software security expert with extensive Java experience. He handles the security of Azul's JVMs that operate at peak speed while making security easier and better for all. Erik was the principal product manager in Oracle focused...
Read more from Erik Costlow
Azul sponsored this post.
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Class.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.