Ticket #231 (new defect)
Opened 8 years ago
Embedded objects
| Reported by: | hauma | Owned by: | hauma |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.0 |
| Component: | uka.transport | Version: | 1.09b |
| Severity: | normal | Keywords: | |
| Cc: |
Description
When value mode marshaling is replaced with anonymous objects (see ticket:228), a possibility is required build complex anonymous objects that internally consist of multiple helper objects e.g. arrays (which in turn cannot be declared anonymous, because their class is not extendable). To prevent references to those helper objects from being marshaled "by reference", they should be declarable as being embedded into its owner object. In the following example, an anonymous class A internaly consists of an array of references to other objects stored in an array A.r. As well as the refernce to A as the reference to the internal helper array A.r should be marshaled in value mode. Only for the containing references A.r[n], regular marshaling should apply:
class A implements Anonymous { /** @embedded */ Object[] r = new Object[10]; }
The @embedded anotation marks the refereced Object A.r as being anonymous in the context of A. This annotation is not restricted to variables of anonymous classes. Also helper objects of regular classes can be embedded (declared anonymous in the context of their owner).
By declaring an object embedded, a class guarantees that the embedded reference is the only reference to the embedded object (an that this reference cannot be null). With this guarantee, it should be possible for a JIT compliler to inline the embedded object.
