611 Commits
Author SHA1 Message Date
cpovirk 174317a08a [Migrate](https://bazel.build/external/migration) to Bazel's ["new" module system](https://bazel.build/external/overview).
My immediate win is that this includes migrating off the old version of bazel-common that includes `google_common_workspace_rules()`: Calling `google_common_workspace_rules()` leads to trouble under macos-latest (as previously in https://github.com/google/guice/commit/17011080a118fc2d23314ccf0d5546ce53e8b650):

```
  ERROR: /Users/runner/work/guice/guice/WORKSPACE:26:30: fetching android_sdk_repository rule //external:androidsdk: Android SDK api level 34 was requested but it is not installed in the Android SDK at /Users/runner/Library/Android/sdk. The api levels found were [36, 35]. Please choose an available api level or install api level 34 from the Android SDK Manager.
  ERROR: Analysis of target '//tools:osgi_wrapper' failed; build aborted: Android SDK api level 34 was requested but it is not installed in the Android SDK at /Users/runner/Library/Android/sdk. The api levels found were [36, 35]. Please choose an available api level or install api level 34 from the Android SDK Manager.
```

RELNOTES=n/a
PiperOrigin-RevId: 957370304
2026-07-31 15:50:31 -07:00
Liam Miller-Cushon 74adac007a Automated Code Change
PiperOrigin-RevId: 830474625
2025-11-10 09:21:59 -08:00
cpovirk 2a1d0fb47c Prepare for changes in how Truth prints class names.
Truth will soon:
- print only the simple name for some well-known classes (e.g., print "NullPointerException" instead of "java.lang.NullPointerException")
- print the canonical name where available instead of the binary name (e.g., print "com.google.Foo.BarException" instead of "com.google.Foo$BarException"

This CL updates callers to accept both versions.

RELNOTES=n/a
PiperOrigin-RevId: 775721999
2025-06-25 09:29:31 -07:00
Sam Berlin b82cc7bbdf Eagerly ensure that user-supplied providers always return the expected type. Historically this was implicitly validated upon injection into whatever used the provider (via reflection magic). However, with the shift to MethodHandles, that particular signature check becomes harder to isolate/replicate without adding a bunch of unnecessary overhead. Thus, we instead change this to validate user-supplied providers when they provide the value (which is the soonest it can go wrong).
PiperOrigin-RevId: 752295067
2025-04-28 07:14:26 -07:00
Luke Sandberg 54f53e812e Fix javacopts for guice tests to also set --source 11
PiperOrigin-RevId: 721030889
2025-01-29 10:40:57 -08:00
Kurt Alfred Kluever 552f30e2ee Automated Code Change
PiperOrigin-RevId: 711437477
2025-01-02 08:53:20 -08:00
Guice Team d83f6770aa Load the builtin Bazel java rules from @rules_java
PiperOrigin-RevId: 689368258
2024-10-24 07:10:13 -07:00
Kurt Alfred Kluever 2418a65f87 Automated Code Change
PiperOrigin-RevId: 659586785
2024-08-05 09:57:21 -07:00
Guice Team df10bedd59 Automated Code Change
PiperOrigin-RevId: 659586774
2024-08-05 09:56:06 -07:00
Sam Berlin 17011080a1 Update to latest bazel-common that has a newer android API level, so it works on the latest macos on github. Also update to the latest Bazel version that supports JavaInfo rule imports, and fix things that break w/ the latest bazel version (requiring imports for defining package statements if a package_info.java exists, and not using @local_jdk//:jar).
PiperOrigin-RevId: 631081930
2024-05-06 11:03:04 -07:00
Guice Team 2d4a3952ee Automated Code Change
PiperOrigin-RevId: 619545649
2024-03-27 08:52:52 -07:00
cpovirk 018f28f701 Remove empty plugins lists.
RELNOTES=n/a
PiperOrigin-RevId: 617628676
2024-03-20 14:38:32 -07:00
Guice Team ddb6315362 Fixup for a common typo.
PiperOrigin-RevId: 547836342
2023-07-13 10:10:21 -07:00
dependabot[bot] ec227cce3e Bump struts2-core from 2.5.30 to 2.5.31 in /extensions/struts2
Bumps [struts2-core](https://github.com/apache/struts) from 2.5.30 to 2.5.31.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/apache/struts/releases">struts2-core's releases</a>.</em></p>
<blockquote>
<h2>Struts 2.5.31</h2>
<h2>What's Changed</h2>
<ul>
<li><a href="https://github.com/apache/struts/commit/2d6f1bc0a6f5ac575a56784ac6461816b67c4f21">Fixes</a> addressing <a href="https://cwiki.apache.org/confluence/display/WW/S2-063">S2-063</a> &amp; <a href="https://cwiki.apache.org/confluence/display/WW/S2-064">S2-064</a> by <a href="https://github.com/yasserzamani"><code>@​yasserzamani</code></a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/apache/struts/compare/STRUTS_2_5_30...STRUTS_2_5_31">https://github.com/apache/struts/compare/STRUTS_2_5_30...STRUTS_2_5_31</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/apache/struts/commits">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=org.apache.struts:struts2-core&package-manager=maven&previous-version=2.5.30&new-version=2.5.31)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/google/guice/network/alerts).

</details>

Fixes #1749

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/guice/pull/1749 from google:dependabot/maven/extensions/struts2/org.apache.struts-struts2-core-2.5.31 e9b9ddecac
PiperOrigin-RevId: 541919125
2023-06-20 07:44:26 -07:00
Guice Team 6412858fca Internal change.
PiperOrigin-RevId: 538300298
2023-06-06 15:00:05 -07:00
Sam Berlin c58bc33b90 A bunch of environment changes.
* Bump minimum JRE to 11 (from 8).
* Change testing matrix from {8,11,15,17} to {11,17,21-ea}. (Except the bazel build has trouble parsing "21-ea" as a java version, so s/21-ea/20 for bazel.)
* Also test on macos (but only with jdk17). (Attempted to test on windows too, but there's issues right now.)
* Cleanup the POMs a little bit (remove unused mailing list reference, fix CI link)
* Bump bazel version to 6.2.0, otherwise the tests fail b/c they try to set a security manager (see https://github.com/bazelbuild/bazel/issues/14502, which was fixed in https://github.com/bazelbuild/bazel/commit/7556e1107b666d10b660470a571631463c7eb4ec, which was cherrypicked into the 6.2.0 release). This also required suppressing the "BanJNDI" errorprone check in the JNDI extension, which was also added to 6.2.0. (A future change should probably just remove the JNDI extension altogether.)

PiperOrigin-RevId: 532849632
2023-05-17 11:22:54 -07:00
Sam Berlin 24324ca6c6 Prepare for the Guice 6.0 & 7.0 releases. This change does the following:
* Bumps the snapshot version to 7.0.1-SNAPSHOT
* Adds Guice 6 & Guice 7 release pages, with explanations of the jakarta transition & how Guice 6.0 & 7.0 should be used. They also include changelogs since 5.1.0.
* Updates the top-level README to reference the 6.0 & 7.0 releases, as well as including "installation instructions" (which fixes #1698).
* Updates the wiki to make sure it's meaningful for both javax & jakarta references, pointing to the correct ones where appropriate.

PiperOrigin-RevId: 529770936
2023-05-05 11:33:15 -07:00
Sam Berlin 49b1a33c59 Remove redundant references to javax.{inject,persistence,servlet} and replace the rest with their jakarta variants.
This required upgrading some test dependencies, because the tests need some impls of the APIs which only exist in newer releases.

This also removes the struts2 extension from the maven & bazel build (although it keeps the now-unused source), because struts2 has no release that supports jakarta. For users that want to continue using the struts2 extension, please continue to use the Guice 6.0 release (instead of the 7.0+ line, which will only support the jakarta dependencies).

Fixes #1383.

(I'll cut the 6.0 candidates/releases from before this commit, and if we need to make further 6.0 changes, I'll manually merge those into the 6.0 branch.)

PiperOrigin-RevId: 529504991
2023-05-04 13:50:43 -07:00
Sam Berlin 3bb74d7e3b Improve the error message if an EntityManager is provisioned before a unit if work is started, to help users transition to the new default that requires an explicit work open (or the legacy option set).
PiperOrigin-RevId: 529465168
2023-05-04 11:26:21 -07:00
Sam Berlin bb54925a2c Some prefactorings that will make it easier to add transformations that strip javax and only use the jakarta variants.
* BoundFieldModule: just say "Provider" and "Qualifier" instead of FQN of each.
* MapBinderTest/MultibinderTest/SpiUtils/ProvidersTest/googlecode.guice.BUILD: reorder some things so it's easier to strip the javax variants
* OptionalBinderTest: introduce a helper that the tests delegate to, so the strip directives can be consolidated
* ContinuingRequestIntegrationTest/ServletTest: Don't pass null for the response in tests that made that fail, pass mocks instead. Earlier HttpServlet impls allowed null, later HttpServlet impls don't allow null.
* ElementsTest: rename javax-referencing to "spec" so it makes sense when its transformed.
* InjectorSpiTest: Run the formatter, since the next CL would have changed this.
* BoundFieldModuleTest: Reference javax explicitly in some places, explicitly don't reference it in others.
* OSGiContainerTest: Add a TODO about the test's uselessness
* pom.xml: Enable maven test failures to include stack traces, so we have some idea WTF went wrong when things go wrong.

PiperOrigin-RevId: 529463507
2023-05-04 11:20:49 -07:00
Sam Berlin 75df9fc285 Fix a few more places where we should check jakarta variants: DaggerMethodScanner scopes and BytecodeGenTest.
PiperOrigin-RevId: 528900279
2023-05-02 15:11:08 -07:00
Sam Berlin 99d0e11294 Add a couple more missing @since tags.
PiperOrigin-RevId: 527669293
2023-04-27 13:36:37 -07:00
Sam Berlin 5eff2eabd4 Add support for jakarta.inject to core Guice.
This does not add support for `toProvider(...)` to instances of `jakarta.inject.Provider` or classes/keys/typeLiterals of type `jakarta.inject.Provider`. See https://github.com/google/guice/issues/1383#issuecomment-1523410855 for details of the plans. The Guice 6.0 release will support `javax.inject` _and_ `jakarta.inject` (excluding `toProvider()` support for `jakarta.inject`), and the Guice 7.0+ release will remove the `javax.inject` references.

Further background on these issues:
 * https://github.com/google/guice/pull/1630
 * https://github.com/google/guice/issues/1679
 * https://github.com/google/guice/issues/1490
 * https://github.com/google/guice/issues/1383

PiperOrigin-RevId: 527349023
2023-04-26 12:55:35 -07:00
Sam Berlin 8edbe68a06 Don't immediately lookup the linked binding associated with @ImplementedBy. Instead, defer it like a normal bind(X.class).to(Y.class) does. This ensures that later bindings of Y are used.
Much thanks goes to @nineninesevenfour for their investigation (in #1650), which made fixing this much easier.

Fixes #700 and fixes #1650.

PiperOrigin-RevId: 527048972
2023-04-25 12:52:54 -07:00
Ken Wenzel 356f6ba30c Set correct bundle version of fragment host. Fixes #1050 & fixes #1049. Much thanks to @kenwenzel and @mcculls for their help figuring out the right incantation for this.
PiperOrigin-RevId: 526290216
2023-04-22 09:06:16 -07:00
Sam Berlin e68fab6524 Don't automatically create an EntityManager outside of a UnitOfWork, because it leads to leaks. Fixes #739, fixes #997, fixes #730, fixes #985, fixes #959, fixes #731. This also adds an optional Options to the JpaPersistModule constructor, if users wish to use the legacy behavior. This is a breaking change, but to a better default value. Users who want to keep the dangerous form can opt back in with the options.
PiperOrigin-RevId: 526106112
2023-04-21 12:24:37 -07:00
Andres Viedma d882d5ed9f Don't wrap methods declared by Object in transactions. Fixes #958, fixes #788.
PiperOrigin-RevId: 526087773
2023-04-21 11:15:50 -07:00
Clemens Lieb 70ad639ea0 accomodate manually initiated rollbacks. Fixes #1137 & fixes #1136.
PiperOrigin-RevId: 525815800
2023-04-20 12:17:17 -07:00
Sebastian Kuerten 7ed6624d70 Fix a number of Javadoc typos. Fixes #1078
PiperOrigin-RevId: 525805514
2023-04-20 11:39:35 -07:00
Stuart McCulloch d857befb8a Remove some lingering references to Java 6 (Guice 5+ requires Java 8). Fixes #1171.
PiperOrigin-RevId: 525564737
2023-04-19 15:21:45 -07:00
Chris Parton 3e21a13dfe Update the persist service to ignore multiple start/stop calls, so it matches its javadoc. Fixes #1214, fixes #972, fixes #598.
PiperOrigin-RevId: 525556346
2023-04-19 14:47:59 -07:00
Sam Berlin 22dca18c8c Improve {Checked,Throwing}ProviderTest to allow exception types to be returned in any order from Method.getGenericExceptionTypes. Fixes #1603.
(This does not use the suggested code from the original PR, and does not attempt to change the `testManyMethods` method because we assume that repeated calls to `getDeclaredMethods` will always return the same order of methods. If that ever changes, we can deal with it then.)

PiperOrigin-RevId: 525220025
2023-04-18 12:35:49 -07:00
Sam Berlin 23c25d5e68 Bump struts2-core dependency to 2.5.30 & fix the struts2 test to work with the new version. Fixes #1624.
PiperOrigin-RevId: 525219685
2023-04-18 12:30:43 -07:00
Sam Berlin f67f9d19c2 Bump spring dependency to 5.3.18. Fixes #1620.
PiperOrigin-RevId: 525219514
2023-04-18 12:28:11 -07:00
Kurt Seebauer d98a4de1ea prevent NullPointerException if contextPath is null
Fixes #1656
Fixes #1655

PiperOrigin-RevId: 524374664
2023-04-14 13:38:51 -07:00
Guice Team 9ed45ab2c6 Open-source @Keep on Guice annotations.
PiperOrigin-RevId: 503916049
2023-01-23 01:19:00 -08:00
Guice Team 294065ccc1 All testing uses Mockito instead of EasyMock.
PiperOrigin-RevId: 498600399
2022-12-30 09:45:27 -08:00
Sam Berlin d6997b0ad0 Fix the remaining jdkhead issues by introducing a new "dollarSeparator" field in the existing internal Annotations configuration (that already did work to figure out if we need to quote strings or include value= prefixes). Update prior CL's code to use this new approach, update remaining tests to use this, and update some non-test code that emits annotation instance strings to delegate to this.
PiperOrigin-RevId: 481018326
2022-10-13 17:04:00 -07:00
Sam Berlin 286e076aa7 Revise some tests to assume less about the way annotations' toString is printed. Recent JDKs change the output to use '.' instead of '$' for nested annotations.
PiperOrigin-RevId: 480935880
2022-10-13 11:07:16 -07:00
Liam Miller-Cushon dd76086f16 Internal change
PiperOrigin-RevId: 475904314
2022-09-21 13:10:12 -07:00
Liam Miller-Cushon 22dd0c81e5 Internal change
PiperOrigin-RevId: 474656593
2022-09-15 14:24:37 -07:00
Liam Miller-Cushon b33cc40f72 Add --add-opens= configuration
PiperOrigin-RevId: 474647824
2022-09-15 14:24:11 -07:00
Guice Team b2554223cc LSC: Fix or suppress ignored return values from instance methods on an Object.
PiperOrigin-RevId: 429675699
2022-02-18 16:54:46 -08:00
David P. Baker 6bc51218d9 Add @CheckReturnValue to com.google.inject.testing.fieldbinder.BoundFieldModule#of(java.lang.Object) and add var unused to existing violations.
PiperOrigin-RevId: 429145212
2022-02-16 14:47:38 -08:00
Guice Team a565b63eae Validate that the transitively exported targets matches what is set in gen_maven_artifact.
PiperOrigin-RevId: 428634587
2022-02-14 16:20:43 -08:00
Guice Team ad77056d77 Fix Javadoc that fails when running with Java 9+.
Also:

- configure bazel and maven to use the same -Xdoclint option
- skip maven tests when generating javadoc and API diffs
- fix shell script to fail when any command returned non-zero exit code
- fix issue with the script that errors when trying to generate API diffs for module that does not contain Java doc (e.g extensions-parent)

PiperOrigin-RevId: 427018267
2022-02-07 14:31:32 -08:00
Guice Team c118f26385 Add steps in the ci workflow to build and test local artifacts.
Also:

- cache more bazel files to speed up executation
- use java version as part of the cache key since it is part of the input bazel uses
- fix maven_gen_artfiacts for libries that export other libries

PiperOrigin-RevId: 426955192
2022-02-07 10:35:41 -08:00
Kurt Alfred Kluever 415a377e3b Use ImmutableMap.Builder.buildOrThrow() instead of deprecated build().
PiperOrigin-RevId: 425938253
2022-02-02 11:41:49 -08:00
Guice Team 757d472e6c Add support to build maven artifacts using bazel.
The setup is mostly based on Dagger's setup and simplified. Further changes might be required to ensure that we are actually deploying the same artifacts as existing maven setup.

PiperOrigin-RevId: 425912979
2022-02-02 10:22:39 -08:00
Guice Team 155bc42345 Remove service and mini extensions.
PiperOrigin-RevId: 424972746
2022-01-28 15:37:29 -08:00