Aladdin - Scala Bugtracking
[#676] project: compiler priority: low category: bug
submitter assigned to status date submitted
Iulian Nikolay fixed 2006-07-25 17:48:47.0
subject IncompatibleClassChangeError using Java annotations
code
// java file
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
public @interface Slider {
  int min();
  int max();
} 

// scala code
object Main extends Application {
  val x: Slider = null;

  def method = x.max

  method
}
what happened
'Slider's symbol will be seen as a class, not as an interface (no 'INTERFACE' flag), and the backend will emit t\
he wrong invoke opcode
what expected Slider should be marked as an interface by the classfile parser. Or not? It does not seem like an omission, but rather intentional. Code inside the classfile parser explicitely tests that an interface is /not/ an annotation. Nik, do you remember why is it a bad idea to see annotations as interfaces in the compiler? Anyway, currently they are seen as classes (for instance, scalac would not complain if one wrote 'new Slider'!) and that's definitely wrong.
[back to overview]
Changes of this bug report
Iulian  edited on  2006-07-25 17:51:18.0
Iulian  edited on  2006-07-25 17:51:41.0
Nikolay  edited on  2006-08-16 10:39:30.0
Fixed in rev 8391&8392. GenJVM will emit an interface call if the target is a Java annotation. Unfortunately, attributes (including annotations) have to be seen as classes because an attribute application is typechecked as an instance creation. However, we should think of disallowing instance creation at least for annotations and maybe for attributes altogether.