Skip to content

CharSequence::isEmpty was added in JDK15 so override in CharSeq to resolve ambiguity

Duncan Mak requested to merge duncanmak/Kawa:isempty-in-jdk15 into master

I installed Oracle's JDK15 on my M1 MacBook Air:

duncan@ateji Kawa % java --version
java 15.0.2 2021-01-19
Java(TM) SE Runtime Environment (build 15.0.2+7-27)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)

When I tried to compile Kawa, I saw this error:

javac -d . -classpath ".:.:$CLASSPATH" -g @tmp-sources1.list
./gnu/lists/CharSeq.java:11: error: types CharSequence and Sequence<E> are incompatible;
public interface CharSeq
       ^
  interface CharSeq inherits abstract and default for isEmpty() from types CharSequence and Sequence
  where E is a type-variable:
    E extends Object declared in interface Sequence

I see that isEmpty was added to CharSequence in JDK 15: https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/CharSequence.html#isEmpty()

I think this patch fixes the issue.

Merge request reports