Skip to content
Advertisement

qbit boon reflect ClassCastException: [B incompatible with [C

I am trying to use qbit (https://github.com/advantageous/qbit) for the first time, and I have to deal with all dependencies manually (can’t use maven etc.)

I am getting the following exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.J9VMInternals.ensureError(J9VMInternals.java:186)
at java.base/java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:175)
at io.advantageous.boon.core.reflection.Reflection.<clinit>(Reflection.java:114)
at io.advantageous.boon.core.reflection.ClassMeta.classMeta(ClassMeta.java:271)
at io.advantageous.qbit.QBit.registerReflectionAndJsonParser(QBit.java:68)
at io.advantageous.qbit.QBit.doGetFactory(QBit.java:57)
at io.advantageous.qbit.QBit.factory(QBit.java:45)
at io.advantageous.qbit.http.server.HttpServerBuilder.getFactory(HttpServerBuilder.java:136)
at io.advantageous.qbit.http.server.HttpServerBuilder.build(HttpServerBuilder.java:236)
at com.myapp.main(App.java:92)
Caused by: java.lang.ClassCastException: [B incompatible with [C
at
io.advantageous.boon.core.reflection.FastStringUtils$StringImplementation$1.toCharArray (FastStringUtils.java:93)
at io.advantageous.boon.core.reflection.FastStringUtils.toCharArray(FastStringUtils.java:178)
at io.advantageous.boon.core.Str.underBarCase(Str.java:538)
at io.advantageous.boon.core.Sys.sysProp(Sys.java:329)
at io.advantageous.boon.core.timer.TimeKeeperBasic.<init>(TimeKeeperBasic.java:52)
at io.advantageous.boon.core.Sys.<clinit>(Sys.java:171)
... 9 more

The jar files I have added so far as dependencies are:

  • qbit-core-2.0.0.jar
  • qbit-web-0.8.18.jar — I have also tried not including this, but it seems to make no difference either way
  • boon-reflekt-0.6.6.jar

I have also tried adding the following, which seem to be dependencies according to maven, but with no success:

  • reactive-streams-1.0.0.jar
  • boon-json-0.6.6.jar
  • metrik-0.1.0.jar
  • slf4j-api-1.7.30.jar

Additionally, my project uses:

  • curator-recipes-4.2.0.jar
  • curator-x-discovery-4.2.0.jar
  • org.json.jar (not sure which version I have but the jar is from 18th September 2017)

Would anyone be able to tell me what I’m missing? The maven link for qbit is: https://search.maven.org/search?q=io.advantageous.qbit

Advertisement

Answer

The problem is that the you are using Java 9+ and the boon dependency hasn’t been updated for Java 9+. The FastStringUtils class within this library does some reflective hackery to access internal fields of the String class, but the internal fields of String changed in Java 9.

This GitHub issue was opened in November 2015 for this problem and is still open almost five years later.

The workarounds are either to run your application in Java 8, or to run your project with the system property io.advantageous.boon.faststringutils.disable set to true. You can do this by adding the command-line argument -Dio.advantageous.boon.faststringutils.disable=true, or by adding the line

System.setProperty("io.advantageous.boon.faststringutils.disable", "true");

to your App class’s main method, before it calls the build() method shown in the stacktrace.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement