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.

withObjectMocked leads to "java.lang.NoSuchFieldException: modifiers"

See original GitHub issue

I’m using java 8 and scala 2.12.

Is withObjectMocked supported in Java 8?

[info]   java.lang.NoSuchFieldException: modifiers
[info]   at java.base/java.lang.Class.getDeclaredField(Class.java:2412)
[info]   at org.mockito.ReflectionUtils$.setFinalStatic(ReflectionUtils.scala:128)
[info]   at org.mockito.MockitoEnhancer.withObjectMocked(MockitoAPI.scala:641)
[info]   at org.mockito.MockitoEnhancer.withObjectMocked$(MockitoAPI.scala:630)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mazers0129commented, May 30, 2022

temporary… I add vm option to my test. –add-opens java.base/java.lang=ALL-UNNAMED –add-opens java.base/java.lang.reflect=ALL-UNNAMED

it work for me!!

  • ENV - jdk17 scala 2.6.19 mockito-scala-scalatest 1.17.7
0reactions
kurtrwallcommented, Feb 17, 2022

I’m seeing this using Java 8, Scala 2.12, mockito v1.17.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Mockito][withObjectMocked]NoSuchFieldException: MODULE
I can't test a simple example of withObjectMocked, and I still get this exception : Caused by: java.lang.NoSuchFieldException: MODULE$.
Read more >
[DISCUSS] Refactoring unit tests which changed modifiers of ...
Hi all Since the latest LTS Java 17 has been released, it's better to support ... It will cause `java.lang.NoSuchFieldException: modifiers`.
Read more >
mockito mockito-scala Issues - Giters
mockito mockito-scala: Mockito for Scala language. ... withObjectMocked leads to "java.lang.NoSuchFieldException: modifiers". Updated 6 months ago 11 ...
Read more >
[Mockito][withObjectMocked]NoSuchFieldException: MODULE
I can't test a simple example of anycodings_scala withObjectMocked, and I still get this anycodings_scala exception : Caused by: java.lang.
Read more >
mockito-scala - Github Plus
withObjectMocked leads to "java.lang.NoSuchFieldException : modifiers". I'm using java 8 and scala 2.12. Is withObjectMocked supported in Java 8?
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