ice icon indicating copy to clipboard operation
ice copied to clipboard

_typeToClassMap in Java Instance

Open bernardnormier opened this issue 7 years ago • 1 comments

Java's Instance maintains a type id to class name map: https://github.com/zeroc-ice/ice/blob/3.7/java/src/Ice/src/main/java/com/zeroc/IceInternal/Instance.java#L1908

This class name is then resolved to an actual class type using the current classloader each time we lookup this type id: https://github.com/zeroc-ice/ice/blob/3.7/java/src/Ice/src/main/java/com/zeroc/IceInternal/Instance.java#L758

We could instead keep a map with key = class loader + type id value = class object (Class<?>) to speed-up this resolution.

Note: InputStream's EncapsDecoder also maintains its own cache typeId to class.

bernardnormier avatar Oct 09 '18 19:10 bernardnormier

One potential issue with the per-communicator caching of classes is for application servers that might load/unload apps. How do we ensure that the classes for unloaded apps are cleared from this map? Or do we cache only for the "fixed" class loaders? (no caching for the per-thread context class loader)

Are we sure that the class lookup by the class loader performs badly? It might be worth testing this before adding another level of caching.

bentoi avatar Oct 10 '18 07:10 bentoi

3.8 introduced a new SliceLoader interface, and a DefaultSliceLoader that improve class loading and allow to customize the loading of clases.

pepone avatar Dec 02 '25 18:12 pepone