Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer)...

48
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Transcript of Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer)...

Page 1: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Lambda-izing JavaFX

Steve Northover (Client Architect)Felipe Heidrich (Senior Software Developer)Java Client GroupOct, 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Page 2: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 2

Safe Harbor StatementThe following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Page 3: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 3

Program Agenda

About Lambda

The Tooling

Lambda-ize It!

Interesting Problems

Conclusions

1

2

3

4

5

Page 4: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 4

A Very Short History of Lambda• A Lambda is an “anonymous function” (*)• In computer programming, an anonymous function (also function

literal or lambda abstraction) is a function definition that is not bound to an identifier• Lambda originated in the work of Alonzo Church, the inventor of the

lambda calculus in 1936• Anonymous functions have been a feature of programming languages

since Lisp in 1958

(*) http://en.wikipedia.org/wiki/Anonymous_function

Page 5: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 5

Lambda in Programming Languages• Lisp – 1958 (lambdas are fundamental)• Smalltalk – 1980 (blocks became lambdas)• JavaScript – 1995 (lambda fundamental, “created in 10 days”)• C# - 2007 (C# 3.0, lambda can be used instead of delegates)• Objective-C – 2009 (non-standard Apple extension)• C/C++ - 2011 (part of C++11)• Java – 2014 – (part of JDK8, inner classes debut in JDK1.1 in 1997)

Hey Java, what took you so long?

Page 6: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 6

Conspiracy Theories?• Lambda is an anagram for:–“Lamb Ad”–“Bald Ma”–“Da Balm”–“Mad Lab”

Page 7: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 7

Are Java Lambdas full lexical closures?• Implementing lexical closures requires that the lifetime of some local

variables can extend beyond the return of the declaring method• Lexical closures trap their enclosing environment and make a “shallow

copy” of local variables for each different lambda instance• Variables trapped within the lambda environment are mutable

In Java, variables referenced outside of a lambda must be “effectively final”

Page 8: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 8

JavaScript versus Java Lambdafunction newGen(array) {

var index = 0; // used in the function

return function () {

return array[index++ % array.length];

};

}

var g1 = newGen([3, 12, 45, 6, 90, 1]);

alert(g1.call() + " " + g1.call());

static Gen newGen(int [] array) {

return new Gen () {

int index; // used in the function

public int next() {

return array[index++ % array.length];

}

};

}

Page 9: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 9

The Java Lambda Versionstatic Gen newGen(int [] array) {

int [] index = new int [1]; // used in the function

return () -> array[index[0]++ % array.length];

}

Why can’t the compiler do this for me?

Page 10: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 10

Are Lambdas the same as inner classes?• Different state restrictions– Lambdas do not have mutable local state (i.e. fields)

• Different scoping and visibility rules– Lambdas have a different “this”– Lambdas do not support variable shadowing

• Different implementation– Lambdas do not instantiate a name mangled class from a jar– Different implementation can mean different runtime behavior

Page 11: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Oracle Confidential – Internal/Restricted/Highly RestrictedCopyright © 2014, Oracle and/or its affiliates. All rights reserved.

The ToolingLambda Chop’s Play Along

Page 12: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 12

Overview of the Tooling• Lambda-fiers are built into three different IDEs– IntelliJ, Eclipse and NetBeans–We used all three depending on the output

• At first, finding the lambda-fier was not obvious– Each IDE use different naming for the refactoring

• JavaFX is a good test case for the tooling– lots of code, hairy generics, classes in classes etc.

Page 13: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 13

The Good, the Bad and the Ugly• Good Things– Easy to use, easy to browse results– Easy to find and fix problems(red squiggles)– Better than doing it by hand

• Bad and Ugly Things– Lambda-fication was manual (no command line)– All of the IDEs have lambda-fier bugs (*)

(*) Most of these bugs have been fixed

Page 14: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 14

IntelliJ

Page 15: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 15

IntelliJ

Page 16: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 16

IntelliJ

Page 17: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 17

Eclipse and NetBeans• Same idea, similar UI, similar behavior, similar problems• Eclipse– Source->Clean Up…, ‘Use Lambda where possible’

• NetBeans– Inspect and Transform, ‘Convert to lambda or Member Reference’

Page 18: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 18

