Skip to content

Inlining doesn't respect JPMS access restrictions #11812

Open
@szeiger

Description

@szeiger

The Scala optimizer respects Java access modifiers so it doesn't inline any code that needs to call other code which is not accessible at the call site. This is not the case for JPMS restrictions. For example, running on OpenJDK 11 with -opt:l:inline -opt-inline-from:**:

Welcome to Scala 2.13.1 (OpenJDK 64-Bit Server VM, Java 11.0.5).
Type in expressions for evaluation. Or try :help.

scala> "".toDouble
java.lang.IllegalAccessError: class  (in unnamed module @0x69b88f85) cannot access class jdk.internal.math.FloatingDecimal (in module java.base) because module java.base does not export jdk.internal.math to unnamed module @0x69b88f85
  ... 36 elided

This happens because the String:toDouble implementation from the JDK gets inlined into user code even though it cannot access jdk.internal.math.FloatingDecimal from outside the JDK.

(It's probably a bad idea to inline from the JDK in the first place but the problem will become more pronounced as more and more libraries make use of Java Modules, too.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions