Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9205

Specify primitive annotation default value using number literal with cast/coerce

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.0.4
    • None

    Description

      Consider the following:

      @interface A {
        int i1() default (int) 42
        int i2() default 42 as int
        byte b1() default (byte) 42
        byte b2() default 42 as byte
        char c1() default (char) 42
        char c2() default 42 as char
        long l1() default (long) 42
        long l2() default 42 as long
        short s1() default (short) 42
        short s2() default 42 as short
        float f1() default (float) 42
        float f2() default 42 as float
        double d1() default (double) 42
        double d2() default 42 as double
      }
      print A.getMethod('i1').defaultValue​
      

      Long, Float and Double defaults cannot currently be specified in this manner.

      See also GROOVY-6025

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: