Need a little help with find_as_inner_class

Mo DeJong
Sun May 6 23:11:00 GMT 2001


I finally got off my duff and decided to try to get
Jacl working with the 3.0 branch. There seems to
be at least 1 bug left, so the source code still
does not compile with gcj.

The most simple test case for this problem is:

class ArrayBug {
    class Inner {}

class ArrayBugTest {
    ArrayBug.Inner not_array; // This works
    ArrayBug.Inner[] array;   // gcj pukes on this !

This code compiles just fine with javac and jikes,
gcj pukes with the following error: Type `ArrayBug.Inner' not found in declaration of field 
       ArrayBug.Inner[] array;   // gcj pukes on this !
1 error

The resolve_class() function gets called with the class names
"ArrayBug.Inner" and then "[ArrayBug.Inner". It works just fine
for the non array case but blows up on the array of inner
class type lookup. I poked around in the debugger a bit.
I think the problem is in the find_as_inner_class method.

Here is the code in question with some bits removed:

static tree
find_as_inner_class (enclosing, name, cl)
     tree enclosing, name, cl;

  /* First search: within the scope of `enclosing', search for name */
  if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
  else if (cl)


  /* We're dealing with a qualified name. Try to resolve thing until
     we get something that is an enclosing class. */
  if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
      tree acc = NULL_TREE, decl = NULL_TREE, ptr;

      for (qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl; 
	   qual = TREE_CHAIN (qual))

      /* A NULL qual and a decl means that the search ended
         successfully?!? We have to do something then. FIXME */
      if (decl)
	enclosing = decl;

When "ArrayBug.Inner" is looked up the first call to
EXPR_WFL_QUALIFICATION() returns a valid pointer.
Then the for loop below calls EXPR_WFL_QUALIFICATION ()
again, it returns a valid pointer, the for loop
runs once and then the if (decl) block sets the
enclosing pointer.

In the case of "[ArrayBug.Inner" the first call to
EXPR_WFL_QUALIFICATION() returns NULL, in the for
loop EXPR_WFL_QUALIFICATION() is called again and
again return NULL. The for loop body never runs
and the else block of the if (decl) code below
is run.

I am not sure if that FIXME note is talking about
this specific case. I guess what I am looking for
is some more information about what is going on
in this method and what of some of these macros
are meant to be doing.

Mo DeJong
Red Hat Inc

More information about the Java mailing list