1 Reply Latest reply: Sep 26, 2010 4:08 PM by 608410 RSS

    Setting default value for a method of an annotation type

    843793
      Is it possible to set the default value for a method which has an annotation as return type, so that it is not mandatory.
      @interface A {
        
         B value() default ???
       
         @interface B {}
      }
      Is it anything I could replace ??? with to make the value() optional.

      Thanks,

      Danial
        • 1. Re: Setting default value for a method of an annotation type
          608410
          An interesting question. That isn't something I have had to do before. the JLS suggests it is just a value and that it is possible. What have you tried already?


          just tried. This works
          B value() default @B;
          Bruce


          (yep that's me, I'll eventually get my identity moved to these new oracle forums)

          Edited by: Hukewaka (aka bruce chapman) on Sep 27, 2010 12:04 PM