Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Java11/Examples

Revision as of 05:24, 5 June 2018 by Unnamed Poltroon (Talk) (Created page with "=== PAGE UNDER CONSTRUCTION ========== This is an informal page listing examples of features that are implemented by the Java 11 Support. You are welcome to try out these exa...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

PAGE UNDER CONSTRUCTION =======

This is an informal page listing examples of features that are implemented by the Java 11 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 11 JRE Support
Add Java 11 JRE Use Window -> Preferences-> Java -> Installed JREs -> Add...


FileAddJ11.jpg
[note: Eclipse -> Preferences in Mac / Window -> Preferences in Windows]

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



J11.compliance.jpg

(NOT YET IMPLEMENTED) No compiler errors
Basic Necessity : Compilation and Error Reporting
Positive Compilation Use the following code:
package pack1;
public class VarLambda {
 
	public static void main(String[] args) {
  		I lam = (var  x) -> { // var compiles here
  			System.out.println(x);
  		};
  		lam.apply(20);
	} 
}
 
interface I {
	public void apply(Integer k);
}



Var11.compile.jpg

Code compiles
Compiler Error Case 1
package pack1;
public class VarLambdaErr {
 
	public static void main(String[] args) {
  		I lam = (var  x, z) -> { // should not mix with type-elided params
  			System.out.println(x);
  		};
  		lam.apply(20);
	} 
}
 
interface I {
	public void apply(Integer k, Integer z);
}
Compiler errors are shown
Compiler Error Case 2
package pack1;
public class VarLambdaErr {
 
	public static void main(String[] args) {
  		I lam = (var  x, Integer z) -> { // should not mix with non-var params
  			System.out.println(x);
  		};
  		lam.apply(20, 200);
	} 
}
 
interface I {
	public void apply(Integer k, Integer z);
}
Compiler errors are shown
Essential Utilities: Code Completion, Hover and Quick Fix.
Basic context based var completion



TODO
More to come in Java 11 !

Back to the top