Eclipse Project Oxygen (4.7) M6 - New and Noteworthy

Here are some of the more noteworthy things available in the Oxygen milestone build M6 which is now available for download.
We also recommend to read the Tips and Tricks, either via Help > Tips and Tricks... or online for Platform, JDT, and PDE.

Platform
Generic editor can now read patch and diff files An extension was provided to the generic editor so that it now can provide syntax highlighting for files with the .patch or .diff extension. Right-click the file and choose Open with > Generic Text Editor to see the editor in action.

Improved exit and restart dialogs The exit and restart dialogs now use verbs instead of OK/No/Yes, which makes the dialogs more direct and specific.

JDT
HiDPI JDT icons Composite icons such as Java element icons with modifier overlays are now rendered in high resolution in environments that support HiDPI images.

Update: On macOS, a bug was found when running with a non-Retina display as main screen and a Retina display as secondary screen. If you're affected, please update the Eclipse SDK to a recent I-build (such as I20170318-2000) from
http://download.eclipse.org/eclipse/updates/4.7-I-builds/

Warnings for unlikely argument types Many developers have learned the hard way, that certain uses of Java collections that pass the compiler's type check, may still contain "type errors", resulting in unexpected runtime behaviour. A new analysis has been added to the Eclipse compiler for Java that will detect the most common bugs in this area.

The common reason behind this problem is the fact that not all methods of those collection types make use of generics in the way one might expect. As a result it is possible to create a Set<Short>, whose add(Short) method will only accept arguments of type Short, yet method remove(Object) will happily accept literally any argument, because the method's parameter has type Object.

Here is a code snippet that seems to add and remove the same element from the set, but at a closer look the remove call has no effect. What is difficult to see for the naked eye is now flagged by a new warning:

Warning on last line: Unlikely argument type int for remove(Object) on a Collection<Short>

In a simple world, this would be all there is to say, but over time people have developed various code patterns that rely on these overly general signatures. Consider the following use of subtyping:

Depending on your coding style this may or may not be accepted as a legitimate short hand for:
if (n instanceof Short) set.remove((Short) n);
To reduce the churn caused by the new analysis, we developed some heuristics that filter out cases where types are "sufficiently similar", so the above goes unwarned.

As with any heuristic, there is no clear line. This implies that the compiler may show "unwanted" warnings, or filter out invocations that are in fact bugs. For the former case, @SuppressWarnings("unlikely-arg-type") will document the exception both for the user and for the compiler. For the latter case, we provide an option to tighten the rules, namely to apply strict type compatibility checks instead of said heuristics. For this extra scrutiny you may enable the sub-option Perform strict analysis against the expected type in Preferences > Java > Compiler > Errors/Warnings > Potential programming problems.

Preference options

Similarly, a check with default severity "Info" is offered for unlikely invocations of java.lang.Object.equals(Object) and java.util.Objects.equals(Object,Object).

Info on last line: Unlikely argument type for equals(): Name seems to be unrelated to String

Conditional watchpoint Like for line breakpoints, conditions can now also be added to Watchpoints, where the old value of the field can be used as part of the condition.

Code formatter: new way to count comment width A new option has been added in the code formatter profile editor that makes the formatter count a comment's width from its starting position instead of the beginning of the line. This allows more space for comments in heavily indented blocks of code and for line comments added to the right of some code, but at the same time keeps comments that start at the beginning of the line from getting too wide and uncomfortable to read.

You can change this setting in the Comments section, under the Line width group:

PDE
p2.inf files open in Properties editor The default editor associated with p2.inf files is now the Properties File Editor.
Quick Fix to add bundle or package adds import statement The Quick Fix that adds an Import-Package or Require-Bundle dependency in the MANIFEST.MF now also adds the relevant import statement for the unresolved type in the Java editor.
API Tools: option for field addition to an annotation On the Plug-in Development > API Errors/Warnings preference page in the API Compatibility tab, there is a new option in the Annotation section to control the severity of a "field addition to annotation".

Declarative Services Annotations v1.3 Version 1.3 of OSGi Declarative Services delivers a number of improvements, including Component Property Types for strongly-typed configuration parameter handling, Field Strategy for dependency injection, service/reference scoping, and others.

PDE now supports the enhanced annotations and new usage options. It generates component properties from any Component Property Types that you may use in your component lifecycle methods. It also creates reference entries from @Reference annotations specified directly in @Component as well as annotated member fields. New reference event method signatures are also supported.

To enable this feature, go to Preferences or Project Properties > Plug-in Development > DS Annotations and check Generate descriptors from annotated sources.

Platform Developers
CompositeImageDescriptor HiDPI-ready The ImageDescriptor and CompositeImageDescriptor classes in org.eclipse.jface.resource are now fully ready for HiDPI images. In Neon (4.6), only ImageDescriptor#createFromURL(URL) supported high-resolution images.

