Welcome! Please see the About page for a little more info on how this works.

0 votes
in Java Interop by

Hello everyone,

I have a lot of Java Serialized Objects I wish to inspect and transform.

I tried using the naive Java-in-Clojure way to do the following:
(Excuse the iterative style, I'm usually never interfacing with Java directly and it's also a language I'm relatively unfamiliar with, but this doesn't seem to have a clojuristic wrapper.

file that contains object: input.ser

(import '[java.io FileInputStream ObjectInputStream])
(def fis (new FileInputStream "input.ser"))
(def ois (new ObjectInputStream fis)

(.readObject ois) ;; this fails due to a ClassNotFoundException

Is there a way to get the sort-of Deserialized View of the object that I can inspect after loading? The file itself is unreadable because it compresses the bytes before serializing.

1 Answer

+2 votes
by
selected by
 
Best answer

You will need the classes that you are deserializing into on your classpath to deserialize. That's just how Java serialization works.

There may be some kind of generic Java serialized object introspector but I'm not aware of one. Really, each class can write customized serialization/deserialization code so without knowing that, I'm not sure a generic inspector is even possible.

...