Dave Landers, BEA Systems Inc.

Annotated Java: Annotations in J2SE 5.0

JDK 5.0 adds several new extensions to the Java language. One of these is called Annotations (a.k.a. MetaData). The idea behind annotations is nothing new – it has been around for quite a while in the form of custom JavaDoc annotations (like XDoclet). The big thing that JDK 5.0 changes is to move those annotations out of the comments and into the code itself.

Usages for annotations include code generation (like XDoclet can do). But since the annotations are actually in the code (and in the class file), their use can reach into class inspection and runtime. For example, EJB and Web Services will use annotations to replace or supplement deployment descriptors. You can use them as markers to enforce design patterns. And there are many more applications possible.

In this session, we'll look at how you can use this new feature to write better code. And we will of course look at lots of code examples.

Topics include:

Generic Java: Generics in J2SE 5.0

Another new feature in JDK 5.0 is Generics. The most common usage of Generics is with the Collections classes. For example, Generics allows you to create a Set which holds Integers. This is pretty useful. The most obvious effect of using Generics is that you get to quit doing so much type-casting when you retrieve things from the Set. The compiler knows that you have a Set of Integers, and adds the casts for you.

But Generics is much more than a typing aid. The real benefits come because the compiler can now enforce more type-safety in your code. Since it knows you have a Set of Integers, it won't let you add Shapes or Animals to that Set. This moves the error checking from run-time (ClassCastException) to compile-time. This will result in more robust code.

Generics are not limited to the Collections classes, you can also write your own classes to support Generic Types. This is much more difficult than it appears, especially if you are retrofitting an existing class and must maintain runtime compatibility with non-Generic usages of the class.

In this session, we will look at how to use the new Generics feature, how to write Generic classes, and take a peek at what's going on “under the hood”. And of course, we'll have plenty of example programs to look at along the way.

Topics include:

Picture of Dave Landers

Dave Landers is a Staff Engineer with BEA Systems in Boulder, Colorado. His current focus is improving the application deployment and management experience for WebLogic Portal. Dave has been using Java and J2EE in product development and consulting projects for just about as long as they've been around. When he is not at work, Dave spends his time working with the Boy Scouts and enjoys various outdoor activities with his family. If there’s any time left over (and there rarely is these days), he’ll disappear into the basement to do some wood turning.

Email: dave.landers@bea.com

Back to...

Chris Laffra

On to...

David Moskowitz