1421
1422 /*non-public*/
1423 abstract MethodHandle copyWith(MethodType mt, LambdaForm lf);
1424
1425 /** Require this method handle to be a BMH, or else replace it with a "wrapper" BMH.
1426 * Many transforms are implemented only for BMHs.
1427 * @return a behaviorally equivalent BMH
1428 */
1429 abstract BoundMethodHandle rebind();
1430
1431 /**
1432 * Replace the old lambda form of this method handle with a new one.
1433 * The new one must be functionally equivalent to the old one.
1434 * Threads may continue running the old form indefinitely,
1435 * but it is likely that the new one will be preferred for new executions.
1436 * Use with discretion.
1437 */
1438 /*non-public*/
1439 void updateForm(LambdaForm newForm) {
1440 if (form == newForm) return;
1441 assert(this instanceof DirectMethodHandle && this.internalMemberName().isStatic());
1442 // ISSUE: Should we have a memory fence here?
1443 UNSAFE.putObject(this, FORM_OFFSET, newForm);
1444 this.form.prepare(); // as in MethodHandle.<init>
1445 }
1446
1447 private static final long FORM_OFFSET;
1448 static {
1449 try {
1450 FORM_OFFSET = UNSAFE.objectFieldOffset(MethodHandle.class.getDeclaredField("form"));
1451 } catch (ReflectiveOperationException ex) {
1452 throw newInternalError(ex);
1453 }
1454 }
1455 }
|
1421
1422 /*non-public*/
1423 abstract MethodHandle copyWith(MethodType mt, LambdaForm lf);
1424
1425 /** Require this method handle to be a BMH, or else replace it with a "wrapper" BMH.
1426 * Many transforms are implemented only for BMHs.
1427 * @return a behaviorally equivalent BMH
1428 */
1429 abstract BoundMethodHandle rebind();
1430
1431 /**
1432 * Replace the old lambda form of this method handle with a new one.
1433 * The new one must be functionally equivalent to the old one.
1434 * Threads may continue running the old form indefinitely,
1435 * but it is likely that the new one will be preferred for new executions.
1436 * Use with discretion.
1437 */
1438 /*non-public*/
1439 void updateForm(LambdaForm newForm) {
1440 if (form == newForm) return;
1441 // ISSUE: Should we have a memory fence here?
1442 newForm.prepare(); // as in MethodHandle.<init>
1443 UNSAFE.putObject(this, FORM_OFFSET, newForm);
1444 }
1445
1446 private static final long FORM_OFFSET;
1447 static {
1448 try {
1449 FORM_OFFSET = UNSAFE.objectFieldOffset(MethodHandle.class.getDeclaredField("form"));
1450 } catch (ReflectiveOperationException ex) {
1451 throw newInternalError(ex);
1452 }
1453 }
1454 }
|