ASW
ASW

Reputation: 37

Getting error "Missing statement for annotation" by passing the array of annotation into another annotation

Getting error "Missing statement for annotation" by passing the array of annotation into another annotation in java. Code looks like this :

public @interface Big {
    String abc() default "";
}

public @interface B {
    String name() default "";
    Big[] big() default {};
}

The following class in scala

@B(name = "Reema",big = {@Big(abc = "a"), @Big(abc = "b")})
class MainTest() {
    ...
}

I tried the above code and it is giving me the error : "Missing statement for annotation" in the scala class. I want to resolve the compiler issue.

Upvotes: 2

Views: 605

Answers (1)

Goosefand
Goosefand

Reputation: 305

In order to make nested annotations work in Scala you have to use them like this:

  @B(
    name = "Reema",
    big = Array(new Big(abc = "a"), new Big(abc = "b"))
  )
  class MainTest() {...}

Upvotes: 2

Related Questions