blob: f1f91731201af7c808a2a7720c2787ae7256e953 [file] [log] [blame]
<?xml version="1.0" encoding="iso-8859-1"?>
<!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) IBM Corporation and others 2011."/>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
p, table, td, th { font-family: verdana, arial, helvetica, geneva; font-size: 10pt}
pre { font-family: "Courier New", Courier, mono; font-size: 10pt}
h2 { font-family: verdana, arial, helvetica, geneva; font-size: 18pt; font-weight: bold ; line-height: 14px}
code { font-family: "Courier New", Courier, mono; font-size: 10pt}
sup { font-family: verdana, arial, helvetica, geneva; font-size: 10px}
h3 { font-family: verdana, arial, helvetica, geneva; font-size: 14pt; font-weight: bold}
li { font-family: verdana, arial, helvetica, geneva; font-size: 10pt}
h1 { font-family: verdana, arial, helvetica, geneva; font-size: 24pt; font-weight: bold}
body { font-family: verdana, arial, helvetica, geneva; font-size: 10pt; margin-top: 5mm; margin-left: 3mm}
.indextop { font-size: x-large; font-family: verdana, arial, helvetica, sans-serif; font-weight: bold}
.indexsub { font-size: xx-small; font-family: verdana, arial, helvetica, sans-serif; color: #8080FF}
a.bar:link { text-decoration: none; color: #FFFFFF}
a.bar:visited { color: #FFFFFF; text-decoration: none}
a.bar:hover { color: #FFFFFF; text-decoration: underline}
a.bar { color: #FFFFFF}
.section {font-size: 20px; font-weight: bold;}
table.news td {border-top: solid thin black;}
table.news tr {vertical-align: top;}
table.news tr td.title {vertical-align: top; width: 30%; font-weight: bold;}
table.news tr td.content {vertical-align: top; width: 70%;}
</style>
<title>What's new for Java 7</title>
</head>
<body>
<h1>What's new for Java 7</h1>
<p>
Java 7 comes with a set of <a href="http://download.oracle.com/javase/7/docs/technotes/guides/language/enhancements.html#javase7">small enhancements</a>
to the Java language (aka Project Coin), a new byte code to dynamically invoke methods
and many additions to the libraries. The Eclipse compiler implements all the new features of Java 7 and all Eclipse JDT features like e.g. search
and refactoring have been updated to support Java 7. Besides that, some new features got added:
</p>
<ul>
<li><a href="#diamond">Improved Type Inference for Generic Instance Creation (Diamond)</a></li>
<li><a href="#Multi-catch">Multi-catch</a></li>
<li><a href="#try-with-resources"><code>try</code>-with-resources statement</a></li>
<li><a href="#simplified-varargs-method-invocation">Simplified Varargs Method Invocation</a></li>
<li><a href="#strings-in-switch">Strings in switch</a></li>
<li><a href="#polymorphic-methods">Polymorphic Methods</a></li>
<li><a href="#miscellaneous">Miscellaneous</a></li>
</ul>
<table class="news" border="0" cellpadding="10" cellspacing="0" width="80%" summary="news entries">
<tr>
<td id="diamond" class="section" colspan="2">
Improved Type Inference for Generic Instance Creation (Diamond)
</td>
</tr>
<tr id="content-assist-diamond">
<td class="title">Content assist inserts diamond</td>
<td class="content">
Where possible, content assist for constructor invocations now inserts a diamond instead of explicit type arguments.
<p><img src="images/content-assist-diamond-1.png" alt="Content assist after 'new HashMap'"/></p>
Result:
<p><img src="images/content-assist-diamond-2.png" alt="Content assist inserted 'new HashMap&lt;&gt;()'"/></p>
</td>
</tr>
<tr id="redundant-specification-of-type-arguments">
<td class="title">Detection of redundant type arguments</td>
<td class="content">
The compiler can now detect <b>redundant specification of type arguments</b>, which you can remove via the <b>Remove type arguments</b> quick fix.
<p><img src="images/redundant-specification-of-type-arguments.png" alt="Redundant specification of type arguments"/></p>
<p>This option is disabled by default but can be enabled on the <b>Java &gt; Compiler &gt; Errors/Warnings</b> preference page:</p>
<p><img src="images/redundant-type-arguments-warning.png" alt="Redundant type arguments warning"/></p>
</td>
</tr>
<tr id="insert-inferred-type-arguments">
<td class="title">New Insert inferred type arguments quick assist</td>
<td class="content">
You can <b>insert inferred type arguments</b> of a diamond via a quick assist.
<p><img src="images/insert-inferred-type-arguments.png" alt="Insert inferred type arguments"/></p>
<p>Hint: This also works as a quick fix in 1.5 and 1.6 code, where the diamond is a syntax error.</p>
</td>
</tr>
<tr>
<td id="Multi-catch" class="section" colspan="2">
Multi-catch
</td>
</tr>
<tr id="surround-with-try-multicatch">
<td class="title">New Surround with try/multi-catch quick fix</td>
<td class="content">
The new action <b>Source > Surround With > Try/multi-catch Block</b> allows you to surround selected statements with a try/multi-catch block.
This is also available as <b>Surround with try/multi-catch</b> quick fix in case there are multiple uncaught exceptions.
<p><img src="images/surround-with-try-multicatch.png" alt="Surround with try/multi-catch"/></p>
</td>
</tr>
<tr id="add-exceptions-to-existin-catch-clause">
<td class="title">New Add exceptions to existing catch clause quick fix</td>
<td class="content">
The new <b>Add exceptions to existing catch clause</b> quick fix allows you to add uncaught exceptions to an existing catch clause.
<p><img src="images/add-exceptions-to-existin-catch-clause.png" alt="Add exceptions to existing catch clause"/></p>
</td>
</tr>
<tr id="use-separate-catch-blocks">
<td class="title">New Use separate catch blocks quick assist</td>
<td class="content">
The new <b>Use separate catch blocks</b> quick assist allows you to replace a multi-catch clause with individual catch blocks,
one for each exception in the multi-catch clause.
<p><img src="images/use-separate-catch-blocks.png" alt="Use separate catch blocks"/></p>
</td>
</tr>
<tr id="move-exceptions-to-separate-catch-block">
<td class="title">New Move exceptions to separate catch block quick assist</td>
<td class="content">
The new <b>Move exceptions to separate catch block</b> quick assist allows you to pick out one or more selected exceptions from a multi-catch clause.
<p><img src="images/move-exceptions-to-separate-catch-block.png" alt="Move exceptions to separate catch block"/></p>
</td>
</tr>
<tr id="combine-catch-blocks">
<td class="title">New Combine catch blocks quick assist</td>
<td class="content">
The new <b>Combine catch blocks</b> quick assist allows you to combine separate catch blocks into a single multi-catch block.
The quick assist is offered only when bodies of all the catch blocks are same.
<p><img src="images/combine-catch-blocks.png" alt="Combine catch blocks"/></p>
</td>
</tr>
<tr id="remove-exception">
<td class="title">New Remove exception quick fix</td>
<td class="content">
The compiler gives an error if an exception in a multi-catch clause is already caught by an alternative exception.
The new <b>Remove exception</b> quick fix allows you to remove this exception.
<p><img src="images/remove-exception.png" alt="Remove exception"/></p>
</td>
</tr>
<tr id="throwing-exception">
<td class="title">Mark Occurrences</td>
<td class="content">
<b>Mark Occurrences</b> has been updated to understand the multi-catch syntax.
<p><img src="images/throwing-exception.png" alt="Mark Occurrences"/></p>
</td>
</tr>
<tr id="formatter-multi-catch">
<td class="title">Formatter</td>
<td class="content">
There are new <b>Line Wrapping options</b> in the formatter for the multi-catch syntax.
<p>These can be configured on <b>Java &gt; Code Style &gt; Formatter</b> preference page under
<b>Line Wrapping &gt; Statements &gt; 'multi-catch'</b>. </p>
</td>
</tr>
<tr>
<td id="try-with-resources" class="section" colspan="2">
try-with-resources statement
</td>
</tr>
<tr id="unhandled-exceptions-thrown-by-automatic-close">
<td class="title">Detection of unhandled exceptions thrown by automatic close()</td>
<td class="content">
The compiler detects unhandled exceptions thrown by automatic <code>close()</code> invocation on a resource.
<p><img src="images/unhandled-exception-thrown-by-automatic-close.png" alt="Detection of unhandled exceptions thrown by automatic close()"/></p>
</td>
</tr>
<tr id="mark-occurrences-exception-thrown-by-automatic-close">
<td class="title">Mark Occurrences</td>
<td class="content">
<b>Mark Occurrences</b> has been updated to understand the <code>try</code>-with-resources syntax.
<p>The closing '}' of a <code>try</code>-with-resources statement is marked as a method exit point if the implicit <code>close()</code>
invocation throws an exception. The corresponding resource variable is also highlighted.</p>
<p><img src="images/mark-occurrences-exception-thrown-by-automatic-close.png" alt="Mark Occurrences"/></p>
</td>
</tr>
<tr id="formatter-try-with-resources">
<td class="title">Formatter</td>
<td class="content">
There are new <b>Line Wrapping and White Space options</b> in the formatter for the <code>try</code>-with-resources syntax.
<p>These can be configured on <b>Java &gt; Code Style &gt; Formatter</b> preference page under
<b>Line Wrapping &gt; Statements &gt; 'try-with-resources'</b> and <b>White Space &gt; Control Statements &gt; 'try-with-resources'</b>.</p>
</td>
</tr>
<tr>
<td id="simplified-varargs-method-invocation" class="section" colspan="2">
Simplified Varargs Method Invocation
</td>
</tr>
<tr id="add-safevarargs">
<td class="title">New Add @SafeVarargs quick fix</td>
<td class="content">
The new <b>Add @SafeVarargs</b> quick fix is offered for potential heap pollution warnings on method declarations.
<p><img src="images/add-safevarargs.png" alt="Add @SafeVarargs"/></p>
<p>The quick fix is also offered from call sites.</p>
<p><img src="images/add-safevarargs-to-declaration.png" alt="Add @SafeVarargs to declaration"/></p>
</td>
</tr>
<tr id="remove-safevarargs">
<td class="title">New Remove @SafeVarargs quick fix</td>
<td class="content">
The new <b>Remove @SafeVarargs</b> quick fix is offered for incorrect usage of @SafeVarargs annotation.
<p><img src="images/remove-safevarargs-1.png" alt="Remove @SafeVarargs"/></p>
<p><img src="images/remove-safevarargs-2.png" alt="Remove @SafeVarargs"/></p>
</td>
</tr>
<tr>
<td id="strings-in-switch" class="section" colspan="2">
Strings in switch
</td>
</tr>
<tr id="convert-switch-to-if-else">
<td class="title">Convert 'switch' to 'if-else' quick assist</td>
<td class="content">
The <b>Convert 'switch' to 'if-else'</b> quick assist has been updated for strings in switch.
<p><img src="images/convert-switch-to-if-else.png" alt="Convert 'switch' to 'if-else' quick assist"/></p>
<p>Note that the quick assist avoids a NullPointerException in the resultant code.</p>
</td>
</tr>
<tr>
<td id="polymorphic-methods" class="section" colspan="2">
Polymorphic Methods
</td>
</tr>
<tr id="invokeExact-javadoc">
<td class="title">Polymorphic method signature in Javadoc hover</td>
<td class="content">
Javadoc hovers for references to
<a href="http://download.oracle.com/javase/7/docs/api/java/lang/invoke/MethodHandle.html#sigpoly">polymorphic methods</a>
show the actually used method signature.
<p><img src="images/invokeExact-javadoc.png" alt="Polymorphic method signature in javadoc hover"/></p>
</td>
</tr>
<tr>
<td id="miscellaneous" class="section" colspan="2">
Miscellaneous
</td>
</tr>
<tr id="debug-evaluation-1-7">
<td class="title">Evaluation support for Java 7</td>
<td class="content">
The evaluation engine in JDT debug has been updated to support Java 7.
<p>
You can now use all of the new code structures from Java 7 in:
<ul>
<li>Display / Inspect actions</li>
<li>Display view</li>
<li>Assign variable value operations</li>
<li>Breakpoint conditions</li>
</ul>
</p>
For example, switch on string is supported in breakpoint conditions:
<p>
<img src="images/bp-condition.png" alt="Breakpoint condition example using switch on string"/>
</p>
</td>
</tr>
<tr id="ee-description">
<td class="title">Execution environment for Java 7</td>
<td class="content">
When configuring JREs and execution environments, you now have the ability to configure a Java 7 execution environment:
<p>
<img src="images/ee-page.png" alt="The execution environments preference page"/>
</p>
</td>
</tr>
<tr id="assign-value">
<td class="title">Assign variable value support for Java 7</td>
<td class="content">
The feature for changing the value of a variable while debugging has been updated for Java 7 to support underscores in literals
and binary literals:
<p>
<img src="images/assign-vars.png" alt="An example of assigning a binary literal with underscores to an int"/>
</p>
</td>
</tr>
<tr id="ee-description">
<td class="title">API Tools support for Java 7</td>
<td class="content">
The execution environment description for Java 7 is available from the corresponding <a href="http://wiki.eclipse.org/Eclipse_Project_Update_Sites">update site</a>.
After installing it, one can detect invalid references to Java 7 system libraries:
<p>
<img src="images/pde-api-pref-page.png" alt="The API Errors/Warnings preference page showing the new Java 7 EE description"/>
</p>
</td>
</tr>
<tr>
<td colspan="2"/>
</tr>
</table>
</body>
</html>