lessthanoptimal / ejml

A fast and easy to use linear algebra library written in Java for dense, sparse, real, and complex matrices.

Home Page:https://ejml.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.lang.NoSuchMethodError: org.ejml.UtilEjml.reshapeOrDeclare

xishen opened this issue · comments

commented

I just downloaded the latest code and built and installed locally with maven. However when I ran my code, both Java 8 and 11 JVM crashed. Here is the stack dump:
java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
at java.lang.Thread.run (Thread.java:829)
Caused by: java.lang.NoSuchMethodError: 'org.ejml.data.ReshapeMatrix org.ejml.UtilEjml.reshapeOrDeclare(org.ejml.data.ReshapeMatrix, org.ejml.data.ReshapeMatrix, int, int)'
at org.ejml.dense.row.CommonOps_MT_FDRM.multTransB (CommonOps_MT_FDRM.java:142)
at com.atg.Linear.ejmlCosineHalfBatch (Linear.java:79)
at com.atg.Linear.main (Linear.java:183)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:297)
at java.lang.Thread.run (Thread.java:829)

Any help?

commented

I tried 0.40, 0.41 and 0.42-SNAPSHOT all failed but 0.39 worked.

I'm seeing several variants of that function inside of UtilEjml and it looks like they were last modified September 2020. Could you paste the code? Maybe the specific variant you're using got refactored.

commented

The following is the code:
private static FMatrixRMaj ejmlCosineHalfBatch(float[] raw) { FMatrixRMaj mat = FMatrixRMaj.wrap(SAMPLE_COUNT, FEATURE_COUNT, raw); FMatrixRMaj result = new FMatrixRMaj(SAMPLE_COUNT, SAMPLE_COUNT); CommonOps_MT_FDRM.multTransB(mat, mat, result); CommonOps_FDRM.elementDiv(result, normMatrix(mat)); return result; }

The exception is caused by CommonOps_MT_FDRM.multTransB(mat, mat, result) it also fails if the function is changed to CommonOps_FDRM.multTransB(mat, mat, result)

P.S.: I didn't use org.ejml.UtilEjml.reshapeOrDeclare directly.

For sake of completeness, can you show you Gradle / Maven / whatever dependency on EJML?

commented

Here is the maven dependency:

<dependency>

  <groupId>org.ejml</groupId>

  <artifactId>ejml-all</artifactId>

  <version>0.42-SNAPSHOT</version>

</dependency>

And the JDK version:

<maven.compiler.source>1.8</maven.compiler.source>

<maven.compiler.target>1.8</maven.compiler.target>
 ...

But EJML was built by JDK11.

commented

I'm seeing several variants of that function inside of UtilEjml and it looks like they were last modified September 2020. Could you paste the code? Maybe the specific variant you're using got refactored.

If I used the variant of the function that didn't exist directly the Java compiler would report an error rather than a runtime exception.

commented

This is what I found within the class file of CommonOps_MT_FDRM.class:

    public static <T extends FMatrix1Row> T multTransB( T a, T b, @Nullable T output ) {
    output = reshapeOrDeclare(output, a, a.numRows, b.numRows);
    UtilEjml.checkSameInstance(a, output);
    UtilEjml.checkSameInstance(b, output);
    MatrixMatrixMult_MT_FDRM.multTransB(a, b, output);
    return output;
}

The second line is the call site.

commented

I've also found something is odd that the class file (UtilEjml.class) has no definition of any reshapeOrDeclare() variants. Looks like the java compiler has removed them Completely. Unlike the source code of UtilEjml.java, the first method in the class file is checkSameInstance() followed by CheckSameShape() instead of reshapeOrDeclare()

Java compiler doesn't remove any code even it is unreachable. Maybe the version of ejml is messed up in my machine.

That's really bizarre. Could there be a dependency on an ancient version of EJML hidden in the project?

Is it possible to make a very simple project and reproduce this?

commented

Is it possible to make a very simple project and reproduce this?

you are right! ;-) Stanford NLP has introduced a implicit dependency on an old version (0.39) of EJML which messed up maven :-( case closed!