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

Invalid compilation error in mixed Scala/Java projects that use Java annotations with default values

    Details

      Description

      This bug was introduced in Scala 2.8.0RC2. In a Scala project if we define a Java annotation with default values and try to compile we get the following message: "not found: type root".

      An annotation like the following produces the above compilation error

      public @interface MyAnnotation {
      
        String name() default "spiros";
      }
      

      This bug is really important since the only reason a Scala programmer has to write Java is for defining annotations. Many of the mixed Scala/Java projects contain annotations and this bug prevents any development in those projects.

        Activity

        Hide
        Miles Sabin added a comment -

        Duplicate of SI-3398? Or can you reproduce this on the command line without -Ybuild-debug:refined?

        Show
        Miles Sabin added a comment - Duplicate of SI-3398 ? Or can you reproduce this on the command line without -Ybuild-debug:refined?
        Hide
        spiros added a comment -

        It might be a duplicate but I can reproduce this using maven which compiles everything so I don't believe that it uses the refined build manager.

        Show
        spiros added a comment - It might be a duplicate but I can reproduce this using maven which compiles everything so I don't believe that it uses the refined build manager.
        Hide
        spiros added a comment -

        I can reproduce this from the command line.

        It might be related to the default argument changes that happen recently in trunk r21794.

        Given the Java annotation

        package hello;
        
        import java.lang.annotation.*;
        
        @Retention(RetentionPolicy.RUNTIME)
        @Target(ElementType.METHOD)
        @Documented
        @Inherited
        public @interface Hello {
          String msg() default "hello world";
        }
        

        and the Scala class:

        package hello
        
        class HelloWorld {
          @Hello
          def method() { }
        }
        

        when I try to compile from the command line using the command scalac hello/* I get the following message:

        hello/Hello.java:10: error: not found: type _root_
          String msg() default "hello world";
                 ^
        hello/HelloWorld.scala:4: error: annotation hello.Hello is missing argument msg
          @Hello
           ^
        two errors found
        
        Show
        spiros added a comment - I can reproduce this from the command line. It might be related to the default argument changes that happen recently in trunk r21794. Given the Java annotation package hello; import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @Documented @Inherited public @interface Hello { String msg() default "hello world"; } and the Scala class: package hello class HelloWorld { @Hello def method() { } } when I try to compile from the command line using the command scalac hello/* I get the following message: hello/Hello.java:10: error: not found: type _root_ String msg() default "hello world"; ^ hello/HelloWorld.scala:4: error: annotation hello.Hello is missing argument msg @Hello ^ two errors found
        Hide
        Lukas Rytz added a comment -

        (In r21891) close SI-3415. relates to r21680. review by milessabin.

        Show
        Lukas Rytz added a comment - (In r21891) close SI-3415 . relates to r21680. review by milessabin.
        Hide
        Miles Sabin added a comment -

        This also appears to have fixed SI-3398.

        Show
        Miles Sabin added a comment - This also appears to have fixed SI-3398 .
        Hide
        spiros added a comment -

        Great news!

        Thanks for the quick fix!

        Show
        spiros added a comment - Great news! Thanks for the quick fix!
        Hide
        Commit Message Bot added a comment -

        (extempore in r25923) Fix for SI-3415 regression.

        Now there's an unlikely fix. No review.

        Show
        Commit Message Bot added a comment - (extempore in r25923 ) Fix for SI-3415 regression. Now there's an unlikely fix. No review.

          People

          • Assignee:
            Lukas Rytz
            Reporter:
            spiros
            TracCC:
            Galder, Ismael Juma, Miles Sabin
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development