Java 11 and Beyond MAKING ECLIPSE JDT FUTURE READY MANOJ PALAT IBM - - PowerPoint PPT Presentation

java 11 and beyond
SMART_READER_LITE
LIVE PREVIEW

Java 11 and Beyond MAKING ECLIPSE JDT FUTURE READY MANOJ PALAT IBM - - PowerPoint PPT Presentation

Java 11 and Beyond MAKING ECLIPSE JDT FUTURE READY MANOJ PALAT IBM @manojnp manojnp Java Releases Road Traveled++ Eclipse Releasing Every Quarter now Version Release Date 1996 1.0 1997, 1998, 2000, 2002, 2004,2006


slide-1
SLIDE 1

Java 11 and Beyond

MAKING ECLIPSE JDT FUTURE–READY MANOJ PALAT – IBM @manojnp manojnp

slide-2
SLIDE 2

Java Releases – Road Traveled++

Version

 1.0  1.1,1.2,1.3,1.4,1.5,1.6  1.7  1.8  9  10  11  12  13…

Release Date

 1996  1997, 1998, 2000, 2002, 2004,2006  2011 (String Switch, t-w-r, dyn-support)  2014 (Lambda, Null)  Sep 2017 (Modules,  Mar 2018  Sep 2018  Mar 2019  Sep 2019…

Eclipse Releasing Every Quarter now

slide-3
SLIDE 3

Eclipse/JDT

ECLIPSE JAVA COMPILER JAVA MODEL

  • Workspace
  • Projects
  • CU, Type, Methods
  • Lightweight - views

Batch Compiler JAVA SEARCH

  • Declarations
  • References
  • Hierarchy
  • Java Constructs

DOM AST

  • Compilation Unit
  • Fine grained
  • Statements,

identifiers

  • Fully resolved

JAVA DEVELOPMENT TOOLS (JDT) UI

slide-4
SLIDE 4

(DEMO) Agenda

 Past

 Java 7 & 8 (LE, indy)  Java 9 (Modules)

 Present

 Java 10 (Local Variable Type

Inference)

 Java 11 (var in LE, condy, Nesting)

 Future

 Java 12 ( Raw String, Switch

Expressions)

 And Beyond…

slide-5
SLIDE 5

Relevant Historical Features -1.7, 1.8, 9

 Java.lang.invoke.MethodHandle, MethodType (1.7)  CONSTANT_MethodHandle_info, CONSTANT_MethodType_info(1.7)  invokedynamic (1.7)  Lambda Expressions (1.8)  _(Underscore) valid identifier (1.7) warning (1.8) Invalid identifier(9)  Modules (9)  t-w-r with effectively final variables(9)

slide-6
SLIDE 6

Current Features -10, 11

 Local variable type inference (10)  var as lambda parameter (11)  Constant_Dynamic, ldc enablement.  Nesting  --enable-preview

slide-7
SLIDE 7

Local Variable Type Inference-10, 11

 Avoid boilerplate code, less ceremony  Var allowed in

 variable declaration with initializers, 

index variable for loop

 enhanced-for loop 

lambda expression parameter (11)

 Null init or no init disallowed  Var not a keyword  Var is a reserved type

 var var = 10; allowed

slide-8
SLIDE 8

Constant_Dynamic (11)

 Reduce the cost and disruption of creating new constants  Allows flexibility  Essentially provide a new constant pool with user specs  Using the existing bootstrap mechanism of LE to this end  Not utilized by Java as of 11 (initial use expected by 12)

slide-9
SLIDE 9

Nest (11)

 JLS allows unrestricted access within a top level type  private access between nestmates is not permitted by the JVM

access rules – compiled into different classes

 Enter bridge method with package private promotion  Nestmates – Nest Host, Nest Member(s)

slide-10
SLIDE 10

Preview Feature

 Language/vm feature  Fully specified  Fully implemented  Not experimental  Impermanent  To invoke feedback  May become permanent  Unavailable by default at compile time and run-time  --enable-preview

slide-11
SLIDE 11

Raw String Literals (12) - preview

 span multiple lines of source code and does not interpret

escape sequences, such as \n, or Unicode escapes, of the form \uXXXX.

 Runtime.getRuntime().exec("\"C:\\Program Files\\foo\" bar");  Runtime.getRuntime().exec(`"C:\Program Files\foo" bar`);  System.out.println("this".matches("\\w\\w\\w\\w"))  System.out.println("this".matches(`\w\w\w\w`))

slide-12
SLIDE 12

Raw String Literal Examples (12)

 `"` // a string containing " alone  ``can`t`` // a string containing 'c', 'a', 'n', '`' and 't'  `This is a string` // a string containing 16 characters  `\n` // a string containing '\' and 'n'  `\u2022` // a string containing '\', 'u', '2', '0', '2' and '2'  `This is a  two-line string` // a single string constant

slide-13
SLIDE 13

Switch Expressions (12) - preview

 Issues/Irritants:  Default control flow : Fall through  Default scoping (Single scope) – one monolithic  Finally, a statement  Extend the switch statement so that it can be used as either a

statement or an expression, and that both forms can use either a "traditional" or "simplified" scoping and control flow behavior.

slide-14
SLIDE 14

Switch Expressions (325)

switch (day) {

case MONDAY: case FRIDAY: case SUNDAY: System.out.println(6); break; case TUESDAY: System.out.println(7); break; case THURSDAY: case SATURDAY: System.out.println(8); break; case WEDNESDAY: System.out.println( 9); break; }

switch (day) { case MONDAY, FRIDAY, SUNDAY -> System.out.println(6); case TUESDAY -> System.out.println(7); case THURSDAY, SATURDAY -> System.out.println(8); case WEDNESDAY -> System.out.println(9); }

switch (day) { case MONDAY -> System.out.println(6); case FRIDAY

  • > System.out.println(6);

case SUNDAY -> System.out.println(6); case TUESDAY -> System.out.println(7); case THURSDAY -> System.out.println(8); case SATURDAY -> System.out.println(8); case WEDNESDAY -> System.out.println(9); }

slide-15
SLIDE 15

Switch Expressions (325)

int numLetters;

switch (day) {

case MONDAY:

case FRIDAY:

case SUNDAY:

numLetters = 6;

break;

case TUESDAY:

numLetters = 7;

break;

case THURSDAY:

case SATURDAY:

numLetters = 8;

break;

case WEDNESDAY:

numLetters = 9;

break;

default:

numLetters = 100;

}

int numLetters = switch (day) {

case MONDAY, FRIDAY, SUNDAY -> 6;

case TUESDAY -> 7;

case THURSDAY, SATURDAY -> 8;

case WEDNESDAY -> 9;

};

int numLetters = switch (day) { case MONDAY, FRIDAY, SUNDAY -> break 6; case TUESDAY -> break 7; case THURSDAY, SATURDAY -> { int k = day.toString().length(); int result = f(k); break result; }; case WEDNESDAY -> throw IllegalStateException(“W”); };

slide-16
SLIDE 16

References

 Java 12 Page (Official):

 http://openjdk.java.net/projects/jdk/12/

 Eclipse JDT Java Plan / Wiki (Mapping, Entry Points and info)

 https://wiki.eclipse.org/JDT_Core/Plan/Java

 Top Level Java 12 Support bug Eclipse JDT

 https://bugs.eclipse.org/bugs/show_bug.cgi?id=536055

 BETA_Java_12 branch  JEP 325 : http://openjdk.java.net/jeps/325  JEP 326 : http://openjdk.java.net/jeps/326

slide-17
SLIDE 17

Pattern Matching (13+..)

if (x instanceof Integer) { int intValue = ((Integer) obj).intValue(); // use intValue }

Switch Expressions

 Dynamic Constant

if (x matches Integer i) { // can use i here }

test (x is an integer)

 Conversion (cast)  Destructuring (extract)  A pattern is a combination of a predicate that can be applied to a

target, along with a set of binding variables that are extracted from the target if the predicate applies to it

slide-18
SLIDE 18

Thank You

@man manojnp

  • jnp

https://in.linkedin.com/in/manojnp