Thursday, July 28, 2011

Java 7 Support in Eclipse 3.7.1, 3.8, 4.2 builds

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.

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.

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.

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.

Saturday, July 9, 2011

JazzHub



JazzHub is a free, public, hosting hub for the open development of academic research and classroom projects. Currently it is in limited beta. To participate in the beta you can request a project creation code.

On JazzHub students and professors can plan projects, collaborate on source code, and track progress, all with the latest Jazz technology in Rational Team Concert.
  • Source code management
  • Work Item Tracking
  • Project and personal dashboards
  • Agile planning
  • Reporting
  • Web, Eclipse and Visual Studio interfaces 

Rational Team Concert (RTC) is also available FREE of charge for qualified open source projects, academic institutions, and research projects. Steps to help you get started are available here. You can also read about RSSOwl's adoption of RTC, this also includes a great video which illustrates how the developers can benefit from RTC.

You can learn more about JazzHub at Innovate 2011, Bangalore. If you're a student, you can also win free passes to Innovate by blogging or tweeting about rational products (use hashtag #innovateindia).