License
Language
Library
Tools
Virtual Machine
Soon. Maybe next week?
Ships on Linux (next Ubuntu, Gutsy Gibbon)
Quality of JDK improves as programmers stop merely reporting bugs and start fixing them.
Forks
Not everyone's gotten the memo
Array Syntax for collections
Closures
Property Literals
Type inference; a.k.a. short instance creation
Factory methods instead of constructors
Arbitrary precision arithmetic
Sub-package access
List content = new LinkedList(10); content.add(0, "Fred"); content.add(1, "Barney"); String name = content.get(0);
becomes:
List content = new LinkedList(10); content[0] = "Fred"; content[1] = "Barney"; String name = content[0];
List content = new LinkedList(10); content.add(0, "Fred"); content.add(1, "Barney"); content.add(1, "Wilma"); content.add(1, "Betty");
becomes:
LinkedList content = {"Fred", "Barney", "Wilma", "Betty"};
Bad: locks in concrete types
Compiler magic only; no VM changes
Does not change the meaning of any existing code
A property is identified by JavaBeans setFoo
/getFoo
naming convention:
Point p = new Point(); p.setX(56); p.setY(87); int z = p.getX();
Property may or may not map to a field
Constraints can be checked.
With ->
:
Point p = new Point(); p->X = 56; p->Y = 87; int z = p->X;
Other symbols including .
and #
have also been suggested.
May have to identify properties inside the class with a new keyword:
public class Point { public int property x; public int property y; }
What I'd really like is Eiffel
Let the compiler guess the types
Saves a miniscule amount of typing; is it easier to read?
// print a frequency table of words public static void main(String[] args) { HashMap<String, Integer> map = new HashMap<String, Integer>(); for(word : args) { int freq := map.get(word); // autoboxing map.put(word, (freq==null) ? 1 : freq+1); } System.out.println(map); }becomes
// print a frequency table of words public static void main(String[] args) { map := new HashMap<String, Integer>(); for(word : args) { freq := map.get(word); map.put(word, (freq==null) ? 1 : freq+1); } System.out.println(map); }or
public static void main(String[] args) { final map = new HashMap<String, Integer>(); for(final word : args) { final freq=map.get(word); map.put(word, (freq==null) ? 1 : freq+1); } System.out.println(map); }
However it's final in both cases.
Locked to the concrete class
Some people really hate constructors
The problem: constructors only create instance of a specific class, never a subclass.
Default factory methods?
Guessing it could look something like this:
Foo f1 = Foo.new(1, 2); Foo f2 = Foo.new(com.subclass.of.Foo.class, 1, 2);
BigInteger low = BigInteger.ONE; BigInteger high = BigInteger.ONE; for (int i = 0; i < 500; i++) { System.out.print(low); BigInteger temp = high; high = high.add(low); low = temp; };becomes
BigInteger low = 1; BigInteger high = 1; for (int i = 0; i < 500; i++) { System.out.print(low); BigInteger temp = high; high = high + low; low = temp; };
But these classes are still slow
Not full operator overloading
JSR 294
Like friend functions in C++
Subpackages can be more closely related to their parents than arbitrary packages
org.jdom.input, org.jdom.output, and org.jdom
JUnit tests
In the file source/org/jdom/super-package.java we might find this:
// Declare the superpackage
superpackage org.jdom {
// Members of the superpackage
member package org.jdom, org.jdom.input, org.jdom.output;
// Publish these classes
export org.jdom.Element, org.jdom.Attribute, org.jdom.input.Builder;
// Other public classes are non-published and can only be accessed
// from within the same superpackage.
}
How to export everything, or everything but a few classes?
An inner function that is closed over external local variables.
But Java doesn't have first class functions or inner functions!
Fake with inner classes?
Any single method interface: ActionListener, Runnable, etc.
Supplying an algorithm (e.g. a comparison function for a sort) as an argument
Making sure a file is closed or a lock unlocked when done with it.
Adding methods to the language that look like keywords: foreach
, withlock
, etc. (This is a good idea?)
BGGA:
void sortBySalary(Collection<Employee> employees) {
sort(employees,
{
Employee e1, Employee e2
=> e1.getSalary().compareTo(e2.getSalary())
}
);
}
FCM:
void sortBySalary(Collection<Employee> employees) {
Collections.sort(employees,
#(Employee e1, Employee e2) {
return e1.getSalary().compareTo(e2.getSalary());
}
);
}
CICE:
void sortBySalary(Collection<Employee> employees) {
Collections.sort(employees,
Comparator<Employee>(Employee e1, Employee e2) {
return e1.getSalary().compareTo(e2.getSalary());
}
);
}
First class functions:
void sortBySalary(Collection<Employee> employees) {
Function f = this.class.compare();
Collections.sort(employees, f);
}
int compare(Employee e1, Employee e2) {
return e1.getSalary().compareTo(e2.getSalary());
}
JSR 308
"permits annotations to appear on any use of a type, not just on class/method/field/variable declarations"
for generic type arguments to parameterized classes:
Map<@NonNull String, @NonEmpty List<@Readonly Document>> files;for generic type arguments in a generic method or constructor invocation:
o.<@NonNull String>m("...");for type parameter bounds and wildcards:
class Folder<F extends @Existing File> { ... } Collection<? super @Existing File>for class inheritance:
class UnmodifiableList<T> implements @Readonly List<@Readonly T> { ... }for throws clauses:
void monitorTemperature() throws @Critical TemperatureException { ... }for typecasts:
myString = (@NonNull String) myObject;for type tests:
boolean isNonNull = myString instanceof @NonNull String;for object creation:
new @NonEmpty @Readonly List<String>(myNonEmptyStringSet)For generic constructors (JLS section 8.8.4), the annotation follows the explicit type arguments (JLS section 15.9):
new <String> @Interned MyObject()for method receivers:
public int size() @Readonly { ... }for class literals:
Class<@NonNull String> c = @NonNull String.class;for arrays:
Document[@Readonly][] docs4 = new Document[@Readonly 2][12]; Document[][@Readonly] docs5 = new Document[2][@Readonly 12];
New filesystem API
True asynchronous I/O
Data and time API
Swing application framework
java.nio.filesystems
java.nio.filesystems.attributes
import java.nio.filesystems.*;
import java.io.*;
public class FileCopier {
public static void main(String[] args) throws IOException {
if (args.length != 2) {
System.err.println("Usage: java FileCopier infile outfile");
return;
}
PathReference source = PathReference.from(args[0]);
PathReference target = PathReference.from(args[1]);
int flags = CopyFlag.COPY_ATTRIBUTES | CopyFlag.REPLACE_EXISTING;
source.copyTo(target, flags);
}
}
import java.nio.filesystems.*;
import java.io.*;
public class FileMover {
public static void main(String[] args) throws IOException {
if (args.length != 2) {
System.err.println("Usage: java FileCopier infile outfile");
return;
}
File in = new File(args[0]);
File out = new File(args[1]);
PathReference source = in.toPathReference();
PathReference target = out.toPathReference();
int flags = CopyFlag.ATOMIC_MOVE
| CopyFlag.REPLACE_EXISTING | CopyFlag.COPY_ATTRIBUTES;
source.moveTo(target, flags);
}
}
import java.nio.filesystems.*;
import java.io.*;
public class FileSystemLister {
public static void main(String[] args) throws IOException {
File[] roots = File.listRoots();
for (int i = 0; i < roots.length; i++) {
FileReference ref = roots[i].toFileReference();
Directory root = ref.openDirectory();
list(root);
}
}
public static void list(Directory dir) {
try {
for (Directory.Entry entry : dir) {
FileReference ref = entry.asFileReference();
System.out.println(entry.getName());
try {
Directory child = ref.openDirectory();
// aliases?
list(child);
}
catch (NotDirectoryException ex) {
// There must be a better way to tell
// if a file is a directory before we open it
}
}
}
finally {
dir.close();
}
}
}
import java.nio.filesystems.*;
import java.io.*;
public class FileSystemLister {
public static void main(String[] args) throws IOException {
File[] roots = File.listRoots();
for (int i = 0; i < roots.length; i++) {
FileReference ref = roots[i].toFileReference();
Directory root = ref.openDirectory();
list(root);
}
}
public static void list(Directory dir) {
try {
for (Directory.Entry entry : dir) {
FileReference ref = entry.asFileReference();
System.out.println(entry.getName());
// Now let's see what it is:
BasicFileAttributes atts = ref.readBasicFileAttributes();
BasicFileType = atts.getFileType();
if (type == BasicFileType.LINK) continue;
else if (type == BasicFileType.DIRECTORY) {
Directory child = ref.openDirectory();
list(child);
}
}
}
finally {
dir.close();
}
}
}
BasicFileAttributes
Creation time
Last access time
Last modified time
File ID
Time units
Size
Type
PosixFileAttributes
Group
Owner
Permissions
FATFileAttributes
Archive
Hidden
Read only
System
ACLFileAttributes
ExtendedAttributeView
import java.nio.filesystems.*;
import java.io.*;
public class FileSystemLister {
public static void main(String[] args) throws IOException {
File[] roots = File.listRoots();
for (int i = 0; i < roots.length; i++) {
FileReference ref = roots[i].toFileReference();
Files.walkFileTree(ref, false, new NamePrinter());
}
}
class NamePrinter implements FileVisitor {
void visit(FileReference file, Path path, BasicFileAttributes attrs) {
System.out.println(path.getName());
}
void visit(FileReference file, Path path, IOException ex) {
System.err.println(ex.getMessage());
}
}
}
java.util.Date
didn't work; java.util.Calendar
didn't work; maybe now?
JSR 310 Date and Time API
Dates and times are hard:
Bruce Hamilton: "the deadline for filing a tax return when I'm sitting in HI, logged into an office in NJ, submitting to a server in CA a return which will be processed in CO."
Many time measurements have varying degrees of ambiguity. An action taken in 2006 may happen after one taken in 2007. However an action taken in 2005 always precedes one in 2008 (but only if we assume both are measured in the same calendar.)
There are more than 24 time zones.
Use cases (not currently adequately handled):
A date without a time: birthday, hire date, tax deadline
A time without a date: flights, class schedule
With or without timezones
Nanosecond precision
Date and time ranges
Convert dates between time zones
Archaeological and astronomical times
JSR 275: Units Specification
javax.measure.units
JSR-275 specifies one or more Java packages for the programmatic handling of physical quantities and their expression as numbers of units. The specification includes:
Checking of unit compatibility
Expression of a quantity in various units
Arithmetic operations on units
Concrete classes implementing the standard types of units (such as base, supplementary, and derived) and unit conversions.
Classes for parsing unit specifications in string form and for formatting string representations of quantities.
A database of predefined units.
I've used both SWT and Swing to develop client-side Java applications on and for the Mac - although nothing particularly complicated. Swing is complex as hell for anything other than trivial applications, and has a deserved reputation for bugs, performance problems, and lack of platform fidelity. SWT is much simpler, faster, and has the enormous advantage of actually using native UI widgets.
--Bill Hutten on the java-dev mailing list, Sunday, 5 Jun 2005 19:04:23
The biggest problem with Swing was that it can do so much that it’s kind of become like the 747 cockpit if you like APIs. There’s a lot of complexity there, and the hard part is figuring out how to use it. It’s in this weird situation where pretty much anything you can want to do in Swing, you can do easily. But what’s hard is to figure out the easy path through all of the different options, the different ways you can do things. Once you figure out the one true path to get what you want done, then it’s pretty easy. People often say “Why don’t you just make it easier by simplifying it?”, and say, “so you simplify it in this way, it would make my life better”. But then for the next guy it would be worse, because he wants to not go there, he wants to go on this particular path. So it’s been difficult to manage the complexity right.
--James Gosling
Read the rest in James Gosling Q & A: Builder AU: Program: At Work
JSR 296:
Well-written Swing applications tend to have the same core elements for startup and shutdown, and for managing resources, actions, and session state. New applications create all of these core elements from scratch. Java SE does not provide any support for structuring applications, and this often leaves new developers feeling a bit adrift, particularly when they're contemplating building an application whose scale goes well beyond the examples provided in the SE documentation.
This specification will (finally) fill that void by defining the basic structure of a Swing application. It will define a small set of extensible classes or "framework" that define infrastructure that's common to most desktop applications.
Developers plug in at a few customization points such as startup and shutdown.
Framework handles takes responsibility for saving and restoring windows and other parts of an application between startups and shutdowns.
Asynchronous actions that run outside of the Swing event dispatch thread.
JSR 295
Updates to one bean are automatically reflected in the others
E.g. GUI grid bean could update automatically when its associated database bean changes.
JSR 303
validation language to specify declaratively what values any given bean may take on:
An int property must be between 1 and 10
A String property must contain a legal e-mail address.
A color property must not contain red.
XML based
Is anybody actually using JavaBeans anyway? (not EJB)
Why did GWT and OpenLaszlo need to be invented?
Why did Flash succeed, and applets fail?
It's the tooling that's hindered client side GUI development in Swing, not the API
What's really needed: Visual C++ for Java; One button apps
Tooling hindered client side GUI development in Swing, not the API
What's really needed: Visual C++ for Java; One button apps
Microsoft, Macromedia, and probably Apple understand this.
Sun and IBM don't. Eclipse is just another API, not another tool.
Versioned JARs/Package Management
invokedynamic
More scripting engines
New Javadoc Tags
Java Kernel
Tiered Compilation
JSR 277, the Java Module System
Instead of a .jar file, data will be stored in a .jam file.
"superjar" that contains all the code and metadata
Supports versioning
A JAM can specify dependencies on other modules.
Centralized repository on each system.
or OSGI?
JSR 292: invokedynamic
The invokedynamic instruction is in many ways similar to the existing invokevirtual instruction. However, it is much less constrained by byte code verification rules. Instead, it relies on dynamic typechecking to ensure the integrity of the virtual machine.
Such instructions have long been present in virtual machines that support dynamically typed object oriented languages, such as Smalltalk or Self. Well known techniques exist for high performance implementation of these instructions, typically based on (polymorphic) in line caching.
Similarly, hotswapping has been part of dynamically typed programming systems for decades (e.g., APL, Lisp, Smalltalk, Self). It is much harder to provide such support for statically typed languages. To the extent that viable support can be added for the Java platform as a whole, we will capitalize on it. In cases where this is not feasible, support that applies only to dynamically typed languages running on the JVM can be added.
More engines? Groovy, Ruby, Python, E, Intercal?
Perhaps this is a bit bloated?
JSR 260: New Javadoc tags to enrich API readability
Categorize methods and fields by their target use
Semantic index of classes and packages
Distinguish static, factory, and deprecated methods from ordinary methods
Distinguish property accessors from ordinary methods
Different views
Embed examples, common use-cases with Javadoc
A.K.A. Java Browser edition
A small VM that installs as little as possible, and then loads other classes as necessary.
Mix of client and server HotSpot VMs
Client VM starts faster; server VM has better asymptotic performance
So use client VM at first, then switch to server
Maybe with multiple threads and processors on an underloaded system?
This presentation: http://www.cafeaulait.org/slides/nycjava/java7/
Java 2007: The year in preview: My article on IBM DeveloperWorks
Pure Danger Tech » Java 7: Alex Miller is tracking various proposals
"Managing the Java classpath (Unix and Mac OS X)" (Elliotte Rusty Harold, developerWorks, December 2006): Tips for mastering this most complex and infuriating part of the Java platform.
"Crossing borders: Closures" (Bruce Tate, developerWorks, January 2007): Investigates the importance of closures in Java syntax.
"The Cathedral and the Bazaar" (Eric Raymond, 2000): Explains why open source is good for the Java platform and other products.
Planet JDK: Aggregates the blogs of many people working on the next Java release.
Early ideas about Java 7: A video presentation by Sun Microsystems's Danny Coward.
The Java Kernel Project: Ethan Nicholas explains the inspiration between the newly renamed Java Browser Edition.
The java.net scripting project: Integrating dynamically typed languages with the Java Virtual Machine.
The Java Module System (JSR-277): Explained by Specification Lead Stanley Ho.
The Swing Application Framework (JSR-296): Join the effort to define the future of Swing development.
NIO.2: An effort to finally define a decent cross-platform filesystem API.
Throw your ideas into the Kitchen Sink Project and see what sticks.