Can You Spot The Duplications?
<foo> <bar>baz</bar> </foo>
Now the quiz:
- Is this a good thing?
- Why was it allowed in the first place?
- Are the reasons still valid today?
Details at 11:00.
Line (and Column) Precise Error Messages: Priceless
Eric Burke: The line (and column) precise error message is PRICELESS. How many hours would this have taken without that perfect error message? No telling, but I'm sure this little gem just saved me a great deal of time.
I am truly looking forward to learning more about Tapestry.
Rob Smith will talk about Tapestry at the December meeting of St. Luois Java Users Group.
Swing, Focus Events, Fun, ...
I received confirmation from Sun for Bug ID: 6180261 nine days ago.
I had a lot of fun distilling this test case from a full blown application back in January (unlike my manager, who had a cardiac event over this (and other bugs).)
If you are a Swing, FocusManager, EventQueue kind of guy, give the test case a spin. You won't be disappointed.
ADV: Positions Available
I just want to pass on some information about several available positions at Object Computing, Inc. and Advantage Consulting, Inc.
Please contact Jane Bullington at 314-590-0205 for more information.
Java Developers, OO Software Engineers, Architects and a Tech Lead needed
All positions require an experienced OOAD Developer with a well rounded Java background. We have an excellent long-term opportunity for a Technical Lead/Architect, and several for Developers.
Requirements are for web developers using Java/J2EE/HTML/ JavaScript/JDBC/JSP/SQL. It is helpful to have Oracle, Struts/XML/WSAD/WebLogic SiteMinder.
Tech Lead must have MS Project, Developers do not. All must have excellent communication skills and it is helpful to have the Unified Process methodology, Use Case and Sequence Diagramming experience.
Other openings exist for Java Developers with expertise in Java/JSP/HTML/Struts/MVC/JavaScript.
One position requires a good working knowledge of Swing. Ant, JUnit and Web based application/Windows/UNIX development experience, UML is very helpful.
Must have a Bachelor's Degree, some positions require U.S. Citizenship and the ability to obtain a Security Clearance. Current Security Clearance helpful.
Google Desktop: Index File Format
Is the Google Desktop index file format available somewhere?
Will they make it an open standard?
Do we care?
Google Desktop: Conspiracy Against Organized People
I have installed Google Desktop for four days now. The initial excitement has died down a little. The reality has started to set in: The thing is not going to work for me!
Why? Because I am organized. I have a meticulously crafted directory hierarchy based on the same principles that big research libraries use to organize their books. I have a habit of maintaining my files: putting them where they belong, deleting no longer needed files, archiving old files away, etc.
As a result, when I search for a word, say 'generics', most of the results are in my src/java/generics, src/c#/generics, doc/java/generics, and doc/c#/generics folders, all under my home directory. Of course, there are a few odd ball matches in other folders, e.g., temp/junk, but generally those are not what I want.
To really benefit from Google Desktop big time, you have to be really really disorganized: saving all your files in My Documents or the bin directory of the editor, saving all your email in Inbox, etc.
I've known a few people like that. They usually need help installing things themselves.
Google Desktop will be perfect for them, just as soon as I help them delete some old files, uninstall some old programs (including all of JDK 1.1.6, 1.2.1_05, 1.2.2, 1.3, 1.4.2_04, etc.) to make room for the Google Desktop index.
And I won't! :)
"Bash Here"
This happens to me many times: I was in Windows Explorer deep down in a folder structure, saw a file, and realized that I wanted to run a command line tool on that file.
What I have done in the past is to go to a command shell, and issue a series cd commands to get to the target directory and run the command line tool.
Not any more, thanks to chere ("Command prompt Here"), a newly arrived Cygwin utility. Running
[weiqi@gao] $ chere -i
installs a context menu "Bash Here" for folders in Windows Explorer. It opens a bash shell at the right directory.
Likewise, running
[weiqi@gao] $ chere -i -s cmd
installs a context menu "Command Prompt Here" that opens the CMD.EXE prompt.
[weiqi@gao] $ chere -u -s bash [weiqi@gao] $ chere -u -s cmd
uninstalls the context menus.
How Big Is Your Google Desktop Index?
Before:
[weiqi@gao] $ df c: Filesystem 1k-blocks Used Available Use% Mounted on c: 13109008 11566560 1542448 89% /cygdrive/c
After:
[weiqi@gao] $ df c: Filesystem 1k-blocks Used Available Use% Mounted on c: 13109008 11801940 1307068 91% /cygdrive/c
My index is only 2%:
[weiqi@gao] $ bc -l size_before = 11566560 size_after = 11801940 size_index = size_after - size_before 235380 size_index/size_before .02035004357388886583
Hmm, I thought I should have a Bigger OneTM.
Google Desktop: Hypeless Innovation
Google is a curious company. First their internet search engine took off like wild fire. Yet I don't remember seeing any Google ads. In fact I don't even remember thinking "How odd, nobody's seen any Google ads" until it was pointed out by Paul Graham's article What the Bubble Got Right.
Then during the past 24 hours, I was bombarded with praises of Google Desktop:
Eric Burke: Google Desktop kicks ass.
Cedric Beust: Google Desktop Search radically changed the way I search on my computer. Check it out!
Kevin Heifner: Way cool!
It just happened. There were no preannouncements a year ago. We don't know what the codename for the project was while they were working on it. I didn't hear them talking about metadata, indexing techniques.
Now, here's my question:
At The JUG
The presentation at the St. Louis Java Users Group last night was, as usual, approachable, lively and entertaining. The topic was J2ME. The presenter was Jeff Heaton. The audience downloaded and installed MIDLets onto their J2ME enabled cell phones.
Some highlights (from off-line chats and from Q&A during the presentation):
- Will downloading a MIDLet to your cell phone void your worranty? No.
- The economy is really coming back. Java hiring is very strong in this area!
- We rolled out our EJB application. We are very happy. WebLogic just works!
- If you are writing the a Windows device, use the .NET Compact Framework. It that much easier.
- Then what is J2ME good for? The one billion J2ME enabled cell phones. Write J2ME games and sell them for $5 a piece.
- One problem with REST is that I have to write a framework myself.
- If C++ templates is this (stretching arms out), Java generics is this (between thumb and index finger).
PS: Some of the above opinions belong to Kyle Cordes, who wants to get blogged. :)
No Style
I just discovered another useful Firefox feature: the
View->Page Style->No Style
menu item. It turns off CSS styling for the current window/tab. It is useful for web pages that are otherwise hard to read (fonts to small, color to light, etc.)
This is not as powerful as the EditCSS extension that I used in Mozilla, but all I use EditCSS for is turning off CSS. So this menu item is quite sufficient for my needs.
Thank you, Firefox team.
It Is Generic After All
Bruce Eckel, March 10, 2004: Generics Aren't
Bruce Eckel, October 8, 2004: ... Using adapters like this would seem to compensate for the lack of latent typing, and thus allow you to write genuinely generic code.
From it's announcement in June 1998, to the final induction into Java 5.0 in August 2004, Java generics has gone through over six years of maturation.
Originally hailed as an efficient and backward compatible extension to the JDK rooted in some esoteric theory, Java generics, especially its erasure based implementation has been under much criticism lately (including on this blog).
One of the complaints leveled against Java generics is that it is not generic:
public class CallF {
public <T> void callF(T t) {
t.f(); // can't call f() here
}
}
In his latest weblog, Bruce Eckel offers several ways around the problem by using adapters. One of them, termed surprising by Bruce, uses an abstract generic adapter instantiated and anonymously extended at the call site.
Here's a distilled version of the example:
[weiqi@gao] $ cat A.java
public class A {
public void f() {
System.out.println("A.f()");
}
}
[weiqi@gao] $ cat CallF.java
public class CallF {
public <T> void callF(HasF<T> adapter) {
adapter.f();
}
}
[weiqi@gao] $ cat HasF.java
public abstract class HasF<T> {
protected T t;
public HasF(T t) {
this.t = t;
}
public abstract void f();
}
[weiqi@gao] $ cat Main.java
public class Main {
public static void main(String[] args) {
A a = new A();
CallF f = new CallF();
f.callF(new HasF<A>(a) {
public void f() {
t.f(); // OK to call f() since t is of type A here
}
});
}
}
[weiqi@gao] $ javac *.java
[weiqi@gao] $ java Main
A.f()
Once understood, the code is quite clear.
The classes CallF and HasF is the library that just want to call a method named f(). No extra requirement is placed on T except that it has the f() method. This qualifies them as true generic algorithm classes.
The class A is a POJO that has an f() method.
In Main we manage to hook up the "library" and the POJO and have the "library", which knows nothing about the POJO, call a method on the POJO, which knows nothing about the "library", just like in C++. Great!
Looking back at the solution, I can't help but notice all the clutter. Suddenly the irony is apparent: We went all the way to add generics into Java, ostensibly to simplify our Java code, yet at the end our code is even more cluttered.
Could we have done the same thing without generics? Of course. This is the land of erasure. Decompiling the classes with JODE, I get:
[weiqi@gao] $ jode -d jode A CallF HasF Main
Jode (c) 1998-2001 Jochen Hoenicke <jochen@gnu.org>
A
CallF
HasF
Main
Decompiled 4 classes.
[weiqi@gao] $ cd jode/
[weiqi@gao] $ cat A.java CallF.java HasF.java Main.java
public class A
{
public void f() {
System.out.println("A.f()");
}
}
public class CallF
{
public void callF(HasF hasf) {
hasf.f();
}
}
public abstract class HasF
{
protected Object t;
public HasF(Object object) {
t = object;
}
public abstract void f();
}
public class Main
{
public static void main(String[] strings) {
A a = new A();
CallF callf = new CallF();
callf.callF(new HasF(a) {
public void f() {
((A) t).f();
}
});
}
}
[weiqi@gao] $ javac *.java
[weiqi@gao] $ java Main
A.f()
Comparing this with the generic classes, we discover that all of our generics mumbo-jumbo bought us exactly one puny little cast!.
Oh wait a minute, have I just written a genuinely generic algorithm in pre 5.0 Java without using generics?
Interesting!
Java News Brief (JNB): Spring MVC
In this month's installment of OCI's Java News Brief (JNB), Paul Jensen writes about Spring MVC. Get it while it's hot. Please also consider subscribing to JNB by joining the monthly email list. (There is a Join List button at the top right corner of the JNB archive page.)
Paul is also scheduled to talk about the Spring Framework at the November meeting (November 11) of the St. Louis JUG.
This month's JUG meeting (October 14, this coming Thursday) will feature Jeff Heaton. Jeff will talk about J2ME.
Wouldn't It Be Nice If Java Can ...
I promised to say more about the Nice programming language nine days ago.
Now I don't have to. Andrew Glover has just published a Nice article on the alt.lang.jre series at IBM DeveloperWorks.
Daniel Bonniot (author of Nice) has a recap in his weblog.
Rhino 1.6 R1
Jon Udell's recent weblog, Introduction to E4X, prompted my to take a look at the new release of Rhino.
1.6 R1 RC1, released ten days ago, includes support for ECMAScript for XML (E4X). Believe it or not, although this is the first time I heard about it, the thing is a new international standard for adding native XML support in JavaScript! The BEA geniuses donated the code to Rhino.
It add the following to the JavaScript language:
- A native XML type in JavaScript
- XML literals (to go with string literals and regular expression literals)
- A natural, minimalist XML/Object mapping
- A set of functions and operators for manipulating XML objects.
[weiqi@gao] $ rhino Rhino 1.6 release 1_pre_RC2 2004 09 24 js> var x = <foo attr1="value1">This is a <test/></foo> js> x.@attr1 value1 js> x.test="JOKE" JOKE js> x <foo attr1="value1"> This is a <test>JOKE</test> </foo>
It's nice to see programming languages start to take XML seriously to add direct XML literal support straight into the language.
Now we can have XHTML which may contain JavaScript which may contain XHTML which may contain JavaScript which may contain ...
We Have an Ant Task, ...
... all you have to do is to copy these lines into your build.xml file:
<taskdef name="ejbdoclet" classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="project.class.path" />
I have been dutifully doing this in every one of my build.xml files that needs the task. (Well, not only this one, but other tasks from other tools.) At first, it is novel and exciting, "Look, I just added a snippet of XML to build.xml, and it can do this!" But it's getting old now, especially on the one thousandth time: "What's the class name of that task? And which jar file is it in?" I've tried external entity references which only obscures the issue.
What I want is a way to tell my installation of Ant about any new Ant tasks that's avaiable in third party packages. Do it once. And have that task available to all Ant runs that use the installation, like any other task that come bundled with Ant.
There must be a way to do this that I missed.
