java 7 whats new(), whats next() from oredev

of 84 /84
7 What’s New() What’s Next() ©Copyright 2011

Author: mattias-karlsson

Post on 10-May-2015




5 download

Embed Size (px)


Finally Java SE 7 is GA and you can start using it. This talk will cover the most important new features of the language and the virtual machine. It will also cover some features that did not make it in to the SE 7 release. Finally we will discuss current state of Java as an ecosystem and my analysis and hopes for the future.


  • 1.Whats New()Whats Next()Copyright 2011

2. Now() 11:1111/11/11 3. DisclaimerI am just an ordinary developerI dont work for Oracle 4. Mattias KarlssonAvega GroupTwitter: @matkarwww.Linkedin/in/mattiask 5. JavaforumJavaforum 6. Biggest news? 7. Java 7 is GA 8. HistoryJDK/YEARCommentFeb 1997Retooling of the AWT event model, innerJDK 1.1 classes added, JavaBeans and JDBC.Dec 1998Reflection, a Collections framework, JavaJ2SE 1.2 (Playground) Swing API Java Plug-in, JIT compiler.May 2000HotSpot JVM, JavaSound, JNDI and JPDAJ2SE 1.3 (Kestrel)Feb 2002RegEx, exception chaining, XML parser andJava SE 1.4 (Merlin)XSLT (JAXP), Java Web StartSep 2004for-each loop, generics, autoboxing and var-Java SE 5 (Tiger) argsDec 2006scripting languages with the JVM, VB langJava SE 6 (Mustang) support. Annotations (JSR 269) 9. Java SE 7Started in Aug 2006 10. Why was 7 delayed Open Sourcing JDK Conflicts Blocking JCP Sun Finance JavaFX Oracle Deal 11. Trouble in paradise James Gosling leaving Oracle Oracle vs Google Apache leaving JCP Doug Lea, Bob Lee leaving JCP 12. Java 7Plan A, JDK 7Late 2012Its been clear for some time that themost recent JDK 7 developmentschedule is, to put it mildly, Unrealistic(Mark Reinhold, 8 Sep 2010) 13. Plan B (Mark R)8 Sep 2010 Re-thinking JDK 720 Sep 2010 Its time forPlan B10 Oct 2010 Plan B: The details 14. Plan B JDK 8 7 Late 2012Mid 2011 Late 2012 15. Plan BNew garbage collector G1Library changesEnhancements to the JVMJDK 7 Language changes (Coin)Concurrency and collectionsJSR 336 NIO.2 16. JSR 336 approval 17. Performance 18. G1 Garbage collector Still considered experimental Leads to much smaller pause times Parallelism and Concurrency Generational Compaction Predictability (over CMS) 19. Using G1Replace CMS (Concurrent mark sweep) GCEnable with:-XX:+UnlockExperimentalVMOptions XX:+UseG1GCGC Paus time 20. Benchmarks Test 1. Add 5 Million String values (each calculated withsome complex Math arithmetic) Test 2. ArrayList with 5 Million insertions (withvalues from Test1)Test 3. HashMap with 5 million keys,values. Each key, value pair is being calculated viaconcurrent thread) Test 4. Printing 5 million items of ArrayList 21. Performance 22. PerformanceJava 6 18% faster then Java 5Java 7 46% faster then Java 6 23. Concurrency Matters Again10,0000001,000,000 Transistors100,000 10,0001,000 Clock (MHz)100 101 1970 1980 1990 2000 2010 24. Fork/Join Java 7 concurrency JSR 166y 25. JSR 166y Fork/Join similar to MapReduce useful for a certain class of problems 26. JSR 166y Fork/JoinResult solve(Problem problem) {if (problem is small enough)directly solve problemelse { split problem into independent parts fork new subtasks to solve each part join all subtasks compose result from subresults}} 27. JSR 166y Fork/Join Create one ForkJoinPool Wrap code in ForkJoinTask Subclass RecursiveAction or RecursiveTask Need to override compute() 28. class Sum extends RecursiveTask {static final int SEQUENTIAL_THRESHOLD = 1000;Sum(int[] arr, int lo, int hi) {array = arr; low = lo; high = hi;}protected Long compute() {if(high - low = 0)out.write(buf, 0, n); } finally {in.close();out.close(); }} 41. Pre Java 7public void copy(String src, String dest) throws IOEx{ InputStream in = new FileInputStream(src); try {OutputStream out = new FileOutputStream(dest);try { byte[] buf = new byte[8 * 1024]; int n; while ((n = >= 0)out.write(buf, 0, n);} finally { out.close();} } finally {in.close(); }} 42. Automatic Resource Managementpublic void copy(String src, String dest) throws IOEx{try ( InputStream in = new FileInputStream(src);OutputStream out = new FileOutputStream(dest)){ byte[] buf = new byte[8 * 1024]; int n; while ((n = >= 0)out.write(buf, 0, n);}//in and out closes automagically} 43. Improved Type Inference for Generic Instance 44. Improved Type Inference forGeneric InstanceMap> anagrams =new HashMap>();Map> anagrams =new HashMap(); 45. NIO.2Network and File System JSR 203 46. NIO.2 Network and File System JSR 203 java.nio.file.Path java.nio.file.FileSystem Other Usefull Methods 47. Pre Java 7URL url = new URL("");try (FileOutputStream fos =new FileOutputStream(new File("output.txt"));InputStream is = url.openStream() ){byte[] buf = new byte[4096];int len;while ((len = > 0){fos.write(buf, 0, len);}} catch (IOException e){e.printStackTrace();} 48. NIO.2Network and File System JSR 203URL url = new URL("");try (InputStream in = url.openStream()) {Files.copy(in, Paths.get("output.txt"));}catch(IOException ex){ex.printStackTrace();} 49. Da Vinci Machine Project 50. Da Vinci Machine Project Support for dynamically typed languages Python, Ruby, Perl, Javascript, Groovy... Implementations will be more efficient JVM level support for such languages and their implementers 51. Charles Nutterco-leads Jruby projectEngine Yard 52. JSR-292invokedynamicMethod HandlesWTF? 53. Without invokedynamicFour existing forms of method dispatchvirtual, interface, special, superJVM decides how they workWhat if you dont fit? 54. invokedynamicUser-defined dispatchName, signature as usualAdditional bootstrap method handleBootstrap called first time to wire it upJVM then optimizes like real Java 55. Method HandlesSuper-awesome function pointersFaster than reflectionCurry-ableStill talking directly to JVMUsed by invokedynamic bootstrapping 56. invokedynamic bootstrap1st timemethodinvokedynamic bytecode JVM target2nd time method 57. Examplepublic static void print(String s) { System.out.println(s);} 58. Examplepublic static void main(java.lang.String[]);Code:0: ldc #9 // String Hello, invokedynamic!2: invokedynamic #18, 0 // InvokeDynamic #0:print:(Ljava/lang/String;)V7: returninvokedynamic bootstrapname and bytecodehandlesignature 59. Examplepublic static CallSite bootstrap(Lookup lookup, String name, MethodType signature{ MethodHandle handle = lookup.findStatic(this_class, name, signature); CallSite site = new ConstantCallSite(handle); return site;} 60. JVM languages to benefit frominvokedynamic These gains will vary: JRuby ? Clojure ? Increasing its performance Big potential wins 61. Other stuff in TLS 1.2 Elliptic-curve cryptography (ECC) JDBC 4.1 Binary literals Better way to handle unsigned literals Unicode 6.0 Locale enhancement Support for IETF BCP 47 and UTR 35 62. Other stuff in New platform APIs for 6u10 graphics features Swing Nimbus look-and-feel Swing JLayer component Updated XML stack 63. Runtimes 64. Java 7 Runtimes Windows x86 Server 2008, Server 2008 R2, 7 & 8 Windows Vista, XP Linux x86 Oracle Linux 5.5+, 6.x Red Hat Enterprise Linux 5.5+, 6.x SuSE Linux Enterprise Server 10.x, 11.x Ubuntu Linux 10.04 LTS, 11.04 Solaris x86/SPARC Solaris 10.9+, 11.x 65. Other runtimesThe IBM SDK for Java V7 is now available forthe following platforms: - 20 Sep 2011 AIX Linux z/OS 66. 67. Java 7 Tool SupportNetBeans 7Eclipse 3.7 3.8 4.1 4.2IntelliJ 10.5 68. Whats.Next() 69. JVM ConvergenceProject HotRockitHotSpot HotRockit JRockit 70. Plan BModularization (Jigsaw)Language and VM SupportPlatform ModularizationProject Lambda (JSR 335)Lambda Expressions for JavaType Annotations (JSR 308)JDK 8Project Coin part IIDate and Time API (JSR 310)JSR 337 71. Plan B++Project Nashorn New implementation of JavaScript Built from the ground up Leverage JVM and invoke dynamicJava FX 3.0Open SourcedBundled with Java 8 JDK 8JSR 337 72. ScheduleMay 2011: Expert Group formationSep 2011: Early Draft ReviewFeb 2012: Public ReviewMay 2012: Proposed Final DraftOct 2012: Final ReleaseJDK 8 JSR 337 73. ScheduleMay 2011: Expert Group formationSep 2011: Early Draft ReviewFeb 2012: Public ReviewMay 2012: Proposed Final DraftSummer 2013: Final Release JDK 8 JSR 337 74. Schedule JDK 8, b10Developer Preview Now Available!JDK 8JSR 75. Using the process to improve the process JSR 348 Transparency Participation Agility Governance A second JSR will be filed soon JavaSE and JavaME EC - merged 76. JCP, new membersTwitterAzul System 77. Were moving again The JCP Dead Lock Needed to be Broken OpenJDK is liberated (GPL) JUG attendances are growing Oracle marketing estimates 9-10 million devs Dozens of new JVM languages A Vibrant Java Ecosystem 78. Community 79. Summary Java 7 is GA Java 8 is on its way The JVM Rocks The community is very much alive! 80. Mattias @[email protected] and Java are registered trademarks of Oracle and/or its affiliates. Other namesappearing on the slides may be trademarks of their respective owners.The development, release, and timing of any features or functionality described for Oraclesproducts remains at the sole discretion of Oracle and JCPCopyright 2011