Hi Laird Nelson are you sure this was JDK 11? Because I remember adding this for JDK 11 and even in JDK 12 (as this line suggests) there was Unsafe, just not accessible this way (maybe not at all, not sure now). Either way, all of these hacks are there just to bypass problems with class defining in JDK 9+ and in SE. EE integrations typically have control over class loading and their implementations of ProxyServices allow them to define new classes without these hacks. We should really have a different solution, but I am not sure what that would be. The problem is that we need to add proxies to:
- The package where the original bean class was, this is a requirement so that package private access on beans won't break
- Custom package for any proxy that is built for any class from Java core as you were never allowed to add classes there
In newer JDKs you cannot crack open a CL without a warning (ATM Weld should work with these warning on newer ones) and the modular approach to class defining didn't allow you to register classes into other people's packages or to add it to a not-yet-existing package (the custom one). I am open to suggestions regarding how to do this properly, but back when I tried, I simply didn't figure it out. |