blob: 3739d856a922fdd4dc19ff5aad025f84508fb570 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="copyright"
content="Copyright (c) Eclipse contributors and others 2014. This page is made available under license. For full details see the LEGAL in the documentation that contains this page." />
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="default_style.css" charset="UTF-8" type="text/css" />
<style type="text/css">
table.news td {
border-top: solid thin black;
}
table.news tr {
vertical-align: top;
}
table.news tr td.section {
font-size: 20px;
font-weight: bold;
}
table.news tr td.title {
vertical-align: top;
width: 30%;
font-weight: bold;
}
table.news tr td.content {
vertical-align: top;
width: 70%;
}
ul {
padding-left: 13px;
}
</style>
<title>Eclipse Project Luna - New and Noteworthy</title>
</head>
<body>
<h2>Java development tools</h2>
<ul>
<li><a href="#JavaEditor">Java Editor</a></li>
<li><a href="#JavaFormatter">Java Formatter</a></li>
<li><a href="#JavaCompiler">Java Compiler</a></li>
<li><a href="#JavaViewsAndDialogs">Java Views and Dialogs</a></li>
<li><a href="#Debug">Debug</a></li>
<li><a href="#JUnit">JUnit</a></li>
</ul>
<!-- *************************************************** -->
<table class="news" cellpadding="10" cellspacing="0" summary="New and noteworthy items">
<tbody>
<!-- ******************* Java Editor ************************************* -->
<tr>
<td id="JavaEditor" class="section" colspan="2">
<h2>Java Editor</h2>
</td>
</tr>
<tr id="convert-compliance-JRE-1.8">
<td class="title"><img src="images/java8.png" alt="" /> Quick fix to change project compliance and JRE to 1.8</td>
<td class="content">A quick fix <b>Change project compliance and JRE to 1.8</b> is provided to quickly change the current project to be compatible with Java 8.
<p>
<img src="images/quickfix-change-compliance-1.8.png" alt="" />
</p>
</td>
</tr>
<tr id="migrate-anonymous-lambda">
<td class="title"><img src="images/java8.png" alt="" /> Migrate anonymous class creations to lambda expressions and back</td>
<td class="content">You can convert anonymous class creations to lambda expressions (and back) by invoking the <b>Quick Assists (Ctrl+1)</b>:
<ul>
<li>Convert to lambda expression</li>
<li>Convert to anonymous class creation</li>
</ul>
<p>Before:</p>
<p>
<img src="images/convert-to-lambda-1.png" alt="anonymous class with a 1-line method body" />
</p>
<p>
After the Quick Assist (<b>Ctrl+1</b>), the 6 lines are condensed into 1:
</p>
<p>
<img src="images/convert-to-lambda-2.png" alt="lambda expression -- everything on 1 line" />
</p> Or invoke <b>Source &gt; Clean Up...</b>, use a custom profile, and on the <b>Configure...</b> dialog select <b>Convert functional interface instances</b> and <b>Use lambda where
possible</b> on the <b>Code Style</b> tab.
</td>
</tr>
<tr id="change-body-block-to-expression">
<td class="title"><img src="images/java8.png" alt="" /> Change lambda expression body block to expression and back</td>
<td class="content">You can convert the body of a lambda expression from block to expression (and back) by invoking the <b>Quick Assists (Ctrl+1)</b>:
<ul>
<li>Change body expression to block
<p>
<img src="images/expression-to-block.png" alt="Change body expression to block" />
</p>
</li>
<li>Change body block to expression
<p>
<img src="images/block-to-expression.png" alt="Change body block to expression" />
</p>
</li>
</ul>
</td>
</tr>
<tr id="view-method-implemented">
<td class="title"><img src="images/java8.png" alt="" /> View the method implemented by the functional interface instances</td>
<td class="content">To view the method implemented by the functional interface instances, you can hover on:
<ul>
<li>'<code>-&gt;</code>' in a lambda expression
</li>
</ul>
<p>
<img src="images/hover-on-lambda.png" alt="Hover on '->' in lambda to show functional method" />
</p>
<ul>
<li>'<code>::</code>' in a method reference
</li>
</ul>
<p>
<img src="images/hover-on-method-reference.png" alt="Hover on '::' in method reference to view functional method" />
</p>
</td>
</tr>
<tr id="navigate-method-declaration">
<td class="title"><img src="images/java8.png" alt="" /> Navigate to the functional method declaration</td>
<td class="content">To navigate to the functional method declaration, hold <b>Ctrl</b>, move the mouse pointer over '<code>-&gt;</code>' or '<code>::</code>', and click the hyperlink.
<ul>
<li>'<code>-&gt;</code>' in a lambda expression:
</li>
</ul>
<p>
<img src="images/navigate-from-lambda.png" alt="" />
</p>
<ul>
<li>'<code>::</code>' in a method reference:
</li>
</ul>
<p>
<img src="images/navigate-from-method-reference.png" alt="" />
</p>
</td>
</tr>
<tr id="quickfix-create-for-loop">
<td class="title">Quick Fixes to create 'for' loops</td>
<td class="content">A set of new quick fixes can create <code>for</code> loops that iterate over a given expression.
<p>For arrays:</p>
<ul>
<li>Create an enhanced <code>for</code> loop
</li>
<li>Create a <code>for</code> loop using an index
</li>
</ul>
<p>
<a href="images/quickfix-create-for-loop-array.txt"><img src="images/quickfix-create-for-loop-array.png" alt="" /></a>
</p> For <code>Collection</code>s:
<ul>
<li>Create an enhanced <code>for</code> loop
</li>
<li>Create a <code>for</code> loop using an <code>Iterator</code></li>
</ul> For <code>List</code>s:
<ul>
<li>Create a <code>for</code> loop using an index and <code>get(i)</code></li>
</ul>
<p>
<a href="images/quickfix-create-for-loop-collection.txt"><img src="images/quickfix-create-for-loop-collection.png" alt="" /></a>
</p>
</td>
</tr>
<tr id="syntax-color">
<td class="title">Enabled coloring of variables</td>
<td class="content">Parameter variables and local variables are now colored by default:
<p>
<img src="images/variable-coloring.png" alt="" />
</p> This can be disabled or configured with different colors and styles on the <b>Java &gt; Editor &gt; Syntax Coloring</b> preference page.
</td>
</tr>
<!-- ******************* Java Formatter ************************************* -->
<tr>
<td id="JavaFormatter" class="section" colspan="2">
<h2>Java Formatter</h2>
</td>
</tr>
<tr id="formatter-for-lambda">
<td class="title"><img src="images/java8.png" alt="" /> Option to control lambda code formatting</td>
<td class="content">New options are provided in the formatter page to configure the formatting of lambda expressions.
<ul>
<li>Configure the position of braces within lambda body:
<p>
<img src="images/formatter-braces-lambda.png" alt="" />
</p>
</li>
<li>Configure whitespace before and after the arrow operator of lambda:
<p>
<img src="images/formatter-whitespace-lambda.png" alt="" />
</p>
</li>
</ul>
<p>
Formatter profiles can be configured on the <b>Java &gt; Code Style &gt; Formatter</b> preference page.
</p>
</td>
</tr>
<!-- ******************* Java Compiler ************************************* -->
<tr>
<td id="JavaCompiler" class="section" colspan="2">
<h2>Java Compiler</h2>
</td>
</tr>
<tr id="java-8">
<td class="title"><img src="images/java8.png" alt="" /> Java 8</td>
<td class="content"><a href="http://docs.oracle.com/javase/8/">Java&trade; 8</a> is here, and JDT fully supports it. The Eclipse compiler for Java (ECJ) implements all the new Java 8 <a
href="http://docs.oracle.com/javase/8/docs/technotes/guides/language/enhancements.html">language enhancements</a>.</td>
</tr>
<tr id="generate-methodparameters">
<td class="title"><img src="images/java8.png" alt="" /> Option to control generation of method parameter attributes in class files</td>
<td class="content">In 1.8 compliance mode, you can enable the generation of method parameter attributes in class files:
<p>
<img src="images/store-method-parameters.png" alt="Option to store method parameters in class files" />
</p>
</td>
</tr>
<tr id="contrib-jres">
<td class="title">Contributed VMs are more recognizable</td>
<td class="content">You can't remove VMs that have been contributed to Eclipse via the <code>org.eclipse.jdt.launching.vmInstalls</code> extension point.This fact is now more
recognizable:
<p>
<img src="images/contrib-vm.png" alt="The Installed JREs preference page showing a contributed VM install" />
</p>
</td>
</tr>
<tr id="null-types-annotations">
<td class="title"><img src="images/java8.png" alt="" /> Null type annotations</td>
<td class="content">With the advent of "type annotations" as introduced in Java 8 via JSR 308, JDT takes null pointer analysis to the next level.
<p>
This feature requires a set of nullness annotations declared with
<code>@Target({TYPE_USE})</code>
, which JDT ships as version 2.0.0 of the <a href="http://help.eclipse.org/luna/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/annotation/package-summary.html"><code>org.eclipse.jdt.annotation</code></a>
bundle.
</p>
<p>With these annotations, nullness can be considered as an intrinsic part of the type system, allowing the compiler to perform null type checking along with each task of type checking.
This is a major step towards systematically detecting all possible NullPointerExceptions in a program.</p>
<p>The most obvious benefit is in annotating type arguments of generic types:</p>
<p>
<a href="images/generics_unsafeSingleton.txt"><img src="images/generics_unsafeSingleton.png" alt="null annotated generics (1)" /></a>
</p>
<p>
The example shows diverse usage of null-annotated type arguments. While most of the code has been checked to be safe, the compiler directly points out one obvious bug:
<code>in</code>
is declared with a nullable type, and hence cannot be passed into
<code>add()</code>
of a list of nonnull elements.
</p>
<p>
<a href="images/generics_unsafePredicateCall.txt"><img src="images/generics_unsafePredicateCall.png" alt="null annotated generics (2)" /></a>
</p>
<p>
In this variant an error is detected by recognizing that
<code>string</code>
has been extracted from a list that may contain nulls, hence passing this value into a Predicate expecting a nonnull argument is wrong.
</p>
<p>
For a comprehensive description of type annotation based null analysis see the <a
href="http://help.eclipse.org/luna/topic/org.eclipse.jdt.doc.user/tasks/task-using_null_type_annotations.htm">online help</a>.
</p>
<p>
While potentially, the new approach could lead to an explosion of the number of annotations, also <a
href="http://help.eclipse.org/luna/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/annotation/NonNullByDefault.html"><code>@NonNullByDefault</code></a> has become much
more powerful, such that programs not using any null values can be fully checked with just a single annotation:
</p>
<p>
<a href="images/generics_defaults.txt"><img src="images/generics_defaults.png" alt="null annotated generics (2)" /></a>
</p>
<p>
The
<code>@NonNullByDefault</code>
annotation in line 7 affects most types in the example (with the exception of local variables, which are inferred using flow analysis). The compiler directly points out the single bug in
the
<code>safe_</code>
methods: the type argument of list
<code>result</code>
defaults to '
<code>@NonNull String</code>
', hence passing null to its
<code>add()</code>
method is now wrong.
</p>
<p>
In line 27 all null-defaults are canceled for the scope of method
<code>unprotectedClient()</code>
. Here we simulate the interface between un-annotated (legacy) code and code governed by
<code>@NonNullByDefault</code>
. We can observe that all arguments and local variables from the legacy code require unchecked conversions when being passed into the annotated code. In particular note that
<code>myStrings</code>
lacks two annotations required by the method
<code>safeFilter()</code>
: the List should be nonnull, and so should be its type argument.
</p>
</td>
</tr>
<tr id="migrating-null-annotations">
<td class="title"><img src="images/java8.png" alt="" /> Migrating projects using null annotations for use in Luna</td>
<td class="content">The switch from declaration annotations (Java 5) to null type annotations (Java 8) brings a few unavoidable incompatibilities. Developers already using null
annotations are advised to carefully read the <a href="http://help.eclipse.org/luna/topic/org.eclipse.jdt.doc.user/tasks/task-using_null_type_annotations.htm#compatibility">compatibility
notes</a>.
<p>Main points to observe:</p>
<dl>
<dt>
<a href="http://help.eclipse.org/luna/topic/org.eclipse.jdt.doc.user/tasks/task-using_null_type_annotations.htm#compatibility_configuration">Project configuration</a>
</dt>
<dd>
No matter if you are adopting null type annotations or continue to use old-style null annotations: always refer to the
<code>org.eclipse.jdt.annotation</code>
bundle using a suitable version range, either
<code>[1.1.0,2.0.0)</code>
for declaration annotations or
<code>[2.0.0,3.0.0)</code>
for type annotations. This is important, because Eclipse now ships with both versions of the annotation bundle.<br /> As an alternative, OSGi/plug-in projects may use a <a
href="http://help.eclipse.org/luna/topic/org.eclipse.pde.doc.user/guide/tools/file_wizards/new_target_definition.htm">target definition</a> for explicitly selecting the appropriate
version of the annotation bundle.
</dd>
<dt>
<a href="http://help.eclipse.org/luna/topic/org.eclipse.jdt.doc.user/tasks/task-using_null_type_annotations.htm#compatibility_syntax">Syntax changes</a>
</dt>
<dd>When migrating to null type annotations, your code may need to be changed if you have null annotations attached to an array type or to a qualified type reference. The latter may
simply create a new compile error, while the former implicitly changes its meaning.</dd>
</dl>
</td>
</tr>
<tr id="ecj-needs-1.5">
<td class="title">ECJ requires 1.6 JRE</td>
<td class="content">The JDT Core project has moved to Java 1.6 compliance level. This means the command line compiler now requires JRE 1.6 or above to run.</td>
</tr>
<tr id="man-page-batch-compiler">
<td class="title">A man page is available for ECJ batch compiler</td>
<td class="content">A UNIX like man page is available for the batch compiler. This man page essentially lists down the options and the corresponding usage information as found in this <a
href="http://help.eclipse.org/luna/topic/org.eclipse.jdt.doc.user/tasks/task-using_batch_compiler.htm">section</a>.
<p>Information in the man file can be read by the command "man &lt;path_to_ecj.1&gt;" in command prompt mode.</p>
</td>
</tr>
<!-- ******************* Java Views and Dialogs ************************************* -->
<tr>
<td id="JavaViewsAndDialogs" class="section" colspan="2">
<h2>Java Views and Dialogs</h2>
</td>
</tr>
<tr id="search-limit-method-reference-expressions">
<td class="title"><img src="images/java8.png" alt="" /> Option to fine-grain Java search to limit to method reference expressions</td>
<td class="content">The Java search for method and constructor can now be limited to method reference expressions.
<p>
This option can be configured by clicking the hyperlink next to <b>Search &gt; Java Search &gt; Limit To &gt; Match locations</b>:
</p>
<p>
<img src="images/search-limitto-method-reference-expression.png" alt="" />
</p>
</td>
</tr>
<!-- *********************** Debug ******************************** -->
<tr>
<td id="Debug" class="section" colspan="2">
<h2>Debug</h2>
</td>
</tr>
<tr id="java8-debug-support">
<td class="title"><img src="images/java8.png" alt="" /> Java 8 debug support</td>
<td class="content">Java Debugger has been enhanced to support Java 8 key features like:
<ul>
<li>Evaluating expressions and variables from the context of interface methods</li>
<li>Java Application can now be executed from the static main method in interface (without <b>public</b> modifier also)
</li>
<li>Breakpoints can be added inside lambda expressions</li>
</ul> See <a
href="https://bugs.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&amp;bug_status=VERIFIED&amp;classification=Eclipse&amp;component=Debug&amp;list_id=9280044&amp;product=JDT&amp;query_format=advanced&amp;resolution=FIXED&amp;short_desc=[1.8]&amp;short_desc_type=allwordssubstr">
here </a>for details on debugger enhancements.
</td>
</tr>
<tr id="improved-hcr">
<td class="title">Improved HCR for member types</td>
<td class="content">Hot Code Replace (HCR) has been improved in the Java debugger to ensure the correct method is dropped to in member types (inner / anonymous / local classes).
<p>
For more information see the <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=409023">bugzilla entry</a>.
</p>
</td>
</tr>
<!-- ******************* JUnit ************************************* -->
<tr>
<td id="JUnit" class="section" colspan="2">
<h2>JUnit</h2>
</td>
</tr>
<tr id="junit-failure-trace-font">
<td class="title">Failure trace font for the JUnit view</td>
<td class="content">The font for the failure trace in the JUnit view is now configurable on the <b>General &gt; Appearance &gt; Colors and Fonts</b> preference page.
<p>
<img src="images/junit-failure-trace-font.png" alt="" />
</p>
</td>
</tr>
<!-- ****************** END OF N&N TABLE ****************** -->
</tbody>
</table>
<p align="center">
<a href="eclipse-news-part1.php">Previous</a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="eclipse-news-part3.php">Next</a>
</p>
</body>
</html>