Series ‘Hacking Java Puzzlers for Fun and Profit’

Consequences when using Mutable Fields in hashCode()

We start our new series with an informative HashSet puzzler. It’s about a bug that gave us quite a headache since its root cause was hard to identify. This subtle bug has without doubt crept into many code bases, so a detailed discussion should interest every Java coder. I will also discuss code inspection tools that detect this violation (sadly, only few). And by the way, what we learned about HashSet also makes a good topic in our job interviews.

Read the rest of this entry »  |   Share

Regular Expressions: Splitting Pipes

It’s a common saying in IT: “I had a problem and used regular expressions to solve it. Now I’ve two problems”. We want to offer help in a series of mgm “Hacking Java Puzzler” blog entries and demonstrate how regular expressions can be useful anyway. In this first episode we will focus on splitting CSV lines.

Read the rest of this entry »  |   Share

Possibly the most malicious Regular Expression

This is the next of my episode on regular expressions. Today, we look at the worst regex you can possibly come up with, although it looks innocent and simple. You will learn about this backtracking trap that let’s you easily wait for 10^30 steps, as an example of an errant email regex will illustrate. One possible solution we investigate is the use of possessive quantifiers.

Read the rest of this entry »  |   Share