Sei sulla pagina 1di 50

Tiger

J2SE 5.0

J2SE Road Map


 Version JDK 1.1.4 JDK 1.1.5 JDK 1.1.6 JDK 1.1.7 JDK 1.1.8 J2SE 1.2 J2SE 1.2.1 J2SE 1.2.2 J2SE 1.3 J2SE 1.3.1 J2SE 1.4.0 J2SE 1.4.1 J2SE 1.4.2  Code Name Sparkler Pumpkin Abigail Brutus Chelsea Playground (none) Cricket Kestrel Ladybird Merlin Hopper Mantis  Release Date Sept 12, 1997 Dec 3, 1997 April 24, 1998 Sept 28, 1998 April 8, 1999 Dec 4, 1998 March 30, 1999 July 8, 1999 May 8, 2000 May 17, 2001 Feb 13, 2002 Sept 16, 2002 June 26, 2003

J2SE 5.0 (1.5.0)

Tiger

Sept 29, 2004

J2SE Themes


J2SE 1.4.0
(Merlin)

- Quality - Ease of Development - Becoming more open


(Java goes multilingual)

J2SE 5.0
(Tiger)

J2SE 6.0
(Mustang)

Theme for J2SE 5.0


    

Ease of development Quality Monitoring and Manageability Performance and Scalability Desktop Client

New Features in J2SE 5.0


    

Language Features Virtual Machine Features Performance Enhancements Base Libraries Integration Libraries

New Features in J2SE 5.0


    

Language Features Virtual Machine Features Performance Enhancements Base Libraries Integration Libraries

Language Features
     

Generics Enhanced for Loop Variable Arguments Boxing / Unboxing Type-safe enumerations Static import

Generics


A way to make class type-safe that are written on any arbitrary object type. Allows to narrow an instance of a Collection to hold a specific object type and eliminating the need to typecast it while retrieving the object.

J2SE 1.4.0 ArrayList intList = new ArrayList(); intList.add(new Integer(0)); Integer intObj = (Integer) intList.get(0); J2SE 5.0 ArrayList<Integer> intList = new ArrayList<Integer>(); intList.add(new Integer(0)); // Only Integer Objects allowed Integer intObj = intList.get(0); // No need to Type Cast

Enhanced for Loop




Iterating over collections is a pain. Often, iterator is unused except to get elements. Iterators are error-prone. Iterator variable occurs three times per loop. Gives you two opportunities to get it wrong. Common cut-and-paste error. Wouldnt it be nice if the compiler took care of the iterator for you?

J2SE 1.4.0 for(Iterator iter = myArray.iterator(); iter.hasNext(); ) { MyClass myObj = (MyClass)iter.next(); myObj.someOperation(); } J2SE 5.0 for(MyClass myObj : myArray) { myObj.someOperation(); }

For Arrays
Eliminates array index rather than iterator Similar advantages // Returns the sum of the elements of a

int sum(int[] a) { int result = 0; for (int i : a) result += i; return result; }

Variable Arguments


 

To write a method that takes an arbitrary number of parameters, you must use an array. Creating and initializing arrays is a pain. Why not complier take care of it?

Example of a method that takes an arbitrary number of int arguments and returns their sum:

public int sum(int... intList){ int i, sum; sum=0; for(i=0; i<intList.length; i++) sum += intList[i]; } return(sum); }
Possible ways to call this method

int arr[] = { 3,5,7 }; int result = sum (arr); int result = sum (20, 30, 10 ,5 ); int result = sum();

Boxing / Unboxing


 

Collections hold only objects, so to put primitive data types it needs to be wrapped into a class, like int to Integer. It is a pain to wrap and unwrap. Wouldnt it be nice if the compiler took care of it for you?

J2SE 1.4.0 ArrayList arrayList = new ArrayList(); Integer intObject = new Integer(10); arrayList.add(intObject); // cannot add 10 directly

J2SE 5.0 ArrayList arrayList = new ArrayList(); arrayList.add(10); // int 10 is automatically wrapped into Integer

Type-safe enumerations
    

Compiler support for Typesafe Enum pattern. Looks like traditional enum (C, C++, Pascal). Far more powerful. Can be used in switch/case statements. Can be used in for loops.

An enumeration is an ordered list of items wrapped into a single entity.

enum Season {winter, spring, summer, fall}


Usage Example

for (Season s : Season.VALUES){ // }


An enumeration (abbreviated enum in Java) is a special type of class. All enumerations implicitly subclass a new class in Java, java.lang.Enum. This class cannot be subclassed manually.

Static import


Ability to access static members from a class without need to qualify them with a class name.

interface ShapeNumbers { public static int CIRCLE = 0; public static int SQUARE = 1; public static int TRIANGLE = 2; }
Implementing this interface creates an unnecessary dependence on the ShapeNumbers interface. It becomes awkward to maintain as the class evolves, especially if other classes need access to these constants also and implement this interface

To make this cleaner, the static members are placed into a class and then imported via a modified syntax of the import directive.

package MyConstants; class ShapeNumbers { public static int CIRCLE = 0; public static int SQUARE = 1; public static int TRIANGLE = 2; }
To import the static members in your class, specify the following in the import section of your Java source file.

import static MyConstants.ShapeNumbers.*; // imports all static data


You can also import constants individually by using the following syntax:

import static MyConstants.ShapeNumbers.CIRCLE; import static MyConstants.ShapeNumbers.SQUARE;

New Features in J2SE 5.0


    

Language Features Virtual Machine Features Performance Enhancements Base Libraries Integration Libraries

Virtual Machine Features


    

Class Data Sharing Server-Class Machine Detection Garbage Collector Ergonomics Thread Priority Changes High-Precision Timing Support

Class Data Sharing


  

Reduces startup time of java applications. Better results for smaller applications. Automatically enabled when conditions allow it to be used. Not supported in Microsoft Windows 95/98/ME.

How CDS Works : When JRE is installed on 32-bit platforms using the Sun provided installer, it loads a set of classes from the system jar file into a private internal representation, and dumps that representation to a file, called a "shared archive".
Unix : jre/lib/[arch]/client/classes.jsa Windows : jre/bin/client/classes.jsa

During subsequent JVM invocations, the shared archive is memory-mapped in, saving the cost of loading those classes and allowing much of the JVM's metadata for these classes to be shared among multiple JVM processes.
CDS produces better results for smaller applications because it eliminates a fixed cost of loading certain core classes.

The footprint cost of new JVM instances has been reduced in two ways. First, a portion of the shared archive, currently 5-6 MB, is mapped read-only and therefore shared among multiple JVM processes. Previously this data was replicated in each JVM instance. Second, since the shared archive contains class data in the form in which the Java VM uses it, the memory which would otherwise be required to access the original class information in rt.jar is not needed.
These savings allow more applications to be run concurrently on the same machine.

Server-Class Machine Detection




At startup Launcher automatically detects if application is running on server-class Machine. Uses Server VM / Client VM accordingly.

Server-class Machine : One with at least 2 CPUs and at least 2GB of physical memory.
Server VM start more slowly than client VM, but over time runs more quickly.

Garbage Collector Ergonomics




On server-class machines running the server VM, the garbage collector (GC) has changed from the previous serial collector to a parallel collector. Can switch the GC collector mode using the command-line option.

XX:+UseSerialGC XX:+UseParallelGC

Serial collector Parallel collector

Thread Priority Changes




Java threads and Native threads to compete on equal footing. Java threads at NORM_PRIORITY can now compete as expected with native threads. Java priorities in the range [10...5] are all mapped to the highest possible TS (timeshare) or IA (interactive) priority. Priorities in the range [1..4] are mapped to correspondingly lower native TS or IA priorities

High-Precision Timing Support




System.nanoTime() method added. Provides access to nanosecond granularity time source for relative time measurements. The actual precision of the time value returned is platform dependant.

New Features in J2SE 5.0


    

Language Features Virtual Machine Features Performance Enhancements Base Libraries Integration Libraries

Performance Enhancements
   

Garbage collection Ergonomics StringBuilder Class Java 2D Technology Image I/O

Garbage collection Ergonomics


 

Automatic detection of Sever-Class Machine

Using Client / Server VM accordingly. Default parallel garbage collection on Server VM.

Parallel Garbage Collection

StringBuilder Class
  

Introduced a new class java.lang.StringBuilder. It is like unsunchronized StringBuffer. Faster than StringBuffer.

Java 2D Technology


Improved acceleration for Buffered Image Objects Support for H/W accelerated rendering using OpenGL. Improved text-rendering performance.

Image I/O


Improved Performance and memory usage while reading and writing JPEG Images. In mage I/O API (javax.imageio) added support for reading and writing BMP and WBMP images.

New Features in J2SE 5.0


    

Language Features Virtual Machine Features Performance Enhancements Base Libraries Integration Libraries

Base Libraries
   

Lang and Util Packages Networking JAXP Bit Manipulation Operations

Lang and Util Packages


 

ProcesBuilder

More convenient way to invoke sub processes than Runtime.exec printf style format strings. Support for layout justification and alignment, common formats for numeric, string and date/time data.

Formatter

Scanner

Converts text into primitives or Strings. regular expression based searches on streams, file data, strings.

Lang and Util Packages contd




Instrumentation

New package java.land.instrument, allows java programming agents to instrument programs running on the Java virtual machine by modifying methods' bytecodes at runtime getState() for querying the execution state of a thread. getStackTrace to obtain stack trace of a thread. A new form of the sleep() method is provided which allows for sleep times smaller than one millisecond.

Threads

Networking


 

Complete support for IPv6 on Windows XP (sp1) and 2003. ping like feature InetAddress class provides API to test the reachability of a host. Improved Cookie support. Proxy Sever Configuration ProxySelector API provides dynamic proxy configuration.

JAXP 1.3
 

A built-in validation processor for XML Schema. XSLTC, the fast, compiling transformer, which is now the default engine for XSLT processing. Java-Centric XPath APIs in javax.xml.xpath, which provide a more java-friendly way to use an XPath expression. Grammar pre-parsing and caching, which has a major impact on performance for high-volume XML processing.

Bit Manipulation Operations




The wrapper classes (Integer, Long, Short, Byte, and Char) now support common bit manipulation operations like

highestOneBit, lowestOneBit, numberOfLeadingZeros, numberOfTrailingZeros, bitCount, rotateLeft, rotateRight, reverse, signum, and reverseBytes.

New Features in J2SE 5.0


    

Language Features Virtual Machine Features Performance Enhancements Base Libraries Integration Libraries

Integration Libraries
  

Remote Method Invocation (RMI) Java Database Connectivity (JDBC) Java Naming and Directory Interface (JNDI)

Remote Method Invocation (RMI)




Dynamic Generation of Stub Classes

Generation of stub at runtime eliminated the need of stub compiler rmic. Standard Java RMI socket factory classes, javax.rmi.ssl.SslRMIClientSocketFactory and javax.rmi.ssl.SslRMIServerSocketFactory added. Communicate over the Secure Sockets Layer (SSL) or Transport Layer Security (TLS) protocols using the Java Secure Socket Extension (JSSE).

Standard SSL/TLS Socket Factory Classes

Java Database Connectivity (JDBC)




RowSet interface has been implemented in five common ways a RowSet object can be used.

JdbcRowSet - used to encapsulate a result set or a driver. CachedRowSet - disconnects from its data source and operates
independently except when it is getting data from the data source or writing modified data back to the data source.

FilteredRowSet - extends CachedRowSet and is used to get a


subset of data.

JoinRowSet - extends CachedRowSet and is used to get an


SQL JOIN of data from multiple RowSet objects.

WebRowSet - extends CachedRowSet and is used for XML


data.

Java Naming and Directory Interface (JNDI)




Enhancements to javax.naming.NameClassPair to access the fullname from the directory/naming service. Support for standard LDAP controls: Manage Referral Control, Paged Results Control and Sort Control. Support for manipulation of LDAP names.

Tiger

Q&A

Thank You

Potrebbero piacerti anche