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

java.lang.IllegalAccessError: failed to access class com.linecorp.armeria.server.AbstractContextPathServicesBuilder #21797

Open
chungonn opened this issue Oct 17, 2024 · 11 comments
Assignees
Labels
compat:java itype:bug stat:fixed in next The issue was fixed in Next and only still applies to LTS.

Comments

@chungonn
Copy link

Compiler version

Scala version 3.3.3 and 3.5.1

Minimized code

The code below runs in Java. But in Scala, it throws an IllegalAccessError exception.

package experiment

import com.linecorp.armeria.common.HttpResponse
import com.linecorp.armeria.server.Server

@main def hello(): Unit =
  val server = Server.builder()
    .contextPath("/v1")
    .service("/", (ctx, req) => HttpResponse.of("Hello, world"))
    .and()
    .build()
    .start()

  println(s"server started = ${server}")

build.sbt

val scala3Version = "3.5.1"

lazy val root = project
  .in(file("."))
  .settings(
    name := "test-armeria",
    version := "0.1.0-SNAPSHOT",

    scalaVersion := scala3Version,

    libraryDependencies ++= Seq(
      "com.linecorp.armeria" % "armeria" % "1.30.1",
    )
  )

Output

Exception in thread "main" java.lang.IllegalAccessError: failed to access class com.linecorp.armeria.server.AbstractContextPathServicesBuilder from class experiment.Main$package$ (com.linecorp.armeria.server.AbstractContextPathServicesBuilder and experiment.Main$package$ are in unnamed module of loader 'app')
	at experiment.Main$package$.hello(Main.scala:9)
	at experiment.hello.main(Main.scala:6)

Expectation

The code should run without error.

@chungonn chungonn added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 17, 2024
@chungonn
Copy link
Author

chungonn commented Oct 17, 2024

The same code works in Scala 2.12.13

package experiment

import com.linecorp.armeria.common.HttpResponse
import com.linecorp.armeria.server.Server
object Test {

  def main(args: Array[String]): Unit = {
    val server = Server.builder()
      .contextPath("/v1")
      .service("/", (ctx, req) => HttpResponse.of("Hello, world"))
      .and()
      .build()
      .start()

    println(s"server started = ${server}")
  }
}
val scala3Version = "2.12.13"

lazy val root = project
  .in(file("."))
  .settings(
    name := "test-armeria",
    version := "0.1.0-SNAPSHOT",

    scalaVersion := scala3Version,

    libraryDependencies ++= Seq(
      "com.linecorp.armeria" % "armeria" % "1.30.1",
    )
  )

@Gedochao
Copy link
Contributor

This seems to have been fixed in nightly ( 3.6.1-RC1-bin-20241016-2fc299b-NIGHTLY), but not in 3.5.2-RC2.
We might need to bisect the fix and backport to the LTS.
cc @prolativ

The following works:

//> using scala 3.6.1-RC1-bin-20241016-2fc299b-NIGHTLY
//> using dep com.linecorp.armeria:armeria:1.30.1
package experiment

import com.linecorp.armeria.common.HttpResponse
import com.linecorp.armeria.server.Server
object Test {

  def main(args: Array[String]): Unit = {
    val server = Server.builder()
      .contextPath("/v1")
      .service("/", (ctx, req) => HttpResponse.of("Hello, world"))
      .and()
      .build()
      .start()

    println(s"server started = ${server}")
  }
}

@Gedochao Gedochao added compat:java stat:needs minimization Needs a self contained minimization stat:needs bisection Need to use nightly builds and git bisect to find out the commit where this issue was introduced stat:fixed in next The issue was fixed in Next and only still applies to LTS. and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 17, 2024
@chungonn
Copy link
Author

@Gedochao I confirmed that 3.6.1-RC1-bin-20241016-2fc299b-NIGHTLY fixes the problem

@chungonn
Copy link
Author

I would be grateful if this fixed can be backport to the next possible 3.5.x. Thanks in advance

@Gedochao
Copy link
Contributor

Gedochao commented Oct 17, 2024

I would be grateful if this fixed can be backport to the next possible 3.5.x. Thanks in advance

It's likely too late for it to be backported to 3.5.2, unless we'd have another RC.
which I'm hoping we won't as 3.5.2 (the last in the 3.5.x line) is being released as we speak.
See:

tagging @WojciechMazur just in case.
Otherwise, I'm guessing the fix would be included in 3.6.0 or 3.6.1

@chungonn
Copy link
Author

Noted with thanks!

@WojciechMazur
Copy link
Contributor

3.5.2 final has already been shipped. It will be backported to 3.6.0 or 3.6.1

@prolativ
Copy link
Contributor

prolativ commented Oct 17, 2024

I needed to slightly modify the snippet to close the server so that it doesn't hang the bisecting tests.
/tmp/bisect/ArmeriaServer.scala:

//> using dep com.linecorp.armeria:armeria:1.30.1

import com.linecorp.armeria.common.HttpResponse
import com.linecorp.armeria.server.Server
object Test {
  def main(args: Array[String]): Unit = {
    val server = Server.builder()
      .contextPath("/v1")
      .service("/", (ctx, req) => HttpResponse.of("Hello, world"))
      .and()
      .build()
    println(s"starting server")
    val started = server.start()
    started.get()
    println(s"server started")
    server.stop()
    println(s"server stopped")
  }
}

Bisected with

scala-cli project/scripts/bisect.scala -- --should-fail --releases 3.5.1-RC1-bin-20240628-1efbb92-NIGHTLY... run /tmp/bisect/ArmeriaServer.scala

The bisect points to #21362

@prolativ prolativ removed stat:needs minimization Needs a self contained minimization stat:needs bisection Need to use nightly builds and git bisect to find out the commit where this issue was introduced labels Oct 17, 2024
@WojciechMazur
Copy link
Contributor

Ah, I've just bisected it to the same commit, adding sys.exit(0) would do the job as well for bisect purpose.
I'll start backporting this to 3.6.0-RC1. I propose to close it after backporting to 3.3.5 LTS

@prolativ
Copy link
Contributor

@WojciechMazur as far as I can see the issue was fixed on 10.08, which was before the cut-off of release-3.6.0, so this shouldn't need any backporting for 3.6.x. Or did I miss something?

@WojciechMazur
Copy link
Contributor

That's correct, I've just checked to ensure it's included, so no work needed for Next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat:java itype:bug stat:fixed in next The issue was fixed in Next and only still applies to LTS.
Projects
None yet
Development

No branches or pull requests

4 participants