### Guice 5.0.1 Released February, 26th, 2021. This release contains a [bug fix](https://github.com/google/guice/issues/1496) for Guice 5.0.0. #### Maven Guice: ```xml com.google.inject guice 5.0.1 ``` Extensions: ```xml com.google.inject.extensions guice-${extension} 5.0.1 ``` #### Downloads * Guice: [guice-5.0.1.jar](http://search.maven.org/remotecontent?filepath=com/google/inject/guice/5.0.1/guice-5.0.1.jar) * Guice extensions are all directly downloadable [from this search page](https://search.maven.org/search?q=g:com.google.inject.extensions%20AND%20v:5.0.1). Just click on the "jar" link for the appropriate extension. #### Docs * [API documentation](https://google.github.io/guice/api-docs/5.0.1/javadoc/index.html) * [API Changes from 4.2.3 to 5.0.1, by JDiff](http://google.github.io/guice/api-docs/5.0.1/api-diffs/index.html) #### Changes since Guice 4.2.3 ##### Some highlights: - Added Java15 support (updated asm and bug fixes). - Removed cglib as a core dependency. ([#1359](https://github.com/google/guice/pull/1359)) - Improved error messages. - Improved support for using Guice with Kotlin. - Added a mechanism to restrict who can bind types or annotations, to allow library authors to control their bindings. - Removed no-aop build variant. - Fixed 'illegal reflective access' warnings. ##### Details, per core + extensions ###### Guice Core - Removed cglib as a core dependency. Guice now uses ASM directly to generate bytecode at runtime for invoking user code and supporting method interception - To disable bytecode generation, use the new `-Dguice_bytecode_gen_option=DISABLED` flag. When disabled, ASM & AOP-related code will still be linked into Guice, but will not be used. - Improved error messages - package names in error messages are compressed to make it easier to read - errors with the same cause are grouped and reported together - common error now links to a wiki page on how to debug and fix the error - additional information like parameter names are included when code are compiled with javac `-parameters` flag - rich formatting like bold, color are used when errors are displayed in a supported console (can be disabled with `-Dguice_colorize_error_messages=DISABLED` flag) - Improved support for using Guice with Kotlin - `Multibinder` now binds `Set` so Kotlin code can inject `Set` instead of `Set<@JvmSuppressWildcards T>` - `MapBinder` now binds `Map` so Kotlin code can inject `Map` instead of `Map` - Removed dependency stack tracking API in `ProvisionListener.getDependencyChain`([commit](https://github.com/google/guice/pull/1431/commits/d3df2d5854fb55f65a8db44f4ecb4814148e495f)). See below for a workaround if you rely on this API. - Duplicate static `@Provides` method will be deduped - [commit](https://github.com/google/guice/commit/1174710c292303432540e172d75e70b02093ffcc) - Added `@RestrictedBindingSource` API to limit who can bind certain types/annotations - [documentation](https://github.com/google/guice/wiki/RestrictedBindingSource). - Added `Key.withAnnotation()` API to create keys of the same type with a different annotation - [commit](https://github.com/google/guice/commit/d071802d48a50dffd89b0cfc61eff251251e637a) - `ModuleAnnotatedMethodScanner` behavior changes: - Forbid installing modules with custom provides methods from a ModuleAnnotatedMethodScanner - Issue error when a scanner tries to register another scanner - Fixed order-dependent private module scanner inheritance - Fixed infinite recursion if `OptionalBinder` links one key to the same key - Updated the Guava and ASM versions ###### TestLib - Added `BoundFieldModule.WithPermits` to support using restricted binding source with `BoundFieldModule`. ###### Multibindings - Removed multibinds extension since it has been included as part of Guice core since 4.2 release. ###### AssistedInject - Improve the way AssistedInject invokes factory methods, to avoid triggering illegal reflection warnings. Users may need to newly call FactoryModuleBuilder.withLookups. Guice will log a warning if this is required. ###### Dagger Adapter - Added [`DaggerAdapter.Builder`](https://google.github.io/guice/api-docs/5.0.1/javadoc/com/google/inject/daggeradapter/DaggerAdapter.Builder.html) for setting configuration options on `DaggerAdapter` #### Migrating from 4.2.3 See the [JDiff change report](http://google.github.io/guice/api-docs/5.0.1/api-diffs/index.html) for complete details. ##### Using Multibinding extension If your project dependent on Guice multibindings extension, simply remove the dependency since it's included as part of Guice core. ##### Using Guice no-AOP version If you were using Guice no-aop version, simply switch to the standard version of Guice. Previous versions of Guice with no-aop did not use runtime bytecode generation. Starting with this release runtime bytecode generation is enabled by default and can be disabled by setting `-Dguice_bytecode_gen_option=DISABLED`. ##### Migrate away from `ProvisionListener.getDependencyChain` API Some use cases can be replaced by inferring the current chain via `ThreadLocals` in the listener, other use cases can use the static dependency graph. For example, ```java bindListener(Matchers.any(), new MyListener()); ... private static final class MyListener implements ProvisionListener { private final ThreadLocal>> bindingStack = new ThreadLocal>>() { @Override protected ArrayDeque> initialValue() { return new ArrayDeque<>(); } }; @Override public void onProvision(ProvisionInvocation invocation) { bindingStack.get().push(invocation.getBinding()); try { invocation.provision(); } finally { bindingStack.get().pop(); } // Inspect the binding stack... } } ``` In this example the `bindingStack` thread local will contain a data structure that is very similar to the data returned by `ProvisionListener.getDependencyChain`. The main differences are that linked keys are not in the stack, but such edges do exist in the static dependency graph, so you could infer some of the missing edges.