-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Missing generic type in JVM signature of public field #17069
Comments
The problem seems to be more general and has nothing to do with class Foo {
val generic: List[String] = ???
} In the bytecode produced byt scala 3 (starting from 3.0.0 up to the newest nightly) we can see
So in general result types of getters have type parameters in signatures but that's not the case for underlying fields |
Will this be scheduled to the next 3.3.1 version? |
This doesn't seem to have very high priority for the core compiler team as the problem has existed since 3.0.0 and nobody even noticed that before. However contributions are welcome 🙂. A fix could go in 3.3.1 if it gets implemented before the branch cut-off for 3.3.1 (which should coincide with the release of stable 3.3.0, so probably in like two weeks unless more regressions appear and we don't manage to fix them on time). I tried to have a quick look at a potential source of the issue and here are my observations: val generic: List[String] in the example above is transformed to a method with an additional <accessor> def generic: List[String] After the type erasure in <accessor> def generic: List Then in <accessor> def generic: List
val generic: List Finally, in My assumption is that as |
(an argument for prioritizing could be that Jackson is very widely used) |
I'm running into this issue as well when using OptaPlanner. It throws the exception defined here |
We encountered this error while trying to migrate a project (from 2.13) that uses JPA (Hibernate). This bug seems to break interop with many Java libraries which rely on field types (reflection) for serialization/persistence. |
I'm having the same issue as @akorneev (i.e. migrating a JPA project from 2.13 to 3.3.1 fails). I'm hitting this bug with Gson. Sample code to reproduce the reflection issue is on Stackoverflow |
@sjrd would you have any guidance about this issue? Do you think it's a hard one? |
@EugeneFlesselle @entangled90 @AnotherMedo @Motii1: the issue we were assigned for tonight's Spree has been solved. I therefore suggest we switch to this one. Sorry for the late notice! If it's anybody's first time hacking on Dotty, you can find information on to get started at https://dotty.epfl.ch/docs/contributing/getting-started.html. |
Not sure how to test it. Maybe we could have the following class Foo:
val generic: List[String] = ???
@main def test =
val tpe = classOf[Foo].getDeclaredField("generic").getGenericType()
val tpe2 = classOf[Foo].getDeclaredMethod("generic").getGenericReturnType()
assert(tpe == tpe2) |
Your entry point will be https://github.com/lampepfl/dotty/blob/main/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala Then figure out what method in the chain does not get applied correctly. |
Compiler version
3.2.2
Minimized code
Output
Partial output of
scalap -c -p
Expectation
Scala 2 and Java add the generic type of the java.util.List to the repos field. Changing the version
//> scala 2
in the code above produces:We got hit by this when Jackson was unable to deserialize the class correctly because it could not reflect on the type of the list.
The text was updated successfully, but these errors were encountered: