gpicron / google-gin

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

LinkageError when injecting AsyncProvider subtype #180

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Define a class that implements com.google.gwt.inject.client.AsyncProvider 
and inject an instance of it.

Example:

public class AsyncProviderTest implements EntryPoint {

    @NoGinModules
    public interface TestGinjector extends Ginjector {
        void injectMembers(AsyncProviderTest instance);
    }

    public static class FooProvider implements AsyncProvider<Widget> {

        @Override
        public void get(AsyncCallback<? super Widget> callback) {
            callback.onSuccess(null);
        }
    }

    // Loading the FooProvider class results in a LinkageError
    @Inject
    private FooProvider fooProvider;

    public void onModuleLoad() {
        GWT.<TestGinjector> create(TestGinjector.class);
    }
}

What is the expected output? What do you see instead?
Expected: no compilation errors
Result: java.lang.LinkageError: loader constraint violation: loader (instance 
of sun/misc/Launcher$AppClassLoader) previously initiated loading for a 
different type with name "com/google/gwt/user/client/rpc/AsyncCallback"

What version of the product are you using? On what operating system?

GIN 2.0 / Windows 7, Ubuntu 12.04

Please provide any additional information below.

Workaround: add AsyncCallback's package to the "excepted packages" by adding 
the following to your GWT module XML:

<extend-configuration-property name="gin.classloading.exceptedPackages" 
value="com.google.gwt.user.client.rpc" />

Possible solutions: 
a) don't add AsyncProvider to excepted packages/types by default
b) exclude AsyncCallback by default in addition to AsyncProvider

Original issue reported on code.google.com by mcart...@gmail.com on 24 Sep 2012 at 3:36