Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Java 8 : What's new??

No description
by

Anand Pandey

on 6 April 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Java 8 : What's new??

Change is good
, when it comes with benefits
!!!

Stream is an
abstraction
that represent one or more values
Spec
says...
"Add functionality to the Java Collections Framework for bulk operations upon data. This is commonly referenced as “filter/map/
reduce for Java.” The bulk data operations include both serial (on the calling thread) and parallel (using many threads) versions of the
operations. Operations upon data are generally expressed as lambda functions."
"
PermGen
" removed
Date-Time
API
Similar to
Joda time
library
Pipelines
Bulk Data Operations
??
Stream
API
Sum
mary

Default
Methods
"
Default methods can be taught as bridge between Lambdas and JDK libraries.
"

... says Anton Arhipov
(Product Lead, JRebel)
Also known as...
VEM
(Virtual Extension Methods)
Why
default methods?
Preserve
backward compatibility
What
are default methods?
Use '
default
' keyword
Lambda

Lambda expressions are anonymous methods that
provide developers with a simple and compact means for representing behavior as data
,”

... explains Brian Goetz
(Language Architect, Java)
Why Lambda
expressions?
What Lambda do?
Syntax
:
(parameters) -> expressions;
(parameters) -> {statements; }
Functional Interfaces
Runtime representation
of a lambda
Capturing lambdas
What lambdas don't do?
Non-final
variable capture
Others
??
Powered By
Java 8 :
What's new??
Anand
Pandey

April 10, 2014
Tech Quench
Howdy!
My name's Anand

Where We're
Headed
??

A picture is worth a
thousand
words...

About me
:
Developer, Java
Domain, Advertising & Telecom
Java, Enthusiast
IntelliJ Idea, Addict

If a lambda expression accesses a non-static variable or an object that is
defined outside of lambda body, then it is a
capturing lambda
Multi-core
Hardware
A pipeline consist of:
- a stream
source
- zero or more
intermediate
operations
- a
terminal
operation
- a pipeline can be executed in
parallel
JVM
Thank
You

Here are the areas that we have covered from Java 8:
1.
Lambda
expressions
2. Default methods
3. Bulk data operations for Java collections
4. Date-Time API
5. Others

Modularity
& Others
Catch the future features of Java @
https://
home.java.net
/
Re
sources
https://
home.java
.net
/

http://
docs.oracle
.com/javase/tutorial/java/javaOO/lambdaexpressions.html

http://
www.
techempower
.com/blog/2013/03/26/everything-about-java-8/

http://
www.
youtube
.com/channel/UCmRtPmgnQ04CMUpSUqPfhxQ

http://
typesafe
.com

http://
zeroturnaround
.com/rebellab
Others
Nashorn Javascript Engine <-
Rhino
Questions
??
4
components of a Method
NO Name
Return Type
Parameters
Body
List of exceptions
Simplicity
Parallelism
SAM (single abstract method)
type
Number of interfaces, like
Runnable
and
Comparator
, that match the criteria
NOT
enough for API evolution!
New package in JDK8
,

java.util.function
Include over
40 new functional interfaces
intended to be used by new API

Here's just a few interesting interfaces defined in the above mentioned
package of the JDK library:

Consumer<T>
- performs an action on type T without returning a result.
Supplier<T>
- returns an instance of type T, no input required.
Predicate<T>
- consumes an instance of type T as a parameter and
produces boolean value.
Function<T,R>
- takes instance of type T as a parameter and produces
an instance of type R as a result.
@FunctionalInterface

annotation
For example, this lambda captures the variable x:
int x = 5;
return y -> x + y;
In order for this lambda declaration to be valid, the variables it captures must be "
effectively final
".
Capturing lambdas
need to be evaluated every time
they're
encountered, much like instantiating a new instance of an
anonymous class.
Exception
transparency
Control flow
(break, early return)
Defender Methods
Obvious
use case
for that is to apply a lambda to every element of a collection.
Providing a
default implementation
of the declared behavior
Implement body for the methods declarations in interface
What has this got to do with Lambda?
- Lambdas tell this operations
what to do
?
"A stream is an
iterator
on steroids"
... says Stuart Marks
"
java.time
" package
Almost
everything
in the API is
immutable
Intermingling
with the legacy date/time API is
minimal

Prefers enums
over integer constants
The
majority of changes
are in JDK (library code, written in Java) and in the surrounding code (e.g. javac)
Semantic changes
are mostly around default methods in interfaces, and type annotations (
both drive class file change
)
Reflection and
annotations changes
JDBC
4.2
Implicit
Explicit
Future
??
JSR 335
- Lambda expressions
JSR 310
- Date and Time API
JSR 308
- Annotation on Types
New functionality -
Updated functionality -
JSR 199
- Java Compiler API
JSR 221
- JDBC 4.0
...
Project
Kenai

Project
JigSaw

Concurrency
API additions
IO/NIO
API additions
Introduce
- Multiple inheritance of behaviour
Helps eliminate
verbosity
To use a lambda expression, you need to implement a functional interface
Full transcript