Skip to content

Smithy CLI bundles a Java 17 runtime, making smithy-java (1.1.0) codegen plugins impossible to run #3202

Description

@igaichenkov

Summary

The Smithy CLI installed via the official Homebrew tap ships with its own bundled Java 17 runtime image (the same applies to the official Linux installer bash script). The smithy-java 1.1.0 codegen-plugin JAR is itself built as Java 21 bytecode (class file version 65.0). Loading that plugin into the Homebrew CLI's bundled Java 17 runtime fails with UnsupportedClassVersionError before any code generation runs. There is no supported way to point the bundled launcher at a newer JDK, so the CLI cannot run smithy-java codegen out of the box.

Environment

  • Smithy CLI: 1.72.0 (also reproduced on 1.68.0), installed via brew install
  • Platform: macOS (arm64)
  • JAVA_HOME points to JDK Corretto 21.0.11, bundled runtime - Corretto 17.0.19

Steps to reproduce

smithy-build.json

{
  "version": "1.0",
  "maven": {
    "dependencies": [
      "software.amazon.smithy.java:codegen-plugin:1.1.0",
      "software.amazon.smithy.java:client-core:1.1.0",
      "software.amazon.smithy.java:aws-client-restjson:1.1.0"
    ]
  },
  "sources": ["model"],
  "projections": {
    "client-sdk": {
      "plugins": {
        "java-codegen": {
          "service": "com.example#MyService",
          "namespace": "com.example.client",
          "protocol": "aws.protocols#restJson1",
          "modes": ["client"]
        }
      }
    }
  }
}
smithy build

...
Validated model, now starting projections...

software/amazon/smithy/java/codegen/JavaCodegenPlugin has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0

Root cause

The Homebrew formula packages its own Java runtime. The smithy CLI launcher script (libexec/bin/smithy) hardcodes the JVM:

  JAVA_HOME="$APP_HOME"          # = the bundled libexec dir
  JAVACMD="$JAVA_HOME/bin/java"  # = bundled Corretto 17

so smithy build always executes on the bundled JDK 17.

Suggested resolution

  1. Bump the bundled runtime image to JDK 21 in the Homebrew tap (matching smithy-java's minimum) or
  2. Honor an external JDK — let SMITHY_JAVA_HOME / JAVA_HOME override the launcher's JAVACMD so users can supply a JDK 21 without touching internal jar paths; or
  3. Document the supported way to run smithy-java codegen with the Homebrew CLI, since the bundled JDK 17 cannot load it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions