Looking for a co-blogger Migrating the code to JavaForge
Jan 31

With the switch to Generics in Java 5.0, I wasn’t at all surprised to find Reference and ThreadLocal classes switched to a generified version where their get() methods return T. Code just looks better, so it makes sense to switch these wrapper class to generified versions.

But what happened to other wrapper classes, deeply rooted in Java as well? GuardedObject and SealedObject should have been generified as well! What makes them any different, aside from being in the security packages?

And if in these wrappers we discuss, I do believe some annotations for easier development using wrappers should have been made. I think the first thing I’ll do with the new annotations processing tool (JSR 269) is to create annotations that would hide the whole get() semantics, such as:



@WeakReference
public Object o;
..
..
// inside method
o = new Object();
..
..
Object i = o;
..
..

Would be compiled as if it was:


public WeakReference<Object> o;
..
..
o = new WeakReference(new Object());
..
..
i = o.get();
..
..

That’s nicer, isn’t it?

Share/Save/Bookmark

One Response to “… And what about SealedObject and GuardedObject?”

  1. Adam Kruszewski :: WebLog(); Says:

    @WeakReference (in response to “… And what about SealedObject and GuardedObject?”)

    Today I have stumbled upon a blog post titled “… And what about SealedObject and GuardedObject?” and
    As a quick exercise I have implemented spoken feature in AspectJ. I didn’t write an annotation processor because it was quicker (for me) to go wit…

Leave a Reply

Chaotic Java is Digg proof thanks to caching by WP Super Cache!