0

I am doing programming analysis for Java​ programs with soot. I customize a class which includes a field whose type is SootMethod. I want to save a large number of these objects and use them in another program. So, I find serialization meet my requirement. However, it triggers out the NotSerializableException because of the SootMethod.

What should I do if I want to save the objects with this SootMethod field? Why SootMethod is not serializable?

Ya Xiao
  • 861
  • 8
  • 16
  • 2
    I'd post your question on the Soot mailing list: http://www.sable.mcgill.ca/mailman/listinfo/soot-list/ – paulsm4 Jan 02 '19 at 06:24

1 Answers1

1

It's probably because SootMethod dose not implement java.io.Serializable so it is impossible to serialize instance of this Class , so if you want to serialize the object that contains a SootMethod type field you have 2 ways :

  1. Make this field transient ! so it is possible to serialize the object , but when you deserialize the object this filed will be null.
  2. Make SootMethod Class serializable by implement java.io.Serializable for this Class.

Generally a Class could be serializale if implements java.io.Serializable interface and all fields implements this interface too and if a field not implements it so this filed must be transient.

Alireza Akhoundi
  • 214
  • 3
  • 12
  • Thank you for your reply. I just curious why this method isn't designed to be serializable. In soot, there are many other classes which are serializable (e.g. Unit, Body, etc.) However, SootMethod is not. In this (https://www.sable.mcgill.ca/soot/doc/soot/class-use/SootMethod.html) webpage which introduces the use of SootMethod, it said: "Serialization has to be avoided by static analyses since each object comes out of the same place." It seems that this class is intended to set as non-serializable. Why? – Ya Xiao Jan 02 '19 at 18:33