aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/util/ClassUtils.scala
blob: 1b388035c3162688684f8937fe4fa61c55264a2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package firrtl.util

object ClassUtils {
  /** Determine if a named class is loaded.
    *
    * @param name - name of the class: "foo.bar" or "org.foo.bar"
    * @return true if the class has been loaded (is accessible), false otherwise.
    */
  def isClassLoaded(name: String): Boolean = {
    val found = try {
      Class.forName(name, false, getClass.getClassLoader) != null
    } catch {
      case e: ClassNotFoundException => false
      case x: Throwable => throw x
    }
//    println(s"isClassLoaded: %s $name".format(if (found) "found" else "didn't find"))
    found
  }
}