The document summarizes new features and changes coming in Java 7. Key points include:
- Major focus on ease of development through simplifying programming models and reducing code through annotations.
- "Rightsizing" the Java EE platform by pruning unused components like EJB entity beans and making parts of the platform optional.
- Significant changes like modularization through JSR 294, new invokedynamic bytecode for dynamic languages, and major JVM improvements like the G1 garbage collector.
- Many smaller language and API improvements like null dereference expressions, type inference, multi-catch, annotations on types, and a new NIO library.
2. Remember Java EE 5?
Ease of Development Focus
Major Revamp of Programming Model
EJB™ 3.0 support for POJOs means less
learn, less to code and less to maintain
New Java™ Persistence API makes object/
relational mapping cleaner and easier
New and updated Web Services (JAX-WS 2.0
and JAXB 2.0) simplifies SOA implementation
JavaServer™ Faces 1.2 facilitates building
Web 2.0 Applications with AJAX
Annotations often eliminates the need for
deployment descriptors
Supported by NetBeans™ 5.5 Enterprise Pack
Get the SDK:
http://java.sun.com/javaee/downloads
2
3. History of Enterprise Java
Ease of
Development
Java EE 5
Ease of
Web Services Development,
Annotations,
J2EE 1.4 EJB 3.0
Persistence
Web
Robustness Services, API, New and
Updated Web
Management,
J2EE 1.3
Enterprise Services
Deployment,
Java CMP, Async.
Platform Connector Connector
Architecture
J2EE 1.2
Servlet, JSP,
EJB, JMS,
RMI/IIOP
JPE Project
3
5. Rightsizing
• “Ease of development is good, but…
… the platform still feels too big.”
> Feedback: we want less bloat
• Reduce size, without losing focus
• Make the platform fit a particular class of applications
well
• Increase flexibility of deployment
5
6. New in Java EE 6
• Profiles
• Pruning
• Extensibility
• More ease of development
6
7. Pruning
• Make some components optional
• Send a strong message to application developers
• Same rules as Java SE apply:
> “pruned now, optional in next release”
• Likely candidates for pruning:
> EJB Entity Beans—Replaced by JPA
> JAX-RPC—Replaced by JAX-WS
> JAXR—Used Infrequently
> JSR-88— Used Infrequently, not used by applications
7
9. Things We Like With
the Java Language
Automatic Memory Management (GC)
•
Strong Typing
•
Object-Oriented
•
No Pointers
•
WORA
•
Run-Time Optimization
•
Rich Class Library
•
Static Typing (well, sometimes…)
•
Simple, Clean and Expressive
•
10. Things We Like With
the JVM
Automatic Memory Management (GC)
•
Strong Typing
•
Object-Oriented
•
No Pointers
•
WORA
•
Run-Time Optimization
•
Rich Class Library
•
Static Typing (well, sometimes…)
•
Simple, Clean and Expressive
•
13. “Big” Changes from Sun
• Modularization
> JSR-294
> Project Jigsaw
> JSR-277
• JVM Support for Dynamic Languages
> JSR-292
> invokedynamic
• New I/O 2
> JSR-203
> True asynchronous I/O
> new file i/o
13
14. More “Big” Changes from Sun
• Language Changes
> Safe rethrow
> Null dereference expressions
> Better type inference
> Multi-Catch
• Swing Application Framework
> JSR-296
• Forward Port of Java 6u10 Features
> Java Kernal
> Quickstarter
> New Applet plug-in
14
15. “Small” Changes from Sun
• SCTP (Stream Control Transmission Protocol)
• SDP (Sockets Direct Protocol)
• Upgrade Class Loader Architecture
• Method for Closing a URLClassLoader
• Unicode 5.0 Support
• XRender Pipeline for Java2D
• Swing Updates
15
16. “Fast” Changes from Sun
• G1 (Garbage First) Garbage Collector
> Shorter pause times
> Replaces Concurrent mark and sweep (hopefully)
• Compressed pointer 64 bit VM
• MVM-Lite
> Multiple Virtual Machine
> Isolation
> “kill -9” on a Java application
16
17. Other Changes
• Annotations on Java Types
> JSR-308
> Driven by Prof. Michael Ernst and Mahmood Ali
> ex. @NonNull
• Concurrency and Collections Updates
> JSR-166
> Fork/Join
> Phasers
> LinkedTransferQueue
> ConcurrentReferenceHashMap
> Fences
17
18. Not in Java™7 (partial list)
• Closures
> No consensus around a single proposal
• Reified Generics
• 1st Class Properties
• Operator Overloading
• BigDecimal Syntax
• JSR-295 Beans Binding
18
19. Superpackages
superpackage example.bar.lib {
// member packages
member package example.bar.lib;
// member superpackages
member superpackage example.bar.lib.net, example.bar.lib.xml;
// list of exported types
export example.bar.lib.Table;
export superpackage example.bar.lib.net;
}
19
23. invokevirtual
• General form:
> invokevirtual TargetObjectType.methodDescriptor
> MethodDescriptor:
methodName(ArgTypes) ReturnType
• Very close to Java programming language semantics
> Only overloading (and generics) left to javac
> Single inheritance, single dispatch, statically typed
• Verifier ensures types are correct
invokevirtual TargetType.method(ArgType) ReturnType
24. Dynamically Typed Languages
• Anything can be passed to a function/method
> No type information at compile time
> No type information at byte code generation time (even
when doing Just-in-Time generation)
> Type information only at run time
25. And Here the Troubles Begin
Consider a trivial snippet of code in a dynamically typed
language:
newSize(c)
// Collection has grown; figure out the next increment
// in size
{
return c.size() * c.growthFactor();
}
26. And Here the Troubles Begin
Consider a trivial snippet of code in a dynamically typed
language:
newSize(c)
// Collection has grown; figure out the next increment
// in size
{
c.growthFactor()
return c.size() * c.growthFactor();
}
27. And Here the Troubles Begin
Consider a trivial snippet of code in a dynamically typed
language:
newSize(c)
// Collection has grown; figure out the next increment
// in size
{
c.growthFactor()
return c.size() * c.growthFactor();
}
invokevirtual UknownType.growthFactor() UnknownReturnType
28. And Here the Troubles Begin
Solution: synthetic interfaces
newSize(c)
// Collection has grown; figure out the next increment
// in size
{
return
((Interface91)((Interface256) c).size()) *
(Interface91) ((Interface42) c).growthFactor();
}
29. And Here the Troubles Begin
Solution: synthetic interfaces
newSize(c)
// Collection has grown; figure out the next increment
// in size
{
return
((Interface91)((Interface256) c).size()) *
(Interface91) ((Interface42) c).growthFactor();
}
invokeinterface Interface42.growthFactor() Object
30. Solution: invokedynamic
A loosely typed invokevirtual
• Target need not be statically known to implement
method descriptor given in instruction
> No need for a host of synthetic interfaces
• Actual arguments need not be statically known to match
method descriptor
> Instead, cast at invocation time to ensure integrity
• Will be added to the Java Virtual Machine as of Java7
(Dolphin)
invokedynamic Anyclass.growthFactor() Object
31. invokedynamic, Cont.
• The JVM won’t traverse the type hierarchy
> delegated to a plug-in written by the language designer
> every language has it’s own rules for inheritance and
delegation
> enables multiple inheritance
> enables prototype based languages
32. Only a Partial Solution
• No direct support for multiple inheritance or multiple
dispatch
> General support is hard—each language has its own rules
• Calling Java platform libraries from scripting languages
brings additional problems
> How do you resolve overloading?
• However, invokedynamic is a useful primitive in most of
these complex scenarios as well
33. invokedynamic
/**
* Syntactic marker interface for class-
* based dynamic method selection.
*/
package java.dyn;
public interface Dynamic {
// empty
}
// Running example Java code which exercises Draft invokedynamic
class MyCaller {
Object myMethod(Object x, Object y, int z) {
// x . invokedynamic[quot;alphaquot;,(Object,int)Object] (y, z)
return ((Dynamic)x).alpha(y, z);
}
}
36. Null-Dereference Expression
T x = null;
if( a != null ) {
B b = a.b();
if( b != null ) {
C c = b.c();
if( c != null ) {
x = c.x();
}
}
}
32
37. Null-Dereference Expression
T x = a?.b()?.c()?.x();
T x = null;
if( a != null ) {
B b = a.b();
if( b != null ) {
C c = b.c();
if( c != null ) {
x = c.x();
}
}
}
32
49. Closures, further example
public class DeepThought {
// { => int } means a function with no arguments and return type int
static { => int } answer = { => 42 };
public static void main(String[] args) {
int i = answer.invoke();
System.out.println(i);
}
}
41
50. SUN LABS PROJECT:
Maxine Open Source Research VM
• GNU General Public License version 2
> License-compatible with OpenJDK™
• Currently builds on JDK 1.6 release
• Not a fully compliant Java™ Virtual Machine (yet)
• Alpha release source code:
https://maxine.dev.java.net/
42
51. SUN LABS PROJECT:
Maxine Platforms
• Supported:
> Solaris™ Operating System / SPARC® Technology
> Solaris / x64
> Mac OS X / x64
> Xen / x64
• Under development:
Solaris OS / x32
>
• Contemplated: Linux / x64
>
Xen / x32
>
Linux / x32
>
ARM
>
Mac OS X / x32
>
PowerPC
>
Windows
>
43
52. SUN LABS PROJECT:
Conventional vs. Meta-Circular
Applications
Applications
JDK
JDK
Java Language Java
Meta-Circular VM
Conventional Language
VM Native
Native
Libraries
Libraries
C/C++ etc. C/C++ etc.
44
53. SUN LABS PROJECT:
Meta-Circular VM Design
• The VM is written in the same language it executes
• The VM uses JDK packages
and implements their downcalls into the VM
• Built around an optimizing compiler (not an interpreter)
• The optimizing compiler in the VM translates itself
45
55. SUN LABS PROJECT:
Multi-Language Potential
• Fortress
JRuby
•
• Jython
JavaScript
•
• Java FX
• All of the above already have Java implementations
• Let's reuse scalable managed runtime investment
• No need for Java bytecode (or extensions thereof)
47