Naming (JNDI) and dependency injection (CDI)

Practice for Week 7

Java does not allow you direct access to the memory location or "pointers" of an object. This makes it difficult to detect whether CDI is exposing real objects or proxies.

However, you can get the name of the class of an object using object.getClass().getName(). In addition, you can use System.identityHashCode(object) as an approximation of a pointer. This function returns an integer that uniquely identifies each object (technically, the specification does not guarantee it, but Java Virtual Machines provide this on a "best effort" basis).


Can you use object.getClass() and System.identityHashCode(object) to prove that CDI uses special classes (i.e., proxies) in dependency injection, and that these proxies redirect calls to an underlying bean?