SlideShare ist ein Scribd-Unternehmen logo
1 von 66
Downloaden Sie, um offline zu lesen
DEV-1550: Why Java 8?
Or, What's a Lambda?
Julian Robichaux, panagenda
Who am I?
• Julian Robichaux
– Programmer and product manager at panagenda
– Developing applications using IBM products since mid-90’s
– Several open-source projects on OpenNTF
– “Learn Java by Example” video course 

on lynda.com (LinkedIn Learning)
– IBM Champion since 2011
– nsftools.com (old stuff)
– @jrobichaux
2
Why are we here?
• To talk about Java 8!
– specifically lambdas and streams
– syntax, gotchas, and “why change?”



• Assuming that everyone in the room is a Java programmer
– you don’t have to be an expert
– any version is fine, we will start with Java 6
– we will also touch on Java 7, just in case



• What to do if you’re still on a Java 6 platform
3
Example Code
• Connect to a web server via HTTPS, and report the key size and expiration
date of the SSL certificate
– check servers for vulnerabilities due to old/weak keys
– tell your admins it’s time to renew the certificate
4
URL url = new URL( "https://my.server" );
checkSSLCertificate(url);
public static void checkSSLCertificate(URL url) {
HttpsURLConnection con = null;
try {
con = (HttpsURLConnection) url.openConnection();
con.setSSLSocketFactory( fakeSocketFactory() );
con.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true; // trust everyone!
}
});
con.connect();
Certificate[] certs = con.getServerCertificates();
for (Certificate cert : certs) {
System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter());
System.out.println( "Server key bit length: " +
((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() );
}
} catch (IOException e) {
e.printStackTrace();
} catch (GeneralSecurityException e) {
e.printStackTrace();
} finally {
con.disconnect();
}
}
Example Code (Java 6)
create an HTTPS connection
tell it that self-signed and
expired certificates are okay
report the expiration date and
RSA key length of each SSL
certificate on the server
Exception handling!
Example Code (Java 6)
/**
* Creates an SSLSocketFactory that doesn't check certificates at all
* DO NOT USE THIS IN REAL LIFE
*/
private static SSLSocketFactory fakeSocketFactory() throws GeneralSecurityException {
TrustManager trustEveryone = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() { return null; }
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {}
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {}
};
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[] { trustEveryone }, new SecureRandom());
return sslContext.getSocketFactory();
}
A Few Words About Java 7
because you’ll see this stuff in Java 8
Catch Multiple Exceptions
• Try-catch blocks can catch multiple exceptions in one statement
HttpsURLConnection con = null;
try {
con = (HttpsURLConnection) url.openConnection();
// do stuff..
} catch (IOException e) {
e.printStackTrace();
} catch (GeneralSecurityException e) {
e.printStackTrace();
} finally {
con.disconnect();
}
HttpsURLConnection con = null;
try {
con = (HttpsURLConnection) url.openConnection();
// do stuff..
} catch (IOException | GeneralSecurityException e) {
e.printStackTrace();
} finally {
con.disconnect();
}
Try-with-resources
• Classes that implement the AutoCloseable interface can be automatically
closed by a try-catch block
HttpsURLConnection con = null;
try {
con = (HttpsURLConnection) url.openConnection();
// do stuff..
} catch (IOException | GeneralSecurityException e) {
e.printStackTrace();
} finally {
con.disconnect();
}
try (CloseableURLConnection closeableCon = new CloseableURLConnection(url)) {
HttpsURLConnection con = closeableCon.getHttpsConnection();
// do stuff..
} catch (IOException | GeneralSecurityException e) {
e.printStackTrace();
}
*
*
*
Creating a Closeable Class
static class CloseableURLConnection implements AutoCloseable {
URLConnection con;
public CloseableURLConnection(URL url) throws IOException {
con = url.openConnection();
}
public HttpsURLConnection getHttpsConnection() {
return (HttpsURLConnection)con;
}
@Override
public void close() {
getHttpsConnection().disconnect();
}
}
implement AutoCloseable
create a close() method
Closeable Classes
• Several standard Java classes are now AutoClosable
– InputStream
– OutputStream
– Reader
– Writer
– java.sql.Connection, Statement, and ResultSet

• You no longer have to declare your streams outside the try/catch block, or
remember to close them when you’re done!

• Like a finally clause, try-with-resources objects get closed even if an
Exception is thrown
11
A Few Other Java 7 Goodies
• New and/or improved classes
– java.nio.file, updated XML libraries, new/enhanced cryptography providers

• Binary literals and underscores in numeric literals
– int byteNum = 0b00100001;
– int phoneNum = 555_1212;

• Type inference for generics
– Map<String, List<String>> map = new HashMap<>();

• Switch statements operate on Strings

• http://docs.oracle.com/javase/8/docs/technotes/guides/language/enhancements.html 

http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html
And Now: Java 8
on to the good stuff
The Code in Java 7…
public static void checkSSLCertificate(URL url) {
try (CloseableURLConnection closeableCon = new CloseableURLConnection(url)) {
HttpsURLConnection con = closeableCon.getHttpsConnection();
con.setSSLSocketFactory( fakeSocketFactory() );
con.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true; // trust everyone!
}
});
con.connect();
Certificate[] certs = con.getServerCertificates();
for (Certificate cert : certs) {
System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter());
System.out.println( "Server key bit length: " +
((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() );
}
} catch (IOException | GeneralSecurityException e) {
e.printStackTrace();
}
}
anonymous class
loop through an array
The Code in Java 8
public static void checkSSLCertificate(URL url) {
try (CloseableURLConnection closeableCon = new CloseableURLConnection(url)) {
HttpsURLConnection con = closeableCon.getHttpsConnection();
con.setSSLSocketFactory( fakeSocketFactory() );
con.setHostnameVerifier( (hostname, session) -> true );
con.connect();
Certificate[] certs = con.getServerCertificates();
Arrays.asList(certs)
.stream()
.map ( cert -> (X509Certificate)cert )
.peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) )
.map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() )
.forEach( i -> System.out.println("Server key bit length: " + i) );
} catch (IOException | GeneralSecurityException e) {
e.printStackTrace();
}
}
lambda hostname verifier
read the array as a stream,
not a loop
What’s a Lambda?
• Simplified syntax for writing single-method classes

