Sunday, 12 December 2010

Apache quits JCP, begun the clone wars has...

This was something expected but still shaking. Apache who had great contributions to Java and JCP and had been choosen JCP member of the year several times left JCP. Since from Sun era, Apache had a clash on TCK license for Apache Harmony project. Actually about a month ago at devoxx keynote panel things became more clear when Joshua Bloch talked about Oracle's reaction behind close doors.
After the JSRs for Java7 voted, Apache finally made the expected move and quit the JCP and the executive commitee.
JCP might not have been a responsive and effective organization but still it was something important for the community. I extremely agree this post on how JCP was ineffective. However this separation would change things on Java world forever. This seperatists movement will make forking of Java official which had been in progress for long. The community will probably follow apache, android and other Java likes where the business will follow Oracle and EE standarts.
Oracle is planning good stuff for Java but definitely they have no idea on community relations. This is the only response on Oracle side while Apache clearly showed their reasons. Please Oracle hire someone to keep up the community relations and please tell your lawyers to let him free.  Or is this just like Palpatine's plan to push a seperatist movement to make legal excuse for the war? Whatever it is, this is not a victory and begun the clone wars has...

Thursday, 2 December 2010

org.eclipse.swt.SWTException: Invalid thread access


Eclipse plugin development may introduce new set of exceptions to your life but actually this one is familiar. Just like most other UI architectures SWT, thus eclipse offers a single threaded UI model. Nature of working with in plugins may confuse in which thread you are but eclipse will definitely and politely remind you by raising an "org.eclipse.swt.SWTException: Invalid thread access" exception.

Although most the exceptions you may face during plugin development can be quite tricky, this is one is quite well documented and well known, even in SWT faq.
Briefly the code block needs to deal with the UI thread should be running within the following block:
Display.getDefault().syncExec( new Runnable() {
   public void run() {
      //access UI stuff
   }
});
Simple? Just keep in mind, SWT is a single threaded UI model just like awt, swing or most of the others.