aboutsummaryrefslogtreecommitdiff
path: root/core/src/com/google/inject
AgeCommit message (Collapse)Author
2015-02-03Only warn one per dependency, otherwise log spam can destroy disks. This ↵sameb
time w/o using Sets.newConcurrentHashSet., ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=85377786
2015-02-03Add some SPI methods to allow users to annotate Module methods with arbitrarysameb
bindings and have those methods bound as Providers to specialized Keys. This is the basis of what will be used to allow Multibinder/MapBinder/OptionalBinder to have stuff like @SetProvides, @MapProvides, @OptionalProvides and dagger interop support. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=85361820
2015-02-03Implement my old patch for issue #366, with some tweaks. This does thesameb
following: * Fixes @Provides injection so that parameters are checked for nullability. By default this will error. The flag is named: guice_check_nullable_provides_params and can be set to ERROR, WARNING or IGNORE. * Adds InjectionPoint.forMethod to build an InjectionPoint off an arbitrary method. * Adds Binder.getProvider(Dependency) to a get a Provider for a given dependency (with all its nullability & injection points maintained). * Update ProviderLookup to accept a Dependency in addition to a Key. This is in preparation for two things: 1) Allowing multibindings/mapbindings/optionalbindings to be specified as annotations on methods in a module. 2) Adding a dagger compatibility module. ... the general idea will be that I'll also add a hook into ProvidesMethodModule somehow to look at arbitrary other annotations and let folks process them specially. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=85353820
2015-02-03Make Guice ignore validation of scope annotations on abstract types for ↵dweis
types annotated with @Component. This allows one to provide Dagger Components with Guice Injectors. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=84836495
2015-01-24Optimization: move ParameterizedTypeImpl checks out of line.bulach
No functional changes. This will allow android apps to remove this method via proguard in release mode. For everything else, it should be almost a no-op, just one extra indirection. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=83477074
2015-01-19Fix linked binding behavior with requireExplicitBindings() in the parent.Tavian Barnes
The old behavior was to try to create the binding in the parent, swallow the error, and create it in the child. This restores that behavior, as bindings created in the current injector shouldn't be prohibited.
2015-01-07Clarify some documentation about linked bindings and child injectors.Tavian Barnes
2014-12-19Fix https://github.com/google/guice/issues/888.Tavian Barnes
When Binder.requireExplicitBindings() is in effect, don't allow any JIT bindings to be created in parent injectors, even JIT bindings that are normally exempt such as the targets of linked key bindings.
2014-12-05Fix for https://github.com/google/guice/issues/884 -- don't letsameb
half-initialized objects leak out to ProvisionListeners. Throw ProvisionException if there's any new errors during provision. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=81455693
2014-11-07rm unchecked suppression.Sam Berlin
2014-11-07Robustness: wrap any calls to System.getProperty in case security is enabled.Stuart McCulloch
Since calling System.getProperty may throw an exception on locked-down systems. Note: this patch has the side-effect of making the 'guice_include_stack_traces' setting static, rather than querying the system property each time a module is installed. Making the setting static improves performance as System.getProperty can be a bottleneck, at the cost of being able to change the setting on-the-fly. (This is a slightly modified version of the pull request from #872.) ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=79427020
2014-10-27Making Singleton's creation lock less coarse.timofeyb
Singleton is defined as a scope which creates no more than one object per injector. It's highly confusing when you catch a deadlock between two unrelated injectors due to the same class injection. Problem is demonstrated using a test that recreates scenario when one thread injecting class can block other thread to use its own injector. Proposed solution is to use Injector-wide locks in a singleton. ThreadLocal as a way to store current state. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=78469951
2014-10-03Results of 'mvn license:format -N' plus some minor tweakingStuart McCulloch
2014-09-24Delete unused code from WeakKeySet.dweis
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=75815862
2014-09-24When checking for Logger keys in providermethodsmodule don't create a new ↵lukes
Key<Logger> for every parameter. Instead use a constant. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=75227883
2014-09-15De-duplicate equivalent scope bindings.Tavian Barnes
2014-08-11fix typo in javadocRyan Berdeen
2014-08-06Implement binding deduplication for multibinder & mapbinder in a different way.Sam Berlin
Instead of relying on Guice binding deduplication (and hacking up RealElement to break the annotation contract to do so, causing weirdness in WeakKeySet & forcing us to care about "rehashing keys"), we instead deduplicate within Multibinder. The downside of this is that toInstance or toProvider(instance) bindings that are deduplicated will remain in the object graph but effectively be unreachable. However, that's a downside I'm willing to live with to remove this hack. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72570932
2014-08-06Fix typo in JavaDoc for c.g.inject.internal.MoreTypes#getGenericSupertypeSam Berlin
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72545394
2014-08-06Guice: Fix for issue 295 (@ProvidedBy doesn't work with enums)Sam Berlin
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72100195
2014-07-21Set a bit in ProviderMethodsModule to see if we are generating provider ↵Sam Berlin
methods for gin. If we are, skip fast class generation. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=71452336
2014-07-20Cleanup javadocs. This makes the following changes:Sam Berlin
1) Stop using doclava. It has too many bugs (like dropping annotations). 2) Tell javadoc not to doclint. Java8 does it and errs if it fails. 3) Link to appropriate third parties from javadoc. 4) Split extensions into separate groups in ant javadoc. 5) Cleanup code that had javadoc warnings.
2014-07-01Detect overrides of @Provides method and add an error for each one.Sam Berlin
Overriding an @Provides method is fairly rare and can be very confusing (e.g. a covariant override). This will not be backwards compatible for open source users. See: https://groups.google.com/d/msg/google-guice/bRo5SvmzpdI/_uIfF3yUy9gJ for the public discussion ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=70120926
2014-07-01Automated code cleanups by internal tool.Sam Berlin
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=69390543
2014-07-01Submitting Stuart McCulloch's patch from ↵Sam Berlin
https://github.com/sonatype/sisu-guice/blob/master/PATCHES/GUICE_288_decouple_thread_local.patch. This rearranges the furniture a bit so we can track down some strange allocations in ThreadLocal#get(). Thanks, Stuart! ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=69169927
2014-05-23Ignore synthetic bridge methods during provider method lookup.Sam Berlin
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=67854418
2014-05-10Try to use cglibs FastClass to invoke @Provides methods, it's faster!Sam Berlin
Here is a caliper benchmark to demonstrate the difference. https://caliper.googleplex.com/runs/2d349fec-2742-45e1-b6e5-16997c522387#r:scenario.benchmarkSpec.methodName,scenario.benchmarkSpec.parameters.strategy This should save about 200-300 ns per method invocation and about 224 bytes (over 4 objects) of allocations for each invocation. The cost of this (of course) is greater permgen usage and potentially slower startup/injector creation due to the class generation. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=66364901
2014-05-03Ignore synthetic/bridge methods when determining if a method should be ↵Sam Berlin
injected. This broke injections for different reasons before & after java8, but the fix is the same for both. Add a test with method injection points & super/sub classes that change method visibility, to confirm that synthesized/bridged methods don't artificially change what's injected or the parameters of the injections. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=66136797
2014-05-03Update provision & creation exception messages. The previous messages ↵Sam Berlin
caused misdiagnosis, as users think "There was a Guice error" when there is an error in user code. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=66120881
2014-05-03Make WeakKeySet less susceptible to programming errors by making the ↵Sam Berlin
backingMap key a concrete type. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=65307015
2014-05-03Add equals/hashCode to Providers.guicify(...) results.Sam Berlin
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=65072672
2014-05-03Implement hashCode and equals on type returned by Providers.of(...). There ↵Sam Berlin
doesn't seem to be any reason *not* to provide these methods, and it means downstream code that does bind(X.class).toProvider(Providers.of(null)) does not result in erroneous duplicate binding errors if Modules.override is used. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=65067530
2014-05-03Use the correct key to check for blacklisting of multibound elements.Sam Berlin
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=64831090
2014-04-08Change Opcodes.ASM4 to Opcodes.ASM5, to work with java8 lambdas. Also ↵Sam Berlin
update opensource build to ASM 5.0.1. I'm not confident this will 100% solve every issue... we may need to update cglib also to use OpCodes.ASM5. Should do some testing w/ AOP over things with default methods & lambdas. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=64557004
2014-04-08The bug in the test that became flaky has been fixed. Note that this is not ↵Sam Berlin
a strict rollback of the rollback - I've added protection against the NPE that would happen if there's a GC between the isBlacklisted call and the getSources call. *** Original change description *** Enhance WeakKeySet to auto evict keys and avoid calling toString on Keys. This should fix https://code.google.com/p/google-guice/issues/detail?id=756. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=64507759
2014-04-08*** Reason for rollback ***Sam Berlin
Causes an internal test to become flaky. *** Original change description *** Enhance WeakKeySet to auto evict keys and avoid calling toString on Keys. This should fix https://code.google.com/p/google-guice/issues/detail?id=756. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=64181193
2014-04-01Enhance WeakKeySet to auto evict keys and avoid calling toString on Keys.Christian Edward Gruber
This should fix https://code.google.com/p/google-guice/issues/detail?id=756. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=64083354
2014-04-01Preparations for OptionalBinder. This fixes MapBinder's SPI so elements ↵Christian Edward Gruber
from different MapBinders are distinct, and also fixes ProviderLookup's Provider so it exposes its dependency, which allows MapBinder to properly find its dependencies. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=63811558
2014-04-01Memoize Key#toString() to reduce allocations.Christian Edward Gruber
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=63557612
2014-03-10Add an SPI for @Provides methods (using the extensions SPI) so that users canSam Berlin
do more analysis (with the enclosing instance, method, etc..). Notably, this can let users write analysis that looks for @Provides methods declared with @Nullable, and compare against injection points w/o @Nullable, failing if so. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=62834918
2014-03-10Change LinkedBindingBuilder.toProvider(Provider) to accept a jsr330 provider,Sam Berlin
in addition to the Guice Provider. This is an incompatible change for people who extend LinkedBindingBuilder, but not for people who use it. This will allow people to switch to JSR330 types more easily. LinkedBindingBuilder needs both toProvider(Provider) and toProvider(javax.inject.Provider) because precompiled jars (e.g, stuff in third_party, maven, etc..) that used toProvider(Provider) would otherwise throw a NoSuchMethodError. I left the getProviderInstance method on ProviderInstanceBinding, otherwise that would require anyone using the SPI method to change their code to accept the weaker type. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=61966924
2013-12-11Fixes issue 652. Allow method interceptors to capture the method & call it ↵Sam Berlin
later from a different context. Patch by Tavian Barnes, thanks Tavian! ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=58040591
2013-12-11A Message should have only one source but as it is used in Errors, currently ↵Sam Berlin
it can have multiple sources. The Message objects is returned from two public methods(Elements#getElements() and Errors#getMessages()) that make any changes in its method declarations difficult. As the first step, I am going to remove all calls to the Message constructor that receives multiple sources from []. So, the only calls will be from Errors that I will deal with separately. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=57979416
2013-12-09Fix issue 723 -- minor optimizations to TypeConverterBindingProcessor.Sam Berlin
Description in the bug describes this best: TypeConverterBindingProcessor has two responsibilities: 1) prepare built-in type converters for primitives, enums, classes, etc. and 2) process TypeConverter bindings and register them with the containing injector. The first responsibility only needs the injector reference, it doesn't need access to the processor's Errors cache. However, the current implementation runs in the context of the processor and creates a number of anonymous classes, and they all contain an implicit reference (this$0) back to the processor. This can lead to some Errors instances being kept alive longer than necessary by these anonymous classes, but not a large number. Changing the prepareBuiltInConverters implementation over to use static methods that pass the injector as an argument fixes this problem by removing the implicit reference to the processor, since the anonymous classes are now created from a static context. Patch by Stuart McCulloch. Thanks Stuart! ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=57906347
2013-12-06Re-committed the rolled back CL, after fixing internal projects.Sam Berlin
*** Original change description *** Pass the correct stage to Modules.override, so currentStage() works. Fixes issue 784 -- patch thanks to Tavian Barnes. *** ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=57809778
2013-12-06Fix issue 779 -- deduplicate listeners & interceptors. Using a slightly ↵Sam Berlin
modified patch from Tavian Barnes, thanks Tavian! ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=57798796
2013-12-06Rolled back commit -- broke some internal projects.Sam Berlin
*** Original change description *** Pass the correct stage to Modules.override, so currentStage() works. Fixes issue 784 -- patch thanks to Tavian Barnes. *** ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=57770628
2013-12-06Fix issue 748 -- add a protected method in PrivateModule for binding provisionSam Berlin
listeners. Patch provided by Stuart McCulloch, thanks! ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=57764090
2013-12-06Optimize RecordingBinder.withSource so it doesn't always create a new binder.Sam Berlin
Fixes issue 776, patch thanks to Stuart McCulloch! ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=57757534
2013-12-06Pass the correct stage to Modules.override, so currentStage() works.Sam Berlin
Fixes issue 784 -- patch thanks to Tavian Barnes. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=57755697