1

Say there are two class foo and bar

bar extends foo but foo is a dependency that was added through maven. So I don't have access to foo's code but I want to serialize it for caching reasons. I want to know is there a way to serialize the foo class without changing the code inside foo it self ?

Thank you

SandMan
  • 555
  • 2
  • 6
  • 15
  • Do you want to serialize `Foo` instances (note the use of naming conventions) or `Bar` instances only? If the latter you could just have `Bar` implement `Serializable` if the former you'd have to write your own serialization code (see here for example: http://stackoverflow.com/questions/14220554/how-to-serialize-a-third-party-non-serializable-final-class-e-g-googles-latln) – Thomas Jun 28 '16 at 12:30
  • I want to serialize the foo instance – SandMan Jun 28 '16 at 12:33
  • In that case the `Bar extends Foo` example is misleading and probably unnecessary anyways. – Thomas Jun 28 '16 at 12:35

1 Answers1

0

You can serialize foo by using a third party Jboss serialization API.

excerpt from Jboss Serialization Website JBossSerialization is a new approach to java-serialization.

Check this link for an example.

Prakash Hari Sharma
  • 1,414
  • 2
  • 17
  • 22