eclipse and java 8 - ghc 2013 poster

1
Join the Eclipse open source community and its large ecosystem of projects: http://www.eclipse.org/ - Forums: http://www.eclipse.org/forums - Bugzilla: http://bugs.eclipse.org/bugs/ - Contributing to JDT/UI: http://wiki.eclipse.org/JDT_UI/How_to_Contribute Noopur Gupta ([email protected] ) Eclipse JDT/UI Committer IBM Software Lab, Bangalore Project Lambda - Problem: A lambda expression that just invokes a named method. - Solution: Further simplify the implementation of functional interface by using a shorthand for lambda method reference of the existing named method. - Interfaces that define a single abstract method. - Optionally capture the design intent with @FunctionalInterface annotation. - Example: Common callback interfaces like Runnable and Comparator. Functional Interfaces Method References - A lambda expression is used to implement a functional interface, without creating a class or an anonymous class. - Problem: “Tiny anonymous classes” used in callbacks, runnables, event handlers, comparators etc. - Solution: Reduced runtime overhead compared to anonymous classes! - Syntax: Concise syntax compared to anonymous classes! All we need! Lambda Expression! (formal parameter list) { expression or statements } Lambda Expressions - Problem: Evolve interfaces without introducing incompatibility with existing implementations. Standard Java libraries need new lambda-friendly methods. - Solution: Default methods means of API evolution - Problem: A common scenario Java libraries having companion utility classes with static methods. - Solution: Static methods allow helper methods specific to an interface to live with the interface. Default Methods Static Methods Type Annotations - Before Java 8: Annotations could only be applied to declarations. - As of Java 8: Annotations can also be applied anywhere you use a type! Supports improved analysis of Java programs. Enables checker frameworks and static analysis tools such as Sonar and FindBugs. - In Java 8, it is permitted to explicitly declare the method receiver as the first formal parameter. The only purpose of writing the receiver explicitly is to make it possible to annotate the receiver’s type. Declaration Annotation Type Use Annotation Project Lambda Interface Improvements Eclipse is a free and open source development platform comprising of extensible frameworks, tools and runtimes. The Eclipse Java development tools (JDT) project contributes an extensible full-featured Java IDE to the Eclipse platform. It is considered by many to be the best Java development tool available. The next iteration of the Java language i.e. Java 8 is currently scheduled for general availability in March 2014. JDT will provide a feature patch for Eclipse Kepler SR2 (4.3.2) and ship Java 8 support with the next Eclipse release i.e. Eclipse Luna (4.4).

Upload: noopur-gupta

Post on 21-Jul-2016

23 views

Category:

Documents


5 download

DESCRIPTION

Poster presented on "Eclipse and Java 8" at the Grace Hopper Celebration of Women in Computing India (Bangalore) 2013 (a program of the Anita Borg Institute, co-presented with the Association for Computing Machinery).

TRANSCRIPT

Join the Eclipse open source community and its large ecosystem of projects:http://www.eclipse.org/

- Forums: http://www.eclipse.org/forums- Bugzilla: http://bugs.eclipse.org/bugs/- Contributing to JDT/UI: http://wiki.eclipse.org/JDT_UI/How_to_Contribute

Noopur Gupta ([email protected])Eclipse JDT/UI CommitterIBM Software Lab, Bangalore

Project Lambda

- Problem: A lambda expression that just invokes a named method.

- Solution: Further simplify the implementation of functional interface by usinga shorthand for lambda – method reference of the existing named method.

- Interfaces that define a single abstract method.- Optionally capture the design intent with @FunctionalInterface annotation.- Example: Common callback interfaces like Runnable and Comparator.

Functional Interfaces

Method References

- A lambda expression is used to implement a functional interface, withoutcreating a class or an anonymous class.

- Problem: “Tiny anonymous classes” used in callbacks, runnables, eventhandlers, comparators etc.

- Solution:

Reduced runtime overhead compared to anonymous classes!

- Syntax:

Concise syntax compared to anonymous classes!

All we need!

Lambda Expression!

(formal parameter list) { expression or statements }

Lambda Expressions

- Problem: Evolve interfaces without introducing incompatibility withexisting implementations. Standard Java libraries need new lambda-friendly methods.

- Solution: Default methods – means of API evolution

- Problem: A common scenario – Java libraries having companion utilityclasses with static methods.- Solution: Static methods – allow helper methods specific to an interface tolive with the interface.

Default Methods

Static Methods

Type Annotations

- Before Java 8: Annotations could only be applied to declarations.

- As of Java 8: Annotations can also be applied anywhere you use a type!

Supports improved analysis of Java programs.Enables checker frameworks and static analysis tools such as Sonar and

FindBugs.

- In Java 8, it is permitted to explicitly declare the method receiver as thefirst formal parameter. The only purpose of writing the receiver explicitly isto make it possible to annotate the receiver’s type.

Declaration Annotation

Type Use Annotation

Project Lambda – Interface ImprovementsEclipse is a free and open source development platform comprising ofextensible frameworks, tools and runtimes.

The Eclipse Java development tools (JDT) project contributes an extensiblefull-featured Java IDE to the Eclipse platform. It is considered by many to bethe best Java development tool available.

The next iteration of the Java language i.e. Java 8 is currently scheduled forgeneral availability in March 2014.

JDT will provide a feature patch for Eclipse Kepler SR2 (4.3.2) and ship Java 8support with the next Eclipse release i.e. Eclipse Luna (4.4).