[code-reflection] RFR: Code model from method reference
Paul Sandoz
psandoz at openjdk.org
Wed Mar 6 16:51:04 UTC 2024
On Wed, 6 Mar 2024 09:41:54 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> Obtain a code model from method reference. The implementation is simple and resolves the method reference to an instance of `Method`, and returns the result of `Method::getCodeModel`.
>
> src/java.base/share/classes/java/lang/reflect/code/type/MethodRef.java line 68:
>
>> 66: MethodHandle resolveToHandle(MethodHandles.Lookup l) throws ReflectiveOperationException;
>> 67:
>> 68: Optional<CoreOps.FuncOp> codeModel(MethodHandles.Lookup l) throws ReflectiveOperationException;
>
> If the result is optional, do we also need the `throws` ?
Yes, an empty optional means the method that is referenced has no code model. If there is an error attempting to determine that or obtain the code model then an exception is thrown e.g., lookup does not have the appropriate permissions to access the code model.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/34#discussion_r1514831279
More information about the babylon-dev
mailing list