3

I have a project in PlayN that allows me to compile a single java codebase to every platform under the sun; I am building against gwt trunk, which presently allows GWT.create() to be called in pure java implementations. There are some hoops to jump through, namely calling ServerGwtBridge.getInstance().register(String.class, new ClassInstantiator() {...}); for every class to be used by GWT.create().

So, rather than manually code every binding, I setup some annotations on my classes, and made a generator that spits out the initialization code needed to register the ClassInstatiators. The generator runs fine on gwt modules, and I made a maven mojo to run the generator on my pure java classes as well. So, now all my modules, gwt, java and android can use GWT.create(), and I can support replace-with syntax from gwt.xml module files.

The trouble is that any classes which reference any gwt-unsupported classes or methods are pruned by the gwt precompiler. They are still present in the unit cache, but the generator's TypeOracle does not see them anymore. I do not want to copy-paste huge swathes of code to stop the compiler from removing the invalid units; I saw some code reference NameEnvironmentAnswer that seems to allow invalid units in the compile, but could not figure out how to make it work.

I have no intent of linking this code, I just want a populated TypeOracle for my generator to run, and that means I need the compiler to stop pruning invalid units.

Ajax
  • 2,465
  • 23
  • 20
  • Note; I do know that I could achieve a simple version of this generator with an annotation processor, but my intent is to create a generator mojo that obeys full gwt module replace-with syntax in pure java, so I can contribute it to gwt when it's ready. – Ajax May 31 '12 at 15:37

0 Answers0