Skip to content

False-positive globally reachable private Java vars under -Ycheck-reentrant #20324

Closed as not planned
@WojciechMazur

Description

@WojciechMazur

Compiler version

3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY

Minimized example

Found in Scala 2 compiler forward-port #19897

private val Close = java.nio.CharBuffer.allocate(0)

Output

> scala-cli compile --server=false sandbox.scala -S 3.nightly -Ycheck-reentrant -Ylog:checkReentrant+ 
possible data race involving globally reachable variable isReadOnly in class CharBuffer: Boolean
  use -Ylog:checkReentrant+ to find out more about why the variable is reachable.
possible data race involving globally reachable variable address in class Buffer: Long
  use -Ylog:checkReentrant+ to find out more about why the variable is reachable.
2 errors found
Compilation failed

Expectation

isReadOnly and address are private/package private? variable, first of them can be only accessed via the accessor method. These should not be reported.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions