Interface JavaTypeFactory

All Known Implementing Classes:
DefaultJavaTypeFactory

@Incubating(since="8.82.0") public interface JavaTypeFactory
Factory for constructing JavaType instances during parsing.

Two method families correspond to two construction shapes:

  1. compute* — stub-then-initialize. The factory constructs a stub, registers it in the cache, then runs a Consumer that populates the stub via unsafeSet. Registering before the initializer runs is what makes recursive resolution during the initializer safe — reserved for types whose construction graph can recurse back to the same key:
  2. *For — atomic build. The caller supplies a Supplier that returns a fully-constructed instance; the factory caches and returns it. No half-built object is ever observable through the cache. Used for variants without self-recursion on the same key: methodFor(java.lang.String, java.util.function.Supplier<org.openrewrite.java.tree.JavaType.Method>, java.util.function.Consumer<org.openrewrite.java.tree.JavaType.Method>), variableFor(java.lang.String, java.util.function.Supplier<org.openrewrite.java.tree.JavaType.Variable>), arrayFor(java.lang.String, java.util.function.Supplier<org.openrewrite.java.tree.JavaType.Array>), intersectionFor(java.lang.String, java.util.function.Supplier<org.openrewrite.java.tree.JavaType.Intersection>).

Parser code that needs a canonical identity-stable JavaType.Class for an FQN that has no Symbol/AST node (synthesized JVM facades, library placeholders, etc.) should call computeClass(java.lang.String, long, org.openrewrite.java.tree.JavaType.FullyQualified.Kind, java.util.function.Consumer<org.openrewrite.java.tree.JavaType.Class>) with an empty initializer. There is no separate "lookup" surface — the absence of richer attribution is signaled at the call site by an empty initializer.

Key formats

Two distinct keying schemes coexist; mixing them within one factory lifetime is a caller bug.