Skip to content

java.lang.IllegalAccessError: failed to access class software.amazon.smithy.model.shapes.NamedMembersShape$Builder #1311

@daddykotex

Description

@daddykotex

Reproduced in a scala REPL, but the same should happen in a regular java project with a dependency on smithy-model 1.22.0:


scala> :paste
// Entering paste mode (ctrl-D to finish)

import software.amazon.smithy.model.shapes.MemberShape
import software.amazon.smithy.model.shapes.StructureShape
import software.amazon.smithy.model.traits.ErrorTrait

val structMember = MemberShape
    .builder()
    .id("test#struct$testing")
    .target("smithy.api#Integer")
    .build()
val struct =
    StructureShape
    .builder()
    .id("test#struct")
    .addMember(structMember)
    .addTrait(new ErrorTrait("client"))
    .build()


// Exiting paste mode, now interpreting.

java.lang.IllegalAccessError: failed to access class software.amazon.smithy.model.shapes.NamedMembersShape$Builder from class $iw (software.amazon.smithy.model.shapes.NamedMembersShape$Builder is in unnamed module of loader sbt.internal.inc.classpath.ClasspathUtil$$anon$2 @2dacc87b; $iw is in unnamed module of loader scala.tools.nsc.interpreter.IMain$TranslatingClassLoader @30001570)
  ... 67 elided

But if I do:

scala> :paste
// Entering paste mode (ctrl-D to finish)

import software.amazon.smithy.model.shapes.MemberShape
import software.amazon.smithy.model.shapes.StructureShape
import software.amazon.smithy.model.traits.ErrorTrait

val structMember = MemberShape
    .builder()
    .id("test#struct$testing")
    .target("smithy.api#Integer")
    .build()
val struct =
    StructureShape
    .builder()
    .id("test#struct")
    .addTrait(new ErrorTrait("client"))
    .addMember(structMember)
    .build()


// Exiting paste mode, now interpreting.

import software.amazon.smithy.model.shapes.MemberShape
import software.amazon.smithy.model.shapes.StructureShape
import software.amazon.smithy.model.traits.ErrorTrait
val structMember: software.amazon.smithy.model.shapes.MemberShape = (member: `test#struct$testing`)
val struct: software.amazon.smithy.model.shapes.StructureShape = (structure: `test#struct`)

It works fine. The only difference is the order of the calls in the builder. If I move .addTrait(new ErrorTrait("client")) after .addMember(structMember), it fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions