The code of constructor MyRequestFactoryDeobfuscatorBuilder() is exceeding the 65535 bytes limit

250 views
Skip to first unread message

Eric Andresen

unread,
Sep 20, 2011, 3:33:43 PM9/20/11
to google-we...@googlegroups.com
Are there any tricks or tips to reduce the size of the 2.4 RequestFactory's generated DeobfuscatorBuilder class?  My compiler is choking with the following error:

The code of constructor MyRequestFactoryDeobfuscatorBuilder() is exceeding the 65535 bytes limit

The generated file is a single constructor that is nearly 11,000 lines long and 780k in size.

I thought about splitting it up into multiple request factories, but then I don't know which one I would pass to the driver.initialize(RF, editor) call, especially if the editor hierarchy spanned multiple ones.  Is it possible to create multiple sub-factories that are then referenced from a top-level one?

Thanks,
Eric

Eric Andresen

unread,
Sep 20, 2011, 3:38:59 PM9/20/11
to google-we...@googlegroups.com
I should note that my RequestFactory references about 120 Request objects, each of which has between 5 and 20 methods.  Would inheriting the Requests off of a common base interface that defined the common methods work in the RF?  I'm not sure of the limitations of 2.4's RF inheritance.

Eric Andresen

unread,
Sep 20, 2011, 9:21:29 PM9/20/11
to google-we...@googlegroups.com
I was able to somewhat unblock my testing using a sleazy workaround:  I re-compiled requestfactory-apt with a different DeobfuscatorBuilder that generated the code as follows:

abstract class Command { public abstract void execute(); }
(new Command(){@Override public void execute() {withOperation(new OperationKey("vimcdMnFZ5TaRh_$0tcC1o6Q51Q="),
  new OperationData.Builder()
  .withClientMethodDescriptor("(Ljava/util/List;)Lcom/google/web/bindery/requestfactory/shared/Request;")
  .withDomainMethodDescriptor("(Ljava/util/List;)Ljava/lang/String;")
  .withMethodName("serialize")
  .withRequestContext("com.my.package.gwt.widget.table.shared.QueryRequest")
  .build());}}).execute();
(new Command(){@Override public void execute() {withOperation(new OperationKey("bVjCi3sjTk7$71BEQQyT5WdiNog="),
  new OperationData.Builder()
  .withClientMethodDescriptor("(Ljava/lang/String;)Lcom/google/web/bindery/requestfactory/shared/Request;")
  .withDomainMethodDescriptor("(Ljava/lang/String;)Ljava/util/List;")
  .withMethodName("deserialize")
  .withRequestContext("com.my.package.gwt.widget.table.shared.QueryRequest")
  .build());}}).execute();

Of course the side effect of this is now instead of generating one 65kb+ method, it is generating 1500+ anonymous inner classes, which I think is blowing my application heap.  

If anyone has any suggestions, please let me know.  I'll update tomorrow if I figure anything out.  

Thanks,
--Eric

Eric Andresen

unread,
Sep 21, 2011, 3:03:54 PM9/21/11
to google-we...@googlegroups.com
Well, I seem to be talking to myself here, but here's my fix in case anyone else runs into this problem in the future.  It's still a hack, but it compiles a lot better than 1500 inner classes.

I updated the DeobfuscatorBuilder.java in requestfactory-apt-2.4.0.jar with the following changes below (in red):

...
class DeobfuscatorBuilder extends ScannerBase<Void> {
  private TypeElement requestFactoryElement;
  private final StringBuilder sb = new StringBuilder();

  private static Integer index = 0;
  
 ...
        OperationKey key =
            new OperationKey(requestContextBinaryName, methodName, clientMethodDescriptor);
        println("private void genMethod_"+index+"(){withOperation(new OperationKey(\"%s\"),", key.get());
        println("  new OperationData.Builder()");
        println("  .withClientMethodDescriptor(\"%s\")", clientMethodDescriptor);
        println("  .withDomainMethodDescriptor(\"%s\")", domainMethodDescriptor);
        println("  .withMethodName(\"%s\")", methodName);
        println("  .withRequestContext(\"%s\")", requestContextBinaryName);
        println("  .build());}");
index++;
        return super.visitExecutable(x, state);
      }

...     

    println("// Automatically Generated -- DO NOT EDIT");
    println("// %s", state.elements.getBinaryName(x));
    println("package %s;", packageName);
    println("import %s;", Arrays.class.getCanonicalName());
    println("import %s;", OperationData.class.getCanonicalName());
    println("import %s;", OperationKey.class.getCanonicalName());
    println("public final class %s extends %s {", simpleName, Deobfuscator.Builder.class
        .getCanonicalName());
    scanAllInheritedMethods(x, state);
println("{");

for (int i = 0; i < index; i++)
{
println("genMethod_"+i+"();");
}
index = 0;
    writeTypeAndTokenMap(state);
    println("}}");

  ...

David Chandler

unread,
Sep 21, 2011, 3:19:48 PM9/21/11
to google-we...@googlegroups.com
Eric,

Please log this on the issue tracker and we'll look into it: http://code.google.com/p/google-web-toolkit/issues/list

Thanks,
/dmc

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/5taSPio9jZUJ.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
David Chandler
Developer Programs Engineer, GWT+GAE
w: http://code.google.com/

Eric Andresen

unread,
Sep 21, 2011, 3:30:47 PM9/21/11
to google-we...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages