Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Java12/Examples

= NOTE: THE PAGE IS UNDER CONSTRUCTION

This is an informal page listing examples of features that are implemented by the Java 12 Support. You are welcome to try out these examples. If you find bugs, please file a bug after checking for a duplicate entry here


Feature / Steps Expected Result
The Pre-requisite: Java 12 JRE Support
Add Java 12 JRE Use Window -> Preferences-> Java -> Installed JREs -> Add...


FileAddJ12.png
[note: Eclipse -> Preferences in Mac / Window -> Preferences in Windows]

Java 12 JRE recognized as a valid JRE
Project JRE In Package Explorer Use project's context menu and add Java 12 JRE JRE specific (eg Object) gets resolved in the project.
Package Explorer Go to Package Explorer and expand the Java 12 JRE Modules (eg java.base etc) are listed in the package explorer view
The First Step: Java 12 Compliance
Set Project Compliance in Package Explorer Context Menu of Project -> Properties -> Set project-specific, drop down to 12



J12.compliance.png

12 is shown in the drop down list Select the checkbox to enable preview features.
No compiler errors
Basic Necessity : Compilation and Error Reporting
Positive Compilation Use the following code:
package j12.preview;
 
public class Test {
 
	enum Day {
		MON, TUE, WED, THUR, FRI, SAT, SUN
	};
 
	@SuppressWarnings("preview")
	public String getDay (Day today) {
		String day = switch(today) {
			case MON, TUE, WED, THUR, FRI -> "Weekday";
			case SAT, SUN -> "Weekend";
		};
		return day;
	}
}



Var.compile.jpg

Code compiles
Compiler Error Cases
 
Compiler errors are shown

Back to the top