[[jdt]]
= Java(TM) development tools

[[Java10]]
[[java-10-support]]
== Java™ 10 Support

[[java-10]]
[[eclipse-support-for-java-10]]
=== Eclipse support for Java™ 10

http://docs.oracle.com/javase/10/[Java™ 10] is here, and JDT supports it completely.

* The Eclipse compiler for Java (ECJ) implements the new Java 10 https://docs.oracle.com/javase/10/language[language enhancement] which is the support for http://openjdk.java.net/jeps/286[*local variable type inference (JEP 286)*].

* *Addition of Java 10 JRE*
** A Java 10 JRE is recognized by Eclipse for launching. It can be added from the *Window > Preferences > Java > Installed JREs > Add...* page. It can be added from the *Package Explorer* as well using the project's context menu.
+
image::images/j10.png[image]
** An option to set compiler compliance to 10 on a Java project is provided.
+
image::images/j10.compliance.png[image]
* *Support for `var` compilation*
** Eclipse supports compilation of `var` as shown below:
+
image::images/var.compile.png[image]
** When the type of `var` cannot be inferred, it is flagged as a compiler error as expected. An example is shown below:
+
image::images/var.nocompile.png[image]
* *Code Completion for `var`*
** Code completion is offered at places where `var` is allowed.
+
image::images/var.complete.png[image]
** Code completion of var is not offered at places where `var` is not allowed.
+
image::images/var.nocomplete.png[image]
* Hover over `var` shows the javadoc of the inferred type.
+
image::images/var.hover.png[image]
* Quick Assist to convert from `var` to the appropriate type is provided.
+
image::images/var.vartotype.png[image]
* Quick Assist to convert from type to `var` is provided.
+
image::images/var.typetovar.png[image]

[[quickfix-change-compliance-10]]
[[quick-fix-to-change-project-compliance-and-jre-to-10]]
=== Quick Fix to change project compliance and JRE to 10

A Quick Fix *Change project compliance and JRE to 10* is provided to quickly change the current project to be compatible with Java 10.

image::images/quickfix-change-compliance-10.png[image]

[[Java9]]
[[java-9-support]]
== Java™ 9 Support

[[java-9]]
[[eclipse-support-for-java-9]]
=== Eclipse support for Java™ 9

http://docs.oracle.com/javase/9/[Java™ 9] is here, and JDT supports it completely:

* The Eclipse compiler for Java (ECJ) implements all the new Java 9 https://docs.oracle.com/javase/9/language[language enhancements">language enhancements]
* Updated significant features to support Java Modules, such as compiler, search and many editor features.

*Note:* It is not mandatory to run Eclipse with Java Runtime 9 to get the Java 9 support. However, a Java runtime 9 is required to be on a project's build path to compile a modular project against the system modules.

* When a Java Runtime 9 is added to a project's build path, the system modules are listed under the System library in the package explorer:
+
image::images/java9-package-explorer.png[image]

* An existing non-modular Java project can be quickly converted to a module by creating a module-info.java for that project. This feature can be availed once the project has been moved to compliance 9:
+
image::images/java9-create-module.png[image]

* With Java 9 support, a library or a container can now be added to the module path as opposed to the classpath:
+
image::images/java9-module-path.png[image]

* Once an entry has been added to a project's module path, its contents and encapsulation properties can further be modified by double-clicking on the *Is modular* node (or using the *Edit* button while *Is modular* is selected):
** On the *Contents* tab individual modules inside a container like *JRE System Library* can be included or excluded by moving the module from left-to-right or vice versa. Modules shown in the lower right box are implicitly included, because they are required by one or more modules in the upper right box.
+
image::images/java9-module-container-contents.png[Configuring the Contents of a module container]
** On the *Details* tab the encapsulation of given modules can be further influenced. The following example shows how module `module.one` can be made to export one of its packages to the module of the current Java project:
+
image::images/java9-module-properties.png[image]
** Toggling *Defines one or more modules* (see above screenshot) lets you specify whether a given regular (non-modular) jar file or project should be considered as an "automatic module". As a consequence of changes here, the entry will move to the Modulepath or Classpath accordingly.

* Java search now includes a new search scope - Module:
+
image::images/java9-module-search.png[image]

* When a Java Runtime 9 is added to a project's build path, the launch configurations are created with "Dependencies" tab and not the old "Classpath" tab.
+
User can change the JRE of launch configuration and on the confirmation, the tab changes from "Classpath" to "Dependencies" or vice versa.
+
image::images/changing-tabs-launch-config.png[image]
+
If Java project is modular and module is described in module_info.java, most of the dependencies will be defined in the Modular Entries.
+
image::images/modular-dependencies.png[image]
+
If Java project is not modular, most of the dependencies will be defined in the Classpath Entries.
+
image::images/non-modular-dependencies.png[image]

* A new Quick Fix is offered on import statements to fix issues that are reported due to *missing module dependency*
+
This Quick Fix is applicable if the project is a Java9 project and has a `module-info.java`.
+
The Quick Fix can be invoked from the editor:
+
image::images/java9-module-requires-on-import.png[image]
+
Before the Quick Fix is applied the module-info file looks as below
+
image::images/java9-before-adding-module-requires-on-import.png[image]
+
After the Quick Fix is invoked, ` module-info.java` will be updated to include `requires 'MODULE_NAME'`
+
image::images/java9-after-adding-module-requires-on-import.png[image]

* A new Quick Fix is available when you have an unresolved type in a Java file. If the unresolved type can be found in a java9 module, a Quick Fix will be available to add an import type entry to your file reporting the error and add the required module dependency to `module-info.java` file.
+
This Quick Fix is applicable if the project is a Java9 project and has a `module-info.java` file.
+
The Quick Fix can be invoked from the editor:
+
image::images/java9-module-requires-and-import-on-missing-type.png[image]
+
Before the Quick Fix is applied, the module-info file looks as below
+
image::images/java9-before-adding-module-requires-on-import.png[image]
+
After the Quick Fix is invoked, ` module-info.java` will be updated to include `requires 'MODULE_NAME'`
+
image::images/java9-after-adding-module-requires-on-import.png[image]
+
After the Quick Fix is applied, the required `import` statement is added to the file reporting error
+
image::images/java9-after-adding-import-module-requires-and-import-on-missing-type.png[image]

* A new Quick Fix is available when you have an unresolved type on `service provider` in a provides directive in module-info.java file. If the unresolved type can not be found in the current module, a Quick Fix will be available to create a new class or an interface in the current module.
+
This Quick Fix is applicable if the project is a Java9 project and has a `module-info.java` file.
+
The Quick Fix can be invoked from the editor:
+
image::images/java9-module-provides-create-class.png[image]
+
image::images/java9-module-provides-create-interface.png[image]
+
When the service is a class, the Quick Fix is proposed for creating a class.
+
When the service is an interface or an annotation, two Quick Fixes are proposed for creating a class or an interface.

[[new---release-on-the-java-compiler-preference-page]]
=== New `--release` on the Java compiler preference page

A new option `--release` is available on the Java compiler preference page.

This option will be enabled only if the JRE being used is a Java 9 or above.

Workspace Preference:

image::images/java9_release_option_workspace_preference_page.png[image]

Project Preference:

image::images/java9_release_option_project_preference_page.png[image]

In the past, it was possible to compile for an older version of the Java language.

However, the compiler always compiled against the platform APIs that is found in the project's build path.

*For Example:* If the JRE being used is java 1.8 and the compliance level is set to 1.7, the API's that are available are from the Java8 library, even if they were not part of Java 1.7.

The new --release compiler option now allows the user to configure compilation against a platform API version of user's choice.

*For Example:* Using --release option if the JRE being used is 9 and the compliance level is set to 1.7, the API's that are available will be from JRE 1.7 even if JRE 1.7 is not available in your workspace.

The --release option supports versions 1.6 and above. That is the --release option is enabled for JRE 9 and above, if the compliance is set to 1.6 or above

In the below picture, compliance is set to 1.5, therefore the --release option is disabled.

image::images/java9_release_option_disabled_project_preference_page.png[image]

The --release option is enabled by default for all new projects created using JRE 9 or above.

[[use---release-option-for-default-access-rules-and-ee-descriptor]]
=== Use `--release` option for Default Access rules and EE descriptor

Java 9 onwards, Access rules intrinsic to JRE will not be available by default. Users must use the --release option to configure compilation against the version of Java library of his or her preference.

From Java 10 and beyond, API tools Execution Environment Descriptions will not be provided to determine if references are present in execution environment or not. Users must use the --release option to configure compilation against platform API of his or her preference. If the user intends to enforce a particular version of Java for determining Java API references in a project, he or she can store this preference in the project settings.

[[module-info-paste]]
[[paste-module-info.java-code-in-package-explorer]]
=== Paste module-info.java code in Package Explorer

You can now paste a snippet of code representing module-info.java directly into a source folder to create a module-info.java file. For example, copy this code:

....
import java.sql.Driver;
module hello {
    exports org.example;
    requires java.sql;
    provides Driver with org.example.DriverImpl;
}
....

Then, select a source folder in a Java 9 project in the *Package Explorer* view and use *Ctrl+V (Edit > Paste)* to paste it. This automatically creates a module-info.java file in the source folder with the copied content.

[[content-assist-module-declaration-name]]
[[content-assist-for-module-declaration-name]]
=== Content assist for module declaration name

Content assist *(Ctrl+Space)* support is now available for module declaration name.

image::images/content-assist-module-declaration-name.png[image]

[[quickfix-javadoc]]
[[quick-fix-for-unresolved-module-on-module-name-in-requires-directive]]
=== Quick Fix for `unresolved module` on module name in `requires directive`

A new Quick Fix is offered on *requires* statements in the *module-info.java* file to fix issues that are reported due to unresolved module. The below Quick Fix will be provided if the module related to the unresolved module error has its related classpath added to the classpath and not to the module path.

This Quick Fix is applicable if the project is a Java 9 project and has a module-info.java file

This Quick Fix can be invoked from the editor.

image::images/java9-module-requires-move-from-classpath-to-modulepath-quickfix.png[image]

Before the Quick Fix is applied the classpath entries look as below:

image::images/java9-module-requires-move-from-classpath-to-modulepath-CPE-before-quickfix.png[image]

After the Quick Fix is applied the classpath entries look as below:

image::images/java9-module-requires-move-from-classpath-to-modulepath-CPE-after-quickfix.png[image]

[[quick-fix-for-non-existing-or-empty-package-on-exports-directive]]
=== Quick Fix for `Non-existing or empty package` on ` exports directive`

A new Quick Fix is available when you have a ` non-existing or an empty package` in an `exports directive` in module-info.java file.

This Quick Fix is applicable if the project is a Java9 project or above and has a `module-info.java` file.

The Quick Fix can be invoked from the editor:

image::images/java9_quickfix_empty_nonexistant_package_on_exports_directive.png[image]

A Quick Fix is provided to create either a Class, or an Interface or an Annotation or an Enum in the given package.

If the package does not exist, a new package is created and the new element is created in the package.

[[newproject-modulefile]]
[[creation-of-module-info.java-file-on-creation-of-a-new-java9-project]]
=== Creation of `module-info.java file` on creation of a new Java9 Project

When creating a Java project with compliance Java 9 or above, a new option is offered for the creation of the `module-info.java` file.

A new checkbox has been added in the Java Settings page (Page 2) of the *New Java Project* wizard. See images below.

Page 1:

image::images/create_Java_Project_1.png[image]

Page 2:

image::images/create_Java_Project_2.png[image]

The new checkbox for the creation of module-info.java file is checked by default.

When this checkbox is checked, upon project creation, the dialog for creation of a new ` module-info.java ` file will appear.

image::images/create_module_info.png[image]

Selecting *Don't Create* in the above dialog does not create the `module-info.java` file, but creates the project.

[[override-dependencies]]
[[overriding-modular-build-path-dependencies-for-launching]]
=== Overriding modular build path dependencies for launching

Based on Java build path, a Java 9 module can have command line options. These options from build path can be overridden for launching programs in the module. *Override Dependencies* button has been added to *Dependencies* tab:

image::images/override-dependencies-button.png[Override Dependencies button]

Dialog can be used to override modular dependencies:

image::images/override-dependencies-dialog.png[Override Dependencies dialog]

[[JUnit]]
[[junit]]
== JUnit

[[junit-5-support]]
[[eclipse-support-for-junit-5.1]]
=== Eclipse support for JUnit 5.1

