mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8311084: Add typeSymbol() API for applicable constant pool entries
Reviewed-by: briangoetz, asotona
This commit is contained in:
parent
9f5d2b947f
commit
1749ba265b
7 changed files with 48 additions and 4 deletions
|
@ -26,6 +26,8 @@ package jdk.internal.classfile.constantpool;
|
||||||
|
|
||||||
import jdk.internal.classfile.TypeKind;
|
import jdk.internal.classfile.TypeKind;
|
||||||
import jdk.internal.classfile.impl.Util;
|
import jdk.internal.classfile.impl.Util;
|
||||||
|
|
||||||
|
import java.lang.constant.ClassDesc;
|
||||||
import java.lang.constant.ConstantDesc;
|
import java.lang.constant.ConstantDesc;
|
||||||
import java.lang.constant.DynamicConstantDesc;
|
import java.lang.constant.DynamicConstantDesc;
|
||||||
|
|
||||||
|
@ -40,6 +42,13 @@ public sealed interface ConstantDynamicEntry
|
||||||
extends DynamicConstantPoolEntry, LoadableConstantEntry
|
extends DynamicConstantPoolEntry, LoadableConstantEntry
|
||||||
permits AbstractPoolEntry.ConstantDynamicEntryImpl {
|
permits AbstractPoolEntry.ConstantDynamicEntryImpl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return a symbolic descriptor for the dynamic constant's type}
|
||||||
|
*/
|
||||||
|
default ClassDesc typeSymbol() {
|
||||||
|
return Util.fieldTypeSymbol(nameAndType());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default ConstantDesc constantValue() {
|
default ConstantDesc constantValue() {
|
||||||
return asSymbol();
|
return asSymbol();
|
||||||
|
@ -51,7 +60,7 @@ public sealed interface ConstantDynamicEntry
|
||||||
default DynamicConstantDesc<?> asSymbol() {
|
default DynamicConstantDesc<?> asSymbol() {
|
||||||
return DynamicConstantDesc.ofNamed(bootstrap().bootstrapMethod().asSymbol(),
|
return DynamicConstantDesc.ofNamed(bootstrap().bootstrapMethod().asSymbol(),
|
||||||
name().stringValue(),
|
name().stringValue(),
|
||||||
Util.fieldTypeSymbol(nameAndType()),
|
typeSymbol(),
|
||||||
bootstrap().arguments().stream()
|
bootstrap().arguments().stream()
|
||||||
.map(LoadableConstantEntry::constantValue)
|
.map(LoadableConstantEntry::constantValue)
|
||||||
.toArray(ConstantDesc[]::new));
|
.toArray(ConstantDesc[]::new));
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
package jdk.internal.classfile.constantpool;
|
package jdk.internal.classfile.constantpool;
|
||||||
|
|
||||||
import jdk.internal.classfile.impl.AbstractPoolEntry;
|
import jdk.internal.classfile.impl.AbstractPoolEntry;
|
||||||
|
import jdk.internal.classfile.impl.Util;
|
||||||
|
|
||||||
|
import java.lang.constant.ClassDesc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models a {@code CONSTANT_Fieldref_info} constant in the constant pool of a
|
* Models a {@code CONSTANT_Fieldref_info} constant in the constant pool of a
|
||||||
|
@ -34,4 +37,10 @@ import jdk.internal.classfile.impl.AbstractPoolEntry;
|
||||||
public sealed interface FieldRefEntry extends MemberRefEntry
|
public sealed interface FieldRefEntry extends MemberRefEntry
|
||||||
permits AbstractPoolEntry.FieldRefEntryImpl {
|
permits AbstractPoolEntry.FieldRefEntryImpl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return a symbolic descriptor for the field's type}
|
||||||
|
*/
|
||||||
|
default ClassDesc typeSymbol() {
|
||||||
|
return Util.fieldTypeSymbol(nameAndType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
package jdk.internal.classfile.constantpool;
|
package jdk.internal.classfile.constantpool;
|
||||||
|
|
||||||
import jdk.internal.classfile.impl.AbstractPoolEntry;
|
import jdk.internal.classfile.impl.AbstractPoolEntry;
|
||||||
|
import jdk.internal.classfile.impl.Util;
|
||||||
|
|
||||||
|
import java.lang.constant.MethodTypeDesc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models a {@code CONSTANT_InterfaceMethodRef_info} constant in the constant pool of a
|
* Models a {@code CONSTANT_InterfaceMethodRef_info} constant in the constant pool of a
|
||||||
|
@ -35,4 +38,10 @@ public sealed interface InterfaceMethodRefEntry
|
||||||
extends MemberRefEntry
|
extends MemberRefEntry
|
||||||
permits AbstractPoolEntry.InterfaceMethodRefEntryImpl {
|
permits AbstractPoolEntry.InterfaceMethodRefEntryImpl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return a symbolic descriptor for the interface method's type}
|
||||||
|
*/
|
||||||
|
default MethodTypeDesc typeSymbol() {
|
||||||
|
return Util.methodTypeSymbol(nameAndType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ package jdk.internal.classfile.constantpool;
|
||||||
|
|
||||||
import java.lang.constant.ConstantDesc;
|
import java.lang.constant.ConstantDesc;
|
||||||
import java.lang.constant.DynamicCallSiteDesc;
|
import java.lang.constant.DynamicCallSiteDesc;
|
||||||
|
import java.lang.constant.MethodTypeDesc;
|
||||||
|
|
||||||
import jdk.internal.classfile.impl.AbstractPoolEntry;
|
import jdk.internal.classfile.impl.AbstractPoolEntry;
|
||||||
import jdk.internal.classfile.impl.Util;
|
import jdk.internal.classfile.impl.Util;
|
||||||
|
@ -38,13 +39,20 @@ public sealed interface InvokeDynamicEntry
|
||||||
extends DynamicConstantPoolEntry
|
extends DynamicConstantPoolEntry
|
||||||
permits AbstractPoolEntry.InvokeDynamicEntryImpl {
|
permits AbstractPoolEntry.InvokeDynamicEntryImpl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return a symbolic descriptor for the call site's invocation type}
|
||||||
|
*/
|
||||||
|
default MethodTypeDesc typeSymbol() {
|
||||||
|
return Util.methodTypeSymbol(nameAndType());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@return a symbolic descriptor for the dynamic call site}
|
* {@return a symbolic descriptor for the dynamic call site}
|
||||||
*/
|
*/
|
||||||
default DynamicCallSiteDesc asSymbol() {
|
default DynamicCallSiteDesc asSymbol() {
|
||||||
return DynamicCallSiteDesc.of(bootstrap().bootstrapMethod().asSymbol(),
|
return DynamicCallSiteDesc.of(bootstrap().bootstrapMethod().asSymbol(),
|
||||||
name().stringValue(),
|
name().stringValue(),
|
||||||
Util.methodTypeSymbol(nameAndType()),
|
typeSymbol(),
|
||||||
bootstrap().arguments().stream()
|
bootstrap().arguments().stream()
|
||||||
.map(LoadableConstantEntry::constantValue)
|
.map(LoadableConstantEntry::constantValue)
|
||||||
.toArray(ConstantDesc[]::new));
|
.toArray(ConstantDesc[]::new));
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
package jdk.internal.classfile.constantpool;
|
package jdk.internal.classfile.constantpool;
|
||||||
|
|
||||||
import jdk.internal.classfile.impl.AbstractPoolEntry;
|
import jdk.internal.classfile.impl.AbstractPoolEntry;
|
||||||
|
import jdk.internal.classfile.impl.Util;
|
||||||
|
|
||||||
|
import java.lang.constant.MethodTypeDesc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models a {@code CONSTANT_MethodRef_info} constant in the constant pool of a
|
* Models a {@code CONSTANT_MethodRef_info} constant in the constant pool of a
|
||||||
|
@ -34,4 +37,10 @@ import jdk.internal.classfile.impl.AbstractPoolEntry;
|
||||||
public sealed interface MethodRefEntry extends MemberRefEntry
|
public sealed interface MethodRefEntry extends MemberRefEntry
|
||||||
permits AbstractPoolEntry.MethodRefEntryImpl {
|
permits AbstractPoolEntry.MethodRefEntryImpl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return a symbolic descriptor for the method's type}
|
||||||
|
*/
|
||||||
|
default MethodTypeDesc typeSymbol() {
|
||||||
|
return Util.methodTypeSymbol(nameAndType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public sealed interface FieldInstruction extends Instruction
|
||||||
* {@return a symbolic descriptor for the type of the field}
|
* {@return a symbolic descriptor for the type of the field}
|
||||||
*/
|
*/
|
||||||
default ClassDesc typeSymbol() {
|
default ClassDesc typeSymbol() {
|
||||||
return Util.fieldTypeSymbol(field().nameAndType());
|
return field().typeSymbol();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -70,7 +70,7 @@ public sealed interface InvokeDynamicInstruction extends Instruction
|
||||||
* {@return the invocation type of the call site, as a symbolic descriptor}
|
* {@return the invocation type of the call site, as a symbolic descriptor}
|
||||||
*/
|
*/
|
||||||
default MethodTypeDesc typeSymbol() {
|
default MethodTypeDesc typeSymbol() {
|
||||||
return Util.methodTypeSymbol(invokedynamic().nameAndType());
|
return invokedynamic().typeSymbol();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue