summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/Aggregate.scala
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/scala/chisel3/Aggregate.scala')
-rw-r--r--core/src/main/scala/chisel3/Aggregate.scala20
1 files changed, 15 insertions, 5 deletions
diff --git a/core/src/main/scala/chisel3/Aggregate.scala b/core/src/main/scala/chisel3/Aggregate.scala
index aacf0b1c..4fc9b20f 100644
--- a/core/src/main/scala/chisel3/Aggregate.scala
+++ b/core/src/main/scala/chisel3/Aggregate.scala
@@ -1116,7 +1116,12 @@ abstract class Record(private[chisel3] implicit val compileOptions: CompileOptio
def elements: SeqMap[String, Data]
/** Name for Pretty Printing */
- def className: String = this.getClass.getSimpleName
+ def className: String = try {
+ this.getClass.getSimpleName
+ } catch {
+ // This happens if your class is defined in an object and is anonymous
+ case e: java.lang.InternalError if e.getMessage == "Malformed class name" => this.getClass.toString
+ }
private[chisel3] override def typeEquivalent(that: Data): Boolean = that match {
case that: Record =>
@@ -1243,10 +1248,15 @@ abstract class Bundle(implicit compileOptions: CompileOptions) extends Record wi
"Please see https://github.com/chipsalliance/chisel3#build-your-own-chisel-projects."
)
- override def className: String = this.getClass.getSimpleName match {
- case name if name.startsWith("$anon$") => "AnonymousBundle" // fallback for anonymous Bundle case
- case "" => "AnonymousBundle" // ditto, but on other platforms
- case name => name
+ override def className: String = try {
+ this.getClass.getSimpleName match {
+ case name if name.startsWith("$anon$") => "AnonymousBundle" // fallback for anonymous Bundle case
+ case "" => "AnonymousBundle" // ditto, but on other platforms
+ case name => name
+ }
+ } catch {
+ // This happens if you have nested objects which your class is defined in
+ case e: java.lang.InternalError if e.getMessage == "Malformed class name" => this.getClass.toString
}
/** The collection of [[Data]]