guxingke/mini-jvm

test failed locally

BryceLee opened this issue · 4 comments

Tests in error:
test_fis(com.gxk.jvm.builtin.JavaIoTest)

Test success after deleting the method.(Jvm-core/src/test/java/com.gxk.jvm.builtin.JavaIoTest.test_fis)

use mvn package .

jvm-core module with mvn test phase depends on examle/target/example.jar .

@guxingke can Build Success but I can't.
The reason is the different JDK version:
my version is “1.8.0_121” and java.io.FileInputStream#available() is a native method.
But the author's JDK version is 1.8.192 and java.io.FileInputStream#available() is not a native method.
For making the project clear and small, The project will not adapt this
So the better method of learning this project is that making your environment like these: maven 3.3.9, Jdk 1.8.192 and on the MacOSX.

I download the latest JDK version 1.8.241 , build Success.

if you don't want to update jdk, another solution:

Manually doRegister FileInputStream#skip and FileInputStream#available for native methods before jdk1.8.192 in mini JVM. For example:

MetaSpace.registerMethod("java/io/FileInputStream_available_()I", frame -> {
      KObject thisObj = frame.popRef();
      FileInputStream extra = (FileInputStream) thisObj.getExtra();
      try {
        int available = extra.available();
        frame.pushInt(available);
      } catch (IOException e) {
        throw new UnsupportedOperationException();
      }
    });