[ 
https://issues.apache.org/jira/browse/OPENEJB-980?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12659496#action_12659496
 ] 

David Blevins commented on OPENEJB-980:
---------------------------------------

It's unfortunate JBoss implemented it this way as it goes against the spec and 
against the Java language rules for annotation inheritance.  Had the annotation 
intended to be inherited it would have been annotated with @Inherited which 
causes the annotation to be propagated to all the subclasses as described.  
Here's an example:

import junit.framework.TestCase;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

public class AnnotationTest extends TestCase {

    @java.lang.annotation.Target(TYPE)
    @java.lang.annotation.Retention(RUNTIME)
    @java.lang.annotation.Inherited
    public static @interface Foo {
    }

    @java.lang.annotation.Target(TYPE)
    @java.lang.annotation.Retention(RUNTIME)
    public static @interface Bar {
    }


    @Foo
    @Bar
    public static class Parent {

    }

    public static class Child extends Parent {

    }

    public void test() throws Exception {

        assertTrue(Child.class.isAnnotationPresent(Foo.class));
        assertFalse(Child.class.isAnnotationPresent(Bar.class));
    }
}

That said I actually support the concept that ApplicationException should be an 
inherited annotation (among a few other annotations).  At this point it's 
nearly impossible to change at the spec level as this would be viewed as a 
breaking backwards compatibility.  I'll try proposing it, but I can hear the 
response already :)

On our end, this might be something we can support as an option which can be 
turned on but off by default.



> @ApplicationException is not being inherited
> --------------------------------------------
>
>                 Key: OPENEJB-980
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-980
>             Project: OpenEJB
>          Issue Type: Bug
>    Affects Versions: 3.1
>            Reporter: Geoff Callender
>            Assignee: Jacek Laskowski
>
> When @ApplicationException(rollback = true) is annotated on an exception 
> thrown by a session bean then all is well - the client receives the exception.
> But if the annotation is moved up to a superclass of the exception then all 
> is not well - the client receives EJBTransactionRolledbackException.
> In the app server I am porting from the following worked OK, and I believe it 
> is the correct behaviour:
> public interface DogServiceRemote {
>     void createDog(Dog dog) throws BusinessException;
> }
> @ApplicationException(rollback = true)
> abstract public class BusinessException extends Exception {
> ...
> }
> public class ValueRequiredException extends BusinessException {
> ...
> }
> where createDog(...) throws many different subclasses of BusinessException, 
> none of which is annotated with @ApplicationException.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to