Skip to content

dotc, scalac and javac lead to java.lang.VerifyError #8101

Closed
@anatoliykmetyuk

Description

@anatoliykmetyuk

minimized code

Foo.scala:

trait Foo {
  def f: String = ???
}

JavaFoo.java:

public abstract class JavaFoo {
    public abstract int read();
}

iss1.scala:

class Bar extends JavaFoo with Foo {
  def read(): Int = ???
}

@main def Test =
  val stdout = new Bar

Compile the first two files with scalac and javac respectively:

javac JavaFoo.java; scalac Foo.scala

Then compile and run the third file with the *.class files from the scalac and javac invocation on the classpath. From SBT:

;dotty-bootstrapped/dotc  -classpath /path/to/classfiles/  /path/to/iss1.scala ;dotty-bootstrapped/dotr  -classpath /path/to/classfiles/  Test
Runtime output
Exception in thread "main" java.lang.VerifyError: Bad operand type when invoking <init>
Exception Details:
  Location:
    Bar.<init>()V @5: invokespecial
  Reason:
    Invalid type: 'Bar' (current frame, stack[0])
  Current Frame:
    bci: @5
    flags: { }
    locals: { 'Bar' }
    stack: { 'Bar' }
  Bytecode:
    0x0000000: 2ab7 000b 2ab7 000c b1

	at iss1$package$.Test(iss1.scala:6)
	at Test.main(iss1.scala:5)

If you debug with -Xprint, at some point Bar has a bad constructor which calls super twice:

  ) class Bar extends JavaFoo, Foo {
    def <init>(): Unit =
      {
        super()
        super[Foo]()
        ()
      }

expectation

Should run correctly.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions