8222744: add support for generating method handles from a variable symbol
Reviewed-by: mcimadamore
This commit is contained in:
parent
fee481d5a2
commit
f9bbbb6e27
@ -1559,6 +1559,10 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
|
|||||||
return ClassFile.CONSTANT_Fieldref;
|
return ClassFile.CONSTANT_Fieldref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MethodHandleSymbol asMethodHandle(boolean getter) {
|
||||||
|
return new MethodHandleSymbol(this, getter);
|
||||||
|
}
|
||||||
|
|
||||||
/** Clone this symbol with new owner.
|
/** Clone this symbol with new owner.
|
||||||
*/
|
*/
|
||||||
public VarSymbol clone(Symbol newOwner) {
|
public VarSymbol clone(Symbol newOwner) {
|
||||||
@ -2110,16 +2114,27 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
|
|||||||
public static class MethodHandleSymbol extends MethodSymbol implements LoadableConstant {
|
public static class MethodHandleSymbol extends MethodSymbol implements LoadableConstant {
|
||||||
|
|
||||||
private Symbol refSym;
|
private Symbol refSym;
|
||||||
|
private boolean getter;
|
||||||
|
|
||||||
public MethodHandleSymbol(Symbol msym) {
|
public MethodHandleSymbol(Symbol msym) {
|
||||||
|
this(msym, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MethodHandleSymbol(Symbol msym, boolean getter) {
|
||||||
super(msym.flags_field, msym.name, msym.type, msym.owner);
|
super(msym.flags_field, msym.name, msym.type, msym.owner);
|
||||||
this.refSym = msym;
|
this.refSym = msym;
|
||||||
|
this.getter = getter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the kind associated with this method handle.
|
* Returns the kind associated with this method handle.
|
||||||
*/
|
*/
|
||||||
public int referenceKind() {
|
public int referenceKind() {
|
||||||
|
if (refSym.kind == VAR) {
|
||||||
|
return getter ?
|
||||||
|
refSym.isStatic() ? ClassFile.REF_getStatic : ClassFile.REF_getField :
|
||||||
|
refSym.isStatic() ? ClassFile.REF_putStatic : ClassFile.REF_putField;
|
||||||
|
} else {
|
||||||
if (refSym.isConstructor()) {
|
if (refSym.isConstructor()) {
|
||||||
return ClassFile.REF_newInvokeSpecial;
|
return ClassFile.REF_newInvokeSpecial;
|
||||||
} else {
|
} else {
|
||||||
@ -2134,6 +2149,7 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int poolTag() {
|
public int poolTag() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user