0

When I try to access Uint8ClampedArray from code running on the JVM, I get the error: java.lang.Error: A method defined in a JavaScript raw type of a Scala.js library has been called. This is most likely because you tried to run Scala.js binaries on the JVM. Make sure you are using the JVM version of the libraries.

What JVM library might resolve this run time error?

Do we have other ways to share this data structure across the JS and JVM builds of sbt-crossprojects?

Ben McKenneby
  • 481
  • 4
  • 15

1 Answers1

0

I'm afraid you cannot. Uint8ClampedArray is a class defined by the JavaScript standard library. It simply does not exist on the JVM.

You might want to look at java.nio.ByteBuffer for a portable solution, but keep in mind that it doesn't have the clamped behavior of Uint8ClampedArray. You'll have to wrap in a custom helper if you want that.

sjrd
  • 21,805
  • 2
  • 61
  • 91
  • Thank you for articulating this, sjrd. Right now I'm pursuing a design that abstracts this array data at a higher level and leaves low level manipulations to separate JVM and JS implementations. – Ben McKenneby Jun 13 '19 at 13:54