Skip to content

$replace() throws org.graalvm.nativeimage.MissingReflectionRegistrationError #15

Description

@eddydee123

As it says in the title:

$ jsonata -v
dev-dev # this is actually v0.4 on Ubuntu 24.04 on WSL2

$ jsonata '$replace("John Smith and John Jones", "John", "Mr")'
Exception in thread "main" java.lang.RuntimeException: org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively invoke method public static java.lang.String com.dashjoin.jsonata.Functions.replace(java.lang.String,java.lang.Object,java.lang.Object,java.lang.Integer) without it being registered for runtime reflection. Add it to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
        at com.dashjoin.jsonata.Jsonata$JFunction.call(Jsonata.java:2226)
        at com.dashjoin.jsonata.Jsonata.applyInner(Jsonata.java:1746)
        at com.dashjoin.jsonata.Jsonata.apply(Jsonata.java:1678)
        at com.dashjoin.jsonata.Jsonata.evaluateFunction(Jsonata.java:1648)
        at com.dashjoin.jsonata.Jsonata._evaluate(Jsonata.java:190)
        at com.dashjoin.jsonata.Jsonata.evaluate(Jsonata.java:131)
        at com.dashjoin.jsonata.Jsonata.evaluate(Jsonata.java:2589)
        at com.dashjoin.jsonata.cli.Main.run(Main.java:162)
        at com.dashjoin.jsonata.cli.Main.main(Main.java:272)
Caused by: org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively invoke method public static java.lang.String com.dashjoin.jsonata.Functions.replace(java.lang.String,java.lang.Object,java.lang.Object,java.lang.Integer) without it being registered for runtime reflection. Add it to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.MissingReflectionRegistrationUtils.forQueriedOnlyExecutable(MissingReflectionRegistrationUtils.java:97)
        at java.base@20.0.2/java.lang.reflect.Method.acquireMethodAccessor(Method.java:77)
        at java.base@20.0.2/java.lang.reflect.Method.invoke(Method.java:575)
        at com.dashjoin.jsonata.Functions.call(Functions.java:2158)
        at com.dashjoin.jsonata.Jsonata$JFunction.call(Jsonata.java:2217)
        ... 8 more

For comparison, other string functions work correctly:

$ jsonata '$trim(" Hello \n World ")'
Hello World

$ jsonata '$uppercase("Hello World")'
HELLO WORLD

$ jsonata '$match("ababbabbcc",/a(b+)/)'
[
  {
    "match": "ab",
    "index": 0,
    "groups": [
      "b"
    ]
  },
  {
    "match": "abb",
    "index": 2,
    "groups": [
      "bb"
    ]
  },
  {
    "match": "abb",
    "index": 5,
    "groups": [
      "bb"
    ]
  }
]

$ jsonata '[1..5].$string()'
[
  "1",
  "2",
  "3",
  "4",
  "5"
]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions