Details

      Description

      This bug blocks SI-5684.
      There is a difference between compiling a java annotation and loading it from the class file and letting scalac parse it:

      $ scalac -version
      Scala compiler version 2.10.0-20120423-023931-3b61d19cdc -- Copyright 2002-2011, LAMP/EPFL
      
      $ cat MyAnnotation.java
      public @interface MyAnnotation { String value(); }
      
      $ scalac -Ystop-after:typer -Xprint:typer MyAnnotation.java
      [[syntax trees at end of typer]]// Scala source: MyAnnotation.java
      package <empty> {
        object MyAnnotation extends  {
          def <init>() = _
        };
        class MyAnnotation extends scala.Annotation with _root_.java.lang.annotation.Annotation with scala.ClassfileAnnotation {
          def <init>(x$1: String) = _;
          def <init>() = _;
          def value(): String
        }
      }
      

      But then:

      $ javac MyAnnotation.java
      
      $ scala
      Welcome to Scala version 2.10.0-20120423-023931-3b61d19cdc (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
      Type in expressions to have them evaluated.
      Type :help for more information.
      
      scala> :power
      ** Power User mode enabled - BEEP WHIR GYVE **
      ** :phase has been set to 'typer'.          **
      ** scala.tools.nsc._ has been imported      **
      ** global._, definitions._ also imported    **
      ** Try  :help, :vals, power.<tab>           **
      
      scala> ?[MyAnnotation].info
      
      res0: $r.power.intp.global.Type = 
      scala.annotation.Annotation
              with scala.annotation.ClassfileAnnotation
              with java.lang.annotation.Annotation {
        def value(): String
        def <init>(): MyAnnotation
      }
      

      So this leaves us with:

      • parsed MyAnnotation.java:
          def <init>(): MyAnnotation
        
      • loaded MyAnnotation.class:
          def <init>(x$1: String) = _; // this is the default constructor
        def <init>() = _;
        

        Issue Links

          Activity

          Hide
          Johannes Rudolph added a comment -

          'parsed MyAnnotation.java' vs. 'loaded MyAnnotation.class' signatures: from the snippets above it seems it is exactly the other way round, no?

          Show
          Johannes Rudolph added a comment - 'parsed MyAnnotation.java' vs. 'loaded MyAnnotation.class' signatures: from the snippets above it seems it is exactly the other way round, no?

            People

            • Assignee:
              Eugene Vigdorchik
              Reporter:
              Vlad Ureche
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development