http://junit.org/junit5/[JUnit 5.1] is here and Eclipse supports it.

* Create a new JUnit Jupiter test via *New JUnit Test Case* wizard:
+
image::images/new-junit-jupiter-test.png[image]
* Add JUnit 5 library to the build path:
** New JUnit Test Case wizard offers to add it while creating a new JUnit Jupiter test:
+
image::images/add-junit-5-lib.png[image]
** Quick Fix *(Ctrl+1)* proposal on **`@Test`**, **`@TestFactory`**, *`@ParameterizedTest`* and *`@RepeatedTest`* annotations:
+
image::images/add-junit-5-lib-quick-fix.png[image]
** Add JUnit library in Java Build Path dialog:
+
image::images/add-junit-5-lib-java-build-path.png[image]
* Create a JUnit Jupiter test method with the new *test_jupiter* template:
+
image::images/junit-jupiter-test-method-template.png[image]
* Create a *`@TestFactory`* method with the new *test_factory* template:
+
image::images/junit-jupiter-test-factory-template.png[image]
* JUnit Jupiter’s `Assertions`, `Assumptions`, `DynamicContainer` and `DynamicTest` classes are now added to *Eclipse Favorites* by default:
+
image::images/content-assist-favorites.png[image]
+
This allows you to quickly import the static methods from these classes in your code via Content Assist *(Ctrl + Space)* and Quick Fix **(Ctrl + 1)**.
* View all the failures from grouped assertions in the same *Result Comparison* dialog opened from JUnit view:
+
image::images/grouped-assertions-result-comparison.png[image]
* View the number of disabled tests and tests with assumption failures on hover in JUnit view:
+
image::images/skipped-tests.png[image]
* Use *Go to File* action or just double-click to navigate to the test from JUnit view even when the test is displayed with a custom name:
+
image::images/display-name.png[image]
* (Re-)Run a single *`@Nested`* test class by using the *Run* action in JUnit view or Outline view. You can even right-click on a nested test class name in the editor and use the *Run As* action:
+
image::images/run-nested-class.png[image]
* The *Test Method Selection* dialog in JUnit launch configuration now shows the method parameter types also:
+
image::images/test-method-selection-dialog.png[image]
* You can provide tags to be included in or excluded from a test run in the *Configure Tags* dialog of JUnit launch configuration:
+
image::images/junit-tags.png[image]
* In JUnit Jupiter, a method parameter of type `TestReporter` can be used to publish additional data about the current test run which can be viewed in the **Console view**:
+
image::images/junit5-test-reporter.png[image]
+
image::images/junit5-test-reporter-console-view.png[image]

*Note:*

* If you are using an Eclipse workspace where you were running your JUnit 5 tests via `@RunWith(JUnitPlatform.class)` in Eclipse without JUnit 5 support then you will have JUnit 4 as the test runner in their launch configurations. Before executing these tests in Eclipse with JUnit 5 support, you should either change their test runner to JUnit 5 or delete them so that new launch configurations are created with JUnit 5 test runner while running the tests:
+
image::images/test-runner-update.png[image]
* We do not support running tests in a setup where an old Eclipse build (not having JUnit 5 support) is using a new Eclipse build (having JUnit 5 support) as target. Also, developers who have the JDT JUnit runtime bundles `(org.eclipse.jdt.junit.runtime, org.eclipse.jdt.junit4.runtime)` checked out and pull the latest changes will run into the above issue. You are expected to use a new Eclipse build for the development.

[[JavaEditor]]
[[java-editor]]
== Java Editor

[[quickfix-nnbd-on-package]]
[[quick-fix-to-add-nonnullbydefault-to-packages]]
=== Quick Fix to add `@NonNullByDefault` to packages

A new Quick Fix is offered to fix issues that are reported when the *Missing '@NonNullByDefault' annotation on package* warning is enabled.

If the package already has a `package-info.java`, the Quick Fix can be invoked from the editor:

image::images/add-nnbd-existing-packageinfo.png[image]

Otherwise, the Quick Fix must be invoked from the problems view, and will create a `package-info.java` with the required annotation:

image::images/add-nnbd-create-packageinfo.png[image]

When invoked from the problems view, both variations of the Quick Fix can fix the problem for multiple packages simultaneously.

[[navigate-to-switch]]
[[navigate-to-switch-statement]]
=== Navigate to 'switch' statement

You can now *Ctrl+click* or use *Open Declaration (F3)* on `case` or `default` keywords to quickly navigate to the beginning of the `switch` statement.

image::images/navigate-to-switch.png[image]

[[escape-non-ascii-when-pasting]]
[[escape-non-ascii-characters-when-pasting-into-a-string-literal]]
=== Escape non-ASCII characters when pasting into a string literal

The *Java > Editor > Typing > Escape text when pasting into a string literal* preference option now has a suboption **Use Unicode escape syntax for non-ASCII characters**:

image::images/escape-non-ascii-settings.png[image]

When enabled, characters outside the visible ASCII range will be replaced by unicode escape sequences when pasted into a string:

image::images/escape-non-ascii-example.png[image]

[[jdt-syntaxcoloring-dark]]
[[improved-java-syntax-coloring-in-the-dark-theme]]
=== Improved Java syntax coloring in the dark theme

To improve readability in the dark theme, bold style usage has been reduced and some colors that were too close to each other have been altered.

image::images/java-syntax-dark.png[image]

[[inherited-members-quick-outline-jdt]]
[[improved-coloring-of-inherited-members-in-the-quick-outline-in-the-dark-theme]]
=== Improved coloring of inherited members in the Quick Outline in the dark theme

The Eclipse default dark theme now includes styling of inherited members in JDT's **Quick Outline**. This improves readability in the dark theme a lot. The color can be configured via the *Java > Inherited Members* color definition on the *Colors and Fonts* preference page.

Before:

image::images/inherited_before.png[before]

After:

image::images/inherited_after.png[after]

[[JavaViewsAndDialogs]]
[[java-views-and-dialogs]]
== Java Views and Dialogs

[[jdt-test-sources]]
[[test-sources]]
=== Test sources

In the *Java Build Path* project settings, there is now an attribute *Contains test sources* to configure that a source folder contains test sources. (Note: test sources must have their own output folder). Similarly, for projects and libraries there is an attribute **Visible only for test sources**. This setting also exists for classpath containers, and if it is set to *Yes* for one of these, this value will be used for all contained libraries and projects.

image::images/1-sourcefolder-settings-521330.png[image]

Test source folders and dependencies are shown with a darker icon in the build path settings, the package explorer and other locations. This can be disabled in **Preferences > Java > Appearance**:

image::images/1a-modified-test-icon-preferences-530179.png[image]

Referenced projects can contain test sources and have test dependencies themselves. Usually, when test sources are compiled, the test code in projects on the build path will be visible. As this is not always desirable, it can be changed by setting the new build path attribute **Without test code**, that is available for projects, to **Yes**.

image::images/2-without-test-code-526858.png[image]

Build path entries configured like this have a decoration `[without test code]` after the project name, which can be disabled in **Preferences > General > Appearance > Label Decorations**:

image::images/2a-without-test-code-decorator-530179.png[image]

For each project, compilation is now done in two phases: First all main sources (which cannot see any test-code on the build-path) and then all test sources.

image::images/3-visibilities-224708.png[image]

As a consequence, if the project is a modular Java 9 project, test dependencies like JUnit can not be referenced in the `module-info.java`, as they will not be visible while compiling it. The solution used to handle this is the same, that Maven uses: When test dependencies are put on the classpath, the module being compiled will automatically be configured to read the unnamed module during the compilation of the test sources, so the test dependencies will be visible.

Of course, code completion will not suggest test code in main sources:

image::images/4a-completion-in-main-521331.png[image]

image::images/4b-completion-in-test-521331.png[image]

There are now two dynamic Java working sets *Java Main Sources* and *Java Test Sources* containing the source folders grouped according to value of the *Contains test sources* attribute. This can for example be used to remove warnings in test sources from the problems view:

image::images/5a-problems-view-521336.png[image]

To achieve this, create a new filter that shows warnings for the *Java Main Sources* working set and select it with the *All Errors on Workspace* filter:

image::images/5b-problems-view-filters-521336.png[image]

There are also dedicated filters to quickly remove hits in main code or test code from Java search results:

image::images/6-filter-search-result-521332.png[image]

Similar, there is a filter to remove test code from **Call hierarchies**:

image::images/7-filter-call-hierarchy-521335.png[image]

Another filter to remove test code exists for **Quick type hierarchies**:

image::images/8-filter-quick-type-hierarchy-521333.png[image]

Test source folders will be preselected in the **New JUnit Test Case**-Wizard

image::images/9-new-junit-332602.png[image]

In Run and Debug configurations, the *Classpath* tab (or *Dependencies* tab when launching with Java 9) contains a new option **Exclude Test Code**, that is automatically preselected when launching a Java Application from a source folder that is not marked to contain test sources:

image::images/10-launching-529321.png[image]

When launching with Java 9 and this option is not selected, command line options will automatically be added so modules that have a non-empty classpath read the unnamed module. These command line options are part of what can be overridden using the new link:#override-dependencies[Override Dependencies] button.

[[sort-library-entries-jdt]]
[[sort-library-entries-alphabetically-in-package-explorer]]
=== Sort library entries alphabetically in Package Explorer

The content of libraries are displayed in the order of the classpath. This makes it difficult to find specific libraries by their name, especially when projects have many dependencies. The library entries can now be sorted alphabetically when setting the preference *Sort library entries alphabetically in Package Explorer* on the *Java > Appearance* preference page:

image::images/jdt_sort_library_pref.png[image]

OFF

ON

image::images/jdt_library_entries_unsorted.png[before]

image::images/jdt_library_entries_sorted.png[before]

The default for this preference is **OFF**.

[[generate-dialogs-jdt]]
[[generate-dialogs-use-verbs-instead-of-ok]]
=== Generate dialogs use verbs instead of OK

The *Generate...* dialogs of the Java tools have been adapted to use verbs instead of OK.

[[JavaCompiler]]
[[java-compiler]]
== Java Compiler

[[trapdoor-regex-module]]
[[option-for-regex-in-module-declaration-search]]
=== Option for Regex in Module Declaration Search

This is an *experimental* support provided to allow the regular expression usage in search field while searching for module declaration. This can be considered as a wrapper of the link:#regex-module-declaration-search-api[API change].

To invoke the regular expression search from the search field under Java Search, start the expression with "/r " i.e, a slash '/', the letter 'r' and a blank ' ' (not tab) followed by a regex, an example of which is shown below:

image::images/mod.regex.trap.png[Trapdoor for regular expression module declaration search]

In the above example, all the characters trailing "/r " form a Java regular expression to denote a module name which starts with zero or more 'n's followed by the string ".ver" and followed again by zero or more number of arbitrary characters.

Another example would be to search for all modules that start with `java.x` followed by zero or more characters which is given by the regular expression `/r java\.x.*` - note the backslash for . to consider this as a "normal" character instead of the special regex].

Yet another example would be search for all module names that start with j followed by zero or more characters and ending with .xml which in regex language translates to `/r j.*\.xml`. Please note that here the first '.' is the special regex character while the second '.' is escaped to denote that this is a normal character.

*Note:* You should use this only for *Declarations* search for modules as it is not implemented for module references. Selecting *All occurrences* in conjunction with regex will default to finding only the Declarations matching the regex ignoring the references.

[[nonnullbydefault-per-module]]
[[nonnullbydefault-per-module]]
=== @NonNullByDefault per module

If a module is annotated with `@NonNullByDefault`, the compiler will interpret this as the global default for all types in this module: `@org.eclipse.jdt.annotation.NonNullByDefault` +
`module my.nullsafe.mod { ...`

Note, however, that this requires an annotation type declared with target `ElementType.MODULE`. Since the annotation bundle `org.eclipse.jdt.annotation` is still compatible with Java 8, it cannot yet declare this target. In the interim, a preview version of this bundle with support for modules will be published by other means than the official SDK build.

[[nonnullbydefault-improvements]]
[[nonnullbydefault-improvements]]
=== @NonNullByDefault improvements

When using annotation-based null analysis, there are now more ways to define which unannotated locations are implicitly assumed to be annotated as `@NonNull`:

* http://help.eclipse.org/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/annotation/NonNullByDefault.html[`@NonNullByDefault`] annotations based on enum http://help.eclipse.org/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/annotation/DefaultLocation.html[`DefaultLocation`] can also be used if the primary nullness annotations are declaration annotations (previously this was supported only for `TYPE_USE` annotations).
* Support for `@NonNullByDefault` annotations that are targeted at parameters has been implemented.
* Multiple different `@NonNullByDefault` annotations (especially with different default values) may be placed at the same target, in which case the sets of affected locations are merged.
* Annotations which use a meta annotation `@TypeQualifierDefault` instead of a `DefaultLocation`-based specification are now understood, too, e.g. https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/lang/NonNullApi.html[`@org.springframework.lang.NonNullApi`].

Version 2.2.0 of bundle `org.eclipse.jdt.annotations` containing an annotation type `NonNullByDefault` that can be applied to parameter and https://www.eclipse.org/eclipse/news/4.8/M5/#nonnullbydefault-per-module[module declarations] (in addition to the previously allowed targets).

[[testsources-apt]]
[[test-sources-1]]
=== Test sources

There is now support for running Java annotation processors on link:../M5/index.html#jdt-test-sources[test sources]. The output folder for files generated for these can be configured in the project properties in *Java Compiler > Annotation Processing* as **Generated test source directory**.

image::images/testsources-apt-531072.png[image]

[[jdt-complier-building-preference]]
[[new-preference-added-compiler-compliance-does-not-match-used-jre]]
=== New preference added "Compiler Compliance does not match used JRE"

A new preference *Compiler Compliance does not match used JRE* is added to Compiler Preference Building Page.

This preference indicates the severity of the problem reported when project's used JRE does not match the compiler compliance level selected. (e.g. a project using JRE 1.8 as JRE System Library, and the compiler compliance is set to 1.7).

The value of this preference is by default WARNING.

If the JRE being used is 9 or above and the *--release* option is selected and even if the compiler compliance does not match the JRE being used, this option will be ignored.

This preference can be set as shown below:

image::images/jdt_compiler_compliance_mismatch_JRE.png[image]

[[JavaFormatter]]
[[java-formatter]]
== Java Formatter

[[formatter-profile]]
[[new-formatter-profile-page]]
=== New formatter profile page

The formatter profile preference page *(Java > Code Style > Formatter > Edit...)* has a new look which makes it much easier to set preferences for formatting Java code. Instead of multiple tabs, all preferences are presented in an expandable tree.

image::images/formatter-profile-overview.png[image]

You can use *filtering* to display only the settings with names matching a specific phrase. Filtering by values is also possible (prefix a value filter with a tilde).

image::images/formatter-profile-filtering.png[Example filtering by word 'lambda']

Most sections have a *Modify all* button in their header that lets you set all their preferences to the same value with one click.

image::images/formatter-profile-modify-all.png[image]

Some preferences have more convenient controls. For example, number values can be easily modified with arrow buttons. Wrap policy settings are controlled by simple toolbars so that you can see and compare multiple policies at once.

image::images/formatter-profile-wrap-settings.png[image]

In the preview panel you can now use your own code to immediately see how it will be affected by the modified settings. You can also see the raw form of standard preview samples and make temporary modifications to them.

image::images/formatter-profile-preview.png[New buttons: 'View/edit raw code' and 'Custom preview contents']

[[formatter-javadoc]]
[[formatter-align-javadoc-tags-in-columns]]
=== Formatter: align Javadoc tags in columns

The formatter can now *align names and/or descriptions* in Javadoc tags in new ways. The formatter profile editor is available for selection, under **Comments > Javadoc**.

image::images/formatter-javadoc-prefs.png[image]

For example, the *Align descriptions, grouped by type* setting is now used in the built-in Eclipse profile.

image::images/formatter-javadoc-preview.png[image]

The setting previously known as *Indent Javadoc tags* is now called **Align descriptions to tag width**. The two settings related to *@param tags* also had their labels changed to better describe what they do.

[[formatter-dark-theme]]
[[java-code-formatter-preferences-now-styled-for-the-dark-theme]]
=== Java code formatter preferences now styled for the dark theme

The formatter preferences tree styling has been fixed to work properly in the dark theme.

[[jdt-remove-redundant-modifiers-cleanup]]
[[new-cleanup-action-remove-redundant-modifiers]]
=== New Cleanup Action "Remove redundant modifiers"

The new cleanup action "Remove redundant modifiers" removes unnecessary modifiers on types, methods and fields. The following modifiers are removed:

* Interface field declarations: `public`, `static`, `final`
* Interface method declarations: `public`, `abstract`
* Nested interfaces: `static`
* Method declarations in final classes: `final`

The cleanup action can be configured as save action on the _Unnecessary Code_ page.

image::images/jdt_remove_redundant_modifiers.png[image]

[[Debug]]
[[debug]]
== Debug

[[prototype-java-launch-configuration]]
[[launch-configuration-prototypes-for-java-launch-configurations]]
=== Launch configuration prototypes for Java Launch Configurations

A Java Launch Configuration can now be based on a prototype.

image::images/prototype-java-launch-configuration.png[Prototype Java Launch Configuration]

A prototype seeds attributes in its associated Java Launch Configurations with the settings specified in the Prototype tab.

image::images/prototype-tab-java-launch-configuration-1.png[Prototype Tab Java Launch Configuration 1]

Once a Java Launch Configuration has been created, you can override any initial settings from the prototype. You can also reset the settings of a Java Launch Configuration with the ones from its prototype. A Java Launch Configuration maintains a link to its prototype, but is a complete stand-alone launch configuration that can be launched, exported, shared, etc.

image::images/prototype-tab-java-launch-configuration-2.png[Prototype Tab Java Launch Configuration 2]

[[advanced-source-lookup]]
[[advanced-source-lookup-implementation]]
=== Advanced source lookup implementation

More precise *advanced* source lookup implementation, particularly useful when debugging applications that load classes dynamically at runtime.

New `org.eclipse.jdt.launching.workspaceProjectDescribers` extension point can be used to enable advanced source lookup for projects with non-default layout, like PDE Plug-In projects.

New `org.eclipse.jdt.launching.sourceContainerResolvers` can be used to download sources jar files from remote artifact repositories, like Maven Central or Eclipse P2.

Advanced source lookup affects debug launches only and can be enabled or disabled with *Java > Debug > Enable advanced source lookup* preference option:

image::images/advanced-source-lookup.png[image]

[[worker-deobfuscated-jdt]]
[[debugger-listens-to-thread-name-changes]]
=== Debugger listens to thread name changes

*Debug view* now automatically updates thread names if they are changed in the debuggee JVM. This shows live information for worker instances, as described above.

Technically speaking, Java debugger automatically adds a new (user invisible) breakpoint in the JVM and notifies clients (like Debug view) on a breakpoint hit. If this behavior is undesired for some reason, product owners can disable it via product customization.

The property value is: `       org.eclipse.jdt.debug.ui/org.eclipse.jdt.debug.ui.javaDebug.ListenOnThreadNameChanges=false        `

[[method-result-and-exception-thrown]]
[[value-displayed-for-method-exit-and-exception-breakpoints]]
=== Value displayed for method exit and exception breakpoints

When a *method exit breakpoint* is hit, the value being returned is now shown in the variables view.

image::images/returningvalue.png[image]

Similarly, when an *exception breakpoint* is hit, the exception being thrown is shown.

image::images/throwingexception.png[image]

[[debug-shell]]
[[display-view-renamed-to-debug-shell]]
=== Display view renamed to Debug Shell

The *Display view* has been renamed to *Debug Shell* to better match the features and purpose of this view. Also, a java comment is shown in the Debug Shell on fresh open that explains when and how to use it.

image::images/debugShell.png[Debug Shell]

[[JDTDev]]
[[jdt-developers]]
== JDT Developers

[[dom-api-getbinding-change]]
[[package-binding-with-recovery]]
=== Package binding with recovery

The existing method `IBinding#getJavaElement()` now accommodates recovered packages in which case a `null` may be returned for such package bindings with problems. Pre-Java 9 compliant code will continue to have a non-null return value for this API for packages.

[[regex-module-declaration-search-api]]
[[support-for-regex-module-declaration-search]]
=== Support for Regex Module Declaration Search

The existing method `SearchPattern#createPattern(String , int , int , int )` is enhanced for supporting regular expression search for module declarations. Please note that the flag `SearchPattern#R_REGEXP_MATCH` used for regular expression search is applicable exclusively for module declarations. No other flag (for eg.`SearchPattern#R_CASE_SENSITIVE`) should be used in disjunction with this match rule.
