Saturday, August 21, 2004

Annotations - one of the many differences between .NET and Java 5.0

If you are a software engineer using both .NET(C#) and Java 5.0, there are some subtle differences between both metadata implementations - attributes/annotations. The first one you normally run into is the fact that Java's annotations are available at source level only by default. Try running the following code:

public @interface SomeAnnotation { String value();}

@SomeAnnotation("hello")
public class SomeClass {
public static void main(String[] args) {
System.out.println(SomeClass.class.isAnnotationPresent(SomeAnnotation.class));
}}


If you come from .NET land, you might expect the output to be "true", but what you actually get is "false". To make the annotation available at runtime, change SomeAnnotation to:

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE,ElementType.METHOD})
public @interface
SomeAnnotation { String value();}

IntelliJ 4.5.1 and Java 5.0

So I upgraded to IntelliJ 4.5.1 last night. As stated by other bloggers, IntelliJ has very nice support for Java 5.0. I'm going to start playing with Java 5.0's annotations tonight since the last project I worked on (C#) used attributes in a big way - attributes before the .NET equivalent of Java 5.0 annotations.

final Object[] aa = {"hello", 22};
I have to admit the autoboxing feature in Java 5.0 is nice - especially if you write Java and C# code.

for (String s : a)
It also feels natural to use the new enhanced loop - maybe again because is some ways its similar to what I write in C#

Friday, August 20, 2004

The New World

I finally moved to Eclipse 3.0 today at work. I've installed the plugins are per the previous blog entry. Anyone got any recommendations for other must-have plugins?

Stuck in the Old World

The current project is interesting, and yet painful. Interesting in that I am back in Java land after a year or so, but painful in that all the current work is on Java 1.3.1 (and Eclipse 2.1), and hence I'm missing out on the expanding world of Eclipse plugin's that make development life easier - Jupiter, FindBugs, JDocs, Profiler etc. With Java 5.0 out soon, I hope we at least move to Java 1.4 on the current project. At least then I can start using Eclipse 3.0 again.
In the last week or so I started using Hibernate. Very cool, easy to use/install, with good documentation. What more could you ask for.

The Sun-JDocs issue is sad. I have to agree with Dion with regards to the Microsoft comment.

Last night I upgrading my Fedora 1 box to Fedora 2. The upgrade went fairly smoothly apart from when I rebooted, and got an error message during Gnome startup. Gnome did start after I ok'd the error message. I just need to dig into some log file to discover and fix the issue.

Finally, one of these days I'm actually going to get time to install and play with Blitz.

Thursday, August 05, 2004

10g

Today I had reason to install Oracle 10g. I always find installing Oracle painful - maybe its just the initial slowness of the actual installer, or maybe its the size of the download. One benefit of 10g is that it offers access to the Oracle Enterprise Manager via a browser (http://localhost:5501/em by default). SQL Plus still sucks badly, maybe one day they will actually fix this crappy product.

Once 10g was installed, I knocked up a simple Java program to ensure I could access the database, and ended up with the classic JDBC error "java.sql.SQLException: ORA-00600: internal error code, arguments: [ttcgcshnd-1], [0], [], [], [], [], [], [] ". The problem as usual turned out to be that I had classes12.zip on the CLASSPATH instead of classes12.jar.

One nice feature (or maybe not a feature) of 10g was that I didn't seem to have the TNS setup issues I had in Oracle 8 - maybe this was due to the thin ("jdbc:oracle:thin:") connection string I was using.