SlideShare una empresa de Scribd logo
1 de 32
Open Jei Di Key not only for DJ's
                                ATTENZIONE: Questo intervento è stato
                                reciclato tra quelli scartati.

                                Successivamente ripescato (tipo Pupo a
                                Sanremo) per la triste rinuncia di qualcuno a
                                tenere lo stra-atteso intervento:


              SKRONDO il linguaggio del futuro
                                     per qualcuno
                       Nino Guarnacci                     davide.delvecchio@gmail.com
                      Davide Del Vecchio                  nino.guarnacci@oracle.com



sabato 5 marzo 2011
Java Language




                      Most Popular Language in the World



                                      Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
Java Around Us



                      Servers     Desktop   Embedded     TV        Mobile     Card


                                                        BD-J


                      Java EE     JavaFX               Java TV     MSA



                                Java SE                  Java ME            Java Card



                                              Java Language




                                                   Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
JCP Evolve & Adapt Java




                             Community Development of
                            Java Technology Specifications


                                  Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
Java Priorities


                                  Grow Developer Base
                                     Grow Adoption

                                Increase Competitiveness

                                    Adapt to change




                                  Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
Vision Java

                  • Drive continued investment in the Java
                    platform across a range of servers and
                    devices

                  • Fuel further innovation in the Java
                    platform, including JavaFX

                  • Continue supporting developer
                    community, open source, and JCP



                                           Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
Standard Edition

              • Rapid delivery of JDK 7 Oracle
              • Converge features of HotSpot and JRockit
                JVM:
                 – Leading performance
                 – Monitoring and management
                 – Automated performance tuning
                 – Virtualized servers
                 – Efficient garbage collection
                 – Deterministic, real time behavior
              • Focus on Serviceability and Interoperability
              • Continue support for all leading OS platforms




                                               Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
Contributors

              • Oracle Is Committed to the Best Open-Source Java
                Implementation
              • Backed by Some of the biggest names in software:
                 –“Oracle and IBM Collaborate to Accelerate Java
                  Innovation Through OpenJDK”
                 –“Oracle and Apple Announce OpenJDK Project for Mac
                  OS X”
                 –Red Hat and Sun (Oracle) Collaborate to Advance Open
                  Source Java Technology




                                        Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
OJDK 7 Fetaures
     • InvokeDynamic byte code + supporting features
        – Multi-lang support

     • Small Language Enhancements (Project ”Coin”)

     • Lambda Expressions (“Closures”) JSR 335

     • SDP and SCTP Support

     • New I/O APIs
       – Filesystem, async I/O

     • JVM Improvements
        – Performance and serviceability


                                           Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
Project Coin

        Strings in switch


    • Binary integral literals and underscores in numeric literals


    • Multi-catch and more precise rethrow


    • try-with-resources statement


  • Improved type inference for generic instance creation (diamond)


    • Simplified varargs method invocation



                                        Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
String in Switch
  p    ublic String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) {

       String typeOfDay;
       switch (dayOfWeekArg) {
           case "Monday":
               typeOfDay = "Start of work week";
               break;
           case "Tuesday":
           case "Wednesday":
           case "Thursday":
               typeOfDay = "Midweek";
               break;
           case "Friday":
               typeOfDay = "End of work week";
               break;
           case "Saturday":
           case "Sunday":
               typeOfDay = "Weekend";
               break;
           default:
               throw new IllegalArgumentException("Invalid day of the week: " +
  dayOfWeekArg);
       }
       return typeOfDay;
  }


                                                Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
Binary integral literals and underscores in numeric
                          literals


                  // An 8-bit 'byte' literal.
               byte aByte = (byte)0b00100001;

               // A 16-bit 'short' literal.
               short aShort = (short)0b1010000101000101;




               long creditCardNumber = 1234_5678_9012_3456L;
               long socialSecurityNumber = 999_99_9999L;
               float pi = ! 3.14_15F;
               long hexBytes = 0xFF_EC_DE_5E;
               long hexWords = 0xCAFE_BABE;
               long maxLong = 0x7fff_ffff_ffff_ffffL;
               byte nybbles = 0b0010_0101;
               long bytes = 0b11010010_01101001_10010100_10010010;




                                                    Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
