New Java Type Cache
One of the strengths of OpenRewrite is that its tree elements include semantic type information. In the case of the Java parser, type attribution is achieved by mapping type information from the Javac compiler into Rewrite's Java-type system. In previous versions of Rewrite, the framework used the flyweight pattern to cache the type information and promote referential de-duplication. The flyweights prevented memory exhaustion and reduced the size of serialized ASTs. An additional feature of Rewrite's Java-type system was that it would artificially break cycles by introducing a Cyclic reference.
As the library has evolved (and we have started collecting more type information), it has exposed limitations and gaps within the legacy type system. This release introduces a new Java Type caching system that is better suited to large-scale, automated refactoring. Most of the changes are "behind-the-scenes" and lead to a much more accurate type-attribution system.
Other Enhancements
- New Recipe: Add new properties to a properties file. #1152
- New Recipe: Change Maven plugin configuration #1190
- New Recipe: Change Maven packaging #1208 #1134
- New Recipe: Add dependencies to maven plugins #1214 #1134
- New Recipe: Use
Map
notation for Gradle dependency declarations 2802d60 - New Recipe: Removing interfaces from class declarations #1241
- Utilities for normalizing names between kebab-case, snake-case, camel-case, etc #1188
- Add support to ImportLayoutStyle for specific packages to fold. #1231 #1206
- Add support to parse DTD Markup in XML. #1226
- Refactored the Java cleanup recipes #1194
- Build is now using Gradle enterprise
- GenerateGetter does not work for primitives #1301
Fixes
- Git provenance is optional and may be null when source files are not in a Git repository. #1148
- Do not left-shift YAML prefix comments following the previous element on the same line. #1149 #1142
XmlParser
throws NPE when parsing a DTC without anexternalId
#1150JsonParserVisitor
parses longs withparseInt
#1145- Scope which types of
SourceFile
are accepted by visitors. #1151 ChangePackage.updateType
is never called #1140- Mismatched parenthesis in
MissingOverrideAnnotation
#1153 AddImport
should not addjava.lang
to classes including classes in the default package #1158 #1156- Add
Anchor
andAlias
models to YAML, and alias support forYaml.Scalar
values. #1155 - Space between annotation arguments after the comma is empty #1162
- Fix import folding collisions in
AddImport
7007421 - Fix
JavaTemplate
method argument substitution and Java8 type mapping cad4aed 9ab35a9 UpgradeParentPom
may downgrade versions #1107- If a Maven visitor successfully changes a non-Maven
Xml.Document
, it is transformed into aMaven
with an empty model #1167 - Upgrade dependency adds an overridden version property by #1170
- Fix TypeMapping.getClasspathElement() so that it also works with Windows paths 5cdd6e0
- Several fixes to provenance information in Maven 413ded9 8a0264d abc3978
- JavaVisitor.visitFieldAccess() does not allow a FieldAccess to be replaced by any other AST element #1174
- Fix in
ChangeMethodTargetToStaticVisitor
to remove potential namespace conflicts. 2be7989 - Fixes for enum types in
BlankLinesVisitor
fefdc00 35bb53f - XML
AutoFormat
always formats maven poms with 4 space indentation #1186 - Enhance Maven
AddPlugin
to correctly format any executions/configuration/dependencies #1187 YamlParser
throwsEmptyStackException
#1180- Expand
LatestRelease
to support timestamped suffixes 5503aac - Parse empty Java source file #1192
- Make sure to use a continuation indent on a lambda when ANY method argument has a newline. #1173
FindProperties
in rewrite-properties missingvisitMarkers
#1195FindProperties
should have a marker on the value, same as YAML and other search results #1196- Relaxed binding on YAML and properties #1182 #1168
- Do not remove blocks that only contain comments in
EmptyBlockVisitor
ef074f5 NoValueOfOnStringType
removes necessary call to String#valueOf in string concatenation #1200MethodNameCasing
should not rename overridden methods by #1217Autodetect
counts prefixes with neither tabs nor spaces as spaces #1221UnnecessaryExplicitTypeArguments
can lead to uncompilable code due to introduced ambiguity #1211MinimumSwitchCases
should prepend enum class to values or statically import them #1212- XML
AutoFormat
under-indents tag values #1189 - NestedEnumsAreNotStatic reformats whole enum #1222
- EmptyBlock recipe should not add throw RuntimeException. #1210
- SpacesVisitor can throw an NPE when operating on Groovy Closures which, unlike Java, can have empty parameters list #1224
IndexOfChecksShouldUseAStartPosition
should ignore cases where the start position is undefined and the index expected to be greater than 0 #1225UnnecessaryThrows
removesthrows
from the parent class and breaks subclasses overriding methods #1207- OrderPomElements removes valid tags while reordering GAVs. #1228
- Preserve new line layout of pom's reordered by
OrderPomElements
. #1230 MethodMatcher
should acknowledgematchOverrides
#1219- Add JavaTemplate coordinate for replacing just the arguments of an annotation #1234
- Refactor JavadocVisitor initialization to make it easier to customize #1233
- JavaTemplate throws Index 0 out of bounds for length 0 #1198
- WrappingAndBraces for Gradle creates incorrect spacing #1237
- Performance fixes in 'MethodParamPad` fd469b4 77af643
- ExplicitLambdaArgumentTypes should add import if necessary #1242
- Avoid
Class.forName
for primitives inMethodMatcher
, bettertoString
onJavaType
ChangeMethodAccessLevel
should pass onmatchOverrides
#1240<?m2e ...?>
tag results extraneous input warning when parsing pom #1243- Converge ChangeDependencyVersion along with the other ChangeDependency* recipes. a0f37c4
- ExplicitLamdaArgumentTypes inserts null as type #1246
- The diff on Result should account for relative paths b9f2c25
- ExplicitInitialization removes initialization expression interface fields #1247
- Use the correct prefix if the value is a Sequence in Yaml ChangeValue 67ca7f5
- Handle exact version ranges in VersionRangeParser #1250
- RemoveUnusedImports is incorrectly removing an import for an annotation on an enum value. #1251
- Update ChangePropertyKey to prevent moving entries to nonscalar nodes or those nested under a sequence #1257
- Add isAcceptable override to JavaVisitor to fix ClassCastExceptions ad96bdf
- Fix type attribution on references in JavaDocs #1273
- The RocksdbMavenPomCache can lead to heap exhaustion. #1284
- Update YAML IndentsVisitor to maintain correct sequence entry indent. #1275
- Refactor AddSerialVersionUidToSerializable to improve performance only checking ClassDeclaration Variables
- Fixes to Java templates and reduce heap pressure #1294 #1288
- Refactor build scripts to use toolchain instead of javac executable #1299
- Merge recipe with sequences within map bad indent #1292
- Rework MavenPomCache and introduce TTL #1304
- When using ListUtils.flatMap to replace an item with a collection, subsequent items may be incorrect #1309
- Fix "too many files open" issues eb92f81 079e715
- MavenDownloader was exiting on first download failure 448094d
Full Changelog: v7.16.0...v7.17.0