You are here: Implementation Strategies > db4o Reflection API > GenericReflector


Db4o uses reflection internally for persisting and instantiating user objects. Reflection helps db4o to manage classes in a general way while saving. It also makes possible instantiation of user objects using class name saved in the database file and class information from the JVM. However db4o reflection API can also work on generic objects when a class information is not available.

Db4o uses GenericReflector as a wrapper around specific reflector (delegate). GenericReflector is set when an ObjectContainer is opened. All subsequent reflector calls are routed through this interface.

GenericReflector keeps list of known classes in memory. When the GenericReflector is called, it first checks its list of known classes. If the class cannot be found, the task is transferred to the delegate reflector. If the delegate fails as well, generic objects are created, which hold simulated "field values" in an array of objects.

Generic reflector makes possible the following usecases:

One of the live usecases is ObjectManager, which uses GenericReflector to read C# objects from Java.