Java One - day 2

Closures Cookbook



- The presentation was okay. It was full of code, which suites me fine. I must say that closures, generics together makes for messy looking code. Adding function types makes it more readable. His examples for choosing closures were poor. His timing interface could have been written much simpler using regular generics.

Conclusion for this session - if or when closures comes to the Java platform, you will need to look it up and learn it properly if you plan to do API's. If you are just a regular user, then it will make your day easier.

Introduction to Web Beans


The reason for going to this lecture is Gavin King. That said, this is what I thought of the talk.
- Goal is to have all state data available in one bean - either request data or transaction source.
- Some interesting stuff about how binding is made: Binding types and deployment types. Using deployment type you can specify like Unit Test or Production. Production is default.
- Scope and context: ApplicationScoped, RequestScoped, SessionScoped, ConversationScoped.
- Producer methods (factory)

My impression is basically that the code using Web Beans makes an effort to make as much as the configuring possible to solve compile time by compilation. Alf pointed out that yo must look at this with Seam in mind where the goal is to remove all the unneeded layers in our code.

Visit to the pavilllion


Today we stopped at Intel's stand. A guy from VM ware was there - he mentioned that VMWare and JRockit had made a product where the operating system is out of the loop. Only a set of virtual hosts with basic functionallity for running multiple JVM's. The cool thing here is that the JVM from JRockit could tell the underlaying virtualization system what amount of memory it actually needs so that other VM's may use it. It was also possible to move one virtual machine from one node in a cluster to another node in the cluster. These are interesting features as they really take a lot of stuff out of the loop. Less security risks, lower cost for OS (if applicable)

Experiences with Debugging Data Races


- Formally
- Two thread accessing the same memory. (broken attempt to use two CPU's)
- Memory reordering can break stuff.
Common data races
- Double read with write in the middle
- Two writes with reads in the middle.
- Double checked locking
- Getting clever with hashMap (Danger - read can trigger resize of hashmap!)

How to solve this
- Visual inspection (does not scale)
-> Make sure that shared variable is good.
-> Avoid double read.

Printing
- Write tokens to per thread ring buffer. Don't create strings. With/TimeStamp.
- Later sort on timestamp and you will see which thread did it.
- Important not to spend much time or it will affect the race conditions.

Tools
- Not ready for prime time.
- Use FindBugs

Good Practice
- Concurrency is it's own complex problem.
- Needs its own wrappers and access control.
- Don't get clever w/concurrency
- Document, Document, Document
- Use private data
- Use immutable data.
- Use well-tested libraries.

Transactional Memory in Java™ Technology-Based Systems


- Concurrency vectors - granularity.
- Corse grain - multiple machines, multiple VM's, virtualization.
- Fine grain
- Data structure level.
- Loop level

Transactional memory
- Similar as DB transactions.
- Software transactional memory (new constructs) or hardware transactional memory (new instructions).

Software transactional memory
- Language extensions (atomic, retry)

An implementation of this is shown. It precompiles to java.
Both the JVM and JIT is affected. (As far as I can understand after almost falling asleep by the Russian English)

.... the Russian guy made me almost fall asleep. The guy from India didn't help either...

In conclusion - this is research in progress - no working prototype for Java was released by them yet.

Putting 3-D Earth into Your Applications and Web Pages


A nice introduction to Whirlwind library. Nice looking UI.

BOF: RIFE

- Good session!
- Rife stands for nothing at all Happy
- Continuations does not support recursion and pause() - this explained a lot of me on how continuations are solved. They are really not a complete co-rutine implementation (not that you need that really).

BOF:The Long Tail Treasure Trove


Nice libraries walkthrough - my favorites was (those that were new and looked useful to me):

* DisplayTag: Library for building tables in jsp.
* EHCache - library for doing caches.
* Janino - a java compiler for inline code - script with code.
* jarjar links - stack into one jar file several jar files, but also rename a given set of classes into a new classpath making it possible to use an old version of classpaths.
* jDBI - simple tool for making easier jdbc queries.
* JSON-lib - code for JSON <-> Java
* Mock Javamail - test mail sending. Fun - Mailbox.get("mailaddress@foo.bar");
* Smack - jabber client.

BOF: What's hot in Java Debugging

This one looked boring as hell. I left as I saw that the only thing they were planning to do was showing the heapwalker.

BOF: The tiny robots.

I went and listened to the sun spot attached to the robots with foam shooters on top. They were cool - even though you do not have the robots, you can run the simulator.
|