Scala 2.12.0 compilation warning when using Jackson @JsonTypeInfo-annotation

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Scala 2.12.0 compilation warning when using Jackson @JsonTypeInfo-annotation

Morten Kjetland
Hi,

The following code using Jackson 2.8.4 and Scala 2.12.0:

import com.fasterxml.jackson.annotation.JsonTypeInfo.{As, Id}
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo}

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes(Array(
new Type(value = classOf[AddCfsRelation], name = "add"),
new Type(value = classOf[RemoveCfsRelation], name = "remove")
))

trait MyTrait {
def someProperty: String
}

Gives this compiler-warning:

[WARNING] warning: While parsing annotations in C:\path\MyTrait.class, could not find NAME in enum <none>.
[INFO] This is likely due to an implementation restriction: an annotation argument cannot refer to a member of the annotated class (SI-7014).


Here is the source of the annotation: https://github.com/FasterXML/jackson-annotations/blob/master/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java


This was not an issue with Scala 2.11


Best regards,
Morten Kjetland


--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scala 2.12.0 compilation warning when using Jackson @JsonTypeInfo-annotation

Lukas Rytz-2
Hi Morten

Thanks for the report. Could you provide exact instructions how to reproduce?
I put this on my classpath and changed your example a little, and it compiles without warnings for me:

import com.fasterxml.jackson.annotation.JsonTypeInfo.{As, Id}
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo}
import JsonSubTypes.Type // <<< added import

@JsonTypeInfo(
  use = JsonTypeInfo.Id.NAME,
  include = JsonTypeInfo.As.PROPERTY,
  property = "type")
@JsonSubTypes(Array(
  new Type(value = classOf[Object], name = "add"),   // <<< changed to Object
  new Type(value = classOf[Object], name = "remove") // <<< changed to Object
))
trait MyTrait {
  def someProperty: String
}

Thanks: Lukas


On Fri, Nov 25, 2016 at 8:39 AM, Morten Kjetland <[hidden email]> wrote:
Hi,

The following code using Jackson 2.8.4 and Scala 2.12.0:

import com.fasterxml.jackson.annotation.JsonTypeInfo.{As, Id}
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo}

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes(Array(
new Type(value = classOf[AddCfsRelation], name = "add"),
new Type(value = classOf[RemoveCfsRelation], name = "remove")
))

trait MyTrait {
def someProperty: String
}

Gives this compiler-warning:

[WARNING] warning: While parsing annotations in C:\path\MyTrait.class, could not find NAME in enum <none>.
[INFO] This is likely due to an implementation restriction: an annotation argument cannot refer to a member of the annotated class (SI-7014).




This was not an issue with Scala 2.11


Best regards,
Morten Kjetland


--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scala 2.12.0 compilation warning when using Jackson @JsonTypeInfo-annotation

Morten Kjetland
Thanks for looking into it.

I'm seeing the warning both when compiling in IntelliJ 2016.3 and with maven using this plugin:

<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-deprecation</arg>
<arg>-feature</arg>
</args>
</configuration>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>doc-jar</goal>
</goals>
</execution>
</executions>
</plugin>

On Friday, November 25, 2016 at 9:10:09 AM UTC+1, Lukas Rytz wrote:
Hi Morten

Thanks for the report. Could you provide exact instructions how to reproduce?
I put <a href="http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.8.4/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frepo1.maven.org%2Fmaven2%2Fcom%2Ffasterxml%2Fjackson%2Fcore%2Fjackson-annotations%2F2.8.4%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNETfK_sD9eRXSFDqMatK6WyVgoFQw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frepo1.maven.org%2Fmaven2%2Fcom%2Ffasterxml%2Fjackson%2Fcore%2Fjackson-annotations%2F2.8.4%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNETfK_sD9eRXSFDqMatK6WyVgoFQw&#39;;return true;">this on my classpath and changed your example a little, and it compiles without warnings for me:

import com.fasterxml.jackson.annotation.JsonTypeInfo.{As, Id}
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo}
import JsonSubTypes.Type // <<< added import

@JsonTypeInfo(
  use = <a href="http://JsonTypeInfo.Id.NAME" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FJsonTypeInfo.Id.NAME\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWFUCudIoweH8NWmvnboglFk9bVg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FJsonTypeInfo.Id.NAME\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWFUCudIoweH8NWmvnboglFk9bVg&#39;;return true;">JsonTypeInfo.Id.NAME,
  include = JsonTypeInfo.As.PROPERTY,
  property = "type")
@JsonSubTypes(Array(
  new Type(value = classOf[Object], name = "add"),   // <<< changed to Object
  new Type(value = classOf[Object], name = "remove") // <<< changed to Object
))
trait MyTrait {
  def someProperty: String
}

Thanks: Lukas


On Fri, Nov 25, 2016 at 8:39 AM, Morten Kjetland <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="x4-mNBIuCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">morten....@...> wrote:
Hi,

The following code using Jackson 2.8.4 and Scala 2.12.0:

import com.fasterxml.jackson.annotation.JsonTypeInfo.{As, Id}
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo}

