gpt4 book ai didi

java - 为什么我需要编译才能使 Groovy 代码工作?

转载 作者:太空宇宙 更新时间:2023-11-04 13:27:07 24 4
gpt4 key购买 nike

我用 AST 编写了一个 groovy 项目

@TupleConstructor(includeSuperProperties=true)

然后我使用了新的构造函数,例如new Child(baseP1,baseP2,childP1,childP2)

运行代码时,Eclipse 以这种方式对所有构造函数显示“无法匹配构造函数”。

然后我切换到 IDEA intellij。

可笑的是,某些构造函数匹配,而某些不匹配。

最后我找到了一种让一切正常工作的方法,即单击 IDEA 中的编译模块。

所以,我想知道

Why the same groovy code have different behaviors, before and after compiling.

IDE 的错误、设计或限制?

最佳答案

@TupleConstructorcompile-time meta-programming 的示例.

它在程序的编译阶段创建代码。如果没有编译步骤,它就没有机会执行。

关于java - 为什么我需要编译才能使 Groovy 代码工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32536305/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com