SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
© 2013 IBM Corporation | Eclipse and Java 8
1
ECLIPSE AND JAVATM 8
Noopur Gupta
Eclipse JDT/UI Committer
IBM Software lab
noopur_gupta@in.ibm.com
© 2013 IBM Corporation | Eclipse and Java 8
2
© 2013 IBM Corporation | Eclipse and Java 8
3
© 2013 IBM Corporation | Eclipse and Java 8
4
Project Lambda
Functional Interfaces
Old content, new name!
Interfaces that define a single abstract method
(excluding Object methods), are now called as
Functional Interfaces.
Examples: Common callback interfaces like
Runnable and Comparator.
Optionally capture the design intent with the
@FunctionalInterface annotation.
© 2013 IBM Corporation | Eclipse and Java 8
5
Project Lambda
Functional Interfaces
© 2013 IBM Corporation | Eclipse and Java 8
6
Problem:
“Tiny” anonymous classes.
Used in callbacks, runnables, event handlers,
comparators etc.
All we need!
Project Lambda
Lambda Expressions
© 2013 IBM Corporation | Eclipse and Java 8
7
Solution:
Lambda Expression!
Project Lambda
Lambda Expressions
A lambda expression is used to implement a functional interface,
without creating a class or an anonymous class.
Reduced runtime overhead compared to anonymous classes!
VM and JRE optimizations in lambda meta factory.
Method invocation with invokedynamic bytecode instruction.
© 2013 IBM Corporation | Eclipse and Java 8
8
Project Lambda
Lambda Expressions
Syntax: (formal parameter list) -> { expression or statements }
Syntax variants:
Concise syntax
compared to
anonymous classes !
© 2013 IBM Corporation | Eclipse and Java 8
9
Project Lambda
Lambda Expressions
Target type of a lambda expression must be a functional interface.
Target type is inferred from the surrounding context.
Lambda parameters' types can be inferred.
A lambda is a method without a name and without an identity (no 'this').
Lambda Expressions do not define a new level of scope (just like for loops
and catch clauses).
© 2013 IBM Corporation | Eclipse and Java 8
10
Project Lambda
Lambda Expressions
Lambda Expressions can capture (reference) local variables of
enclosing contexts if the local variables are final or effectively final
(if its initial value is never changed).
Beneficial for memory management:
Inner class instances always hold a strong reference to their
enclosing instance can lead to memory leaks.
Lambda expressions that do not capture members from the
enclosing instance do not hold a reference to it !
© 2013 IBM Corporation | Eclipse and Java 8
11
Project Lambda
Method References
Problem:
A lambda expression that just invokes a named method – has to provide a
method body.
Solution:
A shorthand for lambda – method reference of the existing named method.
© 2013 IBM Corporation | Eclipse and Java 8
12
A method reference is used to refer to a method without invoking it.
A constructor reference is used to refer to a constructor without
creating a new instance of the named class or array type.
Project Lambda
Method References
Kinds of method references:
 A static method (ClassName::methName)
 An instance method of a particular object (instanceRef::methName)
 A super method of a particular object (super::methName)
 An instance method of an arbitrary object of a particular type (ClassName::methName)
Kinds of Constructor references:
 A class constructor reference (ClassName::new)
 An array constructor reference (TypeName[]::new)
© 2013 IBM Corporation | Eclipse and Java 8
13
Project Lambda
Method References
Example:
© 2013 IBM Corporation | Eclipse and Java 8
14
Project Lambda :
Interface Improvements
Default Methods
Problem:
Evolve interfaces without introducing incompatibility with
existing implementations.
 Standard Java libraries need new lambda-friendly methods.
