From 456a878d126377a4b41b70cff070838436b98241 Mon Sep 17 00:00:00 2001 From: Prabhu Subramanian Date: Sun, 8 Oct 2023 20:10:43 +0100 Subject: [PATCH] Java 21 virtual thread Signed-off-by: Prabhu Subramanian --- .github/workflows/nodejstests.yml | 4 ++-- .github/workflows/npm-release.yml | 2 +- .github/workflows/repotests.yml | 2 +- build.sbt | 6 +++--- .../scala/io/appthreat/atom/dataflows/DataFlowGraph.scala | 2 +- .../scala/io/appthreat/atom/slicing/DataFlowSlicing.scala | 2 +- src/main/scala/io/appthreat/atom/slicing/UsageSlicing.scala | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/nodejstests.yml b/.github/workflows/nodejstests.yml index 1b85e1f..7d90301 100644 --- a/.github/workflows/nodejstests.yml +++ b/.github/workflows/nodejstests.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - java-version: ['17', '19', '20', '21'] + java-version: ['21'] node-version: ['20.x'] runs-on: ${{ matrix.os }} steps: @@ -61,7 +61,7 @@ jobs: runs-on: windows-latest strategy: matrix: - java-version: ['17', '19', '20', '21'] + java-version: ['21'] node-version: ['20.x'] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/npm-release.yml b/.github/workflows/npm-release.yml index 2035452..5286d3d 100644 --- a/.github/workflows/npm-release.yml +++ b/.github/workflows/npm-release.yml @@ -24,7 +24,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '19' + java-version: '21' - name: Release run: | sbt scalafmtCheck stage assembly createDistribution diff --git a/.github/workflows/repotests.yml b/.github/workflows/repotests.yml index 7addcf6..32f7a9f 100644 --- a/.github/workflows/repotests.yml +++ b/.github/workflows/repotests.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - java-version: ['17', '19', '20', '21'] + java-version: ['21'] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 diff --git a/build.sbt b/build.sbt index 4ab0045..4c987c5 100644 --- a/build.sbt +++ b/build.sbt @@ -35,17 +35,17 @@ Compile / doc / scalacOptions ++= Seq("-doc-title", "atom apidocs", "-doc-versio ThisBuild / scalacOptions ++= Seq( "-deprecation", // Emit warning and location for usages of deprecated APIs. "--release", - "17", + "21", ) ThisBuild / compile / javacOptions ++= Seq( "-g", // debug symbols "-Xlint", - "--release=17" + "--release=21" ) ++ { // fail early if users with JDK11 try to run this val javaVersion = sys.props("java.specification.version").toFloat - assert(javaVersion.toInt >= 17, s"this build requires JDK17+ - you're using $javaVersion") + assert(javaVersion.toInt >= 21, s"this build requires JDK21+ - you're using $javaVersion") Nil } diff --git a/src/main/scala/io/appthreat/atom/dataflows/DataFlowGraph.scala b/src/main/scala/io/appthreat/atom/dataflows/DataFlowGraph.scala index 507ce18..fe4e04c 100644 --- a/src/main/scala/io/appthreat/atom/dataflows/DataFlowGraph.scala +++ b/src/main/scala/io/appthreat/atom/dataflows/DataFlowGraph.scala @@ -74,7 +74,7 @@ object DataFlowGraph { private def DF_EDGES = Set(EdgeTypes.REACHING_DEF, EdgeTypes.CALL, EdgeTypes.REF) - val exec: ExecutorService = Executors.newWorkStealingPool(Runtime.getRuntime.availableProcessors / 2) + val exec: ExecutorService = Executors.newVirtualThreadPerTaskExecutor() def buildFromSlice(slice: DataFlowSlice): DataFlowGraph = { val dfNodes = slice.nodes diff --git a/src/main/scala/io/appthreat/atom/slicing/DataFlowSlicing.scala b/src/main/scala/io/appthreat/atom/slicing/DataFlowSlicing.scala index 244a83a..085205c 100644 --- a/src/main/scala/io/appthreat/atom/slicing/DataFlowSlicing.scala +++ b/src/main/scala/io/appthreat/atom/slicing/DataFlowSlicing.scala @@ -13,7 +13,7 @@ import scala.collection.concurrent.TrieMap object DataFlowSlicing { implicit val resolver: ICallResolver = NoResolve - val exec: ExecutorService = Executors.newWorkStealingPool(Runtime.getRuntime.availableProcessors() / 2) + val exec: ExecutorService = Executors.newVirtualThreadPerTaskExecutor() private val excludeOperatorCalls = new AtomicBoolean(true) private val nodeCache = new TrieMap[Long, SliceNode]() private var language: Option[String] = _ diff --git a/src/main/scala/io/appthreat/atom/slicing/UsageSlicing.scala b/src/main/scala/io/appthreat/atom/slicing/UsageSlicing.scala index 3af093f..4ff7618 100644 --- a/src/main/scala/io/appthreat/atom/slicing/UsageSlicing.scala +++ b/src/main/scala/io/appthreat/atom/slicing/UsageSlicing.scala @@ -19,7 +19,7 @@ import java.util.concurrent.* object UsageSlicing { private val resolver = NoResolve - val exec: ExecutorService = Executors.newWorkStealingPool(Runtime.getRuntime.availableProcessors() / 2) + val exec: ExecutorService = Executors.newVirtualThreadPerTaskExecutor() private val constructorTypeMatcher = Pattern.compile(".*new (\\w+)\\(.*") private val excludeOperatorCalls = new AtomicBoolean(true)