Java 7 New Features .

Uploaded on:
Category: Food / Beverages
Java 7
Slide 1

Java 7 – New Features Mihail Stoynov, Svetlin Nakov Bulgarian Association of Software Developers Spring Conference of the Bulgarian Oracle User Group (BGOUG), Plovdiv, 24 April 2010

Slide 2

Table of Contents Introduction and Chronology Compressed 64-bit Object Pointers Garbage-First GC (G1) Dynamic Languages in JVM Java Modularity – Project Jigsaw Language Enhancements (Project Coin) Strings in Switch Automatic Resource Management (ARM ) Improved Type Inference for Generic Instance Creation

Slide 3

Table of Contents (2) Improved Type Inference for Generic Instance Creation Simplified Varargs Method Invocation Collection Literals Indexing Access Syntax for Lists and Maps Language Support for JSR 292 Underscores in Numbers Binary Literals Closures for Java First-class Functions

Slide 4

Table of Contents (3) Function Types Lambda Expressions Project Lambda Extension Methods Upgrade Class-Loader Architecture Method to close a URLClassLoader Unicode 5.1 JSR 203: NIO.2 SCTP (Stream Control Transmission Protocol ) SDP (Sockets Direct Protocol )

Slide 5

Introduction and Chronology

Slide 6

OpenJDK JDK7 is the second JDK done by means of the OpenJDK exertion OpenJDK is free, open-source and GPL authorized A great deal of the changes of JDK7 are separate tasks on OpenJDK Some say that undertakings go under the top of OpenJDK to evade the bulky and moderate JCP handle

Slide 7

Milestones Began in August 2006 First expected to be 7 turning points Mark Reinhold stretched out them to 10 Current status: M7 completed, introduction made with build89 M10 anticipated that would complete 09.09.2010 "The last planned breakthrough cycle will be trailed by a test and adjustment time of uncertain length , after which the last discharge will be pronounced"

Slide 8

There\'s No JSR Yet A JSR should be shaped Java SE 6 was under the "Umbrella" JSR 270 JDK7 is in Eclipse\'s low need list in light of the fact that an absence of compartment JSR JDK7 can\'t be settled without a JSR There are a few functionalities that additionally do not have a JSR While doing this introduction we utilized the term JSR TBD in lieu of the missing JSR

Slide 9

Source Control System Official SCM is SVN, still Note: it takes a "while" Unofficial Mercurial backwoods archives accessible since November 2007 Note: this likewise takes a "while" >svn co >hg fclone

Slide 10

Currently Supported IDEs Eclipse Both Eclipse 3.6M6 and E4 don\'t bolster JDK7\'s linguistic structure … or the moderators couldn\'t make sense of it  Strangely enough the choice is there: Source similarity: 1.7 NetBeans 6.9 Beta backings JDK7 All the demos are finished with it Eclipse was utilized to make the introduction 

Slide 11

Compressed 64-bit Object Pointers

Slide 12

What is an oop? A "oop", or "ordinary question pointer" in HotSpot speech is an overseen pointer to a protest it is typically an indistinguishable size from a local machine pointer which implies 64 bits on a LP64 framework (LP64 = Long and Pointer are 64bit long) On an ILP32 framework, there is a most extreme pile size of to some degree under 4GB which is insufficient for some applications

Slide 13

The Problem – half Larger Heap On a LP64 framework the pile for any given run may must be around 1.5 circumstances as huge concerning the comparing IPL32 framework accepting the run fits both modes This is because of the extended size of oversaw pointers Memory is entirely shabby, however nowadays transmission capacity and reserve is hard to come by so remarkably expanding the measure of the load just to get over as far as possible is excruciating

Slide 14

Compressed uh oh Compressed oh no = oversaw pointers 32-bit values, must be scaled by an element of 8 and added to a 64-bit base deliver to discover the protest they allude to in many yet not all spots in the JVM This permits applications to deliver up to four billion items  (not bytes) or a pile size of up to around 32Gb in the meantime, information structure conservativeness is aggressive with ILP32 mode <base> + (<narrow-oop> << 3) + <offset>

Slide 15

Encoding/Decoding The term  disentangle  expresses the operation by which a 32-bit packed oop is changed over into a 64-bit local address into the stack The opposite operation is  encoding All uh oh are the local machine word estimate in An ILP32-mode JVM In LP64 mode, when the UseCompressedOops banner is killed The Hotspot VM\'s information structures to oversee Java classes are not compacted

Slide 16

Null Processing A 32-bit zero esteem deciphers into a 64-bit local invalid esteem A clumsy unique way is required in the unraveling rationale It is productive to statically note which packed oh no are ensured never to be invalid and utilize a more straightforward rendition of the full translate or encode operation Implicit invalid checks are significant to JVM speed Trick: if packed invalid is ever decoded, there\'s a flag – the primary page or so of the virtual locations utilized by pile is not mapped

Slide 17

Zero Based Compressed uh oh Narrow oop base = java pile base less one secured page (for understood invalid checks) If the thin oop base can be made to be zero: Also if Java pile measure < 4Gb and it can be moved into low virtual address space (underneath 4Gb) then packed uh oh can be utilized without encoding/interpreting <oop-base> + (<narrow-oop> << 3) + <field-offset> (<narrow-oop> << 3) + <field-offset> <wide_oop> = <narrow-oop>

Slide 18

Garbage-First GC (G1)

Slide 19

Java GC – Introduction Java GC isolates pile into youthful and old eras of articles Takes preferred standpoint of the perception that by far most of articles bite the dust youthful magnificent passings Very modest number of articles live for quite a while (successfully the life of the application) Few references from the old era to the youthful era Focus gathering consideration on the youthful gen

Slide 20

Concurrent Mark Sweep GC Garbage gatherer up to and including Java 6 is called Concurrent Mark Sweep (CMS) CMS has minor and real cycles (for various gen spaces – youthful, tenured, perm) Young gen GC is simultaneous Old gen GC stops the-world delays to stamp and complete Fallback to full stop-the-world for old gen compaction

Slide 21

G1 Garbage Collector G1 partitions the all memory (aside from perm gen) into 1 MB "areas" Regions are either old or youthful In G1, the old era GC there is one stop-the-world interruption to stamp G1 utilizes "recalled sets" to oversee references into a district Every locale has a little information structure (<5% of aggregate store) The recollected sets contain every outer reference into that district

Slide 22

G1 Additional Facts Garbage-first is a server-style junk jockey Targeted for multi-processors with vast recollections meets a delicate continuous objective with high likelihood while accomplishing high throughput Added in Milestone1 (02.01.2009) Released in Java 6 refresh 6u14 Support contract discussion

Slide 23

Dynamic Languages in JVM

Slide 24

Dynamic Languages in JVM Da Vinci Machine Project A.k.a. Multi Language Virtual Machine – to permit non-Java dialects to run productively in the JVM JSR 292: Supporting Dynamically Typed Languages on the Java Platform The standard behind Da Vinci Machine Natural continuation of JSR 223: Scripting for the Java Platform actualized in JDK 6

Slide 25

Dynamic Languages in JVM (2) New JVM direction invokedynamic Allows greatly quick element technique summon through strategy handles Will empower JRuby, Jython, Groovy and other element and scripting dialects to call dynamic strategies locally at bytecode level Method handles Lightweight references to a technique – java.dyn.MethodHandle Anonymous classes in the JVM

Slide 26

Dynamic Languages in JVM (3) Autonomous strategies Methods that can be powerfully joined to a current class at runtime Interface infusion Acquiring base interfaces and strategy usage at runtime Continuations and stack thoughtfulness Suspend/resume string\'s execution stack Tail calls and tail recursion

Slide 27

Dynamic Languages in JVM (4) Runtime bolster for terminations Closure is a lambda-expression bound (shut) to its condition Multimethods Dispatch a strategy over-burden contingent upon the genuine contentions at runtime Faster reflection and speedier interface conjuring in view of element summon Symbolic flexibility for identifier names

Slide 28

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

Slide 29

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

Slide 30

Java Modularity Project Jigsaw

Slide 31

Introduction The JDK and the JRE, have dependably been conveyed as huge, indissoluble ancient rarities The development of the stage has along these lines definitely prompted to the development of the basic JRE download which now remains at well more than 14MB notwithstanding brave designing endeavors, for example, the Pack200 class document pressure arrange Java Kernel and Quickstarter features do enhance download time and startup time, in any event for Windows

View more...