Beware of Computation in static {} Initializer
It’s a quite common practice to prepare immutable data during class initialization and save the results in static final fields. In fact, this is exactly what static initializers are designed for.
However you should be careful using it as it can cause significant performance degradation in new JDK versions as shown in this article.
#java #bug #performance #middle #senior
https://pangin.pro/posts/computation-in-static-initializer
It’s a quite common practice to prepare immutable data during class initialization and save the results in static final fields. In fact, this is exactly what static initializers are designed for.
However you should be careful using it as it can cause significant performance degradation in new JDK versions as shown in this article.
#java #bug #performance #middle #senior
https://pangin.pro/posts/computation-in-static-initializer
pangin.pro
Beware of computation in static initializer
Even though it's a common practice to prepare data in static initializers in Java, this can have a dramatic performance impact.
Can instanceof make Unmodifiable Collections faster?
In a battle-hardened code base, all normal bugs were fixed - those that remain are usually quite bizarre. This is a story of one such bug and how it uncovered a less than optimal implementation in the JDK itself.
#bug #java
https://www.opsian.com/blog/can-instanceof-make-unmodifiable-collections-faster/
In a battle-hardened code base, all normal bugs were fixed - those that remain are usually quite bizarre. This is a story of one such bug and how it uncovered a less than optimal implementation in the JDK itself.
#bug #java
https://www.opsian.com/blog/can-instanceof-make-unmodifiable-collections-faster/
Opsian
Can instanceof make Unmodifiable Collections faster?
In a battle-hardened code base, all normal bugs were fixed - those that remain are usually quite bizarre. This is a story of one such bug and how it uncovered a less than optimal implementation in the JDK itself.