mirror of
https://github.com/google/guava.git
synced 2026-10-28 08:35:50 +08:00
I want to call attention up front to the fact that _`Finalizer`_ still uses reflection (to invoke `finalizeReferent`). We might imagine an alternative class similar to `Finalizer` that we'd use in the same-class-loader case. That class could call `finalizeReferent` directly. Hopefully it wouldn't need to [worry about class unloading](https://github.com/google/guava/blob/de2b19178d2748fe09402c531ef75350af634667/guava/src/com/google/common/base/internal/Finalizer.java#L70-L71), since we might be running under an environment in which that's not a thing? But this would deserve more thought. Anyway: The motivation here is that GraalVM needs help to see through reflection, just as Proguard, R8, etc. do. We haven't made much [effort to support Graal](https://github.com/google/guava/issues/3894), but this CL is an easy enough win. (Again, given that we _also_ use reflection in `Finalizer`, I wouldn't assume that `FinalizableReference`+GraalVM now "works." But it does now get through an initial step that I was testing against.) This CL might also allow us to simplify our Proguard configuration. However, it's not necessarily that simple: - Since we still _attempt_ reflection, we might want the class we reflect upon to still have its expected shape, even if we ultimately don't use it for one reason or another. - We could consider configuring Proguard with `-assumevalues` so that it _doesn't_ attempt reflection. (Compare https://github.com/google/guava/commit/14050c34d13b64846875d1a7b3ca4a1003a1e5cf, which I later undid in https://github.com/google/guava/commit/75da92419a7d414bd3de23c89f2ddfd83754767d.) - _Technically_, we should keep in mind that it's possible to use Proguard for a _server_ app, so "Proguard" does not imply "Android," and we ideally would write rules with that in mind. (This also came up in https://github.com/google/guava/commit/75da92419a7d414bd3de23c89f2ddfd83754767d.) In practice, I'm not sure how much that would matter. RELNOTES=n/a PiperOrigin-RevId: 884581412