< prev index next >

src/java.base/share/classes/java/lang/invoke/VarHandle.java

Print this page

1636         COMPARE_AND_SET(boolean.class),
1637         COMPARE_AND_EXCHANGE(Object.class),
1638         GET_AND_UPDATE(Object.class);
1639 
1640         static final int COUNT = GET_AND_UPDATE.ordinal() + 1;
1641         static {
1642             assert (COUNT == values().length);
1643         }
1644         final Class<?> returnType;
1645         final boolean isMonomorphicInReturnType;
1646 
1647         AccessType(Class<?> returnType) {
1648             this.returnType = returnType;
1649             isMonomorphicInReturnType = returnType != Object.class;
1650         }
1651 
1652         MethodType accessModeType(Class<?> receiver, Class<?> value,
1653                                   Class<?>... intermediate) {
1654             Class<?>[] ps;
1655             int i;






1656             switch (this) {
1657                 case GET:
1658                     ps = allocateParameters(0, receiver, intermediate);
1659                     fillParameters(ps, receiver, intermediate);
1660                     return MethodType.methodType(value, ps);
1661                 case SET:
1662                     ps = allocateParameters(1, receiver, intermediate);
1663                     i = fillParameters(ps, receiver, intermediate);
1664                     ps[i] = value;
1665                     return MethodType.methodType(void.class, ps);
1666                 case COMPARE_AND_SET:
1667                     ps = allocateParameters(2, receiver, intermediate);
1668                     i = fillParameters(ps, receiver, intermediate);
1669                     ps[i++] = value;
1670                     ps[i] = value;
1671                     return MethodType.methodType(boolean.class, ps);
1672                 case COMPARE_AND_EXCHANGE:
1673                     ps = allocateParameters(2, receiver, intermediate);
1674                     i = fillParameters(ps, receiver, intermediate);
1675                     ps[i++] = value;

1636         COMPARE_AND_SET(boolean.class),
1637         COMPARE_AND_EXCHANGE(Object.class),
1638         GET_AND_UPDATE(Object.class);
1639 
1640         static final int COUNT = GET_AND_UPDATE.ordinal() + 1;
1641         static {
1642             assert (COUNT == values().length);
1643         }
1644         final Class<?> returnType;
1645         final boolean isMonomorphicInReturnType;
1646 
1647         AccessType(Class<?> returnType) {
1648             this.returnType = returnType;
1649             isMonomorphicInReturnType = returnType != Object.class;
1650         }
1651 
1652         MethodType accessModeType(Class<?> receiver, Class<?> value,
1653                                   Class<?>... intermediate) {
1654             Class<?>[] ps;
1655             int i;
1656             // the field type (value) is mapped to the return type of MethodType
1657             // the receiver type is mapped to a parameter type of MethodType
1658             // So use the value type if it's a primitive class
1659             if (receiver != null && receiver.isPrimitiveClass()) {
1660                 receiver = receiver.asValueType();
1661             }
1662             switch (this) {
1663                 case GET:
1664                     ps = allocateParameters(0, receiver, intermediate);
1665                     fillParameters(ps, receiver, intermediate);
1666                     return MethodType.methodType(value, ps);
1667                 case SET:
1668                     ps = allocateParameters(1, receiver, intermediate);
1669                     i = fillParameters(ps, receiver, intermediate);
1670                     ps[i] = value;
1671                     return MethodType.methodType(void.class, ps);
1672                 case COMPARE_AND_SET:
1673                     ps = allocateParameters(2, receiver, intermediate);
1674                     i = fillParameters(ps, receiver, intermediate);
1675                     ps[i++] = value;
1676                     ps[i] = value;
1677                     return MethodType.methodType(boolean.class, ps);
1678                 case COMPARE_AND_EXCHANGE:
1679                     ps = allocateParameters(2, receiver, intermediate);
1680                     i = fillParameters(ps, receiver, intermediate);
1681                     ps[i++] = value;
< prev index next >