Skip to content

java annotation with @Retention(RUNTIME) is not retained for parameters #8531

Closed
@ohze

Description

@ohze

minimized code

Named.java

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface Named {}

Test.scala

class Foo(@Named s: String)

object Test {
  def main(args: Array[String]): Unit = {
    val ctor = classOf[Foo].getDeclaredConstructors()(0)
    val annots = ctor.getParameterAnnotations()(0)
    println(annots.length) // == 0 in dotty, == 1 in scala 2
    assert(annots.length == 1)
  }
}

expectation

annots.length == 1 as in scala 2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions