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

Shiki Okasaka shiki at google.com
Mon Nov 23 22:22:27 PST 2009

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

More information about the whatwg mailing list