• You are effectively passing a function as a parameter to a method
16
con.setHostnameVerifier( (hostname, session) -> true );
(parameters)
arrow
expression
How Does that Lambda Work?
con.setHostnameVerifier( new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
con.setHostnameVerifier( (hostname, session) -> true );
?
How Does that Lambda Work?
con.setHostnameVerifier( new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
con.setHostnameVerifier( (hostname, session) -> true );
?
How Does that Lambda Work?
con.setHostnameVerifier( new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
con.setHostnameVerifier( (hostname, session) -> true );
?
How Does that Lambda Work?
con.setHostnameVerifier( new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
con.setHostnameVerifier( (hostname, session) -> true );
?
How Does that Lambda Work?
con.setHostnameVerifier( new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
con.setHostnameVerifier( (hostname, session) -> true );
!
Functional Interfaces
• Lambdas rely on “functional interfaces” to work
– an interface with only one abstract method
– also called a “single abstract method” or SAM interface
– there can be only one! <insert highlander joke here>

• If there’s only one method, the compiler knows which one you will call

• If you know the method, and the compiler knows the method, we don’t
have to talk about the method
– everyone already knows!
– skip the obvious stuff
22
Functional Interfaces
con.setHostnameVerifier( new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
con.setHostnameVerifier( (hostname, session) -> true );
the class MUST be a HostnameVerifier, and the
method MUST be verify(String, SSLSession)
therefore… throw away everything obvious
Lambda Syntax
object.method( (param1, param2) -> result );
object.method( param1 -> doStuff(param1) );
object.method( param1 -> doStuff(param1, object) );
object.method( () -> {
doStuff();
return doMoreStuff();
} );
Method References
• There is an alternative syntax called “Method References”
– for a lambda that only calls a single method of the parameter, or a single
static method that uses the parameter, or creates a single new Object
object.method( s -> s.getLength() );
object.method( String::getLength );
http://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html
Another Example: Sandwiches!
static enum Sandwich {
PB_J ("Peanut butter & jelly", 500),
SUB ("Sub", 500),
HOTDOG ("Hot dog", 900),
TACO ("Taco", 500),
PIZZA ("Pizza", 900);
private String name;
private int calories;
private Sandwich(String name, int calories) {
this.name = name;
this.calories = calories;
}
public String getName() { return name; }
public int getCalories() { return calories; }
public String toString() { return "n" + calories +
" caloriest" + name; }
}
List the Sandwiches in Order of Calories
List<Sandwich> sandwiches = Arrays.asList( Sandwich.values() );
Collections.sort(sandwiches, new Comparator<Sandwich>() {
public int compare(Sandwich s1, Sandwich s2) {
return Integer.compare(s1.getCalories(), s2.getCalories());
}
});
System.out.println(sandwiches);
PB_J ("Peanut butter & jelly", 500),
SUB ("Sub", 500),
HOTDOG ("Hot dog", 900),
TACO ("Taco", 500),
PIZZA ("Pizza", 900);
500 calories Peanut butter & jelly,
500 calories Sub,
500 calories Taco,
900 calories Hot dog,
900 calories Pizza
List the Sandwiches in Order of Calories
List<Sandwich> sandwiches = Arrays.asList( Sandwich.values() );
/*
Collections.sort(sandwiches, new Comparator<Sandwich>() {
public int compare(Sandwich s1, Sandwich s2) {
return Integer.compare(s1.getCalories(), s2.getCalories());
}
});
*/
Collections.sort(sandwiches,
(s1, s2) -> Integer.compare(s1.getCalories(), s2.getCalories()) );
System.out.println(sandwiches);
PB_J ("Peanut butter & jelly", 500),
SUB ("Sub", 500),
HOTDOG ("Hot dog", 900),
TACO ("Taco", 500),
PIZZA ("Pizza", 900);
500 calories Peanut butter & jelly,
500 calories Sub,
500 calories Taco,
900 calories Hot dog,
900 calories Pizza
List the Sandwiches in Order of Calories
List<Sandwich> sandwiches = Arrays.asList( Sandwich.values() );
/*
Collections.sort(sandwiches, new Comparator<Sandwich>() {
public int compare(Sandwich s1, Sandwich s2) {
return Integer.compare(s1.getCalories(), s2.getCalories());
}
});
*/
Collections.sort(sandwiches,
Comparator.comparing( sandwich -> sandwich.getCalories() ) );
System.out.println(sandwiches);
PB_J ("Peanut butter & jelly", 500),
SUB ("Sub", 500),
HOTDOG ("Hot dog", 900),
TACO ("Taco", 500),
PIZZA ("Pizza", 900);
500 calories Peanut butter & jelly,
500 calories Sub,
500 calories Taco,
900 calories Hot dog,
900 calories Pizza
List the Sandwiches in Order of Calories
List<Sandwich> sandwiches = Arrays.asList( Sandwich.values() );
/*
Collections.sort(sandwiches, new Comparator<Sandwich>() {
public int compare(Sandwich s1, Sandwich s2) {
return Integer.compare(s1.getCalories(), s2.getCalories());
}
});
*/
Collections.sort(sandwiches,
Comparator.comparing( Sandwich::getCalories ) );
System.out.println(sandwiches);
PB_J ("Peanut butter & jelly", 500),
SUB ("Sub", 500),
HOTDOG ("Hot dog", 900),
TACO ("Taco", 500),
PIZZA ("Pizza", 900);
500 calories Peanut butter & jelly,
500 calories Sub,
500 calories Taco,
900 calories Hot dog,
900 calories Pizza
All These are the Same Comparator
Collections.sort(sandwiches, new Comparator<Sandwich>() {
public int compare(Sandwich s1, Sandwich s2) {
return Integer.compare(s1.getCalories(), s2.getCalories());
}
});
Collections.sort(sandwiches,
(s1, s2) -> Integer.compare(s1.getCalories(), s2.getCalories()) );
Collections.sort(sandwiches,
Comparator.comparing( sandwich -> sandwich.getCalories() ) );
Collections.sort(sandwiches,
Comparator.comparing( Sandwich::getCalories ) );
Fun with the Comparator
Collections.sort(sandwiches,
Comparator.comparing( Sandwich::getCalories )
.thenComparing( Sandwich::getName )
.reversed() );
900 calories Pizza,
900 calories Hot dog,
500 calories Taco,
500 calories Sub,
500 calories Peanut butter & jelly
PB_J ("Peanut butter & jelly", 500),
SUB ("Sub", 500),
HOTDOG ("Hot dog", 900),
TACO ("Taco", 500),
PIZZA ("Pizza", 900);
But Really, What’s the Point?
• This all seems like needless tomfoolery
– after all, the old code still works!

• Two major advantages:
1. Forces (or strongly encourages) you to write functional code
2. Less visual noise makes code easier to read and understand
33
Collections.sort(sandwiches, new Comparator<Sandwich>() {
public int compare(Sandwich s1, Sandwich s2) {
return Integer.compare(s1.getCalories(), s2.getCalories());
}
});
Collections.sort(sandwiches,
Comparator.comparing( Sandwich::getCalories ) );
Code Should Describe Behavior
Code Should Read Like A Story
Dealing with Exceptions
Collections.sort(sandwiches,
Comparator.comparing( Sandwich::getCalories )
.thenComparing( Sandwich::getName )
.reversed() );
NULLWICH (null, 500),
PB_J ("Peanut butter & jelly", 500),
SUB ("Sub", 500),
HOTDOG ("Hot dog", 900),
TACO ("Taco", 500),
PIZZA ("Pizza", 900);
Exception in thread "main" java.lang.NullPointerException
at java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469)
at java.util.Comparator.lambda$thenComparing$36697e65$1(Comparator.java:217)
at java.util.Collections$ReverseComparator2.compare(Collections.java:5178)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.util.TimSort.sort(TimSort.java:220)
at java.util.Arrays.sort(Arrays.java:1438)
at java.util.Arrays$ArrayList.sort(Arrays.java:3895)
at java.util.Collections.sort(Collections.java:175)
at com.panagenda.ssltest.MoreJava8Examples.main(MoreJava8Examples.java:52)
Dealing with Exceptions
• It’s not always obvious what caused the Exception

• It’s cumbersome to add a try/catch to a lambda
– same with adding logging

• If an Exception is possible, maybe better to call out to a method instead
36
Collections.sort(sandwiches,
Comparator.comparing( sandwich -> getCalories(sandwich) )
.thenComparing( sandwich -> getName(sandwich) )
.reversed() );
A Few More Examples
// process all the keys and values of a HashMap
Map<String, Integer> myHashMap = new HashMap<>();
myHashMap.forEach( (key, value) -> System.out.println(key + "; " + value) );
// remove all the null elements in a List
List<String> myArrayList = new ArrayList<>();
myArrayList.removeIf( s -> s == null );
// get all the JPG files in a directory
File photoDir = new File("c:/photos");
File[] docFiles = photoDir.listFiles( file -> file.getName().endsWith("jpg") );
// run some code in a thread
new Thread( () -> doSomething() ).start();
Under the Hood
• If you’re really curious about how all this works…
– http://cr.openjdk.java.net/~briangoetz/lambda/lambda-translation.html 

• It’s all Function and Predicate objects
– https://docs.oracle.com/javase/8/docs/api/java/util/function/package-
summary.html
– Closures? By some definitions.
38
Function<Sandwich, Integer> caloryCompare = sandwich -> sandwich.getCalories();
Streams!
of data, not water
From Loop to Stream
Certificate[] certs = con.getServerCertificates();
for (Certificate cert : certs) {
System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter());
System.out.println( "Server key bit length: " +
((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() );
}
Certificate[] certs = con.getServerCertificates();
Arrays.asList(certs)
.stream()
.map ( cert -> (X509Certificate)cert )
.peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) )
.map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() )
.forEach( i -> System.out.println("Server key bit length: " + i) );
?
What Does that Loop Actually Do?
41
Certificate[] certs = con.getServerCertificates();
for (Certificate cert : certs) {
System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter());
System.out.println( "Server key bit length: " +
((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() );
}
print the information
get something from the objectprint the information
get something from the object
How Does the Stream Work?
Certificate[] certs = con.getServerCertificates();
Arrays.asList(certs)
.stream()
.map ( cert -> (X509Certificate)cert )
.peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) )
.map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() )
.forEach( i -> System.out.println("Server key bit length: " + i) );
start with an array,
convert it to a List
convert the List to a stream
TIP: this could also be just
Arrays.stream(certs)
}
change the stream
do something to each item
change the stream
do something to each item
Breaking Down the Example
Certificate[] certs = con.getServerCertificates();
Arrays.asList(certs)
.stream()
.map ( cert -> (X509Certificate)cert )
.peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) )
.map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() )
.forEach( i -> System.out.println("Server key bit length: " + i) );
map() converts each item by
casting it to X509Certificate,
then returns a Stream of
X509Certificate objects
map() gets an int value from
each item, then returns a
Stream of int values
start with an array of
Certificates
Breaking Down the Example
Certificate[] certs = con.getServerCertificates();
Arrays.asList(certs)
.stream()
.map ( cert -> (X509Certificate)cert )
.peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) )
.map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() )
.forEach( i -> System.out.println("Server key bit length: " + i) );
peek() is an intermediate
operation: it does something
with each item and returns
the original Stream
forEach() is a terminal
operation: it does something
with each item and stops
What’s a Stream?
• Allows you to perform operations on a collection of data
– multiple operations can be combined in a pipeline



• Has the following properties
– uses functional arguments (lambdas!) to process data
– does not store data
– pipeline operations are optimized for laziness
– optionally process in parallel (multi-threaded) with no extra code
45
Is a Stream Better than a Loop?
Certificate[] certs = con.getServerCertificates();
for (Certificate cert : certs) {
System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter());
System.out.println( "Server key bit length: " +
((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() );
}
Certificate[] certs = con.getServerCertificates();
Arrays.asList(certs)
.stream()
.map ( cert -> (X509Certificate)cert )
.peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) )
.map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() )
.forEach( i -> System.out.println("Server key bit length: " + i) );
!Stream version is more
descriptive of the behavior
of the code
Stream version can easily be
turned into multi-threaded
code
Multi-threaded You Say?
Arrays.asList(certs)
.stream()
.parallel()
.map ( cert -> (X509Certificate)cert )
.peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) )
.map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() )
.forEach( i -> System.out.println("Server key bit length: " + i) );
DANGER: The forEach() and peek()
output might be out-of-order!
Adding Numbers in a Loop
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
45
int sum = 0;
for (int i : new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9}) {
sum += i;
}
return sum;
Adding Numbers with Reduce
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
1 + 2 3 + 4 + 5 6 + 8 7 + 9
3 + 14 12 + 16
45
Adding Numbers with Reduce
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
1 + 2 3 + 4 + 5 6 + 8 7 + 9
3 + 14 12 + 16
45
By abstracting away the very concept
of looping, you can implement looping
any way you want, including
implementing it in a way that scales
nicely with extra hardware.
Joel Spolsky
https://www.joelonsoftware.com/2006/08/01/
can-your-programming-language-do-this
each computation could be on a separate processor core… or a separate machine!
Other Things to Know About Streams
• Normally get them from Collections or arrays
– List.stream(), Map.entrySet().stream(), Arrays.stream(Object[])
– also other fun places, like BufferedReader.lines() or Files.list()



