-
Notifications
You must be signed in to change notification settings - Fork 17
Strange error when doing a StdArrays.copyFrom
with a matrix using JDK 17
#11
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
Comments
This is not a problem with Scala. It is an issue with the JDK version. If I copy the Java code to my Scala project and run it their, it also fails. It does not help if set the java compiler options to use JDK 11, as per this project's POM (source and target). I am using Github's CodeSpaces, so that VM uses:
I am using on my local machine:
I am assuming version 17 should be backwards compatible, but it does not seem like it. Can this be considered a bug? |
StdArrays.copyFrom
with a matrixStdArrays.copyFrom
~~with a matrix~~ using JDK 17
StdArrays.copyFrom
~~with a matrix~~ using JDK 17StdArrays.copyFrom
with a matrix using JDK 17
Thanks for reporting this @hmf , I've tried the Java snippet with OpenJDK 11, 17 and 19 distributed by Zulu and it always passes, so I don't think it is a JDK version problem (or which distribution do you use?) Now I'll have to dig a bit deeper to understand how |
@hmf What version of Scala are you running, and is it identical across JVMs? |
@karllessard Thanks for the feedback. You are correct. I setup the CodeSpace to use JDK 17. It uses the following:
and all tests passed. On my machine I have:
which fails. Wondering how I can change the JDK version just to make sure. |
@Craigacp I am using Scala 3.2.1. Its compatible with JDK 11 and 17. I have not encountered such compatibility issues before. Going to see if I can check on this. |
Can you pull down OpenJDK 17.0.4.1 from your preferred JDK provider and check that locally? I wouldn't expect there to be that kind of bug in a point release, but such things happen very occasionally. |
I was first trying to see if I can use JDK 17.0.5 on the dev container. Failing that I will see what I can do on my system. Don't want to mess with it if I can (using deb packages). |
You can always download a tar.gz version, unpack that locally and then set |
Seems the JDK might not be my issue. I have on the dev container:
Not the Ubuntu build, but same JDK version. The dev container does not have the open version, so I cannot test that. I am starting to suspect the build script on my side. Going to clone and run locally to see what happens. EDIT: local execution also runs correctly. |
I have created a bare-bones Java project. It has only 1 dependency - NdArray (0.3.3). I use Mill for my build script. I then executed the test (no asserts) and got the same error. Checking the dependencies I get:
I am assuming this is all I need. I then created a fat jar and executed the Java application directly:
I have in the link below the the fat jar and the source code. Could any brave and generous soul run that and confirm that the exception occurs? After decompressing the contents please open the fat jar and confirm its contents or use a sandbox. In the meantime I will try and check the original Maven script for any differences. TIA |
I have gone through the Maven script and included all of the dependencies. I have added the following: val junitVersion = "5.6.2"
val jmhVersion = "1.21"
val junit = ivy"org.junit.jupiter:junit-jupiter-api:${junitVersion}"
val junitEngine = ivy"org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
val jmh = ivy"org.openjdk.jmh:jmh-core:${jmhVersion}"
val jmhGen = ivy"org.openjdk.jmh:jmh-generator-annprocess:${jmhVersion}" I then reactivated all the original asserts I have in the original test code. For good measure I have also added the export and opens module to the JVM fork arguments (although this seems to be used for compilation only, tested with and without). Once again the Once again in the link below is the compiled version of the fat jar. I have also included the source. Anyone care to execute this also? I don't see what else I can do to replicate the error I have, save create a Mill script in my fork for someone else to test. Suggestions welcomed. |
Hey @hmf , so I've ran both of your JARs in a docker image I can reproduce this error... But what I've noticed even more is that I did my previous tests with 0.4.0-SNAPSHOT and not 0.3.3 :-/ sorry for that. So on 0.3.3 it fails, on 0.4.0-SNAPSHOT it does not, I've just validated that. At this point, I cannot tell why. Can you please try using the snapshot version? We're planning to make the release of 0.4.0 before the end of the year.
|
@karllessard works perfectly. Both Java and Scala examples pass the tests. Should have figured this out too. Thank you very much. I have some additional code I can add to the existing test. If you like I can make a PR with these tests. Is this of interest to the project? If you like, I can close this issue. Once again thanks. |
Of course, please do, that'll be very appreciated! |
Uh oh!
There was an error while loading. Please reload this page.
Expected Behavior
Note: title changed - Strange error
interfacing with Scalawhen doing aStdArrays.copyFrom
with a matrix using JDK 17While exploring and documenting the Index API, I get errors when using Scala. I get a
java.nio.BufferOverflowException
exception. However, what seems like an equivalent Java test, has no problem. I expect the Scala code to work just as it does in Java. I am trying to replicate the error in Java.I understand that Scala is not a supported platform, but will appreciate any help. I have been at this for a week.
Actual Behavior
I have created a test that succeeds here . The relevant code is:
The equivalent Scala code is:
Steps to Reproduce the Problem
It is difficult for me get a failing example in Scala that anyone here could easily run and check. So my goal is to try and replicate this in Java. In particular I have found that the Java version does not follow the same path as the Scala code. When debugging the Java version I manually get this trace:
Note that with the Java version the
DataTransfer
class executes thecopyByElement [104]
method. The Scala code does asrcBuffer.copyTo [114]
. The testsrcDimensions.isSegmented()
seems to be different. The relevant code is shown below:So my question is, how can one change the Java test code so that a
srcDimensions.isSegmented()
is false and IsrcBuffer.copyTo
method is used.On another note, would it be interesting to provide additional tests as a PR, including the one above?
Specifications
The text was updated successfully, but these errors were encountered: