-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to build Scala Native on JDK 21 (#3492)
* `Thread.Builder.allowSetThreadLocals` didn't made it to stable release, and is only available in JDK 19-20 until --preview flag. Remove it's implementation and tests referencing this no longer existing API * Update CI to test against JDK 21 instead of JDK 20 with --enable-preview flags * Don't warn when accessing `Thread.getId()` which is deprecated in latest JDK versions * Add stubs for JDK 21 Sequential Collections to allow for linkling when using JDK 21+ * CI - Test JDK 21 only on Scala 2.13, compilation fails in Scala 3
- Loading branch information
1 parent
5d53d3e
commit 4eb7261
Showing
14 changed files
with
125 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
javalib/src/main/scala/java/util/SequencedCollection.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package java.util | ||
|
||
trait SequencedCollection[E /* <: AnyRef */ ] extends Collection[E] { | ||
/* Commented out until we're able to provide reversed views for collections | ||
def reversed(): SequencedCollection[E] | ||
def addFirst(elem: E): Unit = throw new UnsupportedOperationException() | ||
def addLast(elem: E): Unit = throw new UnsupportedOperationException() | ||
def getFirst(): E = this.iterator().next() | ||
def getLast(): E = this.reversed().iterator().next() | ||
def removeFirst(): E = { | ||
val it = this.iterator() | ||
val elem = it.next() | ||
it.remove() | ||
elem | ||
} | ||
def removeLast(): E = { | ||
val it = this.reversed().iterator() | ||
val elem = it.next() | ||
it.remove() | ||
elem | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package java.util | ||
|
||
trait SequencedMap[K /* <: AnyRef */, V /* <: AnyRef */ ] extends Map[K, V] { | ||
/* Commented out until we're able to provide reversed views for collections | ||
def reversed(): SequencedMap[K, V] | ||
def firstEntry(): Map.Entry[K, V] = { | ||
val it = entrySet().iterator() | ||
if (it.hasNext()) SequencedMap.CopyOfEntry(it.next()) else null | ||
} | ||
def lastEntry(): Map.Entry[K, V] = { | ||
val it = reversed().entrySet().iterator() | ||
if (it.hasNext()) SequencedMap.CopyOfEntry(it.next()) else null | ||
} | ||
def pollFirstEntry(): Map.Entry[K, V] = { | ||
val it = entrySet().iterator() | ||
if (it.hasNext()) { | ||
val entry = SequencedMap.CopyOfEntry(it.next()) | ||
it.remove() | ||
entry | ||
} else null | ||
} | ||
def pollLastEntry(): Map.Entry[K, V] = { | ||
val it = this.reversed().entrySet().iterator() | ||
if (it.hasNext()) { | ||
val entry = SequencedMap.CopyOfEntry(it.next()) | ||
it.remove() | ||
entry | ||
} else null | ||
} | ||
def putFirst(key: K, value: V): V = throw new UnsupportedOperationException() | ||
def putLast(key: K, value: V): V = throw new UnsupportedOperationException() | ||
def sequencedKeySet(): SequencedSet[K] = ??? | ||
def sequencedValues(): SequencedCollection[V] = ??? | ||
def sequencedEntrySet(): SequencedSet[Map.Entry[K, V]] = ??? | ||
} | ||
private object SequencedMap { | ||
private object CopyOfEntry { | ||
def apply[K /* <: AnyRef */, V /* <: AnyRef */](entry: Map.Entry[K, V]) = { | ||
Objects.requireNonNull(entry) | ||
new CopyOfEntry( | ||
key = entry.getKey(), | ||
value = entry.getValue() | ||
) | ||
} | ||
} | ||
private class CopyOfEntry[K /* <: AnyRef */, V /* <: AnyRef */] private (key: K, value: V) | ||
extends Map.Entry[K, V] { | ||
override def getKey(): K = key | ||
override def getValue(): V = value | ||
override def setValue(value: V): V = | ||
throw new UnsupportedOperationException() | ||
override def equals(o: Any): Boolean = o match { | ||
case entry: Map.Entry[K, V] @unchecked => | ||
Objects.equals(key, entry.getKey()) && | ||
Objects.equals(value, entry.getValue()) | ||
case _ => false | ||
} | ||
override def hashCode(): Int = { | ||
def hash(obj: Any) = if (obj == null) 0 else obj.## | ||
hash(key) ^ hash(value) | ||
} | ||
override def toString(): String = s"$key=$value" | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package java.util | ||
|
||
trait SequencedSet[E /* <: AnyRef */ ] | ||
extends SequencedCollection[E] | ||
with Set[E] { | ||
/* Commented out until we're able to provide reversed views for collections | ||
override def reversed(): SequencedSet[E] | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters