Skip to content

Can't access methods of java declared annotations from scala #1576

@OlivierBlanvillain

Description

@OlivierBlanvillain

Bumped into this with ScalaTest, the pattern seams to be used for all of their annotations. Quoting their scaladoc/javadoc:

Note: This is actually an annotation defined in Java, not a Scala trait. It must be defined in Java instead of Scala so it will be accessible at runtime

Here is a minimized two file test case:

TagAnnotation.java:

public @interface TagAnnotation {
  public String value();
}

Access.scala:

object Test {
  val v: TagAnnotation = null
  println(v.value) // error: value value in class TagAnnotation cannot be accessed as a
                   // member of TagAnnotation(Test.v) from module class Test$.
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions