Java development tools
- Java™ 10 Support
- Java™ 9 Support
- JUnit
- Java Editor
- Java Views and Dialogs
- Java Compiler
- Java Formatter
- Debug
- JDT Developers
Java™ 10 Support |
|||||
Eclipse support for Java™ 10 |
Java™ 10 is here, and JDT supports it completely.
|
||||
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.
|
||||
Java™ 9 Support |
|||||
Eclipse support for Java™ 9 |
Java™ 9 is here, and JDT supports it completely:
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.
|
||||
New --release on the Java compiler preference page |
A new option This option will be enabled only if the JRE being used is a Java 9 or above. Workspace Preference: Project Preference: 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. 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 |
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. |
||||
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 for module declaration name |
Content assist (Ctrl+Space) support is now available for module declaration name.
|
||||
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. Before the quick fix is applied the classpath entries look as below: After the quick fix is applied the classpath entries look as below: |
||||
Quick fix for Non-existing or empty package on exports directive |
A new quick fix is available when you have a This quick fix is applicable if the project is a Java9 project or above and has a The quick fix can be invoked from the editor: 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. |
||||
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: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 Selecting Don't Create in the above dialog does not create the |
||||
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:
|
||||
JUnit |
|||||
Eclipse support for JUnit 5.1 |
JUnit 5.1 is here and Eclipse supports it.
Note:
|
||||
Java Editor |
|||||
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 Otherwise, the quick fix must be invoked from the problems view, and will create a When invoked from the problems view, both variations of the quick fix can fix the problem for multiple packages simultaneously. |
||||
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.
|
||||
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:
|
||||
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.
|
||||
Improved coloring of links in code element information in the dark theme |
The colors of links in code element information control now takes the color settings of the Hyperlink text color and the Active hyperlink text color from the Colors & Fonts preference page into account.
The readability in the dark theme has been improved a lot by this.
Before: After: |
||||
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: After: |
||||
Java Views and Dialogs |
|||||
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.
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: 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. Build path entries configured like this have a decoration 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. As a consequence, if the project is a modular Java 9 project, test dependencies like JUnit can not be referenced in
the Of course, code completion will not suggest test code in main sources: 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: 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: There are also dedicated filters to quickly remove hits in main code or test code from Java search results: Similar, there is a filter to remove test code from Call hierarchies: Another filter to remove test code exists for Quick type hierarchies: Test source folders will be preselected in the New JUnit Test Case-Wizard 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: 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 Override Dependencies button. |
||||
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:
The default for this preference is OFF. |
||||
Generate dialogs use verbs instead of OK | The Generate... dialogs of the Java tools have been adapted to use verbs instead of OK. | ||||
Java Compiler |
|||||
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 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:
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
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 |
||||
@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 either with target |
||||
@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 :
org.eclipse.jdt.annotation
contains an annotation type NonNullByDefault that can be applied to parameter and
module declarations (in addition to the previously allowed targets).
|
||||
Test sources |
There is now support for running Java annotation processors on 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.
|
||||
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: |
||||
Java Formatter |
|||||
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.
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). Most sections have a Modify all button in their header that lets you set all their preferences to the same value with one click. 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. 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. |
||||
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.
For example, the Align descriptions, grouped by type setting is now used in the built-in Eclipse profile. 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. |
||||
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. | ||||
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:
|
||||
Debug |
|||||
Launch configuration prototypes for Java Launch Configurations |
A Java Launch Configuration can now be based on a prototype.
|
||||
Advanced source lookup implementation |
More precise advanced source lookup implementation, particularly useful when debugging applications that load classes dynamically at runtime.
New
New Advanced source lookup affects debug launches only and can be enabled or disabled with Java > Debug > Use advanced source lookup (JRE 1.5 and higher) preference option: |
||||
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:
|
||||
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.
Similarly, when an exception breakpoint is hit, the exception being thrown is shown.
|
||||
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.
|
||||
JDT Developers |
|||||
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.
|
||||
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.
|