yugalatea / gwt-google-apis

Automatically exported from code.google.com/p/gwt-google-apis
0 stars 0 forks source link

NPE in Google Gadget Linker when compiling non gadget module in same project #221

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Found in Release:
gwt-gadgets-1.0.1 (gwt 1.5.3)

Detailed description:
This is what I did:
- added a gadget module to an existing gwt project with a normal gwt module
- inherit com.google.gwt.gadgets.Gadgets in both modules (the non gadget
module also needs this, otherwise the compiler fails)
When compiling the non gadget module I get the NPE below. It is somehow
invoking the Gadget linker, but I would think this is not necessary for the
non gadget module.

Exception that is thrown:
     [exec]    Invoking Linker Google Gadget
     [exec]       [ERROR] Failed to link
     [exec] java.lang.NullPointerException
     [exec]     at
com.google.gwt.gadgets.linker.GadgetLinker.emitSelectionScript(GadgetLinker.java
:71)
     [exec]     at
com.google.gwt.core.ext.linker.impl.SelectionScriptLinker.link(SelectionScriptLi
nker.java:98)
     [exec]     at
com.google.gwt.gadgets.linker.GadgetLinker.link(GadgetLinker.java:55)
     [exec]     at
com.google.gwt.core.ext.linker.impl.StandardLinkerContext.invokeLinkerStack(Stan
dardLinkerContext.java:407)
     [exec]     at
com.google.gwt.core.ext.linker.impl.StandardLinkerContext.link(StandardLinkerCon
text.java:269)
     [exec]     at com.google.gwt.dev.GWTCompiler.distill(GWTCompiler.java:367)
     [exec]     at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:564)
     [exec]     at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:554)
     [exec]     at com.google.gwt.dev.GWTCompiler.main(GWTCompiler.java:214)

Original issue reported on code.google.com by rintc...@gmail.com on 5 Dec 2008 at 6:03

GoogleCodeExporter commented 9 years ago
The NPE needs to be fixed, but running the linker in your non-gadgets module is 
to be
expected.  Inheriting the "Gadgets" module in your normal entry point causes the
gadget linker to be invoked (there's an <add-linker> line in that module)

Original comment by galgwt.reviews@gmail.com on 7 Dec 2008 at 9:49

GoogleCodeExporter commented 9 years ago
But, from a conceptual viewpoint, is it correct to have the gadget linker added
unconditionally as soon as the gadgets module is inherited? I mean it looks
unnecessary to me to invoke the gadget linker in some cases (like the case that 
the
NPE occurs). I would think that a better decision point whether the gadget 
linker
should be invoked or not would be based on whether the entrypoint extends the 
Gadget
class or not (again conceptually; don't know about the technical feasibility)

Original comment by rintc...@gmail.com on 8 Dec 2008 at 2:18

GoogleCodeExporter commented 9 years ago
When you compile a GWT module, there is only one linker used to generate your 
output
classes.  If you want 2 different outputs, then you'll have to compile two 
different
modules.

An EntryPoint class just a class that gets invoked when the module is loaded. 
There
can be many of them in a module.  The Gadget class and Gadget linker is invoked 
to
create output files that are suitable for uploading as a gadgets.  When you 
inherit
the Gadget module, the assumption is made that you are are compiling a gadget.  
The
Gadget class is completely useless otherwise. 

Original comment by galgwt.reviews@gmail.com on 8 Dec 2008 at 2:47

GoogleCodeExporter commented 9 years ago
Ok, that's clear, apart from the sentence "When you inherit the Gadget module, 
the
assumption is made that you are are compiling a gadget". I assumed that fixing 
the
NPE would automatically support my use case (which I think is the simplest 
solution
when several linkers need to be invoked), but that sentence makes me doubt about
this. In my project setup I am forced to inherit the Gadget module also from my
non-gadget module, otherwise the compiler fails (both modules share the same 
source
roots). 

After this bug is fixed, can I keep this project setup or do I need to change 
it?

Original comment by rintc...@gmail.com on 8 Dec 2008 at 3:30

GoogleCodeExporter commented 9 years ago
Unfortunately, currently you cannot keep this setup, because the GWT compiler 
can
only invoke one linker.  You could move your Gadget specific code to a separate
source path, and then add the gadget specific sources into a second module 
using a
<source> tag in your module gwt.xml.  Then, you could compile 2 different 
modules,
with the second inheriting the "Gadgets" module and overriding the standard 
linker
with the gadgets linker.

Original comment by galgwt.reviews@gmail.com on 8 Dec 2008 at 4:02

GoogleCodeExporter commented 9 years ago
Oh, that's a pity. But thanks for your explanation.

Original comment by rintc...@gmail.com on 9 Dec 2008 at 8:24

GoogleCodeExporter commented 9 years ago
http://galgwt-reviews.appspot.com/1220/show

Original comment by galgwt.reviews@gmail.com on 11 Dec 2008 at 8:01

GoogleCodeExporter commented 9 years ago

Original comment by galgwt.reviews@gmail.com on 11 Dec 2008 at 9:23

GoogleCodeExporter commented 9 years ago
Fixed in gwt-gadgets-1.0.2

Original comment by galgwt.reviews@gmail.com on 21 Feb 2009 at 1:33