| I had a quick look and I think ultimately this exposes an incorrect implementation in ValidationInvocationHandler. Instead of passing the wrapped object into the validation engine, the proxy – as passed to the invoke() method – should be passed. So I tried that, but this causes several tests to fail, as the proxy is no sub-class if the proxied object, i.e. is-a assertions will fail. So I quickly hacked together a PoC which uses sub-class proxies generated via ByteBuddy instead of JDK dynamic proxies which can be found here: https://github.com/hibernate/hibernate-validator/compare/master...gunnarmorling:HV-1361?expand=1 With some adjustments in tests, this makes almost all tests pass. The only remaining failures are caused by the fact that a re-declared default group sequence isn't handled correctly. I thought I could simply copy that annotation to the proxy class (calling ByteBuddy's annotatedWith() method), but this results in an exception telling me that the type itself isn't part of the redeclared default group sequence. I don't think this can be achieved using ByteBuddy, as the proxy class naturally doesn't exist yet when calling annotatedWith(). On the other hand I'd also expect the redeclared default group sequence on the proxied type itself to apply, but it isn't. This is worth investigating, but I need to focus on some other things in the spec for the time being. |