Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.UnsatisfiedLinkError #155

Open
haaohao opened this issue Feb 17, 2022 · 2 comments
Open

java.lang.UnsatisfiedLinkError #155

haaohao opened this issue Feb 17, 2022 · 2 comments

Comments

@haaohao
Copy link

haaohao commented Feb 17, 2022

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 :

com.google.elemental2
elemental2-core
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

@niloc132
Copy link
Contributor

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.

@haaohao
Copy link
Author

haaohao commented Feb 18, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants