On Tuesday, May 23, 2017 at 9:36:45 PM UTC-4, John A. Tamplin wrote: > > Why is that so? Can't you do your own whole-world analysis pass > independently of the compiler if that is what you want to do? It does not > seem possible to have whole-world analysis in the compiler (hooks or not) > if the goal is to enable separate compilation at the Java layer. So, if > that is important to you, it must necessarily be outside the compiler. >
Well, think a little bit more about it yourself. Yes, I *can* do the analysis. I don't even need the source code for it, in fact. But what then? Code needs to be generated to perform (de)serialization as there is no reflection in the GWT client side. Fine. I could do that too but there are non-public fields without accessor methods (and, these are perfectly valid cases, and in fact, a good pattern). So how/where do you generate code that can both get/read and set non-public fields of any class? There are following ways about this: 1. Use reflection. But reflection is not available in the GWT client-side. 2. Generate code / synthetic methods within the classes they (de)serialize. But J2CL does not offer that. 3. Re-generate ALL code so that the new copy is a superset of the original - it includes both the original and new synthetic methods. Essentially a Java-to-Java compiler. But this would be much slower because it has to regenerate code in a file system somewhere so that J2CL has all of it, including those from imported libraries. Debugging also becomes interesting. You can't just generate new code to be equivalent functionally - you need to actually maintain exact formatting as it was before and add stuff at the end to avoid shifting line numbers. If you have nested classes this becomes impossible. 4. Like (2) but generating CL / JavaScript code instead and, thus, not having the issues of (3) and even being able to bypass Java visibility rules. As J2CL evolves and possibly changes how it translates Java to JavaScript this would have to evolve equivalently too. So (1) is not possible, (3) is not feasible or possible / practical and (2) or (4) are both OK but require hooks in J2CL to integrate with the process. See https://github.com/konsoletyper/teavm/wiki/Metaprogramming for such a hook in TeaVM. TeaVM does *not* have RPC like GWT does but it makes it possible for it to be implemented externally via this API. -- You received this message because you are subscribed to the Google Groups "GWT Contributors" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/ecb1909a-8789-4da5-812f-f1d27a00ddc2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
