Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Native-tests are broken with GraalVM 22.1 #1561

Closed
mhalbritter opened this issue Mar 30, 2022 · 4 comments · Fixed by #1562
Closed

Native-tests are broken with GraalVM 22.1 #1561

mhalbritter opened this issue Mar 30, 2022 · 4 comments · Fixed by #1562
Labels
type: compatibility Native image compatibility issue
Milestone

Comments

@mhalbritter
Copy link
Contributor

Running for example the tests in commandlinerunner via mvn test -Pnative

Working version:

openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment GraalVM CE 22.0.0.2 (build 17.0.2+8-jvmci-22.0-b05)
OpenJDK 64-Bit Server VM GraalVM CE 22.0.0.2 (build 17.0.2+8-jvmci-22.0-b05, mixed mode, sharing)

Working output

Broken version (built from oracle/graal@3eb1d11):

openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment GraalVM 22.1.0-dev (build 17.0.3+4-jvmci-22.1-b02)
OpenJDK 64-Bit Server VM GraalVM 22.1.0-dev (build 17.0.3+4-jvmci-22.1-b02, mixed mode, sharing)

Broken output

Main problem seems to be

com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.mockito.plugins.PluginSwitch] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles=<comma-separated-config-files> and -H:DynamicProxyConfigurationResources=<comma-separated-config-resources> options.
@mhalbritter mhalbritter added the type: compatibility Native image compatibility issue label Mar 30, 2022
@mhalbritter mhalbritter added this to the 0.11.4 milestone Mar 30, 2022
@mhalbritter
Copy link
Contributor Author

mhalbritter commented Mar 30, 2022

It seems that the ResetMocksTestExecutionListener triggers Mockitos PluginRegistry.<init> which then tries to load plugins. Maybe there's a way to disable this listener, as Mockito is not supported at the moment?

@mhalbritter
Copy link
Contributor Author

mhalbritter commented Mar 30, 2022

Even when including all proxied interfaces via the following configuration, it still fails:

java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
        at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:88) ~[na:na]
        at jdk.proxy4.$Proxy305.getHandler(Unknown Source) ~[native-tests:na]
        at org.mockito.internal.util.MockUtil.isMock(MockUtil.java:110) ~[na:na]
        at org.mockito.internal.util.DefaultMockingDetails.isMock(DefaultMockingDetails.java:32) ~[na:na]
        at org.springframework.boot.test.mock.mockito.MockReset.get(MockReset.java:106) ~[native-tests:na]
        at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:82) ~[native-tests:na]
        at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:70) ~[native-tests:na]
        at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.beforeTestMethod(ResetMocksTestExecutionListener.java:57) ~[native-tests:na]
        at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:293) ~[native-tests:5.3.16]
        at org.springframework.test.context.junit.jupiter.SpringExtension.beforeEach(SpringExtension.java:174) ~[native-tests:5.3.16]

I used this proxy-config.json:

[
  [
    "org.mockito.plugins.PluginSwitch"
  ],
  [
    "org.mockito.plugins.MockMaker"
  ],
  [
    "org.mockito.plugins.MemberAccessor"
  ],
  [
    "org.mockito.plugins.StackTraceCleanerProvider"
  ],
  [
    "org.mockito.plugins.AnnotationEngine"
  ],
  [
    "org.mockito.plugins.MockitoLogger"
  ],
  [
    "org.mockito.plugins.MockResolver"
  ],
  [
    "org.mockito.plugins.InstantiatorProvider2"
  ]
]

@sdeleuze
Copy link
Contributor

Could you try to see if we can exclude it via MockitoExcludeFilter?

mhalbritter added a commit to mhalbritter/spring-native that referenced this issue Mar 31, 2022
- The failures occur because MockitoTestExecutionListener and
  ResetMocksTestExecutionListener tried to initialize Mockito,
  which isn't supported yet.
- This change ignores both listeners when running in AOT mode

Closes spring-atticgh-1561
mhalbritter added a commit to mhalbritter/spring-native that referenced this issue Mar 31, 2022
- The failures occur because MockitoTestExecutionListener and
  ResetMocksTestExecutionListener tried to initialize Mockito,
  which isn't supported yet.
- This change ignores both listeners when running in AOT mode

Closes spring-atticgh-1561
@mhalbritter
Copy link
Contributor Author

#1562 fixes this issue by using IgnoredFactoriesCodeContributor to ignore MockitoTestExecutionListener and ResetMocksTestExecutionListener when generating AOT code.

sdeleuze pushed a commit that referenced this issue Mar 31, 2022
- The failures occur because MockitoTestExecutionListener and
  ResetMocksTestExecutionListener tried to initialize Mockito,
  which isn't supported yet.
- This change ignores both listeners when running in AOT mode

Closes gh-1561
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: compatibility Native image compatibility issue
Development

Successfully merging a pull request may close this issue.

2 participants