Home > Java, JavaOne > JavaOne day three

JavaOne day three

Beans binding good for the heart

The session was presented by Shannon Hickey and Jan Stola and started with them explaining that the caveat with the Beans Binding Framework’s JSR is not final. It’s pretty solid although not final. But they don’t see any fundamental changes being made until it’s finalised.

The Beans Binding Framework is all about properties. A property is not just a string. It’s an interface that represents the abstract concept of a property, it allows for definition of a property through various means, like for example through standard Java methodology or through an XPath expression.

A property is readable and write-able. It’s also immutable, it can be reused and properties themselves are neat objects.

The basic class of the framework is the BeanProperty which resolves properties by using reflection. There is also another class that represents a property and it’s called ELProperty since it represents expression language properties and it adds EL capabilities to them. Both of these classes work similarly. If a property or a value of a property changes they are being notified. And they both support maps, get(“key”).

There are also binding providers that provide all the functionality needed. Swing has already registered default providers for several of its components like JtextComponent.text, Slider.value, AbstractButton.selected and so on.

The binding describes and maintain binding between two properties. It is abstract and contains a Converter (the ability to convert values from source or target) and a Validator (it validates changes from the target). The AutoBinding subclass provides updates for the binding. 

Then they showed a demo of how to use NetBeans 6.1 (NetBeans 6.1 includes the binding framework by default) and the binding framework.

Then they talked about BindingGroup. A BindingGroup manages a group of bindings, methods and listener to track state of the group of bindings and is a singe point to bind and unbind a set of values.

What about when we want to bind multiple pieces of data, like a JList or a JTable? Well the binding framework provides the relevant implementations like JListBinding, JTableBinding and so on. An example code for JTableBinding in Java 7 is the following

Property fnp = BeanProperty.create("firstName");

Property lnp = BeanProperty.create("lastName");

JTableBinding tb = SwingBindings.createJTableBinding(READ, list, jtable);


    .setColumnName("First name" )



    .setColumnName("Last name" )



and for a list you will be able to do

Property nameProperty = ELProperty.create("${firstName} ${lastName}");

JListBinding lb = SwingBindings.createJListBinding(READ, list, jList);



Then they showed a JTable binding example (where the check box binding didn’t quite work). Then another demo with a car and pictures that correspond to properties. And a final demo with a picture of a train and properties read from the database (this reminded me of a similar demo I saw at Javoxx by Hans Muller).

For more information you can look at Shannon’s blog, at the project’s home page or at the JSR



Refactoring does not work with the framework. They are working on it.

What happens if a property cannot be bound? The system will throw an exception.


NLJUG and James Gosling meeting

This is so far the most interesting session I have attended. Well it wasn’t actually a scheduled session but something that the NLJUG is organising. This is actually the third time the NLJUG meets with James Gosling in person and has the ability to ask him questions. What can I say, respect to NLJUG and Klassjan for giving us such a great opportunity to meet and ask questions at James. These guys are amazing and have a model JUG which I think 99% of the JUGs out there need to follow. Well done guys.

Off to the questions:

Question: What do you think about closures? 

Answer: James said that he does not know how to answer that. He does not know what is going on in the JCP. Loads of people originally were afraid about closures mainly because of performance times. But now we have better hardware and language progresses and since closures solve a few problems it could be a good idea.

Question: What about Scala in the JVM?

Answer: Scala is a pretty good language but if you use it correctly it becomes unnatural for several people because it’s a functional programming language. He wouldn’t make huge changes to Java to accommodate functional programming languages since this would turn Java into a brand new language.  He closed this question by saying that there are loads of different language for different things.

Question: Isn’t it time for Java3? 

Answer: It might be, this is what things like Scala could be. It would depend on what kind of compatibility you would want to break if you implement all new changes. You have massive APIs that people are addicted to and these would be massive changes. 

Question: What do you think about deprecated methods? 

Answer: There were loads in Java 1.1. (mainly bean patterns) and many APIs like AWT use deprecated methods. There was actually a debate with the AWT team, should we break AWT and build up a new pattern or leave AWT as it is? Another interesting deprecated method is stop() (from Thread) method which is deprecated because almost every time you use it it’s the wrong thing. 99% of the people who have the urge to use the stop method are wrong. He also mentioned that he wanted to change the stop method name with a long name like stop_yes_I_understand_what_this_is_and_I_know_what_i_am_doing().

 Question: What about delivering different versions of Java without the deprecated methods? 

Answer: You could do it at different levels. One is to have the compiler fail the compilation (to something like “undefined method” error message). But there are so many libraries out there that people use that it’s unlikely you will find that you use no library out there that does not use some deprecated methods somewhere, even if they are hidden pretty well. It’s also depressing how often people use older APIs, like in the enterprise world they use old versions because of licensing reasons. Some of these enterprise application contracts people could have avoided by solaris because solaris can pretend to be some other systems (like solaris eight or nine or even linux) so vendors could use it to “fool” the application servers about the version used.

Question: Why isn’t aspect oriented programming endorsed by sun? 

Answer: Sometimes it is endorsed and sometimes it isn’t. It mostly works pretty well. But then when you look at some of the tools they make you do things way outside the real nature of the problem. It’s so easy to inappropriately use AspectJ. It’s completely overshadowed by use cases which are bad. Too many people were abusing it. There are places where people use that kind of technology (code injection) and it works really well, without aspect oriented programming. James mentioned that he likes aspect oriented technology but you should use it wisely and carefully. He would like to use it but not to have someone else use it on him.

Question: Do you feel the same about closures? 

Answer: Closures are a lot harder to use. Like operator overloading, there are some really compelling uses cases that would matter a lot to 5% of the developers, but not to the rest of them. In C++ they used shift operators for I/O and this was bad. But it feels like these wounds are now healed.

Question: Did you really fail chemistry? 

Answer: Not really but I never did well.

Question: Java is getting complex, it’s a risk, are you worried? 

 Answer: Not really. The language hasn’t got terribly more complicated. They tend to put a bit more of features there for the world to see.  If you look at generics or closures, people do not have the same depth discussing all the corner cases. Look at ruby, it does not have tight specs. But with generics, most of the scary bits are corner cases. Yes it works but it was really pretty tough. But most people do not have to go there. 

All the weirdness, like wild chars, are pretty straight forward. But most of the complexities are in the libraries these days. The only way to make it simple is to do less. One thing that people mention is why do you not delete CORBA? No one is using it. But the truth is that no-one admits to using it. they use CORBA all over the place and if you try to take out these numbers it’s a really bad idea. It’s always a very difficult thing to decide how to redo some of the complexities.

Question: What new things in open source community are you waiting closely that might end up in next releases of Java? 

Answer: I don’t really have any kind of list in mind. I wish someone would do a decent HTML rendering engine. Currently all available are either broken or outrageous complicated. The problem with HTML is that there is no specification. There is a document that people call it a specification but it’s not. The open source project he works with mainly the most is open solaris. 

Question: When is it safe to buy an iPhone with a decent Java implementation? 

Answer: There are Java implementations in iPhone, but not with the GUI. This is Apple’s issue. Look at the SDK license, it’s a nightmare. It seems they have a compiler but it will take a stack and compile into apple bytecode that’ indistinguishable to other bytecode. But its code linking issue and introspection is a bit of a problem. One day in the future. Nothing more to say other than a look at the Wireless magazine article a couple of months ago. Go back to linux.

Question: What about android

Answer: They are telling nobody anything. They have written their own VM. At various times they had discussions with them about putting a real VM in there. Google has not announced any plans of business models. What are they going to do about it?

Answer: Why can’t you inherit annotations? 

Answer: I don’t have the answer for this. Probably the expert group couldn’t find out how to resolve several semantic issues, but I don’t know. There is a huge redesign in the annotation group that will be available in Java 7. But this is more for people to annotate more.

Question: What about progress on FX? 

Answer: The FX team is very happy with the progress on FX. They now have a real compiler. They are currently expecting to resolve a few naming issues remaining. 

Question: Is it stable enough to use in projects? 

Answer: It’s stable enough to play around with it, but in a few months people will be able to use it seriously in production code.

Question: What about the adoption of FX? 

Answer: People have been very enthusiastic so far. But you just have to wait and see. There is really computing underneath, real rocket science below so you have do really hard rendering with excellent integration of all accelerators. The new thing about the FX compiler is that it can adopt for different implementations. You can compile it to target different devices like android, mobile phones and so on. In blue ray you really care about gorgeous results. They have pre-computed images rather use the graphics images. If you look at the chip sets you can get today (like 3D rendering chips for cell phones) they cost nothing, they do gorgeous 3D so it’s easy to explore FX capabilities.

Question: What about visual editors for FX? 

Answer: We had hoped to have stuff to show at J1 this year (there is a thing called “the distiller” which works well with NetBeans) but it didn’t work. They are working on a visual editor. FX becomes big deal for more folks as they really care these days that things look very good. 

Question: What about the future of flex, FX etc. Will they replace traditional web? 

Answer: Yes. Ajax had a few issues. You could make interesting stuff but it was unbelievably hard. And yet, despite the fact that you put thousands of man hours creating a text editor for example, it was pretty lame text editor. The Ajax experience has been very interesting. It demonstrated that people cared about dynamic interactive experience, but they cared so much that made simple things complicated.

Question: What do you think about SunSPOT?

Answer: They are really cool. And there is a really huge business case around it. There are a variety of companies that build things for SunSPOTs. They might be less known but the are leading the industrial revolution.  They get a lot more deployments that you think about but they are not very visible so you don’t know they exist. The kind of stuff people doing with embedded stuff is very very different than the traditional use of Java.

Question: How is it with Swartz being CEO? 

Answer: I like Jonathan a lot. He is a cool guy. When you are CEO you have to look responsible in front of wall street analysts. He is a bit edgy for them but he works pretty well and he is really sharp. I like him a lot. By training he is a mathematician. He asked the question “what do you do with a maths degree?”; well software. Before coming to Sun he ran a small software company. It’s nice to have someone who thinks making software beautiful is a good thing. 


Transactional memory in Java technology based systems by Vyacheslav Shakin and Surech Srinivas

The main goal of the session was to learn about about what transaction memory is and how Java can utilise it.

The mutli-core era is upon us. In April 2005 Intel introduced the first dual core processor. In 2007 it started getting accelerated and so the hardware folks have thrown the gauntlet. Now it’s up to the software people to utilise it.

In order to utilise the cores, you have to have concurrency control vectors. Concurrency control vectors provide

  • granularity – coarse grain/fine grain concurrency
  • scalability- scale up/down
  • partitioning- task level parallelism, data parallelism, main core/accelerator

Granularity deals with 

  • coarse grain concurrency which is used in J2EE transactions (every connection is concurrently processed), application level concurrency (virtualisation, multiple JVM instances)
  • fine grain concurrency which is using transactional memory and java.util.concurrent data strucures

Transactional memory is sequence of memory operations that execute completely. There is 

  • Software transactional memory –  software only implementation and new language constructs
  • Hardware transactional memory – hardware only or HW/SW implementation

 Software transactional memory is implemented completely in software using  language extensions (like “atomic” or “retry”). The software system 

  • guarantees atomicity
  • discovers and guarantees concurrency
  • coarse grain programming and fine grain performance

An example of how the atomic extension could be used (instead of a synchronized block) is shown below.

public Objec get(object k)



    return Map.get(k)



Hardware transactional memory works as follows

  • Hardware views individual threads as executing a series of reads/writes to memory
  • in a transaction we want the series of read/write to occur at a single instance in time

In order to design software transactional memory we need to think about

  • isolation (weak/strong atomic system)
  • data management (in place/buffered)
  • conflict detection(eager, lazy, granularity, policies)
  • language integration (nesting, native code,i/o, exceptions, library/language extensions)

 Isolation means that each transaction must appear to execute in complete isolation. We have weak atomic systems (only relative to other transactions) and strong atomic system (relative to both transactional and non-transactional access). Weak is not a string subset of strong

There is a number of implementations software transactional implementations

The transaction in the Java platform will define the following extensions 

  • atomic – execute block atomically
  • retry – block until alternative path available
  • orelse – compose alternate atomic blocks
  • tryatomic- atomic with escape hatch
  • when – conditionally atomic region
  • it is build on prior research in other systems.

In order to design hardware transactional memory we need to think about the existing software usage – the industry has invested a lot in the existing programming model for Java and changing the programming model is hard. 

Sun wants to implement a Java based system that utilises hardware transactional memory (isolation & atomicity) with no changes to software. They use  speculative lock elision which improves concurrency by speculatively executing locking code and roll back on actual data contention. And 

speculative execution which improve single thread performance by speculatively executing hot paths and roll back on assumption violation.

