This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: invoke-static
- From: Per Bothner <per at bothner dot com>
- To: Chris Dean <Chris dot Dean at sokitomi dot com>
- Cc: Kawa List <kawa at sources dot redhat dot com>
- Date: Thu, 24 Apr 2003 16:13:46 -0700
- Subject: Re: invoke-static
- References: <14710.1051221160@mercedsystems.com>
Chris Dean wrote:
Say we have a file with an invoke-static expression:
(invoke-static <MyClass> 'staticMethod)
When we compile this file, the static block in MyClass is executed.
I *really* don't want it to do that. Any ideas for a workaround? There
is come code below to demonstrate this.
This is probably because Class.forName is called, and forName
by default initializes the class. In Java 2 there is a forName
version that takes an explicit 'initialize' parameter, which
we could set to false.
But that gets us into the issue of Kawa requiring Java 2.
Last time we discussed this, the concern was that there are
some platforms (such as Mac classic, I believe) that have
JDK 1.1, but not JDK 1.2 or anything similar.
My solution has been to "pre-process" the Java files, but
that is an ugly and heavy-duty solution. It would be
less confusing to use real .java files. On the other hand,
I'm unhappy to cut off the JDK 1.1 users, few though they are.
Perhaps a better model is that the actual source file are
the .java files that may depend on Java 2 features, but
I provide a patch file to remove Java 2 dependencies.
The "mainline" would be the intersection of JDK 1.4.1,
GCJ 3.3, and possibly Kaffe; if you're using a Java
implementation that does not have these features, you'd
have to run the patch file first.
Comments?
--
--Per Bothner
per at bothner dot com http://per.bothner.com/