[kaffe] KeyEvent -> JDK 1.4 patch (And longer explanation;)

Jukka Santala jsantala@morphine.tml.hut.fi
Mon, 30 Sep 2002 15:42:40 +0300 (EEST)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

---559023410-758783491-1033389760=:13821
Content-Type: TEXT/PLAIN; charset=US-ASCII

This patch updates java.awt.event.KeyEvent to "sorta" JDK 1.4 spec. This
mostly involves a bunch of new key type defines, and is neccessary because
Swing for some reason now thinks Kaffe is Java2 compatible and so tries to
use them with Kaffe. This implementation has been checked with reflection
etc. to match Sun JDK 1.4.0 and IBM Java 1.3.0.

JDK 1.4 adds "Key locations". This class provides code for supporting
them, but since the Kaffe input layer core doesn't presently support them
at least directly, the patch has related functionality quoted out and
returns KEY_LOCATION_UNKNOWN for all events. This saves one int per
KeyEvent instance, which might be significant somewhere.

Speaking of space savings, this patch adds a non-trivial amount of static
key-defines, as well as code for getKeyText() and complexity for
isActionKey(). I submit that this would be a potential case for weighting
the advantages and costs involved in trying to support a JDK specific
class-lib build system. I think embedded use is still oen important
consideration for Kaffe, and Java2's code-bloat doesn't really help with
it. Unfortunately for decisions inside classes this would seem to mean
some kind of preprocessor with directives.

Another thought while doing the class checkup, I noticed that the
constructor functions do almost exactly same thing, but each one has been
separately typed in there. This is ofcourse good for performance, since
KeyEvent constructors will be called for all key-presses etc. and this
avoids one level of nested calls compared to each constructor making call
to "meta-constructor" with fixed attributes. Incidentally though, this is
use of the same pattern as I've suggested for HashMap.find(), which
several magnitudes more often used than KeyEven constructors. Hopefully
there will be some sort of common guidleine (not neccessarily a "rule") on
the use of code-duplication for performance-critical code-paths to avoid
nested calls.

Speaking of performance tunings, this patch uses a touch unconventional
code for isActionKey(). Optimizers that can optimize for expected keyboard
input are still far, far in the future, so I hope nobody objects on "Let's
optimize this in the VM for all code" to this :) Ofcourse, even so it's
just a guess on the frequency of letters checked, and my main incencitive
was to make the checks as compact as possible. They may be harder to read
than a straight list of which keys/events to consider actions, but I've
verified the results match Sun/IBM JDK's, so it doesn't particularily
matter. It's still at least as easy to figure out whether a specific key
is action or not even from the code.


For future work: With j2sdk1.4.0:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalArgumentException: null source
        at java.util.EventObject.<init>(EventObject.java:34)
        at java.awt.AWTEvent.<init>(AWTEvent.java:225)
        at java.awt.event.ComponentEvent.<init>(ComponentEvent.java:94)
        at java.awt.event.InputEvent.<init>(InputEvent.java:179)
        at java.awt.event.KeyEvent.<init>(KeyEvent.java:858)
        at java.awt.event.KeyEvent.<init>(KeyEvent.java:914)
        at java.awt.event.KeyEvent.<init>(KeyEvent.java:923)

Adding this exception to Kaffe should be easy, but I didn't bother
clumping it together with this patch. Another thing is actually
integrating the JDK 1.4 key-location system to Kaffe core. I didn't check
that all key-modifiers work the same, but I assume the old implementation
had it right. CHAR_UNDEFINED has different value from JDK's, but I didn't
change this, as it'd require checking with input code, and it'll work as
long as people use the defined constants as intended. I have not had an
opportunity to check that the keys like VK_F20 or VK_CUT actually work
yet, this class just guarantess they're defined and Kaffe doesn't bowl
over because of that.

And I'll be unlikely to do that work, because this patch is enough to get
our software work with Kaffe ;) (Actually, it's fairly lot more than just
what's needed, since I wanted to make sure all the constants were there
and consistent).

 -Jukka Santala

---559023410-758783491-1033389760=:13821
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="kaffe-donwulff-keyevent.patch"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.GSO.4.44.0209301542400.13821@morphine.tml.hut.fi>
Content-Description: 
Content-Disposition: attachment; filename="kaffe-donwulff-keyevent.patch"

SW5kZXg6IGxpYnJhcmllcy9qYXZhbGliL2phdmEvYXd0L2V2ZW50L0tleUV2
ZW50LmphdmENCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NClJDUyBmaWxlOiAv
Y3ZzL2thZmZlL2thZ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