Software transactional memory results in

  • smaller workloads easier to transactionalise (larger workloads are harder due to i/o, native code, or weak atomicity.  
  • Software transactional memory has subtle semantic challenges but it also has good scalability under lower contention and for micro benchmarks.

Both software lock elision and speculative execution prototypes run realistic workloads using future proposed instructions and yield10% better performance.

In summary

  • transaction management is a tool for concurrency control in multi core systems
  • software transactional memory is a software technology for developing new parallel software
  • hardware transactional memory is a hardware technology that both existing and new software can utilise to improve performance as well as concurrency

Java Mangement extensions technology update by Jean-François Denise and Eamonn McManus

The session started by a slide explaining what is new in JMX 2.0

  • namespaces
  • event services
  • miscellaneous changes

JMX is a standard part of Java since version 5 and can be used to manage and monitor running applications.

At this point they showed us a demo of how to use JConsole and its functionalities.

After the demo they talked about MBeans (ManagedObject) which can link to other objects or they can even manage themselves. A ManagedObject (MBean) represents a resource. A MBean can have (lets say in a Poker game)

  • attributes (player count, maximum connected players)
  • operations (ejectPlayer, addPlayer)
  • notifications (com.example.player.joined – a notification every time a player joins) 

There are several kinds of mbeans

  • standard
  • MXBean
  • dynamic
  • model
  • open

the simplest are standard MBeans and their cousins MXBeans

At this point they went through some code examples of how to create a managed bean.

In order to make an application JMX connectable in Java 5 you can run it with -Dcom.sun.management.jmxremote. In Java 6 this has changed and it just works (if you are connecting from the same machine).

There are two JSRs, JSR 255 and JSR 262 and they expect that Java 7 will include both of the JSRs.

The namespaces they mentioned in the beginning mean that you can structure the MBeanServer in a hierarchical way. You can have several applications running in the same JVM and you don’t want them interfering with each other, so you want each to have a separate MBean server assigned on them. With namespaces this is possible and we can gather these MBean servers together and control them from a higher MBeanServer.

Another feature of namespaces is cascading which means that the MBeanServer for a namespace can be remote by using “subagents” from the “master agent”. This would be useful for clustered application servers. Each clustered instance can have its own MBean server but also have a parent MBean server to control these subsequent servers.

But there are some cascading issues like security. If I connect to a master agent what permissions do I need to connect to subagents? This can be solved by the master propagating the credentials to sub agents. If there is network failure what happens? What do we do if the connection to the remote MBeanServer fails? Do I still see it in the master server? Can I reconnect when connection comes up again?

We can have virtual Mbeans. The standard implementation has only one Java object for every MBean, so we do whatever necessary in order to simulate the existence of an object. This is very appropriate for large numbers of objects where they come and go very quickly.

We can have client contexts. We can use locales for clients to communicate with server in namespace jmx.content//. A call to getAttribute(“jmx.context//locale=uk//com.example…”), “bar”) becomes  a call to getAttribute(“com.example…”, “bar”). An Mbean can return localised string in attributes.

The event service mentioned in the beginning is defined in the JSR 160 and allows notifications to be received remotely. 

Several times we have very loose coupling between client and server and when there are many notifications a client can miss some since an MBean does not know who is listening to it). Event service fixes these problems without changing the client/server protocol, and also allows listening to a set of MBeans in one operation.

Event service also allows you to use custom transport, it allows you to change the transport on which you receive notifications.


  • you can define MBeans with annotations
  • you don’t have to define the interface you just annotation the implementation class with @Mbean annotation
  • there are annotations for descriptions with @Description
  • there is a query language
  • queries inspired by SQL but must be constructed with code
  • there is new sql-like language (queryexp query = query.fromStrign(conenctTime > 60) for instance)
  • code is much easier to read/write and provides a simple way for clients to input user queries

web services connectors 

  • integrate JMX with http/web architectures
  • allows JMX to interoperate outside of the Java world.

Java clients can use JMX Remote API. The protocol choice is nearly transparent and it fits into JMS Remote API Open Architecture. All you have to do is to just change the URL service: jmx:ws://…

This fits into web architecture and is firewall friendly. It also provides interoperability.

The web service management is soap based and relies on existing set of web service specification. The adoption is growing (it’s supported in Windows Vista, XP sp2, 2003 server) and it is the building block for the management of the virtualisation (Sun, MS, VMWare, Novell).

The JSR 262 is about mappings. It defines an XML representation for Java types exposed in MBean interfaces (primitive and boxed types, other java types like URL, JMX open type, some collections such as Lists, Map, Vector). It defines a mapping from exceptions into web service management faults. The security relies on the same security model and is using http basic authentication and https encryption. 

Finally there was a poker demo written with JMX and JavaFX as the front end.

If you want to learn more visit java.sun.com/jmx



Is there any facility to persists JMX state? No, you will have to programme it yourself.


Creating Games on the Java™ Platform with the jMonkeyEngine with Rikard Herlitz and Joshua Slack

This was mainly a friendly discussion and a presentation of games that are using the jMonkeyEngine and are written in Java.

People compare Java games to top quality games and they don’t believe that the games that perform as good as the non-java games are actually written in Java. The evolution can best embodied into an example: jMonkeyEngine.

JMonkey is an open source graphics API. It is the bedrock technology to build 3D games in Java and you can embed it into Swing and AWT if you want.

There were presentations for

In any language it’s the hardware that does all the work. The language just sets up the hardware and instructs it what to do.

Project wonderland (no really a game but the platform could be applied for gaming technology) it’s an open source project. They are moving to jMonkeyEngine for rendering. They want to get all the capabilities that jMonkeyEngine supports. Also the jMonkeyEngine community and tools are in abundance. The jMonkeyEngine edition will be released in Fall this year.

Then Doug (the person in Sun responsible for 3D) said that they are re-writing the Java 3D components. They are doing some interesting things that have not been addressed yet in the 3D industry. Client technologies become multi-core and they will build a games engine that people have never seen before. It would be  platform that wonderland could be plugged in. They are sort of finalising the architecture before it goes public.


Java class loader rearchitected with Iris Clark and Karen Kinnear

The current problem with class loaders is that there can occur class loader deadlock. The JVM spec does not specify that class loaders have to ask parent before they load child class. Technically speaking a class loader implementation can delegate to anyone. But the class loader spec does specify the parent delegation. This is what they have implemented into the SDK.

A deadlock may occur when a multi-threaded custom class loader uses a non-hierarchical delegation model. It frequently occurs in app servers or code that is trying to run multiple versions of the same application classes. Examples of class loader deadlock  running on recent versions of JDK are scarce (might be because users have written their own workaround, or that the JVM changes already in production have reduced their frequency)

The JSR 277 specifies the module system which solves name space an versioning problems associated with distributing complex applications. Each instance of java.module.Module provides its own class loader (a) when the application’s main class is a Java Module b) the system class loader is the corresponding Module’s and c) ModuleLoaderModule authors must extend java.module.Module)

The requirements for re-architecture are 

  • they must allow non-hierarchical class delegation topologies without deadlock
  • they must be backwards compatible
  • they must meet the JSR 277 needs
  • must be possible to define guidance to migrate custom class loaders to take advantages of un synchronised behaviour.

VM changes that are already in production

  • bug 46999981 which is a ClassCircularityError incorrectly thrown (occurs when two threads attempt to load the same class even if there is no circular dependency, fixed in JDK6 and JDK 5u8)
  • finer granularity locking not dependent on ClassLoader object (VM updated to ensure class loading is thread safe, fixed in JDK7 and JDK 6u4)
  • 4470034 additional diagnostic information for NoClassDefFoundError (exception chain mechanism to provide root cause data, fixed in jdk7 and JDK6u4)

ClassLoader.loadClassInternal() is called by the JVM. It is called after acquiring a lock on the ClassLoader object since as of JDK6u4 the VM has a “parallel” mode for the bootstrap class loader (ClassLoader object is no longer used as a locking mechanism by the VM). The “default” mode continues to lock as before and invokes LoadClassInternal().

Sun asked if they can delete the ClassLoader.loadClassInternal(). If yes it will help resolve the no 1 SDN bug; 4670071 loadClassInternal(String) is too restrictive (817 SDN votes as of 28 April 2008, originally filed in 2002 against JDK1.3.1_01 largely in response to problems running JBoss, potential workaround in JBoss 3.2.3?). The last constructive SDN comment posted late 2004 and Sun thinks that removing loadClassInternal() would be the most effective solution.

APIs changes that are proposed APIs is the addition of an interface ParallelClassLoader which can be used as shown below



  if (this instanceof ParallelClassLoader)

    loadClassUnsynch(name, false)


    // Load class as you normallt do


loadClassAsynch… is the same as loadClass but it’s not synchronised

If you want to implementing a custom class loader you wouldn’t have to change anything, just  implement ParallelClassLoader and update existing findClass method to be thread safe. The second solution would be to convert to the Modules system (the Modules class loader is necessarily a ParallelClassLoader, custom code will still need to be thread safe).

Additional library changes

  • Synchronisation scheme in some libraries classes
  • remove usages of exceptions for message passing
  • provide APIs for additional diagnosing info
  • update documentation
  • modernise language use in code (generics, varargs)
  • other bugs and RFEs





Categories: Java, JavaOne
  1. 12 October 2008 at 6:14 pm

    I just love the title. Beans binding good for the heart. That is good stuff.

  2. 2 May 2009 at 9:28 am

    Nice stuff,
    Thanks for sharing.

  1. 28 October 2009 at 9:24 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: