RFR: 8187221 [Nestmates] Virtual invocation for private interface methods

David Holmes david.holmes at oracle.com
Tue Sep 5 12:34:46 UTC 2017

webrev: http://cr.openjdk.java.net/~dholmes/8187221/

Following up from JDK-8186763 this issue handles item #2:

2. Use invokeinterface for private interface method invocations, instead 
of invokespecial

This involves three basic pieces:

1. javac issues invokeinterface instead of invokespecial
2. Verifier rules requiring invokespecial are relaxed for latest class 
file version (exact version TBD based on release timing)
3. Method resolution locates the expected method.

As part of this change I'm also isolating the changes that allowed 
invokespecial to be used for nestmate method invocations. In the near 
future that code will be removed so that we are near final-form.

Actual file changes are very simple in the end:


Restore original (pre-nestmate) logic for invokespecial and add in the 
nestmate-enabling logic under the UseNewCode guard.



LinkResolver::resolve_interface_method: Only prohibit invokeinterface 
for private interface methods if : 
InstanceKlass::cast(current_klass)->major_version() < 

LinkResolver::runtime_resolve_interface_method: Don't resolve in the 
receiver class if dealing with a private interface method



Removed the check for interface methods when generating virtual calls.


With these changes in place the following test options will test the use 
of invokevirtual and invokeinterface for private method invocations:


If you still want to experiment with the invokespecial changes use:

-javacoption:-XDdisablePrivateAccessors -javaoption:-XX:+UseNewCode

(note the second one is a java option not javac)

Next iteration I plan on removing the invokespecial related changes.


Testing so far:
  - all runtime jtreg tests
  - langtools jtreg tests


More information about the valhalla-dev mailing list