diff --git a/compiler/src/dotty/tools/dotc/profile/Profiler.scala b/compiler/src/dotty/tools/dotc/profile/Profiler.scala index 6df88d9e28f0..0533b6bdaec3 100644 --- a/compiler/src/dotty/tools/dotc/profile/Profiler.scala +++ b/compiler/src/dotty/tools/dotc/profile/Profiler.scala @@ -1,5 +1,6 @@ package dotty.tools.dotc.profile +import scala.annotation.* import scala.language.unsafeNulls import java.io.{FileWriter, PrintWriter} @@ -123,6 +124,7 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(using Context) } private def readHeapUsage() = RealProfiler.memoryMx.getHeapMemoryUsage.getUsed + @nowarn private def doGC: Unit = { System.gc() System.runFinalization() diff --git a/library/src/scala/runtime/LazyVals.scala b/library/src/scala/runtime/LazyVals.scala index f3fe52beb9ee..7a66639a826a 100644 --- a/library/src/scala/runtime/LazyVals.scala +++ b/library/src/scala/runtime/LazyVals.scala @@ -1,9 +1,12 @@ package scala.runtime +import scala.annotation.* + /** * Helper methods used in thread-safe lazy vals. */ object LazyVals { + @nowarn private[this] val unsafe: sun.misc.Unsafe = classOf[sun.misc.Unsafe].getDeclaredFields.nn.find { field => field.nn.getType == classOf[sun.misc.Unsafe] && { @@ -100,6 +103,7 @@ object LazyVals { } def getOffset(clz: Class[_], name: String): Long = { + @nowarn val r = unsafe.objectFieldOffset(clz.getDeclaredField(name)) if (debug) println(s"getOffset($clz, $name) = $r") @@ -107,6 +111,7 @@ object LazyVals { } def getOffsetStatic(field: java.lang.reflect.Field) = + @nowarn val r = unsafe.objectFieldOffset(field) if (debug) println(s"getOffset(${field.getDeclaringClass}, ${field.getName}) = $r") diff --git a/project/Build.scala b/project/Build.scala index 30aa05b9ee5d..d89f67f0be35 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -169,9 +169,10 @@ object Build { "-feature", "-deprecation", "-unchecked", - "-Xfatal-warnings", + //"-Wconf:cat=deprecation&msg=Unsafe:s", // example usage + "-Xfatal-warnings", // -Werror in modern usage "-encoding", "UTF8", - "-language:implicitConversions" + "-language:implicitConversions", ), (Compile / compile / javacOptions) ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),