Solution:
Default methods – means of painless API evolution.
© 2013 IBM Corporation | Eclipse and Java 8
15
Project Lambda :
Interface Improvements
Static Methods
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.
© 2013 IBM Corporation | Eclipse and Java 8
16
© 2013 IBM Corporation | Eclipse and Java 8
17
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!
Support improved analysis of Java programs.
Enabler for checker frameworks and static analysis tools
such as Sonar and FindBugs.
Declaration
Annotation
Type Use
Annotation
© 2013 IBM Corporation | Eclipse and Java 8
18
Type Annotations
@
Examples:
To declare a non-empty array of English-language strings:
Each non-static method has an implicit formal
parameter, this, which is called the receiver.
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.
© 2013 IBM Corporation | Eclipse and Java 8
19
Type Annotations
Use of a type name as a scoping mechanism is not a type use,
hence cannot be annotated.
Examples:
© 2013 IBM Corporation | Eclipse and Java 8
20
Set up Eclipse IDE (unreleased beta impl):
http://wiki.eclipse.org/JDT_Core/Java8#What_to_do_to_set
_up_the_IDE
Java 8 features:
http://openjdk.java.net/projects/jdk8/features
Lambda FAQ: http://www.lambdafaq.org
Trying Out Lambda Expressions in the
Eclipse IDE:
http://www.oracle.com/technetwork/articles/java/lambda-
1984522.html
Type Annotations Specification:
http://types.cs.washington.edu/jsr308/specification/java-
annotation-design.html
© 2013 IBM Corporation | Eclipse and Java 8
21

Más contenido relacionado

La actualidad más candente

java 8 new features
java 8 new features java 8 new features
java 8 new features Rohit Verma
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8Takipi
 
C++ question and answers
C++ question and answersC++ question and answers
C++ question and answersAdenKheire
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with XtendSven Efftinge
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noiseNeeraj Bhusare
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8Talha Ocakçı
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8LivePerson
 
Functional programming principles and Java 8
Functional programming principles and Java 8Functional programming principles and Java 8
Functional programming principles and Java 8Dragos Balan
 
C++ to java
C++ to javaC++ to java
C++ to javaAjmal Ak
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scalaStratio
 

La actualidad más candente (20)

Major Java 8 features
Major Java 8 featuresMajor Java 8 features
Major Java 8 features
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8The Dark Side Of Lambda Expressions in Java 8
The Dark Side Of Lambda Expressions in Java 8
 
C++ question and answers
C++ question and answersC++ question and answers
C++ question and answers
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with Xtend
 
Xtend - better java with -less- noise
Xtend - better java with -less- noiseXtend - better java with -less- noise
Xtend - better java with -less- noise
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
C progrmming
C progrmmingC progrmming
C progrmming
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
 
Java ce241
Java ce241Java ce241
Java ce241
 
The OCLforUML Profile
The OCLforUML ProfileThe OCLforUML Profile
The OCLforUML Profile
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Xtext Webinar
Xtext WebinarXtext Webinar
Xtext Webinar
 
Java 8 new features
Java 8 new featuresJava 8 new features
Java 8 new features
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Functional programming principles and Java 8
Functional programming principles and Java 8Functional programming principles and Java 8
Functional programming principles and Java 8
 
C++ to java
C++ to javaC++ to java
C++ to java
 
From Java to Kotlin
From Java to KotlinFrom Java to Kotlin
From Java to Kotlin
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
Cs30 New
Cs30 NewCs30 New
Cs30 New
 

Similar a Eclipse and Java 8 - Eclipse Day India 2013

Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhHarmeet Singh(Taara)
 
Week-1..................................
Week-1..................................Week-1..................................
Week-1..................................kmjanani05
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An OverviewIndrajit Das
 
Java 8 lambdas expressions
Java 8 lambdas expressionsJava 8 lambdas expressions
Java 8 lambdas expressionsLars Lemos
 
Lambda Expressions Java 8 Features usage
Lambda Expressions  Java 8 Features usageLambda Expressions  Java 8 Features usage
Lambda Expressions Java 8 Features usageAsmaShaikh478737
 
Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Simon Ritter
 
JDT embraces lambda expressions
JDT embraces lambda expressionsJDT embraces lambda expressions
JDT embraces lambda expressionsEclipse Day India
 
