Closed
Description
Environment
Compiler: 3.0.2, 3.1.0
JVM: tested on AdoptOpenJDK 8, Temurin 11 (compiler and runtime)
OS: tested on darwin x86_64 and darwin arm64
Minimized code
build.sbt
libraryDependencies ++= Seq(
"software.amazon.smithy" % "smithy-model" % "1.12.0"
)
Main.scala
import software.amazon.smithy.model.shapes._
object Main {
def main(args: Array[String]): Unit = {
val string = StringShape.builder.id("com.example#String").build
val int = IntegerShape.builder.id("com.example#Integer").build
val foo = StructureShape.builder
.id("com.example#Foo")
.addMember("bar", string.getId)
.addMember("baz", int.getId)
// commenting out the second addMember
// or explicitly typing the expression before it to `StructureShape.Builder` makes it compile
}
}
Output
Exception in thread main: java.lang.Exception: java.lang.IllegalAccessError: failed to access class software.amazon.smithy.model.shapes.NamedMembersShape$Builder from class Main$ (software.amazon.smithy.model.shapes.NamedMembersShape$Builder and Main$ are in unnamed module of loader 'app')
Expectation
Snippet should terminate without raising an exception. Snippet compiles and terminates successfully on 2.13.5 compiler. This builder pattern is used considerably throughout AWS SDK so likely affects other AWS libraries as well.