Multi-catch and more precise rethrow



                      catch (IOException ex) {
                           logger.log(ex);
                           throw ex;
                      catch (SQLException ex) {
                           logger.log(ex);
                           throw ex;
                      }




                                Open JDK7
                      catch (IOException|SQLException ex) {
                          logger.log(ex);
                          throw ex;
                      }




                                                        Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
try-with-resources statement
        static void copy(String src, String dest) throws   IOException {
      InputStream in = new FileInputStream(src);
      try {
         OutputStream out = new FileOutputStream(dest);
         try {
           byte[] buf = new byte[8 * 1024];                •   java.nio.channels.FileLock
                                                           •   javax.imageio.stream.ImageInputStream
           int n;
                                                           •   java.beans.XMLEncoder
           while ((n = in.read(buf)) >= 0)                 •   java.beans.XMLDecoder
             out.write(buf, 0, n);                         •   java.io.ObjectInput
         } finally {                                       •   java.io.ObjectOutput
           out.close();                                    •   javax.sound.sampled.Line
         }                                                 •   javax.sound.midi.Receiver
      } finally {                                          •   javax.sound.midi.Transmitter
                                                           •   javax.sound.midi.MidiDevice
         in.close();                                       •   java.util.Scanner
      }                                                    •   java.sql.Connection
  }                                                        •   java.sql.ResultSet
                                                           •   java.sql.Statement
                      Open JDK7
  static void copy(String src, String dest) throws IOException {
    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);
    }

                                                 Nino Guarnacci <--> Davide Del Vecchio
sabato 5 marzo 2011
Linguaggi per la JVM (http://is-research.de/info/
                      vmlanguages)




                                       Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Perché tutto questo
                         affollamento?

                      Perché viene scelto di usare il
                        runtime di java per
                        implementare nuovi linguaggi
                        anche strutturalmente diversi?




                                    Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Multi Language JVM JRuby (Antonio Cangiano
                      Luglio 2010)




                                      Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Vantaggi dell’uso di una JVM


    Velocità :
    > performance (JIT che ottimizza le
     chiamate, nessun interprete)
    > Uso della memoria efficiente (GC,
     nessuna allocazione tramite primitive
     malloc)
    > multiprocessor scaling (pervasive
     threading)
                                Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Vantaggi per Java di questa
                      apertura

    In molti casi è utile disporre di un
      linguaggio con una semantica diversa
    >Testing (è molto comodo scrivere un
     test per Java in Groovy)
    >DSL (espressività ..)




                                Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Strumenti


                      Che cosa abbiamo a
                       disposizione per
                       implementare nuovi
                       linguaggi e migliorare
                       le perfomance di quelli
                       che ci sono?




                                   Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Javax.scripting Solo un Driver


    
    Le JSR 223 (Scripting for the java platform) tenevano conto
       della necessità di interazione con diversi linguaggi di
       scripting : poteva essere dichiarato uno scripting engine
       ed invocato da codice java alla maniera in cui si carica un
       driver JDBC
    
      ScriptEngineManager scriptEngineMgr = new
           ScriptEngineManager(); ScriptEngine jsEngine =
           scriptEngineMgr.getEngineByName("JavaScript");




                                      Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
VM multilinguaggio


    > Supporto per linguaggi dinamici
    > Perfomance paragonabili a quelle native
    > Estendibile senza hacking o riuso
          Il codice scritto in un linguaggio dovrebbe:
                      Invocare codice scritto in un linguaggio
                       diverso
                      Manipolare oggetti nativi di un
                       linguaggio diverso

                                       Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Come avviene l’invocazione di un
                       metodo?


                      Pensiamo ad
                        un’invocazione di un
                        metodo come ad un
                        trasferimento di
                        messaggi




                                  Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Come avviene un’invocazione
                        (bytecode)

                      identificati   scope        receiver?    dispatch?
                      vo
                      invokestatic   class        no           no



                      invokespecia class          yes          no
                      l
                      invokevirtual class         yes          yes


                      invokeinterfa interface     yes          yes
                      ce




                                                Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Un’ulteriore ditta di trasporto
                         Invokedynamic


                               obj.helloText
                                      ⇓
                       methodVisitor.visitMethodInsn(
                              INVOKEDYNAMIC,
                              "InvokeDynamic",
                           "dyn:getProp:helloText",
                      "(Ljava/lang/Object;)Ljava/lang/
                                   Object;");
                                      Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Perché è meglio?


    Separa il lavoro in due fasi: link-time
      and
    invocation-time
    • Quanto più possiamo spendere su
      link-time è meglio
    • nel caso precedente l’id della
      proprietà è fisso e quindi può essere
      risolto a link-time
                                Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Come la reflection? NO

                      Java può fare questo con le
                        reflection API (che sono
                        quelle adoperate per
                        l’implementazione dei
                        linguaggi visti prima)




                                 Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Reflection Basics


    public static Object invoke(Object
     targetObject, String methodName,
     Object[] arguments, Class<?>[]
     signature)

    
 return method.invoke(targetObject,
      arguments);


                                Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
No Wrapping

                      Non ci sono tutte le
                         restrizioni
                         dell’invocazione di
                         metodi
                      • Nessun wrapping di
                        eccezione
                      • La verifica delle
                        condizioni di accesso è
                        fatta a tempo di
                        creazione
                                  Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Piccole patch per la JVM
                      ufficiale

    >invokedynamic (indy.patch)
    > method handles (meth.patch)
    > small Java language changes
     (langtools/meth.patch)
    > interface injection (inti.patch)



                                Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
JSR 292

    JSR-292 fornisce la specifica per la il bytecode perla
       dynamic method invocation, più un meccanismo
       per l’evoluzione del codice
    > Quello che adesso è presente è il
    • invokedynamic bytecode
    • Application-defined linkage (and re-linkage)
    • Method handles
    • Un’infrastruttura generale per "code pointers"
    • Interface injection


                                Davide Del Vecchio <--> Nino Guarnacci
sabato 5 marzo 2011
Nino Guarnacci             Davide Del Vecchio
            nino.guarnacci@oracle.com   davide.delvecchio@gmail.com


                               lo SKRONDO


sabato 5 marzo 2011

Más contenido relacionado

Destacado

Amor e Vingança
Amor e VingançaAmor e Vingança
Amor e Vingança
Kaio Rios
 
Uk england country editable powerpoint maps with states and counties
Uk england country editable powerpoint maps with states and countiesUk england country editable powerpoint maps with states and counties
Uk england country editable powerpoint maps with states and counties
SlideTeam.net
 

Destacado (11)

Team2-Week9
Team2-Week9Team2-Week9
Team2-Week9
 
Team1 week9
Team1 week9Team1 week9
Team1 week9
 
La unidad del alma hacia con dios
La unidad del alma hacia con diosLa unidad del alma hacia con dios
La unidad del alma hacia con dios
 
Amor e Vingança
Amor e VingançaAmor e Vingança
Amor e Vingança
 
almuerzo navidad
almuerzo navidad almuerzo navidad
almuerzo navidad
 
Comunicació efectiva i llenguatge no verbal (euncet)
Comunicació efectiva i llenguatge no verbal (euncet)Comunicació efectiva i llenguatge no verbal (euncet)
Comunicació efectiva i llenguatge no verbal (euncet)
 
Eletricidade
EletricidadeEletricidade
Eletricidade
 
El poder del paradigma
El poder del paradigmaEl poder del paradigma
El poder del paradigma
 
Uk england country editable powerpoint maps with states and counties
Uk england country editable powerpoint maps with states and countiesUk england country editable powerpoint maps with states and counties
Uk england country editable powerpoint maps with states and counties
 
Basic Statistic
Basic Statistic Basic Statistic
Basic Statistic
 
McDonald's and Franchising
McDonald's and FranchisingMcDonald's and Franchising
McDonald's and Franchising
 

Similar a Open Jei Di Key not only for DJ's

Introduzione a node: cenni storici ecc
Introduzione a node: cenni storici eccIntroduzione a node: cenni storici ecc
Introduzione a node: cenni storici ecc
Luciano Colosio
 
Terracotta Torino Javaday
Terracotta Torino JavadayTerracotta Torino Javaday
Terracotta Torino Javaday
Simone Federici
 

Similar a Open Jei Di Key not only for DJ's (20)

javaday 2006 - Tiger
javaday 2006 - Tigerjavaday 2006 - Tiger
javaday 2006 - Tiger
 
Scala: come recuperare la programmazione funzionale e perché
Scala: come recuperare la programmazione funzionale e perchéScala: come recuperare la programmazione funzionale e perché
Scala: come recuperare la programmazione funzionale e perché
 
Java basics
Java basicsJava basics
Java basics
 
Sviluppo Rapido Di Applicazioni Con Grails
Sviluppo Rapido Di Applicazioni Con GrailsSviluppo Rapido Di Applicazioni Con Grails
Sviluppo Rapido Di Applicazioni Con Grails
 
Maven Eclipse
Maven EclipseMaven Eclipse
Maven Eclipse
 
Easy Driver
Easy DriverEasy Driver
Easy Driver
 
continuous integration rubyday Italy 2011
continuous integration rubyday Italy 2011continuous integration rubyday Italy 2011
continuous integration rubyday Italy 2011
 
Node.js – Convincing the boss
Node.js – Convincing the bossNode.js – Convincing the boss
Node.js – Convincing the boss
 
Json Web Tokens
Json Web TokensJson Web Tokens
Json Web Tokens
 
Webbit 2004: Tiger, java
Webbit 2004: Tiger, javaWebbit 2004: Tiger, java
Webbit 2004: Tiger, java
 
JWT: JSON Web Tokens - bye bye Session and Cookie - RFC7519
JWT: JSON Web Tokens - bye bye Session and Cookie - RFC7519JWT: JSON Web Tokens - bye bye Session and Cookie - RFC7519
JWT: JSON Web Tokens - bye bye Session and Cookie - RFC7519
 
Introduzione al java
Introduzione al javaIntroduzione al java
Introduzione al java
 
Continuous Delivery Database - Diego Mauricio Lagos Morales - Codemotion Rome...
Continuous Delivery Database - Diego Mauricio Lagos Morales - Codemotion Rome...Continuous Delivery Database - Diego Mauricio Lagos Morales - Codemotion Rome...
Continuous Delivery Database - Diego Mauricio Lagos Morales - Codemotion Rome...
 
Groovy technology ecosystem
Groovy technology ecosystemGroovy technology ecosystem
Groovy technology ecosystem
 
Introduzione a node: cenni storici ecc
Introduzione a node: cenni storici eccIntroduzione a node: cenni storici ecc
Introduzione a node: cenni storici ecc
 
Workshop: Introduzione ad TDD
Workshop: Introduzione ad TDDWorkshop: Introduzione ad TDD
Workshop: Introduzione ad TDD
 
Struttin' on, novità in casa Struts
Struttin' on, novità in casa StrutsStruttin' on, novità in casa Struts
Struttin' on, novità in casa Struts
 
React JS + ES6
React JS + ES6React JS + ES6
React JS + ES6
 
Glossario tecnologico 2011
Glossario tecnologico   2011Glossario tecnologico   2011
Glossario tecnologico 2011
 
Terracotta Torino Javaday
Terracotta Torino JavadayTerracotta Torino Javaday
Terracotta Torino Javaday
 

Más de Codemotion

Más de Codemotion (20)

Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
 
Pompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending storyPompili - From hero to_zero: The FatalNoise neverending story
Pompili - From hero to_zero: The FatalNoise neverending story
 
Pastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storiaPastore - Commodore 65 - La storia
Pastore - Commodore 65 - La storia
 
Pennisi - Essere Richard Altwasser
Pennisi - Essere Richard AltwasserPennisi - Essere Richard Altwasser
Pennisi - Essere Richard Altwasser
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 - Francesco Baldassarri  - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
 

Open Jei Di Key not only for DJ's

  • 1. Open Jei Di Key not only for DJ's ATTENZIONE: Questo intervento è stato reciclato tra quelli scartati. Successivamente ripescato (tipo Pupo a Sanremo) per la triste rinuncia di qualcuno a tenere lo stra-atteso intervento: SKRONDO il linguaggio del futuro per qualcuno Nino Guarnacci davide.delvecchio@gmail.com Davide Del Vecchio nino.guarnacci@oracle.com sabato 5 marzo 2011
  • 2. Java Language Most Popular Language in the World Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 3. Java Around Us Servers Desktop Embedded TV Mobile Card BD-J Java EE JavaFX Java TV MSA Java SE Java ME Java Card Java Language Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 4. JCP Evolve & Adapt Java Community Development of Java Technology Specifications Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 5. Java Priorities Grow Developer Base Grow Adoption Increase Competitiveness Adapt to change Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 6. Vision Java • Drive continued investment in the Java platform across a range of servers and devices • Fuel further innovation in the Java platform, including JavaFX • Continue supporting developer community, open source, and JCP Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 7. Standard Edition • Rapid delivery of JDK 7 Oracle • Converge features of HotSpot and JRockit JVM: – Leading performance – Monitoring and management – Automated performance tuning – Virtualized servers – Efficient garbage collection – Deterministic, real time behavior • Focus on Serviceability and Interoperability • Continue support for all leading OS platforms Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 8. Contributors • Oracle Is Committed to the Best Open-Source Java Implementation • Backed by Some of the biggest names in software: –“Oracle and IBM Collaborate to Accelerate Java Innovation Through OpenJDK” –“Oracle and Apple Announce OpenJDK Project for Mac OS X” –Red Hat and Sun (Oracle) Collaborate to Advance Open Source Java Technology Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 9. OJDK 7 Fetaures • InvokeDynamic byte code + supporting features – Multi-lang support • Small Language Enhancements (Project ”Coin”) • Lambda Expressions (“Closures”) JSR 335 • SDP and SCTP Support • New I/O APIs – Filesystem, async I/O • JVM Improvements – Performance and serviceability Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 10. Project Coin Strings in switch • Binary integral literals and underscores in numeric literals • Multi-catch and more precise rethrow • try-with-resources statement • Improved type inference for generic instance creation (diamond) • Simplified varargs method invocation Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 11. String in Switch p ublic String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) { String typeOfDay; switch (dayOfWeekArg) { case "Monday": typeOfDay = "Start of work week"; break; case "Tuesday": case "Wednesday": case "Thursday": typeOfDay = "Midweek"; break; case "Friday": typeOfDay = "End of work week"; break; case "Saturday": case "Sunday": typeOfDay = "Weekend"; break; default: throw new IllegalArgumentException("Invalid day of the week: " + dayOfWeekArg); } return typeOfDay; } Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 12. Binary integral literals and underscores in numeric literals // An 8-bit 'byte' literal. byte aByte = (byte)0b00100001; // A 16-bit 'short' literal. short aShort = (short)0b1010000101000101; long creditCardNumber = 1234_5678_9012_3456L; long socialSecurityNumber = 999_99_9999L; float pi = ! 3.14_15F; long hexBytes = 0xFF_EC_DE_5E; long hexWords = 0xCAFE_BABE; long maxLong = 0x7fff_ffff_ffff_ffffL; byte nybbles = 0b0010_0101; long bytes = 0b11010010_01101001_10010100_10010010; Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 13. Multi-catch and more precise rethrow catch (IOException ex) { logger.log(ex); throw ex; catch (SQLException ex) { logger.log(ex); throw ex; } Open JDK7 catch (IOException|SQLException ex) { logger.log(ex); throw ex; } Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 14. try-with-resources statement static void copy(String src, String dest) throws IOException { InputStream in = new FileInputStream(src); try { OutputStream out = new FileOutputStream(dest); try { byte[] buf = new byte[8 * 1024]; • java.nio.channels.FileLock • javax.imageio.stream.ImageInputStream int n; • java.beans.XMLEncoder while ((n = in.read(buf)) >= 0) • java.beans.XMLDecoder out.write(buf, 0, n); • java.io.ObjectInput } finally { • java.io.ObjectOutput out.close(); • javax.sound.sampled.Line } • javax.sound.midi.Receiver } finally { • javax.sound.midi.Transmitter • javax.sound.midi.MidiDevice in.close(); • java.util.Scanner } • java.sql.Connection } • java.sql.ResultSet • java.sql.Statement Open JDK7 static void copy(String src, String dest) throws IOException { 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); } Nino Guarnacci <--> Davide Del Vecchio sabato 5 marzo 2011
  • 15. Linguaggi per la JVM (http://is-research.de/info/ vmlanguages) Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 16. Perché tutto questo affollamento? Perché viene scelto di usare il runtime di java per implementare nuovi linguaggi anche strutturalmente diversi? Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 17. Multi Language JVM JRuby (Antonio Cangiano Luglio 2010) Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 18. Vantaggi dell’uso di una JVM Velocità : > performance (JIT che ottimizza le chiamate, nessun interprete) > Uso della memoria efficiente (GC, nessuna allocazione tramite primitive malloc) > multiprocessor scaling (pervasive threading) Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 19. Vantaggi per Java di questa apertura In molti casi è utile disporre di un linguaggio con una semantica diversa >Testing (è molto comodo scrivere un test per Java in Groovy) >DSL (espressività ..) Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 20. Strumenti Che cosa abbiamo a disposizione per implementare nuovi linguaggi e migliorare le perfomance di quelli che ci sono? Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 21. Javax.scripting Solo un Driver Le JSR 223 (Scripting for the java platform) tenevano conto della necessità di interazione con diversi linguaggi di scripting : poteva essere dichiarato uno scripting engine ed invocato da codice java alla maniera in cui si carica un driver JDBC ScriptEngineManager scriptEngineMgr = new ScriptEngineManager(); ScriptEngine jsEngine = scriptEngineMgr.getEngineByName("JavaScript"); Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 22. VM multilinguaggio > Supporto per linguaggi dinamici > Perfomance paragonabili a quelle native > Estendibile senza hacking o riuso Il codice scritto in un linguaggio dovrebbe: Invocare codice scritto in un linguaggio diverso Manipolare oggetti nativi di un linguaggio diverso Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 23. Come avviene l’invocazione di un metodo? Pensiamo ad un’invocazione di un metodo come ad un trasferimento di messaggi Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 24. Come avviene un’invocazione (bytecode) identificati scope receiver? dispatch? vo invokestatic class no no invokespecia class yes no l invokevirtual class yes yes invokeinterfa interface yes yes ce Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 25. Un’ulteriore ditta di trasporto Invokedynamic obj.helloText ⇓ methodVisitor.visitMethodInsn( INVOKEDYNAMIC, "InvokeDynamic", "dyn:getProp:helloText", "(Ljava/lang/Object;)Ljava/lang/ Object;"); Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 26. Perché è meglio? Separa il lavoro in due fasi: link-time and invocation-time • Quanto più possiamo spendere su link-time è meglio • nel caso precedente l’id della proprietà è fisso e quindi può essere risolto a link-time Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 27. Come la reflection? NO Java può fare questo con le reflection API (che sono quelle adoperate per l’implementazione dei linguaggi visti prima) Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 28. Reflection Basics public static Object invoke(Object targetObject, String methodName, Object[] arguments, Class<?>[] signature) return method.invoke(targetObject, arguments); Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 29. No Wrapping Non ci sono tutte le restrizioni dell’invocazione di metodi • Nessun wrapping di eccezione • La verifica delle condizioni di accesso è fatta a tempo di creazione Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 30. Piccole patch per la JVM ufficiale >invokedynamic (indy.patch) > method handles (meth.patch) > small Java language changes (langtools/meth.patch) > interface injection (inti.patch) Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 31. JSR 292 JSR-292 fornisce la specifica per la il bytecode perla dynamic method invocation, più un meccanismo per l’evoluzione del codice > Quello che adesso è presente è il • invokedynamic bytecode • Application-defined linkage (and re-linkage) • Method handles • Un’infrastruttura generale per "code pointers" • Interface injection Davide Del Vecchio <--> Nino Guarnacci sabato 5 marzo 2011
  • 32. Nino Guarnacci Davide Del Vecchio nino.guarnacci@oracle.com davide.delvecchio@gmail.com lo SKRONDO sabato 5 marzo 2011