On Thu, 19 May 2022 23:44:12 GMT, liach <d...@openjdk.java.net> wrote:

>> Currently, in ProxyBuilder::mapToModule and ProxyBuilder::defineProxyClass, 
>> the interfaces are iterated twice. The two passes can be merged into one, 
>> yielding the whole proxy definition context (module, package, whether 
>> there's package-private interface) when determining the module.
>> 
>> Split from #8278. Helpful for moving proxies to hidden classes, but is a 
>> good cleanup on its own.
>
> liach has updated the pull request with a new target base due to a merge or a 
> rebase. The incremental webrev excludes the unrelated changes brought in by 
> the merge/rebase. The pull request contains four additional commits since the 
> last revision:
> 
>  - Updates suggested by mandy
>  - Merge branch 'master' into fix/proxy-single-pass
>  - Don't need to complexify module cache
>  - 8284942: Proxy building can just iterate superinterfaces once

Looks good with a couple comments.

src/java.base/share/classes/java/lang/reflect/Proxy.java line 509:

> 507:                 if (!m.isNamed())
> 508:                     throw new InternalError("unnamed module: " + m);
> 509:             } else if (proxyPkg.isEmpty() && m.isNamed()) {

With the refactoring, it may be easier to understand to make this check for 
both public and non-public access (i.e. drop the `else`) for clarity - a named 
module can't have unnamed package.

src/java.base/share/classes/java/lang/reflect/Proxy.java line 534:

> 532:              * Generate the specified proxy class.
> 533:              */
> 534:             accessFlags |= Modifier.FINAL;

It can be inlined in the call to `generateProxyClass`:


            byte[] proxyClassFile = ProxyGenerator.generateProxyClass(loader, 
proxyName, interfaces, accessFlags | Modifier.FINAL);

-------------

PR: https://git.openjdk.java.net/jdk/pull/8281

Reply via email to