@JsonTypeInfo(
use = <a href="http://JsonTypeInfo.Id.NAME" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FJsonTypeInfo.Id.NAME\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWFUCudIoweH8NWmvnboglFk9bVg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FJsonTypeInfo.Id.NAME\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWFUCudIoweH8NWmvnboglFk9bVg&#39;;return true;">JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes(Array(
new Type(value = classOf[AddCfsRelation], name = "add"),
new Type(value = classOf[RemoveCfsRelation], name = "remove")
))

trait MyTrait {
def someProperty: String
}

Gives this compiler-warning:

[WARNING] warning: While parsing annotations in C:\path\MyTrait.class, could not find NAME in enum <none>.
[INFO] This is likely due to an implementation restriction: an annotation argument cannot refer to a member of the annotated class (SI-7014).


Here is the source of the annotation: <a href="https://github.com/FasterXML/jackson-annotations/blob/master/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FFasterXML%2Fjackson-annotations%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Ffasterxml%2Fjackson%2Fannotation%2FJsonTypeInfo.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFUGbChpMSq4uxJlJiOu0oZK6Hd2Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FFasterXML%2Fjackson-annotations%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Ffasterxml%2Fjackson%2Fannotation%2FJsonTypeInfo.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFUGbChpMSq4uxJlJiOu0oZK6Hd2Q&#39;;return true;">https://github.com/FasterXML/jackson-annotations/blob/master/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java


This was not an issue with Scala 2.11


Best regards,
Morten Kjetland


--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="x4-mNBIuCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">scala-interna...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scala 2.12.0 compilation warning when using Jackson @JsonTypeInfo-annotation

Alan Stewart
In reply to this post by Morten Kjetland

Hi,
I also see the same warnings using 2.12.1 and Jackson 2.8.4 with:

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes(Array(
new Type(value = classOf[TagObject], name = "tag"),
new Type(value = classOf[CommitObject], name = "commit"),
new Type(value = classOf[BlobObject], name = "blob")))
sealed trait TypedObject extends GitHubRef

and same compiler plugin configuration

On Friday, 25 November 2016 18:39:25 UTC+11, Morten Kjetland wrote:
Hi,

The following code using Jackson 2.8.4 and Scala 2.12.0:

import com.fasterxml.jackson.annotation.JsonTypeInfo.{As, Id}
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo}

@JsonTypeInfo(
use = <a href="http://JsonTypeInfo.Id.NAME" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FJsonTypeInfo.Id.NAME\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWFUCudIoweH8NWmvnboglFk9bVg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FJsonTypeInfo.Id.NAME\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEWFUCudIoweH8NWmvnboglFk9bVg&#39;;return true;">JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes(Array(
new Type(value = classOf[AddCfsRelation], name = "add"),
new Type(value = classOf[RemoveCfsRelation], name = "remove")
))

trait MyTrait {
def someProperty: String
}

Gives this compiler-warning:

[WARNING] warning: While parsing annotations in C:\path\MyTrait.class, could not find NAME in enum <none>.
[INFO] This is likely due to an implementation restriction: an annotation argument cannot refer to a member of the annotated class (SI-7014).


Here is the source of the annotation: <a href="https://github.com/FasterXML/jackson-annotations/blob/master/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FFasterXML%2Fjackson-annotations%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Ffasterxml%2Fjackson%2Fannotation%2FJsonTypeInfo.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFUGbChpMSq4uxJlJiOu0oZK6Hd2Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FFasterXML%2Fjackson-annotations%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Ffasterxml%2Fjackson%2Fannotation%2FJsonTypeInfo.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFUGbChpMSq4uxJlJiOu0oZK6Hd2Q&#39;;return true;">https://github.com/FasterXML/jackson-annotations/blob/master/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java


This was not an issue with Scala 2.11


Best regards,
Morten Kjetland


--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Scala 2.12.0 compilation warning when using Jackson @JsonTypeInfo-annotation

Jason Zaugg
It would be a great help if you could produce a standalone project that we could clone to investigate further.

-jason

On Tue, 13 Dec 2016 at 11:17 Alan Stewart <[hidden email]> wrote:

Hi,
I also see the same warnings using 2.12.1 and Jackson 2.8.4 with:

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes(Array(
new Type(value = classOf[TagObject], name = "tag"),
new Type(value = classOf[CommitObject], name = "commit"),
new Type(value = classOf[BlobObject], name = "blob")))
sealed trait TypedObject extends GitHubRef

and same compiler plugin configuration

On Friday, 25 November 2016 18:39:25 UTC+11, Morten Kjetland wrote:
Hi,

The following code using Jackson 2.8.4 and Scala 2.12.0:

import com.fasterxml.jackson.annotation.JsonTypeInfo.{As, Id}
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo}

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes(Array(
new Type(value = classOf[AddCfsRelation], name = "add"),
new Type(value = classOf[RemoveCfsRelation], name = "remove")
))

trait MyTrait {
def someProperty: String
}

Gives this compiler-warning:

[WARNING] warning: While parsing annotations in C:\path\MyTrait.class, could not find NAME in enum <none>.
[INFO] This is likely due to an implementation restriction: an annotation argument cannot refer to a member of the annotated class (SI-7014).




This was not an issue with Scala 2.11


Best regards,
Morten Kjetland


--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.