<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 20/10/2011, at 5:19 PM, Mark Struberg wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>They must have at least 1 non-private ct (this includes the default ct). And if it does have a parameter, then it must be annotated with @Inject.<br>This is perfectly enough to create a proxy. Of course this @Inject constructor must not get called while creating the proxy itself (because this might contain certain checks and logic). In this very case a default-ct must get added to the proxy-subclass via byte code enhancement techniques.<br></div></blockquote><div><br></div><div>That does not really work, according to the JVM spec:&nbsp;</div><div><br></div><div><a href="http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html">http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html</a></div><div><br></div><div>4.8.2 Structural Constraints - "Each instance initialization method&nbsp;(§3.9), except for the instance initialization method derived from the constructor of class&nbsp;Object, must call either another instance initialization method of&nbsp;this&nbsp;or an instance initialization method of its direct superclass&nbsp;super&nbsp;before its instance members are accessed. However, instance fields of&nbsp;this&nbsp;that&nbsp;are declared in the current class may be assigned before calling any instance initialization method."</div><div><br></div><div>So even if you add a default constructor to the sub class, this default constructor still has to call the non default constructor of the superclass. It is possible to pass 'default' arguments (i.e. null for objects and 0 for primitives), but this is kinda dodgy, and can result in NPE's if the constructor is expecting a non-null value. All JVM's also provide a non-portable way to instantiate a class without calling the constructor (such as com.sun.misc.Unsafe), however as this is not really an official part of java platform it is not really something a spec should rely on.&nbsp;</div><div><br></div><div>So even though it is not impossible to do, it is not very well specified and kinda fragile, or just plain non-portable.&nbsp;</div><div><br></div><br><blockquote type="cite"><div><br><br>Also please note that not the CDI specification defines any interceptor behaviour but the Interceptors-1.1 specification (or any update which gets defined by the EJB-3.2 Expert Group). So any assumption we made in CDI must be synced with their work.<br><br></div></blockquote><div><br></div><div>The interceptors specification does not really have much to say on this. It seems to assume that the proxiability requirements will be taken care of by the specification that defines the component type that is being intercepted.&nbsp;</div><br><blockquote type="cite"><div><br>And actually, all beans of passivating scopes must provide a default-ct because of Serialization reasons anyway, isn't?<br><br></div></blockquote><div><br></div><div>A default constructor is not a requirement for serialisation. The JVM can create instances during serialisation directly, without calling the constructor. (Even though the javadoc for Serializable talks about need a no-arg constructor, this is only a requirement for a non-serialization superclass with a serializable sub-class).</div><div><br></div><div>Stuart</div><br><blockquote type="cite"><div><br>LieGrue,<br>strub<br><br><br><br>----- Original Message -----<br><blockquote type="cite">From: Stuart Douglas &lt;<a href="mailto:stuart.w.douglas@gmail.com">stuart.w.douglas@gmail.com</a>&gt;<br></blockquote><blockquote type="cite">To: Mark Struberg &lt;<a href="mailto:struberg@yahoo.de">struberg@yahoo.de</a>&gt;<br></blockquote><blockquote type="cite">Cc: Jozef Hartinger &lt;<a href="mailto:jharting@redhat.com">jharting@redhat.com</a>&gt;; cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br></blockquote><blockquote type="cite">Sent: Thursday, October 20, 2011 6:54 AM<br></blockquote><blockquote type="cite">Subject: Re: [cdi-dev] Question for clarification and my understanding<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I thought that interceptors had to be done via subclassing as well, as the spec <br></blockquote><blockquote type="cite">does not specify that intercepted beans have to have a default constructor?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Stuart<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On 20/10/2011, at 3:44 PM, Mark Struberg wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"> The spec says that only Decorators need to be done via subclassing.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> LieGrue,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> strub<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> ----- Original Message -----<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> From: Jozef Hartinger &lt;<a href="mailto:jharting@redhat.com">jharting@redhat.com</a>&gt;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> To: Rick Hightower &lt;<a href="mailto:richardhightower@gmail.com">richardhightower@gmail.com</a>&gt;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Cc: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Sent: Wednesday, October 19, 2011 7:33 PM<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Subject: Re: [cdi-dev] Question for clarification and my understanding<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Only normal scoped beans require client proxies. Decoration and <br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> interception should be implemented by subclassing (see CDI-74, CDI-44).<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> On 10/19/2011 07:24 PM, Rick Hightower wrote:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Section 5.4<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> "Client proxies are never required for a bean whose scope is a <br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> pseudo-scope such as @Dependent."<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> I understand the concept of client proxies to allow for scopes and <br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> context.<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Is this a true statement...<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Client proxies may not be needed for @Dependent (pseudo scope). CDI <br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> may provide a client proxy for @Dependent.<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> A proxy is needed for @Dependent objects that are decorated or <br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> intercepted with Decorators or Interceptors.<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Are all injected objects proxied or only objects that are normal <br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> scoped or decorated?<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> -- <br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> *Rick Hightower*<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> (415) 968-9037<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> Profile &lt;<a href="http://www.google.com/profiles/RichardHightower">http://www.google.com/profiles/RichardHightower</a>&gt;<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> _______________________________________________<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> cdi-dev mailing list<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> _______________________________________________<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> cdi-dev mailing list<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> _______________________________________________<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> cdi-dev mailing list<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br></blockquote></blockquote><blockquote type="cite"><br></blockquote></div></blockquote></div><br></body></html>