<< May 2004 | Home | July 2004 >>

Open Source Java

As Sun resists the call from ESR and IBM to open source Sun's implementation of Java, another Java implementation may already have been installed on your hard drive.

If you use a recent version of Linux such as Fedora Core 2, or Cygwin, you may already have installed the GNU GCJ compiler, and the GNU Classpath class library.

Although not as complete as the Sun JDK, the GCJ/Classpath combination can compile Java bytecodes to native executables, and can already run many open source Java applications, including Eclipse and Ant. I wrote about it for OCI's Java News Brief in January 2003.

So Sun or no Sun, Open Source Java is here and now. Sure, it's not as complete as we would like, but it is useful already and has the potential to do more. And it comes with my Linux distribution.

I mentioned 29 days ago that I was ready to switch sides from Sun to ESR/IBM. My wish as a user of Java technology is very simple: Make is so that the Sun JDK can be bundled in the Fedora Core CDs (or other Linux distributions). While I'm waiting, I'll be using GNU GCJ, and (very reluctantly) SWT.

I understand there's going to be a panel discussion about "a new community and development model". I sure hope someone would address the issues raised in Tom Tromey's blog.

JavaOne Keynote = InfomercialOne

Those who went to the show probably won't say this, but the Jonathan Schwartz keynote at JavaOne was just an infomercial:

Jonathan: Java can make you a lot of money

Siemens: We used Java, and made billions

Jonathan: We have a tool just for you. Making money has never been so easy

Java Guy: We used Java, and made billions

Sun guy: Thousands of people has gotten rich using Java. So can you.

Sun guy: We have a package just for you.

Sun guy: It's so easy, you can make money just by drag and drop

Sun guy: How much do you think it will cost you?

Sun guy: Not $1000. Not $500. For our viewers, it's Free!

Sun guy: All you have to do is to call this toll-free number and subscribe to our incredible newsletter for $99 a year

Sun guy: As a special bonus, our studio audience gets to subscribe to the same newsletter for 50% off

Sun guy: That's not all. Our studio audience also gets this incredible book (holding up book), a $40 value, free

Jonathan: Everybody can become a Java billionaire!

J2SE 5.0!

C|Net News.com: Another spotlight at the show will shine on the new version of Java for desktop computers--a version code-named "Tiger," different enough to merit a new name. Previously called Java 2 Standard Edition (J2SE) 1.5, it's now going by the name J2SE 5.0, Keller said.

Friday Misc Bits

Guess that secret:

David Flanagan: Finally, to pique your interest I'll add that the second paragraph of the preface and the second sentence of Chapter 1 both mention something that is supposed to remain a secret until JavaOne. If you can get your hands on a copy before then, you can be in the know while it is still secret. (Hint: notice that I've been referring to this next release of Java by its codename.)

Let me guess: The next release of Java will have a shockingly novel real name, like the JDK? No. Better than that, how about "The next release of Java will be called Java 5"?


Nathan Tippy told me he prefers Eclipse over IDEA: "The key bindings a so unnatural in IDEA."

Well, Eclipse is certainly getting better and better. But I still prefer IDEA.


Paul Jensen gave a OCI internal presentation on Spring Framework. It's a very good talk. The good news is that Paul will give an extended version of it at the St. Louis Java User's Group in November. The JUG is open to everybody and is free.


While you are at the JUG homepage, also check out the presentations for the next few months: Velocity in July, Eclipse Plugins in August, Pluto in September, J2ME in October, and Groovy in December!


I met Zhicheng at the lunch meeting. He told me he still needs to figure out something for the project (the one I left a couple of weeks ago). It's a Swing JTextField that has a fixed length limit (using a DocumentFilter). The problem is that it doesn't work in Japanese.

The crux of the problem is that "Toyota" is a two character string in Japanese, yet needs six keystrokes (or more) to enter in, for example, the Windows XP Japanese IME. The screen representation simply morphs as you type.

If you have dealt with the problem before and would like to share the secret, drop me a line.


My new project is in C++. "My sympathies" was what both my old Java colleagues and my new C++ ones tell me.

Hallway conversations that I overhear reveal that C++ people works on all sorts of weird platforms. And I thought Java was supposed to be cross-platform. Apparently it's any platform as long as it is Windows, Solaris, or Linux. OK, OK, and the Mac OS X (on your 17" PowerBook).


