Scala Programming Language
  1. Scala Programming Language
  2. SI-2764

Java annotations with enum parameters are reported as errors

    Details

      Description

      Enum.java

      public enum Enum {
        VALUE;
      }
      

      Ann.java

      public @interface Ann {
        Enum value();
      }
      

      Use.scala

      class Use {
        @Ann(Enum.VALUE)
        def foo {}
      }
      

      Compiling them together with scalac gives:

      lamppc11:sandbox luc$$ ../build/pack/bin/scalac Enum.java Ann.java Use.scala 
      Use.scala:2: error: annotation argument needs to be a constant; found: Enum.VALUE
        @Ann(Enum.VALUE)
                  ^
      one error found
      

      Compiling java first, then scala works.

      The same issue arises for static constants in Java source files.

      https://lampsvn.epfl.ch/trac/scala/ticket/2764#comment:12

        Issue Links

          Activity

          Hide
          Paul Phillips added a comment -

          I've tagged this for backporting, which is not a guarantee; I don't have time to do it right now but I expect to in the near future.

          Show
          Paul Phillips added a comment - I've tagged this for backporting, which is not a guarantee; I don't have time to do it right now but I expect to in the near future.
          Hide
          Philip Kster added a comment -

          Great job, Paul. Thanks a lot.

          Show
          Philip Kster added a comment - Great job, Paul. Thanks a lot.
          Hide
          Lukas Rytz added a comment -

          Great, thanks for the fix! For the second part of the ticket, there's a separate issue now (SI-5791).

          Show
          Lukas Rytz added a comment - Great, thanks for the fix! For the second part of the ticket, there's a separate issue now ( SI-5791 ).
          Hide
          Adriaan Moors added a comment -

          fixed for 2.10 in 8075672308 – reopened for potential backport in 2.9.3-RC2

          Show
          Adriaan Moors added a comment - fixed for 2.10 in 8075672308 – reopened for potential backport in 2.9.3-RC2
          Hide
          Adriaan Moors added a comment -

          too complex to backport to 2.9 – please upgrade to 2.10

          Show
          Adriaan Moors added a comment - too complex to backport to 2.9 – please upgrade to 2.10

            People

            • Assignee:
              Paul Phillips
              Reporter:
              Alex
              TracCC:
              Alan, Alex Cruise, Bram Bouwens, Christos KK Loverdos, Florian Hars, Irmo Manie, Ismael Juma, Jean-Francois Menard, Johannes Rudolph, Martin Krischik, Marvin Froeder, Miles Sabin, robinst, Simon Ochsenreither, spiros, Thomas Scheiblauer, Vladimir Kirichenko
            • Votes:
              16 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development