• Home
  • About
  • Sample Apps
  • JavaOne 2007 – Day Three

    I don’t get much sleep during JavaOne. Days are long even if you don’t attend any late night BOFs and the jetlag gets me out of bed pretty early. On the third day I start get feeling the lack of sleep and I am not too unhappy that JavaOne lasts only four days rather than five as in previous years.

    My first session in the morning was “Java Persistence API: Portability Do’s and Don’ts”. I have been using Solarmetric Kodo (now with BEA) for some years and although I am not using the latest version I am still quite pleased with the functionality. The latest version of Kodo also supports JPA and therefore I was curious how JPA can be used with portability in mind. Mike Keith explained how the JPA specification was specifically designed such that vendors could add specific functionality without interfering with other vendors. A developer can refer to vendor specifics both at the property and query level and it’s quite easy to support more than one vendor. It reminded me a lot of JDO which has similar capabilities. The only thing that’s missing is a portable approach for pessimistic locking.

    Designing Scalable High Performance Rich Clients: From the Trenches” was up next. Rob Ratcliffe took part in the development of a complex Swing-based application which monitors and controls a potentially large number of mobile sensors. The talk was less than convincing, his demo nice in the beginning but way too long so I left early. If somebody tries to teach to me the advantages and disadvantages of a singleton I am definitely in the wrong session.

    I was looking forward to Ben Galbraith’s talk about “Debugging Swing Apps” and I wasn’t disappointed. Ben is a brilliant presenter, although he speaks incredibly fast which might be a challenge to some people in the audience. I admired the two sign language interpreters who somehow managed to keep up with his speed (they had to take turns every ten minutes). Ben explained how to use weak references for easy fixing of memory leaks and how AOP can help to identify code that leads to sluggish user interfaces. At the end he demonstrated a tool he wrote to experiment with Java 2D, e.g. trying out Java 2D calls interactively to gauge the impact of options on different platforms. To summarize, the talk was both filled with lots of useful information and entertaining. I was quite amused when Ben tried to dodge the Apple NDA while explaining some garbage collection features on Mac OS X.

    The title of “Spaghetti Is Not Tasty: Architecting Full-Scale Swing Apps” was promising but did not meet my expectations. Rather than focusing on design problems of large Swing applications he spent too much time on OSGI which can solve some problems but not all of it. The only thing I took from this talk is that for large applications it is recommended to use a message bus to distribute events, which was also mentioned by Rob Ratcliffe in his talk. Wiring listeners to too many consumers does not scale and is hardly maintainable,

    My last session was about “Garbage-Collection Friendly Programming“. Three garbage-collecting engineers from Sun laid out all the do’s and don’ts in Java to effectively deal with garbage collection:

    • Don’t use object pools. Java’s memory management is usually way better than Java developers can implement object pools.
    • Don’t use System.gc(): The garbage collector knows better when to run, you don’t have to tell it.
    • Resizing arrays frequently can put more pressure on the garbage collector
    • Finalize always takes two garbage collection cycles and is therefore quite inefficient. For Java 6 the garbage collection team even convinced the AWT-team to remove all finalize methods from the AWT (and therefore Swing) components. If you need something like finalize you can either use a finally clause or weak references.
    • Don’t use soft references, because it is expensive for the garbage collector to reclaim objects referenced softly. Only use soft references for quick and small caches. This contradicts what Ben Galbraith said in his session when he recommended soft references for any kind of cache.

    If you have a chance to grab the slides, just do it. They contain numerous hints how to write clean and efficient code with respect to memory management.

    The third day was kind of a mixed experience. I learned most in the sessions about Swing Debugging and Garbage Collection. With the other two Swing sessions the JavaOne program committee made some questionable decisions.

    Leave a Comment

    This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

    You must read and type the 5 chars within 0..9 and A..F, and submit the form.

      

    Oh no, I cannot read this. Please, generate a