One question: I see a change to how enums are created in
GenerateJavaAST.  What's going on there?  I see code being deleted but
no associated add.

Otherwise, LVGTM.  I've been wanting this type hierarchy for a while
just for logical cleanliness.  I hadn't thought about the memory and
speed implications, but those are excellent as well.

Comments:

JReferenceType has a commented-out getMethods() in the version I looked at.

Logically, a little bit more could go down into JDeclaredType. They seem
like good todos to mark, because ideally these questions wouldn't be asked
on a general reference type.  This issue becomes more important the more
we expand the JReferenceType hierarchy.

  - superclass: arrays and null don't really have a superclass, so it's
  tricky to ask for it.  Allowin callers to do so seems like an
invitation for bugs,
  e.g. asking for the superclass of String[] when what was intended was asking
  for the superclass of String.

  - hasClinit: this question is only asked for field references, and a
  field always has a real enclosing class.  The one exception I can
  think of the "length" field of an array; if that's the issue, maybe we should
  think about encoding array.length a different way, anyway.


Methods like removeMethod(int) are an improvement over directly accessing the
list, but it looks fragile to me due to how careful the code has to be
with the index
passed into it.  It would be a little simpler and safer to have a
method like removeAllMethodsSuchThat(Predicate<JMethod>).  For
example, instead of this:

     for (int i = 1; i < type.getMethods().size(); ++i) {
       JMethod method = type.getMethods().get(i);
         // all other interface methods are instance and abstract
         if (!isInstantiated || !methodIsReferenced(method)) {
         type.removeMethod(i);
           didChange = true;
         --i;
         }
       }

we could write this:

  didChange |= type.removeAllMethodsSuchThat(new Predicate<JMethod>() {
    public boolean apply(JMethod method) {
      // all other interface methods are instance and abstract
      return !isInstantiated || !methodIsReferenced(method);
    }
  }


Just a thought.  Sometimes this idiom can push out just a little
further the complexity threshold where brains start melting.

Lex

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to