2 Replies Latest reply: Sep 2, 2008 1:28 PM by 843793 RSS

    annotation's inheritance

    843793
      I think it would be wonderfull to have Annotation's inheritance,

      for example there is a javax.persistence.Entitiy and org.hibernate.annotations.Entity, the former is created for extending properties of the first; it would be nice to make second one extends the first one, don't you think so?
        • 1. Re: annotation's inheritance
          843793
          I think it would be wonderfull to have Annotation's
          inheritance,

          for example there is a javax.persistence.Entitiy and
          org.hibernate.annotations.Entity, the former is
          created for extending properties of the first; it
          would be nice to make second one extends the first
          one, don't you think so?
          This capability was considered by the JSR 175 expert group (http://www.jcp.org/en/jsr/detail?id=175) but rejected . The question is addressed in their design FAQ:

          "Why don't you support annotation subtyping (where one annotation type extends another)?

          It complicates the annotation type system, and makes it much more difficult to write "Specific Tools" (per the taxonomy in Section VI). "

          There is also the general advice to favor composition over inheritance ("Effective Java" item 14).
          • 2. Re: annotation's inheritance
            843793
            I just saw this topic. On my website, I have an experimental, modified javac compiler that supports annotations with subtyping, and the beginnings of a reflection API that supports annotations with subtyping:

            http://www.cs.rice.edu/~mgricken/research/xajavac/index.shtml

            I'm interested in any feedback.