W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2009

[whatwg] HTMLCollection and HTMLAllCollection issue in HTML5 spec in respect to Java biding

From: Shiki Okasaka <shiki@google.com>
Date: Tue, 24 Nov 2009 15:22:27 +0900
Message-ID: <2fdcc83a0911232222v3ab92f87u699179513c6d41f2@mail.gmail.com>
It appears WHATWG revision r4323 [0] for HTMLCollection and
HTMLAllCollection causes a compile time error in Java.

The Java interfaces for HTMLCollection and HTMLAllCollection would
look like below following the Web IDL Java binding:

public interface HTMLCollection {
?public int getLength();
?public Element item(int index);
?public Element namedItem(String name);

public interface HTMLAllCollection extends HTMLCollection {
?// inherits length and item()
?public Object namedItem(String name); // overrides inherited namedItem()
?public HTMLAllCollection tags(String tagName);

In Jave, however, this type of overriding is not allowed [1], and this
might be why these two interfaces were defined without using
inheritance before.

A possible solution for this is, as suggested by Maciej [2], revising
the IDL definitions like below:

interface HTMLCollection {
?readonly attribute unsigned long length;
?caller getter object item(in unsigned long index); ?// Element -> object
?caller getter object namedItem(in DOMString name); ?// Element -> object

public interface HTMLAllCollection extends HTMLCollection {
?// inherits length, item() and namedItem() ? ?// remove namedItem()
?public HTMLAllCollection tags(String tagName);

[0] http://html5.org/tools/web-apps-tracker?from=4322&to=4323
[1] http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.8
[2] http://www.w3.org/Bugs/Public/show_bug.cgi?id=8035


?- Shiki Okasaka
Received on Monday, 23 November 2009 22:22:27 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:19 UTC