Java jdk-update-nov10-sde-v3m

Preview:

DESCRIPTION

Jd

Citation preview

<Insert Picture Here>

Java SE UpdateSteve Elliott – Oracle UKsteve.elliott@oracle.comNovember 2010

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.

3

4

5

?

6

ProductivityPerformanceUniversalityModularityIntegration

Servicability

7

Project CoinProject Lambda

The DaVinci MachineProject Jigsaw

JVM ConvergenceRoadmap

ProductivityPerformanceUniversalityModularityIntegration

Servicability

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

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

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

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

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;

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:...

14

• Pre generics

List strList = new ArrayList();

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>>();

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<>();

17

Copying Streams

18

19

20

Try-with-resources(Automatic Resource Management)

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

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

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

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;

}

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();

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();

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

28

29

30

31

32

Hotspot Optimisations

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

34

Problems

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

• Performance– Download time– Startup time

• Platform scalability– Down to small devices

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

36

Modularity

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

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

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;

}

39

module-info.java

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

}

Encapsulating modules

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

41

42

OSGi ?

Java SE 8 JSR :

43

JVM

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

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

46

47

JRockit Mission Control

48

Roadmap

49

http://blogs.sun.com/mr

50

51

52

GPLv2+ Classpath Exception

53

54

jcp.org : JSR 336 – Java SE 7

55

jcp.org : JSR 337 – Java SE 8

56

JDK 7 Schedule

57

58

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

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

60

Thank You!

Q&A