New c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_iiNew c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_iiNico Ludwig
 
LambdaExpressionInjavaforlearning fucntion
LambdaExpressionInjavaforlearning fucntionLambdaExpressionInjavaforlearning fucntion
LambdaExpressionInjavaforlearning fucntionShivamMishra465316
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsNewCircle Training
 
Java+8-New+Features.pdf
Java+8-New+Features.pdfJava+8-New+Features.pdf
Java+8-New+Features.pdfgurukanth4
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzJAX London
 
Lambda expressions java8 - yousry
Lambda expressions java8 - yousryLambda expressions java8 - yousry
Lambda expressions java8 - yousryyousry ibrahim
 

Similar a Eclipse and Java 8 - Eclipse Day India 2013 (20)

Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singh
 
Week-1..................................
Week-1..................................Week-1..................................
Week-1..................................
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Lambdas in Java 8
Lambdas in Java 8Lambdas in Java 8
Lambdas in Java 8
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
 
Java 8-revealed
Java 8-revealedJava 8-revealed
Java 8-revealed
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Java 8 lambdas expressions
Java 8 lambdas expressionsJava 8 lambdas expressions
Java 8 lambdas expressions
 
14274730 (1).ppt
14274730 (1).ppt14274730 (1).ppt
14274730 (1).ppt
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Lambda Expressions Java 8 Features usage
Lambda Expressions  Java 8 Features usageLambda Expressions  Java 8 Features usage
Lambda Expressions Java 8 Features usage
 
Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3
 
JDT embraces lambda expressions
JDT embraces lambda expressionsJDT embraces lambda expressions
JDT embraces lambda expressions
 
Towards Improving Interface Modularity in Legacy Java Software Through Automa...
Towards Improving Interface Modularity in Legacy Java Software Through Automa...Towards Improving Interface Modularity in Legacy Java Software Through Automa...
Towards Improving Interface Modularity in Legacy Java Software Through Automa...
 
New c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_iiNew c sharp3_features_(linq)_part_ii
New c sharp3_features_(linq)_part_ii
 
LambdaExpressionInjavaforlearning fucntion
LambdaExpressionInjavaforlearning fucntionLambdaExpressionInjavaforlearning fucntion
LambdaExpressionInjavaforlearning fucntion
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
 
Java+8-New+Features.pdf
Java+8-New+Features.pdfJava+8-New+Features.pdf
Java+8-New+Features.pdf
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian Goetz
 
Lambda expressions java8 - yousry
Lambda expressions java8 - yousryLambda expressions java8 - yousry
Lambda expressions java8 - yousry
 

Más de Noopur Gupta

Mastering your Eclipse IDE - Java tooling, Tips & Tricks!
Mastering your Eclipse IDE - Java tooling, Tips & Tricks!Mastering your Eclipse IDE - Java tooling, Tips & Tricks!
Mastering your Eclipse IDE - Java tooling, Tips & Tricks!Noopur Gupta
 
Java 14 support in Eclipse IDE
Java 14 support in Eclipse IDEJava 14 support in Eclipse IDE
Java 14 support in Eclipse IDENoopur Gupta
 
Unleashing the Java Tooling in Eclipse IDE - Tips & Tricks!
Unleashing the Java Tooling in Eclipse IDE - Tips & Tricks!Unleashing the Java Tooling in Eclipse IDE - Tips & Tricks!
Unleashing the Java Tooling in Eclipse IDE - Tips & Tricks!Noopur Gupta
 
Mastering your Eclipse IDE - Java tooling, Tips & Tricks - EclipseCon Europe ...
Mastering your Eclipse IDE - Java tooling, Tips & Tricks - EclipseCon Europe ...Mastering your Eclipse IDE - Java tooling, Tips & Tricks - EclipseCon Europe ...
Mastering your Eclipse IDE - Java tooling, Tips & Tricks - EclipseCon Europe ...Noopur Gupta
 
