sageserpent-open / plutonium

CQRS providing bitemporal object modelling for Java POJOs and Scala too.
MIT License
5 stars 0 forks source link

Mutative methods that are package-private don't trigger storage of a snapshot. #43

Open sageserpent-open opened 6 years ago

sageserpent-open commented 6 years ago

This was seen and worked-around in issue #39 . The problem is that if a mutating method calls another mutating method on one of its item arguments, the latter won't be detected as a mutation if the argument's method is package-private.

Given this is a natural way of enforcing relationship invariants on item that can refer to each other cyclically, we should support this.

sageserpent-open commented 6 years ago

The quick way to fix this is to intercept package private mutators.

sageserpent-open commented 6 years ago

Actually, this is supported already by ByteBuddy - the problem is that an override can't be defined by ByteBuddy unless the proxy class exists in the same package as the method being overridden / defined. Need to think about this - what if a class inherits several interfaces that define package-private methods, but the interfaces are in separate packages?

Even then, I'm unsure as to whether ByteBuddy will forward a call to another object from the package-private override it creates. It seems logical that it can do this, but...