Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java 7 – New Features Svetlin Nakov, Mihail Stoynov Bulgarian Association of Software Developers www.devbg.org BGJUG, TU-Sofia, hall 2140 20.05.2010 BGJUG,

Similar presentations


Presentation on theme: "Java 7 – New Features Svetlin Nakov, Mihail Stoynov Bulgarian Association of Software Developers www.devbg.org BGJUG, TU-Sofia, hall 2140 20.05.2010 BGJUG,"— Presentation transcript:

1 Java 7 – New Features Svetlin Nakov, Mihail Stoynov Bulgarian Association of Software Developers www.devbg.org BGJUG, TU-Sofia, hall 2140 20.05.2010 BGJUG, TU-Sofia, hall 2140 20.05.2010

2 About the Speakers Svetlin NakovSvetlin Nakov 15+ years software engineering experience15+ years software engineering experience PhD in computer science from Sofia UniversityPhD in computer science from Sofia University Chairman of the Bulgarian Association of Software Developers (BASD) – www.devbg.orgChairman of the Bulgarian Association of Software Developers (BASD) – www.devbg.org www.devbg.org Author of 6 books about Java,.NET and software engineeringAuthor of 6 books about Java,.NET and software engineering Blog: www.nakov.com/blog/Blog: www.nakov.com/blog/www.nakov.com/blog/

3 About the Speakers (2) Mihail StoynovMihail Stoynov Dev Lead, Materna BulgariaDev Lead, Materna Bulgaria Many years software engineering experience with Java,.NET and othersMany years software engineering experience with Java,.NET and others Blog: http://mihail.stoynov.com/blog/Blog: http://mihail.stoynov.com/blog/ http://mihail.stoynov.com/blog/

4 Table of Contents Java 7 – Introduction and ChronologyJava 7 – Introduction and Chronology Dynamic Languages in JVMDynamic Languages in JVM Java Modularity – Project JigsawJava Modularity – Project Jigsaw Language Enhancements (Project Coin)Language Enhancements (Project Coin) Closures for JavaClosures for Java JSR 203: NIO 2JSR 203: NIO 2 Other new features:Other new features: Compressed 64-bit oops, Garbage-First GC, Upgraded Class-Loaders, URLClassLoader. close(), Unicode 5.1, SCTP and SDPCompressed 64-bit oops, Garbage-First GC, Upgraded Class-Loaders, URLClassLoader. close(), Unicode 5.1, SCTP and SDP

5 Introduction and Chronology

6 OpenJDK JDK7 is the second JDK done via the OpenJDK effortJDK7 is the second JDK done via the OpenJDK effort OpenJDK is free, open-source and GPL licensedOpenJDK is free, open-source and GPL licensed A lot of the improvements of JDK7 are separate projects on OpenJDKA lot of the improvements of JDK7 are separate projects on OpenJDK Some say that projects go under the cap of OpenJDK to avoid the cumbersome and slow JCP processSome say that projects go under the cap of OpenJDK to avoid the cumbersome and slow JCP process

7 Java 7 – Milestones Began in August 2006Began in August 2006 First supposed to be 7 milestonesFirst supposed to be 7 milestones Mark Reinhold extended them to 10Mark Reinhold extended them to 10 Current status: M7 finished, presentation made with build89Current status: M7 finished, presentation made with build89 M10 expected to finish 09.09.2010M10 expected to finish 09.09.2010 “The last scheduled milestone cycle will be followed by a test and stabilization period of indeterminate length, after which the final release will be declared”

8 There’s No JSR Yet A Java 7 JSR is supposed to be formed Java SE 6 was under the 'Umbrella' JSR 270 JDK7 is in Eclipse’s low priority list because a lack of container JSR JDK7 cannot be finalized without a JSR There are some functionalities that also lack a JSR While doing this presentation we used the term JSR TBD in lieu of the missing JSR

9 Source Control System Official SCM is SVN, still Note: it takes a 'while' (e.g. one night) Unofficial Mercurial forest repositories available since November 2007 Note: this also takes a 'while' >svn co https://jdk7.dev.java.net/svn/jdk7/trunk >hg fclone http://hg.openjdk.java.net/

10 Currently Supported IDEs EclipseEclipse Both Eclipse 3.6M6 and E4 do not support JDK7’s syntaxBoth Eclipse 3.6M6 and E4 do not support JDK7’s syntax … or I couldn’t figure it out… or I couldn’t figure it out Strangely enough the option is there:Strangely enough the option is there: Source compatibility: 1.7Source compatibility: 1.7 NetBeansNetBeans 6.9 Beta supports JDK76.9 Beta supports JDK7 Compiles successfully the M7 syntaxCompiles successfully the M7 syntax

11 Dynamic Languages in JVM

12 The Da Vinci Machine Project Prototype a number of extensions to the JVMPrototype a number of extensions to the JVM A.k.a. Multi Language Virtual Machine – http://openjdk.java.net/projects/mlvm/A.k.a. Multi Language Virtual Machine – http://openjdk.java.net/projects/mlvm/ http://openjdk.java.net/projects/mlvm/ Allows non-Java dynamic languages to run efficiently in the JVMAllows non-Java dynamic languages to run efficiently in the JVM Emphasis is on general purpose extensionsEmphasis is on general purpose extensions Hosted on OpenJDKHosted on OpenJDK Da Vinci: a multi-language renaissance for the Java Virtual Machine architecture

13 Dynamic Languages in JVM Da Vinci Machine sub-projects include:Da Vinci Machine sub-projects include: Dynamic invocationDynamic invocation ContinuationsContinuations Tail-callsTail-calls And interface injectionAnd interface injection JSR 292: Supporting Dynamically Typed Languages on the Java PlatformJSR 292: Supporting Dynamically Typed Languages on the Java Platform The standard behind Da Vinci MachineThe standard behind Da Vinci Machine Natural continuation of JSR 223: Scripting for the Java Platform implemented in JDK 6Natural continuation of JSR 223: Scripting for the Java Platform implemented in JDK 6

14 Dynamic Languages in JVM (2) New JVM instruction invokedynamicNew JVM instruction invokedynamic Allows extremely fast dynamic method invocation through method handlesAllows extremely fast dynamic method invocation through method handles Will enable JRuby, Jython, Groovy and other dynamic and scripting languages to call dynamic methods natively at bytecode levelWill enable JRuby, Jython, Groovy and other dynamic and scripting languages to call dynamic methods natively at bytecode level Method handlesMethod handles Lightweight references to a method – java.dyn.MethodHandleLightweight references to a method – java.dyn.MethodHandle Anonymous classes in the JVMAnonymous classes in the JVM

15 Dynamic Languages in JVM (3) Autonomous methodsAutonomous methods Methods that can be dynamically attached to an existing class at runtimeMethods that can be dynamically attached to an existing class at runtime Interface injectionInterface injection Acquiring base interfaces and method implementations at runtimeAcquiring base interfaces and method implementations at runtime Continuations and stack introspectionContinuations and stack introspection Suspend / resume thread's execution stackSuspend / resume thread's execution stack Tail calls and tail recursionTail calls and tail recursion

16 Dynamic Languages in JVM (4) Runtime support for closuresRuntime support for closures Closure is a lambda-expression bound (closed) to its environmentClosure is a lambda-expression bound (closed) to its environment MultimethodsMultimethods Dispatch a method overload depending on the actual arguments at runtimeDispatch a method overload depending on the actual arguments at runtime Faster reflection and faster interface invocation based on dynamic invocationFaster reflection and faster interface invocation based on dynamic invocation Symbolic freedom for identifier namesSymbolic freedom for identifier names

17 Dynamic Invoke – Example static void greeter(String x) { System.out.println("Hello, " + x); } static MethodHandle greeterMethodHandle = MethodHandles.lookup().findStatic( DynamicInvocation.class, "greeter", MethodType. methodType(void.class, String.class)); static { Linkage.registerBootstrapMethod( "bootstrapDynamic"); }

18 Dynamic Invoke – Example (2) private static CallSite bootstrapDynamic( Class caller, String name, MethodType type) { if (type.parameterCount() == 1 && name == "hail") { MethodHandle target = MethodHandles. convertArguments(greeterMethodHandle, type); CallSite site = new CallSite(caller, name, type); site.setTarget(target); System.out.println("Set the CallSite target to " + greeterMethodHandle); return site; } public static void main(String... args) { InvokeDynamic.hail("dynamic invocation"); }

19 Java Modularity Project Jigsaw

20 Modularization – Introduction The JDK and the JRE, have always been delivered as massive, indivisible artifactsThe JDK and the JRE, have always been delivered as massive, indivisible artifacts The growth of the platform has thus inevitably led to the growth of the basic JRE downloadThe growth of the platform has thus inevitably led to the growth of the basic JRE download which now stands at well over 14MBwhich now stands at well over 14MB despite heroic engineering efforts such as the Pack200 class file compression formatdespite heroic engineering efforts such as the Pack200 class file compression format Java Kernel and Quickstarter features do improve download time and startup time, at least for Windows usersJava Kernel and Quickstarter features do improve download time and startup time, at least for Windows users

21 The Real Solution The most promising way to improve the key metrics ofThe most promising way to improve the key metrics of Download timeDownload time Startup timeStartup time And memory footprintAnd memory footprint Is to attack the root problem head-on:Is to attack the root problem head-on: Divide the JDK into a set of well specified and separate, yet interdependent, modulesDivide the JDK into a set of well specified and separate, yet interdependent, modules A side effect is that JAR format has to reworkedA side effect is that JAR format has to reworked

22 Alan Bateman: It’s Difficult Suppose you are using the Logging APISuppose you are using the Logging API Logging requires NIO (for file locking)Logging requires NIO (for file locking) And JMX (as loggers are managed)And JMX (as loggers are managed) JMX requires JavaBeans, JNDI, RMI and CORBA (JMX remote API mandates that the RMI connector support both JRMP and IIOP)JMX requires JavaBeans, JNDI, RMI and CORBA (JMX remote API mandates that the RMI connector support both JRMP and IIOP) JNDI requires java.applet.Applet (huh?) and JavaBeans has dependencies on AWT, SwingJNDI requires java.applet.Applet (huh?) and JavaBeans has dependencies on AWT, Swing Not satisfied with this, JavaBeans has persistent delegates that create dependencies on JDBC and moreNot satisfied with this, JavaBeans has persistent delegates that create dependencies on JDBC and more

23 How to Do It? Modularizing the JDK requires a module system capable of supporting such an effortModularizing the JDK requires a module system capable of supporting such an effort It requires, in particular, a module system whose core can be implemented directly within the Java virtual machineIt requires, in particular, a module system whose core can be implemented directly within the Java virtual machine Modularizing is best done with a module system that’s tightly integrated with the Java languageModularizing is best done with a module system that’s tightly integrated with the Java language Otherwise the compile-time module environment can differ dramatically from the run-time module environmentOtherwise the compile-time module environment can differ dramatically from the run-time module environment

24 Which Module System? JSR 277 proposes the JAM module systemJSR 277 proposes the JAM module system Some of its rich, non-declarative features would be impossible to implement its core functionality directly within the JVMSome of its rich, non-declarative features would be impossible to implement its core functionality directly within the JVM Therefore Sun halted the developmentTherefore Sun halted the development JSR 294 is chartered to extend the language and JVM to support modular programmingJSR 294 is chartered to extend the language and JVM to support modular programming Well received for its simplicity and its utility to existing module systems such as OSGiWell received for its simplicity and its utility to existing module systems such as OSGi

25 Which Module System? (2) OSGiOSGi May 2007: OSGi 4.1 standardized as JSR-291May 2007: OSGi 4.1 standardized as JSR-291 Reasonably mature, stable, and robustReasonably mature, stable, and robust Implemented within Apache Harmony JVMImplemented within Apache Harmony JVM Not at all integrated with the Java languageNot at all integrated with the Java language Jigsaw created to modularize JDK7Jigsaw created to modularize JDK7 Will not be an official part of the Java SE 7 Platform Specification and might not be supported by other SE 7 implementationsWill not be an official part of the Java SE 7 Platform Specification and might not be supported by other SE 7 implementations

26 Status and Examples Probably JSR 294 will be chosenProbably JSR 294 will be chosen There are issues, JSR 294 is inactive (paused)There are issues, JSR 294 is inactive (paused) Not implemented yet (b89), java.lang.moduleNot implemented yet (b89), java.lang.module Example (may, and probably will, change)Example (may, and probably will, change) module M1@1.0 provides M2@2.0, M3@3.0 { requires M4@4.0, M5@5.0; permits M6; // only M6 can depend on M1 } module M; package P; public class Foo {...}

27 JSR 308: (Extended) Annotations on Java Types

28 JSR 308 – Introduction Java SE 6 permits annotations only on declarationsJava SE 6 permits annotations only on declarations JSR 308 extends Java’s annotation system so that annotations may appear on nearly any use of a typeJSR 308 extends Java’s annotation system so that annotations may appear on nearly any use of a type JSR 308 is backward-compatible and continues to permit those annotationsJSR 308 is backward-compatible and continues to permit those annotations Two new types of annotations (target wise):Two new types of annotations (target wise): ElementType.TYPE_USEElementType.TYPE_USE ElementType.TYPE_PARAMETERElementType.TYPE_PARAMETER

29 JSR 308: Examples public static void main() { //for generic type arguments in a generic method JSR308Example2. method("..."); //for type parameters and type parameter bounds: Collection c = null; //for class inheritance: class UnmodifiableList implements @Readonly List { } } //for throws clauses: void monitorTemperature() throws @Critical Exception {} //for method receivers: public String toString() @Readonly { return null; } // helper only public static T method(String s) {return null;}

30 Small Language Enhancements (Project Coin)

31 Project Coin – Introduction Project Coin unites all language changes to the Java Lang Specification (JLS) to be added to JDK 7Project Coin unites all language changes to the Java Lang Specification (JLS) to be added to JDK 7 Open call for proposalsOpen call for proposals From February 27, 2009From February 27, 2009 Through March 30, 2009Through March 30, 2009 70 proposal forms70 proposal forms 9 were chosen9 were chosen No Milestone selected yet (so not all features are available)No Milestone selected yet (so not all features are available)

32 The Chosen Ones Strings in SwitchStrings in Switch By Joseph D. DarcyBy Joseph D. Darcy Automatic Resource ManagementAutomatic Resource Management By Joshua BlochBy Joshua Bloch Improved Type Inference for Generic Instance CreationImproved Type Inference for Generic Instance Creation By Jeremy MansonBy Jeremy Manson Simplified Varargs Method InvocationSimplified Varargs Method Invocation By Bob LeeBy Bob Lee

33 The Chosen Ones (2) Collection LiteralsCollection Literals By Joshua BlochBy Joshua Bloch Indexing access syntax for Lists and MapsIndexing access syntax for Lists and Maps By Shams MahmoodBy Shams Mahmood Language support for JSR 292Language support for JSR 292 By John RoseBy John Rose Binary LiteralsBinary Literals Underscores in numbersUnderscores in numbers By Derek FosterBy Derek Foster

34 1. Strings in Switch

35 Strings in Switch Syntactic sugarSyntactic sugar // Finally! - strings in switch String s = ""; switch (s) { case "Edno": out.println("1"); break; case "Dve": out.println("2"); break; default: out.println("Unknown BG number."); break; }

36 2. Automatic Resource Management (ARM)

37 ARM – The Problem A resource is as an object that must be closed manuallyA resource is as an object that must be closed manually InputStream, Reader, Writer, DB connectionInputStream, Reader, Writer, DB connection Manual resource termination has proven ugly and error proneManual resource termination has proven ugly and error prone Even good programmers get it wrongEven good programmers get it wrong Resource leaks or even outright failures, which may be silentResource leaks or even outright failures, which may be silent If an exception is thrown in the try block, and in the finally block, the second supplants the firstIf an exception is thrown in the try block, and in the finally block, the second supplants the first

38 ARM – The Problem (2) Where’s the problem with this code?Where’s the problem with this code? If an exception is thrown in the try block, and in the finally block, the second supplants the firstIf an exception is thrown in the try block, and in the finally block, the second supplants the first Was "Text" written successfully?Was "Text" written successfully? BufferedWriter br = new BufferedWriter(new FileWriter(path)); try { br.write("Text"); } finally { br.close(); }

39 How It’s Done (One Resource) BufferedWriter br = new BufferedWriter(new FileWriter(path)); try { // This exception is more important br.write("Text"); } finally { try { //... than this one br.close(); } catch(IOException ioe) {} } Try-finally – with one resource:Try-finally – with one resource:

40 How It’s Done (Two Resources) 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]; int n; while ((n = in.read(buf)) >= 0) out.write(buf, 0, n); } finally { try { out.close(); } catch(IOException ioe) {} } } finally { try { in.close(); } catch(IOException ioe) {} }

41 Code is now 4 linesCode is now 4 lines Removed the boring nested try, catch, finally, close() clausesRemoved the boring nested try, catch, finally, close() clauses The first exception is thrown if a problem occurs, the close() exception is hiddenThe first exception is thrown if a problem occurs, the close() exception is hidden ARM Syntax – Two Resources 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); }

42 Automatic Resource Management ARM statement is a form of the try statement that declares one or more resourcesARM statement is a form of the try statement that declares one or more resources The scope of these resource declarations is limited to the statementThe scope of these resource declarations is limited to the statement When the statement completes, whether normally or abruptly, all of its resources are closed automaticallyWhen the statement completes, whether normally or abruptly, all of its resources are closed automatically As of b89 ARM is not yet available, but definitely going to be inside JDK7As of b89 ARM is not yet available, but definitely going to be inside JDK7

43 An Interface Must be Chosen A class must implement a designated interface to make it eligible for automatic resource managementA class must implement a designated interface to make it eligible for automatic resource management An obvious choice would be CloseableAn obvious choice would be Closeable close() method throws IOExceptionclose() method throws IOException What about general purpose resources?What about general purpose resources? package java.io; import java.io.IOException; public interface Closeable { public void close() throws IOException; }

44 An Interface Must be Chosen (2) It is possible to retrofit Closeable with a parameterized superinterfaceIt is possible to retrofit Closeable with a parameterized superinterface Disposable would become:Disposable would become: package java.lang; public interface Disposable { void close() throws X; } package java.io; import java.io.IOException; public interface Closeable extends Disposable { void close() throws IOException; }

45 ARM – Notes No interface is chosen, nor implemented yetNo interface is chosen, nor implemented yet As of b89As of b89 MigrationMigration Any resource that must be closed manually should be retrofitted to implement the Disposable interfaceAny resource that must be closed manually should be retrofitted to implement the Disposable interface In the JDK, this includes:In the JDK, this includes: Closeable (all streams implement it)Closeable (all streams implement it) Connection, Statement, and ResultSetConnection, Statement, and ResultSet

46 Suppressed Exceptions ARM discards suppressed exceptionsARM discards suppressed exceptions Proposal implies they can be saved by adding them in suppressing exception via two new methods to Throwable :Proposal implies they can be saved by adding them in suppressing exception via two new methods to Throwable : void addSuppressedException(Throwable)void addSuppressedException(Throwable) Throwable[]getSuppressedExceptions()Throwable[]getSuppressedExceptions() As of b89 not implemented and it’s not clear whether they will beAs of b89 not implemented and it’s not clear whether they will be

47 3. Improved Type Inference for Generic Instance Creation

48 What is the Fuss All About? Simply this:Simply this: … becomes:… becomes: <> is called the ‘diamond‘<> is called the ‘diamond‘ Cannot be omitted because no difference can be made between raw HashMap and a parameterized oneCannot be omitted because no difference can be made between raw HashMap and a parameterized one [Ctrl+Shift+F] fails on diamond in NetBeans 6.9[Ctrl+Shift+F] fails on diamond in NetBeans 6.9 Implemented in b89Implemented in b89 Map > anagrams = new HashMap >(); Map > anagrams = new HashMap<>();

49 Diamond <>: Advanced Example This is supposed to work:This is supposed to work: …but does not yet (as of b89)…but does not yet (as of b89) public class AdvancedExample { public static void main() { method("", new ArrayList<>(), new ArrayList<>()); } public static T method( T a, List b, List > c) { return a; }

50 4. Simplified Varargs Method Invocation

51 Simplified Varargs Method… The compiler currently generates an "unsafe operation" warningThe compiler currently generates an "unsafe operation" warning When a programmer tries to invoke a varargs method with a non-reifiable varargs typeWhen a programmer tries to invoke a varargs method with a non-reifiable varargs type JDK 7 will move the warning from the call site to the method declarationJDK 7 will move the warning from the call site to the method declaration Major advantagesMajor advantages Reduces the total number of warnings reported to and suppressed by programmersReduces the total number of warnings reported to and suppressed by programmers

52 A Picture is Worth a 1000 Words /** NOT WORKING in b89, no change with jdk1.6.0_20 */ public static void main() { Callable t = null; //OLD: Warning: "uses unchecked or unsafe operations“ List > merged = asList(t); System.out.println(merged); } // NEW: Warning: "unchecked generic array creation" private static List asList(T... elements ) { return Arrays.asList(elements); }

53 Simplified Varargs – Example interface Sink { void add(T... a); } /** NOT WORKING in b89, no change with jdk1.6.0_20 */ interface BrokenSink extends Sink { // OLD: no warning // NEW: Warning: "Overriddes non-reifiable varargs type with array" void add(T[] a); } /** NOT WORKING in b89, no change with jdk1.6.0_20 */ class StringSink implements Sink { // OLD: no warning // NEW: Warning: "override generates a more specific varargs type erasure" public void add(String... a) {} }

54 5. Collection Literals

55 Collection Literals Again a syntax sugarAgain a syntax sugar Not yet available, so no demo Not yet available, so no demo  /** NOT WORKING in b89 */ public static void main(String... args) { List list = ["One", "Two"]; Set set = {"One", "Two", "Three"}; Map map = {"One" : 1, "Two" : 2}; // Note: Object s = { }; // empty set; Object m = {:}; // empty map; }

56 6. Indexing Access Syntax for Lists and Maps

57 Collection Indexers Syntax sugarSyntax sugar /** NOT WORKING in b89 */ public static void main(String... args) { List list = Arrays.asList(new String[]{"a", "b", "c"}); Map map = new HashMap (4); // THE OLD WAY String firstElement = list.get(0); map.put(1, "One"); // THE NEW WAY (NOT IMPLEMENTED YET) String firstElement = list[0]; map[1] = "One"; }

58 7. Language Support for JSR 292

59 JSR 292 Support in javac java.dyn.InvokeDynamic will accept any method call and turn it into an invokedynamic instructionjava.dyn.InvokeDynamic will accept any method call and turn it into an invokedynamic instruction The type java.dyn.MethodHandle will accept any argument and return typesThe type java.dyn.MethodHandle will accept any argument and return types Bytecode names acceptable to the JVM can be spelled from Java code, using #" "Bytecode names acceptable to the JVM can be spelled from Java code, using #" " java.dyn.InvokeDynamic serves as a bare reference type: anything implicitly converts to itjava.dyn.InvokeDynamic serves as a bare reference type: anything implicitly converts to it It can be cast to anything, but it is not a subtype of java.lang.ObjectIt can be cast to anything, but it is not a subtype of java.lang.Object

60 JSR 292 – Example // Works in b89 // type (Object, int) -> boolean boolean z = java.dyn.InvokeDynamic. myEquals(x, y); // Works in b89 MethodHandle hndl = MethodHandles.lookup().findVirtual( PrintStream.class, "println", MethodType.methodType( void.class, String.class)); hndl.invokeGeneric(System.out, "Merhaba"); // Works in b89 String #"g 1 $!$#%" = "Text"; System.out.println(#"g 1 $!$#%");

61 9. Underscores in Numbers

62 Underscores in Numbers /** WORKING in b89 */ public static void main(String... args) { // THE OLD WAY int oldBillion = 1000000000; // THE NEW WAY int newBillion = 1_000_000_000; out.println(oldBillion); out.println(newBillion); } Too much sugar can cause diabetesToo much sugar can cause diabetes May seem useless, but don’t judge too quicklyMay seem useless, but don’t judge too quickly

63 10. Binary Literals

64 Binary Literals /** WORKING in b89 */ public static void main(String... args) { // THE OLD WAY int oldBinary1 = 153; int oldBinary2 = 128 ^ 0 ^ 0 ^ 16 ^ 8 ^ 0 ^ 0 ^ 1; // THE NEW WAY int newBinary = 0b1001_1001; out.println(oldBinary1); out.println(oldBinary2); out.println(format("[0b1001_1001] is {0}", newBinary)); } The syntax is 0b11110000;The syntax is 0b11110000; See where underscores come in handy?See where underscores come in handy?

65 Closures in Java First-class Functions, Function Types and Lambda Expressions

66 What are Closures? Closures – definitionClosures – definition Closures are functions that are evaluated in an environment containing one or more bound variables [Wikipedia]Closures are functions that are evaluated in an environment containing one or more bound variables [Wikipedia] In English: a little snippet of code (function) that can be passed as argument of some method for subsequent executionIn English: a little snippet of code (function) that can be passed as argument of some method for subsequent execution Closures come from functional programming languages like LispClosures come from functional programming languages like Lisp Limited support for closures since JDK 1.1, in the form of anonymous classesLimited support for closures since JDK 1.1, in the form of anonymous classes

67 First-class and Anonymous Functions First-class are programming paradigm that supportsFirst-class functions are programming paradigm that supports Data structure holding a function with its parameters and return typeData structure holding a function with its parameters and return type Passing functions as arguments to other functions and invoking themPassing functions as arguments to other functions and invoking them Returning functions as resultReturning functions as result Anonymous functionsAnonymous functions Functions without name (lambda functions)Functions without name (lambda functions) Take some parameters and return a valueTake some parameters and return a value

68 Lambda Expressions Lambda calculusLambda calculus A formal mathematical system for function definition, function application and recursionA formal mathematical system for function definition, function application and recursion Typed and untyped lambda calculusTyped and untyped lambda calculus Lambda expressionsLambda expressions Anonymous functions that take parameters and return values, e.g.Anonymous functions that take parameters and return values, e.g. x → x*xx → x*x (x, y) → x*x + y*y(x, y) → x*x + y*y A.k.a. lambda functionsA.k.a. lambda functions

69 Project Lambda Project LambdaProject Lambda GoalsGoals To formulate a proposal to add first-class functions, function types, and lambda expressions (informally, "closures") to JavaTo formulate a proposal to add first-class functions, function types, and lambda expressions (informally, "closures") to Java To implement a prototype suitable for inclusion in JDK 7To implement a prototype suitable for inclusion in JDK 7 Official Web SiteOfficial Web Site http://openjdk.java.net/projects/lambda/http://openjdk.java.net/projects/lambda/http://openjdk.java.net/projects/lambda/ StatusStatus Straw-man proposal, still no JSRStraw-man proposal, still no JSR

70 Lambda Expressions in Java Lambda expressions in Java use the # syntaxLambda expressions in Java use the # syntax Function with no arguments, returns 42:Function with no arguments, returns 42: Function with int argument:Function with int argument: Function with two int arguments:Function with two int arguments: #()(42) #(int x)(x + x) #(int x, int y)(x * y)

71 Lambda Expressions with Code Block Lambda expressions can have bodyLambda expressions can have body A Java code block:A Java code block: #(int x, int y) { int z = (int)Math.sqrt(x*x + y*y); int z = (int)Math.sqrt(x*x + y*y); if (z < 10) if (z < 10) return x; return x; else if (z > 10) else if (z > 10) return y; return y; else else return 0; return 0;}

72 Function Types Function types are data types that hold a reference to lambda function or method:Function types are data types that hold a reference to lambda function or method: Functions stored in variable of function type can be invoked like any other function:Functions stored in variable of function type can be invoked like any other function: #int() fortyTwo = #()(42); #int(int) triple = #(int x)(3*x); #int(int,int) mult = #(int x, int y)(x * y); System.out.println(fortyTwo()); int result = triple(5); int multResult = mult(3, 5);

73 Functions as Arguments Lambda functions can be passed as arguments to a methodLambda functions can be passed as arguments to a method public long sum(int[] arr, #int(int) fn) { long sum = 0; long sum = 0; for (int element : arr) for (int element : arr) sum += fn(element); sum += fn(element); return sum; return sum;} int[] arr = new int[] {1, 2, 3, 4}; long squaresSum = sum(arr, #(int x)(x*x)); System.out.println(squaresSum); // 30

74 Functions as Return Value Lambda functions can be returned as result of method execution:Lambda functions can be returned as result of method execution: public #int(int) adder(int c) { return #(int x)(x + c); return #(int x)(x + c);} #int(int) a42 = adder(42); System.out.println(a42(2)); // 44

75 Function Conversions Lambda functions can be converted to abstract class / interface defining a single method:Lambda functions can be converted to abstract class / interface defining a single method: Thread th = new Thread(new Runnable() { public void run() { public void run() { doSomeStuff(); doSomeStuff(); doMoreStuff(); doMoreStuff(); }}); Thread th = new Thread(#(){ doSomeStuff(); doMoreStuff(); } ) doSomeStuff(); doMoreStuff(); } )

76 Variable Capture We can share local state between the body of a lambda expression and its enclosing scopeWe can share local state between the body of a lambda expression and its enclosing scope A new keyword shared is introducedA new keyword shared is introduced shared int comparisonsCount = 0; Collections.sort(data, #(String a, String b) { comparisonsCount++; comparisonsCount++; return a.compareTo(b); return a.compareTo(b);});System.out.println(comparisonsCount);

77 Instance Capture The this reference of the enclosing class could be accessed in a lambda expression:The this reference of the enclosing class could be accessed in a lambda expression: class CountingSorter { private int comparisonsCount = 0; private int comparisonsCount = 0; Collections.sort(data, Collections.sort(data, #(String a, String b) { #(String a, String b) { comparisonsCount++; comparisonsCount++; return a.compareTo(b); return a.compareTo(b); });

78 Extension Methods Extension methods allow the author of an existing interface to add methods to that interface while preserving compatibilityExtension methods allow the author of an existing interface to add methods to that interface while preserving compatibility For example, we need to add a method for filtering members from any collection by given Boolean condition:For example, we need to add a method for filtering members from any collection by given Boolean condition: Set set = new Set (new int[] {1,2,3,4,5}); new Set (new int[] {1,2,3,4,5}); Set filteredSet = set.filter(#boolean(int x)(x < 3)); set.filter(#boolean(int x)(x < 3));

79 Extension Methods (2) Defining extension methods:Defining extension methods: class Collections { … static Set filter( static Set filter( Set s, #boolean(T) pred) { … } Set s, #boolean(T) pred) { … } static Set map( static Set map( Set s, #S(T) func) { … } Set s, #S(T) func) { … }} interface Set extends Collection { … Set filter(#boolean(T)) import static Set filter(#boolean(T)) import static Collections.filter; Collections.filter; map(#S(T)) import static Collections.map; map(#S(T)) import static Collections.map;}

80 Extension Methods (3) Using extension methods:Using extension methods: int ints = new int[] { 1, 2, 3, 4, 5 }; int[] transformedInts = s.filter(#(int x)(x % 2 == 0)) s.filter(#(int x)(x % 2 == 0)).map(#(int x)(x + 3));.map(#(int x)(x + 3)); // transformedInts = { 5, 7 } int[] transformedInts = Collections.map( Collections.map( Collections.filter(s, #(int x)(x % 2 == 0)), Collections.filter(s, #(int x)(x % 2 == 0)), #(int x)(x + 3) #(int x)(x + 3));

81 Parallel Arrays API ParallelArray is ideal candidate for extension methodsParallelArray is ideal candidate for extension methods Can utilize efficiently multi-core / multiprocessor systemsCan utilize efficiently multi-core / multiprocessor systems The class ParallelArray allows parallel aggregate operations over a collectionThe class ParallelArray allows parallel aggregate operations over a collection Apply transformation to each elementApply transformation to each element Map each element to a new elementMap each element to a new element Select subset of the elements by predicateSelect subset of the elements by predicate Reduce elements to a single value (e.g. sum)Reduce elements to a single value (e.g. sum)

82 JSR 203: More New I/O APIs for the Java Platform (NIO.2)

83 NIO2 – Introduction New I/O or non-blocking I/O, usually called NIONew I/O or non-blocking I/O, usually called NIO Collection of Java APIs that offer features for intensive I/O operationsCollection of Java APIs that offer features for intensive I/O operations It was introduced with the J2SE 1.4It was introduced with the J2SE 1.4 NIO was developed under the Java Community Process as JSR 51NIO was developed under the Java Community Process as JSR 51 As of 2006, an extension to NIO, called NIO2, is being developed under JSR 203As of 2006, an extension to NIO, called NIO2, is being developed under JSR 203 JSR 203 is scheduled to be included in JDK 7JSR 203 is scheduled to be included in JDK 7

84 Cool New Things: resolve() resolve() – resolves a relative pathresolve() – resolves a relative path public static void resolve() { FileSystem fileSystem = FileSystems.getDefault(); Path currentDir = fileSystem.getPath("."); Path srcDir = fileSystem.getPath("src"); Path file1 = fileSystem.getPath("./Test.java"); Path file2 = fileSystem.getPath(“../Copy.java"); System.out.println( "file2: " + currentDir.resolve(srcDir).resolve(file2)); }

85 Cool New Things: relativize() relativize() – makes path relativerelativize() – makes path relative public static void relativize() { FileSystem fileSystem = FileSystems.getDefault(); Path source = fileSystem.getPath("."); Path temp = fileSystem.getPath("/temp"); Path relativeSource = source.toAbsolutePath(). relativize(temp.toAbsolutePath()); System.out.println(relativeSource); }

86 How to Copy a File Up to Java 6 (w/o channels) it looks like this:Up to Java 6 (w/o channels) it looks like this: Familiar?Familiar? Most developers write this incorrectlyMost developers write this incorrectly try { from = new FileInputStream(fromFile); to = new FileOutputStream(toFile); byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = from.read(buffer)) != -1) to.write(buffer, 0, bytesRead); // write } finally { // Close the streams "to" and "from" }

87 How to Copy a File (2) java.io.File is used to represent a filejava.io.File is used to represent a file @since 1.0@since 1.0 Is there a way to copy metadata?Is there a way to copy metadata? JDK7: java.io.File -> java.nio.file.PathJDK7: java.io.File -> java.nio.file.Path java.io.File won’t be deprecated, but shouldjava.io.File won’t be deprecated, but should Path is a better name (might be a dir, right?)Path is a better name (might be a dir, right?) // java.io.File -> java.nio.filePath Path p = new File("/foo/bar.txt").toPath(); FileSystem local = FileSystems.getDefault(); Path from = local.getPath(FileName); Path to = local.getPath(toFileName); from.copyTo(to);

88 Upgrade Class- Loader Architecture

89 The Problem Bug ID: 4670071Bug ID: 4670071 Submit Date: 17-APR-2002Submit Date: 17-APR-2002 Release Fixed: 7 (b47)Release Fixed: 7 (b47) Means: Fixed in JDK7 (build 47)Means: Fixed in JDK7 (build 47) b47 got released Q1 2009b47 got released Q1 2009 The bug is about a classloader deadlockThe bug is about a classloader deadlock deadlocks as caused by non-interceptible loadClassInternal() callsdeadlocks as caused by non-interceptible loadClassInternal() calls How many of you know about the existence of bug 4670071?How many of you know about the existence of bug 4670071?

90 Compressed 64-bit Object Pointers

91 What is an oop? An "oop", or "ordinary object pointer" in the JVM is a managed object pointerAn "oop", or "ordinary object pointer" in the JVM is a managed object pointer It is normally the same size as a native machine pointerIt is normally the same size as a native machine pointer 64 bits on an 64-bit OS64 bits on an 64-bit OS 32 bits on an 32-bit OS32 bits on an 32-bit OS 32-bit JVM can address less than 4GB32-bit JVM can address less than 4GB 64-bit JVM can address all the available RAM64-bit JVM can address all the available RAM But this costs a lot of memory lost in oopsBut this costs a lot of memory lost in oops

92 Compressed oops Compressed oops allow to address up to 32 GB RAM with 32-bit pointers The address space is mapped using a 64-bit base and 32-bit oop This allows applications to address up to four billion objects (not bytes) Java heap can grow up to 32 GB

93 Garbage-First GC (G1)

94 G1 (garbage-first) garbage collectorG1 (garbage-first) garbage collector Improved performance and less freeze timeImproved performance and less freeze time Server-style garbage collectorServer-style garbage collector Targeted for multi-processors with large memoriesTargeted for multi-processors with large memories Meets a soft real-time goal with high probabilityMeets a soft real-time goal with high probability Added in Milestone1 (02.01.2009)Added in Milestone1 (02.01.2009) Released in Java 6 update 6u14Released in Java 6 update 6u14

95 Method to close a URLClassLoader

96 URLClassLoader.close () URLClassLoader has new method called close()URLClassLoader has new method called close() since b48 of JDK 7since b48 of JDK 7 Closes any JAR files that were open by the loaderCloses any JAR files that were open by the loader Allows the application to delete/replace these files and if necessary to create new loadersAllows the application to delete/replace these files and if necessary to create new loaders Invalidates the loader, so that no new classes can be loaded from itInvalidates the loader, so that no new classes can be loaded from it /** @since 1.7 */ urlClassLoader.close();

97 Unicode 5.1

98 Unicode 5.1 in Java 7 Java 6 is Unicode 4.0 compliantJava 6 is Unicode 4.0 compliant Java 7 will be Unicode 5.1 compliantJava 7 will be Unicode 5.1 compliant Most up-to-date version of Unicode is 5.2 (October 2009)Most up-to-date version of Unicode is 5.2 (October 2009) What's new in Unicode 5 ?What's new in Unicode 5 ? Unicode 5.0 will include 1,369 new characters and 9 new blocks (~alphabets)Unicode 5.0 will include 1,369 new characters and 9 new blocks (~alphabets) Unicode 5.1 will have 1,624 additional char’s making a grand total of 100,713 breaking the 100K mark for the first timeUnicode 5.1 will have 1,624 additional char’s making a grand total of 100,713 breaking the 100K mark for the first time

99 SCTP (Stream Control Transmission Protocol)

100 SCTP Stream Control Transmission Protocol (SCTP) is a Transport Layer protocolStream Control Transmission Protocol (SCTP) is a Transport Layer protocol serving in a similar role as TCP and UDPserving in a similar role as TCP and UDP Features of SCTP include:Features of SCTP include: Multihoming support: both endpoints of a connection can consist of more than one IPMultihoming support: both endpoints of a connection can consist of more than one IP Chunks delivered within independent streamsChunks delivered within independent streams Protect against flooding attacksProtect against flooding attacks No Windows supports SCTPNo Windows supports SCTP

101 JDK7: The SCTP Project The goal of this Project is:The goal of this Project is: To develop an API for the Stream Control Transport Protocol (SCTP)To develop an API for the Stream Control Transport Protocol (SCTP) And a corresponding OpenJDK prototypeAnd a corresponding OpenJDK prototype The API is implementation agnosticThe API is implementation agnostic Included in build 56Included in build 56 Could be hacked to work with JDK6Could be hacked to work with JDK6 Currently only Solaris is supportedCurrently only Solaris is supported

102 SDP (Sockets Direct Protocol)

103 SDP The Sockets Direct Protocol (SDP) is a networking protocol originally defined by the InfiniBand Trade AssociationThe Sockets Direct Protocol (SDP) is a networking protocol originally defined by the InfiniBand Trade Association Transport agnostic protocol for Remote Direct Memory Access (RDMA)Transport agnostic protocol for Remote Direct Memory Access (RDMA) RDMA is a direct memory access from one computer’s memory into another’s without involving either one's operating systemRDMA is a direct memory access from one computer’s memory into another’s without involving either one's operating system JDK7’s SDP implementation works, unfortunately, only on SolarisJDK7’s SDP implementation works, unfortunately, only on Solaris

104 Questions? Java 7 New Features

105 Resources – Java Chronology JDK 7 – FeaturesJDK 7 – Features http://openjdk.java.net/projects/jdk7/featu res/http://openjdk.java.net/projects/jdk7/featu res/http://openjdk.java.net/projects/jdk7/featu res/http://openjdk.java.net/projects/jdk7/featu res/ JDK 7 – MilestonesJDK 7 – Milestones http://openjdk.java.net/projects/jdk7/miles tones/http://openjdk.java.net/projects/jdk7/miles tones/http://openjdk.java.net/projects/jdk7/miles tones/http://openjdk.java.net/projects/jdk7/miles tones/

106 Resources – Dynamic Langs New JDK 7 Feature: Support for Dynamically Typed Languages in the Java Virtual MachineNew JDK 7 Feature: Support for Dynamically Typed Languages in the Java Virtual Machine http://java.sun.com/developer/technicalArti cles/DynTypeLang/http://java.sun.com/developer/technicalArti cles/DynTypeLang/http://java.sun.com/developer/technicalArti cles/DynTypeLang/http://java.sun.com/developer/technicalArti cles/DynTypeLang/ John Rose's weblog at Sun MicrosystemsJohn Rose's weblog at Sun Microsystems http://blogs.sun.com/jrose/http://blogs.sun.com/jrose/http://blogs.sun.com/jrose/ JSR 292: Supporting Dynamically Typed Languages on the Java PlatformJSR 292: Supporting Dynamically Typed Languages on the Java Platform http://jcp.org/en/jsr/detail?id=292http://jcp.org/en/jsr/detail?id=292http://jcp.org/en/jsr/detail?id=292

107 Resources – Project Jigsaw Project Jigsaw: Language changes for ModulesProject Jigsaw: Language changes for Modules http://openjdk.java.net/projects/jigsaw/doc /language.htmlhttp://openjdk.java.net/projects/jigsaw/doc /language.htmlhttp://openjdk.java.net/projects/jigsaw/doc /language.htmlhttp://openjdk.java.net/projects/jigsaw/doc /language.html Project Jigsaw – Mark Reinhold’s BlogProject Jigsaw – Mark Reinhold’s Blog http://blogs.sun.com/mr/entry/jigsawhttp://blogs.sun.com/mr/entry/jigsawhttp://blogs.sun.com/mr/entry/jigsaw Is the JDK Losing its Edge(s)?Is the JDK Losing its Edge(s)? http://blogs.sun.com/alanb/entry/ is_the_jdk_losing_itshttp://blogs.sun.com/alanb/entry/ is_the_jdk_losing_itshttp://blogs.sun.com/alanb/entry/ is_the_jdk_losing_itshttp://blogs.sun.com/alanb/entry/ is_the_jdk_losing_its

108 Resources – JSR 308 Type Annotations Specification (JSR 308)Type Annotations Specification (JSR 308) http://types.cs.washington.edu/jsr308/speci fication/java-annotation-design.htmlhttp://types.cs.washington.edu/jsr308/speci fication/java-annotation-design.htmlhttp://types.cs.washington.edu/jsr308/speci fication/java-annotation-design.htmlhttp://types.cs.washington.edu/jsr308/speci fication/java-annotation-design.html Type Annotations FAQ (JSR 308)Type Annotations FAQ (JSR 308) http://types.cs.washington.edu/jsr308/js r308-faq.htmlhttp://types.cs.washington.edu/jsr308/js r308-faq.htmlhttp://types.cs.washington.edu/jsr308/js r308-faq.htmlhttp://types.cs.washington.edu/jsr308/js r308-faq.html The Checker Framework: Custom Pluggable Types for JavaThe Checker Framework: Custom Pluggable Types for Java http://types.cs.washington.edu/checker- framework/current/checkers-manual.htmlhttp://types.cs.washington.edu/checker- framework/current/checkers-manual.htmlhttp://types.cs.washington.edu/checker- framework/current/checkers-manual.htmlhttp://types.cs.washington.edu/checker- framework/current/checkers-manual.html

109 Resources – Project Coin Project CoinProject Coin http://wikis.sun.com/display/ProjectCoin/20 09ProposalsTOChttp://wikis.sun.com/display/ProjectCoin/20 09ProposalsTOChttp://wikis.sun.com/display/ProjectCoin/20 09ProposalsTOChttp://wikis.sun.com/display/ProjectCoin/20 09ProposalsTOC http://mail.openjdk.java.net/pipermail/coin -dev/2009-February/000001.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-February/000001.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-February/000001.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-February/000001.html Strings in switchStrings in switch http://mail.openjdk.java.net/pipermail/coin- dev/2009-February/000001.htmlhttp://mail.openjdk.java.net/pipermail/coin- dev/2009-February/000001.htmlhttp://mail.openjdk.java.net/pipermail/coin- dev/2009-February/000001.htmlhttp://mail.openjdk.java.net/pipermail/coin- dev/2009-February/000001.html Automatic Resource ManagementAutomatic Resource Management http://mail.openjdk.java.net/pipermail/coin- dev/2009-February/000011.htmlhttp://mail.openjdk.java.net/pipermail/coin- dev/2009-February/000011.htmlhttp://mail.openjdk.java.net/pipermail/coin- dev/2009-February/000011.htmlhttp://mail.openjdk.java.net/pipermail/coin- dev/2009-February/000011.html

110 Resources – Project Coin (2) Improved Type Inference for Generic Instance CreationImproved Type Inference for Generic Instance Creation http://mail.openjdk.java.net/pipermail/coin -dev/2009-February/000009.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-February/000009.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-February/000009.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-February/000009.html Simplified Varargs Method InvocationSimplified Varargs Method Invocation http://mail.openjdk.java.net/pipermail/coin -dev/2009-March/000316.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/000316.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/000316.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/000316.html Collection LiteralsCollection Literals http://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001193.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001193.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001193.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001193.html

111 Resources – Project Coin (3) Indexing access syntax for Lists and MapsIndexing access syntax for Lists and Maps http://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001108.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001108.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001108.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001108.html Language support for JSR 292Language support for JSR 292 http://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001077.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001077.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001077.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001077.html Binary LiteralsBinary Literals http://mail.openjdk.java.net/pipermail/coin -dev/2009-April/001627.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-April/001627.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-April/001627.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-April/001627.html Underscores in numbersUnderscores in numbers http://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001208.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001208.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001208.htmlhttp://mail.openjdk.java.net/pipermail/coin -dev/2009-March/001208.html

112 Resources – Closures Project LambdaProject Lambda http://openjdk.java.net/projects/lambda/http://openjdk.java.net/projects/lambda/http://openjdk.java.net/projects/lambda/ Project Lambda: Straw-Man ProposalProject Lambda: Straw-Man Proposal http://cr.openjdk.java.net/~mr/lambda/straw-man/http://cr.openjdk.java.net/~mr/lambda/straw-man/http://cr.openjdk.java.net/~mr/lambda/straw-man/ Closures for Java – Mark Reinhold’s BlogClosures for Java – Mark Reinhold’s Blog http://blogs.sun.com/mr/entry/closureshttp://blogs.sun.com/mr/entry/closureshttp://blogs.sun.com/mr/entry/closures

113 Resources – NIO2 Java New I/OJava New I/O http://en.wikipedia.org/wiki/New_I/Ohttp://en.wikipedia.org/wiki/New_I/Ohttp://en.wikipedia.org/wiki/New_I/O JSR 203: The Open Road – java.nio.fileJSR 203: The Open Road – java.nio.file http://today.java.net/pub/a/today/2008/07/0 3/jsr-203-new-file-apis.htmlhttp://today.java.net/pub/a/today/2008/07/0 3/jsr-203-new-file-apis.htmlhttp://today.java.net/pub/a/today/2008/07/0 3/jsr-203-new-file-apis.htmlhttp://today.java.net/pub/a/today/2008/07/0 3/jsr-203-new-file-apis.html

114 Resources – Compressed oops Compressed oops in the Hotspot JVMCompressed oops in the Hotspot JVM http://wikis.sun.com/display/HotSpotInterna ls/CompressedOopshttp://wikis.sun.com/display/HotSpotInterna ls/CompressedOopshttp://wikis.sun.com/display/HotSpotInterna ls/CompressedOopshttp://wikis.sun.com/display/HotSpotInterna ls/CompressedOops Wikipedia – 64-bitWikipedia – 64-bit http://en.wikipedia.org/wiki/64-bithttp://en.wikipedia.org/wiki/64-bithttp://en.wikipedia.org/wiki/64-bit ILP32, LP64, and LLP64ILP32, LP64, and LLP64 http://wiki.wireshark.org/Development/Win64http://wiki.wireshark.org/Development/Win64http://wiki.wireshark.org/Development/Win64 C Programming LanguageC Programming Language http://en.wikipedia.org/wiki/C_(programming _language)http://en.wikipedia.org/wiki/C_(programming _language)http://en.wikipedia.org/wiki/C_(programming _language)http://en.wikipedia.org/wiki/C_(programming _language)

115 Resources – Garbage Collection Garbage-First Garbage CollectionGarbage-First Garbage Collection http://research.sun.com/jtech/pubs/04-g1- paper-ismm.pdfhttp://research.sun.com/jtech/pubs/04-g1- paper-ismm.pdfhttp://research.sun.com/jtech/pubs/04-g1- paper-ismm.pdfhttp://research.sun.com/jtech/pubs/04-g1- paper-ismm.pdf JavaOne: G1 Garbage CollectorJavaOne: G1 Garbage Collector http://tech.puredanger.com/2008/05/09/javaone- g1-garbage-collectorhttp://tech.puredanger.com/2008/05/09/javaone- g1-garbage-collectorhttp://tech.puredanger.com/2008/05/09/javaone- g1-garbage-collectorhttp://tech.puredanger.com/2008/05/09/javaone- g1-garbage-collector Garbage Collection – WikipediaGarbage Collection – Wikipedia http://en.wikipedia.org/wiki/Garbage_collectio n_(computer_science)http://en.wikipedia.org/wiki/Garbage_collectio n_(computer_science)http://en.wikipedia.org/wiki/Garbage_collectio n_(computer_science)http://en.wikipedia.org/wiki/Garbage_collectio n_(computer_science) Wikipedia – Hard and Soft Real-time SystemsWikipedia – Hard and Soft Real-time Systems http://en.wikipedia.org/wiki/Real- time_computing#Hard_and_soft_real-time_systemshttp://en.wikipedia.org/wiki/Real- time_computing#Hard_and_soft_real-time_systemshttp://en.wikipedia.org/wiki/Real- time_computing#Hard_and_soft_real-time_systemshttp://en.wikipedia.org/wiki/Real- time_computing#Hard_and_soft_real-time_systems

116 Resources – Upgrade ClassLoader Architecture Draft Proposal for ClassLoader Deadlock FixDraft Proposal for ClassLoader Deadlock Fix http://www.mail-archive.com/core-libs- dev@openjdk.java.net/msg00863.htmlhttp://www.mail-archive.com/core-libs- dev@openjdk.java.net/msg00863.htmlhttp://www.mail-archive.com/core-libs- dev@openjdk.java.net/msg00863.htmlhttp://www.mail-archive.com/core-libs- dev@openjdk.java.net/msg00863.html java.lang.ClassLoader.loadClassInternal(St ring) is Too Restrictivejava.lang.ClassLoader.loadClassInternal(St ring) is Too Restrictive http://bugs.sun.com/bugdatabase/view_bug.do ?bug_id=4670071http://bugs.sun.com/bugdatabase/view_bug.do ?bug_id=4670071http://bugs.sun.com/bugdatabase/view_bug.do ?bug_id=4670071http://bugs.sun.com/bugdatabase/view_bug.do ?bug_id=4670071

117 Resources – URL ClassLoader Closing a URLClassLoaderClosing a URLClassLoader http://blogs.sun.com/michaelmcm/entry/closi ng_a_urlclassloaderhttp://blogs.sun.com/michaelmcm/entry/closi ng_a_urlclassloaderhttp://blogs.sun.com/michaelmcm/entry/closi ng_a_urlclassloaderhttp://blogs.sun.com/michaelmcm/entry/closi ng_a_urlclassloader Class URLClassLoader – close()Class URLClassLoader – close() http://download.java.net/jdk7/docs/api/java /net/URLClassLoader.html#close()http://download.java.net/jdk7/docs/api/java /net/URLClassLoader.html#close()http://download.java.net/jdk7/docs/api/java /net/URLClassLoader.html#close()http://download.java.net/jdk7/docs/api/java /net/URLClassLoader.html#close()

118 Resources – Unicode 5.1 JDK 7 – Features – Unicode 5.1JDK 7 – Features – Unicode 5.1 http://openjdk.java.net/projects/jdk7/featu res/#f497http://openjdk.java.net/projects/jdk7/featu res/#f497http://openjdk.java.net/projects/jdk7/featu res/#f497http://openjdk.java.net/projects/jdk7/featu res/#f497 What's new in Unicode 5.0?What's new in Unicode 5.0? http://babelstone.blogspot.com/2005/11/what s-new-in-unicode-50.htmlhttp://babelstone.blogspot.com/2005/11/what s-new-in-unicode-50.htmlhttp://babelstone.blogspot.com/2005/11/what s-new-in-unicode-50.htmlhttp://babelstone.blogspot.com/2005/11/what s-new-in-unicode-50.html What's new in Unicode 5.1?What's new in Unicode 5.1? http://babelstone.blogspot.com/2007/06/what s-new-in-unicode-51.htmlhttp://babelstone.blogspot.com/2007/06/what s-new-in-unicode-51.htmlhttp://babelstone.blogspot.com/2007/06/what s-new-in-unicode-51.htmlhttp://babelstone.blogspot.com/2007/06/what s-new-in-unicode-51.html

119 Resources – SCTP SCTP ProjectSCTP Project http://openjdk.java.net/projects/sctp/http://openjdk.java.net/projects/sctp/http://openjdk.java.net/projects/sctp/

120 Resources – SDP Understanding the Sockets Direct ProtocolUnderstanding the Sockets Direct Protocol http://java.sun.com/docs/books/tutorial/sdp /sockets/index.htmlhttp://java.sun.com/docs/books/tutorial/sdp /sockets/index.htmlhttp://java.sun.com/docs/books/tutorial/sdp /sockets/index.htmlhttp://java.sun.com/docs/books/tutorial/sdp /sockets/index.html Sockets Direct Protocol – WikipediaSockets Direct Protocol – Wikipedia http://en.wikipedia.org/wiki/Sockets_Direct _Protocolhttp://en.wikipedia.org/wiki/Sockets_Direct _Protocolhttp://en.wikipedia.org/wiki/Sockets_Direct _Protocolhttp://en.wikipedia.org/wiki/Sockets_Direct _Protocol Remote Direct Memory AccessRemote Direct Memory Access http://en.wikipedia.org/wiki/Remote_Direct_ Memory_Accesshttp://en.wikipedia.org/wiki/Remote_Direct_ Memory_Accesshttp://en.wikipedia.org/wiki/Remote_Direct_ Memory_Accesshttp://en.wikipedia.org/wiki/Remote_Direct_ Memory_Access Zero-copyZero-copy http://en.wikipedia.org/wiki/Zero-copyhttp://en.wikipedia.org/wiki/Zero-copyhttp://en.wikipedia.org/wiki/Zero-copy

121 Resources – Authors Authors of this presentation:Authors of this presentation: Svetlin NakovSvetlin Nakov http://www.nakov.com/blog/http://www.nakov.com/blog/http://www.nakov.com/blog/ Mihail StoynovMihail Stoynov http://mihail.stoynov.com/blog/http://mihail.stoynov.com/blog/http://mihail.stoynov.com/blog/


Download ppt "Java 7 – New Features Svetlin Nakov, Mihail Stoynov Bulgarian Association of Software Developers www.devbg.org BGJUG, TU-Sofia, hall 2140 20.05.2010 BGJUG,"

Similar presentations


Ads by Google