Geoffrey De Smet Profile picture
Timefold co-founder, OptaPlanner creator, Java, open source contributor, speaker, Planning Optimization AI
Oct 4, 2022 16 tweets 5 min read
Most @java programmers only use 10% of their... debugger.

Use the full power of your debugger with advanced breakpoints.

Diagnose complex bugs in minutes, instead of hours.

Test your debugger skills with 4 challenges in this thread. Works with @intellijidea and other IDEs. 🧵 1) Challenge

Line 8 throws a division by zero exception.
Presume line 5 and 6 are hidden in 1000 lines of code.

How do we find out if variable a or variable b is causing it? Image
May 31, 2022 4 tweets 2 min read
The JVM does not load all classes in the classpath.
It only loads the ones it needs. What triggers the JVM to load a particular #Java class?

Then answer might surprise you.
Consider the code below. What does it print?

Let's show the output and explain why. 🧵 Answer:
Class A, C and D are loaded.
Class B, E and F aren't.

Class F is never used, so it obviously isn't loaded.

Notice that MyBean contains fields of type B (static) and type E (non-static), but the B and E classes aren't loaded, because no instances are created.
May 17, 2022 11 tweets 5 min read
You can probably optimize your @Java programs to run 2-10x faster, by focusing on the bottlenecks.

Those bottlenecks are not where you think they are.

Use free tools such as async-profiler, VisualVM, JFR and vmstat to find them.

Let me show you how. 🧵 Create a main() Java application that runs the bulk of your code on a seriously sized dataset for at least a minute.

Run async-profiler and Java Flight Recorder (JFR) on that, either from the command line (free) or through @intellijidea Ultimate (paid) as shown below.