[External] : how does one get value of ConstantValueAttribute?
Chen Liang
chen.l.liang at oracle.com
Mon Nov 25 22:49:01 UTC 2024
This is an interface method, which is implicitly public. You should be able to call it without any problem. If there is a compile error, can you share the snippet of code that you managed to reproduce an error?
________________________________
From: Mark Roberts <markro at cs.washington.edu>
Sent: Monday, November 25, 2024 4:44 PM
To: Chen Liang <chen.l.liang at oracle.com>; classfile-api-dev at openjdk.org <classfile-api-dev at openjdk.org>
Subject: RE: [External] : how does one get value of ConstantValueAttribute?
Sorry – typo: ‘constant()’
From: Chen Liang <chen.l.liang at oracle.com<mailto:chen.l.liang at oracle.com>>
Sent: Monday, November 25, 2024 2:35 PM
To: Mark Roberts <markro at cs.washington.edu<mailto:markro at cs.washington.edu>>; classfile-api-dev at openjdk.org<mailto:classfile-api-dev at openjdk.org>
Subject: Re: [External] : how does one get value of ConstantValueAttribute?
Hi Mark,
I don't understand your question. Nowhere in any document mentions there's a "const" in ConstantValueAttribute. Its Javadoc is available here:
https://download.java.net/java/early_access/jdk24/docs/api/java.base/java/lang/classfile/attribute/ConstantValueAttribute.html<https://urldefense.com/v3/__https://download.java.net/java/early_access/jdk24/docs/api/java.base/java/lang/classfile/attribute/ConstantValueAttribute.html__;!!ACWV5N9M2RV99hQ!LL2vfYLl-_GR0xLXyaydxqZog5OPnJudBuAZUaFkt9ojJHORh2WZryU1DK0bAH9EPsUz1D3nHmNwq16k4EPL2opBEg$>
So once you get a ConstantValueAttribute from a field, you can check its constant() accessor, and pattern match to check if it is an IntegerEntry/StringEntry etc.
Regards,
Chen Liang
________________________________
From: Mark Roberts <markro at cs.washington.edu<mailto:markro at cs.washington.edu>>
Sent: Monday, November 25, 2024 4:17 PM
To: Chen Liang <chen.l.liang at oracle.com<mailto:chen.l.liang at oracle.com>>; classfile-api-dev at openjdk.org<mailto:classfile-api-dev at openjdk.org> <classfile-api-dev at openjdk.org<mailto:classfile-api-dev at openjdk.org>>
Subject: [External] : how does one get value of ConstantValueAttribute?
ConstantValueAttribute:const() is not public. The documentation implies it is. How do you get the value?
Thanks,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20241125/9b1b11b7/attachment-0001.htm>
More information about the classfile-api-dev
mailing list