Force GWT compiler to stop pruning invalid CompilationUnits

给你一囗甜甜゛ 提交于 2019-12-01 22:14:15

问题


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.

来源:https://stackoverflow.com/questions/10836760/force-gwt-compiler-to-stop-pruning-invalid-compilationunits

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!