We reported the bugs we found• http://youtrack.jetbrains.com/issue/IDEA-119936• http://youtrack.jetbrains.com/issue/IDEA-120096• http://youtrack.jetbrains.com/issue/IDEA-120699• http://youtrack.jetbrains.com/issue/IDEA-120698• https://bugs.eclipse.org/bugs/show_bug.cgi?id=428694• https://bugs.eclipse.org/bugs/show_bug.cgi?id=428694• … and a few more

Page 19: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Oracle Confidential – Internal/Restricted/Highly RestrictedCopyright © 2014, Oracle and/or its affiliates. All rights reserved.

Lambda-fy It!The Lambda Lies Down on Broadway

Page 20: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 20

The Restrictions that we had• Distributed team– Can’t and don’t want to stop the world

• Component ownership– Component owners are responsible for code cleanliness

• Lambda only (no stream conversions)– Ports of OpenJFX to Android and iOS don’t use JDK8 class libraries– Streams are used freely in platform specific Java code (ie. Glass)

Page 21: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 21

The Approach that we used• Components lambda-ized one at a time– Use “best” lambda-izer, fix trivial errors, revert entire files

• Component owners notified that changes are coming• All tests must pass before moving to the next component• Communication through JIRA and the mailing list– https://javafx-jira.kenai.com/browse/RT-35197

Page 22: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 22

The Problems that we found• Compile errors– Bugs in the lambda-fier (found and fixed easily)

• Semantic errors– Found and fixed by unit tests, (in)sanity testing, etc.–Often quickly understood by examining the code

• Runtime errors – Found the same way as semantic errors (must run the code)– Differences in the implementation of lambdas versus inner classes– Bugs in the compiler

Page 23: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Oracle Confidential – Internal/Restricted/Highly RestrictedCopyright © 2014, Oracle and/or its affiliates. All rights reserved.

Interesting ProblemsLike lambdas to the slaughter …

Page 24: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 24

Compile Error: Forward ReferenceRunnable r = new Runnable() {

public void run() {

Math.max(x, 13);

}

};

int x = 12; // this is a field

Runnable r = () -> {

Math.max(x, 13);

};

int x = 12; // this is a field

Page 25: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 25

The Fix: Use “this” to reference the varaible Runnable r = () -> {

Math.max(this.x, 13);

};

int x = 12; // this is a field

Why can’t the compiler do this for me?

Page 26: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 26

Compile Error: Variable Shadowingint z = 12; // this is a local

Function<Integer,Integer> z2 =

new Function<Integer,Integer> () {

public Integer apply(Integer z) {

return z + 1;

}

};

int z = 12; // this is a local

Function<Integer,Integer> z2 =

z -> z + 1;

Page 27: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 27

The Fix: Rename the Variableint z = 12; // this is a local

Function<Integer,Integer> z2 =

z1 -> z1 + 1;

Why is shadowing of local variables disallowedwhile shadowing of fields is not?

Page 28: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 28

Compile Error: Ambiguous Methodreturn AccessController.doPrivileged(

new PrivilegedAction<Integer>() {

public Integer run() {

return 12;

}

});

return AccessController.doPrivileged(

() -> 12

);

NOTE: There are multiple different doPrivileged() methods

Page 29: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 29

The Fix: Cast the Argument return AccessController.doPrivileged(

(PrivilegedAction<Integer>) () -> 12

);

Easy fix: All the lambda-fiers now get this one right now!

Page 30: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 30

Semantic Error: Wrong Exception ThrownCallback cb = new

