Port of: https://git.openjdk.org/panama-foreign/pull/831
------------- Commit messages: - Cleanup code so that restricted method check is shared - Initial push Changes: https://git.openjdk.org/jdk/pull/13863/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13863&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8307615 Stats: 128 lines in 11 files changed: 65 ins; 17 del; 46 mod Patch: https://git.openjdk.org/jdk/pull/13863.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/13863/head:pull/13863 PR: https://git.openjdk.org/jdk/pull/13863