Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Panache bytecode enhancers to benefit from class transformers caches #40192

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ void replaceFieldAccesses(CombinedIndexBuildItem index,
PanacheJpaEntityAccessorsEnhancer entityAccessorsEnhancer = new PanacheJpaEntityAccessorsEnhancer(index.getIndex(),
modelInfo);
for (String entityClassName : entitiesWithExternallyAccessibleFields) {
transformers.produce(new BytecodeTransformerBuildItem(entityClassName, entityAccessorsEnhancer));
final BytecodeTransformerBuildItem transformation = new BytecodeTransformerBuildItem.Builder()
.setClassToTransform(entityClassName)
.setCacheable(true)
.setVisitorFunction(entityAccessorsEnhancer)
.build();
transformers.produce(transformation);
}

// Replace field access in application code with calls to accessors
Expand All @@ -125,8 +130,17 @@ void replaceFieldAccesses(CombinedIndexBuildItem index,
continue;
}
produced.add(cn);
transformers.produce(
new BytecodeTransformerBuildItem(cn, panacheFieldAccessEnhancer, entityClassNamesInternal));
//The following build item is not marked as CacheAble intentionally: see also https://github.com/quarkusio/quarkus/pull/40192#discussion_r1590605375.
//It shouldn't be too hard to improve on this by checking the related entities haven't been changed
//via LiveReloadBuildItem (#isLiveReload() && #getChangeInformation()) but I'm not comfortable in making this
//change without having solid integration tests.
final BytecodeTransformerBuildItem transformation = new BytecodeTransformerBuildItem.Builder()
.setClassToTransform(cn)
.setCacheable(false)//TODO this would be nice to improve on: see note above.
.setVisitorFunction(panacheFieldAccessEnhancer)
.setRequireConstPoolEntry(entityClassNamesInternal)
.build();
transformers.produce(transformation);
}
}
}
Expand Down
Loading