fmgasparino / google-gin

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

non-public classes fail weirdly #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Trying to inject an instance of a non-public class fails weirdly. Would be
nice to support this as well as Guice does. Regardless, if it fails, it
should fail with useful error messages.

Original issue reported on code.google.com by bstoler+code@google.com on 28 Aug 2008 at 11:43

GoogleCodeExporter commented 9 years ago
This should be fixed, Brian can you confirm?

Original comment by aragos on 26 Jan 2009 at 4:45

GoogleCodeExporter commented 9 years ago
Nope, doesn't work. Non-public constructors, field and methods work (I think), 
but a
non-public type can not be injected (unless the Ginjector happens to be in its
package). This may be tricky to support. For package-private types, we could 
generate
a bridge class in that package. For private nested classes, that may not work 
either.

The attached patch has failing unit tests. The failure output is below. It is 
not too
confusing, I guess, though we could do better if we checked explicitly for this 
case
in BindingsProcessor.

Rebinding com.google.gwt.inject.client.nonpublic.NonPublicGinjector
   Removing units with errors
      [ERROR] Errors in
'file:/Users/bstoler/Library/Caches/IntelliJIDEA80/gwt/gin.gin37b8d123/Gin.9af16
8a0/test/gen/com/google/gwt/inject/client/nonpublic/NonPublicGinjectorImpl.java'
         [ERROR] Line 10: The type
com.google.gwt.inject.client.nonpublic.secret.PrivateClass is not visible
         [ERROR] Line 11: The type
com.google.gwt.inject.client.nonpublic.secret.PrivateClass is not visible
         [ERROR] Line 11: The type
com.google.gwt.inject.client.nonpublic.secret.PrivateClass is not visible
         [ERROR] Line 14: The type
com.google.gwt.inject.client.nonpublic.secret.PrivateClass is not visible
         [ERROR] Line 15: The method
create_Key$type$com$google$gwt$inject$client$nonpublic$secret$PrivateClass$_anno
tation$$none$$()
is undefined for the type NonPublicGinjectorImpl
         [ERROR] Line 19: The type
com.google.gwt.inject.client.nonpublic.secret.SecretMain.Inner is not visible
         [ERROR] Line 20: The type
com.google.gwt.inject.client.nonpublic.secret.SecretMain.Inner is not visible
         [ERROR] Line 20: The type
com.google.gwt.inject.client.nonpublic.secret.SecretMain.Inner is not visible
         [ERROR] Line 23: The type
com.google.gwt.inject.client.nonpublic.secret.SecretMain.Inner is not visible
         [ERROR] Line 24: The method
create_Key$type$com$google$gwt$inject$client$nonpublic$secret$SecretMain$Inner$_
annotation$$none$$()
is undefined for the type NonPublicGinjectorImpl
         [ERROR] Line 28: The type
com.google.gwt.inject.client.nonpublic.secret.PrivateClass is not visible
         [ERROR] Line 28: The type
com.google.gwt.inject.client.nonpublic.secret.SecretMain.Inner is not visible
         [ERROR] Line 32: The type
com.google.gwt.inject.client.nonpublic.secret.PrivateClass is not visible
         [ERROR] Line 36: The type
com.google.gwt.inject.client.nonpublic.secret.PrivateClass is not visible
         [ERROR] Line 40: The type
com.google.gwt.inject.client.nonpublic.secret.SecretMain.Inner is not visible
         [ERROR] Line 45: The method
get_Key$type$com$google$gwt$inject$client$nonpublic$secret$PrivateClass$_annotat
ion$$none$$()
is undefined for the type NonPublicGinjectorImpl
         [ERROR] Line 45: The method
get_Key$type$com$google$gwt$inject$client$nonpublic$secret$SecretMain$Inner$_ann
otation$$none$$()
is undefined for the type NonPublicGinjectorImpl
         [ERROR] Line 45: The method
get_Key$type$com$google$gwt$inject$client$nonpublic$secret$PrivateClass$_annotat
ion$$none$$()
is undefined for the type NonPublicGinjectorImpl
         [ERROR] Line 46: The method
get_Key$type$com$google$gwt$inject$client$nonpublic$secret$PrivateClass$_annotat
ion$$none$$()
is undefined for the type NonPublicGinjectorImpl
         [ERROR] Line 47: The method
get_Key$type$com$google$gwt$inject$client$nonpublic$secret$SecretMain$Inner$_ann
otation$$none$$()
is undefined for the type NonPublicGinjectorImpl
   [ERROR] Unable to find recently-generated type
'com.google.gwt.inject.client.nonpublic.NonPublicGinjectorImpl
[ERROR] Deferred binding failed for
'com.google.gwt.inject.client.nonpublic.NonPublicGinjector'; expect subsequent 
failures

Original comment by bstoler+code@google.com on 5 Feb 2009 at 2:13

Attachments:

GoogleCodeExporter commented 9 years ago
Code review: http://codereview.appspot.com/14073

We can't easily support non-public types, but we can at least give better error 
messages.

Original comment by bstoler+code@google.com on 11 Feb 2009 at 12:33

GoogleCodeExporter commented 9 years ago
Better error messages in r88 and r90.

Original comment by bstoler+code@google.com on 12 Feb 2009 at 6:46

GoogleCodeExporter commented 9 years ago
FYI, errors are now like:

    [junit]             [ERROR] Can not inject an instance of an inaccessible class.
Key=Key[type=com.google.gwt.inject.client.nonpublic.secret.PrivateClass,
annotation=[none]]
    [junit]             [ERROR] Can not inject an instance of an inaccessible class.
Key=Key[type=com.google.gwt.inject.client.nonpublic.secret.SecretMain$Inner,
annotation=[none]]

Original comment by bstoler+code@google.com on 12 Feb 2009 at 6:48