On Tue, 5 Nov 2024 19:51:04 GMT, Vicente Romero <vrom...@openjdk.org> wrote:
> Javac is not issuing a mandated unchecked cast warning for code like: > > > import java.lang.invoke.VarHandle; > > class VarHandleCast<V> { > VarHandle vh; > V method(Object obj) { > return (V)vh.getAndSet(this, obj); > } > } > > > according to the spec the return type inferred for this method polymorphic > method should be Object see: > > - If the compile-time declaration for the method invocation is a signature > polymorphic method, then: > ... > – The compile-time result is determined as follows: > Otherwise, if the method invocation expression is the operand of a > cast > expression (§15.16), the compile-time result is the erasure of the type > of the > cast expression (§4.6). > > javac is not doing the type erasure mandated by the spec which is what this > PR is fixing > > TIA > > Note: I had to add some annotations to suppress warnings in java.base that > were not being issued before due to the javac bug This pull request has now been integrated. Changeset: cc2acd14 Author: Vicente Romero <vrom...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/cc2acd14b13ada243fc13dc4d9007c4e2df56148 Stats: 40 lines in 10 files changed: 38 ins; 0 del; 2 mod 8343286: Missing unchecked cast warning in polymorphic method call Reviewed-by: mcimadamore ------------- PR: https://git.openjdk.org/jdk/pull/21914