steffimueller / google-gin

Automatically exported from code.google.com/p/google-gin
Apache License 2.0
0 stars 1 forks source link

NPE in BindingsProcessor.createImplicitBinding #119

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Using both trunk and 1.0, I'm getting following exception which doesn't provide 
much information on how to fix my bindings. This one is produced by trunk 
version of gin:

14:59:13.680 [ERROR] [client] Generator 
'com.google.gwt.inject.rebind.GinjectorGenerator' threw threw an exception 
while rebinding 'org.ires.gwt.client.gin.ClientGinjector'
java.lang.NullPointerException: null
    at com.google.gwt.inject.rebind.BindingsProcessor.createImplicitBinding(BindingsProcessor.java:491)
    at com.google.gwt.inject.rebind.BindingsProcessor.access$900(BindingsProcessor.java:98)
    at com.google.gwt.inject.rebind.BindingsProcessor$GuiceBindingVisitor.addImplicitBinding(BindingsProcessor.java:967)
    at com.google.gwt.inject.rebind.BindingsProcessor$GuiceBindingVisitor.visit(BindingsProcessor.java:957)
    at com.google.gwt.inject.rebind.BindingsProcessor$GuiceBindingVisitor.visit(BindingsProcessor.java:888)
    at com.google.inject.internal.UntargettedBindingImpl.acceptTargetVisitor(UntargettedBindingImpl.java:40)
    at com.google.gwt.inject.rebind.BindingsProcessor$GuiceElementVisitor.visit(BindingsProcessor.java:817)
    at com.google.gwt.inject.rebind.BindingsProcessor$GuiceElementVisitor.visit(BindingsProcessor.java:810)
    at com.google.inject.internal.BindingImpl.acceptVisitor(BindingImpl.java:92)
    at com.google.gwt.inject.rebind.BindingsProcessor.createBindingsForModules(BindingsProcessor.java:402)
    at com.google.gwt.inject.rebind.BindingsProcessor.process(BindingsProcessor.java:237)
    at com.google.gwt.inject.rebind.GinjectorGeneratorImpl.generate(GinjectorGeneratorImpl.java:76)
    at com.google.gwt.inject.rebind.GinjectorGenerator.generate(GinjectorGenerator.java:47)
    at com.google.gwt.dev.javac.StandardGeneratorContext.runGenerator(StandardGeneratorContext.java:418)
    at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:38)
    at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.tryRebind(StandardRebindOracle.java:108)
    at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:54)
    at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:154)
    at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:119)
    at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:531)
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:414)
    at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:39)
    at com.google.gwt.core.client.GWT.create(GWT.java:98)
    at org.ires.gwt.client.Client.<init>(Client.java:13)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:422)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:361)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
    at java.lang.Thread.run(Thread.java:619)

Original issue reported on code.google.com by dusan.ma...@gmail.com on 10 Oct 2010 at 1:07

GoogleCodeExporter commented 9 years ago
Interesting, you're trying to bind a type which GWT can't seem to find. I can 
provide you with a patched Gin version that will give a better error message as 
to which type is affected.

http://codesearch.google.com/codesearch/p?hl=en#d7yaITFH7NQ/trunk/src/com/google
/gwt/inject/rebind/util/KeyUtil.java&l=111

Original comment by aragos on 11 Oct 2010 at 5:16

GoogleCodeExporter commented 9 years ago
Marking as "won't fix" for now since we have too little information on how this 
came about.

Original comment by aragos on 12 Feb 2011 at 10:59

GoogleCodeExporter commented 9 years ago
Ah. Dropped off my radar.

FYI, I see that we get this type of error when we mistakenly reference a 
non-gwt class (well, one without a source file available for GWT). I'll open a 
new bug if feeling properly motivated by additional errors.

Original comment by smc...@google.com on 14 Feb 2011 at 6:36

GoogleCodeExporter commented 9 years ago
I also get such errors a lot and I am pretty much left alone in space tracking 
down the actual problem.

> I can provide you with a patched Gin version
> that will give a better error message as to which type is affected.

That would really save the world. However the provided link does not work for 
me.

Original comment by joerg.ho...@googlemail.com on 25 Jan 2012 at 8:51

GoogleCodeExporter commented 9 years ago
Hi again,

Class: com.google.gwt.inject.rebind.BindingsProcessor
Method: createImplicitBinding
Line 498 (or 491):
    if (rawClassType.equals(ginjectorInterface)) {

For some reason the TypeOracle can return null for rawClassType and then you 
get this NPE. An excellent improvement would be to add this before the if 
stated above:

if (rawClassType == null) {
  throw new IllegalStateException("Failed to resolve " + key);
}

Original comment by joerg.ho...@googlemail.com on 26 Jan 2012 at 10:37

GoogleCodeExporter commented 9 years ago
I tracked my problem down to the root and in the end I used an
someClass.isAssignableFrom(otherClass)
what is not compliant with GWT client code.
I would expect the GWT Compiler to log something in such case. I got no message 
for this problem even with -loglevel DEBUG.
Not a problem of GIN but if you have good connections to GWT core team please 
let them know to improve... Thanks for all!

Original comment by joerg.ho...@googlemail.com on 26 Jan 2012 at 11:25

GoogleCodeExporter commented 9 years ago
Whoever runs into the same problem: Maybe you have excluded certain classes 
from your gwt.xml file.

E.g. I excluded all classes ending in *Mock and just spent an hour on this 
issue. ;)

Original comment by AndiShea...@gmail.com on 8 May 2012 at 9:05

GoogleCodeExporter commented 9 years ago
It's very easy to reproduce this problem. It happens when there are some gwt 
compiler errors in the class file.

I checked what's default behavior in gwt without gin (on sample starter project 
from eclipse). It's enough to add

Double.doubleToLongBits(0.0);

in EntryPoint#onModuleLoad(); to see in the dev mode console logs about the 
exact location and explanation of the error.

The error is reported in CompilingClassLoader#findClassBytes(String) 
(http://code.google.com/p/google-web-toolkit/source/browse/trunk/dev/core/src/co
m/google/gwt/dev/shell/CompilingClassLoader.java#1331). It seems that NPE is 
crashing compilation before the error is reported.

Maybe it's possible to avoid that NPE, and when control reaches the class 
loader, the exact information about the error will be displayed as in non gin 
project.

Original comment by grz3gorz...@gmail.com on 13 Aug 2012 at 11:36

GoogleCodeExporter commented 9 years ago
Why is this issue in the WontFix category? it's a defect in the compiler, isn't 
it? And one that costs many hours to developers, as we are left alone in the 
dark wondering which is the offending class. Besides, it looks like a very easy 
to reproduce error. Should I consider it a compiler "feature" then? 

Original comment by pablocha...@gmail.com on 2 Sep 2012 at 6:05

GoogleCodeExporter commented 9 years ago
Reopening due to more information. We should be able to emit a better error 
message now that there is a reproducible way to test the bug with.

Original comment by aragos on 2 Sep 2012 at 6:13

GoogleCodeExporter commented 9 years ago
Historically, I've seen this NPE when I've inadvertently used a non-client 
class in a client class.  In this case, the GWT compiler (ref. GWT 2.4.0) can 
identify the offending import.  Note that this technique does not help for all 
causes of client compilation failure, and it should not decrease priority of 
this ticket.

With Google Plugin for Eclipse hosted dev mode:
 1. On the launch configuration on the GWT tab, set "Log level" to TRACE.
 2. Launch using that configuration, and load the launch URL to generate the error.
 3. In the Development Mode window, expand the "Validating newly compiled units" item.
 4. Beneath the "Validating newly compiled units" item, expand each "Error in..." item that cites a file in client or shared packages.
 5. Scan for items of the form: "Line NN: No source code is available for type XXXX; did you forget to inherit a required module?"

Some of those messages will be irrelevant (e.g. 
requestfactory.vm.impl.Deobfuscator.Builder), but one of them will be the 
offending non-client class.

You can get the same info in more grep-friendly form by compiling with 
-logLevel TRACE.

Original comment by joew...@gmail.com on 19 Sep 2012 at 11:45

GoogleCodeExporter commented 9 years ago
Can anyone add that better error message mentioned in 
http://code.google.com/p/google-gin/issues/detail?id=119#c5

After this change I would consider this bug fixed as long as key allows to 
guess which class is being resolved.

That is simple change and would help a lot when this error occurs. Currently 
GIN is not helpful in this case. It is no fun trying to track reason of this 
error by randomly pocking in configuration instead of getting at least some 
error message.

Original comment by PetrG...@gmail.com on 1 Jul 2014 at 7:21