Callback<String,Integer>() {

public Integer call(String param) {

throw new Error(“Explode!");

}

};

cb.call(12);

Callback cb = param -> {

throw new Error(“Explode!");

};

cb.call(12);

Page 31: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 31

The Fix: Cast the ArgumentCallback cb = (Callback<String, Integer>) param -> {

throw new Error(“Explode!");

};

cb.call(12);

The class cast exception is correctly thrown

Page 32: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 32

Semantic Error: What is the meaning of “this”?Runnable last; // this is a field

Runnable newRunnable() {

return last = new Runnable () {

public void run () {

if (this == last) {

System.out.println("Last");

}

}

};

}

Runnable last; // this is a field

Runnable newRunnable() {

return last = () -> {

if (this == last) {

System.out.println("Last");

}

};

}

Page 33: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 33

The Fix: Do not Lambda-ify• “this” is not the lambda object inside the lambda body• Most of the time, the wrong “this” will cause a compile error• Methods such as == compile without error

The lambda-fiers don’t get this wrong, so you shouldn’t either

Page 34: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 34

Runtime Error: An Unexpected Hangstatic {

CountDownLatch latch = new CountDownLatch(1);

new Thread(new Runnable() {

public void run() {

latch.countDown();

}

}).start();

try {

latch.await();

} catch (InterruptedException ex) {}

}

static {

CountDownLatch latch = new CountDownLatch(1);

new Thread(() -> {

latch.countDown();

}).start();

try {

latch.await();

} catch (InterruptedException ex) {}

}

Page 35: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 35

The Problem: Class Initialization Deadlock• Caused by the implementation of Lambda– The body of a lambda is compiled into a private method in the class– The lambda is called from the call site using a lambda factory

• The private lambda method causes a circular reference

static { … new Thread(() -> {

latch.countDown(); // private static synthetic void lambda$static$2

}).start();

Page 36: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 36

Runtime Error: A JDK Compiler Bug (Already Fixed)Supplier<Integer> s1 = new

Supplier<Integer>() {

public Integer get(Integer t) {

return t++;

}

};

System.out.println(s1.get(2)); //2

System.out.println(s1.get(2)); //2

Supplier<Integer> s2 = t -> t++;

System.out.println(s1.get(2)); //3

System.out.println(s1.get(2)); //3

Page 37: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Oracle Confidential – Internal/Restricted/Highly RestrictedCopyright © 2014, Oracle and/or its affiliates. All rights reserved.

ConclusionsThe Silence of the Lambdas

Page 38: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 38

Some Statistics• Jar Size: Lambda vs. Inner Classes– 9,035,812 bytes (9 MB on disk)– 9,789,587 bytes (9.8 MB on disk)

• Code Size: Lambda vs. Inner Classes– 1272259 Lines of Code– 1237531 Lines of Code

8.16% Smaller Jar

2.27%Less Code

Page 39: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 39

Conclusion• Lambdas and inner classes are almost interchangeable• Lambda conversion is 99% automatic– No single IDE lambda-izer gets it right – There are a very few subtle edge cases

• Lambda-fication is worth the effort– Increases code readability and reduces complexity– Significant reduction in jar size

Page 40: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 40

Safe Harbor StatementThe preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Page 41: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.
Page 42: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Oracle Confidential – Internal/Restricted/Highly RestrictedCopyright © 2014, Oracle and/or its affiliates. All rights reserved.

Page 43: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 43

Some Statistics• Jar Size: Lambda vs. Inner Classes– 9,035,812 bytes (9 MB on disk)– 9,789,587 bytes (9.8 MB on disk)

• Code Size: Lambda vs. Inner Classes– 1272259 Lines of Code– 1237531 Lines of Code

8.16% Smaller Jar

2.27%Less Code

Page 44: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 44

Title and Content Layout Line 1Title and Content Layout Line 2• First-level bulleted text is Calibri 28 pt– Second-level text (press tab key) is 24 pt• Third-level text (press tab key) is 20 pt– Fourth-level text (press tab key) is 18 pt

• Calibri is the only font used in the template• All bulleted text is sentence case (capitalize first letter of first word)• Use bold, blue, or both to highlight ONLY KEY text

Page 45: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 45

IntelliJ• Some bugs:– Declaration order (field must be declared before used in lambda)– Variable shadowing (parameter names must not shadow fields)• Bugs around renaming (ie. “e becomes e1 but not all places changed)

– A few strange edge cases (Mapping Change, ObservableListWrapper)

Page 46: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 46

Eclipse• Some bugs:– Choosing the correct method when overloaded (ie. doPrivileged())• Requires a “cast” to show return type (ie. (PrivilegedAction<Boolean>)()-> …)

– Declaration order (field must be declared before used in lambda)– Variable shadowing (parameter names must not shadow fields)• Bugs around renaming (ie. “e becomes e1 but not all places changed)

–More strange edge cases (Mapping Change, ObservableListWrapper)

Page 47: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 47

NetBeans• Some bugs:– Ambiguous :: (ie. Integer.toString() or Integer::toString(int)?)– Classes inside other classes (SetChangeListener.Change became Change)– Declaration order (field must be declared before used in lambda)– Variable shadowing (parameter names must not shadow fields)

Page 48: Lambda-izing JavaFX Steve Northover (Client Architect) Felipe Heidrich (Senior Software Developer) Java Client Group Oct, 2014 Copyright © 2014, Oracle.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted 48

Conspiracy Theories• Lambda is an anagram for:– “Bald Ma”– “Da Balm”– “Mad Lab”