How do I get a list of JNI libraries which are loaded?

前端 未结 7 1938
半阙折子戏
半阙折子戏 2020-11-28 07:54

Just what the subject says, is there a way in Java to get a list of all the JNI native libraries which have been loaded at any given time?

相关标签:
7条回答
  • 2020-11-28 08:25

    FWIW, here's jitter's solution again, this time as a small Scala method:

    def loadedLibs: Seq[String] = {
      val libs = classOf[ClassLoader].getDeclaredField("loadedLibraryNames")
      libs.setAccessible(true)
      import scala.collection.JavaConverters._
      libs.get(ClassLoader.getSystemClassLoader())
        .asInstanceOf[java.util.Vector[String]]
        .asScala
    }
    
    0 讨论(0)
提交回复
热议问题