question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type-parameterized annotations are not deserializable

See original GitHub issue

Type of issue: bug report

What is the use case for changing the behavior? If a user tries to build a type-parameterized annotation, chisel will emit it without complaint, but it will not be deserializable by firrtl.

Impact: API modification

Development Phase: request

Other information

For example:

trait MyCoolTrait {
  val foo: Int
}

case class MyConcreteClassA(foo: Int) extends MyCoolTrait
case class MyConcreteClassB(foo: Int, bar: String) extends MyCoolTrait

case class MyAnnotation[T <: MyCoolTrait](target: ModuleTarget, data: T)
  extends SingleTargetAnnotation[ModuleTarget] { /* snipped boilerplate */ }

This is serialized by chisel without issue, but cannot be deserialized by firrtl because no type hints for data are provided. I think there are basically two options:

  1. Figure out a smart way to enable this
  2. Explicitly disallow it somehow so that chisel errors out when building such a thing

But… I currently have no suggestions on how to do either of these. 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
davidbiancolincommented, Oct 24, 2019

I modified the JsonProtocol (firrtl) to let annotations supply additional TypeHints to get this working in Golden Gate. The fully qualified classnames for everything you need the extra type hint for is captured in an additional annotation, so that deserialization can proceed. I think it would be trivial to let annotations also supply a custom serdes, though i suspect in your case that extra type hints are all you need.

I was going to open a draft PR later today.

0reactions
albert-magyarcommented, Nov 16, 2019

Closed by #1211

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deserialization Not Working Right with Generic Types and ...
I use Lombok and the @JsonPOJOBuilder - annotation to trick Jackson into deserializing my immutable object, but once a type parameter enters ...
Read more >
Is Jackson really unable to deserialize json into a generic type?
And without the @JsonProperty annotation, Jackson does not know that the first argument of the constructor maps to the result property. Share.
Read more >
Serialization Attributes - Json.NET
The JsonExtensionDataAttribute instructs the JsonSerializer to deserialize properties with no matching field or property on the type into the specified ...
Read more >
How to serialize and deserialize JSON using C# - .NET
Use the library directly, not through a framework such as ASP.NET Core. Use the JsonSerializer class with custom types to serialize from and ......
Read more >
JsonTypeInfo (Jackson-annotations 2.4.0 API) - FasterXML
Annotation used for configuring details of if and how type information is used with JSON serialization and deserialization, to preserve information about ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found