Teach JSONOutputStream about SezPoz-specific classes

There are exactly four SezPoz-specific classes we need to serialize:
SerAnnotatedElement, SerEnumConst, SerAnnConst and SerTypeConst. We
handle the first three by writing them to JSON as maps and SerTypeConst
instances by writing out the type name as a plain String.

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.

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.

So we'll have to work slightly harder when annotation indexes are
deserialized from JSON.

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 annotation and enum types explictly now (in
other words: the toString() output changed).

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 SezPoz-speciic types 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>
JSONInputStream: speed up by buffering the input

While our test suite is not speeded up tremendously by this (in this
developer's tests, in a best-of-five comparison, it was only about 7%,
but then, the unit tests' execution time is dominated by the apt runs),
projects with serious amounts of annotated classes should benefit from
this change (otherwise, the JSONInputStream would really read the JSON
byte by byte...).

Compared to the pre-JSON version of SezPoz, there is still a moderate
improvement of about 3-4%, proving at least that the switch to JSON
does not necessarily lead to a performance penalty.

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