JDK-8131749 : VarHandles JLS changes
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-07-17
  • Updated: 2018-08-03
  • Resolved: 2017-02-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Relates :  
Relates :  
Description
From the JEP 193 description:

The following additions will be required to the Java Language Specification:

1. Make reference to the signature-polymorphic access mode methods in the VarHandle class.

2. Allow signature-polymorphic methods to return types other than Object, indicating that the return type is not polymorphic (and would otherwise be declared via a cast at the call site). This makes it easier invoke write-based access methods that return void and invoke compareAndSet that returns a boolean value. 
Comments
* 15.12.3. Compile-Time Step 3: Is the Chosen Method Appropriate? ... ��� If the compile-time declaration for the method invocation is a signature polymorphic method, then: ��� The compile-time parameter types are ... ��� The compile-time result is determined as follows: ��� If the signature polymorphic method is either void or has a return type other than Object, the compile-time result is the result of the invocation type of the compile-time declaration (��15.12.2.6). ��� Otherwise, if the method invocation expression is an expression statement, the compile-time result is void. ��� 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). ��� Otherwise, the compile-time result is the signature polymorphic method's return type, Object. A method is signature polymorphic if all of the following are true: ��� It is declared in the java.lang.invoke.MethodHandle class or the java.lang.invoke.VarHandle class. ��� It takes a single variable arity parameter (��8.4.1) whose declared type is Object[]. ��� It is native. * 15.12.4.4. Locate Method to Invoke ��� Otherwise, if the invocation mode is virtual, and T and m jointly indicate a signature polymorphic method (��15.12.3), then the target object is an instance of java.lang.invoke.MethodHandle or java.lang.invoke.VarHandle. The target object encapsulates state which is matched against the information associated with the method invocation at compile time (��15.12.3). Details of this matching are given in The Java Virtual Machine Specification and the Java SE platform API. If matching succeeds, then either the method referenced by the java.lang.invoke.MethodHandle instance is directly and immediately invoked, or the variable represented by the java.lang.invoke.VarHandle instance is directly and immediately accessed, /and in either case the procedure in ��15.12.4.5 is not executed/. If matching fails, then a java.lang.invoke.WrongMethodTypeException is thrown. * 15.13.3. Run-Time Evaluation of Method References Remove paragraph "The effect of this determination when the compile-time declaration of the method reference is signature polymorphic is that: ..."
10-02-2017