Skip to content

Thread.getId is deprecated #16142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/profile/Profiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(using Context)

private val mainThread = Thread.currentThread()

@nowarn("cat=deprecation")
private[profile] def snapThread(idleTimeNanos: Long): ProfileSnap = {
import RealProfiler._
val current = Thread.currentThread()
Expand Down Expand Up @@ -245,6 +246,7 @@ class StreamProfileReporter(out:PrintWriter) extends ProfileReporter {
reportCommon(EventType.BACKGROUND, profiler, threadRange)
override def reportForeground(profiler: RealProfiler, threadRange: ProfileRange): Unit =
reportCommon(EventType.MAIN, profiler, threadRange)
@nowarn("cat=deprecation")
private def reportCommon(tpe:EventType, profiler: RealProfiler, threadRange: ProfileRange): Unit =
out.println(s"$tpe,${threadRange.start.snapTimeNanos},${threadRange.end.snapTimeNanos},${profiler.id},${threadRange.phase.id},${threadRange.phase.phaseName.replace(',', ' ')},${threadRange.purpose},${threadRange.taskCount},${threadRange.thread.getId},${threadRange.thread.getName},${threadRange.runNs},${threadRange.idleNs},${threadRange.cpuNs},${threadRange.userNs},${threadRange.allocatedBytes},${threadRange.end.heapBytes} ")

Expand Down
9 changes: 5 additions & 4 deletions library/src/scala/runtime/coverage/Invoker.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package scala.runtime.coverage

import scala.collection.mutable.{BitSet, AnyRefMap}
import scala.annotation.internal.sharable
import scala.annotation.nowarn
import scala.collection.concurrent.TrieMap
import scala.collection.mutable.{BitSet, AnyRefMap}
import java.io.{File, FileWriter}
import java.nio.file.Files
import java.io.FileWriter
import java.io.File
import scala.annotation.internal.sharable

@sharable // avoids false positive by -Ycheck-reentrant
object Invoker {
Expand Down Expand Up @@ -48,6 +48,7 @@ object Invoker {
writer.write('\n')
writer.flush()

@nowarn("cat=deprecation")
def measurementFile(dataDir: String): File = new File(
dataDir,
MeasurementsPrefix + runtimeUUID + "." + Thread.currentThread.nn.getId
Expand Down