Skip to content

Commit

Permalink
Enable build with Java 21 (nextflow-io#5030)
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Nathan Thorpe <[email protected]>
  • Loading branch information
pditommaso authored and nathanthorpe committed May 31, 2024
1 parent af6067f commit 446b604
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ allprojects {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(19)
languageVersion = JavaLanguageVersion.of(21)
// note: the use of Java 21 causes the error "NoClassDefFoundError: java/util/SequencedCollection"
// see also
// https://aphyr.com/posts/369-classnotfoundexception-java-util-sequencedcollection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,10 @@ class LazyMap implements Map<String,Object> {
@CompileStatic
class ConfigList implements List {

@Delegate
// note: excludes 'reversed' to prevent issues caused by the introduction
// of SequenceCollection by Java 21 when running on Java 20 or earlier
// see: https://github.com/nextflow-io/nextflow/issues/5029
@Delegate(excludes = ['reversed','addFirst','addLast','getFirst','getLast','removeFirst','removeLast'])
private List target

ConfigList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import static nextflow.ast.NextflowDSLImpl.OUT_PREFIX
@CompileStatic
class ChannelOut implements List<DataflowWriteChannel> {

private @Delegate List<DataflowWriteChannel> target
// note: excludes 'reversed' to prevent issues caused by the introduction
// of SequenceCollection by Java 21 when running on Java 20 or earlier
// see: https://github.com/nextflow-io/nextflow/issues/5029
@Delegate(excludes = ['reversed','addFirst','addLast','getFirst','getLast','removeFirst','removeLast'])
private List<DataflowWriteChannel> target

private Map<String,DataflowWriteChannel> channels

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ class InputsList implements List<InParam>, Cloneable {
return result
}

@Delegate
// note: excludes 'reversed' to prevent issues caused by the introduction
// of SequenceCollection by Java 21 when running on Java 20 or earlier
// see: https://github.com/nextflow-io/nextflow/issues/5029
@Delegate(excludes = ['reversed','addFirst','addLast','getFirst','getLast','removeFirst','removeLast'])
private List<InParam> target = new LinkedList<>()

List<DataflowReadChannel> getChannels() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class OutputsList implements List<OutParam>, Cloneable {
return result
}

@Delegate
// note: excludes 'reversed' to prevent issues caused by the introduction
// of SequenceCollection by Java 21 when running on Java 20 or earlier
// see: https://github.com/nextflow-io/nextflow/issues/5029
@Delegate(excludes = ['reversed','addFirst','addLast','getFirst','getLast','removeFirst','removeLast'])
private List<OutParam> target = new LinkedList<>()

List<DataflowWriteChannel> getChannels() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ import org.codehaus.groovy.runtime.InvokerHelper
@CompileStatic
class ArrayBag<E> implements Bag<E>, List<E>, KryoSerializable {

@Delegate(interfaces = false)
// note: excludes 'reversed' to prevent issues caused by the introduction
// of SequenceCollection by Java 21 when running on Java 20 or earlier
// see: https://github.com/nextflow-io/nextflow/issues/5029
@Delegate(interfaces = false, excludes = ['reversed','addFirst','addLast','getFirst','getLast','removeFirst','removeLast'])
List target

ArrayBag() { target = new ArrayList() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import groovy.transform.EqualsAndHashCode

@CompileStatic
@EqualsAndHashCode
class BlankSeparatedList implements KryoSerializable, PathEscapeAware {
class BlankSeparatedList implements KryoSerializable, PathEscapeAware, List {

@Delegate
List target
private List target

// note: this constructor is needed by kryo serialization
private BlankSeparatedList() { }
Expand Down Expand Up @@ -71,4 +70,118 @@ class BlankSeparatedList implements KryoSerializable, PathEscapeAware {
target.getAt(index)
}

@Override
int size() {
return target.size()
}

@Override
boolean isEmpty() {
return target.isEmpty()
}

@Override
boolean contains(Object o) {
return target.contains(o)
}

@Override
Iterator iterator() {
return target.iterator()
}

@Override
Object[] toArray() {
return target.toArray()
}

@Override
boolean add(Object object) {
return target.add(object)
}

@Override
boolean remove(Object o) {
return target.remove(o)
}

@Override
boolean addAll(Collection c) {
return target.addAll(c)
}

@Override
boolean addAll(int index, Collection c) {
return target.addAll(index, c)
}

@Override
void clear() {
target.clear()
}

@Override
Object get(int index) {
return target.get(index)
}

@Override
Object set(int index, Object element) {
return target.set(index, element)
}

@Override
void add(int index, Object element) {
target.add(index, element)
}

@Override
Object remove(int index) {
return target.remove(index)
}

@Override
int indexOf(Object o) {
return target.indexOf(o)
}

@Override
int lastIndexOf(Object o) {
return target.lastIndexOf(o)
}

@Override
ListIterator listIterator() {
return target.listIterator()
}

@Override
ListIterator listIterator(int index) {
return target.listIterator(index)
}

@Override
List subList(int fromIndex, int toIndex) {
return target.subList(fromIndex, toIndex)
}

@Override
boolean retainAll(Collection c) {
return target.retainAll(c)
}

@Override
boolean removeAll(Collection c) {
return target.remove(c)
}

@Override
boolean containsAll(Collection c) {
return target.containsAll(c)
}

@Override
Object[] toArray(Object[] a) {
return target.toArray(a)
}
}

0 comments on commit 446b604

Please sign in to comment.