Transcript
Page 1: Java jdk-update-nov10-sde-v3m

<Insert Picture Here>

Java SE UpdateSteve Elliott – Oracle [email protected] 2010

Page 2: Java jdk-update-nov10-sde-v3m

2

The 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: Java jdk-update-nov10-sde-v3m

3

Page 4: Java jdk-update-nov10-sde-v3m

4

Page 5: Java jdk-update-nov10-sde-v3m

5

?

Page 6: Java jdk-update-nov10-sde-v3m

6

ProductivityPerformanceUniversalityModularityIntegration

Servicability

Page 7: Java jdk-update-nov10-sde-v3m

7

Project CoinProject Lambda

The DaVinci MachineProject Jigsaw

JVM ConvergenceRoadmap

ProductivityPerformanceUniversalityModularityIntegration

Servicability

Page 8: Java jdk-update-nov10-sde-v3m

8

Project CoinSmall (Language) Changesopenjdk.java.net/projects/coin

● Diamond● Try-with-resources● Improved integral Literals● Strings in switch● Varargs warnings● Multi-catch & precise rethrow

● Joe Darcy - http://blogs.sun.com/darcy

coin, n. A piece of small changecoin, v. To create a new language

Page 9: Java jdk-update-nov10-sde-v3m

9

Evolving the LanguageFrom “Evolving the Java Language” - JavaOne 2005

• Java language principles– Reading is more important than writing

– Code should be a joy to read

– The language should not hide what is happening

– Code should do what it seems to do

– Simplicity matters

– Every “good” feature adds more “bad” weight

– Sometimes it is best to leave things out

• One language: with the same meaning everywhere– No dialects

Also see “Growing a Language” - Guy Steele 1999

Page 10: Java jdk-update-nov10-sde-v3m

10

Evolving the LanguageFrom “Evolving the Java Language” - JavaOne 2005

• We will evolve the Java Language- but cautiously, with a long term view

– We want Java to be around in 2030– We can't take a slash and burn approach– “first do no harm”

• We will add a few select features periodically– Aimed at developer productivity– While preserving clarity and simplicity

Page 11: Java jdk-update-nov10-sde-v3m

11

Project Coin Constraints

• Small language changes– Small in specification, implementation, testing– No new keywords!– Wary of type system changes

• Coordinate with larger language changes– Project Lambda– Modularity

• One language, one javac

Page 12: Java jdk-update-nov10-sde-v3m

12

Better Integer Literal

• Binary literals

• With underscores for clarity

int mask = 0b101010101010;

int mask = 0b1010_1010_1010;long big = 9_223_783_036_967_937L;

Page 13: Java jdk-update-nov10-sde-v3m

13

String in Switch

