aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala
diff options
context:
space:
mode:
authorSchuyler Eldridge2019-11-07 12:33:22 -0500
committerSchuyler Eldridge2019-11-14 13:47:03 -0500
commitb076ac8fb482d2ef694f5b941cd8d72a2d9761ef (patch)
tree5d8221340400fadc8742888d7b435d18ceeab7ba /src/main/scala
parent4d80f5d41a6cd05838999b7b64389fc053325a18 (diff)
Use getName instead of getSimpleName
This changes uses of `getSimpleName` to `getName`. The former throws idiotic exceptions under Java 8, e.g., `getSimpleName` will fail if used on a class inside an object. This fixes a bug where any call to the `name` method of a custom transform defined inside an object (or in an environment wrapping things in objects like a REPL) will throw a malformed class name exception. E.g., if you do this and run with `-ll info` or your custom transform deletes annotations. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/main/scala')
-rw-r--r--src/main/scala/firrtl/Compiler.scala2
-rw-r--r--src/main/scala/firrtl/annotations/JsonProtocol.scala2
-rw-r--r--src/main/scala/firrtl/options/DependencyManager.scala8
-rw-r--r--src/main/scala/firrtl/stage/package.scala2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/main/scala/firrtl/Compiler.scala b/src/main/scala/firrtl/Compiler.scala
index 600b991e..9014d213 100644
--- a/src/main/scala/firrtl/Compiler.scala
+++ b/src/main/scala/firrtl/Compiler.scala
@@ -171,7 +171,7 @@ final case object UnknownForm extends CircuitForm(-1) {
/** The basic unit of operating on a Firrtl AST */
abstract class Transform extends TransformLike[CircuitState] {
/** A convenience function useful for debugging and error messages */
- def name: String = this.getClass.getSimpleName
+ def name: String = this.getClass.getName
/** The [[firrtl.CircuitForm]] that this transform requires to operate on */
def inputForm: CircuitForm
/** The [[firrtl.CircuitForm]] that this transform outputs */
diff --git a/src/main/scala/firrtl/annotations/JsonProtocol.scala b/src/main/scala/firrtl/annotations/JsonProtocol.scala
index c3853650..9992400a 100644
--- a/src/main/scala/firrtl/annotations/JsonProtocol.scala
+++ b/src/main/scala/firrtl/annotations/JsonProtocol.scala
@@ -109,7 +109,7 @@ object JsonProtocol {
val annos = parsed match {
case JArray(objs) => objs
case x => throw new InvalidAnnotationJSONException(
- s"Annotations must be serialized as a JArray, got ${x.getClass.getSimpleName} instead!")
+ s"Annotations must be serialized as a JArray, got ${x.getClass.getName} instead!")
}
// Recursively gather typeHints by pulling the "class" field from JObjects
// Json4s should emit this as the first field in all serialized classes
diff --git a/src/main/scala/firrtl/options/DependencyManager.scala b/src/main/scala/firrtl/options/DependencyManager.scala
index 1de8095b..604a1b10 100644
--- a/src/main/scala/firrtl/options/DependencyManager.scala
+++ b/src/main/scala/firrtl/options/DependencyManager.scala
@@ -291,7 +291,7 @@ trait DependencyManager[A, B <: TransformLike[A] with DependencyAPI[B]] extends
val nodes =
(prerequisiteGraph + dependentsGraph + invalidateGraph + otherDependents)
.getVertices
- .map(v => s"""${transformName(v)} [label="${v.getClass.getSimpleName}"]""")
+ .map(v => s"""${transformName(v)} [label="${v.getClass.getName}"]""")
s"""|digraph DependencyManager {
| graph [rankdir=BT]
@@ -315,8 +315,8 @@ trait DependencyManager[A, B <: TransformLike[A] with DependencyAPI[B]] extends
def rec(pm: DependencyManager[A, B], cm: Seq[String], tab: String = "", id: Int = 0): (String, Int) = {
var offset = id
- val targets = pm._targets.toSeq.map(_.getSimpleName).mkString(", ")
- val state = pm._currentState.toSeq.map(_.getSimpleName).mkString(", ")
+ val targets = pm._targets.toSeq.map(_.getName).mkString(", ")
+ val state = pm._currentState.toSeq.map(_.getName).mkString(", ")
val header = s"""|${tab}subgraph cluster_$id {
|$tab label="targets: $targets\\nstate: $state"
@@ -331,7 +331,7 @@ trait DependencyManager[A, B <: TransformLike[A] with DependencyAPI[B]] extends
case a =>
val name = s"""${transformName(a, "_" + id)}"""
sorted += name
- s"""$tab $name [label="${a.getClass.getSimpleName}"]"""
+ s"""$tab $name [label="${a.getClass.getName}"]"""
}.mkString("\n")
(Seq(header, body, s"$tab}").mkString("\n"), offset)
diff --git a/src/main/scala/firrtl/stage/package.scala b/src/main/scala/firrtl/stage/package.scala
index 89a61914..d0a481fb 100644
--- a/src/main/scala/firrtl/stage/package.scala
+++ b/src/main/scala/firrtl/stage/package.scala
@@ -49,7 +49,7 @@ package object stage {
options.collectFirst{ case a: FirrtlCircuitAnnotation => a.circuit } match {
case None => FirrtlExecutionFailure("No circuit found in AnnotationSeq!")
case Some(a) => FirrtlExecutionSuccess(
- emitType = fopts.compiler.getClass.getSimpleName,
+ emitType = fopts.compiler.getClass.getName,
emitted = emittedRes,
circuitState = CircuitState(
circuit = a,