Skip to content

[OPENJPA-2958] Add ImplHelper.registerUnenhancedInstance() - #170

Merged
rzo1 merged 2 commits into
masterfrom
OPENJPA-2958
Sep 2, 2026
Merged

[OPENJPA-2958] Add ImplHelper.registerUnenhancedInstance()#170
rzo1 merged 2 commits into
masterfrom
OPENJPA-2958

Conversation

@rzo1

@rzo1 rzo1 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

BrokerImpl reached into the public mutable ImplHelper._unenhancedInstanceMap to register the persistence-capable instance of an unenhanced one. This adds a method for it and routes all three write sites through it, so the registry is no longer written to from outside the class that owns it. Behaviour is unchanged — the method is the same overwriting put.

The field itself is now package private. Nothing outside ImplHelper reads or writes it any more, and 4.2.0 already removes public API elsewhere, so keeping it public for compatibility was not worth it. Package private rather than private so the unit test, which lives in the same package, can still read a registration back: there is no public read path, since toPersistenceCapable() rejects a non-manageable instance before it reaches the map.

BrokerImpl reached into the public mutable ImplHelper._unenhancedInstanceMap
to register the persistence capable instance of an unenhanced one. Add a
method for it and route all three write sites through it, so the registry
is no longer written to from outside the class that owns it. Behaviour is
unchanged: the method is the same overwriting put.

The field is deprecated to point callers at the method. It stays public:
its type is a reference type, so it is never inlined into callers, and
making it private would turn into a NoSuchFieldError at runtime for
anything compiled against 4.1.x rather than a compile error on upgrade.
Making it private belongs in a major release.
@rzo1 rzo1 self-assigned this Aug 29, 2026
@rzo1
rzo1 requested review from cristof and solomax August 29, 2026 18:17
Comment thread openjpa-kernel/src/main/java/org/apache/openjpa/util/ImplHelper.java Outdated
Review feedback: 4.2.0 already removes public API, so keeping the field
public for compatibility was not worth it. Nothing outside ImplHelper reads
or writes it any more. Package private rather than private so that the unit
test, which lives in the same package, can still read a registration back;
there is no public read path for it, since toPersistenceCapable() rejects a
non manageable instance before it reaches the map.
@rzo1
rzo1 requested a review from solomax August 31, 2026 19:26
@rzo1
rzo1 merged commit a1e3c27 into master Sep 2, 2026
4 checks passed
@rzo1
rzo1 deleted the OPENJPA-2958 branch September 2, 2026 17:14
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.

3 participants