• Some operations will short circuit instead of processing each item
– built-in optimizations



• Stream operations should be stateless
– for example, don’t update Lists as part of a stream operation
– items could process out of order, and might not be thread-safe
– collect the results at the end instead
51
Other Things to Know About Streams
• Operations on Streams should be associative when possible
– (a + b + c) == (c + b + a) == b + (a + c)
– if order of operations does matter, make sure you:
• start with an ordered set of data, like a List
• use forEachOrdered() instead of forEach()
• don’t use reduce() 



• For reference:
– https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-
summary.html
52
Under the Hood
• If you’re really curious about how all this works…
– http://www.ibm.com/developerworks/java/library/j-java-streams-1-brian-
goetz 

• Read about java.util.function
– https://docs.oracle.com/javase/8/docs/api/java/util/function/package-
summary.html
– Predicate, Consumer, and Supplier interfaces
53
Backwards Compatibility
because not all of us have a choice
Java 8 API Changes (partial list)
• Streams
– in its own package
– throughout Collections, Files, etc.

• Functional classes in java.util.function

• Brand new Date-Time package and classes
– http://docs.oracle.com/javase/tutorial/datetime 

• JavaFX for GUIs

• http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html 

http://docs.oracle.com/javase/8/docs/technotes/guides/language/lambda_api_jdk8.html
55
Function<Sandwich, Integer> caloryCompare =
sandwich -> sandwich.getCalories();
Compiling to Earlier Versions
• Java can compile for previous versions, but…
– you can’t use any of the new APIs (classes or methods)
– you can’t use any of the new language features



• What happens if you use a Java 8 JAR in a Java 6 environment?
– it won’t work
– the JRE checks the JAR file for a version number first
– if the version number is too high, you get errors



• Some tools can convert bytecode to earlier versions
– but new APIs still won’t work
56
Options for Backwards Compatibility
• If you don’t want to use new language features at all
– set “Source compatibility” and “Generated .class files compatibility” to your
desired older Java version
– use a tool to make sure you didn’t use new APIs

Animal Sniffer: http://www.mojohaus.org/animal-sniffer 

57
Options for Backwards Compatibility
• If you only want to use lambdas and try-with-resources
– compile as Java 8, then use RetroLambda to backport your JAR file 

https://github.com/orfjackal/retrolambda
– you still have to make sure you didn’t use new APIs: AnimalSniffer again



• You might be able to backport Streams too (mixed results)
– http://sourceforge.net/projects/streamsupport
58
Is It Worth It?
• Backporting? Maybe, but probably not regularly
– Risky: even if it seems to work, hard to test if it really worked
– make sure you have great unit tests to run against the backported code



• Learning? Absolutely!
– even if you can’t use Java 8 now, you will later
– functional programming can be much “safer”
– teaches you good coding habits
– helps you understand code examples on StackOverflow ;)
59
Required Reading
we only scratched the surface
On the Oracle Website
• Streams
– https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-
summary.html
– http://www.oracle.com/technetwork/articles/java/ma14-java-se-8-
streams-2177646.html 

• Lambdas
– https://docs.oracle.com/javase/tutorial/java/javaOO/
lambdaexpressions.html
– http://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html
– https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.27
61
Articles and Musings
• State of the lambda (Brian Goetz)
– http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-final.html 

• IBM DeveloperWorks articles by Brian Goetz
– http://www.ibm.com/developerworks/java/library/j-java-streams-1-brian-goetz
– http://www.ibm.com/developerworks/java/library/j-java-streams-2-brian-goetz
– http://www.ibm.com/developerworks/java/library/j-java-streams-3-brian-goetz
– http://www.ibm.com/developerworks/java/library/j-java-streams-4-brian-goetz
– http://www.ibm.com/developerworks/java/library/j-java-streams-5-brian-goetz

• Joel Spolsky on MapReduce
– https://www.joelonsoftware.com/2006/08/01/can-your-programming-language-
do-this
62
Books (!)
• Java 8 in Action
– Raoul-Gabriel Urma

Manning Press
• Mastering Lambdas:
Java Programming in
a Multicore World
– Maurice Naftalin

Oracle Press
Notices and
disclaimers
Copyright © 2017 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in
any form without written permission from IBM.
U.S. Government Users Restricted Rights — Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM.
Information in these presentations (including information relating to products that have not yet been announced by IBM) has been
reviewed for accuracy as of the date of initial publication and could include unintentional technical or typographical errors. IBM shall
have no responsibility to update this information. THIS DOCUMENT IS DISTRIBUTED "AS IS" WITHOUT ANY WARRANTY, EITHER
EXPRESS OR IMPLIED. IN NO EVENT SHALL IBM BE LIABLE FOR ANY DAMAGE ARISING FROM THE USE OF THIS
INFORMATION, INCLUDING BUT NOT LIMITED TO, LOSS OF DATA, BUSINESS INTERRUPTION, LOSS OF PROFIT OR LOSS OF
OPPORTUNITY. IBM products and services are warranted according to the terms and conditions of the agreements under which they
are provided.
IBM products are manufactured from new parts or new and used parts. In some cases, a product may not be new and may have been
previously installed. Regardless, our warranty terms apply.”
Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice.
Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as
illustrations of how those customers have used IBM products and the results they may have achieved. Actual performance, cost,
savings or other results in other operating environments may vary.
References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs
or services available in all countries in which IBM operates or does business.
Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily
reflect the views of IBM. All materials and discussions are provided for informational purposes only, and are neither intended to, nor
shall constitute legal or other guidance or advice to any individual participant or their specific situation.
It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel
as to the identification and interpretation of any relevant laws and regulatory requirements that may affect the customer’s business and
any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or represent or warrant that its
services or products will ensure that the customer is in compliance with any law
64
Notices and
disclaimers
continued
Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other
publicly available sources. IBM has not tested those products in connection with this publication and cannot confirm the accuracy of
performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should
be addressed to the suppliers of those products. IBM does not warrant the quality of any third-party products, or the ability of any such
third-party products to interoperate with IBM’s products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESSED OR
IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE.
The provision of the information contained herein is not intended to, and does not, grant any right or license under any IBM patents,
copyrights, trademarks or other intellectual property right.
IBM, the IBM logo, ibm.com, Aspera®, Bluemix, Blueworks Live, CICS, Clearcase, Cognos®, DOORS®, Emptoris®, Enterprise
Document Management System™, FASP®, FileNet®, Global Business Services ®, Global Technology Services ®, IBM
ExperienceOne™, IBM SmartCloud®, IBM Social Business®, Information on Demand, ILOG, Maximo®, MQIntegrator®, MQSeries®,
Netcool®, OMEGAMON, OpenPower, PureAnalytics™, PureApplication®, pureCluster™, PureCoverage®, PureData®,
PureExperience®, PureFlex®, pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, Smarter Commerce®,
SoDA, SPSS, Sterling Commerce®, StoredIQ, Tealeaf®, Tivoli®, Trusteer®, Unica®, urban{code}®, Watson, WebSphere®, Worklight®,
X-Force® and System z® Z/OS, are trademarks of International Business Machines Corporation, registered in many jurisdictions
worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is
available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.
65
Thank you!
Julian Robichaux
@jrobichaux
jrobichaux@panagenda.com

Weitere ähnliche Inhalte

Was ist angesagt?

Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...Codemotion
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctlyDror Helper
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent codeDror Helper
 
DataStax: Making Cassandra Fail (for effective testing)
DataStax: Making Cassandra Fail (for effective testing)DataStax: Making Cassandra Fail (for effective testing)
DataStax: Making Cassandra Fail (for effective testing)DataStax Academy
 
Cassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra ApplicationsCassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra ApplicationsChristopher Batey
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Morris Singer
 
Cassandra is great but how do I test my application?
Cassandra is great but how do I test my application?Cassandra is great but how do I test my application?
Cassandra is great but how do I test my application?Christopher Batey
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzIvan Krylov
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersJavan Rasokat
 
Enhanced Web Service Testing: A Better Mock Structure
Enhanced Web Service Testing: A Better Mock StructureEnhanced Web Service Testing: A Better Mock Structure
Enhanced Web Service Testing: A Better Mock StructureCRMScienceKirk
 
Ajax World Comet Talk
Ajax World Comet TalkAjax World Comet Talk
Ajax World Comet Talkrajivmordani
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingLars Thorup
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comVan-Duyet Le
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGuillaume Laforge
 
Fault tolerant microservices - LJC Skills Matter 4thNov2014
Fault tolerant microservices - LJC Skills Matter 4thNov2014Fault tolerant microservices - LJC Skills Matter 4thNov2014
Fault tolerant microservices - LJC Skills Matter 4thNov2014Christopher Batey
 
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programmingEric Polerecky
 

Was ist angesagt? (20)

Exploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systemsExploring lambdas and invokedynamic for embedded systems
Exploring lambdas and invokedynamic for embedded systems
 
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
DataStax: Making Cassandra Fail (for effective testing)
DataStax: Making Cassandra Fail (for effective testing)DataStax: Making Cassandra Fail (for effective testing)
DataStax: Making Cassandra Fail (for effective testing)
 
Cassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra ApplicationsCassandra Summit EU 2014 - Testing Cassandra Applications
Cassandra Summit EU 2014 - Testing Cassandra Applications
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015
 
Celery
CeleryCelery
Celery
 
Cassandra is great but how do I test my application?
Cassandra is great but how do I test my application?Cassandra is great but how do I test my application?
Cassandra is great but how do I test my application?
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
Code lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf LinzCode lifecycle in the jvm - TopConf Linz
Code lifecycle in the jvm - TopConf Linz
 
Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発
 
OWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA TestersOWASP ZAP Workshop for QA Testers
OWASP ZAP Workshop for QA Testers
 
Enhanced Web Service Testing: A Better Mock Structure
Enhanced Web Service Testing: A Better Mock StructureEnhanced Web Service Testing: A Better Mock Structure
Enhanced Web Service Testing: A Better Mock Structure
 
Ajax World Comet Talk
Ajax World Comet TalkAjax World Comet Talk
Ajax World Comet Talk
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit Testing
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
 
Fault tolerant microservices - LJC Skills Matter 4thNov2014
Fault tolerant microservices - LJC Skills Matter 4thNov2014Fault tolerant microservices - LJC Skills Matter 4thNov2014
Fault tolerant microservices - LJC Skills Matter 4thNov2014
 
Real world functional reactive programming
Real world functional reactive programmingReal world functional reactive programming
Real world functional reactive programming
 

Andere mochten auch

DEV-1185: IBM Notes Performance Boost - Reloaded – IBM Connect 2017
DEV-1185: IBM Notes Performance Boost - Reloaded – IBM Connect 2017DEV-1185: IBM Notes Performance Boost - Reloaded – IBM Connect 2017
DEV-1185: IBM Notes Performance Boost - Reloaded – IBM Connect 2017panagenda
 
IBM Connect 2017 - Beyond Domino Designer
IBM Connect 2017 - Beyond Domino DesignerIBM Connect 2017 - Beyond Domino Designer
IBM Connect 2017 - Beyond Domino DesignerStephan H. Wissel
 
IBM Connect 2017: Refresh and Extend IBM Domino Applications
IBM Connect 2017: Refresh and Extend IBM Domino ApplicationsIBM Connect 2017: Refresh and Extend IBM Domino Applications
IBM Connect 2017: Refresh and Extend IBM Domino ApplicationsEd Brill
 
DEV-1268: IBM Connections Adminblast – IBM Connect 2017
DEV-1268: IBM Connections Adminblast – IBM Connect 2017DEV-1268: IBM Connections Adminblast – IBM Connect 2017
DEV-1268: IBM Connections Adminblast – IBM Connect 2017panagenda
 
Connect 2017 DEV-1420 - Blue Mix and Domino – Complementing Smartcloud
Connect 2017 DEV-1420 - Blue Mix and Domino – Complementing SmartcloudConnect 2017 DEV-1420 - Blue Mix and Domino – Complementing Smartcloud
Connect 2017 DEV-1420 - Blue Mix and Domino – Complementing SmartcloudMatteo Bisi
 
DEV-1223: Socialytics: Accelerating IBM Connections Adoption with Watson Anal...
DEV-1223: Socialytics: Accelerating IBM Connections Adoption with Watson Anal...DEV-1223: Socialytics: Accelerating IBM Connections Adoption with Watson Anal...
DEV-1223: Socialytics: Accelerating IBM Connections Adoption with Watson Anal...panagenda
 
Big Data With Graphs
Big Data With GraphsBig Data With Graphs
Big Data With GraphsRed Pill Now
 
Your App Deserves More – The Art of App Modernization
Your App Deserves More – The Art of App ModernizationYour App Deserves More – The Art of App Modernization
Your App Deserves More – The Art of App ModernizationKlaus Bild
 
OpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino DevelopmentOpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino DevelopmentPaul Withers
 
Domino, Exchange, O365: Ihre Email Daten sind Gold wert - Kinoforum 2016
Domino, Exchange, O365: Ihre Email Daten sind Gold wert - Kinoforum 2016Domino, Exchange, O365: Ihre Email Daten sind Gold wert - Kinoforum 2016
Domino, Exchange, O365: Ihre Email Daten sind Gold wert - Kinoforum 2016panagenda
 
DEV-1269: Best and Worst Practices for Deploying IBM Connections – IBM Conne...
DEV-1269: Best and Worst Practices for Deploying IBM Connections  – IBM Conne...DEV-1269: Best and Worst Practices for Deploying IBM Connections  – IBM Conne...
DEV-1269: Best and Worst Practices for Deploying IBM Connections – IBM Conne...panagenda
 
Virtual,Faster,Better! How To Virtualize the IBM Notes Client and IBM Client ...
Virtual,Faster,Better! How To Virtualize the IBM Notes Client and IBM Client ...Virtual,Faster,Better! How To Virtualize the IBM Notes Client and IBM Client ...
Virtual,Faster,Better! How To Virtualize the IBM Notes Client and IBM Client ...Christoph Adler
 
DEV-1430 IBM Connections Integration
DEV-1430 IBM Connections IntegrationDEV-1430 IBM Connections Integration
DEV-1430 IBM Connections IntegrationJesse Gallagher
 
One Firm's Wild Ride to The Cloud
One Firm's Wild Ride to The CloudOne Firm's Wild Ride to The Cloud
One Firm's Wild Ride to The CloudKeith Brooks
 
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...Frank van der Linden
 
Socialytics: Accelerating IBM Connections Adoption with Watson Analytics
Socialytics: Accelerating IBM Connections Adoption with Watson AnalyticsSocialytics: Accelerating IBM Connections Adoption with Watson Analytics
Socialytics: Accelerating IBM Connections Adoption with Watson AnalyticsFemke Goedhart
 
Going Cloud - warum und wie? - 42. DNUG
Going Cloud - warum und wie? - 42. DNUGGoing Cloud - warum und wie? - 42. DNUG
Going Cloud - warum und wie? - 42. DNUGpanagenda
 
SI1692: When Lightning Strikes Collaboration - IBM Connect 2016
SI1692: When Lightning Strikes Collaboration - IBM Connect 2016SI1692: When Lightning Strikes Collaboration - IBM Connect 2016
SI1692: When Lightning Strikes Collaboration - IBM Connect 2016panagenda
 

Andere mochten auch (20)

DEV-1185: IBM Notes Performance Boost - Reloaded – IBM Connect 2017
DEV-1185: IBM Notes Performance Boost - Reloaded – IBM Connect 2017DEV-1185: IBM Notes Performance Boost - Reloaded – IBM Connect 2017
DEV-1185: IBM Notes Performance Boost - Reloaded – IBM Connect 2017
 
IBM Connect 2017 - Beyond Domino Designer
IBM Connect 2017 - Beyond Domino DesignerIBM Connect 2017 - Beyond Domino Designer
IBM Connect 2017 - Beyond Domino Designer
 
IBM Connect 2017: Refresh and Extend IBM Domino Applications
IBM Connect 2017: Refresh and Extend IBM Domino ApplicationsIBM Connect 2017: Refresh and Extend IBM Domino Applications
IBM Connect 2017: Refresh and Extend IBM Domino Applications
 
DEV-1268: IBM Connections Adminblast – IBM Connect 2017
DEV-1268: IBM Connections Adminblast – IBM Connect 2017DEV-1268: IBM Connections Adminblast – IBM Connect 2017
DEV-1268: IBM Connections Adminblast – IBM Connect 2017
 
Connect 2017 DEV-1420 - Blue Mix and Domino – Complementing Smartcloud
Connect 2017 DEV-1420 - Blue Mix and Domino – Complementing SmartcloudConnect 2017 DEV-1420 - Blue Mix and Domino – Complementing Smartcloud
Connect 2017 DEV-1420 - Blue Mix and Domino – Complementing Smartcloud
 
DEV-1223: Socialytics: Accelerating IBM Connections Adoption with Watson Anal...
DEV-1223: Socialytics: Accelerating IBM Connections Adoption with Watson Anal...DEV-1223: Socialytics: Accelerating IBM Connections Adoption with Watson Anal...
DEV-1223: Socialytics: Accelerating IBM Connections Adoption with Watson Anal...
 
DEV-1467 - Darwino
DEV-1467 - DarwinoDEV-1467 - Darwino
DEV-1467 - Darwino
 
Big Data With Graphs
Big Data With GraphsBig Data With Graphs
Big Data With Graphs
 
Your App Deserves More – The Art of App Modernization
Your App Deserves More – The Art of App ModernizationYour App Deserves More – The Art of App Modernization
Your App Deserves More – The Art of App Modernization
 
OpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino DevelopmentOpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino Development
 
Domino, Exchange, O365: Ihre Email Daten sind Gold wert - Kinoforum 2016
Domino, Exchange, O365: Ihre Email Daten sind Gold wert - Kinoforum 2016Domino, Exchange, O365: Ihre Email Daten sind Gold wert - Kinoforum 2016
Domino, Exchange, O365: Ihre Email Daten sind Gold wert - Kinoforum 2016
 
DEV-1269: Best and Worst Practices for Deploying IBM Connections – IBM Conne...
DEV-1269: Best and Worst Practices for Deploying IBM Connections  – IBM Conne...DEV-1269: Best and Worst Practices for Deploying IBM Connections  – IBM Conne...
DEV-1269: Best and Worst Practices for Deploying IBM Connections – IBM Conne...
 
Virtual,Faster,Better! How To Virtualize the IBM Notes Client and IBM Client ...
Virtual,Faster,Better! How To Virtualize the IBM Notes Client and IBM Client ...Virtual,Faster,Better! How To Virtualize the IBM Notes Client and IBM Client ...
Virtual,Faster,Better! How To Virtualize the IBM Notes Client and IBM Client ...
 
DEV-1430 IBM Connections Integration
DEV-1430 IBM Connections IntegrationDEV-1430 IBM Connections Integration
DEV-1430 IBM Connections Integration
 
One Firm's Wild Ride to The Cloud
One Firm's Wild Ride to The CloudOne Firm's Wild Ride to The Cloud
One Firm's Wild Ride to The Cloud
 
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
DEV-1129 How Watson, Bluemix, Cloudant, and XPages Can Work Together In A Rea...
 
