Commit Graph
18 Commits
Author SHA1 Message Date
Guice TeamandGuice Team 5caa549395 Enable the new Guice error messages.
Changes include:

 - update Guice tests that asserts error messages
 - export new errors tests
 - update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests

PiperOrigin-RevId: 337602195
2020-10-16 16:55:03 -07:00
Guice TeamandGuice Team 9a8e46716e Revert previous change because it broke some tests when running with openjdk8.
PiperOrigin-RevId: 337517262
2020-10-16 09:13:55 -07:00
Guice TeamandGuice Team 2c8c7fed12 Enable the new Guice error messages.
Changes include:
- update Guice tests that asserts error messages
- export new errors tests
- update Guice compiler flag so parameter names are available at runtime, which is required for the errors tests

PiperOrigin-RevId: 337401912
2020-10-15 16:06:22 -07:00
xiaomingjiaandKurt Alfred Kluever db66b74249 Fix some unchecked and rawtypes warnings in Guice code.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=324662892
2020-08-04 11:22:03 -04:00
Stuart McCullochandkevinb9n 85e30beafe Import https://github.com/google/guice/pull/1298
Replace CGLIB with custom code to generate "enhancers" and "fast-classes".

Some user visible changes from using cglib:
- intercepted method that has a return type of int but returns null from the interceptor will no longer be automatically converted to 0, instead a NullPointerException will be thrown.
- Scope implementation can no longer check for circular proxy instance using CircularDependencyProxy marker class, instead should use Scopes.isCircularProxy
- Depending on which custom class loading option is used, Guice enhanced class may no longer be mockable/spyable
- Generated class name is slightly longer.

Closes #1298

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=320433559
2020-07-10 08:43:31 -07:00
lukesandRon Shapiro 63fb234bb9 Remove (most) accumulation of multiple errors during provisioning
We will still collect multiple errors during configuration, but during
provisioning there are fewer benefits and in highly connected binding graphs
this can result in an error being reported once for every path to a broken
binding.  Even with this change multiple errors can be collected while injecting multiple members of a single object and in a few other less common ways (returning null from a non-nullable injection point).  But this cl removes the most common way.

This is also an enabling change.  With this it should be possible to move all
calls to Errors.withSource into catch blocks in the factory objects. So that
instead of recording progress as we provision, we will only record the sources
when the provision actually fails.  This will save an allocation for every node
and edge in the binding graph. (this change will happen in a followup)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173327556
2018-01-25 11:12:58 -05:00
lukesandRon Shapiro 4c2c276cdc Remove empty overrides of AbstractModule.configure() from guice modules
In 41f307e21b this AbstractModule.configure() became non-abstract in the base class, so it is now allowed for subclasses to not override the method at all when they don’t need to access the binding dsl.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148043119
2017-03-21 15:29:08 -04:00
lukesandSam Berlin 34e7c5d715 Run google-java-format on all Guice code.
configure a presubmit to ensure that it stays formatted.

Highlights include:
* simplified import order
* method annotations are now consistently defined on the preceding line
* javadoc reformatted to 100 chars column width

One test that contained line numbers in error messages had to be modified and
the formatter didn't like some of the more complicated preprocessor directives
(MOE and AOP).

To avoid formatting the copyright notices as javadoc i did a preprocessing step to rewrite the initial '/**' to '/*' using perl

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132718493
2016-09-13 11:47:18 -04:00
lukesandSam Berlin 713c06cce9 Fix issues reported by errorprone
99% of this is adding missing @Override annotations, in the long tail we also have

* insert missing calls to Assert.fail() in tests that are testing exception behavior
* rewrite a few cases of Foo.class.instanceof(c) to c instanceof Foo
* rewrite Class.newInstance - > Class.getConstructor().newInstance() which doesn't break checked exception checking.
* adding @javax.inject.Inject annotations to methods that override methods annotated with @javax.inject.Inject

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131839622
2016-09-07 17:45:54 -04:00
Tavian Barnes 522b303a92 Make disableCircularProxies() disable all forms of circular dependencies. 2015-12-22 16:10:08 -05:00
guice.mirrorbot@gmail.com 05bf8e5922 Add Scopes.isCircularProxy, for use by Scope implementations. The basic problem is that somewhere along the line, Guice is breaking the type-safety of <T> in the scope(Key<T>, Provider<T>) method. This happens when <T> is involved in a circular dependency, and the ConstructionContext creates a circular proxy for a given 'expectedType' of <T> (the type in the parameter where it's being injected). Expected type is a superclass or superinterface of <T>, not a subclass or subinterface, so if a Scope caches the result of Key<T> -> Provider<T>.get(), and then tries to reuse it, it's possible that we return something that isn't compatible with <T>. This results in either a ClassCastException (if cglib is involved) or IllegalArgumentException (java reflection) when trying to construct the object, because the parameters don't match the arguments.
Revision created by MOE tool push_codebase.
MOE_MIGRATION=3341


git-svn-id: https://google-guice.googlecode.com/svn/trunk@1586 d779f126-a31b-0410-b53b-1d3aecad763e
2011-09-27 15:37:30 +00:00
sberlin b7a02b02d8 * Remove unused imports
* Sort imports
* Convert tabs to spaces
* Fix the ant no_aop build


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2532


git-svn-id: https://google-guice.googlecode.com/svn/trunk@1572 d779f126-a31b-0410-b53b-1d3aecad763e
2011-07-08 00:34:16 +00:00
sberlin d5737a6019 fix @ProvidedBy circular dependencies.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1546 d779f126-a31b-0410-b53b-1d3aecad763e
2011-05-02 18:03:35 +00:00
sberlin c94f4506c7 assert that ProviderInternalFactory doesn't think circular dependencies exist when the providers are in different PrivateModules, temporarily remove check for @ProvidedBy due to other things that need fixing first.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1545 d779f126-a31b-0410-b53b-1d3aecad763e
2011-05-02 13:30:37 +00:00
sberlin 425d099754 fix provider circular dependency detection to use the Key it is creating, not the Key it is fulfulling, to catch errors sooner.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1544 d779f126-a31b-0410-b53b-1d3aecad763e
2011-05-02 00:28:59 +00:00
sberlin e6ce1886f5 fix issue 626 -- properly handle circular proxies between providers (either failing or proxying), prevents StackOverflowErrors.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1543 d779f126-a31b-0410-b53b-1d3aecad763e
2011-04-30 15:38:05 +00:00
sberlin 8b64d455b9 Remove InjectorBuilder in favor of methods in Binder.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1457 d779f126-a31b-0410-b53b-1d3aecad763e
2010-12-13 02:44:36 +00:00
mcculls 74d714c1e7 Issue 552: (step 1) move core code to its own subdirectory
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1300 d779f126-a31b-0410-b53b-1d3aecad763e
2010-10-21 19:10:16 +00:00