Force GWT compiler to stop pruning invalid Compila

2019-02-24 23:32发布

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.

0条回答
登录 后发表回答