Java Development Tools in Indigo
What’s new in Eclipse’s flagship project?
Another year has passed and the new Eclipse Simultaneous
Release, Indigo, has arrived. This year’s release again includes
many new features and enhancements in the area of Java Development
Tools, bringing Eclipse back to the forefront of the Java IDEs.
It is quite amazing, how the engineers of the Java Development
Tools (JDT) project always manage to install new functionality into
the development environment, which are really useful when it comes
to developing Java software. Without taking into account the Java 7
support, which is currently under development, there are over
30 new functions and improvements in this
year’s release. The new developments and changes have, of course,
taken place in different areas within the Java Development Tooling
project. The Java Editor is the main tool, which is used by
developers most of the time. Therefore, it is not surprising that
most of the new features are related to the Java Editor. The main
focus seems to be on improving developer productivity. There are
also innovations in other areas, such as the integrated compiler,
in the Properties File Editor and the JUnit integration. In this
article, it is not possible to discuss all the new features in
detail. But, we will take a closer look at some of them.
One JDT, two Eclipse Versions
Eclipse is changing. Some time ago, as part of the e4 project, a
process was started that was not only an internal clean up, but
also an effort to improve, and place the platform on a modern
technological base. Since you cannot change an established platform
overnight, it was decided to carry out a smooth transition from
version 3.x to 4. That’s the reason why there are actually two
versions of Eclipse this year: the classical 3.x branch and the new
version based on e4 technology. Because the Java Development
Tooling is just a set of plug-ins, which implements the Java
development environment, it can be used in both versions without
modification. It does not matter whether you use the Indigo-based
3.7 release, or work with the 4.1 version: the Java development
tools are always the same. Therefore, JDT is the best proof that
the included 4.1 Compatibility Layer works well. It was especially
developed to help as many plug-ins as possible into tomorrow’s
brave new world of Eclipse. By the way, next year, as part of the
Juno Simultaneous Release, the migration to the 4.x branch is
likely to be carried out. But, I assume the 3.x branch will
continue to be maintained.
Five years after the release of Java 6, the next generation of
Java was finally released in July 2011. This year’s Indigo
Simultaneous Release does not include official support for Java 7.
But the work to match Eclipse and Java 7 is already in full swing,
and can be tried today. A subsequent installation is required for
both 3.7 and 4.1. The development of Java 7 is
already quite advanced: for example, the code editor already
supports new language constructions like string in switches or the
new Try-with-Resources construct, which can be used to express
source code to resources, such as files, in a much shorter and
clearer fashion. Details about the current state of Java 7
integration in Eclipse can be found in . It is important to mention that the Java 7
integration is not an official part of the Indigo release.
New in the Editor
Every improvement in the Java code editor aims to simplify the
developer’s work. The new Open from Clipboard feature located
within the NAVIGATE menu is quite interesting. When starting this
function, Eclipse analyzes the contents of the clipboard and tries
to find corresponding classes within the Java development
environment. If you add the text toString() to the clipboard,
Eclipse will shortly show you a dialog and offer all the classes
containing this method. This is helpful if you want to quickly
start navigation from a stacktrace, to the error-causing place:
Simply mark the appropriate line in the trace, take it to the
clipboard and call the new function Open from Clipboard.
Hyperlinks are not just a great thing on the web. Even in the
Java editor they’ve long been useful for code-navigation. With
Indigo, three new links have been added: Open Super Implementation,
Open Declared Type and Open Return Type. Open Super Implementation
has already been available in recent Eclipse versions in the
NAVIGATE menu, and is now also available as a hyperlink. The other
two are completely new links. Open Declare Type offers the
possibility to easily navigate from variables, to their type. When
using a variable of String-type, it is possible to jump into the
implementation of the String itself. Vice versa Open Return Type
works on methods by providing the opportunity to jump into the
implementation of the type of return.
The numerous Quick Assists are surely amongst the most helpful
features of the Eclipse Code Editor. They offer comprehensive
support during the development process in terms of code completion
and code snippets. They are activated with CTRL+1. This year’s
release again contains a few new ones. Using the instanceof-keyword
it has always been possible to automatically create the
corresponding if with istanceof-test. Eclipse can also generate the
Cast of the tested object to the actual type. The new Quick Assist
Introduce new local with cast type now offers the ability to
produce the Cast separately as well. The new Quick Assist Exchange
left and right operands for infix expression however, permits the
rotation of the comparative values, e.g. in if-statements. The new
Quick Assist is available for the following operations: !=, <,
<=, > and >=. Using the new Quick Assist, the expression
if ( a != b would be converted into if ( b != a).
The existing Quick Assist Add paranoiac parentheses was renamed
to the more descriptive name Put expressions in parentheses, and
still offers the opportunity to put single compare-actions or
expressions in parentheses. Likely to be quite useful, is the new
Add missing case statements Quick Assist. It offers the possibility
of automatically generating missing case-branches in switches.
Figure 1 shows all Quick Assists in action.
Java 1.4 introduced the assert-command, which has been very
useful in the past when testing and debugging. It offers the
opportunity to ensure that a certain fact is observed in the code.
The developer does this by typing the assert command followed by a
boolean expression which is assumed to always be true.
Using assert in JDT has been further improved. If the new
option, switched off by Default, Include ‘assert’ in null analysis
in the Preference Page JAVA | COMPILER | ERRORS/WARNINGS is
activated, JDT takes assert commands into consideration, in which a
variable is null. If such a variable is checked again and it is
null, Eclipse can detect this and document either a warning or an
error in the editor.
Regarding the huge amount of configuration options on the
Preference Page Java | Compiler | Errors/Warning the newly added
filter options actually make a lot of sense. Figure 2 shows the new
filter at work: if you put a Tilde before/after the Search value,
not only the Name of the corresponding configuration, but also the
configuration-value is taken into account. Furthermore, the
compiler of the new Eclipse version detects and shows even more
unused variables now. On top of that, the compiler notices if it is
possible to declare a method static and offers it to you in case
the needed Option (again on the Error/Warnings Preference Page) is
Nice to have
Of course, you’ll find a lot of rather small changes in the new
Java Development Tooling which are quite interesting as well.
That’s why they should be mentioned briefly.
Particularly helpful is the newly added option to disclaim
Getter and Setter while debugging using Step Into. This can be
achieved by activating the new filter options filter simple setter
and filter simple getter in the Preference Page JAVA | DEBUG | STEP
FILTERING (Figure 3).
With those filters, activated while debugging in a method like
getOrder(input.getOrderNumber()), the Method getOrderNumber() is no
longer jumped into, but skipped instead and you´ll be brought
directly to getOrder.
A very useful feature, because you may reach the method you
really want to investigate a lot faster.
Helpful as well, is the new option using Preference Page JAVA |
EDITOR | SYNTAX COLORING to color abstract classes in the code
editor differently to other classes. This is not necessarily
required, but is “nice to have”. Helpful when working with JUnit,
is the newly added ability to generate test suites for JUnit 4. A
small enhancement in the Properties File Editor should be mentioned
as well: there is now the option to automatically “escape/unescape”
backslashes using a new Quick Assist (Ctrl +1).
In this article, we could not describe all the new features of
JDT’s Indigo version.
For a detailed list of not only all the new features in JDT, but
also the Eclipse platform, I would like to refer once again to
. Therefore, the overall conclusion can only
be the fact that Eclipse is still among the top development
environments in the Java ecosystem. You should be curious as to
what the Eclipse Foundation will come up with for the next version
of JDT – because there is actually not much more that can be done