And talking about Java and platforms. Yuhang Sun told me something that I think I agree to some extent: "If you are building a GUI application for Windows, use C#. It's so much easier than Java/Swing. Reserve Java/Swing for truly cross-platform applications."


Rob Martin convinced me to use jEdit which he learned from Mario Aquino. What sold me is its hypersearch feature. You have to see it in person to experience it.


"To see it in person to experience it" also summarizes a lot of the XP/Agile/TDD practices. Pair programming and test driven development are two things that a lot of people (especially decision maker types) don't "get". When I said "I highly recommend the XP practices, especially pair programming" on my going away meeting, my team lead went "Huh?"


Talking about XP, I learned the true meaning of "Doing the simplest thing" from Jeff Grigg at last month's JUG meeting. We were talking about the "simplest thing possible" doctrine and how some people uses it as an excuse to do the dumbest thing and leave it that way.

Jeff said that the simplest thing is one part of the story. Before that you must have a set of automated test. The simplest thing refers to the simplest thing that'll make the test pass. And after that, you are supposed to "refactor relentlessly" to better the design of the code.

Without the thing that comes before it and after it, doing the simplest thing possible alone will only lead to chaos.

Class Data Sharing in JDK 1.5.0

Just noticed a new feature in the JDK 1.5.0 Beta2 called Class Data Sharing.

Certain system classes from the rt.jar are loaded and then memory dumped into a shared archive file /opt/jdk1.5.0/jre/lib/i386/client/classes.jsa, either during installation or by running java -Xshare:dump.

On my system, this file is 12591104 bytes long.

Subsequent invocations of Java programs will merely map this file into memory, saving the time to load the classes. Moreover, between five to six megabytes of the shared archive (metadata for the classes in the shared archive) will be mapped read-only and shared by all JVM instances.

The net result is faster startup time for small Java programs such as BeanShell scripts. Here's some benchmarks while running a trivial class with an empty CLASSPATH:

[weiqi@gao] $ cat Foo.java
public class Foo {
  public static void main(String[] args) throws Exception {
    Thread.sleep(1000);
  }
}
[weiqi@gao] $ . switch-to-1.5.0
[weiqi@gao] $ time java Foo

real    0m1.101s
user    0m0.051s
sys     0m0.017s
[weiqi@gao] $ time java -Xshare:off Foo

real    0m1.144s
user    0m0.103s
sys     0m0.023s
[weiqi@gao] $ . switch-to-1.4.2
[weiqi@gao] $ time java Foo

real    0m1.131s
user    0m0.082s
sys     0m0.017s

Discounting the 1 second sleep, startup time in 1.5.0 Beta2 is 23% faster than in 1.4.2_04, and 30% faster than in 1.5.0 Beta2 with class data sharing turned off.

Ever since I started using Java, I have expressed the opinion that it is foolish to load and jit Java classes like java.lang.Object and java.lang.String on every invocation of any Java program, day after day, month after month, year after year.

I'm glad to see class data sharing coming to the JDK.

Bigger Yahoo Mailbox Will Be Wasted

I've been using the free Yahoo mail since 1998, with a 6MB mailbox. And a month into using it, I was at 99% of my limit.

Deleting just enough old emails to free up a little space has been a constant chore that I do once a week. Since I can delete only a screenful (25, the default screen size) of my emails in one click, I would stop as soon as the percentage drops down to below 90% or the size drops to below 5MB, whichever caught my eyes first.

Starting last week or thereabouts, I've noticed that Yahoo Mail has increased my mailbox size to 100MB. And instead of running at 95% capacity, I'm running at 6%. Now a week later, I'm at 7%.

If past experience is any indication, my mailbox will grow 1% every couple of days until it finally reaches 100% in three to six months. At which time I'll be frantically deleting old emails, 25 at a time, till it drops to 99% or my wrist is sore, whichever happens sooner.

I'll be using the old Yahoo Mail the same old way. Except that now I will have 99MBs instead of 5MBs of old emails wasting Yahoo Mails disk space.

Very comforting, isn't it?

Know Your Origin

Ted Leung: ... During the talk, I was reminded (again) of Java's great intellectual debt to Lisp. The Future construct which is part of util.concurrent and now java.util.concurrent was originally invented in Multilisp around 1985.

I'm a firm believer of the software art as a science, out of which comes my tendency to pay attention to attributions, historical notes, and the evolution of ideas.

The commercial software world is especially guilty of hiding the origins of ideas. Do you know

  • what inspired the EJB container concept?
  • what inspired the AOP concepts?
  • what inspired the .NET framework design?
  • who first uttered the Inversion of Control Principle (Hollywood Principle)?
  • what are all the Web Services specifications cheap knock-offs of?
  • what does the original Model-View-Controller look like?
  • who wrote the first C++ compiler in GCC?
  • who designed Microsoft's COM?

Mono 1.0 Beta 2 Comes To Fedora Core 2

I reported the first beta release of Mono 1.0 40 days ago. Since then I have been eagerly awaiting the second beta due on June 1.

Beta 2 was released on time on June 1. However the yum repository for Fedora Core 2 was not ready until yesterday.

So if you are a Fedora Core 2 user, you can add the following lines to your /etc/yum.conf:

[mono]
name=Mono
baseurl=http://www.go-mono.com/archive/yum-repository/fedora-2-i386/

and then run yum install mono-complete to obtain the whole thing.

This beta included the MonoDevelop IDE, which is quite nice. It supports projects, manages classes, provides code completion hints. It does not support code reformatting, import management, and the mono debugger yet. But it will get there if enough people use it.

Another piece of software that's included in Mono is IKVM, a Java virtual machine that runs on top of .NET and Mono. It allows one to write Mono programs in the Java language. It can also compile Java classes and jar files into .NET assemblies for use by C#. See Miguel de Icaza's article Java, Gtk and Mono for details.

Your Build Script Is In Production Use Everyday---By Your Developers!

Yesterday was my last day at my current client (that I started 163 days ago).

As I reflect back I couldn't help but notice something odd: each developer uses a different set of Ant targets in their daily routine. The fun begins when something goes wrong:

Berlin, I just did an ant update, and the server wouldn't start now. Do you know why?

Sorry, I never do ant update. I always do ant get_all. Ask Ninju.

Ninju, Ninju, Help!

Oh, you are in the Build directory. You should be running from the dev directory. Just do an ant from there.

But wouldn't that take, what, like two hours?

You can run ant quick_compile then. That'll skip the part that takes too long.

Thank you!

(Later) Zhicheng, Ninju told me to do an ant quick_compile from dev, but it still doesn't work!

No, ant quick_compile deletes a directory that you need. Do an ant gen to get it back.

OK. (Ran ant gen.) No, it still doesn't work. Hey Cathy, do you know anything about this?

They send out an email yesterday about the latest changes to the build scripts. There is a batch file that you need to run only once.

Could you forward me that email?

Sure.

(Reading email) Ahh, I need to go to dev/config/versioning and run version_gen.bat. That fixed it. Thanks everybody.

We wouldn't dream of inflicting such pain and confusion on the users of the software we are building. Yet we do it to ourselves. We are users too. We are users of the build scripts for the project we work on. If the build script is not right, we all lose productivity.

The build script is in production use everyday. Treat it accordingly.

JDK 1.5 Beta 2, Jython 2.1, ClassFormatError, ...

I've seen this with both JDK 1.5 beta 1 and beta 2 now. And I don't know how to get around it. :(

[weiqi@gao]$ java -version
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)

[weiqi@gao]$ jython
Exception in thread "main" java.lang.ClassFormatError: Duplicated LocalVariableTable
attribute entry for 'itmp' in class file org/python/core/PyObject
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:605)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:290)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:279)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:236)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:303)

Help!

Tags :

It's Link To That Blog Day

Everybody is linking to the "A fresh look at the waterfall" blog entry today. Enjoy!

Free XML Spy Home Edition License

Here. The title says it all.

Of course, this being a blog, I'm obliged to enumerate all the intermediate steps that led me to the link:

Backups, Rebuilds, Upgrades, ...

I've done more than my fair share of rebuilding PCs lately. And here's what I learned:

  • Always have usable backups of all systems.
  • Keep a record of software installations, including how your mod_jk is compiled and installed.
  • Rebuilding boxes is easy, restoring all custom software, preferences, and user data is hard.
  • Fedora Core, and Red Hat Linux before it, is far easier to install then Windows NT/2000/XP. Rebooting after install wastes more time than you think.
  • "My Documents" does not contain Outlook emails.
  • Backup data and then reinstall immediately. Don't check POP3 emails after the backup and before the reinstall.
  • Backing up to CD is the way to go.
  • Backing up by ftping a tar file to another box is confusing.
  • Backing up to a partition that you "promise not to delete" during the install is asking for trouble.