Socialytics: Accelerating IBM Connections Adoption with Watson Analytics
Socialytics: Accelerating IBM Connections Adoption with Watson AnalyticsSocialytics: Accelerating IBM Connections Adoption with Watson Analytics
Socialytics: Accelerating IBM Connections Adoption with Watson Analytics
 
GraphQL 101
GraphQL 101GraphQL 101
GraphQL 101
 
Going Cloud - warum und wie? - 42. DNUG
Going Cloud - warum und wie? - 42. DNUGGoing Cloud - warum und wie? - 42. DNUG
Going Cloud - warum und wie? - 42. DNUG
 
SI1692: When Lightning Strikes Collaboration - IBM Connect 2016
SI1692: When Lightning Strikes Collaboration - IBM Connect 2016SI1692: When Lightning Strikes Collaboration - IBM Connect 2016
SI1692: When Lightning Strikes Collaboration - IBM Connect 2016
 

Ähnlich wie DEV-1550: Why Java 8? Or, What's a Lambda? – IBM Connect 2017

Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014Barney Hanlon
 
WSO2 SOA with C and C++
WSO2 SOA with C and C++WSO2 SOA with C and C++
WSO2 SOA with C and C++WSO2
 
Scaling application with RabbitMQ
Scaling application with RabbitMQScaling application with RabbitMQ
Scaling application with RabbitMQNahidul Kibria
 
02 servlet-basics
02 servlet-basics02 servlet-basics
02 servlet-basicssnopteck
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.xYiguang Hu
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance testBryan Liu
 
Altitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopAltitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopFastly
 
Spring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFuSpring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFuVMware Tanzu
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Yevgeniy Brikman
 
Vert.x - Reactive & Distributed [Devoxx version]
Vert.x - Reactive & Distributed [Devoxx version]Vert.x - Reactive & Distributed [Devoxx version]
Vert.x - Reactive & Distributed [Devoxx version]Orkhan Gasimov
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScriptSimon Guest
 
What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0Bruno Borges
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRichard Lee
 

Ähnlich wie DEV-1550: Why Java 8? Or, What's a Lambda? – IBM Connect 2017 (20)

Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014
 
Tdd iPhone For Dummies
Tdd iPhone For DummiesTdd iPhone For Dummies
Tdd iPhone For Dummies
 
WSO2 SOA with C and C++
WSO2 SOA with C and C++WSO2 SOA with C and C++
WSO2 SOA with C and C++
 
Scaling application with RabbitMQ
Scaling application with RabbitMQScaling application with RabbitMQ
Scaling application with RabbitMQ
 
02 servlet-basics
02 servlet-basics02 servlet-basics
02 servlet-basics
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.x
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 
Altitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopAltitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly Workshop
 
Lagom in Practice
Lagom in PracticeLagom in Practice
Lagom in Practice
 
Spring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFuSpring Boot Revisited with KoFu and JaFu
Spring Boot Revisited with KoFu and JaFu
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
Vert.x - Reactive & Distributed [Devoxx version]
Vert.x - Reactive & Distributed [Devoxx version]Vert.x - Reactive & Distributed [Devoxx version]
Vert.x - Reactive & Distributed [Devoxx version]
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScript
 
What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
JEE Programming - 04 Java Servlets
JEE Programming - 04 Java ServletsJEE Programming - 04 Java Servlets
JEE Programming - 04 Java Servlets
 

Mehr von panagenda

De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdfDe05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdfpanagenda
 
Co01_panagenda_NotesDomino-Licensing-Understand-and-Optimize-DLAU-results-wit...
Co01_panagenda_NotesDomino-Licensing-Understand-and-Optimize-DLAU-results-wit...Co01_panagenda_NotesDomino-Licensing-Understand-and-Optimize-DLAU-results-wit...
Co01_panagenda_NotesDomino-Licensing-Understand-and-Optimize-DLAU-results-wit...panagenda
 
Ad01_Navigating-HCL-Notes-14-Upgrades_A-Comprehensive-Guide-for-Conquering-Ch...
Ad01_Navigating-HCL-Notes-14-Upgrades_A-Comprehensive-Guide-for-Conquering-Ch...Ad01_Navigating-HCL-Notes-14-Upgrades_A-Comprehensive-Guide-for-Conquering-Ch...
Ad01_Navigating-HCL-Notes-14-Upgrades_A-Comprehensive-Guide-for-Conquering-Ch...panagenda
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Why you need monitoring to keep your Microsoft 365 journey successful
Why you need monitoring to keep your Microsoft 365 journey successfulWhy you need monitoring to keep your Microsoft 365 journey successful
Why you need monitoring to keep your Microsoft 365 journey successfulpanagenda
 
Developer Special: How to Prepare Applications for Notes 64-bit Clients
Developer Special: How to Prepare Applications for Notes 64-bit ClientsDeveloper Special: How to Prepare Applications for Notes 64-bit Clients
Developer Special: How to Prepare Applications for Notes 64-bit Clientspanagenda
 
Everything You Need to Know About HCL Notes 14
Everything You Need to Know About HCL Notes 14Everything You Need to Know About HCL Notes 14
Everything You Need to Know About HCL Notes 14panagenda
 
Alles was Sie über HCL Notes 14 wissen müssen
Alles was Sie über HCL Notes 14 wissen müssenAlles was Sie über HCL Notes 14 wissen müssen
Alles was Sie über HCL Notes 14 wissen müssenpanagenda
 
Workshop: HCL Notes 14 Upgrades einfach gemacht – von A bis Z
Workshop: HCL Notes 14 Upgrades einfach gemacht – von A bis ZWorkshop: HCL Notes 14 Upgrades einfach gemacht – von A bis Z
Workshop: HCL Notes 14 Upgrades einfach gemacht – von A bis Zpanagenda
 
How to Perform HCL Notes 14 Upgrades Smoothly
How to Perform HCL Notes 14 Upgrades SmoothlyHow to Perform HCL Notes 14 Upgrades Smoothly
How to Perform HCL Notes 14 Upgrades Smoothlypanagenda
 
The Ultimate Administrator’s Guide to HCL Nomad Web
The Ultimate Administrator’s Guide to HCL Nomad WebThe Ultimate Administrator’s Guide to HCL Nomad Web
The Ultimate Administrator’s Guide to HCL Nomad Webpanagenda
 
Die ultimative Anleitung für HCL Nomad Web Administratoren
Die ultimative Anleitung für HCL Nomad Web AdministratorenDie ultimative Anleitung für HCL Nomad Web Administratoren
Die ultimative Anleitung für HCL Nomad Web Administratorenpanagenda
 
Bring the Modern and Seamless User Experience You Deserve to HCL Nomad
Bring the Modern and Seamless User Experience You Deserve to HCL NomadBring the Modern and Seamless User Experience You Deserve to HCL Nomad
Bring the Modern and Seamless User Experience You Deserve to HCL Nomadpanagenda
 
Wie man HCL Nomad eine moderne User Experience verschafft
Wie man HCL Nomad eine moderne User Experience verschafftWie man HCL Nomad eine moderne User Experience verschafft
Wie man HCL Nomad eine moderne User Experience verschafftpanagenda
 
Im Praxistest – Microsoft Teams Performance im hybriden Arbeitsalltag
Im Praxistest – Microsoft Teams Performance im hybriden ArbeitsalltagIm Praxistest – Microsoft Teams Performance im hybriden Arbeitsalltag
Im Praxistest – Microsoft Teams Performance im hybriden Arbeitsalltagpanagenda
 
Hybrid Environments and What They Mean for HCL Notes and Nomad
Hybrid Environments and What They Mean for HCL Notes and NomadHybrid Environments and What They Mean for HCL Notes and Nomad
Hybrid Environments and What They Mean for HCL Notes and Nomadpanagenda
 
Hybride Umgebungen und was sie für HCL Notes und Nomad bedeuten
Hybride Umgebungen und was sie für HCL Notes und Nomad bedeutenHybride Umgebungen und was sie für HCL Notes und Nomad bedeuten
Hybride Umgebungen und was sie für HCL Notes und Nomad bedeutenpanagenda
 

Mehr von panagenda (20)

De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdfDe05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
De05_panagenda_Prepare-Applications-for-64-bit-Clients.pdf
 
Co01_panagenda_NotesDomino-Licensing-Understand-and-Optimize-DLAU-results-wit...
Co01_panagenda_NotesDomino-Licensing-Understand-and-Optimize-DLAU-results-wit...Co01_panagenda_NotesDomino-Licensing-Understand-and-Optimize-DLAU-results-wit...
Co01_panagenda_NotesDomino-Licensing-Understand-and-Optimize-DLAU-results-wit...
 
Ad01_Navigating-HCL-Notes-14-Upgrades_A-Comprehensive-Guide-for-Conquering-Ch...
Ad01_Navigating-HCL-Notes-14-Upgrades_A-Comprehensive-Guide-for-Conquering-Ch...Ad01_Navigating-HCL-Notes-14-Upgrades_A-Comprehensive-Guide-for-Conquering-Ch...
Ad01_Navigating-HCL-Notes-14-Upgrades_A-Comprehensive-Guide-for-Conquering-Ch...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Why you need monitoring to keep your Microsoft 365 journey successful
Why you need monitoring to keep your Microsoft 365 journey successfulWhy you need monitoring to keep your Microsoft 365 journey successful
Why you need monitoring to keep your Microsoft 365 journey successful
 
Developer Special: How to Prepare Applications for Notes 64-bit Clients
Developer Special: How to Prepare Applications for Notes 64-bit ClientsDeveloper Special: How to Prepare Applications for Notes 64-bit Clients
Developer Special: How to Prepare Applications for Notes 64-bit Clients
 
Everything You Need to Know About HCL Notes 14
Everything You Need to Know About HCL Notes 14Everything You Need to Know About HCL Notes 14
Everything You Need to Know About HCL Notes 14
 
