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.

Help wanted: compiling mockito with native-image

See original GitHub issue

I am trying to compile mockito with mock-maker-proxy with graalvm native image, and I got stuck with the plugin mechanism (At least the stacktrace point to that). (In preparation for having some mockito suppport in spring-native https://github.com/spring-projects-experimental/spring-native/issues/1063)

I know this maybe a little of topic, but having at least “some” mockito when running native tests made me get started with this.

What I’ve got so far is

  • some proxy config
  • some reflection config
  • basic compiler args

When I compile this example https://github.com/eiswind/native-mock-example

I get a NPE at:

     Caused by: java.lang.NullPointerException
       org.mockito.internal.configuration.plugins.Plugins.getStackTraceCleanerProvider(Plugins.java:26)
       org.mockito.internal.exceptions.stacktrace.StackTraceFilter.<clinit>(StackTraceFilter.java:20)
       com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
       com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)

from which I would guess that registry itself is null, but that makes only little sense. I added some --initialize-at-runtime for the plugins package but that didn’t do it.

So for know I can only hope that this is something of interest and I really would appreciate some pointers what to try.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
raphwcommented, Dec 7, 2022

It works already: https://gist.github.com/raphw/e0f6864ddcad69630d839c2eebaad818

But it requires some prework. As far as I know, the Graal team is working on something to ease this.

0reactions
mhalbrittercommented, Dec 5, 2022

I’ve added support for Mockito to the GraalVM reachability metadata and got the ProxyMockMaker to work, see here for more details.

The reachability metadata repo is a way to get non-compliant libraries to work nonetheless on GraalVM. Feel free to copy the GraalVM metadata files directly in the Mockito codebase (actually I would be very happy about that 😃).

What is the status of the other mock makers (particularly one which allows mocking of classes) on GraalVM?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Native Images with Spring Boot and GraalVM - Baeldung
Learn how to use Spring Native to compile and build native images using Buildpacks and GraalVM's native build tools.
Read more >
Spring Native documentation
Spring Native provides support for compiling Spring applications to native executables using the GraalVM native-image compiler.
Read more >
Spring Boot 2.3 + GraalVM Error encountered while parsing ...
I have a spring boot 2.3 app which I want to compile as a native image. I'm using GraalVM 20.1.0.r11-grl as the SDK/JDK...
Read more >
Ease creation of GraalVM native images using assisted ...
This post will show how we can use the new native image trace agent to generate ... Thus in this scenario the configuration...
Read more >
Testing Your Application - Quarkus
This currently does not support the @ApplicationPath() annotation to set the JAX-RS context path. Use the quarkus.resteasy.path config value instead if you want...
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