Commit Graph
529 Commits
Author SHA1 Message Date
Guice TeamandGuice Team ed6993aa14 Delete ant related build files.
PiperOrigin-RevId: 345749534
2020-12-04 13:51:03 -08:00
Guice TeamandGuice Team 70062306db Update BoundFieldModule description to be more specific about what it does.
PiperOrigin-RevId: 345252174
2020-12-02 09:49:56 -08:00
Guice TeamandGuice Team 6eaf556c8b Fix ServletConfig.getInitParameterNames return type.
Closes #1440.

PiperOrigin-RevId: 339960006
2020-10-30 16:30:10 -07:00
Guice TeamandGuice Team 383d377436 Bump snapshot version, update README & prior API xml
PiperOrigin-RevId: 339910400
2020-10-30 11:43:16 -07:00
Guice TeamandGuice Team b1975a7c29 Update dagger jar used by ant to match the actual version used in maven.
PiperOrigin-RevId: 339701941
2020-10-29 10:53:18 -07:00
Guice TeamandGuice Team 2de2311318 Update FactoryProvider2 to support Java 15.
The private constructor used in looking up method handles has changed to take an extra parameter. This change update the code to look for both constructor signatures.

PiperOrigin-RevId: 339124988
2020-10-26 15:00:30 -07:00
Guice TeamandGuice Team 8b2a048a71 Fix BoundFieldModuleTest to run with Java 15.
PiperOrigin-RevId: 339039746
2020-10-26 08:09:52 -07:00
Guice TeamandGuice Team b256703850 Remove multibindings extension, it has been part of Guice core since 4.2 release.
Also clean up no_aop build variant from BOM.

PiperOrigin-RevId: 338771054
2020-10-23 17:03:44 -07:00
Guice TeamandGuice Team 80b91afae2 Update tests to support running with Java 15.
In Java 15, the annotation `toString` implementation omits the member name.

PiperOrigin-RevId: 338746927
2020-10-23 14:37:28 -07:00
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
Guice TeamandGuice Team dd873be400 Remove AOP build variant.
Changes include:

- skip tests that are testing bytecode generation enabled behaviors
- make line number and source file name information available even when bytecode generation is disabled since it does not use bytecode generation and makes testing easier (some tests rely on the information being available)
- update maven pom files to stop producing a no-aop version of Guice
- added test profile to execute tests with bytecode generation disabled

PiperOrigin-RevId: 336306344
2020-10-09 09:23:54 -07:00
Guice TeamandGuice Team b7cadc1cfa Migrate several tests to junit4 so that tests that rely on AOP can be skipped using Assume.assumeTrue.
PiperOrigin-RevId: 335755255
2020-10-06 17:18:53 -07:00
Sam BerlinandGuice Team 6586659da6 Update BoundFieldModule to mark the field as the source of the binding.
PiperOrigin-RevId: 333317842
2020-09-23 10:18:28 -07:00
Colin DeckerandGuice Team 835084290b Replace some usernames in TODOs.
PiperOrigin-RevId: 329928334
2020-09-03 09:01:02 -07:00
Guice TeamandColin Decker 83c9a329f4 Automatic code cleanup.
PiperOrigin-RevId: 328979463
2020-08-28 15:28:47 -04:00
xiaomingjiaandColin Decker 67a5327dc0 Delete TODO to make @Inject required to use assisted inject.
Since it's actually possible to use assisted inject with field or method injection, an `@Inject` annotated constructor is not necessary.

