Programming Java 7 in Eclipse

不羁岁月 提交于 2019-11-28 22:17:58
Pascal Thivent

As Alex pointed out, Eclipse uses its own compiler which currently doesn't support Java 7 and, as noted in the Project Plan For Eclipse Project, version Helios, support for Java 7 is deferred and decoupled from the 3.6 release:

  • (

    deferred) Add support for Java SE 7 features. The next feature release of Java SE is version 7, which will probably be available in the second half of 2010. While the contents of this release are still under discussion, that release is expected to contain extensions to the Java language, including annotations on types (JSR-308), modularity support (JSR-294), and other minor language changes (Coin project). Eclipse Java tooling will include initial support for compiling, editing, and launching applications for Java 7 for those parts which have publicly available specifications (only JSR-308 at this point). [JDT Core, JDT UI] (288548)

    NOTE: In order to align our schedule with the delayed official Java 7 appearance and due to lack of publicly available specifications (including lack of a Java 7 JSR), we have decided to move the development work to a separate branch and decouple it from the 3.6 release. In that branch we will continue to develop the Java 7 features as they become publicly accessible. We will deliver separate updates for the official builds in order to provide early access to Java 7 features.

See http://wiki.eclipse.org/JDT_Core/Java7, http://wiki.eclipse.org/PDE/API_Tools/Java7 and Bug 288548 for the ongoing support of Eclipse for Java 7. And see http://wiki.eclipse.org/JDT/Eclipse_Java_7_Support_%28BETA%29 for instructions on how to evaluate Java 7 in Eclipse.

UPDATE 1: The BETA_JAVA7 branch has been merged to HEAD and R3_7_maintenance (See the eclipse-dev archive).

UPDATE 2: Eclipse 3.7.1 (Indigo SR1) supports Java 7.

Eclipse has its own embedded Java compiler. So if there is no eclipse beta or something like that that already can compile Java 7 then you're out of luck.

Netbeans should work.

I checkout the so called JSR 308 branch of org.eclipse.jdt.core using the following CVS repository information.

Connection type: pserver User: anonymous Host: dev.eclipse.org Port: Default Repository path: /cvsroot/eclipse Module: org.eclipse.jdt.core Tag: JSR_308 (Branch) 

Then, I followed the instructions to install the checked out JDT in eclipse. Subsequently, I looked up org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeTypeAnnotationTest.java and /org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java to come up with small examples exercising JSR 308 type annotations.

At this point, the branch supports and generates the corresponding new attributes in the .class files when annotations on types are present. But, annotation processors don't seem to work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!