Skip to content

build and test fails with OpenJDK11 #5

@ostueker

Description

@ostueker

I noticed the build of Euclid fails when using OpenJDK11:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project euclid: Compilation failure
[ERROR] /home/travis/build/BlueObelisk/euclid/src/main/java/blogspot/software_and_algorithms/stern_library/data_structure/ThriftyList.java:[1043,30] reference to toArray is ambiguous
[ERROR]   both method <T>toArray(java.util.function.IntFunction<T[]>) in java.util.Collection and method <U>toArray(U[]) in blogspot.software_and_algorithms.stern_library.data_structure.ThriftyList match

I've managed to get the build working with this:

diff --git a/src/main/java/blogspot/software_and_algorithms/stern_library/data_structure/ThriftyList.java b/src/main/java/blogspot/software_and_algorithms/stern_library/data_structure/ThriftyList.java
index 0b5a091..6dc166d 100644
--- a/src/main/java/blogspot/software_and_algorithms/stern_library/data_structure/ThriftyList.java
+++ b/src/main/java/blogspot/software_and_algorithms/stern_library/data_structure/ThriftyList.java
@@ -1040,7 +1040,7 @@ public class ThriftyList<T> extends AbstractList<T> implements List<T>,
         */
        @Override
        public T[] toArray() {
-               return (T[]) toArray(null);
+               return (T[]) toArray((Object[]) null);
        }
 
        /**

However I really can't tell whether this would be the right thing to do.


There are also some tests that are failing with OpenJDK11:

target/surefire-reports/org.xmlcml.euclid.test.PolarTest.txt

-------------------------------------------------------------------------------
Test set: org.xmlcml.euclid.test.PolarTest
-------------------------------------------------------------------------------
Tests run: 17, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec <<< FAILURE! - in org.xmlcml.euclid.test.PolarTest
testPlus(org.xmlcml.euclid.test.PolarTest)  Time elapsed: 0.001 sec  <<< FAILURE!
java.lang.AssertionError: polar expected:<60.0> but was:<60.000000000000014>
	at org.junit.Assert.fail(Assert.java:91)
	at org.junit.Assert.failNotEquals(Assert.java:645)
	at org.junit.Assert.assertEquals(Assert.java:441)
	at org.xmlcml.euclid.test.PolarTest.testPlus(PolarTest.java:138)

Here the precision is just out of the bounds of EPS.

target/surefire-reports/org.xmlcml.euclid.test.IntArrayTest.txt

-------------------------------------------------------------------------------
Test set: org.xmlcml.euclid.test.IntArrayTest
-------------------------------------------------------------------------------
Tests run: 58, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.034 sec <<< FAILURE! - in org.xmlcml.euclid.test.IntArrayTest
testElementAt(org.xmlcml.euclid.test.IntArrayTest)  Time elapsed: 0.001 sec  <<< FAILURE!
org.junit.ComparisonFailure: ArrayIndexOutOfBoundsException expected:<[5]> but was:<[Index 5 out of bounds for length 4]>
	at org.junit.Assert.assertEquals(Assert.java:123)
	at org.xmlcml.euclid.test.IntArrayTest.testElementAt(IntArrayTest.java:229)

testGetSubArray(org.xmlcml.euclid.test.IntArrayTest)  Time elapsed: 0 sec  <<< FAILURE!
org.junit.ComparisonFailure: subArray ArrayIndexOutOfBoundsException expected:<...OutOfBoundsException[]> but was:<...OutOfBoundsException[: arraycopy: last source index 6 out of bounds for int[4]]>
	at org.junit.Assert.assertEquals(Assert.java:123)
	at org.xmlcml.euclid.test.IntArrayTest.testGetSubArray(IntArrayTest.java:375)

target/surefire-reports/org.xmlcml.euclid.test.RealArrayTest.txt

-------------------------------------------------------------------------------
Test set: org.xmlcml.euclid.test.RealArrayTest
-------------------------------------------------------------------------------
Tests run: 88, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.14 sec <<< FAILURE! - in org.xmlcml.euclid.test.RealArrayTest
testElementAt(org.xmlcml.euclid.test.RealArrayTest)  Time elapsed: 0.001 sec  <<< FAILURE!
org.junit.ComparisonFailure: ArrayIndexOutOfBoundsException expected:<[5]> but was:<[Index 5 out of bounds for length 4]>
	at org.junit.Assert.assertEquals(Assert.java:123)
	at org.xmlcml.euclid.test.RealArrayTest.testElementAt(RealArrayTest.java:537)

testGetSubArray(org.xmlcml.euclid.test.RealArrayTest)  Time elapsed: 0.001 sec  <<< FAILURE!
org.junit.ComparisonFailure: subArray ArrayIndexOutOfBoundsException expected:<...OutOfBoundsException[]> but was:<...OutOfBoundsException[: arraycopy: last source index 6 out of bounds for double[4]]>
	at org.junit.Assert.assertEquals(Assert.java:123)
	at org.xmlcml.euclid.test.RealArrayTest.testGetSubArray(RealArrayTest.java:714)

The other ones seem to choke on some more comprehensive error messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions