获得错误的“丢失说明”的注释。通过将注释数组传递到另一个注释

发布于 2025-01-18 10:15:32 字数 403 浏览 2 评论 0原文

通过将注释的数组传递到Java中的另一个注释中,从而获得错误的“丢失注释语句”。代码看起来像这样:

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

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

Scala中的以下类,

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

我尝试了上述代码,它给了我错误:Scala类中的“丢失语句”。 我想解决编译器问题。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十雾 2025-01-25 10:15:32

为了使嵌套注释在Scala中起作用,您必须这样使用它们:

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

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() {...}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文