This does mean that assisted injection does not respect the `binder().requireAtInjectOnConstructors()` requirement and it is non-trivial to propagate the injector option down to enforce this because the injection point is looked up at module configuration time.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=326730924
2020-08-17 11:30:36 -04:00
xiaomingjiaandColin Decker 51ba928a1b Implement MissingConstructor error in the new format.
This also merge MISSING_CONSTRUCTOR with AT_INJECT_REQUIRED into a single error since they are essentially about the same issue.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=325867978
2020-08-12 11:24:17 -04:00
xiaomingjiaandKurt Alfred Kluever 97bed3ffbd Fix and suppress more javac warnings in Guice code.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=325307904
2020-08-07 11:50:03 -04:00
xiaomingjiaandKurt Alfred Kluever 84e0ce89ba Fix or suppress more javac warnings in Guice.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=325069224
2020-08-06 13:57:00 -04:00
xiaomingjiaandKurt Alfred Kluever 363c593aa7 Fix or suppress some unchecked/rawtypes javac warnings in Guice code.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=324884430
2020-08-05 09:53:37 -04:00
xiaomingjiaandKurt Alfred Kluever ffb154d030 Fix some unchecked and rawtypes warnings in Guice code.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=324668014
2020-08-04 11:22:03 -04: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
vzmandDavid P. Baker f1ed57d045 Add BoundFieldModule.WithPermits wrapper for granting @RestrictedBindingSource permits to instances of BoundFieldModule.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=321408556
2020-07-16 10:59:26 -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
xiaomingjiaandkevinb9n 4e8a119c54 Switch all tests under com.google.inject to run with junit4 test runner internally.
Left the googlecode test as junit3 since moving to junit4 runner causes issue with the OSGiContainerTest, as junit4 does not allow test class that doesn't have any test methods.

Also need to move ThrowingProviderTest to junit4 because somehow the class initialization constructor is called before the Suite's BeforeClass method thus reading the flag before the flag gets parsed, causing flag parsing to throw exception.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=320426928
2020-07-09 12:49:58 -07:00
diamondmandkevinb9n d65c576a21 Simplify some usages of Key.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=320184863
2020-07-08 12:51:29 -07:00
xiaomingjiaandKurt Alfred Kluever 6006bb7856 Add ErrorId enum to identify different types of Guice errors.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=310666294
2020-05-11 10:33:27 -04:00
idkandNick Glorioso 37c098d559 Adding Predicate<Method> to DaggerAdapter.
Only the methods which satisfy the predicate will be processed by the DaggerAdapter. The objective is to conditionally limit Guice bindings exposed by the DaggerAdapter based on an external condition.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=302462640
2020-03-25 10:04:27 -04:00
samebandChris Povirk 485191facb bump snapshot version, update README & prior API xml
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=301892530
2020-03-19 17:20:52 -04:00
diamondmandColin Decker 134db35272 Tidy up some usages of lambdas and other Java 8 features, and a few other tweaks.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=267686084
2019-09-13 13:03:49 -04:00
diamondmandDavid P. Baker 47fcfb19fc Address http://errorprone.info/bugpattern/InjectInvalidTargetingOnScopingAnnotation warning.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=263374326
2019-08-15 14:38:41 -04:00
diamondmandDavid P. Baker c1225dcf8f Change the error message for missingConstructor() to be more similar to missingImplementation() (which is far more often the actual issue).
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=263249646
2019-08-15 14:38:41 -04:00
ronshapiroandRon Shapiro ece6a9fce3 Migrate DaggerAdapter tests off of JUnit3 assertions and onto Truth
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=256429282
2019-07-11 08:04:25 -04:00
ronshapiroandRon Shapiro 09b7f977ec Support @IntoMap in DaggerAdapter
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=256416722
2019-07-11 08:04:25 -04:00
ronshapiroandRon Shapiro dbf496896a Consolidate two different yet similar tests
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=256084668
2019-07-11 08:04:25 -04:00
ronshapiroandRon Shapiro 8c596b2a20 Fix support for DaggerAdapter's unsupported annotations checker for modules that are passed as class literals.
We were incorrectly checking for Class.class in this case, which is never what we wanted.

In the process, also refactor the set of annotations which should have caught this discrepancy when we added support for abstract binding methods.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=256027168
2019-07-11 08:04:25 -04:00
ronshapiroandRon Shapiro 17e28c96db Remove stale TODO
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=255606896
2019-07-11 08:04:25 -04:00
ronshapiroandRon Shapiro 19ea943425 Install @Module(includes = ...) modules in DaggerAdapter.
Also validate that duplicates are passed as the declared modules to DaggerAdapter

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=255511592
2019-07-11 08:04:25 -04:00
ronshapiroandRon Shapiro c465b2b3c3 Add some clarifying details about DaggerMethodScanner/ProviderMethodsModule that I didn't know until now
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=255445300
2019-06-28 09:20:02 -04:00
ronshapiroandRon Shapiro ff1de7c26b Add support for abstract binding methods to DaggerAdapter: @Binds, @Multibinds and @BindsOptionalOf
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=254084186
2019-06-28 09:20:02 -04:00
samebandRon Shapiro c209ed23ee Make @RequestScoped use @Scope instead of @ScopeAnnotation.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=253582933
2019-06-28 09:20:02 -04:00
cpovirkandRon Shapiro 159e13370d Update to Truth 0.45, and address deprecations.
Renames may include:
- containsAllOf => containsAtLeast
- containsAllIn => containsAtLeastElementsIn
- isSameAs => isSameInstanceAs
- isOrdered => isInOrder
- isStrictlyOrdered => isInStrictOrder

The other major change is to change custom subjects to extend raw Subject instead of supplying type parameters. The type parameters are being removed from Subject. This CL will temporarily produce rawtypes warnings, which will go away when I remove the type parameters (as soon as this batch of CLs is submitted).

Some CLs in this batch also migrate calls away from actualAsString(). Its literal replacement is `"<" + actual + ">"` (unless an object overrides actualCustomStringRepresentation()), but usually I've made a larger change, such as switching from an old-style "Not true that..." failure message to one generated with the Fact API. In that case, the new code usually contains a direct reference to this.actual (a field that I occasionally had to create). Another larger change I sometimes made is to switch from a manual check-and-fail approach to instead use check(...). And sometimes I just remove a withMessage() call that's no longer necessary now that the code uses check(...), or I introduce a check(...) call. (An assertion made with check(...) automatically includes the actual value from the original subject, so there's no need to set it again with withMessage().)

Finally, there's one CL in this batch in which I migrate a Correspondence subclass to instead use Correspondence.from.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=251472122
2019-06-06 11:06:16 -04:00
ronshapiroandRon Shapiro 6a2b57138e Fix typo
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=247217813
2019-05-15 13:04:32 -04:00
cpovirkandRon Shapiro 553a475a2c Migrate Truth Subjects from no-arg check() to the overload that accepts a description.
The overload that accepts a description generally produces better failure messages:
- The first line of the message it produces is something like: "value of: myProto.getResponse()" (where "getResponse()" is taken from the provided description)
- The last line of the message it produces is something like: "myProto was: response: query was throttled" (the full value of myProto)
- And the existing text goes in between.

Additional motivation: We are deleting the no-arg overload externally (and probably internally thereafter).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=247095743
2019-05-08 10:35:03 -04:00
cpovirkandRon Shapiro ea179b962f Instead of calling Subject.actual(), store the actual value in a field, and read that.
actual() is being removed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=247039297
2019-05-08 10:35:03 -04:00
ronshapiroandRon Shapiro cc350c6b57 Validate that all modules passed to DaggerAdapter are in fact Dagger modules
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246535932
2019-05-05 12:32:27 -04:00
ronshapiroandRon Shapiro 785ed8d7bd Ban @Module(subcomponents) from DaggerAdapter until we properly support it
Supporting it correctly requires a fair amount of thought - Guice and Dagger scopes are different, multibindings are different, and implementing subcomponent factories+builders would be non-trivial. (We could possibly take advantage of child injectors to help?) Anyway, there's more to considered before traversing down this path.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246354857
2019-05-05 12:32:27 -04:00
ronshapiroandRon Shapiro c53f70d499 Compile against the newest version of Dagger for dagger-adapter, and make it optional so that users must bring their own version of dagger.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246331380
2019-05-05 12:32:27 -04:00