Clients that use DecorationOverlayIcon will get HiDPI support for free. Subclasses of CompositeImageDescriptor will have to update their implementation of #drawCompositeImage(int, int) to use the new #drawImage(ImageDataProvider, int, int) method to draw the elements of the composite image.

Old code:
protected void drawCompositeImage(int width, int height) {
	// draw overlay in top-right corner:
	ImageData imageData = myImageDescriptor.getImageData();
	drawImage(imageData, width - imageData.width, 0);
}
      
HiDPI-aware code:
protected void drawCompositeImage(int width, int height) {
	// draw overlay in top-right corner:
	CachedImageDataProvider provider =
		createCachedImageDataProvider(myImageDescriptor);
	drawImage(provider, width - provider.getWidth(), 0);
}
      

Hint: Use CompositeImageDescriptor­#createCachedImageDataProvider(­Image­/ImageDescriptor) to create an ImageDataProvider. To calculate the width and height of the image that is about to be drawn, you can use CachedImageDataProvider­#getWidth()/­getHeight(). These methods already return values in SWT points, so that your code doesn't have to deal with device-dependent pixel coordinates.

SWT Table header colors Support for custom table header foreground and background colors has been added on Windows and Linux (GTK3) platforms.

APIs for Table header foreground color:
Table#getHeaderForeground()
Table#setHeaderForeground(Color)

APIs for Table header background color:
Table#getHeaderBackground()
Table#setHeaderBackground(Color)

Screen-shot of an SWT Table with customized header on Linux (GTK3):

AccessibleTableListener­#getCaption(..) deprecated The AccessibleTableListener#getCaption(AccessibleTableEvent) method corresponds to the IAccessibleTable2::caption method, which has been deprecated by the IA2 accessibility specification implemented by SWT Accessibility. Instead, an IA2_RELATION_LABELED_BY relation should be used to create a relation between the table and its caption.
AccessibleTableListener­#getSummary(..) deprecated The AccessibleTableListener#getSummary(AccessibleTableEvent) method corresponds to the IAccessibleTable2::summary method, which has been deprecated by the IA2 accessibility specification implemented by SWT Accessibility. Instead, an IA2_RELATION_DESCRIBED_BY relation should be used to create a relation between the table and its summary.
Separation of DI extension annotations and supplier The annotations specified in org.eclipse.e4.core.di.extensions and the corresponding ExtendedObjectSupplier implementations have been separated. The annotations are still available in the org.eclipse.e4.core.di.extensions bundle. The ExtendedObjectSupplier implementations have beend moved to the new org.eclipse.e4.core.di.extensions.supplier bundle. This makes it easier for platform adopters to change the default implementation by providing a replacement for the supplier bundle.

For plug-in based products this means that the new org.eclipse.e4.core.di.extensions.supplier bundle needs to be added the list of included plug-ins. Feature based products should not notice the split.

Note: As part of the re-organization, org.eclipse.e4.core.di.extensions.EventUtils (only intended to be used for internal testing), was moved to org.eclipse.e4.core.di.internal.extensions.util.EventUtils in the new bundle.

@Service annotation available in DI extensions The @Service annotation has been added to org.eclipse.e4.core.di.extensions. You can use this annotation to get OSGi services injected by supporting additional service specific features like getting services with higher service ranking injected automatically, to get the list of services injected for the given type, and to filter for a specific filter by providing an OSGi LDAP filter.
public class MyPart {
		   
    // highest ranked service
	
    @Inject
    @Service
    MyOsgiService service;
			
}
public class MyPart {

    // all services sorted by ranking

    @Inject
    @Service
    List<MyOsgiService> service; 
		
}
public class MyPart {
		    
    // get the highest ranked service that has
    // the component property connection=online set		
	
    @Inject
    @Service(filterExpression="(connection=online)") 
    MyOsgiService service;
			
}
Imperative Expressions You can now define visible-when expressions for menu items and tool items in an Eclipse 4 fashion by using ImperativeExpressions rather than CoreExpressions.

ImperativeExpressions reference a POJO class with a method being annotated with the new @Evaluate annotation.
public class TestExpression {
   @Evaluate
   public boolean isVisible(EPartService partService,
          @Optional @Named("myValueToBeChecked") String myValueToBeChecked) {

      return "expectedValue".equals(myValueToBeChecked) &&
         !partService.getDirtyParts().isEmpty();
   }
}
The tracking property causes to track the values which are injected so that the visible state will be evaluated on eclipse context changes, e.g, when the "myValueToBeChecked" value in the context is changed, the visibility check will be run once more.
Equinox
Tracing honors -consoleLog When the -consoleLog runtime option is specified on the command line, the Eclipse debug tracing framework will send trace messages to System.out too (typically back to the command shell, if any). This is especially handy when debugging Eclipse from Eclipse with tracing enabled, so no extra trace file needs to be opened to check tracing output, and tracing output appears together with all other debug output in the Console view.

The above features are just the ones that are new since the previous milestone build. Summaries for earlier Oxygen milestone builds: