+ if (h != null && h instanceof ClassMark) {
+ String clazz = ReflectiveWalker.mangle(((ClassMark)h).clazz);
+ Class c2 = (c!=null && c.getName().endsWith("$"+clazz)) ? c : Reflection.forNameOrNull(baseClass.getName()+"$"+clazz);
+ if (c2!=null) return buildBody(t, c2);
+ for(Method m : baseClass.getMethods()) {
+ if (!m.getName().equals(clazz)) continue;
+ Object[] o = new Object[m.getParameterTypes().length];
+ for(int i=0; i<o.length; i++)
+ o[i] = i>=t.numChildren() ? null : buildHead(t.child(i), m.getParameterTypes()[i]);
+ return m.invoke(null, o);
+ }
+ throw new RuntimeException("couldn't figure out what to invoke for ClassMark " + clazz);
+ } else if (h==arrayMark && c==null) {
+ c = Object[].class;
+ }
+ if (c==null) System.out.println(h + " -- " + t.toPrettyString());