src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java
Print this page
@@ -32,10 +32,11 @@
/** Working storage for an LF that is being transformed.
* Similarly to a StringBuffer, the editing can take place in multiple steps.
*/
final class LambdaFormBuffer {
+ private final LambdaForm lambdaForm;
private int arity, length;
private Name[] names;
private Name[] originalNames; // snapshot of pre-transaction names
private byte flags;
private int firstChange;
@@ -44,26 +45,24 @@
private ArrayList<Name> dups;
private static final int F_TRANS = 0x10, F_OWNED = 0x03;
LambdaFormBuffer(LambdaForm lf) {
- this(lf.arity, lf.names, lf.result);
+ this.lambdaForm = lf;
+ this.arity = lf.arity;
+ setNames(lf.names);
+ int result = lf.result;
+ if (result == LAST_RESULT) result = length - 1;
+ if (result >= 0 && lf.names[result].type != V_TYPE)
+ resultName = lf.names[result];
debugName = lf.debugName;
assert(lf.nameRefsAreLegal());
}
- private LambdaFormBuffer(int arity, Name[] names, int result) {
- this.arity = arity;
- setNames(names);
- if (result == LAST_RESULT) result = length - 1;
- if (result >= 0 && names[result].type != V_TYPE)
- resultName = names[result];
- }
-
private LambdaForm lambdaForm() {
assert(!inTrans()); // need endEdit call to tidy things up
- return new LambdaForm(debugName, arity, nameArray(), resultIndex());
+ return new LambdaForm(lambdaForm, debugName, arity, nameArray(), resultIndex());
}
Name name(int i) {
assert(i < length);
return names[i];