[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [sca-j] ISSUE 96: Proposal - "Are annotations allowed on static methods?"
Jim, Static initializers are typically used to do the initialization before a class is instantiated and are executed once per class. Static methods can be invoked from non static methods. The user can always mark a non-static method with @Init and call a static method from within. So, there is nothing prohibited in the example you gave. Even though being permissive looks simple, there is no clarity and there is a good chance for errors creeping in. The purpose of the spec is to make things clear. In the process, if we have to impose more rules, we should do so. Vamsi Jim Marino <jim.marino@gmail .com> To C Vamsi/India/IBM@IBMIN 11/12/2008 22:56 cc sca-j@lists.oasis-open.org Subject Re: [sca-j] ISSUE 96: Proposal - "Are annotations allowed on static methods?" Hi, This is an edge case and not good design but in the interest of not being overly restrictive and simplicity, I think we should allow static initializer and destructor methods (@Init and @Destroy). For example, someone could have a counter that is incremented and decremented. Admittedly, this can be achieved by having a non-static method use a static member variable but there is nothing illegal about making the method static from a Java perspective. Also, if we make static initializers and destructors illegal, are they prohibited from invoking other static methods on the same class? For example: @Init public void init() { someStaticInit(); } Unless doing something causes an error, my preference is to remain permissive rather than restrictive as it simplifies things for developers (less to remember) and spec authors (less rules to write). Jim On Dec 11, 2008, at 4:01 AM, C Vamsi wrote: > ISSUE: Are annotations allowed on static methods? > > PROPOSAL: SCA annotations are not allowed on static methods and static > fields. Add the following text at the end of line 872 ( > sca-javacaa-1.1-spec-cd01, section 8). > > As a general rule, SCA annotations are not allowed on static methods > and > static fields. It is an error to use an SCA annotation on a static > method > or a static field of an implementation class and the SCA runtime > MUST NOT > instantiate such implementation class. > > > RATIONALE: > The following are the SCA annotations that could be applied on static > fields and methods. The text next to each annotation explains a > reason for > disallowing the annotation. > @AllowsPassByReference - On service method of remotable service. > Does not > make sense since remotable service methods can not be static. > @Callback - The callback is per implementation instance and since > static > methods can only access static methods and fields > @ComponentName - Will be a problem since we don't restrict that an > implementation can be used at most once in an assembly. > @Context - Will be a problem since we don't restrict that an > implementation can be used at most once in an assembly. > @ConversationID - Will be a problem since we don't restrict that an > implementation can be used at most once in an assembly. > @Destroy - Since this is invoked for each implementation instance > going > out of scope and since static methods can only access static > methods > and fields. > @EndsConversation - Not applicable since it is applied only on > interface > methods. > @Init - Since this is invoked for each implementation instance > coming into > scope and since static methods can only access static methods and > fields. > @OneWay - Applied on service method and service method cannot be > static. > @Property - Will be a problem since we don't restrict that an > implementation can be used at most once in an assembly. > @Reference - Will be a problem since we don't restrict that an > implementation can be used at most once in an assembly. > > > --------------------------------------------------------------------- > To unsubscribe from this mail list, you must leave the OASIS TC that > generates this mail. Follow this link to all your TCs in OASIS at: > https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php >
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]