|
|
Line 35: |
Line 35: |
| |12 is shown in the drop down list. | | |12 is shown in the drop down list. |
| A checkbox to enable preview features is available on the preference page. | | A checkbox to enable preview features is available on the preference page. |
− | |-
| |
− | | No compiler errors
| |
| |- | | |- |
| ! colspan="3" | Basic Necessity : Compilation and Error Reporting | | ! colspan="3" | Basic Necessity : Compilation and Error Reporting |
Line 67: |
Line 65: |
| | Code compiles | | | Code compiles |
| |- | | |- |
− | ! scope="row" | Compiler Warning Cases | + | ! scope="row" | Compiler Warning Case |
| | | | | |
| <source lang="java"> | | <source lang="java"> |
Line 92: |
Line 90: |
| | Compiler warning is shown for preview feature | | | Compiler warning is shown for preview feature |
| |- | | |- |
− | ! scope="row" | Compiler Error Cases | + | ! scope="row" | Compiler Error Case |
| | | | | |
| <source lang="java"> | | <source lang="java"> |
Line 113: |
Line 111: |
| } | | } |
| </source> | | </source> |
− | <br>
| |
− | <br>
| |
| [[File:switch.cover-all-cases.error.png]] | | [[File:switch.cover-all-cases.error.png]] |
| | Compiler error is shown | | | Compiler error is shown |
| |- | | |- |
Revision as of 06:53, 18 March 2019
= 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...
[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
|
12 is shown in the drop down list.
A checkbox to enable preview features is available on the preference page.
|
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_1 (Day today) {
String day = switch(today) {
case MON, TUE, WED, THUR, FRI -> "Weekday";
case SAT, SUN -> "Weekend";
};
return day;
}
}
|
Code compiles
|
Compiler Warning Case
|
package j12.preview;
public class Test {
enum Day {
MON, TUE, WED, THUR, FRI, SAT, SUN
};
public String getDay_1 (Day today) {
String day = switch(today) {
case MON, TUE, WED, THUR, FRI: break "Weekday";
case SAT, SUN: break "Weekend";
};
return day;
}
}
|
Compiler warning is shown for preview feature
|
Compiler Error Case
|
package j12.preview;
public class Test {
enum Day {
MON, TUE, WED, THUR, FRI, SAT, SUN
};
@SuppressWarnings("preview")
public String getDay_1 (Day today) {
String day = switch(today) {
case MON : break "Weekday";
case SAT, SUN : break "Weekend";
};
return day;
}
}
|
Compiler error is shown
|