quarkusio/quarkus · error · java.lang.UnsupportedOperationException

Module name not supported while building

Error message

Module name not supported while building

What it means

ResolvedDependencyBuilder is a builder for ResolvedDependency; the JPMS module name is only computed on the built, resolved object, not during construction. Calling getModuleName() on the builder throws UnsupportedOperationException by design.

Solutions

  1. Call build() first and invoke getModuleName() on the resulting ResolvedDependency
  2. Restructure code so module-name inspection happens after dependency resolution completes, not during building
  3. Check the variable's static type; if it is ResolvedDependencyBuilder, you are in the build phase

Example fix

// before
String name = builder.getModuleName();
// after
String name = builder.build().getModuleName();
Defensive patterns

Strategy: type-guard

Validate before calling

String safeModuleName(Object o) {
    return (o instanceof ResolvedDependency rd)
        ? rd.getModuleName()
        : null; // builders do not support getModuleName
}

Type guard

String moduleNameIfResolved(Object o) {
    if (!(o instanceof ResolvedDependency)) return null;
    return ((ResolvedDependency) o).getModuleName();
}

Try / catch

try {
    return builder.getModuleName();
} catch (UnsupportedOperationException e) {
    return builder.build().getModuleName(); // only valid post-build
}

Prevention

When it happens

Trigger: Calling getModuleName() on a ResolvedDependencyBuilder instance (e.g. while iterating builder objects during dependency resolution) instead of on the ResolvedDependency returned by build().

Common situations: Code refactored from using ResolvedDependency directly to the builder API, accidentally calling getModuleName on the builder mid-resolution; debug code inspecting builders.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/07d4b17b0b9165c1. Report an issue: GitHub.

Appendix: source

Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ResolvedDependencyBuilder.java:163

    }

    @Override
    public Collection<ArtifactCoords> getDependencies() {
        return deps;
    }

    public ResolvedDependencyBuilder setDirectDependencies(Collection<Dependency> directDeps) {
        this.directDeps = directDeps;
        return this;
    }

    @Override
    public Collection<Dependency> getDirectDependencies() {
        return directDeps;
    }

    public String getModuleName() {
        throw new UnsupportedOperationException("Module name not supported while building");
    }

    @Override
    public ResolvedDependency build() {
        return new ResolvedArtifactDependency(this);
    }

    @Override
    public Map<String, Object> asMap(MappableCollectionFactory factory) {
        final Map<String, Object> map = factory.newMap(7);
        putInMap(this, map, factory);
        return map;
    }
}

View on GitHub (pinned to e1c734241f)