Alles was Sie über HCL Notes 14 wissen müssen
Alles was Sie über HCL Notes 14 wissen müssenAlles was Sie über HCL Notes 14 wissen müssen
Alles was Sie über HCL Notes 14 wissen müssen
 
Workshop: HCL Notes 14 Upgrades einfach gemacht – von A bis Z
Workshop: HCL Notes 14 Upgrades einfach gemacht – von A bis ZWorkshop: HCL Notes 14 Upgrades einfach gemacht – von A bis Z
Workshop: HCL Notes 14 Upgrades einfach gemacht – von A bis Z
 
How to Perform HCL Notes 14 Upgrades Smoothly
How to Perform HCL Notes 14 Upgrades SmoothlyHow to Perform HCL Notes 14 Upgrades Smoothly
How to Perform HCL Notes 14 Upgrades Smoothly
 
The Ultimate Administrator’s Guide to HCL Nomad Web
The Ultimate Administrator’s Guide to HCL Nomad WebThe Ultimate Administrator’s Guide to HCL Nomad Web
The Ultimate Administrator’s Guide to HCL Nomad Web
 
Die ultimative Anleitung für HCL Nomad Web Administratoren
Die ultimative Anleitung für HCL Nomad Web AdministratorenDie ultimative Anleitung für HCL Nomad Web Administratoren
Die ultimative Anleitung für HCL Nomad Web Administratoren
 
Bring the Modern and Seamless User Experience You Deserve to HCL Nomad
Bring the Modern and Seamless User Experience You Deserve to HCL NomadBring the Modern and Seamless User Experience You Deserve to HCL Nomad
Bring the Modern and Seamless User Experience You Deserve to HCL Nomad
 
Wie man HCL Nomad eine moderne User Experience verschafft
Wie man HCL Nomad eine moderne User Experience verschafftWie man HCL Nomad eine moderne User Experience verschafft
Wie man HCL Nomad eine moderne User Experience verschafft
 
Im Praxistest – Microsoft Teams Performance im hybriden Arbeitsalltag
Im Praxistest – Microsoft Teams Performance im hybriden ArbeitsalltagIm Praxistest – Microsoft Teams Performance im hybriden Arbeitsalltag
Im Praxistest – Microsoft Teams Performance im hybriden Arbeitsalltag
 
Hybrid Environments and What They Mean for HCL Notes and Nomad
Hybrid Environments and What They Mean for HCL Notes and NomadHybrid Environments and What They Mean for HCL Notes and Nomad
Hybrid Environments and What They Mean for HCL Notes and Nomad
 
Hybride Umgebungen und was sie für HCL Notes und Nomad bedeuten
Hybride Umgebungen und was sie für HCL Notes und Nomad bedeutenHybride Umgebungen und was sie für HCL Notes und Nomad bedeuten
Hybride Umgebungen und was sie für HCL Notes und Nomad bedeuten
 

Kürzlich hochgeladen

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 

Kürzlich hochgeladen (20)

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 

