Skip to content

Phase 4: Move critter-core into morphia-core#4205

Open
evanchooly wants to merge 6 commits intomasterfrom
phase-4-move-critter-core
Open

Phase 4: Move critter-core into morphia-core#4205
evanchooly wants to merge 6 commits intomasterfrom
phase-4-move-critter-core

Conversation

@evanchooly
Copy link
Member

Summary

Closes #4186

  • Move all Java source files from critter/core to core preserving package structure
  • Move all test files from critter/core to core
  • Add optional bytecode-generation deps to core/pom.xml: gizmo, asm-tree, asm-util, roaster-jdt
  • Add morphia-annotation-node plugin execution to core/pom.xml (generates AnnotationNodeExtensions.java)
  • Refactor Generators from static singleton to instance class with Generators(MorphiaConfig, Mapper) constructor
  • Make CritterGizmoGenerator methods static; add generators parameter to generate()
  • Update GizmoEntityModelGenerator to accept MorphiaConfig in constructor
  • Update PropertyFinder to pass config from mapper to propertyModelGenerator() calls
  • Update CritterClassLoader to accept configurable parent classloader (defaults to thread context CL)
  • Update CritterProcessor (critter-maven) to construct a Generators instance from the injected config

Test plan

  • ./mvnw install -pl :morphia-core -am -DskipTests -Ddeploy.skip=true -Dinvoker.skip=true — compiles successfully
  • ./mvnw test -pl :morphia-core -Dtest="TestGizmoGeneration,TestVarHandleAccessor,TypesTest,TestAccessorsMutators,TestPropertyModelGenerator" -Ddeploy.skip=true — 57 tests pass
  • ./mvnw install -pl :critter-maven -DskipTests -Ddeploy.skip=true -Dinvoker.skip=true — compiles successfully

🤖 Generated with Claude Code

- Move all Java source files from critter/core to core preserving package structure
- Move all test files from critter/core to core
- Add optional bytecode-gen deps to core/pom.xml (gizmo, asm-tree, asm-util, roaster-jdt)
- Add morphia-annotation-node plugin execution to core/pom.xml
- Refactor Generators from static singleton to instance class with constructor injection
- Make CritterGizmoGenerator methods static, add generators parameter to generate()
- Update GizmoEntityModelGenerator to accept MorphiaConfig in constructor
- Update PropertyFinder to pass config from mapper to propertyModelGenerator()
- Update CritterClassLoader to accept configurable parent classloader
- Update CritterProcessor (critter-maven) to use new Generators instance

Closes #4186

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@evanchooly evanchooly requested a review from Copilot March 6, 2026 15:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves Critter’s core/gizmo generation implementation into morphia-core and refactors generator configuration away from a static singleton into explicitly constructed instances.

Changes:

  • Refactors Generators from a static singleton to an instance constructed from MorphiaConfig + Mapper, updating call sites accordingly.
  • Makes CritterGizmoGenerator a static utility (in core) and threads config through generation paths (PropertyFinder, GizmoEntityModelGenerator).
  • Updates core/pom.xml with an annotation-node generator execution and optional bytecode-generation dependencies.

Reviewed changes

Copilot reviewed 13 out of 38 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
critter/critter-maven/src/main/kotlin/dev/morphia/critter/maven/CritterProcessor.kt Switches maven plugin to instance-based Generators and updated gizmo generation API.
critter/core/src/main/java/dev/morphia/critter/parser/Generators.java Removes singleton/lazy-loading; requires callers to provide config + mapper.
critter/core/src/main/java/dev/morphia/critter/parser/PropertyFinder.java Threads config into property model generation and moves to static CritterGizmoGenerator methods.
critter/core/src/main/java/dev/morphia/critter/parser/gizmo/GizmoEntityModelGenerator.java Uses injected MorphiaConfig instead of global Generators.INSTANCE.
critter/core/src/main/java/dev/morphia/critter/CritterClassLoader.java Allows configurable parent classloader; defaults to thread context CL.
core/src/main/java/dev/morphia/critter/parser/gizmo/CritterGizmoGenerator.java New static generator entry point in core using instance Generators.
core/pom.xml Adds annotation-node generation execution and optional asm/gizmo/roaster deps.
critter/core/src/test/** Updates tests to construct Generators explicitly and use static gizmo generator APIs.

evanchooly and others added 2 commits March 6, 2026 11:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Mar 6, 2026

@evanchooly I've opened a new pull request, #4206, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 38 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

core/src/main/java/dev/morphia/critter/parser/PropertyFinder.java:32

  • mapper is stored as a field but never used outside the constructor. This is dead state and will trigger warnings; remove the field or use it (e.g., use mapper.getConfig() instead of threading a separate config parameter if that’s the intent).

Comment on lines +24 to +25
private val critterClassLoader = CritterClassLoader()
private val generators = Generators(config, ReflectiveMapper(config))
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CritterClassLoader is created with the default constructor (parent = TCCL). In the Maven plugin context this can differ from the project/classesDirectory classLoader passed into CritterProcessor, and can lead to generated/accessed classes failing to resolve entity types. Construct CritterClassLoader with the provided classLoader (or otherwise ensure its parent is the same loader used to load entity classes).

Copilot uses AI. Check for mistakes.
Copilot AI and others added 2 commits March 6, 2026 16:47
…izmoGenerator

Co-authored-by: evanchooly <195021+evanchooly@users.noreply.github.com>
Fix InputStream resource leak in CritterGizmoGenerator
super(parent, Collections.emptyMap());
}

public CritterClassLoader() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot i think this should take a classloader so that the configure classloader on MorphiaConfig can be passed in. check other uses where we pass in classloaders to methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Copilot AI commented Mar 6, 2026

@evanchooly I've opened a new pull request, #4207, to work on those changes. Once the pull request is ready, I'll request review from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[0%] Phase 4: Move critter-core into morphia-core

3 participants