Initial stab at a JSONOutputStream

This implements *not quite* JSON because we need to special-case
characters to be able to read them back as Character instances (as opposed
to String or Integer instances), so we use single quotes just like Java
does.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Initial stab at a JSONInputStream

This is the counterpart for JSONOutputStream.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Teach JSONOutputStream about SezPoz-specific classes

There are exactly four SezPoz-specific classes we need to serialize:
SerAnnotatedElement, SerEnumConst, SerTypeConst and SerAnnConst . We
serialize the first two to JSON as maps, SerTypeConst instances
by writing out the type name as a plain String, and SerAnnConst by
introducing another extension to the JSON format: we serialize
them as @MyAnnotation{"key":"value"}.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Teach JSONInputStream to deserialize SezPoz-specific data

Since we write out SerAnnotatedElement instances as if they were maps,
when reading them back, we actually cannot know whether they are plain
maps or not.

Therefore, let's have a method that we call explicitly when we want a
SerAnnotatedElement.

Prepare this method already to handle the case we will introduce later,
for backwards-compatibility, where readObject() already returns an
instance of SerAnnotatedElement.

Also, let's handle our '@MyAnnotation' style JSON extension and return
SerAnnConst instances in that case.

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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>
Prepare IndexItem to read JSON instead of serialized objects

When reading from a JSONInputStream, by necessity the fields' types are
not known before-hand, as e.g. a Class is serialized as its name (i.e.
as a String), and only when using the value in the proxy, it is apparent
what type it is actually expected to have.

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

With this change, we can read annotations indexes written out both with
the Java serialization technique as well as with the upcoming JSON
technique.

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.

The IndexerTestBase had to be adjusted to reflect that the JSON-backed
serialization has to encode enum types explictly now.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
IndexItem: optimize code path for JSON-based serialization

Now that we're (de-)serializing from/to our extended version of JSON, we
actually do not expect to see the types SerEnumConst and SerTypeConst
anymore, except for legacy artifacts. So let's try to handle other cases
more urgently than those.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>