Skip to content

IllegalAccessError with package protected java class #10249

Open
@scabug

Description

@scabug

A.java

package a;
abstract class A {
    public final void m() { System.out.println("hi"); }
}

Test.scala

package a {
  // A is a class, so W does not conform to A in bytecode. an access (w: W).m() requires a cast to A.
  // If `A` is not accessible, there's no solution, need to issue an error. Currently crashes.
  trait W extends A
  class C extends W
}

object Test {
  def main(args: Array[String]): Unit = {
    val w: a.W = new a.C
    w.m()
  }
}

Crashes

java.lang.IllegalAccessError: tried to access class a.A from class Test$

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions