Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How (at an implementation level) does Java RMI load+define classes?

When RMI (the sun.rmi implementation in Sun VMs) is de-serializing an object, as part of either the parameters or return value of a remote call, it needs to go from the class's name (a string in the serialized data) to a Class object. How does RMI decide which ClassLoader to use to define the class?

like image 431
jon Avatar asked Nov 26 '25 15:11

jon


1 Answers

By default Java deserialisation searches down the stack for the first non-system class and uses its class loader (i.e. the first non-null class loader). RMI adds annotations the serial stream to give the location (URL) where the classes should be downloaded from. By default, RMI class loaders uses that location to find additional classes. There is a system property to switch that behaviour off (not a bad idea).

like image 158
Tom Hawtin - tackline Avatar answered Nov 29 '25 04:11

Tom Hawtin - tackline



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!