samedi 27 avril 2019

Java load .class received by the application at runtime

I'm working on a Java distributed application for MANET.

For simplicity let's say I have two nodes A and B that are communicating the one with the other by exchanging serialized objects of a class Message available locally to both nodes because defined at development time.

My goal is to define a new feature that let the two nodes to exchange serialized objects of a class received at runtime.

In particular I have a third node C that knows A and B. The node C by using the GUI let the user to specify a .class file that will be sent to A and B. A and B using reflection should be able to load, create, manipulate and exchange objects of this class received at runtime.

My doubt is, should I use the URLClassLoader for A and B to load the .class file at runtime?

Do you think is it better that C sends to A and B a .jar file containing the .class file o directly the .class file?

Regards





Aucun commentaire:

Enregistrer un commentaire