int monthNameToDays(String s, int year) {switch(s) {

case "April": case "June":case "September": case "November":

return 30;

case "January": case "March":case "May": case "July":case "August": case "December":

return 31;

case "February":...

default:...

Page 14: Java jdk-update-nov10-sde-v3m

14

• Pre generics

List strList = new ArrayList();

Page 15: Java jdk-update-nov10-sde-v3m

15

• Pre generics

• With generics

List strList = new ArrayList();

List<String> strList = new ArrayList<String>();

List<Map<String, List<String>> strList =new ArrayList<Map<String, List<String>>();

Page 16: Java jdk-update-nov10-sde-v3m

16

Diamond

• Pre generics

• With generics

• With diamond (<>) to infer the type

List strList = new ArrayList();

List<String> strList = new ArrayList<String>();

List<Map<String, List<String>> strList =new ArrayList<Map<String, List<String>>();

List<String> strList = new ArrayList<>();

List<Map<String, List<String>> strList =new ArrayList<>();

Page 17: Java jdk-update-nov10-sde-v3m

17

Copying Streams

Page 18: Java jdk-update-nov10-sde-v3m

18

Page 19: Java jdk-update-nov10-sde-v3m

19

Page 20: Java jdk-update-nov10-sde-v3m

20

Try-with-resources(Automatic Resource Management)

Page 21: Java jdk-update-nov10-sde-v3m

21

Project LambdaClosures and moreopenjdk.java.net/projects/lambda

● Lambda expressions● SAM conversion with target typing● Method references● Library enhancements for internal iteration● Default methods for interface evolution

● Brian Goetz - @BrianGoetz● Alex Buckley - http://blogs.sun.com/abuckley

Page 22: Java jdk-update-nov10-sde-v3m

22

Motivation for Lambda Project

• Moore's law, multi core chip• Library is one of Java's key

strength– Better libraries are key to making

parallelization better

• Higher level operations tend to improve readability of code as well as performance

• Without more language support for parallel idioms, people will instinctively reach for serial idioms

Page 23: Java jdk-update-nov10-sde-v3m

23

UltraSPARC T1

( Niagara 1 (2005) )

8 x 4 = 32

UltraSPARC T2

( Niagara 2 (2007) )

8 x 8 = 64

UltraSPARC T3

( Rainbow Falls )

16 x 8 = 128

Page 24: Java jdk-update-nov10-sde-v3m

24

For loop – External Iteration

• Code is inherently serial– Iterate through students serially– Stateful – use of > and highestScore– External iteration – client of students determines iteration

mechanism

double highestScore = 0.0;for (Student s : students) {if ((s.gradYear == 2010)

&& (s.score > highestScore))highestScore = s.score;

}

Page 25: Java jdk-update-nov10-sde-v3m

25

Hypothetical Internal Iteration

• Not inherently serial– students traversal not determined by developer– Looks like a functional language

• Anonymous inner class!

double highestScore = students.filter(new Predicate<Student>() {

public boolean isTrue(Student s) {return s.gradYear == 2010;

}}).map(new Extractor<Student,Double>() {

public Double extract(Student s) {return s.score;

}}).max();

Page 26: Java jdk-update-nov10-sde-v3m

26

Introducing Lambda Expressions

• Lambda expressions introduced with #– Signal to the JVM to defer execution of the code– Body may be an expression

• Lambda expression are not syntactic sugar for anonymous inner class – Implemented with MethodHandle from JSR-292

double highestScore = students.filter(#{ Student s -> s.gradYear == 2010 }).map(#{ Student s -> s.score }).max();

Page 27: Java jdk-update-nov10-sde-v3m

27

The DaVinci Machine ProjectJSR 292A multi-language renaissance for the JVMopenjdk.java.net/projects/mlvm

● Dynamic Invocation- InvokeDynamic bytecode

● Method Handles

● Tail Calls● Tuples● Continuations● Interface Injection ...● John Rose -

http://blogs.sun.com/jrose

Page 28: Java jdk-update-nov10-sde-v3m

28

Page 29: Java jdk-update-nov10-sde-v3m

29

Page 30: Java jdk-update-nov10-sde-v3m

30

Page 31: Java jdk-update-nov10-sde-v3m

31

Page 32: Java jdk-update-nov10-sde-v3m

32

Hotspot Optimisations

Page 33: Java jdk-update-nov10-sde-v3m

33

Project JigsawModularity in the Java platformopenjdk.java.net/projects/jigsaw

● Module System for JDK

● Mark Reinholdhttp://blogs.sun.com/mr

● Alex Buckleyhttp://blogs.sun.com/abuckley

Page 34: Java jdk-update-nov10-sde-v3m

34

Problems

• Application construction, packaging and publication – “JAR Hell”

• Performance– Download time– Startup time

• Platform scalability– Down to small devices

Page 35: Java jdk-update-nov10-sde-v3m

35

Solution – The Modular Java Platform

• Enables escape from “JAR Hell”– Eliminates class path

– Package modules for automatic download & install

– Generate native packages – deb, rpm, ips, etc

• Enables significant performance improvements– Incremental download → fast classloading– Optimise module content during installation

• Platform scalability – down to small devices– Well-specified SE subsets can fit into small devices

Page 36: Java jdk-update-nov10-sde-v3m

36

Modularity

• Grouping• Dependencies• Versioning• Encapsulation• Optional modules• Virtual modules

Page 37: Java jdk-update-nov10-sde-v3m

37

module-info.java

module com.foo @ 1.0.0 {class com.foo.app.Mainrequires org.bar.lib @ 2.1-alpha;requires edu.baz.util @ 5.2_11;provides com.foo.app.lib @ 1.0.0;

}

Module name

VersionEntry point

Dependency

Virtual module

Page 38: Java jdk-update-nov10-sde-v3m

38

module-info.java

Optional modules

module com.foo @ 1.0.0 {class com.foo.app.Mainrequires org.bar.lib @ 2.1-alpha;requires edu.baz.util @ 5.2_11;provides com.foo.app.lib @ 1.0.0;requires optional com.foo.extra;

}

Page 39: Java jdk-update-nov10-sde-v3m

39

module-info.java

module com.foo.secret @ 1 {permits com.foo.lib;

}

Encapsulating modules

Page 40: Java jdk-update-nov10-sde-v3m

40

Packaging Modules

• Compiling

• Packaging – supports native package format

• Create and install libraries

• Link a repository to library

• Execute

javac -modulepath mods src/com/foo/...

jpkg -modulepath mods jmod com.foo.app ...jpkg -modulepath mods debs com.foo.app ...

jmod -L mlib createjmod -L mlib install *.jmod

java -L mlib -m com.foo.app

jmod add-repo http://jig.sfbay

Page 41: Java jdk-update-nov10-sde-v3m

41

Page 42: Java jdk-update-nov10-sde-v3m

42

OSGi ?

Java SE 8 JSR :

Page 43: Java jdk-update-nov10-sde-v3m

43

JVM

Page 44: Java jdk-update-nov10-sde-v3m

44

JVM Convergence● Two mainstream JVMs● HotSpot

● Versatile (client and server), market share leader, high quality and performance

● JRockit● Specialized for the Oracle server stack, basis of value-adds

like Mission Control, Virtual Edition and Soft Real-Time● Wasteful to continue development on both, so● Goal: Single JVM incorporating best features

Page 45: Java jdk-update-nov10-sde-v3m

45

JVM Convergence

● More engineers working on HotSpot so..● Converged JVM based on HotSpot with all goodness from JRockit● Open-sourced via OpenJDK

● Some value-add such as Mission Control will remain proprietary● Free binary download includes closed source goodies

● Same use license as before● Oracle committed to continued investment

● JVM teams have been merged, working on feature transfer● And moving forward on new projects

● Will be a multi-year process

Page 46: Java jdk-update-nov10-sde-v3m

46

Page 47: Java jdk-update-nov10-sde-v3m

47

JRockit Mission Control

Page 48: Java jdk-update-nov10-sde-v3m

48

Roadmap

Page 49: Java jdk-update-nov10-sde-v3m

49

http://blogs.sun.com/mr

Page 50: Java jdk-update-nov10-sde-v3m

50

Page 51: Java jdk-update-nov10-sde-v3m

51

Page 52: Java jdk-update-nov10-sde-v3m

52

GPLv2+ Classpath Exception

Page 53: Java jdk-update-nov10-sde-v3m

53

Page 54: Java jdk-update-nov10-sde-v3m

54

jcp.org : JSR 336 – Java SE 7

Page 55: Java jdk-update-nov10-sde-v3m

55

jcp.org : JSR 337 – Java SE 8

Page 56: Java jdk-update-nov10-sde-v3m

56

JDK 7 Schedule

Page 57: Java jdk-update-nov10-sde-v3m

57

Page 58: Java jdk-update-nov10-sde-v3m

58

openjdk.java.net/projects/jdk7download.java.net/jdk7

Page 59: Java jdk-update-nov10-sde-v3m

59

(Some) More...

Mark Reinhold http://blogs.sun.com/mr ( @mreinhold )

Henrik Stahl http://blogs.oracle.com/henrik

Dalobor Topic http://robilad.livejournal.com ( @robilad )

Open JDK http://openjdk.java.net ( /projects/jdk7 ) ( @openjdk )

OTN http://www.oracle.com/technetwork/java ( @oracletechnet )

JavaOne 2010 http://www.oracle.com/us/javaonedevelop

Page 60: Java jdk-update-nov10-sde-v3m

60

Thank You!

Q&A