Java的Groovy Superset [英] Groovy Superset of Java

查看:97
本文介绍了Java的Groovy Superset的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Groovy是Java的超集吗?如果不是,Groovy和Java之间的不兼容性是什么?



通过超集,我的意思是源代码向后兼容性,意思是说:您可以获取Java文件并编译它作为Groovy源文件,并且它可以像以前一样工作。 Groovy的目标与Java非常相似,以尽量减少学习曲线。然而,直到Groovy 1.7不支持匿名的内部类和类似的东西。



我看到一些文章提出这样的声明,但我没有看到它在 Groovy网站

解决方案


Groovy是Java的超集(即与Java兼容)吗?如果不是,现在Java和Groovy之间有什么不兼容?

Groovy扩展了Java,Groovy和Java之间存在差异Groovy文件不能由Java编译器编译)。 与Java的区别页面列出了Java和Groovy之间的所有主要差异。也就是说,Groovy编译器可以将Groovy文件转换为可以使用Java Intepreter运行的.class文件(这需要 groovy-all-VERSION.jar CLASSPATH)。这是否回答这个问题?


Is Groovy a superset of Java yet? If not, what are the incompatibilities between Groovy and Java?

By superset, I mean source backward compatibility, in the sense that: you can take a Java file and compile it as Groovy source file, and it would work just as before. It has been the goal of Groovy to make very similar to Java, to minimize the learning curve. However, until Groovy 1.7 that was no support for anonymous inner classes and such.

I have seen some articles making such claim, but I haven't seen it verified on the Groovy website.

解决方案

Is Groovy a superset of (i.e. source compatible with) Java yet? If not, what are the incompatibilities between Java and Groovy now?

Groovy "extends" Java and there are differences between Groovy and Java (a Groovy File can not be compiled by the Java compiler). The page Differences from Java list all the major differences between Java and Groovy. That said, the Groovy Compiler can converts a Groovy File into a .class File that can be run using the Java Intepreter (this requires groovy-all-VERSION.jar to be on the CLASSPATH). Does this answer the question?

这篇关于Java的Groovy Superset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