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

Compiler-generated bitmaps for -Xcheckinit should be marked synthetic #9456

Open
scabug opened this issue Sep 1, 2015 · 2 comments
Open

Comments

@scabug
Copy link

scabug commented Sep 1, 2015

When compiling with -Xcheckinit, the compiler-generated bitmap field(s) are not marked synthetic. For example:

$ ~/Programs/scala-2.11.7/bin/scala -Xcheckinit
Welcome to Scala version 2.11.7 (OpenJDK 64-Bit Server VM, Java 1.8.0_51).
Type in expressions to have them evaluated.
Type :help for more information.

scala> final class Foo(constant: Double) { val value: Double = constant }
defined class Foo

scala> classOf[Foo].getDeclaredFields
res0: Array[java.lang.reflect.Field] = Array(private final double Foo.value, private volatile boolean Foo.bitmap$init$0)

scala> res0.last.isSynthetic
res1: Boolean = false

This may cause a problem for reflection-based tools that specifically must ignore synthetic fields for correctness (e.g. see this thread related to the EqualsVerifier library).

A similar issue was raised on the scala-internals mailing list last year, and there seemed to be agreement that such compiler-generated bitmap fields should be marked synthetic. However, I was unable to find an associated issue in JIRA.

@scabug
Copy link
Author

scabug commented Sep 1, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9456?orig=1
Reporter: Steven Soloff (s_soloff)
Affected Versions: 2.11.7

@scabug
Copy link
Author

scabug commented Sep 1, 2015

@soc said (edited on Sep 1, 2015 5:20:08 PM UTC):
I agree, although if I remember correctly, synthetic translates to ARTIFACT, not SYNTHETIC, in scalac terms. Adriaan, can you advise?

Mhhh, by the way, shouldn't this field be marked as transient, too?

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