rdf

Bart Kleijngeld 2022-09-22T13:40:00.693179Z

I'm trying to compile a GraalVM native image for our application, but the RDF4j dependency causes an reflection related issue:

Exception: #error {
 :cause Class org.eclipse.rdf4j.model.IRI[] is instantiated reflectively but was never registered.Register the class by adding "unsafeAllocated" for the class in reflect-config.json.
 :via
We're trying out https://www.graalvm.org/22.2/reference-manual/native-image/dynamic-features/Reflection/#manual-configuration from the GraalVM docs, but to no avail yet. It is remarkable that IRI seems to be understood to be a class, where really it's an interface. Maybe that's (part of) the cause of this issue? Anyways, before delving into more detail, I was mostly hoping someone (perhaps @rickmoynihan?) has already gotten this to work at some point.

2022-10-19T08:05:50.258619Z

👍 sorry for the late reply — I was on paternity leave.

2022-10-19T08:05:57.256289Z

but glad you got it working

🙂 1
2022-09-24T09:21:44.713539Z

Hi, Yeah, that does look a bit strange… I suspect the array of IRI’s is due to a variadic method in the RDF4j API. Yes, I’ve managed to get code to work under graalvm, with RDF4j. However I don’t recall seeing this specific issue. Though on at least one of the occasions I got graalvm to generate the config for me…. On that project I do see

{
  "name":"org.eclipse.rdf4j.model.IRI"
},
in my reflect-config.json. It looks to me like you’re trying to instantiate an array of IRI’s… I suspect there are more clues in the stack trace you removed from the paste… in particular the call site of the reflective call. Beyond further interogating the stack trace; I’d suggest you get graal to generate a config via instrumentation and see if it works… then you can work to trim that config down.

Bart Kleijngeld 2022-09-24T12:32:19.722829Z

Alright, good to know it should be possible. Is there any way for me to get a look at that reflect-config.json for inspiration? I did generate one with the tracing agent, and also built one myself, but this specific issue I haven't yet been able to surpass

Bart Kleijngeld 2022-09-24T12:48:31.151749Z

Running different scenarios to cover more code paths with the tracing agent seemed to have helped discovering more cases of reflection. The generated config seems to have alleviated the issue 🙂. I do get another error, but I'll see if I can get that fixed. It works! Thanks

quoll 2022-09-22T14:11:34.770109Z

It’s an interface, but it’s being instantiated reflectively?

quoll 2022-09-22T14:11:42.086939Z

Something seems off with that

Bart Kleijngeld 2022-09-22T14:14:06.216219Z

Yes, I thought so too. I'm ready to read up and delve in, but before I do I just hope someone here already has gone through the experience of getting RDF4j to work in a GraalVM native image at least.