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.

BeanProperty annotation does not seem to work as expected in Scala 3.0.0-RC2

See original GitHub issue

Compiler 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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
smartercommented, Apr 2, 2021

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.

2reactions
jim-oflaherty-jr-qalocate-comcommented, Apr 2, 2021
Read more comments on GitHub >

github_iconTop 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 >

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