Java 7: Quo vadis?

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Java 7: Quo vadis? - Presentation Transcript

        • Michal Malohlava
      Java 7 : Quo vadis? DISTRIBUTED SYSTEMS RESEARCH GROUP http://dsrg.mff.cuni.cz/ CHARLES UNIVERSITY IN PRAGUE Faculty of Mathematics and Physics
      • Java development process
      • Language extension
      • Related projects
        • Java Module System
      • Conclusion
      Outline
      • JDK
        • Official Sun's Java
        • Source code released (GPL v.2)
        • 18months release interval
          • JDK6 fall 2006 => JDK7 spring 2008 (January 2009:)
        • Still no official JSR ( Java Specification Request )
          • only many proposals of Java7 features/anti-features
      • OpenJDK
        • Free implementation of JDK by Java community
          • OpenJDK 6 will be based on OpenJDK 7
        • Now only Modules project - JSR 277, JSR 294
      Java development process
      • No official JSR
        • Still in discussion
      • JUG (Java User Group)
        • Unofficial JSR for JDK7
          • Published on 7 th November
        • Specify
          • Closures
          • Generics, enum, switch enhancements
          • Chained invocations, extension methods
          • Exception catching
      Language extensions
      • Generics
        • Constructors without duplicate declaration
          • Map<String, List<String>> anagrams = new HashMap<>(); instead of Map<String, List<String>> anagrams = new HashMap<String, List<String>>();
          • Generics are not still covariant!
            • List<Integer> li = new ArrayList<Integer>(); List<Number> ln = li; // illegal ln.add(new Float(3.1415)); // legal
        • More type safe packages
          • JDK 5: static Object newInstance(Class<?> componentType, int size)
            • Because of backward compatibility
          • JDK 5,7: static<T> T[] newInstance(Class<T> componentType, int size)
            • More type-safe, can be called Array.<String>newInstance(String.class, 10)
        • Inference of method arguments
            • static<E> Set<E> emptySet();
            • void print(Set<Man> men) {...}
            • Call: print(Collection.emptySet()) // in JDK5,6 is necessary to explicitly specify which method should be called: Collection.<Man>emptySet();
        • Template type information available at runtime
      Lang. Ext. - JUG proposal
      • Enum
        • JDK6: Enum implements Comparable, but cannot be used in expressions with <, >, >=, <=
        • JDK7:
      • Strings in switch
        • Use strings as constants in switch-statement instead of bundle of equals:
      Lang. Ext. - JUG proposal enum Size {SMALL, MEDIUM, LARGE}; if (mySize < yourSize) { /* ... */ } switch (s) { “ yellow” : /* ... */ break ; “ red” : /* ... */ break ; defaul t: /* ... */ break ; } JDK7 JDK7
      • Chained invocations
        • Reuse the receiver of previous call in case of a call of a method returning void
      • Method extensions
        • A way how to extend existing interface by utility methods
          • Static imported method can be used as a member of its first argument
      Lang. Ext. - JUG proposal public class Beana { public void setName(String void) {} public void setDate(Date date) {} } Beana a = new Beana() .setName(“name”) .setDate(new Date()); import static java.util.Collections.sort; ... List<String> list = ...; list.sort(); JDK7
      • Catching multiple exception types
        • To avoid repeating code
      Lang. Ext. - JUG proposal
      • More flexible checking of re-thrown exception
          • When we need to catch all exceptions, do something with them and re throw them
            • Re-thrown exception is threated as if it can throw only checked exceptions occurring in the try block
      public void test() throws IOException { try { doSomething(); } catch ( final Throwable ex) { throw ex; } } try { return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { /* .. */ } public void doSomething throws IOException {} public void test() throws Throwable { try { doSomething(); } catch (Throwable ex) } throw ex; } JDK7 JDK7 JDK5
      • Creation of XML fragments
        • XML embedded in Java code
          • <tag> or #tag
        • Data coders in according to XSD
          • date/time
      • XPath language support
      Lang. Ext. - XML lang. support public void addMember(XML xml, String name, Integer age) { xml.addChild(<member> <name> { name } </name> <age> { 26 } </age> </member>); } public void makeYounger(XML fs, Integer newAge) { List<XML> l = fs.findAll(“member[age>25]”); for (XML a : l) { a.get(“age”).set(newAge); } } JDK7 JDK7
      • Closures
        • Similar to delegates in C#
        • Anonymous functions
        • Function type
          • Local functions
      • Main idea: translate closure to interface (similar to creating anonymous classes)
      Lang. Ext. - closures {String, String => String} simpleConcat = {String a, String b => a+b }; String s = “DS”; String g = “RG”; String dsrg = simpleConcat.invoke(s,t); interface Func<R extends String, A1 super String, A2 super String> { public R invoke(A1, A2); } ↔ Locks.withLock(lock, {=> doSomething()}); Collections.map(strings, {Strings s => Integer.decode(s)}); JDK7
      • Additional information
        • @Licence
      • Annotations for static analysis of code
        • @NonNull
        • @NonEmpty
        • @ReadOnly
        • @Existing
        • @Critical
      Lang. Ext. - annotation extension
      • Operator overloading (BigDecimal)
        • Arithmetic operators for BigDecimal
      • Lightweight reflection
      • 64bit index for arrays
      • XQuery support (JSR 225)
      • Resource Consumption Management API (JSR 284)
        • Performance policies (CPU, heap consumption per application/thread, reservations)
      • Null-safe types
        • public void method(#K key)
          • # marks not-null parameter
            • Checked at compile time (globally, per-method,...)
          • (#) casting operator
          • Alternative to @NonNull annotation
      Lang. Ext. - proposed enhancements
      • Separated projects
        • Almost work in the current version of Java
        • Proposed to be part of JDK7
          • Java Modules
          • Beans bindings, validation
          • Swing application API
          • ...
      Related projects
      • Superpackages (JSR 294)
        • Why? To hide unnecessary packages.
        • Superpackage is a named collection of packages or superpackages, classes
        • Accessibility defined by superpackages
          • Compiled, loaded and checked by JVM at runtime
        • Define development module for JSR 277 (Java Module System)
        • Separate compilation ?
          • Not yet specified
      Rel. projects – modules superpackage jdk { member package java.util; member package java.io; member package sun.io; // Impl detail export java.util.*; // Public API export java.io.*; } JDK7
      • Java Modules (JSR 277)
        • Specifies:
          • Modules, Versioning, Repository, Runtime support
      • Development module (=superpackage) => deployment module (JAM – Java Module)
        • Meta-info (generated from devel. module)
        • Compiled code
        • Resources
      • Versioning
        • Simple major/minor versions
        • Intervals, expressions e.g 1.3* = <1.3, 1.4)
      Rel. projects – modules
    1. Rel. projects – modules
      • Repository
        • Can store more than one version of module
          • Bootstrap repository
            • Contains core modules (Java SE)
            • Always presented in system
          • Application repository
            • Modules specific for application
        • Delegation model of repositories
          • Parent repository
            • Search is delegated to the parent repository
            • Insulating of modules
        • Other features
          • Repository reload, sharing modules among repositories (repository interchange format)
        • Changed classloading
      • OSGi and JAM
        • Comparison – special seminar
      Rel. projects – modules and OSGi
      • JSR 296
      • Framework for Swing applications
        • library for typical operations:
        • ApplicationContext
          • Provides resource, task management, session storage.
          • Each application has one ApplicationContext
        • Application
          • lifecycle
      Rel. projects – SWING API
      • Beans bindings (JSR 295)
        • Keep properties of beans synced (bindings), listeners to properties...
          • the project works with JDK5
          • Mainly focused on SWING
      • Property keyword
        • Spec. is really vague:
          • No more getter/setters
          • In fact generates inner class with property getter/setters
            • Property per-type
          • Access attribute member#surname = “Sac”
          • Access property object member##surname
          • ?Readonly properties?
      Rel. projects – beans class Person { private String surname; private Integer age; private Person mother; } // Bean property Property surnameP = BeanProperty.create(“surname”); // EL properties – JSP syntax Property motherSurnameP = BeanProperty.create(“${mother.surname}”); Property isTeenP = BeanProperty.create(“${age < 20}”); // m stores information about a person System.out.println(“Member surname = “ + surnameP.getValue(m)); System.out.println(“Member's mother surname = “ + surnameP.getValue(M)); Binding b = Bindings.createAutoBinding(READ_WRITE, m, surnameP,m , motherSurnameP); b.bind(); // the call affects attribute m.surname motherSurnameP.setValue(m, “NewSurname”);
      • Beans Validation (JSR 303)
        • Bindings validation ( à la Hibernate Validator)
          • constraints via annotations, e.g.:
            • @NotNull, @NotEmpty
            • @Min(value=), @Max(value=)
            • @Length(min=, max=), @Range(min=,max=)
            • @Past/@Future, @Email
            • ...
          • New constraint = new annotation + new class
      Rel. projects – beans
      • Improvements of JSR 166 (Concurrency utilities)
        • Fork-join concept
          • Fine-grained parallel computation framework
          • Divide problems to subproblems, solve it, join the results
            • Subproblems are executed in parallel, current thread waits until they complete
              • coInvoke(task1, task2)
          • Work-stealing
            • Each thread has deque of tasks, instead of sleeping try to steal and execute a task from other busy threads
        • TransferQueue (type of BlockingQueue )
          • Producer side blocking until the consumers is ready
      Rel. projects – concurrent framework
      • Improvements of JSR 166 (Concurrency utilities)
        • Fork-join concept
          • Fine-grained parallel computation framework
          • Divide problems to subproblems, solve it, join the results
            • Subproblems are executed in parallel, current thread waits until they complete
              • coInvoke(task1, task2)
          • Work-stealing
            • Each thread has deque of tasks, instead of sleeping try to steal and execute a task from other threads
        • TransferQueue (type of BlockingQueue )
          • Producer side blocking until the consumers is ready
      Rel. projects – concurrent framework // PSEUDOCODE Result solve(Problem problem) { if (problem.size < SEQUENTIAL_THRESHOLD) return solveSequentially(problem); else { Result left, right; INVOKE-IN-PARALLEL { left = solve(extractLeftHalf(problem)); right = solve(extractRightHalf(problem)); } return combine(left, right); } } JDK7
      • JVM change
      • Invokedynamic (JSR 292)
        • Improvement of scripting engine (JSR 223)
        • New byte code instruction (type free invokevirtual)
          • Support for dynamically typed languages (Jython, Groovy)
            • Jython – code written in Python, compiled into byte code at runtime, run in JVM
          • Target of call/parameters need not to be statically known
      Rel. projects – invokedynamic
      • Units and Quantities (JSR 275)
        • Conversions between many SI/Imperial units
      • JMX 2.0 (JSR 255)
          • Annotations support for def. MBeans
      • JMX Web Service Connector (JSR 262)
      • Native IO - NIO 2.0 (JSR 203)
          • New filesystem API (access file attributes, ...)
          • Async IO
      • Javadoc update (JSR 260)
        • New tags and documentation mechanism
      Rel. projects – others
      • Java kernel
        • Should be a part of JDK7, but will be released earlier in like “Consumer JRE” in 2008
        • Small installation of Java
      • Improved installation ?
      • Startup time of JVM ?
        • Tiered compilation
          • Mix of client and server hot spot compiler
      • HotSpot improvements ?
      Other proposed improvements
      • JDK7
        • Current build 23 (22 th November)
          • Only bug fixes, no new features
      • OpenJDK
        • Modules (JSR254, JSR257)
      • Projects
        • Beans binding, Fork framework, Swing API
      • Missing!
        • No proposals from EE (mainly app. servers)?
          • Separation of application in JVM
      What is already implemented?
      • Java module system
        • How will it cooperate with OSGi?
      • Java kernel
      • Annotations
        • Static analysis of code
      • How will Google's Android affect Sun's Java?
      Important for us
      • Sun JDK7 Project
        • https://jdk7.dev.java.net/
      • OpenJDK
        • http://openjdk.java.net/
      • Overview of Java 7 (updated)
        • http://tech.puredanger.com/java7
      Links

    + mmalohlavammalohlava, 2 years ago

    custom

    828 views, 1 favs, 2 embeds more stats

    This presentations try to make a brief overview of more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 828
      • 814 on SlideShare
      • 14 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 41
    Most viewed embeds
    • 13 views on http://dsrg.mff.cuni.cz
    • 1 views on http://static.slideshare.net

    more

    All embeds
    • 13 views on http://dsrg.mff.cuni.cz
    • 1 views on http://static.slideshare.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags