Home arrow Java & J2EE arrow Page 6 - Java Comes of Age

Meta-data - Java

Time to open the Champagne -- Java 1.5 is out, and the language has finally come of age! With the new Java 1.5 specification, Java now contains features that make it feel like a proper "grown-up" language. The rest of this article will introduce you to these new features. To try out the features for yourself, simply download Java 1.5 from Sun’s website and give it a whirl. Note that you’ll need to compile the code using the –source 1.5 option; otherwise, you’ll get compilation errors when using the new features.

  1. Java Comes of Age
  2. Type-Safe Enumerations
  3. Static Import and Generics
  4. Enhanced For Loop
  5. Auto-boxing, Auto-Unboxing, and VarArgs
  6. Meta-data
By: Simon White
Rating: starstarstarstarstar / 20
April 07, 2004

print this article



The idea of the new Meta-Data facility is to add annotations to your code that do not alter its semantics, but provide additional information that can be used by a compiler or other utilities. An example of such an annotation that you probably use already is the @deprecated tag. Marking a method as deprecated does not change the operation of the method, but does generate a warning when the compiler encounters it.

Java 1.5 introduces a new tag, called @override, with which the programmer can explicitly state the intention to override a method of the superclass. If the superclass contains no such method, then the compiler generates an error:

public @Overrides String toSring() {
return value+" of "+suit;

In this example, I missed out the t of String in the method name, so that the method in fact does not in fact override the toString() method of java.lang.Object. When the code is compiled it produces the following error:

Card.java:22method does not override a method from its superclass
public @Overrides String toSring() {
1 error

Defining your own tags to contain meta-data is somewhat more involved, and is therefore an activity that most Java programmers will eschew. On the other hand, I can imagine that once tags are defined, they would be used by large numbers of programmers. Depending on how the meta-data facility is configured, annotations can be available in the source-code, at compile-time, or even in the class files, accessible through Java reflection. This promises rich and powerful sets of annotations that can be used at different stages of the development lifecycle for many different purposes.


There are some other new features, too. The features that I found most interesting are the following:

  • Extensions to JDBC RowSets to provide caching and filtering.

  • Two new look-and-feels: Synth, a skinnable look and feel, and Ocean, a new theme for Metal.

  • There is now printing support for the Swing JTable.

  • Improved diagnostic abilities: using Thread.getStackTrace(), it is now possible to programmatically generate a stack trace as an array of StackTraceElements.

Java1.5 is an impressive step forward, although not all of the changes are popular among developers. I have read several discussions in which some people express the sentiment "Why do I need that -- I can get on perfectly well without it!". That may be true. But most of the language changes in Java 1.5 aim to reduce programming errors and increase productivity. Developers who do not embrace such changes risk being left behind by more receptive, and ultimately more productive, peers.

Although I welcome the changes from a technical standpoint, one cannot help but wonder what would have been included in Java 1.5 were it not for the driving influence of .NET and C# in the marketplace. I believe that new features such as enumerations and generics are a direct response to the features of C#. The intense competition for market share between Sun and Microsoft is not only an interesting sideline sport, it is also accelerating the technological advances from which we, as developers, will benefit.

>>> More Java & J2EE Articles          >>> More By Simon White

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates


Dev Shed Tutorial Topics: