All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.epfl.scala.debugadapter.internal.evaluator.JdiPrimitive.scala Maven / Gradle / Ivy

package ch.epfl.scala.debugadapter.internal.evaluator

import com.sun.jdi.{ObjectReference, ThreadReference}

object JdiPrimitive {
  def box(
      value: AnyVal,
      classLoader: JdiClassLoader,
      thread: ThreadReference
  ): Safe[ObjectReference] = {
    for {
      jdiValue <- classLoader.mirrorOf(value.toString)
      clazz <- value match {
        case _: Boolean => classLoader.loadClass("java.lang.Boolean")
        case _: Byte => classLoader.loadClass("java.lang.Byte")
        case _: Char => classLoader.loadClass("java.lang.Character")
        case _: Double => classLoader.loadClass("java.lang.Double")
        case _: Float => classLoader.loadClass("java.lang.Float")
        case _: Int => classLoader.loadClass("java.lang.Integer")
        case _: Long => classLoader.loadClass("java.lang.Long")
        case _: Short => classLoader.loadClass("java.lang.Short")
      }
      objectRef <- clazz.invokeStatic("valueOf", List(jdiValue))
    } yield objectRef.asInstanceOf[ObjectReference]
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy