Commit 23be80c
authored
JavaTypeFactory: type construction, classpath fast paths, TypeTable JARs (#7528)
Surface area for parser-time type construction is now centralized on
JavaTypeFactory and threaded through every TypeMapping (Java 8/11/17/21/25,
Groovy, Kotlin/KotlinIr, Scala, JavaReflection). Each compute* method
returns the cached instance keyed by signature, or allocates a stub,
registers it, and runs the supplied initializer. Registering the stub
before the initializer runs is what makes recursive resolution safe —
a recursive lookup for the same signature finds the stub instead of
looping.
The previous two-phase create*/populate* surface is gone.
DefaultJavaTypeFactory implements compute* directly. Initializers call
unsafeSet on the stub to populate fields, replacing the earlier
typeFactory.populateXxx indirection.
JavaTypeFactory.Provider is the parser-builder hand-off: parsers
(JavaParser, Java*Parser, GroovyParser, KotlinParser, ScalaParser,
GradleParser) and JavaTemplateParser all consume a Provider rather than a
JavaTypeCache directly. JavaTypeCache itself is unchanged but the cache()
configuration on parser builders is deprecated in favor of typeFactory().
RecipeScheduler exposes a rootCursorProvider so a recipe-scoped
JavaTypeFactory can flow into JavaTemplate parses, keeping splice-time
type identity consistent with the surrounding LST.
JavaSourceSet gains two fast-path accessors for recipes that index by
classpath:
- findClasspathType(fqn) — sorted-bsearch on a per-source-set
ClasspathIndex SPI, falls back to linear scan for legacy markers.
- classpathTypesInPackage(pkg) — sorted-prefix range scan.
Both go through ClasspathIndex.Subset, an SPI marker producers
(serializer V4 lazy backings) implement to short-circuit. ImportLayoutStyle
uses the per-package fast path. removeTypesMatching / removeTypesForGav
also dispatch through ClasspathIndex#withGavsRemoved when the marker
backing supports it, preserving lazy classpath views across recipe edits.
JavaSourceSetCompat retains the legacy materialization path under
@toBeRemoved(after = "2026-06-30") for recipes still calling
JavaSourceSet.build(...) directly. RecipeClassLoader parent-loads
JavaTypeFactory so recipe-side and parser-side factory instances unify.
TypeTable now writes per-artifact JARs (instead of classes-directories) so
javac uses ArchiveContainer with a cached central directory rather than
DirectoryContainer, which calls openat() per list() during template
parsing. Wall-mode profiling on AssertJ recipe / spring-data-commons:
__open worker samples 921 → 157 (-83%); recipe wall time 1m23s → 1m16s.
TypeTable annotations are now structured: AnnotationDeserializer is a
public class, TypeSignature parses ASM signatures, and TypeTableSink is
the abstract sink interface so writers don't go through string
round-trip.1 parent c3fc21b commit 23be80c
61 files changed
Lines changed: 4317 additions & 5350 deletions
File tree
- docs/superpowers
- plans
- specs
- rewrite-benchmarks/src/jmh/java/org/openrewrite/benchmarks/java
- rewrite-core/src/main/java/org/openrewrite
- marketplace
- rewrite-gradle/src/main/java/org/openrewrite/gradle
- rewrite-groovy/src/main/java/org/openrewrite/groovy
- rewrite-java-11/src/main/java/org/openrewrite/java
- isolated
- rewrite-java-17/src/main/java/org/openrewrite/java
- isolated
- rewrite-java-21/src/main/java/org/openrewrite/java
- isolated
- rewrite-java-25/src/main/java/org/openrewrite/java
- isolated
- rewrite-java-8/src/main/java/org/openrewrite/java
- rewrite-java-test/src/test/java/org/openrewrite/java/internal/template
- rewrite-java/src
- main/java/org/openrewrite/java
- internal
- parser
- template
- marker
- search
- style
- tree
- test/java/org/openrewrite/java/internal/parser
- rewrite-kotlin/src/main
- java/org/openrewrite/kotlin
- format
- internal
- kotlin/org/openrewrite/kotlin
- rewrite-scala/src/main
- java/org/openrewrite/scala
- scala/org/openrewrite/scala/internal
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 0 additions & 1353 deletions
This file was deleted.
Lines changed: 0 additions & 267 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | | - | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
Lines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
35 | 57 | | |
36 | 58 | | |
37 | 59 | | |
| |||
70 | 92 | | |
71 | 93 | | |
72 | 94 | | |
73 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
74 | 98 | | |
75 | 99 | | |
76 | 100 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
172 | 183 | | |
173 | 184 | | |
174 | 185 | | |
| |||
0 commit comments