I need to have an app that during run-time can load another class and deserialize it successfuly so that it can run it's methods and read the member variables.
From what I noticed, you can not serialize methods in Java, so I'm thinking about serializing the class instance in project2
, load the compiled class with ClassLoader
in project1
, instantiate it and assign the deserialized instance from porject2
in project1
to the instantiated loaded class.
The serialized class will inherit the same parent class in both projects.
Is this the best way to go? It's a school project so the requirements are that my app can accept any other type of class without changing the code.
Aucun commentaire:
Enregistrer un commentaire