Skip to content

Java coder emits unqualified @link refs for nested case-classes, failing the Javadoc build #449

@joshsh

Description

@joshsh

Summary

The Java coder emits {@link hydra.<ns>.<CaseClass>} Javadoc references for sum-type case-classes, but those case-classes are nested static classes of their parent type, so the correct reference is {@link hydra.<ns>.<Parent>.<CaseClass>}. The unqualified links fail javadoc with error: reference not found. Because the per-package Maven build uses withJavadocJar() with strict (fail-on-error) Javadoc, this fails gradle build and the publishAggregationToCentralPortal task.

Surfaced during the 0.16.0 Java publish dry-run (heads/java/bin/publish-maven.sh on dist/java/hydra-kernel): 99 reference not found errors (plus 1 @param name not found) across multiple sum types (Associativity, CoderDirection, CheckingError, Definition, ComparisonConstraint, CaseConvention, Comparison, …). All errors are cosmetic Javadoc references; there are no structural/compile errors.

Example

dist/java/hydra-kernel/src/main/java/hydra/ast/Associativity.java:

public abstract class Associativity ... {
  public static final class None extends hydra.ast.Associativity ... { ... }   // nested
  public interface Visitor<R> {
    /** Visit the {@link hydra.ast.None} case. */          // should be hydra.ast.Associativity.None
    R visit(None instance);
  }
}

hydra.ast.None does not exist as a top-level type; None is hydra.ast.Associativity.None.

Root cause

In the Java coder (packages/hydra-java/src/main/java/hydra/sources/java/Coder.java, with its Haskell-DSL twin packages/.../Hydra/Sources/Java/Coder.hs), the doc-comment builders that emit {@link ...} use <package>.<caseName> and omit the enclosing type. Affected emission sites (the string("...{@link ") markers): the Visitor visit methods, the Visitor/PartialVisitor interface headers, the immutable constructors, and the copy/withX methods. This is a follow-up gap to #309 ("Sanitize class names in Java coder javadoc @link refs"), which fixed link sanitization but did not qualify nested case-classes; the volume increased in 0.16 because #349 began emitting doc descriptions as method-level Javadoc, multiplying @link references.

Fix

Qualify nested case-class @link targets with the enclosing type: {@link <package>.<Parent>.<CaseName>}. Fix at the coder emission sites in Coder.java/Coder.hs (not in generated dist/), regenerate the Java distribution, and confirm gradle build (which runs javadoc) succeeds for dist/java/hydra-kernel and the other published packages. Keep strict Javadoc (do not disable failOnError) — matching the #309 decision to keep generated Javadoc honest.

Impact / scope

  • Affects the Java/Maven Central publish (Central requires the Javadoc jar).
  • Does not affect Haskell/Hackage, Python, or the common test suite — CI's "Java tests" job is the self-host test run and does not exercise the Javadoc/publish path, which is why this was invisible to CI and only caught at publish time.
  • All Java sum-type files are affected (kernel + downstream packages).

Repro

export JAVA_HOME=$(/usr/libexec/java_home -v 19)
cd dist/java/hydra-kernel && gradle build -x test   # fails at :javadoc with 99 "reference not found"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    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