diff options
Diffstat (limited to 'src/main/scala/firrtl/util/ClassUtils.scala')
| -rw-r--r-- | src/main/scala/firrtl/util/ClassUtils.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/util/ClassUtils.scala b/src/main/scala/firrtl/util/ClassUtils.scala new file mode 100644 index 00000000..1b388035 --- /dev/null +++ b/src/main/scala/firrtl/util/ClassUtils.scala @@ -0,0 +1,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 + } +} |
