SlideShare una empresa de Scribd logo
1 de 60
Descargar para leer sin conexión
Thursday, September 8, 2011
<Insert Picture Here>




          Java SE 7: The Platform Evolves
          Dalibor Topić
          Java F/OSS Ambassador




Thursday, September 8, 2011
Priorities for the Java Platforms

                              Grow Developer Base

                              Grow Adoption

                              Increase Competitiveness

                              Adapt to change




Thursday, September 8, 2011
Java Communities




Thursday, September 8, 2011
How Java Evolves and Adapts




                              Community Development of
                                 Java Technology
                                  Specifications


Thursday, September 8, 2011
JCP Reforms

       • Developers’ voice in the Executive Committee
            •   SOUJava
            •   Goldman Sachs
            •   London JavaCommunity
            •   Alex Terrazas
       • JCP starting a program of reform
            • JSR 348: Towards a new version of the JCP




Thursday, September 8, 2011
Evolving the Language
          From “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
          • We will evolve the Java language
              • But cautiously, with a long term view
              • “first do no harm”
                                             also “Growing a Language” - Guy Steele 1999
                                                  “The Feel of Java” - James Gosling 1997


                                                                                       7
Thursday, September 8, 2011
So you want to change the language?




                                                8
Thursday, September 8, 2011
Java SE 7 Release Contents

       • Java Language
             •    Project Coin (JSR-334)
       • Class Libraries
             •    NIO2 (JSR-203)
             •    Fork-Join framework, ParallelArray (JSR-166y)
       • Java Virtual Machine
             •    The DaVinci Machine project (JSR-292)
             •    InvokeDynamic bytecode
       • Miscellaneous things
       • JSR-336: Java SE 7 Release Contents



                                                                  9
Thursday, September 8, 2011
Section Divider
                                Small         <Insert Picture Here>




                              Language
                              Changes
                               Project Coin

                                                              10
Thursday, September 8, 2011
coin, n. A piece of small change
                    coin, v. To create new language




                                                       11
Thursday, September 8, 2011
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
Thursday, September 8, 2011
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;




                                                13
Thursday, September 8, 2011
String Switch Statement

       • Today case label includes integer constants and
         enum constants
       • Strings are constants too (immutable)




                                                           14
Thursday, September 8, 2011
Discriminating Strings Today

      int 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))
            ...




                                                               15
Thursday, September 8, 2011
Strings in Switch Statements
         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:
                   ...


                                                     16
Thursday, September 8, 2011
Simplifying Generics

       • Pre-generics
       List strList = new ArrayList();




                                         17
Thursday, September 8, 2011
Simplifying Generics

       • Pre-generics
       List strList = new ArrayList();
       • With Generics
         List<String> strList = new ArrayList<String>();




                                                       18
Thursday, September 8, 2011
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>>();




                                                       19
Thursday, September 8, 2011
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<>();


                                                       20
Thursday, September 8, 2011
Copying a File

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




                                                          21
Thursday, September 8, 2011
Copying a File (Better, but wrong)

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



                                                        22
Thursday, September 8, 2011
Copying a File (Correct, but complex)
      InputStream 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();
      }


                                                         23
Thursday, September 8, 2011
Copying a File (Correct, but complex)
      InputStream 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 {
                                      Exception thrown from
        in.close();                  potentially three places.
      }                           Details of first two could be lost



                                                                   24
Thursday, September 8, 2011
Automatic Resource Management

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




                                                    25
Thursday, September 8, 2011
The Details

       • Compiler desugars try-with-resources into nested try-
         finally blocks with variables to track exception state
       • Suppressed exceptions are recorded for posterity
         using a new facillity of Throwable
       • API support in JDK 7
             • New superinterface java.lang.AutoCloseable
             • All AutoCloseable and by extension java.io.Closeable
               types useable with try-with-resources
             • anything with a void close() method is a candidate
             • JDBC 4.1 retrefitted as AutoCloseable too




                                                                      26
Thursday, September 8, 2011
More Informative Backtraces

       java.io.IOException
            at Suppress.write(Suppress.java:19)
            at Suppress.main(Suppress.java:8)
            Suppressed: java.io.IOException
                at Suppress.close(Suppress.java:24)
                at Suppress.main(Suppress.java:9)
            Suppressed: java.io.IOException
                at Suppress.close(Suppress.java:24)
                at Suppress.main(Suppress.java:9)




                                                      27