DEV-1550: Why Java 8? Or, What's a Lambda? – IBM Connect 2017

  • 1. DEV-1550: Why Java 8? Or, What's a Lambda? Julian Robichaux, panagenda
  • 2. Who am I? • Julian Robichaux – Programmer and product manager at panagenda – Developing applications using IBM products since mid-90’s – Several open-source projects on OpenNTF – “Learn Java by Example” video course 
 on lynda.com (LinkedIn Learning) – IBM Champion since 2011 – nsftools.com (old stuff) – @jrobichaux 2
  • 3. Why are we here? • To talk about Java 8! – specifically lambdas and streams – syntax, gotchas, and “why change?”
 
 • Assuming that everyone in the room is a Java programmer – you don’t have to be an expert – any version is fine, we will start with Java 6 – we will also touch on Java 7, just in case
 
 • What to do if you’re still on a Java 6 platform 3
  • 4. Example Code • Connect to a web server via HTTPS, and report the key size and expiration date of the SSL certificate – check servers for vulnerabilities due to old/weak keys – tell your admins it’s time to renew the certificate 4 URL url = new URL( "https://my.server" ); checkSSLCertificate(url);
  • 5. public static void checkSSLCertificate(URL url) { HttpsURLConnection con = null; try { con = (HttpsURLConnection) url.openConnection(); con.setSSLSocketFactory( fakeSocketFactory() ); con.setHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; // trust everyone! } }); con.connect(); Certificate[] certs = con.getServerCertificates(); for (Certificate cert : certs) { System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter()); System.out.println( "Server key bit length: " + ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ); } } catch (IOException e) { e.printStackTrace(); } catch (GeneralSecurityException e) { e.printStackTrace(); } finally { con.disconnect(); } } Example Code (Java 6) create an HTTPS connection tell it that self-signed and expired certificates are okay report the expiration date and RSA key length of each SSL certificate on the server Exception handling!
  • 6. Example Code (Java 6) /** * Creates an SSLSocketFactory that doesn't check certificates at all * DO NOT USE THIS IN REAL LIFE */ private static SSLSocketFactory fakeSocketFactory() throws GeneralSecurityException { TrustManager trustEveryone = new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { return null; } public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {} public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {} }; SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, new TrustManager[] { trustEveryone }, new SecureRandom()); return sslContext.getSocketFactory(); }
  • 7. A Few Words About Java 7 because you’ll see this stuff in Java 8
  • 8. Catch Multiple Exceptions • Try-catch blocks can catch multiple exceptions in one statement HttpsURLConnection con = null; try { con = (HttpsURLConnection) url.openConnection(); // do stuff.. } catch (IOException e) { e.printStackTrace(); } catch (GeneralSecurityException e) { e.printStackTrace(); } finally { con.disconnect(); } HttpsURLConnection con = null; try { con = (HttpsURLConnection) url.openConnection(); // do stuff.. } catch (IOException | GeneralSecurityException e) { e.printStackTrace(); } finally { con.disconnect(); }
  • 9. Try-with-resources • Classes that implement the AutoCloseable interface can be automatically closed by a try-catch block HttpsURLConnection con = null; try { con = (HttpsURLConnection) url.openConnection(); // do stuff.. } catch (IOException | GeneralSecurityException e) { e.printStackTrace(); } finally { con.disconnect(); } try (CloseableURLConnection closeableCon = new CloseableURLConnection(url)) { HttpsURLConnection con = closeableCon.getHttpsConnection(); // do stuff.. } catch (IOException | GeneralSecurityException e) { e.printStackTrace(); } * * *
  • 10. Creating a Closeable Class static class CloseableURLConnection implements AutoCloseable { URLConnection con; public CloseableURLConnection(URL url) throws IOException { con = url.openConnection(); } public HttpsURLConnection getHttpsConnection() { return (HttpsURLConnection)con; } @Override public void close() { getHttpsConnection().disconnect(); } } implement AutoCloseable create a close() method
  • 11. Closeable Classes • Several standard Java classes are now AutoClosable – InputStream – OutputStream – Reader – Writer – java.sql.Connection, Statement, and ResultSet
 • You no longer have to declare your streams outside the try/catch block, or remember to close them when you’re done!
 • Like a finally clause, try-with-resources objects get closed even if an Exception is thrown 11
  • 12. A Few Other Java 7 Goodies • New and/or improved classes – java.nio.file, updated XML libraries, new/enhanced cryptography providers
 • Binary literals and underscores in numeric literals – int byteNum = 0b00100001; – int phoneNum = 555_1212;
 • Type inference for generics – Map<String, List<String>> map = new HashMap<>();
 • Switch statements operate on Strings
 • http://docs.oracle.com/javase/8/docs/technotes/guides/language/enhancements.html 
 http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html
  • 13. And Now: Java 8 on to the good stuff
  • 14. The Code in Java 7… public static void checkSSLCertificate(URL url) { try (CloseableURLConnection closeableCon = new CloseableURLConnection(url)) { HttpsURLConnection con = closeableCon.getHttpsConnection(); con.setSSLSocketFactory( fakeSocketFactory() ); con.setHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; // trust everyone! } }); con.connect(); Certificate[] certs = con.getServerCertificates(); for (Certificate cert : certs) { System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter()); System.out.println( "Server key bit length: " + ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ); } } catch (IOException | GeneralSecurityException e) { e.printStackTrace(); } } anonymous class loop through an array
  • 15. The Code in Java 8 public static void checkSSLCertificate(URL url) { try (CloseableURLConnection closeableCon = new CloseableURLConnection(url)) { HttpsURLConnection con = closeableCon.getHttpsConnection(); con.setSSLSocketFactory( fakeSocketFactory() ); con.setHostnameVerifier( (hostname, session) -> true ); con.connect(); Certificate[] certs = con.getServerCertificates(); Arrays.asList(certs) .stream() .map ( cert -> (X509Certificate)cert ) .peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) ) .map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ) .forEach( i -> System.out.println("Server key bit length: " + i) ); } catch (IOException | GeneralSecurityException e) { e.printStackTrace(); } } lambda hostname verifier read the array as a stream, not a loop
  • 16. What’s a Lambda? • Simplified syntax for writing single-method classes
 • You are effectively passing a function as a parameter to a method 16 con.setHostnameVerifier( (hostname, session) -> true ); (parameters) arrow expression
  • 17. How Does that Lambda Work? con.setHostnameVerifier( new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); con.setHostnameVerifier( (hostname, session) -> true ); ?
  • 18. How Does that Lambda Work? con.setHostnameVerifier( new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); con.setHostnameVerifier( (hostname, session) -> true ); ?
  • 19. How Does that Lambda Work? con.setHostnameVerifier( new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); con.setHostnameVerifier( (hostname, session) -> true ); ?
  • 20. How Does that Lambda Work? con.setHostnameVerifier( new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); con.setHostnameVerifier( (hostname, session) -> true ); ?
  • 21. How Does that Lambda Work? con.setHostnameVerifier( new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); con.setHostnameVerifier( (hostname, session) -> true ); !
  • 22. Functional Interfaces • Lambdas rely on “functional interfaces” to work – an interface with only one abstract method – also called a “single abstract method” or SAM interface – there can be only one! <insert highlander joke here>
 • If there’s only one method, the compiler knows which one you will call
 • If you know the method, and the compiler knows the method, we don’t have to talk about the method – everyone already knows! – skip the obvious stuff 22
  • 23. Functional Interfaces con.setHostnameVerifier( new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); con.setHostnameVerifier( (hostname, session) -> true ); the class MUST be a HostnameVerifier, and the method MUST be verify(String, SSLSession) therefore… throw away everything obvious
  • 24. Lambda Syntax object.method( (param1, param2) -> result ); object.method( param1 -> doStuff(param1) ); object.method( param1 -> doStuff(param1, object) ); object.method( () -> { doStuff(); return doMoreStuff(); } );
  • 25. Method References • There is an alternative syntax called “Method References” – for a lambda that only calls a single method of the parameter, or a single static method that uses the parameter, or creates a single new Object object.method( s -> s.getLength() ); object.method( String::getLength ); http://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html
  • 26. Another Example: Sandwiches! static enum Sandwich { PB_J ("Peanut butter & jelly", 500), SUB ("Sub", 500), HOTDOG ("Hot dog", 900), TACO ("Taco", 500), PIZZA ("Pizza", 900); private String name; private int calories; private Sandwich(String name, int calories) { this.name = name; this.calories = calories; } public String getName() { return name; } public int getCalories() { return calories; } public String toString() { return "n" + calories + " caloriest" + name; } }
  • 27. List the Sandwiches in Order of Calories List<Sandwich> sandwiches = Arrays.asList( Sandwich.values() ); Collections.sort(sandwiches, new Comparator<Sandwich>() { public int compare(Sandwich s1, Sandwich s2) { return Integer.compare(s1.getCalories(), s2.getCalories()); } }); System.out.println(sandwiches); PB_J ("Peanut butter & jelly", 500), SUB ("Sub", 500), HOTDOG ("Hot dog", 900), TACO ("Taco", 500), PIZZA ("Pizza", 900); 500 calories Peanut butter & jelly, 500 calories Sub, 500 calories Taco, 900 calories Hot dog, 900 calories Pizza
  • 28. List the Sandwiches in Order of Calories List<Sandwich> sandwiches = Arrays.asList( Sandwich.values() ); /* Collections.sort(sandwiches, new Comparator<Sandwich>() { public int compare(Sandwich s1, Sandwich s2) { return Integer.compare(s1.getCalories(), s2.getCalories()); } }); */ Collections.sort(sandwiches, (s1, s2) -> Integer.compare(s1.getCalories(), s2.getCalories()) ); System.out.println(sandwiches); PB_J ("Peanut butter & jelly", 500), SUB ("Sub", 500), HOTDOG ("Hot dog", 900), TACO ("Taco", 500), PIZZA ("Pizza", 900); 500 calories Peanut butter & jelly, 500 calories Sub, 500 calories Taco, 900 calories Hot dog, 900 calories Pizza
  • 29. List the Sandwiches in Order of Calories List<Sandwich> sandwiches = Arrays.asList( Sandwich.values() ); /* Collections.sort(sandwiches, new Comparator<Sandwich>() { public int compare(Sandwich s1, Sandwich s2) { return Integer.compare(s1.getCalories(), s2.getCalories()); } }); */ Collections.sort(sandwiches, Comparator.comparing( sandwich -> sandwich.getCalories() ) ); System.out.println(sandwiches); PB_J ("Peanut butter & jelly", 500), SUB ("Sub", 500), HOTDOG ("Hot dog", 900), TACO ("Taco", 500), PIZZA ("Pizza", 900); 500 calories Peanut butter & jelly, 500 calories Sub, 500 calories Taco, 900 calories Hot dog, 900 calories Pizza
  • 30. List the Sandwiches in Order of Calories List<Sandwich> sandwiches = Arrays.asList( Sandwich.values() ); /* Collections.sort(sandwiches, new Comparator<Sandwich>() { public int compare(Sandwich s1, Sandwich s2) { return Integer.compare(s1.getCalories(), s2.getCalories()); } }); */ Collections.sort(sandwiches, Comparator.comparing( Sandwich::getCalories ) ); System.out.println(sandwiches); PB_J ("Peanut butter & jelly", 500), SUB ("Sub", 500), HOTDOG ("Hot dog", 900), TACO ("Taco", 500), PIZZA ("Pizza", 900); 500 calories Peanut butter & jelly, 500 calories Sub, 500 calories Taco, 900 calories Hot dog, 900 calories Pizza
  • 31. All These are the Same Comparator Collections.sort(sandwiches, new Comparator<Sandwich>() { public int compare(Sandwich s1, Sandwich s2) { return Integer.compare(s1.getCalories(), s2.getCalories()); } }); Collections.sort(sandwiches, (s1, s2) -> Integer.compare(s1.getCalories(), s2.getCalories()) ); Collections.sort(sandwiches, Comparator.comparing( sandwich -> sandwich.getCalories() ) ); Collections.sort(sandwiches, Comparator.comparing( Sandwich::getCalories ) );
  • 32. Fun with the Comparator Collections.sort(sandwiches, Comparator.comparing( Sandwich::getCalories ) .thenComparing( Sandwich::getName ) .reversed() ); 900 calories Pizza, 900 calories Hot dog, 500 calories Taco, 500 calories Sub, 500 calories Peanut butter & jelly PB_J ("Peanut butter & jelly", 500), SUB ("Sub", 500), HOTDOG ("Hot dog", 900), TACO ("Taco", 500), PIZZA ("Pizza", 900);
  • 33. But Really, What’s the Point? • This all seems like needless tomfoolery – after all, the old code still works!
 • Two major advantages: 1. Forces (or strongly encourages) you to write functional code 2. Less visual noise makes code easier to read and understand 33 Collections.sort(sandwiches, new Comparator<Sandwich>() { public int compare(Sandwich s1, Sandwich s2) { return Integer.compare(s1.getCalories(), s2.getCalories()); } }); Collections.sort(sandwiches, Comparator.comparing( Sandwich::getCalories ) );
  • 34. Code Should Describe Behavior Code Should Read Like A Story
  • 35. Dealing with Exceptions Collections.sort(sandwiches, Comparator.comparing( Sandwich::getCalories ) .thenComparing( Sandwich::getName ) .reversed() ); NULLWICH (null, 500), PB_J ("Peanut butter & jelly", 500), SUB ("Sub", 500), HOTDOG ("Hot dog", 900), TACO ("Taco", 500), PIZZA ("Pizza", 900); Exception in thread "main" java.lang.NullPointerException at java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469) at java.util.Comparator.lambda$thenComparing$36697e65$1(Comparator.java:217) at java.util.Collections$ReverseComparator2.compare(Collections.java:5178) at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) at java.util.TimSort.sort(TimSort.java:220) at java.util.Arrays.sort(Arrays.java:1438) at java.util.Arrays$ArrayList.sort(Arrays.java:3895) at java.util.Collections.sort(Collections.java:175) at com.panagenda.ssltest.MoreJava8Examples.main(MoreJava8Examples.java:52)
  • 36. Dealing with Exceptions • It’s not always obvious what caused the Exception
 • It’s cumbersome to add a try/catch to a lambda – same with adding logging
 • If an Exception is possible, maybe better to call out to a method instead 36 Collections.sort(sandwiches, Comparator.comparing( sandwich -> getCalories(sandwich) ) .thenComparing( sandwich -> getName(sandwich) ) .reversed() );
  • 37. A Few More Examples // process all the keys and values of a HashMap Map<String, Integer> myHashMap = new HashMap<>(); myHashMap.forEach( (key, value) -> System.out.println(key + "; " + value) ); // remove all the null elements in a List List<String> myArrayList = new ArrayList<>(); myArrayList.removeIf( s -> s == null ); // get all the JPG files in a directory File photoDir = new File("c:/photos"); File[] docFiles = photoDir.listFiles( file -> file.getName().endsWith("jpg") ); // run some code in a thread new Thread( () -> doSomething() ).start();
  • 38. Under the Hood • If you’re really curious about how all this works… – http://cr.openjdk.java.net/~briangoetz/lambda/lambda-translation.html 
 • It’s all Function and Predicate objects – https://docs.oracle.com/javase/8/docs/api/java/util/function/package- summary.html – Closures? By some definitions. 38 Function<Sandwich, Integer> caloryCompare = sandwich -> sandwich.getCalories();
  • 40. From Loop to Stream Certificate[] certs = con.getServerCertificates(); for (Certificate cert : certs) { System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter()); System.out.println( "Server key bit length: " + ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ); } Certificate[] certs = con.getServerCertificates(); Arrays.asList(certs) .stream() .map ( cert -> (X509Certificate)cert ) .peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) ) .map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ) .forEach( i -> System.out.println("Server key bit length: " + i) ); ?
  • 41. What Does that Loop Actually Do? 41 Certificate[] certs = con.getServerCertificates(); for (Certificate cert : certs) { System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter()); System.out.println( "Server key bit length: " + ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ); } print the information get something from the objectprint the information get something from the object
  • 42. How Does the Stream Work? Certificate[] certs = con.getServerCertificates(); Arrays.asList(certs) .stream() .map ( cert -> (X509Certificate)cert ) .peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) ) .map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ) .forEach( i -> System.out.println("Server key bit length: " + i) ); start with an array, convert it to a List convert the List to a stream TIP: this could also be just Arrays.stream(certs) } change the stream do something to each item change the stream do something to each item
  • 43. Breaking Down the Example Certificate[] certs = con.getServerCertificates(); Arrays.asList(certs) .stream() .map ( cert -> (X509Certificate)cert ) .peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) ) .map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ) .forEach( i -> System.out.println("Server key bit length: " + i) ); map() converts each item by casting it to X509Certificate, then returns a Stream of X509Certificate objects map() gets an int value from each item, then returns a Stream of int values start with an array of Certificates
  • 44. Breaking Down the Example Certificate[] certs = con.getServerCertificates(); Arrays.asList(certs) .stream() .map ( cert -> (X509Certificate)cert ) .peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) ) .map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ) .forEach( i -> System.out.println("Server key bit length: " + i) ); peek() is an intermediate operation: it does something with each item and returns the original Stream forEach() is a terminal operation: it does something with each item and stops
  • 45. What’s a Stream? • Allows you to perform operations on a collection of data – multiple operations can be combined in a pipeline
 
 • Has the following properties – uses functional arguments (lambdas!) to process data – does not store data – pipeline operations are optimized for laziness – optionally process in parallel (multi-threaded) with no extra code 45
  • 46. Is a Stream Better than a Loop? Certificate[] certs = con.getServerCertificates(); for (Certificate cert : certs) { System.out.println( "Valid until: " + ((X509Certificate)cert).getNotAfter()); System.out.println( "Server key bit length: " + ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ); } Certificate[] certs = con.getServerCertificates(); Arrays.asList(certs) .stream() .map ( cert -> (X509Certificate)cert ) .peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) ) .map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ) .forEach( i -> System.out.println("Server key bit length: " + i) ); !Stream version is more descriptive of the behavior of the code Stream version can easily be turned into multi-threaded code
  • 47. Multi-threaded You Say? Arrays.asList(certs) .stream() .parallel() .map ( cert -> (X509Certificate)cert ) .peek( cert -> System.out.println("Valid until: " + cert.getNotAfter()) ) .map ( cert -> ((RSAPublicKey)cert.getPublicKey()).getModulus().bitLength() ) .forEach( i -> System.out.println("Server key bit length: " + i) ); DANGER: The forEach() and peek() output might be out-of-order!
  • 48. Adding Numbers in a Loop 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 45 int sum = 0; for (int i : new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9}) { sum += i; } return sum;
  • 49. Adding Numbers with Reduce 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 1 + 2 3 + 4 + 5 6 + 8 7 + 9 3 + 14 12 + 16 45
  • 50. Adding Numbers with Reduce 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 1 + 2 3 + 4 + 5 6 + 8 7 + 9 3 + 14 12 + 16 45 By abstracting away the very concept of looping, you can implement looping any way you want, including implementing it in a way that scales nicely with extra hardware. Joel Spolsky https://www.joelonsoftware.com/2006/08/01/ can-your-programming-language-do-this each computation could be on a separate processor core… or a separate machine!
  • 51. Other Things to Know About Streams • Normally get them from Collections or arrays – List.stream(), Map.entrySet().stream(), Arrays.stream(Object[]) – also other fun places, like BufferedReader.lines() or Files.list()
 
 • Some operations will short circuit instead of processing each item – built-in optimizations
 
 • Stream operations should be stateless – for example, don’t update Lists as part of a stream operation – items could process out of order, and might not be thread-safe – collect the results at the end instead 51
  • 52. Other Things to Know About Streams • Operations on Streams should be associative when possible – (a + b + c) == (c + b + a) == b + (a + c) – if order of operations does matter, make sure you: • start with an ordered set of data, like a List • use forEachOrdered() instead of forEach() • don’t use reduce() 
 
 • For reference: – https://docs.oracle.com/javase/8/docs/api/java/util/stream/package- summary.html 52
  • 53. Under the Hood • If you’re really curious about how all this works… – http://www.ibm.com/developerworks/java/library/j-java-streams-1-brian- goetz 
 • Read about java.util.function – https://docs.oracle.com/javase/8/docs/api/java/util/function/package- summary.html – Predicate, Consumer, and Supplier interfaces 53
  • 54. Backwards Compatibility because not all of us have a choice
  • 55. Java 8 API Changes (partial list) • Streams – in its own package – throughout Collections, Files, etc.
 • Functional classes in java.util.function
 • Brand new Date-Time package and classes – http://docs.oracle.com/javase/tutorial/datetime 
 • JavaFX for GUIs
 • http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html 
 http://docs.oracle.com/javase/8/docs/technotes/guides/language/lambda_api_jdk8.html 55 Function<Sandwich, Integer> caloryCompare = sandwich -> sandwich.getCalories();
  • 56. Compiling to Earlier Versions • Java can compile for previous versions, but… – you can’t use any of the new APIs (classes or methods) – you can’t use any of the new language features
 
 • What happens if you use a Java 8 JAR in a Java 6 environment? – it won’t work – the JRE checks the JAR file for a version number first – if the version number is too high, you get errors
 
 • Some tools can convert bytecode to earlier versions – but new APIs still won’t work 56
  • 57. Options for Backwards Compatibility • If you don’t want to use new language features at all – set “Source compatibility” and “Generated .class files compatibility” to your desired older Java version – use a tool to make sure you didn’t use new APIs
 Animal Sniffer: http://www.mojohaus.org/animal-sniffer 
 57
  • 58. Options for Backwards Compatibility • If you only want to use lambdas and try-with-resources – compile as Java 8, then use RetroLambda to backport your JAR file 
 https://github.com/orfjackal/retrolambda – you still have to make sure you didn’t use new APIs: AnimalSniffer again
 
 • You might be able to backport Streams too (mixed results) – http://sourceforge.net/projects/streamsupport 58
  • 59. Is It Worth It? • Backporting? Maybe, but probably not regularly – Risky: even if it seems to work, hard to test if it really worked – make sure you have great unit tests to run against the backported code
 
 • Learning? Absolutely! – even if you can’t use Java 8 now, you will later – functional programming can be much “safer” – teaches you good coding habits – helps you understand code examples on StackOverflow ;) 59
  • 60. Required Reading we only scratched the surface
  • 61. On the Oracle Website • Streams – https://docs.oracle.com/javase/8/docs/api/java/util/stream/package- summary.html – http://www.oracle.com/technetwork/articles/java/ma14-java-se-8- streams-2177646.html 
 • Lambdas – https://docs.oracle.com/javase/tutorial/java/javaOO/ lambdaexpressions.html – http://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html – https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.27 61
  • 62. Articles and Musings • State of the lambda (Brian Goetz) – http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-final.html 
 • IBM DeveloperWorks articles by Brian Goetz – http://www.ibm.com/developerworks/java/library/j-java-streams-1-brian-goetz – http://www.ibm.com/developerworks/java/library/j-java-streams-2-brian-goetz – http://www.ibm.com/developerworks/java/library/j-java-streams-3-brian-goetz – http://www.ibm.com/developerworks/java/library/j-java-streams-4-brian-goetz – http://www.ibm.com/developerworks/java/library/j-java-streams-5-brian-goetz
 • Joel Spolsky on MapReduce – https://www.joelonsoftware.com/2006/08/01/can-your-programming-language- do-this 62
  • 63. Books (!) • Java 8 in Action – Raoul-Gabriel Urma
 Manning Press • Mastering Lambdas: Java Programming in a Multicore World – Maurice Naftalin
 Oracle Press
  • 64. Notices and disclaimers Copyright © 2017 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in any form without written permission from IBM. U.S. Government Users Restricted Rights — Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM. Information in these presentations (including information relating to products that have not yet been announced by IBM) has been reviewed for accuracy as of the date of initial publication and could include unintentional technical or typographical errors. IBM shall have no responsibility to update this information. THIS DOCUMENT IS DISTRIBUTED "AS IS" WITHOUT ANY WARRANTY, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL IBM BE LIABLE FOR ANY DAMAGE ARISING FROM THE USE OF THIS INFORMATION, INCLUDING BUT NOT LIMITED TO, LOSS OF DATA, BUSINESS INTERRUPTION, LOSS OF PROFIT OR LOSS OF OPPORTUNITY. IBM products and services are warranted according to the terms and conditions of the agreements under which they are provided. IBM products are manufactured from new parts or new and used parts. In some cases, a product may not be new and may have been previously installed. Regardless, our warranty terms apply.” Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice. Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual performance, cost, savings or other results in other operating environments may vary. References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs or services available in all countries in which IBM operates or does business. Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily reflect the views of IBM. All materials and discussions are provided for informational purposes only, and are neither intended to, nor shall constitute legal or other guidance or advice to any individual participant or their specific situation. It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel as to the identification and interpretation of any relevant laws and regulatory requirements that may affect the customer’s business and any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or represent or warrant that its services or products will ensure that the customer is in compliance with any law 64
  • 65. Notices and disclaimers continued Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products in connection with this publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to interoperate with IBM’s products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The provision of the information contained herein is not intended to, and does not, grant any right or license under any IBM patents, copyrights, trademarks or other intellectual property right. IBM, the IBM logo, ibm.com, Aspera®, Bluemix, Blueworks Live, CICS, Clearcase, Cognos®, DOORS®, Emptoris®, Enterprise Document Management System™, FASP®, FileNet®, Global Business Services ®, Global Technology Services ®, IBM ExperienceOne™, IBM SmartCloud®, IBM Social Business®, Information on Demand, ILOG, Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™, PureApplication®, pureCluster™, PureCoverage®, PureData®, PureExperience®, PureFlex®, pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, Smarter Commerce®, SoDA, SPSS, Sterling Commerce®, StoredIQ, Tealeaf®, Tivoli®, Trusteer®, Unica®, urban{code}®, Watson, WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml. 65