WIP: Initial stab at a JSONInputStream

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
fixup! Initial stab at a JSONOutputStream
Add a unit test for the JSON input/output

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Make sure that PrintWriter is closed, not the underlying Writer

This makes sure that the PrintWriter's remaining characters are flushed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Introduce a JSONInputStream wrapper that falls back to ObjectInputStream

We are about to switch the serialization to a custom JSON one, but we
also want to retain backwards-compatibility with artifacts that have
been built (and annotated) using older SezPoz versions.

The strategy is to test whether the input stream starts with a '{'
(tell-tale for JSON) and use a JSONInputStream as back-end. If the input
stream starts with the magic 0xac instead (part of Java serialization's
0xaced magic), we fall back to using Java's ObjectInputStream instead
(hoping that we're not on Android where the TreeMap serialization is
incompatible with Oracle Java's).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Revert "Introduce a JSONInputStream wrapper that falls back to ObjectInputStream"

Let's teach JSONInputStream about this directly, to avoid having to use a
PushbackInputStream all the time.

This reverts commit 61ab09ccca49de867b252a4f28575115dd05075c.
Teach JSONInputStream to fall back on ObjectInputStream

For backwards-compatibility, we need to handle annotations serialized with
previous SezPoz versions. For that reason, let's just look at the first
byte of the input stream and fall back to Java's deserialization if it
looks like a serialized object.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Use JSONInputStream to deserialize annotations

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Serialize annotations as JSON

This helps SezPoz to be independent of the vagaries of the particular
class path library it is running with: Android's TreeMap, for example,
is incompatible to deserialize TreeMap instances serialized with
Oracle's Java class library.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
fixup! Use JSONInputStream to deserialize annotations
wip