Thursday, September 8, 2011
Varargs Warnings

         class Test {
            public static void main(String... args) {
               List<List<String>> monthsInTwoLanguages =
                 Arrays.asList(Arrays.asList("January",
                                             "February"),
                               Arrays.asList("Gennaio",
                                             "Febbraio" ));
            }
         }


          Test.java:7: warning:
          [unchecked] unchecked generic array creation
          for varargs parameter of type List<String>[]
                   Arrays.asList(Arrays.asList("January",
                                 ^
          1 warning



                                                              28
Thursday, September 8, 2011
Varargs Warnings Revised

       • New mandatory compiler warning at suspect varargs
         method declarations
       • By applying an annotation at the declaration,
         warnings at the declaration and call sites can be
         suppressed
       • @SuppressWarnings(value = “unchecked”)
       • @SafeVarargs




                                                             29
Thursday, September 8, 2011
Exceptions Galore
            try {
              ...
            } catch(ClassNotFoundException cnfe) {
              doSomethingClever(cnfe);
              throw cnfe;
            } catch(InstantiationException ie) {
              log(ie);
              throw ie;
            } catch(NoSuchMethodException nsme) {
              log(nsme);
              throw nsme;
            } catch(InvocationTargetException ite) {
              log(ite);
              throw ite;
            }



                                                       30
Thursday, September 8, 2011
Multi-Catch
      try {
        ...
      } catch (ClassCastException e) {
        doSomethingClever(e);
        throw e;
      } catch(InstantiationException |
          NoSuchMethodException |
          InvocationTargetException e) {
        log(e);
        throw e;
      }




                                           31
Thursday, September 8, 2011
32
Thursday, September 8, 2011
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




                                                                   33
Thursday, September 8, 2011
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
       • java.nio.file.Filesystem
            • interface to a filesystem (FAT, ZFS, Zip archive, network, etc)
       • java.nio.file.attribute package
            • Access to file metadata




                                                                                34
Thursday, September 8, 2011
Path Class
          • Equivalent of java.io.File in the new API
             – Immutable
          • Have methods to access and manipulate Path
          • Few ways to create a Path
             – From Paths and FileSystem

         //Make a reference to the path
         Path home = Paths.get(“/home/fred”);
         //Resolve tmp from /home/fred -> /home/fred/tmp
         Path tmpPath = home.resolve(“tmp”);
         //Create a relative path from tmp -> ..
         Path relativePath = tmpPath.relativize(home)
         File file = relativePath.toFile();



                                                           35
Thursday, September 8, 2011
File Operation – Copy, Move

          • File copy is really easy
             – With fine grain control
          Path src = Paths.get(“/home/fred/readme.txt”);
          Path dst = Paths.get(“/home/fred/copy_readme.txt”);
          Files.copy(src, dst,
               StandardCopyOption.COPY_ATTRIBUTES,
               StandardCopyOption.REPLACE_EXISTING);
          • File move is supported
             – Optional atomic move supported

          Path src = Paths.get(“/home/fred/readme.txt”);
          Path dst = Paths.get(“/home/fred/readme.1st”);
          Files.move(src, dst, StandardCopyOption.ATOMIC_MOVE);


                                                                36
Thursday, September 8, 2011
Directories
          • DirectoryStream iterate over entries
             – Scales to large directories
             – Uses less resources
             – Smooth out response time for remote file systems
             – Implements Iterable and Closeable for productivity
          • Filtering support
             – Build-in support for glob, regex and custom filters

         Path srcPath = Paths.get(“/home/fred/src”);
         try (DirectoryStream<Path> dir =
              srcPath.newDirectoryStream(“*.java”)) {
           for (Path file: dir)
              System.out.println(file.getName());
         }


                                                                     37
Thursday, September 8, 2011
Concurrency APIs

       • JSR166y
            • Update to JSR166x which was an update to JSR166
       • Adds a lightweight task framework
            • Also referred to as Fork/Join
       • Phaser
            • Barrier similar to CyclicBarrier and CountDownLatch
       • TransferQueue interface
            • Extension to BlockingQueue
            • Implemented by LinkedTransferQueue




                                                                    38
Thursday, September 8, 2011
Fork Join Framework
          • Goal is to take advantage of multiple processor
          • Designed for task that can be broken down into
             smaller pieces
              – Eg. Fibonacci number fib(10) = fib(9) + fib(8)
          • Typical algorithm that uses fork join


    if I can manage the task
      perform the task
    else
      fork task into x number of smaller/similar task
      join the results




                                                                 39
Thursday, September 8, 2011
Key Classes
          • ForkJoinPool
             – Executor service for running ForkJoinTask
          • ForkJoinTask
             – The base class for forkjoin task
          • RecursiveAction
             – A subclass of ForkJoinTask
             – A recursive resultless task
             – Implements compute() abstract method to perform
               calculation
          • RecursiveTask
             – Similar to RecursiveAction but returns a result




                                                                 40
Thursday, September 8, 2011
ForkJoin Example – Fibonacci
       public class Fibonacci extends RecursiveTask<Integer> {
           private final int number;
           public Fibonacci(int n) { number = n; }

              @Override protected Integer compute() {
                  switch (number) {
                      case 0: return (0);
                      case 1: return (1);
                      default:
                          Fibonacci f1 = new Fibonacci(number – 1);
                          Fibonacci f2 = new Fibonacci(number – 2);
                          f1.fork(); f2.fork();
                          return (f1.join() + f2.join());
                  }
              }
       }




                                                                      41
Thursday, September 8, 2011
ForkJoin Example – Fibonacci

         ForkJoinPool pool = new ForkJoinPool();
         Fibonacci r = new Fibonacci(10);
         pool.submit(r);

         while (!r.isDone()) {
           //Do some work
           ...
         }

         System.out.println("Result of fib(10) = "
             + r.get());




                                                     42
Thursday, September 8, 2011
Client Libraries

       •   Nimbus Look and Feel
       •   Platform APIs for shaped and translucent windows
       •   JLayer (formerly from Swing labs)
       •   Optimised 2D rendering




                                                              43
Thursday, September 8, 2011
Nimbus Look and Feel
       • Better than Metal for cross platform look-and-feel
       • Introduced in Java SE 6u10, now part of Swing
       • Not the default L&F




                                                              44
Thursday, September 8, 2011
JLayer component
          Easy enrichment for Swing components




                                                 45
Thursday, September 8, 2011
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);




                                                                  46
Thursday, September 8, 2011
The DaVinci Machine Project (JSR-292)
           (A multi-language renaissance for the JVM)




                              Better




                                                        47
Thursday, September 8, 2011
Languages Like Virtual Machines

       • Programming languages need runtime support
             •   Memory management / Garbage collection
             •   Concurrency control
             •   Security
             •   Reflection
             •   Debugging integration
             •   Standard libraries
       • Compiler writers have to build these from scratch
       • Targeting a VM allows reuse of infrastructure




                                                             48
Thursday, September 8, 2011
JVM Specification

         “The Java virtual machine knows
               nothing about the Java
         programming language, only of a
         particular binary format, the class
                     file format.”
                              1.2 The Java Virtual Machine Spec.



                                                                   49
Thursday, September 8, 2011
Languages Running on the JVM
                                                                          Tea
        Zigzag                                     JESS                     Jickle     iScript
                      Modula-2                                    Lisp
                                    Nice
                                                          CAL                        JavaScript
               Correlate
                               Simkin                Drools     Basic JudoScript
                 Groovy                   Eiffel
        Icon                                            v-language               Pascal Luck
                                Prolog        Mini
                      Tcl                                        PLAN       Hojo
     Rexx                     JavaFX Script                                             Scala
                                                                        Funnel
                 Tiger        Anvil                             Yassl                Oberon
                                                                                        FScript
           E                          Smalltalk
                 Logo
                    Tiger                                    JHCR           JRuby
         Ada           G                                    Scheme
                               Clojure
        Processing        Dawn                                          Phobos          Sather
                   WebL                                    TermWare
                                                                                      Sleep
                             LLP                                            Pnuts     Bex Script
              BeanShell        Forth
                                         C#                PHP
                                              Yoix            SALSA ObjectScript
                    Jython                                 Piccola
                                                                                                        51


                                                                                                   50
Thursday, September 8, 2011
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



                                                                            51
Thursday, September 8, 2011
CallSite and MethodHandle
          • invokedynamic linked to a CallSite
             – CallSite can be linked or unlinked
             – CallSite holder of MethodHandle
          • MethodHandle is a directly executable reference to
             an underlying method, constructor, field
              – Can transform arguments and return type
              – Transformation – conversion, insertion, deletion, substitution




                                                                                 52
Thursday, September 8, 2011
invokedynamic Illustrated
     this[method_name](x, y)
     invokedynamic
       [#bootstrapMethod]
       .this_method_name                               1. Invoke bootstrap


                                                                class LangaugeRuntime {
                                                  2. Produces      bootstrapMethod(info) {
                                                  CallSite            ...
          3.Complete linkage
                                                                      return new CallSite();
                                                                   }
                                      CallSite



                                                              class AClass {
                                                                 aMethod(x, y) {
                              4. Invokes method         Method      ...
                               implementation           Handle }




                                                                                           53
Thursday, September 8, 2011
Miscellaneous Things

       • Security
            • Eliptic curve cryptography
            • TLS 1.2
       •   JAXP 1.4.4
       •   JAX-WS 2.2
       •   JAXB 2.2
       •   ClassLoader architecture changes
       •   close() for URLClassLoader
       •   Javadoc support for CSS



                                              54
Thursday, September 8, 2011
JDK 7 Platform Support
       • Windows x86
             • Server 2008, Server 2008 R2, 7 & 8 (when it GAs)
             • 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
       • Apple OSX x86
             • will be supported post-GA, detailed plan TBD

       Note: JDK 7 should run on pretty much any Windows/Linux/Solaris.
          These configurations are the ones primarily tested by Oracle, and
          for which we provide commercial support.




                                                                              55
Thursday, September 8, 2011
JVM Convergence – Forward looking
           Project “HotRockit”


      JDK 7 GA – 07/11        JDK 7u2                JDK 7uX                  JDK 8 GA


      • Hotspot 21            • Hotspot 22           • Hotspot 23             • Hotspot24
      • Java SE 7 Support     • Performance          • More performance       • Java SE 8 Support
      • Rebranding            • Enable large heaps   • Improved command       • All performance
      • Improved JMX
                               with reasonable         line servicability       features from
                               latencies               (jcmd)                   JRockit ported
        Agent
                                                     • Enable large heaps     • All servicability
      • Command line
        servicability tool                             with consistent          features from
        (jrcmd)                                        reasonable latencies     JRockit ported
                                                     • No PermGen                • Compiler controls
                                                                                 • Verbose logging
                                                          --- Premium ---         --- Premium ---
          --- Premium ---
                                                     • Complete JRockit       • JRockit Mission
      • Improved JRockit
                                                       Flight Recorder          Control Memleak
        Mission Control                                Support                  Tool Support
        Console support
                                                                              • Soft Real Time GC




Thursday, September 8, 2011
Java SE 8
                              Project Jigsaw (JSR-294)
                              Modularising the Java Platform



                              Project Lambda (JSR 335)
                              Closures and lambda expressions
                              Better support for multi-core processors

                              More Project Coin
                              Small Language Changes



                                                                         57
Thursday, September 8, 2011
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 continues to grow and adapt to the changing
         world of IT




                                                                          58
Thursday, September 8, 2011
The 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.




                                                                 59
Thursday, September 8, 2011
60
Thursday, September 8, 2011

Más contenido relacionado

Similar a JavaSE 7

Java se-7-evolves-toulouse-jug-2001-09-14
Java se-7-evolves-toulouse-jug-2001-09-14Java se-7-evolves-toulouse-jug-2001-09-14
Java se-7-evolves-toulouse-jug-2001-09-14Baptiste Mathus
 
Text Manipulation with/without Parsec
Text Manipulation with/without ParsecText Manipulation with/without Parsec
Text Manipulation with/without Parsecujihisa
 
The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180Mahmoud Samir Fayed
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5Tim Wright
 
A Tour Through the Groovy Ecosystem
A Tour Through the Groovy EcosystemA Tour Through the Groovy Ecosystem
A Tour Through the Groovy EcosystemLeonard Axelsson
 
Java7 - Top 10 Features
Java7 - Top 10 FeaturesJava7 - Top 10 Features
Java7 - Top 10 FeaturesAndreas Enbohm
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189Mahmoud Samir Fayed
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUGAlex Ott
 
Johnson at RubyConf 2008
Johnson at RubyConf 2008Johnson at RubyConf 2008
Johnson at RubyConf 2008jbarnette
 
Intro to HTML5 Game Programming
Intro to HTML5 Game ProgrammingIntro to HTML5 Game Programming
Intro to HTML5 Game ProgrammingJames Williams
 
Developing a Language
Developing a LanguageDeveloping a Language
Developing a Languageevanphx
 
Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Mohamed Nabil, MSc.
 
Developing a Language
Developing a LanguageDeveloping a Language
Developing a LanguageEngine Yard
 

Similar a JavaSE 7 (20)

Java se-7-evolves-toulouse-jug-2001-09-14
Java se-7-evolves-toulouse-jug-2001-09-14Java se-7-evolves-toulouse-jug-2001-09-14
Java se-7-evolves-toulouse-jug-2001-09-14
 
Text Manipulation with/without Parsec
Text Manipulation with/without ParsecText Manipulation with/without Parsec
Text Manipulation with/without Parsec
 
The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180The Ring programming language version 1.5.1 book - Part 13 of 180
The Ring programming language version 1.5.1 book - Part 13 of 180
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5
 
A Tour Through the Groovy Ecosystem
A Tour Through the Groovy EcosystemA Tour Through the Groovy Ecosystem
A Tour Through the Groovy Ecosystem
 
Go courseday2
Go courseday2Go courseday2
Go courseday2
 
Java7 - Top 10 Features
Java7 - Top 10 FeaturesJava7 - Top 10 Features
Java7 - Top 10 Features
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUG
 
Node at artsy
Node at artsyNode at artsy
Node at artsy
 
Johnson at RubyConf 2008
Johnson at RubyConf 2008Johnson at RubyConf 2008
Johnson at RubyConf 2008
 
When?, Why? and What? of MongoDB
When?, Why? and What? of MongoDBWhen?, Why? and What? of MongoDB
When?, Why? and What? of MongoDB
 
Intro to HTML5 Game Programming
Intro to HTML5 Game ProgrammingIntro to HTML5 Game Programming
Intro to HTML5 Game Programming
 
Developing a Language
Developing a LanguageDeveloping a Language
Developing a Language
 
Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Kotlin for Android Developers - 1
Kotlin for Android Developers - 1
 
Go courseday1
Go courseday1Go courseday1
Go courseday1
 
XQuery Design Patterns
XQuery Design PatternsXQuery Design Patterns
XQuery Design Patterns
 
Go courseday1
Go courseday1Go courseday1
Go courseday1
 
Developing a Language
Developing a LanguageDeveloping a Language
Developing a Language
 

Último

UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 

Último (20)

UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 

JavaSE 7

  • 2. <Insert Picture Here> Java SE 7: The Platform Evolves Dalibor Topić Java F/OSS Ambassador Thursday, September 8, 2011
  • 3. Priorities for the Java Platforms Grow Developer Base Grow Adoption Increase Competitiveness Adapt to change Thursday, September 8, 2011
  • 5. How Java Evolves and Adapts Community Development of Java Technology Specifications Thursday, September 8, 2011
  • 6. JCP Reforms • Developers’ voice in the Executive Committee • SOUJava • Goldman Sachs • London JavaCommunity • Alex Terrazas • JCP starting a program of reform • JSR 348: Towards a new version of the JCP Thursday, September 8, 2011
  • 7. Evolving the Language From “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 • We will evolve the Java language • But cautiously, with a long term view • “first do no harm” also “Growing a Language” - Guy Steele 1999 “The Feel of Java” - James Gosling 1997 7 Thursday, September 8, 2011
  • 8. So you want to change the language? 8 Thursday, September 8, 2011
  • 9. Java SE 7 Release Contents • Java Language • Project Coin (JSR-334) • Class Libraries • NIO2 (JSR-203) • Fork-Join framework, ParallelArray (JSR-166y) • Java Virtual Machine • The DaVinci Machine project (JSR-292) • InvokeDynamic bytecode • Miscellaneous things • JSR-336: Java SE 7 Release Contents 9 Thursday, September 8, 2011
  • 10. Section Divider Small <Insert Picture Here> Language Changes Project Coin 10 Thursday, September 8, 2011
  • 11. coin, n. A piece of small change coin, v. To create new language 11 Thursday, September 8, 2011
  • 12. 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 Thursday, September 8, 2011
  • 13. 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; 13 Thursday, September 8, 2011
  • 14. String Switch Statement • Today case label includes integer constants and enum constants • Strings are constants too (immutable) 14 Thursday, September 8, 2011
  • 15. Discriminating Strings Today int 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)) ... 15 Thursday, September 8, 2011
  • 16. Strings in Switch Statements 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: ... 16 Thursday, September 8, 2011
  • 17. Simplifying Generics • Pre-generics List strList = new ArrayList(); 17 Thursday, September 8, 2011
  • 18. Simplifying Generics • Pre-generics List strList = new ArrayList(); • With Generics List<String> strList = new ArrayList<String>(); 18 Thursday, September 8, 2011
  • 19. 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>>(); 19 Thursday, September 8, 2011
  • 20. 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<>(); 20 Thursday, September 8, 2011
  • 21. Copying a File 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); 21 Thursday, September 8, 2011
  • 22. Copying a File (Better, but wrong) InputStream 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(); } 22 Thursday, September 8, 2011
  • 23. Copying a File (Correct, but complex) InputStream 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(); } 23 Thursday, September 8, 2011
  • 24. Copying a File (Correct, but complex) InputStream 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 { Exception thrown from in.close(); potentially three places. } Details of first two could be lost 24 Thursday, September 8, 2011
  • 25. Automatic Resource Management try (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); } 25 Thursday, September 8, 2011
  • 26. The Details • Compiler desugars try-with-resources into nested try- finally blocks with variables to track exception state • Suppressed exceptions are recorded for posterity using a new facillity of Throwable • API support in JDK 7 • New superinterface java.lang.AutoCloseable • All AutoCloseable and by extension java.io.Closeable types useable with try-with-resources • anything with a void close() method is a candidate • JDBC 4.1 retrefitted as AutoCloseable too 26 Thursday, September 8, 2011
  • 27. More Informative Backtraces java.io.IOException at Suppress.write(Suppress.java:19) at Suppress.main(Suppress.java:8) Suppressed: java.io.IOException at Suppress.close(Suppress.java:24) at Suppress.main(Suppress.java:9) Suppressed: java.io.IOException at Suppress.close(Suppress.java:24) at Suppress.main(Suppress.java:9) 27 Thursday, September 8, 2011
  • 28. Varargs Warnings class Test { public static void main(String... args) { List<List<String>> monthsInTwoLanguages = Arrays.asList(Arrays.asList("January", "February"), Arrays.asList("Gennaio", "Febbraio" )); } } Test.java:7: warning: [unchecked] unchecked generic array creation for varargs parameter of type List<String>[] Arrays.asList(Arrays.asList("January", ^ 1 warning 28 Thursday, September 8, 2011
  • 29. Varargs Warnings Revised • New mandatory compiler warning at suspect varargs method declarations • By applying an annotation at the declaration, warnings at the declaration and call sites can be suppressed • @SuppressWarnings(value = “unchecked”) • @SafeVarargs 29 Thursday, September 8, 2011
  • 30. Exceptions Galore try { ... } catch(ClassNotFoundException cnfe) { doSomethingClever(cnfe); throw cnfe; } catch(InstantiationException ie) { log(ie); throw ie; } catch(NoSuchMethodException nsme) { log(nsme); throw nsme; } catch(InvocationTargetException ite) { log(ite); throw ite; } 30 Thursday, September 8, 2011
  • 31. Multi-Catch try { ... } catch (ClassCastException e) { doSomethingClever(e); throw e; } catch(InstantiationException | NoSuchMethodException | InvocationTargetException e) { log(e); throw e; } 31 Thursday, September 8, 2011
  • 33. 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 33 Thursday, September 8, 2011
  • 34. 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 • java.nio.file.Filesystem • interface to a filesystem (FAT, ZFS, Zip archive, network, etc) • java.nio.file.attribute package • Access to file metadata 34 Thursday, September 8, 2011
  • 35. Path Class • Equivalent of java.io.File in the new API – Immutable • Have methods to access and manipulate Path • Few ways to create a Path – From Paths and FileSystem //Make a reference to the path Path home = Paths.get(“/home/fred”); //Resolve tmp from /home/fred -> /home/fred/tmp Path tmpPath = home.resolve(“tmp”); //Create a relative path from tmp -> .. Path relativePath = tmpPath.relativize(home) File file = relativePath.toFile(); 35 Thursday, September 8, 2011
  • 36. File Operation – Copy, Move • File copy is really easy – With fine grain control Path src = Paths.get(“/home/fred/readme.txt”); Path dst = Paths.get(“/home/fred/copy_readme.txt”); Files.copy(src, dst, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING); • File move is supported – Optional atomic move supported Path src = Paths.get(“/home/fred/readme.txt”); Path dst = Paths.get(“/home/fred/readme.1st”); Files.move(src, dst, StandardCopyOption.ATOMIC_MOVE); 36 Thursday, September 8, 2011
  • 37. Directories • DirectoryStream iterate over entries – Scales to large directories – Uses less resources – Smooth out response time for remote file systems – Implements Iterable and Closeable for productivity • Filtering support – Build-in support for glob, regex and custom filters Path srcPath = Paths.get(“/home/fred/src”); try (DirectoryStream<Path> dir = srcPath.newDirectoryStream(“*.java”)) { for (Path file: dir) System.out.println(file.getName()); } 37 Thursday, September 8, 2011
  • 38. Concurrency APIs • JSR166y • Update to JSR166x which was an update to JSR166 • Adds a lightweight task framework • Also referred to as Fork/Join • Phaser • Barrier similar to CyclicBarrier and CountDownLatch • TransferQueue interface • Extension to BlockingQueue • Implemented by LinkedTransferQueue 38 Thursday, September 8, 2011
  • 39. Fork Join Framework • Goal is to take advantage of multiple processor • Designed for task that can be broken down into smaller pieces – Eg. Fibonacci number fib(10) = fib(9) + fib(8) • Typical algorithm that uses fork join if I can manage the task perform the task else fork task into x number of smaller/similar task join the results 39 Thursday, September 8, 2011
  • 40. Key Classes • ForkJoinPool – Executor service for running ForkJoinTask • ForkJoinTask – The base class for forkjoin task • RecursiveAction – A subclass of ForkJoinTask – A recursive resultless task – Implements compute() abstract method to perform calculation • RecursiveTask – Similar to RecursiveAction but returns a result 40 Thursday, September 8, 2011
  • 41. ForkJoin Example – Fibonacci public class Fibonacci extends RecursiveTask<Integer> { private final int number; public Fibonacci(int n) { number = n; } @Override protected Integer compute() { switch (number) { case 0: return (0); case 1: return (1); default: Fibonacci f1 = new Fibonacci(number – 1); Fibonacci f2 = new Fibonacci(number – 2); f1.fork(); f2.fork(); return (f1.join() + f2.join()); } } } 41 Thursday, September 8, 2011
  • 42. ForkJoin Example – Fibonacci ForkJoinPool pool = new ForkJoinPool(); Fibonacci r = new Fibonacci(10); pool.submit(r); while (!r.isDone()) { //Do some work ... } System.out.println("Result of fib(10) = " + r.get()); 42 Thursday, September 8, 2011
  • 43. Client Libraries • Nimbus Look and Feel • Platform APIs for shaped and translucent windows • JLayer (formerly from Swing labs) • Optimised 2D rendering 43 Thursday, September 8, 2011
  • 44. Nimbus Look and Feel • Better than Metal for cross platform look-and-feel • Introduced in Java SE 6u10, now part of Swing • Not the default L&F 44 Thursday, September 8, 2011
  • 45. JLayer component Easy enrichment for Swing components 45 Thursday, September 8, 2011
  • 46. 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); 46 Thursday, September 8, 2011
  • 47. The DaVinci Machine Project (JSR-292) (A multi-language renaissance for the JVM) Better 47 Thursday, September 8, 2011
  • 48. Languages Like Virtual Machines • Programming languages need runtime support • Memory management / Garbage collection • Concurrency control • Security • Reflection • Debugging integration • Standard libraries • Compiler writers have to build these from scratch • Targeting a VM allows reuse of infrastructure 48 Thursday, September 8, 2011
  • 49. JVM Specification “The Java virtual machine knows nothing about the Java programming language, only of a particular binary format, the class file format.” 1.2 The Java Virtual Machine Spec. 49 Thursday, September 8, 2011
  • 50. Languages Running on the JVM Tea Zigzag JESS Jickle iScript Modula-2 Lisp Nice CAL JavaScript Correlate Simkin Drools Basic JudoScript Groovy Eiffel Icon v-language Pascal Luck Prolog Mini Tcl PLAN Hojo Rexx JavaFX Script Scala Funnel Tiger Anvil Yassl Oberon FScript E Smalltalk Logo Tiger JHCR JRuby Ada G Scheme Clojure Processing Dawn Phobos Sather WebL TermWare Sleep LLP Pnuts Bex Script BeanShell Forth C# PHP Yoix SALSA ObjectScript Jython Piccola 51 50 Thursday, September 8, 2011
  • 51. 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 51 Thursday, September 8, 2011
  • 52. CallSite and MethodHandle • invokedynamic linked to a CallSite – CallSite can be linked or unlinked – CallSite holder of MethodHandle • MethodHandle is a directly executable reference to an underlying method, constructor, field – Can transform arguments and return type – Transformation – conversion, insertion, deletion, substitution 52 Thursday, September 8, 2011
  • 53. invokedynamic Illustrated this[method_name](x, y) invokedynamic [#bootstrapMethod] .this_method_name 1. Invoke bootstrap class LangaugeRuntime { 2. Produces bootstrapMethod(info) { CallSite ... 3.Complete linkage return new CallSite(); } CallSite class AClass { aMethod(x, y) { 4. Invokes method Method ... implementation Handle } 53 Thursday, September 8, 2011
  • 54. Miscellaneous Things • Security • Eliptic curve cryptography • TLS 1.2 • JAXP 1.4.4 • JAX-WS 2.2 • JAXB 2.2 • ClassLoader architecture changes • close() for URLClassLoader • Javadoc support for CSS 54 Thursday, September 8, 2011
  • 55. JDK 7 Platform Support • Windows x86 • Server 2008, Server 2008 R2, 7 & 8 (when it GAs) • 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 • Apple OSX x86 • will be supported post-GA, detailed plan TBD Note: JDK 7 should run on pretty much any Windows/Linux/Solaris. These configurations are the ones primarily tested by Oracle, and for which we provide commercial support. 55 Thursday, September 8, 2011
  • 56. JVM Convergence – Forward looking Project “HotRockit” JDK 7 GA – 07/11 JDK 7u2 JDK 7uX JDK 8 GA • Hotspot 21 • Hotspot 22 • Hotspot 23 • Hotspot24 • Java SE 7 Support • Performance • More performance • Java SE 8 Support • Rebranding • Enable large heaps • Improved command • All performance • Improved JMX with reasonable line servicability features from latencies (jcmd) JRockit ported Agent • Enable large heaps • All servicability • Command line servicability tool with consistent features from (jrcmd) reasonable latencies JRockit ported • No PermGen • Compiler controls • Verbose logging --- Premium --- --- Premium --- --- Premium --- • Complete JRockit • JRockit Mission • Improved JRockit Flight Recorder Control Memleak Mission Control Support Tool Support Console support • Soft Real Time GC Thursday, September 8, 2011
  • 57. Java SE 8 Project Jigsaw (JSR-294) Modularising the Java Platform Project Lambda (JSR 335) Closures and lambda expressions Better support for multi-core processors More Project Coin Small Language Changes 57 Thursday, September 8, 2011
  • 58. 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 continues to grow and adapt to the changing world of IT 58 Thursday, September 8, 2011
  • 59. The 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. 59 Thursday, September 8, 2011