Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type parameter bound check regression in Scala 2.13.0-M5 #11202

Closed
xerial opened this issue Oct 11, 2018 · 2 comments
Closed

Type parameter bound check regression in Scala 2.13.0-M5 #11202

xerial opened this issue Oct 11, 2018 · 2 comments

Comments

@xerial
Copy link

xerial commented Oct 11, 2018

When checking Java's type parameter bound, Scala 2.13.0-M5 shows this kind of error:

[error] /Users/leo/work/git/airframe/airframe-jmx/src/main/scala/wvlet/airframe/jmx/JMXMBean.scala:79:26: inferred type arguments [javax.management.JMX] do not conform to method getAnnotation's type parameter bounds [A <: java.lang.annotation.Annotation]
[error]     val description = cl.getAnnotation(classOf[JMX]) match {
[error]                          ^
[error] /Users/leo/work/git/airframe/airframe-jmx/src/main/scala/wvlet/airframe/jmx/JMXMBean.scala:79:47: type mismatch;
[error]  found   : Class[javax.management.JMX](classOf[javax.management.JMX])
[error]  required: Class[A]

https://github.com/wvlet/airframe/blob/5ca3143788b4768fb3ea3096138c759764c29e40/airframe-jmx/src/main/scala/wvlet/airframe/jmx/JMXMBean.scala#L79

JMX in the above error is a Java annotation definition like this:
https://github.com/wvlet/airframe/blob/083f50ad452bab07a6c9f4bb436bb245e78a2e2d/airframe-jmx/src/main/scala/wvlet/airframe/jmx/JMX.java#L24

Class.getAnnotation in JDK (Class.java) uses the following definition:

    public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
        Objects.requireNonNull(annotationClass);

        return (A) annotationData().annotations.get(annotationClass);
    }

In this example:

  • JMX is a Java annotation
  • When calling Class.getAnnotation(classOf[JMX]) shows the above error in Scala 2.13.0-M5, even though JMX should be an extension of Java's Annotation.
  • This error didn't happen in Scala 2.13.0-M4 or prior.

== (update)
I've found the above error is referencing different type (javax.management.JMX), but my expectation was resolving wvlet.airframe.jmx.JMX.

It seems the import order might have been changed since Scala 2.13.0-M5.

@xerial
Copy link
Author

xerial commented Oct 11, 2018

Let me close the issue. It seems this is not the type bound check error, rather the import order precedence has changed since Scala 2.13.0-M5

@xerial xerial closed this as completed Oct 11, 2018
xerial added a commit to xerial/airframe that referenced this issue Oct 11, 2018
@SethTisue
Copy link
Member

sounds like scala/scala#6589

xerial added a commit to xerial/airframe that referenced this issue Oct 30, 2018
xerial added a commit to wvlet/airframe that referenced this issue Oct 31, 2018
* Upgrade to Scala 2.13.0-M5
* Upgrade ScalaTest and Scalacheck
* Update travis config for Scala 2.13.0-M5
* Scala 2.13.0-M5 confused java.util.logging.LogRecord and wvlet.log.LogRecord
* Fix scala/bug#11202 by explicitely specifying JMX annotation package path
* Use Scala test 3.0.6-SNAP4
* Add a workaround for Scala 2.13.0-M5 serialization bug: scala/bug#11192
* Exclude airframe-fluentd from Scala 2.13 build
* Exclude serilaization test for Scala 2.13.0-M5 instead of forking JVM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants