elemental2 icon indicating copy to clipboard operation
elemental2 copied to clipboard

java.lang.UnsatisfiedLinkError

Open haaohao opened this issue 2 years ago • 2 comments

Hi all, Recently, i am using the elemental2-core for using js type of Int8Array, but got exception. if anyone can tell what i am wrong. thanks.

jdk is 1.8 and 1.11

dependency is using : <groupId>com.google.elemental2</groupId> <artifactId>elemental2-core</artifactId> 1.1.0

java code is as below: ArrayBuffer buffer = new ArrayBuffer(8); Int8Array array = new Int8Array(buffer); DataView view = new DataView(buffer); view.setInt8(0, v);

but got below error: java.lang.UnsatisfiedLinkError: elemental2.core.DataView.setInt8(ID)V at elemental2.core.DataView.setInt8(Native Method) at game.creata.engine.worker.script.shell.VoxelViewTest.writeDouble(VoxelViewTest.java:24) at game.creata.engine.worker.script.shell.VoxelViewTest.testName(VoxelViewTest.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at junit.framework.TestCase.runTest(TestCase.java:177) at junit.framework.TestCase.runBare(TestCase.java:142) at junit.framework.TestResult$1.protect(TestResult.java:122) at junit.framework.TestResult.runProtected(TestResult.java:142) at junit.framework.TestResult.run(TestResult.java:125) at junit.framework.TestCase.run(TestCase.java:130) at junit.framework.TestSuite.runTest(TestSuite.java:241) at junit.framework.TestSuite.run(TestSuite.java:236) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArg

haaohao avatar Feb 17 '22 09:02 haaohao

It looks you are trying to run this from inside the JVM, instead of as JS, and that isn't going to work - these "native" methods are implemented by the browser, so the code must be executed in a browser. Specifically, these are meant to be used by GWT or J2CL, as opposed to other tools like JSweet or TeaVM which also enable you to transpile Java so that it can be run in as JavaScript.

If you happen to be using something like LibGDX to develop a game (which in turn uses GWT to create its HTML builds), you'll need to be sure to only use this class from your HTML code, not from your other platforms.

niloc132 avatar Feb 17 '22 15:02 niloc132

Hi niloc132,

Ok, noted. Know what I am wrong now, and i need to try other way to do that.

So Appreciate for your help

haaohao avatar Feb 18 '22 02:02 haaohao