| [Issue
162] Exceptions in Java
In this article, we look at exception handling in Java. We
start with the history of exceptions, looking back at the
precursor of Java, a language called Oak. We see reasons
why Thread.stop() should not be used and discover the
mystery of the RuntimeException name. We then look at some
best practices that you can use for your coding, followed
by some worst practices, in the form of exception
anti-patterns. |
[Issue
161] Of Hacking Enums and Modifying "final static" Fields
The developers of the Java language tried their best to
stop us from constructing our own enum instances. However,
for testing purposes, it can be useful to temporarily add
new enum instances to the system. In this newsletter we
show how we can do this using the classes in sun.reflect.
In addition, we use a similar technique to modify static
final fields, which we need to do if we want the switch
statements to still work with our new enums. |
| [Issue
160] The Law of the Uneaten Spinach
Imagine a very stubborn father insisting that his equally
stubborn child eat its spinach before going to sleep. In
real life one of the "threads" eventually will give up, but
in Java, the threads become deadlocked, with neither giving
an inch. In this newsletter we discover how we can
sometimes escape from such deadlocked situations in Java
and learn why the stop() function should never ever ever be
called. |
[Issue
159] The Law of Sudden Riches
We all expect faster hardware to make our code execute
faster and better. In this newsletter we examine why this
is not always true. Sometimes the code breaks on faster
servers or executes slower than on worse hardware. |