elastic/elasticsearch · error · UnsupportedOperationException

Architecture {}

Error message

Architecture {}

What it means

UnsupportedOperationException from the toolchain resolver's architecture-name mapping. toArchString() handles only X86_64, AARCH64, and X86; any other Architecture falls to default.

Source

Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/toolchain/AbstractCustomJavaToolchainResolver.java:37

    static String toOsString(OperatingSystem operatingSystem) {
        return toOsString(operatingSystem, null);
    }

    static String toOsString(OperatingSystem operatingSystem, JvmVendorSpec v) {
        return switch (operatingSystem) {
            case MAC_OS -> (v == null || v.equals(JvmVendorSpec.ADOPTIUM) == false) ? "macos" : "mac";
            case LINUX -> "linux";
            case WINDOWS -> "windows";
            default -> throw new UnsupportedOperationException("Operating system " + operatingSystem);
        };
    }

    static String toArchString(Architecture architecture) {
        return switch (architecture) {
            case X86_64 -> "x64";
            case AARCH64 -> "aarch64";
            case X86 -> "x86";
            default -> throw new UnsupportedOperationException("Architecture " + architecture);
        };
    }

    protected static boolean anyVendorOr(JvmVendorSpec givenVendor, JvmVendorSpec expectedVendor) {
        return givenVendor.matches("any") || givenVendor.equals(expectedVendor);
    }
}

View on GitHub (pinned to db6a809a66)

Solutions

  1. Verify the host CPU maps to X86_64, AARCH64, or X86 in Gradle's detection.
  2. Add an explicit case branch with the download catalogue's arch token if a new architecture must be supported.
  3. Align the Gradle version with the resolver's known Architecture set.

Example fix

// before
case X86 -> "x86";
default -> throw new UnsupportedOperationException("Architecture " + architecture);

// after
case X86 -> "x86";
case RISCV64 -> "riscv64";
default -> throw new UnsupportedOperationException("Architecture " + architecture);
Defensive patterns

Strategy: validation

Validate before calling

Set<Architecture> supported = EnumSet.of(Architecture.X86_64, Architecture.AARCH64, Architecture.X86);
if (!supported.contains(architecture)) {
    throw new IllegalStateException("Unsupported architecture for custom toolchain: " + architecture);
}

Type guard

static boolean isArchSupported(Architecture a) {
    return a == Architecture.X86_64 || a == Architecture.AARCH64 || a == Architecture.X86;
}

Prevention

When it happens

Trigger: Gradle reports an Architecture enum value such as ARM64 (non-AARCH64 naming) or a future constant (e.g. RISCV64, LOONGARCH64) when resolving a custom JDK download.

Common situations: Building on emerging architectures not yet enumerated; Gradle version mismatch introducing/renaming an Architecture constant; a test injecting an unsupported architecture.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/b3892dda546ba80d. Report an issue: GitHub.