Skip to content

v1.17.1

Latest

Choose a tag to compare

@Gedochao Gedochao released this 17 Sep 10:19
· 1 commit to main since this release
c6fb50d

Java 8+ support in the pure Java test runner

Projects with no Scala on the class path are handled by a dedicated, pure Java test runner. It used to be compiled for
Java 17, which made it impossible to run such tests on an older JVM. It is now compiled for Java 8, so the whole
Java 8+ range is supported again.

//> using test.dep junit:junit:4.13.2
//> using test.dep com.novocode:junit-interface:0.11
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class MyTests {
  @Test
  public void addition() {
    assertEquals(4, 2 + 2);
    System.out.println("Tested on Java " + System.getProperty("java.version") + ", no Scala needed!");
  }
}
scala-cli test java-tests --jvm 8
# Tested on Java 1.8.0_492, no Scala needed!

Previously, the very same invocation would have died while loading the test runner itself:

Exception in thread "main" java.lang.UnsupportedClassVersionError: scala/build/testrunner/JavaDynamicTestRunner has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Note: Support for JDK <17 will likely be gradually deprecated, but running tests with Java 8+ is likely to be kept long-term for the sake of backwards compatibility.

Fixed by @Gedochao in #4473

Fixes

  • Support Java 8+ with Scala CLI's pure Java test runner by @Gedochao in #4473

Build and internal changes

Updates

Full Changelog: v1.17.0...v1.17.1