So far the Java 7 support work was done in the BETA_JAVA7 branch. This branch has now been merged to HEAD and R3_7_maintenance. As a result all upcoming 3.7.1, 3.8 and 4.2 builds will fully support Java 7 development.
Showing posts with label java7. Show all posts
Showing posts with label java7. Show all posts
Thursday, July 28, 2011
Friday, July 22, 2011
Java 7 Support in Eclipse JDT (BETA) - Part III
I have already talked about adding Java 7 support to your Eclipse 3.7 or 4.1 install. Last week I also talked about the new features in JDT for Multi-catch, try-with-resources and Simplified Varargs Method Invocation. Now I will talk about Improved Type Inference for Generic Instance Creation (Diamond).
This language change allows explicit type arguments to constructors of parameterized classes to be omitted in many situations. The compiler infers the omitted type arguments based on the expected type.
The JDT compiler detects redundant specification of type arguments, which you can remove via Remove type arguments quick fix.
This warning can be configured as shown below.
You can also insert inferred type arguments via a quick assist.
Where possible, Content assist inserts diamond instead of explicit type arguments.
Future items: We plan to show the inferred type arguments right in the constructor hover, see bug 351048. In 3.8 we also plan to provide Remove redundant type arguments as a cleanup, see bug 351956.
Note that the type inference done by the compiler can at times be non-obvious. For example, at first glance the following two methods might appear equivalent, when in fact the one with conditional operator has an error.
An analogous example from the pre-Java 7 world.
This language change allows explicit type arguments to constructors of parameterized classes to be omitted in many situations. The compiler infers the omitted type arguments based on the expected type.
The JDT compiler detects redundant specification of type arguments, which you can remove via Remove type arguments quick fix.
You can also insert inferred type arguments via a quick assist.
Where possible, Content assist inserts diamond instead of explicit type arguments.
Future items: We plan to show the inferred type arguments right in the constructor hover, see bug 351048. In 3.8 we also plan to provide Remove redundant type arguments as a cleanup, see bug 351956.
Note that the type inference done by the compiler can at times be non-obvious. For example, at first glance the following two methods might appear equivalent, when in fact the one with conditional operator has an error.
An analogous example from the pre-Java 7 world.
Thursday, July 14, 2011
Java 7 Support in Eclipse JDT (BETA) - Part II
I have already talked about the new features to support multi-catch in an earlier post. Now I will talk about Try-with-resources statement and Simplified Varargs Method Invocation.
The compiler detects unhandled exceptions thrown by automatic/implicit close() invocation on a resource.
With Mark Occurrences enabled, the closing '}' of a try-with-resources statement is marked as a method exit point if the implicit close() invocation throws an exception. The corresponding resource variable is also highlighted.
Future items: In 3.8 we plan to add warnings to indicate that a resource is not closed, see bug 349326. In Java 7 a resource is a subtype of java.lang.AutoCloseable and in the pre-Java 7 world a resource is a subtype of java.io.Closeable. Based on these warnings we will also provide quick fixes/assists and clean-ups to enclose a resource in a try-with-resources statement, see bug 349390.
A new quick fix Add @SafeVarargs is offered for potential heap pollution warnings on method declarations.
Add @SafeVarargs quick fix is also offered from call sites.
Remove @SafeVarargs quick fix is offered for incorrect usage of @SafeVarargs annotation.
Note: This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP.
The compiler detects unhandled exceptions thrown by automatic/implicit close() invocation on a resource.
With Mark Occurrences enabled, the closing '}' of a try-with-resources statement is marked as a method exit point if the implicit close() invocation throws an exception. The corresponding resource variable is also highlighted.
Future items: In 3.8 we plan to add warnings to indicate that a resource is not closed, see bug 349326. In Java 7 a resource is a subtype of java.lang.AutoCloseable and in the pre-Java 7 world a resource is a subtype of java.io.Closeable. Based on these warnings we will also provide quick fixes/assists and clean-ups to enclose a resource in a try-with-resources statement, see bug 349390.
A new quick fix Add @SafeVarargs is offered for potential heap pollution warnings on method declarations.
Add @SafeVarargs quick fix is also offered from call sites.
Remove @SafeVarargs quick fix is offered for incorrect usage of @SafeVarargs annotation.
Note: This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP.
Java 7 Support in Eclipse JDT (BETA) - Part I
JDT team has been working overtime over the last few months on the Java 7 support. The compiler is rock solid now and the UI is looking good with a number of new features. You can add the Java 7 support to your existing 3.7 or 4.1 install by following the instructions on http://wiki.eclipse.org/JDT/Eclipse_Java_7_Support_(BETA).
This post is the first in a series in which I will talk about the new features in JDT for Java 7. In this post I will focus on Multi-catch.
The new action Source > Surround With > Try/multi-catch Block allows you to surround the selected statements with a try/multi-catch block. This is also available as Surround with try/multi-catch quick fix in case there are multiple uncaught exceptions.
The new Add exceptions to existing catch clause quick fix allows you to add uncaught exceptions to an existing catch clause.
You can replace a multi-catch clause with individual catch blocks via Use separate catch blocks quick assist. The quick assist will create separate catch clauses for all the exceptions.
You can also pick out one or more selected exceptions from a multi-catch clause via Move exceptions to separate catch block.
The new Combine catch blocks quick assist allows you to combine separate catch blocks into a single multi-catch block, pretty useful for migrating existing code to Java 7. The quick assist is offered only when bodies of all the catch blocks are same, we still need to make it a little more smarter, see bug 350308. In 3.8 we will also provide this as a clean-up (bug 351179).
The compiler gives an error if an exception in a multi-catch clause is already caught by an alternative exception. The new Remove exception quick fix allows you to remove this exception.
Mark Occurrences has been updated to understand the multi-catch syntax.
There are also new Line Wrapping options in the Formatter for the multi-catch syntax.
Note: This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP.
This post is the first in a series in which I will talk about the new features in JDT for Java 7. In this post I will focus on Multi-catch.
The new action Source > Surround With > Try/multi-catch Block allows you to surround the selected statements with a try/multi-catch block. This is also available as Surround with try/multi-catch quick fix in case there are multiple uncaught exceptions.
The new Add exceptions to existing catch clause quick fix allows you to add uncaught exceptions to an existing catch clause.
You can replace a multi-catch clause with individual catch blocks via Use separate catch blocks quick assist. The quick assist will create separate catch clauses for all the exceptions.
You can also pick out one or more selected exceptions from a multi-catch clause via Move exceptions to separate catch block.
The new Combine catch blocks quick assist allows you to combine separate catch blocks into a single multi-catch block, pretty useful for migrating existing code to Java 7. The quick assist is offered only when bodies of all the catch blocks are same, we still need to make it a little more smarter, see bug 350308. In 3.8 we will also provide this as a clean-up (bug 351179).
The compiler gives an error if an exception in a multi-catch clause is already caught by an alternative exception. The new Remove exception quick fix allows you to remove this exception.
Mark Occurrences has been updated to understand the multi-catch syntax.
There are also new Line Wrapping options in the Formatter for the multi-catch syntax.
Note: This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP.
Thursday, June 23, 2011
Java 7 Support in Eclipse JDT (BETA)
Java 7 is not publicly released yet and hence the Eclipse Java 7 support could not be shipped with 3.7 or 4.1. However those who want to use it in 3.7 or 4.1 can do it using the install instructions mentioned on http://wiki.eclipse.org/JDT/Eclipse_Java_7_Support_(BETA).
If you find a bug or have ideas on new quick fixes / refactorings / templates / ... , please file a bug with the [1.7] tag !
I should add that this is a work in progress, and more details are available on the following two wiki pages
Note: This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP.
If you find a bug or have ideas on new quick fixes / refactorings / templates / ... , please file a bug with the [1.7] tag !
I should add that this is a work in progress, and more details are available on the following two wiki pages
Note: This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP.
Tuesday, May 10, 2011
Eclipse Day India 2011
Anshu Jain started of the day with an excellent talk Eclipse - A Framework of Frameworks. In his talk he went through the design of a very simple calculator framework to explain all the things that Eclipse does - extensions, dynamic loading, plugin discovery etc. There was also a .cff file (calculator framework format) equivalent to plugin.xml in Eclipse. The example code from his talk is available at his site - highly recommended for someone starting of with plug-in development.
Ankur followed up with another great talk Good Practices for Plug-in Developers. Some of the images he used to drive his point home were really funny and awesome. I thought my session JDT Bootcamp (JDT Tips and Tricks, and Extending JDT) went well, of course the fact that Satyam did a fantastic job of explaining the Java Model and the Search APIs helped a great deal.
There was a lot of interest in What's new in Java 7 talk by Ayush (the guy with the funny pose in the above pic), which was nice to see. After this Praveen talked about his experience at Adobe with migrating a Eclipse 3.x application to Eclipse 4.x platform. It was nice to hear that Adobe wants to stay on the latest Eclipse platform and has made considerable progress in this regard.
The day ended with an interesting talk about Eclipse UOMo project. Werner Keil gave a few funny examples on what can go wrong if the proper care is not taken in consistently interpreting the units, for e.g. if one team uses inches and feet and the another team interprets the values as meters and centimeters. The image of an upside down NASA shuttle because someone messed up the measurement units will always stay in my mind :)
Lastly a big thank you to SAP Laps for hosting the event! You have been a great host for Eclipse Day India 2011 and the demo camp in Nov 2010. However I would like to see the next Eclipse event in Bangalore hosted at a different venue - just for variety :) Maybe other organizations can step forward.
I almost forgot, the 'discussion' over drinks in the evening with fellow Eclipse committers and Eclipse users was 'entertaining' ;-) Those who could not join us for drinks, please do next time.
Labels:
e4,
eclipse,
eclipseday,
java7,
jdt,
pde,
planeteclipse
Monday, May 2, 2011
Eclipse JDT and Java 7
Will Eclipse 3.7 include support for Java 7?
Short answer: No
Slightly longer answer: "Due to late availability of JSR-292 (Invoke Dynamic) and JSR-334 (Project Coin) and due to the official release date (July 28, 2011) of Java 7 being after 3.7 ships we had to defer the Java 7 support to 3.7.1. It has not yet been decided whether this will be available as part of the 3.7.1 downloads or as separate feature update.
The work for the Java 7 features is currently in progress in the 'BETA_JAVA7' branch and we will deliver separate updates for the stable builds in order to provide early access to the Java 7 features for interested parties."
See bug 288548.
What is the current status of support for Java 7 in JDT ?
Take a look at the wiki page: http://wiki.eclipse.org/JDT_Core/Java7
I want to try some of the new features of Java 7 in Eclipse
At this point in time you will need to
Short answer: No
Slightly longer answer: "Due to late availability of JSR-292 (Invoke Dynamic) and JSR-334 (Project Coin) and due to the official release date (July 28, 2011) of Java 7 being after 3.7 ships we had to defer the Java 7 support to 3.7.1. It has not yet been decided whether this will be available as part of the 3.7.1 downloads or as separate feature update.
The work for the Java 7 features is currently in progress in the 'BETA_JAVA7' branch and we will deliver separate updates for the stable builds in order to provide early access to the Java 7 features for interested parties."
See bug 288548.
What is the current status of support for Java 7 in JDT ?
Take a look at the wiki page: http://wiki.eclipse.org/JDT_Core/Java7
I want to try some of the new features of Java 7 in Eclipse
At this point in time you will need to
- Create a new CVS repository location to:
- :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse
- Check out the following projects from BETA_JAVA7 branch:
- org.eclipse.jdt.core
- org.eclipse.jdt.ui
- Launch another eclipse application from this workspace or export the two plugins into the host eclipse.
- Of course you will also need to install a JDK7 build as an installed JRE.
Subscribe to:
Posts (Atom)


















