fix: make AbstractPersistentActorWithTimers and AbstractFSMWithStash - #3477
Open
pjfanning wants to merge 2 commits into
Open
fix: make AbstractPersistentActorWithTimers and AbstractFSMWithStash#3477pjfanning wants to merge 2 commits into
pjfanning wants to merge 2 commits into
Conversation
…subclassable from Java on Scala 3 (apache#3475) * fix: make AbstractPersistentActorWithTimers and AbstractFSMWithStash subclassable from Java on Scala 3 Motivation: Extending `AbstractPersistentActorWithTimers` from Java fails to compile against the Scala 3 artifacts: class TestActor inherits unrelated defaults for aroundPreRestart(Throwable,Option<Object>) from types Timers and Eventsourced Both `Timers` and `Eventsourced` implement `aroundReceive`, `aroundPreRestart` and `aroundPostStop`. Scala 3 does emit the mixin forwarder into the class, but flags it `ACC_BRIDGE, ACC_SYNTHETIC`; javac ignores synthetic and bridge members when resolving inherited members, so it falls back to the two interface defaults and rejects the subclass. Scala 2.13 emits the same forwarder without those flags, which is why the 2.12/2.13 artifacts work. A javac probe over every Java-facing `Abstract*` class that mixes in more than one trait found one other class with the same defect: `AbstractFSMWithStash`, where `FSM` and `UnrestrictedStash` both implement `postStop`. Modification: Give both classes real (non-synthetic) overrides of the conflicting members that just delegate to `super`, which resolves exactly like the forwarders they replace. `AbstractFSMWithStash.postStop` deliberately carries no `@throws(classOf[Exception])`, since `FSM.postStop` declares no checked exceptions and a wider throws clause is not a valid override for javac. Add Java sources exercising both classes so the Scala 3 build fails if this regresses. Result: Java subclasses of `AbstractPersistentActorWithTimers` and `AbstractFSMWithStash` compile against the Scala 3 artifacts. No other Java-facing multi-trait base class in the build is affected. Tests: - sbt "++3.3.8" "persistence/testOnly org.apache.pekko.persistence.TimerPersistentActorSpec" - 5 succeeded, 0 failed - sbt "++3.3.8" "actor-tests/testOnly org.apache.pekko.actor.AbstractFSMWithStashActorTest org.apache.pekko.actor.AbstractFSMActorTest" - 2 succeeded, 0 failed - sbt "persistence/testOnly org.apache.pekko.persistence.TimerPersistentActorSpec" - 5 succeeded, 0 failed - sbt "actor-tests/testOnly org.apache.pekko.actor.AbstractFSMWithStashActorTest org.apache.pekko.actor.AbstractFSMActorTest" - 2 succeeded, 0 failed - sbt headerCreateAll javafmtAll scalafmtAll scalafmtSbt (JDK 17) - no churn outside the changed files - sbt +mimaReportBinaryIssues - Not run, left to CI Binary Compatibility job References: Fixes apache#3474 * compile checks * fix: mark deprecated PersistentFSM compile guard as deprecated for -Werror
Motivation: The cherry-pick of apache#3475 does not compile on 1.7.x. That branch has an older API surface than main: - `actor-tests` has no JUnit 5; `PekkoJUnitJupiterActorSystemResource` and the `org.junit.jupiter` packages do not exist there. - `UntypedAbstractLoggingActor`, `UntypedAbstractActorWithStash`, `UntypedAbstractActorWithUnboundedStash` and `UntypedAbstractActorWithUnrestrictedStash` do not exist on 1.7.x. Modification: Port `AbstractFSMWithStashActorTest` to JUnit 4 with `JUnitSuite` and `PekkoJUnitActorSystemResource`, matching the neighbouring `AbstractFSMActorTest`. Drop `actor-tests/.../JavaSubclassCompilationCheck.java`. Every Java-facing class on 1.7.x that mixes in more than one trait already has a Java subclass somewhere in the build, so the guard has nothing left to cover on this branch. The persistence and stream guards still apply and are unchanged. Result: The backport compiles and its tests pass on 1.7.x. Tests: - sbt "actor-tests/Test/compile" "persistence/Test/compile" "stream-tests/Test/compile" - success - sbt "actor-tests/testOnly org.apache.pekko.actor.AbstractFSMWithStashActorTest" - 1 succeeded, 0 failed - sbt "persistence/testOnly org.apache.pekko.persistence.TimerPersistentActorSpec" - 5 succeeded, 0 failed - sbt javafmtAll (JDK 17) - no churn outside the changed files - Scala 2.12 and Scala 3 - Not run locally, left to CI References: Refs apache#3475, Refs apache#3474
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cherry pick 90b02d6 #3475 #3474