mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8335927: Revisit AnnotationConstantValueEntry and AnnotationValue.OfConstant
Reviewed-by: asotona
This commit is contained in:
parent
9e282e5c96
commit
6af1d6ff21
12 changed files with 356 additions and 179 deletions
|
@ -510,25 +510,6 @@ public sealed interface ConstantPoolBuilder
|
|||
throw new IllegalArgumentException("Illegal type: " + (c == null ? null : c.getClass()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return An {@link AnnotationConstantValueEntry} describing the provided
|
||||
* constant} The constant should be an Integer, String, Long, Float,
|
||||
* Double, ClassDesc (for a Class constant), or MethodTypeDesc (for a MethodType
|
||||
* constant.)
|
||||
*
|
||||
* @param c the constant
|
||||
*/
|
||||
default AnnotationConstantValueEntry annotationConstantValueEntry(ConstantDesc c) {
|
||||
if (c instanceof Integer i) return intEntry(i);
|
||||
if (c instanceof String s) return utf8Entry(s);
|
||||
if (c instanceof Long l) return longEntry(l);
|
||||
if (c instanceof Float f) return floatEntry(f);
|
||||
if (c instanceof Double d) return doubleEntry(d);
|
||||
if (c instanceof ClassDesc cd) return utf8Entry(cd);
|
||||
if (c instanceof MethodTypeDesc mtd) return utf8Entry(mtd);
|
||||
throw new IllegalArgumentException("Illegal type: " + (c == null ? null : c.getClass()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return a {@link BootstrapMethodEntry} describing the provided
|
||||
* bootstrap method and static arguments}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue