Académique Documents
Professionnel Documents
Culture Documents
2 Platform, Standard
Edition (J2SE™) java.sun.com/javaone/sf
5.0 Technology
Calvin Austin
J2SE 5.0 Specification Lead
Sun Microsystems, Inc.
1 | 2004 JavaOneSM Conference | Session TS-1952
Goal of This Presentation
Beta1 Feedback
• Introduction to “Tiger”
• Main Theme Features
• Miscellaneous Features
• Demo
• Q&A
2004 2005
• Quality
─ Compatibility, compatibility, compatibility!
• Performance and scalability
• Ease of development
• Monitoring and manageability
• Desktop client
• Quality
─ Compatibility, compatibility, compatibility!
• Performance and scalability
• Ease of development
• Monitoring and manageability
• Desktop client
• Quality
─ Compatibility, compatibility, compatibility!
• Performance and scalability
• Ease of development
• Monitoring and manageability
• Desktop Client
• Performance Ergonomics
─ Less reliance on command line flags
─ More support for adaptive self-tuning
• Performance tools
─ Jstat and jvmstat
90
80
70
60
1.4.2
50 5.0build47
40
30
20
10
0
Startup minimal awt applet minimal Swing app
• Quality
─ Compatibility, compatibility, compatibility!
• Performance and scalability
• Ease of development
• Monitoring and manageability
• Desktop Client
• MetaData
• Generics
• Autoboxing
• Enhanced for loops
• Enumerated Types, Static Import
• Covariant Return Types
• Formatted Output/Input
• Varargs
• Concurrency Utilities
18 | 2004 JavaOneSM Conference | Session TS-1952
Compiler Options
• @Retention(RUNTIME) @interface
debug {
boolean devbuild() default
false;
int counter();
}
• Developer specifies metadata using @tag
• public @debug mymethod;
Before
public interface HelloIF extends Remote {
public String sayHello(String s) throws
RemoteException;
}
public class HelloImpl implements HelloIF {
public String sayHello(String s) {
return “Hello “+s;
}
}
After
public class HelloImpl {
public @remote String HelloImpl(String s) {
return "Hello “+s;
}
}
23 | 2004 JavaOneSM Conference | Session TS-1952
Generics
• The solution
• Allow the developer to provide a type
parameter at declaration time inside
<..>, e.g., <Integer>
• The compiler now can check for type safety
• Collections have been updated to use
Generics
Before
After
$ javac MoneyBox.java
$ java MoneyBox
Exception in thread "main"
java.lang.ClassCastException:
java.lang.String
at MoneyBox.main(MoneyBox.java:18)
$ javac MoneyBox.java
MoneyBox.java:15:
addCoin(java.lang.Integer) in
MoneyBox<java.lang.Integer> cannot be
applied to (java.lang.String)
m.addCoin("iou");
^
1 error
Before
After
list.add(0,42);
int total = list.get(0);
After
ArrayList<Integer> list = new ArrayList<Integer>();
for (Integer i : list) { ... }
StopLight t=StopLight.red;
StopLight t=1;//error
StopLight t=StopLight.blue; //error
• 1.4 Version
public class MyDialog {
MyDialog getDialog() {
return this;
}
}
5.0 Version
class MyDialog {MyDialog getDialog() {
return this;
}
}
class MyFileDialog extends MyDialog{
public boolean isDirectory() {
}
// was MyDialog getDialog() {
MyFileDialog getDialog() {
return this;
}
}
MyFileDialog f = new
MyFileDialog();System.out.println("fd="+f.getDial
og().isDirectory());
• C version
scanf(“%s”, name);
scanf(“%d”, age);
• Java Version
Scanner s=new Scanner(System.in);
String name= s.next();
int age=s.nextInt();
s.close();
//
argtest(“test”, “data”);
• Semaphores
final private Semaphore s= new Semaphore(1,
true)s.acquireUninterruptibly(); //for non-
blocking
//use s.acquire()
balance=balance+10; //protected value
s.release(); //return semaphore token
• Atomic Variables
AtomicInteger balance=new
AtomicInteger(10);System.out.println(balance.getA
ndAdd(10));
• Thread Executors
class Worker implements Runnable {
public void run() {
System.out.println("New Worker");
}
}
public class ConThread {
public static void main(String args[]) {
Executor e =
Executors.newFixedThreadPool(3);
e.execute(new Worker());
}
}
41 | 2004 JavaOneSM Conference | Session TS-1952
“Tiger” Themes
• Quality
─ Compatibility, compatibility, compatibility!
• Performance and scalability
• Ease of development
• Monitoring and manageability
• Desktop Client
• SNMP Out-of-the-Box
java -Dcom.sun.management.snmp.port=161
-Dcom.sun.management.snmp.trap=162
-Dcom.sun.management.snmp.acl=false -jar
Java2Demo.jar
• JMX Out-of-the-Box
java -Dcom.sun.management.jmxremote.port=5001
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false -jar
Java2Demo.jar
• Easy to Configure
java.lang.MemoryPool.TenuredGen.UsageThreshold=16000
System.out.println(Thread.getAllStackTraces());
StackTraceElement
e[]=Thread.currentThread().getStackTrace();
for (int i=0; i<e.length; i++) {
System.out.println(e[i]);
}
-XX:OnError="pmap %p"
-XX:OnError="gcore %p; dbx - %p"
-XX:OnError=”gdb %p”
-XX:OnError="cat hs_err_pid%p.log | mailx -s help
calvin.austin@sun.com"
• Quality
─ Compatibility, compatibility, compatibility!
• Performance and scalability
• Ease of development
• Monitoring and manageability
• Desktop Client
• CachedRowSet
─ Contains in-memory collection of rows
─ Allows disconnected use of data
─ Updates can be resynchronized into database
• WebRowSet
─ Can also import and export XML representation
• pack200 -v charsets.pack.gz
charsets.jar
• unpack200 -v charsets.pack.gz
charsets.jar
Calvin Austin
• http://java.sun.com/j2se/1.5.0
• http://jcp.org/en/jsr/detail?id=176
5.0 Technology
Calvin Austin
J2SE 5.0 Specification Lead
Sun Microsystems, Inc.
66 | 2004 JavaOneSM Conference | Session TS-1952