Using MongoDB, I need to persist objects from Twitter4J. Twitter4J uses interfaces, which are implemented in JSON versions. Example:
The API returns Status
(an interface), and Status
is implemented as StatusJSONImpl
.
I can't save Status
to MongoDB, I need to implement StatusJSONImpl
.
My issue is, this class StatusJSONImpl
is not public (see here) so I can't use it in my code. I tried to download the source of Twitter4J to manually add "public
" to StatusJSONImpl
: I can do:
Status status = twitter.updateStatus(latestStatus);
String statusStringified = TwitterObjectFactory.getRawJSON(status);
StatusJSONImpl statusImplemented = (StatusJSONImpl) TwitterObjectFactory.createUserList(statusStringified);
SingletonLaunchDB.getMongo().save(statusImplemented);
But I still get a java.lang.IllegalAccessError
on the class StatusJSONImpl
at run time.
I see from other SA answers that users routinely point other users to this Impl classes... how do they do to use it in their code?
Your help is much appreciated.