question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WARNING: Illegal reflective access by com.google.inject.assistedinject.FactoryProvider2

See original GitHub issue

I’m seeing this warning when starting Gerrit with Java11:

$ java -jar bazel-bin/release.war init -d ../test_site_gerrit_3.2 --batch --dev
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.assistedinject.FactoryProvider2 (file:/home/davido/.gerritcodereview/tmp/gerrit_6966619352392581698_app/guice-assistedinject-4.2.3.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of com.google.inject.assistedinject.FactoryProvider2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

The code has even “this isn’t a public API” comment:

https://github.com/google/guice/blob/master/extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider2.java#L900-L915

// Note: this isn't a public API, but we need to use it in order to call default methods on (or
  // with) non-public types.  If it doesn't exist, the code falls back to a less precise check.
  private static final Constructor<MethodHandles.Lookup> methodHandlesLookupCxtor =
      findMethodHandlesLookupCxtor();

  private static Constructor<MethodHandles.Lookup> findMethodHandlesLookupCxtor() {
    try {
      Constructor<MethodHandles.Lookup> cxtor =
          MethodHandles.Lookup.class.getDeclaredConstructor(Class.class, int.class);
      cxtor.setAccessible(true);
      return cxtor;
    } catch (ReflectiveOperationException ignored) {
      // Ignore, the code falls back to a less-precise check if we can't create method handles.
      return null;
    }
  }

See also this upstream issue: [1].

[1] https://crbug.com/gerrit/12639

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ogregoirecommented, Oct 30, 2020

I was kind of hoping this would be fixed by 5.0.0-BETA-1, but nope, it’s still there.

0reactions
davidocommented, Jan 10, 2021

Encountered this issue while initializing Gerrit 3.3.1 using JDK 12.0.1. Looks like the issue isn’t fixed

Correct.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Guice error, "An illegal reflective access operation ...
The issue is due to how Guice internally accesses Java objects, which is unsafe under the new (Java 9+) Java Module System.
Read more >
12639 - WARNING: An illegal reflective access operation has ...
That looks like a problem in Guice Assisted Inject v4.2.3: FactoryProvider2 is breaking strong encapsulation. The test *IS* with Vanilla Gerrit.
Read more >
New gerrit install 3.3.3 - get this strange error - Google Groups
WARNING: An illegal reflective access operation has occurred. WARNING: Illegal reflective access by com.google.inject.assistedinject.FactoryProvider2 ...
Read more >
Unhelpful error on web UI, logs don't seem to show any issues
WARNING : Illegal reflective access by com.google.inject.assistedinject.FactoryProvider2$MethodHandleWrapper (file:/usr/sha
Read more >
[JENKINS-46620] [JDK9] Illegal reflective access from guice 4.0
WARNING : Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$2 (file:/var/jenkins_home/war/WEB-INF/lib/guice-4.0.jar) to method ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found