<Insert Picture Here>The Future of the Java Platform:Java SE 7 & Java SE 8Terrence BarrSenior Technologist, Mobile & Embed...
The preceding is intended to outline our generalproduct direction. It is intended for informationpurposes only, and may no...
Agenda   Small(Language)     Project Coin (JSR 334) ChangesProject Coin               Small Language Changes              ...
Evolving the LanguageFrom “Evolving the Java Language” - JavaOne 2005• Java language principles  –   Reading is more impor...
Java Standard Edition (Java SE) vs. Java Development Kit (JDK)• Java SE                        • Java Development Kit  • D...
Java SE 7            6            6
SmallSection Divider                          <Insert Picture Here>    (Language)     Changes           Project Coin      ...
Project Coin Constraints• Small   language changes   • Small in specification, implementation, testing   • No new keywords...
Better Integer Literal• Binary literals  int mask = 0b101010101010;• With underscores for clarity  int mask = 0b1010_1010_...
String Switch Statement• Today case label includes integer constants and  enum constants• Strings are constants too (immut...
Discriminating Strings Todayint monthNameToDays(String s, int year) {  if("April".equals(s) || "June".equals(s) ||       "...
Strings in Switchint monthNameToDays(String s, int year) {  switch(s) {    case "April": case "June":    case "September":...
Simplifying Generics• Pre-generics  List strList = new ArrayList();                                    13                 ...
Simplifying Generics• Pre-generics  List strList = new ArrayList();• With GenericsList<String> strList = new ArrayList<Str...
Simplifying Generics• Pre-generics  List strList = new ArrayList();• With Generics List<String> strList = new ArrayList<St...
Diamond Operator• Pre-generics  List strList = new ArrayList();• With Generics List<String> strList = new ArrayList<String...
Simplifying Resource UseInputStream in = new FileInputStream(src);OutputStream out = new FileOutputStream(dest);byte[] buf...
Simplifying Resource UseInputStream in = new FileInputStream(src);OutputStream out = new FileOutputStream(dest);try {  byt...
Simplifying Resource UseInputStream in = new FileInputStream(src);try {  OutputStream out = new FileOutputStream(dest);  t...
Automatic Resource Managementtry (InputStream in = new FileInputStream(src),     OutputStream out = new FileOutputStream(d...
Exceptions Galoretry {  ...} catch(ClassNotFoundException cnfe) {  doSomething(cnfe);  throw cnfe;} catch(InstantiationExc...
Multi-Catchtry {  // Reflective operations calling Class.forName,  // Class.newInstance, Class.getMethod,  // Method.invok...
More Precise Rethrow try {   // Reflective operations calling Class.forName,   // Class.newInstance, Class.getMethod,   //...
The DaVinci Machine ProjectJSR 292A multi-language renaissance for the JVMopenjdk.java.net/projects/mlvm●   Dynamic Invoca...
2525
JVM Architecture• Stack based  • Push operand on to the stack  • Instructions operates by popping data off the stack  • Pu...
JVM Specification“The Java virtual machine knows      nothing about the Javaprogramming language, only of aparticular bina...
Languages Running on the JVM                                                                 Tea Zigzag                   ...
Method Calls● Calling a method is cheap  (VMs can even inline!)● Selecting the right target  method can be expensive      ...
InvokeDynamic Bytecode• JVM currently has four ways to invoke method  • Invokevirtual, invokeinterface, invokestatic, invo...
LibraryChanges           31           31
New I/O 2 (NIO2) Libraries JSR 203• Original Java I/O APIs presented challenges for  developers  •   Not designed to be ex...
Java NIO2 Features• Path is a replacement for File  • Biggest impact on developers• Better directory support  • list() met...
Concurrency APIs• JSR166y  • Update to JSR166x which was an update to JSR166• Adds a lightweight task framework  • Also re...
Client Libraries•   Nimbus Look and Feel•   Platform APIs for shaped and translucent windows•   JLayer (formerly from Swin...
Nimbus Look and Feel                       36                       36
JLayer componentEasy enrichment for Swing components                                       37                             ...
JLayer component    The universal decorator• Transparent decorator for a Swing component• Controls the painting of its sub...
Miscellaneous Updates• Security    • Eliptic curve cryptography    • TLS 1.2•   JAXP 1.4.4 (Java API for XML processing)• ...
Platform Support• Windows (x86)• Linux (x86)  • Redhat  • Ubuntu• Solaris (x86)• New: Apple OSX (x86)                     ...
Java SE 8            41            41
Java SE 8        Project Jigsaw        Modularising the Java Platform        Project Lambda (JSR 335)        Closures and ...
The Modular Java Platform• Enables escape from “JAR Hell”   – Eliminates class path   – Package modules for automatic down...
module-info.javaEntry point   Module name                            Versionmodule com.foo @ 1.0.0 {  class com.foo.app.Ma...
Project LambdaClosures and moreopenjdk.java.net/projects/lambda● Lambda expressions● SAM conversion with target typing● Me...
Hypothetical Internal Iterationdouble highestScore = students     .filter(new Predicate<Student>() {        public boolean...
Introducing Lambda Expressionsdouble highestScore = students    .filter(#{ Student s -> s.gradYear == 2010 })    .map(#{ S...
Roadmaps Are Approved!• JSRs approved by JCP   – JSR 334: Small enhancements to the Java language   – JSR 335: Lambda expr...
Conclusions• Java SE 7  • Incremental changes  • Evolutionary, not revolutionary  • Good solid set of features to make dev...
5050
Upcoming SlideShare
Loading in...5
×

Terence Barr - jdk7+8 - 24mai2011

886

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
886
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
30
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Terence Barr - jdk7+8 - 24mai2011

  1. 1. <Insert Picture Here>The Future of the Java Platform:Java SE 7 & Java SE 8Terrence BarrSenior Technologist, Mobile & Embedded Technologies
  2. 2. The preceding is intended to outline our generalproduct direction. It is intended for informationpurposes only, and may not be incorporated into anycontract. It is not a commitment to deliver anymaterial, code, or functionality, and should not berelied upon in making purchasing decisions.The development, release, and timing of anyfeatures or functionality described for Oracle’sproducts remains at the sole discretion of Oracle. 2 2
  3. 3. Agenda Small(Language) Project Coin (JSR 334) ChangesProject Coin Small Language Changes The DaVinci Machine Multiple Languages on the JVM invokedynamic (JSR 292) Library changes Miscellaneous Updates JSR 337: Java SE 8 Release Contents 3 3
  4. 4. Evolving the LanguageFrom “Evolving the Java Language” - JavaOne 2005• Java language principles – Reading is more important than writing – 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• We will evolve the Java language • But cautiously, with a long term view • “first, do no harm” • Beware: Changes have many downstream implications (spec, tests, implementation(s), tools, compatibility, future, ...) 4 4
  5. 5. Java Standard Edition (Java SE) vs. Java Development Kit (JDK)• Java SE • Java Development Kit • Definition of the software • Oracles implementation of platform Java SE • Specification documents • Additional features not in • Implementation the spec • Test suite (TCK) • Tools and documentation • Implemented by several • Deployment and groups management capabilities • Produced in the JCP • Performance features • Produced in the OpenJDK project 5 5
  6. 6. Java SE 7 6 6
  7. 7. SmallSection Divider <Insert Picture Here> (Language) Changes Project Coin 7 7
  8. 8. 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 8 8
  9. 9. Better Integer Literal• Binary literals int mask = 0b101010101010;• With underscores for clarity int mask = 0b1010_1010_1010; long big = 9_223_783_036_967_937L; 9 9
  10. 10. String Switch Statement• Today case label includes integer constants and enum constants• Strings are constants too (immutable) 10 10
  11. 11. Discriminating Strings Todayint monthNameToDays(String s, int year) { if("April".equals(s) || "June".equals(s) || "September".equals(s) ||"November".equals(s)) return 30; if("January".equals(s) || "March".equals(s) || "May".equals(s) || "July".equals(s) || "August".equals(s) || "December".equals(s)) return 31; if("February".equals(s)) ... 11 11
  12. 12. Strings in Switchint 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: ... 12 12
  13. 13. Simplifying Generics• Pre-generics List strList = new ArrayList(); 13 13
  14. 14. Simplifying Generics• Pre-generics List strList = new ArrayList();• With GenericsList<String> strList = new ArrayList<String>(); 14 14
  15. 15. Simplifying Generics• Pre-generics List strList = new ArrayList();• With Generics List<String> strList = new ArrayList<String>(); List<Map<String, List<String>> strList = new ArrayList<Map<String, List<String>>(); 15 15
  16. 16. Diamond Operator• Pre-generics List strList = new ArrayList();• With Generics List<String> strList = new ArrayList<String>(); List<Map<String, List<String>> strList = new ArrayList<Map<String, List<String>>();• With diamond (<>) compiler infers type List<String> strList = new ArrayList<>(); List<Map<String, List<String>> strList = new ArrayList<>(); 16 16
  17. 17. Simplifying Resource UseInputStream in = new FileInputStream(src);OutputStream out = new FileOutputStream(dest);byte[] buf = new byte[8192];int n;while (n = in.read(buf)) >= 0) out.write(buf, 0, n); 17 17
  18. 18. Simplifying Resource UseInputStream in = new FileInputStream(src);OutputStream out = new FileOutputStream(dest);try { byte[] buf = new byte[8192]; int n; while (n = in.read(buf)) >= 0) out.write(buf, 0, n);} finally { in.close(); out.close();} 18 18
  19. 19. Simplifying Resource UseInputStream in = new FileInputStream(src);try { OutputStream out = new FileOutputStream(dest); try { byte[] buf = new byte[8192]; int n; while (n = in.read(buf)) >= 0) out.write(buf, 0, n); } finally { out.close(); }} finally { in.close();} 19 19
  20. 20. Automatic Resource Managementtry (InputStream in = new FileInputStream(src), OutputStream out = new FileOutputStream(dest)){ byte[] buf = new byte[8192]; int n; while (n = in.read(buf)) >= 0) out.write(buf, 0, n);} 20 20
  21. 21. Exceptions Galoretry { ...} catch(ClassNotFoundException cnfe) { doSomething(cnfe); throw cnfe;} catch(InstantiationException ie) { log(ie); throw ie;} catch(NoSuchMethodException nsme) { log(nsme); throw nsme;} catch(InvocationTargetException ite) { log(ite); throw ite;} 21 21
  22. 22. Multi-Catchtry { // Reflective operations calling Class.forName, // Class.newInstance, Class.getMethod, // Method.invoke, etc.} catch (final ClassCastException e) { doSomething(e); throw e;} catch(final InstantiationException | NoSuchMethodException | InvocationTargetException e) { log(e); throw e;} 22 22
  23. 23. More Precise Rethrow try { // Reflective operations calling Class.forName, // Class.newInstance, Class.getMethod, // Method.invoke, etc. } catch(final ReflectiveOperationException e) { //e means any of the subtype thrown from try {} log(e); ReflectiveOperationException throw e; } ClassNotFoundException InstantiationException NoSuchMethodException InvocationTargetExceptionhttp://download.java.net/jdk7/docs/api/java/lang/ReflectiveOperationException.html23 23
  24. 24. The DaVinci Machine ProjectJSR 292A multi-language renaissance for the JVMopenjdk.java.net/projects/mlvm● Dynamic Invocation ● InvokeDynamic bytecode● Method Handles 24 24
  25. 25. 2525
  26. 26. JVM Architecture• Stack based • Push operand on to the stack • Instructions operates by popping data off the stack • Pushes result back on the stack• Data types • Eight primitive types, objects and arrays• Object model – single inheritance with interfaces• Method resolution • Receiver and method name • Statically typed for parameters and return types • Dynamic linking + static type checking • Verified at runtime 26 26
  27. 27. JVM Specification“The Java virtual machine knows nothing about the Javaprogramming language, only of aparticular binary format, the class file format.” 1.2 The Java Virtual Machine Spec. 27 27
  28. 28. Languages Running on the JVM Tea Zigzag JESS Jickle iScript Modula-2 Lisp Correlate Nice CAL JudoScript JavaScript Simkin Drools Basic Icon Groovy Eiffel v-language Pascal Luck Prolog Mini Tcl PLAN HojoRexx Jython Scala Funnel Tiger Anvil Yassl Oberon FScript E Smalltalk Logo Tiger JHCR JRuby Ada G Scheme Clojure Phobos Processing WebL Dawn TermWare Sather Sleep LLP Pnuts Bex Script BeanShell Forth PHP C# Yoix SALSA ObjectScript Piccola 28 28 28
  29. 29. Method Calls● Calling a method is cheap (VMs can even inline!)● Selecting the right target method can be expensive ● Static languages do most of their method selection at compile time ● Single-dispatch on receiver type is left for runtime ● Dynamic languages do almost none at compile time ● But it would be nice to not have to re-do method selection for every single invocation● Each Language has its own ideas about linkage 29 29
  30. 30. InvokeDynamic Bytecode• JVM currently has four ways to invoke method • Invokevirtual, invokeinterface, invokestatic, invokespecial• All require full method signature data• InvokeDynamic will use method handle • Effectively an indirect pointer to the method• When dynamic method is first called bootstrap code determines method and creates handle• Subsequent calls simply reference defined handle• Type changes force a re-compute of the method location and an update to the handle • Method call changes are invisible to calling code 30 30
  31. 31. LibraryChanges 31 31
  32. 32. New I/O 2 (NIO2) Libraries JSR 203• Original Java I/O APIs presented challenges for developers • Not designed to be extensible • Many methods do not throw exceptions as expected • rename() method works inconsistently • Developers want greater access to file metadata• Java NIO2 solves these problems 32 32
  33. 33. Java NIO2 Features• Path is a replacement for File • Biggest impact on developers• Better directory support • list() method can stream via iterator • Entries can be filtered using regular expressions in API• Symbolic link support• Two security models (POSIX, ACL based on NFSv4)• java.nio.file.Filesystem • interface to a filesystem (FAT, ZFS, Zip archive, network, etc)• java.nio.file.attribute package • Access to file metadata 33 33
  34. 34. Concurrency APIs• JSR166y • Update to JSR166x which was an update to JSR166• Adds a lightweight task framework • Also referred to as Fork/Join• Uses ParallelArray • Greatly simplifies use of many cores/processors for tasks that can easily be separated 34 34
  35. 35. Client Libraries• Nimbus Look and Feel• Platform APIs for shaped and translucent windows• JLayer (formerly from Swing labs)• Optimized 2D rendering 35 35
  36. 36. Nimbus Look and Feel 36 36
  37. 37. JLayer componentEasy enrichment for Swing components 37 37
  38. 38. JLayer component The universal decorator• Transparent decorator for a Swing component• Controls the painting of its subcomponents• Catches all input and focus events for the whole hierarchy // wrap your component with JLayer JLayer<JPanel> layer = new JLayer<JPanel>(panel); // custom ui provides all extra functionality layer.setUI(myLayerUI); // add the layer as usual component frame.add(layer); 38 38
  39. 39. Miscellaneous Updates• Security • Eliptic curve cryptography • TLS 1.2• JAXP 1.4.4 (Java API for XML processing)• JAX-WS 2.2 (Java API for XML Web Services)• JAXB 2.2 (Java Architecture for XML Binding)• ClassLoader architecture changes• close() for URLClassLoader• Javadoc support for CSS 39 39
  40. 40. Platform Support• Windows (x86)• Linux (x86) • Redhat • Ubuntu• Solaris (x86)• New: Apple OSX (x86) 40 40
  41. 41. Java SE 8 41 41
  42. 42. Java SE 8 Project Jigsaw Modularising the Java Platform Project Lambda (JSR 335) Closures and more Better support for multi-core processors More Project Coin Small Language Changes 42 42
  43. 43. 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 43 43
  44. 44. module-info.javaEntry point Module name Versionmodule com.foo @ 1.0.0 { class com.foo.app.Main requires org.bar.lib @ 2.1-alpha; requires edu.baz.util @ 5.2_11; provides com.foo.app.lib @ 1.0.0;} Dependency Virtual module 44 44
  45. 45. 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 45 45
  46. 46. Hypothetical Internal Iterationdouble 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();• Not inherently serial – students traversal not determined by developer – Looks like a functional language• Anonymous inner class! 46 46
  47. 47. Introducing Lambda Expressionsdouble highestScore = students .filter(#{ Student s -> s.gradYear == 2010 }) .map(#{ Student s -> s.score }) .max(); • 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 47 47
  48. 48. Roadmaps Are Approved!• JSRs approved by JCP – JSR 334: Small enhancements to the Java language – JSR 335: Lambda expressions for the Java language – JSR 336: Java SE 7 Release Contents – JSR 337: Java SE 8 Release Contents• OpenJDK Releases in 2011 & 2012 – Committed Features List for 2011: • openjdk.java.net/projects/jdk7/features 48 48
  49. 49. Conclusions• Java SE 7 • Incremental changes • Evolutionary, not revolutionary • Good solid set of features to make developers life easier• Java SE 8 • Major new features: Modularisation and Closures • More smaller features to be defined• Java Evolution Continues • Grow and adapt to the changing world of IT • Oracle and its partners are committed to a vibrant and evolving Java ecosystem 49 49
  50. 50. 5050
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×