After some discussion of this on IRC, here is what we think...
I think we should get out of the business of swapping the TCCL. I think we do it for noble reasons (trying to make sure we can integrate with libraries that rely on it), but I think it causes a lot of problems (duh). The big one we are worried about is hibernate-commons-annotations, but I actually already added hooks in that library to have it properly use our aggregated classloader directly. For other libraries that rely on TCCL... we'll we all know by now they shouldn't. And its not really Hibernate's job to make sure other libraries work properly in various environments; it's certainly not our core competency.
So what I propose is to:
-
Remove TcclSafeAggregatedClassLoader
-
Remove the ClassLoaderService#withTccl method
-
Never, ever, ever swap the TCCL in our code
Along with this we need to make sure that we are setting org.hibernate.annotations.common.reflection.ReflectionManager#injectClassLoaderDelegate. How this needs to happen is different in 4.x and 5.0.
|