BeanProperty annotation does not seem to work as expected in Scala 3.0.0-RC2
See original GitHub issueCompiler version
Scala 3.0.0-RC2 (and Scala 3.0.0-RC1)
Minimized code
https://scastie.scala-lang.org/ItQMKLDxT5mX3d5cmfwwUQ
import scala.beans.BeanProperty
class PojoWrittenInScala {
@BeanProperty var fooBar: String = ""
}
val pojo = new PojoWrittenInScala
@main def main = {
println("fooBar=" + pojo.getFooBar())
}
Output
compiler error saying value getFooBar is not a member of PojoWrittenInScala
Expectation
The equivalent code compiles and works in Scala 2.
I had to do this hack to a test case in jackson-module-scala to get it to compile with Scala 3.0.0-RC2 – https://github.com/FasterXML/jackson-module-scala/commit/85e11761e58e21751fcdf83c776556ca331dd1dc
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
scala.beans.BeanProperty annotation removed in Scala3?
Hi, This annotation doesn't seem to be in scala3-library. ... BeanProperty annotation does not seem to work as expected in Scala 3.0.0-RC2 ......
Read more >Is it good practice to use @BeanProperty in Scala instead of ...
@BeanProperty is meant for Java interoperability, in particular with reflection-based Java frameworks expecting get and set methods. Do not use ...
Read more >Scala 3.0.0-RC1 – first release candidate is here - EPFL
Eta-expand companion object if functions are expected. Starting from RC1, we no longer generate a function parent for companions of case classes ...
Read more >@BeanProperty and @BooleanBeanProperty should not replicate ...
If a developer wishes to have annotations defined on the Java-visible getter or setter, they should define those methods explicitly in the Scala...
Read more >1 Introduction - Micronaut Documentation
Hibernate Validator is no longer a required dependency to activate bean ... to beans that accept @Valid arguments or use any javax.validation annotation....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is intentional: the methods generated from the scala.beans annotations are now invisible in Scala code (but visible in Java code and through reflection), because their primary usecase is interoperability with Java frameworks.
Tysvm, again. I have submitted a ticket: https://github.com/scalacenter/scala-3-migration-guide/issues/174