Mastering your Eclipse IDE - Tips, Tricks, Java 8 tooling & More!
Mastering your Eclipse IDE - Tips, Tricks, Java 8 tooling & More!Mastering your Eclipse IDE - Tips, Tricks, Java 8 tooling & More!
Mastering your Eclipse IDE - Tips, Tricks, Java 8 tooling & More!Noopur Gupta
 
What's cool in Eclipse goody bag!
What's cool in Eclipse goody bag!What's cool in Eclipse goody bag!
What's cool in Eclipse goody bag!Noopur Gupta
 
High productivity development with Eclipse and Java 8
High productivity development with Eclipse and Java 8High productivity development with Eclipse and Java 8
High productivity development with Eclipse and Java 8Noopur Gupta
 

Más de Noopur Gupta (7)

Mastering your Eclipse IDE - Java tooling, Tips & Tricks!
Mastering your Eclipse IDE - Java tooling, Tips & Tricks!Mastering your Eclipse IDE - Java tooling, Tips & Tricks!
Mastering your Eclipse IDE - Java tooling, Tips & Tricks!
 
Java 14 support in Eclipse IDE
Java 14 support in Eclipse IDEJava 14 support in Eclipse IDE
Java 14 support in Eclipse IDE
 
Unleashing the Java Tooling in Eclipse IDE - Tips & Tricks!
Unleashing the Java Tooling in Eclipse IDE - Tips & Tricks!Unleashing the Java Tooling in Eclipse IDE - Tips & Tricks!
Unleashing the Java Tooling in Eclipse IDE - Tips & Tricks!
 
Mastering your Eclipse IDE - Java tooling, Tips & Tricks - EclipseCon Europe ...
Mastering your Eclipse IDE - Java tooling, Tips & Tricks - EclipseCon Europe ...Mastering your Eclipse IDE - Java tooling, Tips & Tricks - EclipseCon Europe ...
Mastering your Eclipse IDE - Java tooling, Tips & Tricks - EclipseCon Europe ...
 
Mastering your Eclipse IDE - Tips, Tricks, Java 8 tooling & More!
Mastering your Eclipse IDE - Tips, Tricks, Java 8 tooling & More!Mastering your Eclipse IDE - Tips, Tricks, Java 8 tooling & More!
Mastering your Eclipse IDE - Tips, Tricks, Java 8 tooling & More!
 
What's cool in Eclipse goody bag!
What's cool in Eclipse goody bag!What's cool in Eclipse goody bag!
What's cool in Eclipse goody bag!
 
High productivity development with Eclipse and Java 8
High productivity development with Eclipse and Java 8High productivity development with Eclipse and Java 8
High productivity development with Eclipse and Java 8
 

Último

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 

Último (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Eclipse and Java 8 - Eclipse Day India 2013

  • 1. © 2013 IBM Corporation | Eclipse and Java 8 1 ECLIPSE AND JAVATM 8 Noopur Gupta Eclipse JDT/UI Committer IBM Software lab noopur_gupta@in.ibm.com
  • 2. © 2013 IBM Corporation | Eclipse and Java 8 2
  • 3. © 2013 IBM Corporation | Eclipse and Java 8 3
  • 4. © 2013 IBM Corporation | Eclipse and Java 8 4 Project Lambda Functional Interfaces Old content, new name! Interfaces that define a single abstract method (excluding Object methods), are now called as Functional Interfaces. Examples: Common callback interfaces like Runnable and Comparator. Optionally capture the design intent with the @FunctionalInterface annotation.
  • 5. © 2013 IBM Corporation | Eclipse and Java 8 5 Project Lambda Functional Interfaces
  • 6. © 2013 IBM Corporation | Eclipse and Java 8 6 Problem: “Tiny” anonymous classes. Used in callbacks, runnables, event handlers, comparators etc. All we need! Project Lambda Lambda Expressions
  • 7. © 2013 IBM Corporation | Eclipse and Java 8 7 Solution: Lambda Expression! Project Lambda Lambda Expressions A lambda expression is used to implement a functional interface, without creating a class or an anonymous class. Reduced runtime overhead compared to anonymous classes! VM and JRE optimizations in lambda meta factory. Method invocation with invokedynamic bytecode instruction.
  • 8. © 2013 IBM Corporation | Eclipse and Java 8 8 Project Lambda Lambda Expressions Syntax: (formal parameter list) -> { expression or statements } Syntax variants: Concise syntax compared to anonymous classes !
  • 9. © 2013 IBM Corporation | Eclipse and Java 8 9 Project Lambda Lambda Expressions Target type of a lambda expression must be a functional interface. Target type is inferred from the surrounding context. Lambda parameters' types can be inferred. A lambda is a method without a name and without an identity (no 'this'). Lambda Expressions do not define a new level of scope (just like for loops and catch clauses).
  • 10. © 2013 IBM Corporation | Eclipse and Java 8 10 Project Lambda Lambda Expressions Lambda Expressions can capture (reference) local variables of enclosing contexts if the local variables are final or effectively final (if its initial value is never changed). Beneficial for memory management: Inner class instances always hold a strong reference to their enclosing instance can lead to memory leaks. Lambda expressions that do not capture members from the enclosing instance do not hold a reference to it !
  • 11. © 2013 IBM Corporation | Eclipse and Java 8 11 Project Lambda Method References Problem: A lambda expression that just invokes a named method – has to provide a method body. Solution: A shorthand for lambda – method reference of the existing named method.
  • 12. © 2013 IBM Corporation | Eclipse and Java 8 12 A method reference is used to refer to a method without invoking it. A constructor reference is used to refer to a constructor without creating a new instance of the named class or array type. Project Lambda Method References Kinds of method references:  A static method (ClassName::methName)  An instance method of a particular object (instanceRef::methName)  A super method of a particular object (super::methName)  An instance method of an arbitrary object of a particular type (ClassName::methName) Kinds of Constructor references:  A class constructor reference (ClassName::new)  An array constructor reference (TypeName[]::new)
  • 13. © 2013 IBM Corporation | Eclipse and Java 8 13 Project Lambda Method References Example:
  • 14. © 2013 IBM Corporation | Eclipse and Java 8 14 Project Lambda : Interface Improvements Default Methods Problem: Evolve interfaces without introducing incompatibility with existing implementations.  Standard Java libraries need new lambda-friendly methods. Solution: Default methods – means of painless API evolution.
  • 15. © 2013 IBM Corporation | Eclipse and Java 8 15 Project Lambda : Interface Improvements Static Methods 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.
  • 16. © 2013 IBM Corporation | Eclipse and Java 8 16
  • 17. © 2013 IBM Corporation | Eclipse and Java 8 17 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! Support improved analysis of Java programs. Enabler for checker frameworks and static analysis tools such as Sonar and FindBugs. Declaration Annotation Type Use Annotation
  • 18. © 2013 IBM Corporation | Eclipse and Java 8 18 Type Annotations @ Examples: To declare a non-empty array of English-language strings: Each non-static method has an implicit formal parameter, this, which is called the receiver. 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.
  • 19. © 2013 IBM Corporation | Eclipse and Java 8 19 Type Annotations Use of a type name as a scoping mechanism is not a type use, hence cannot be annotated. Examples:
  • 20. © 2013 IBM Corporation | Eclipse and Java 8 20 Set up Eclipse IDE (unreleased beta impl): http://wiki.eclipse.org/JDT_Core/Java8#What_to_do_to_set _up_the_IDE Java 8 features: http://openjdk.java.net/projects/jdk8/features Lambda FAQ: http://www.lambdafaq.org Trying Out Lambda Expressions in the Eclipse IDE: http://www.oracle.com/technetwork/articles/java/lambda- 1984522.html Type Annotations Specification: http://types.cs.washington.edu/jsr308/specification/java- annotation-design.html
  • 21. © 2013 IBM Corporation | Eclipse and Java 8 21