It's not a bug but it's not user friendly
forax at univ-mlv.fr
forax at univ-mlv.fr
Mon Dec 14 22:01:22 UTC 2020
> De: "mandy chung" <mandy.chung at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>, "core-libs-dev"
> <core-libs-dev at openjdk.java.net>
> Envoyé: Lundi 14 Décembre 2020 22:41:23
> Objet: Re: It's not a bug but it's not user friendly
> I think [ https://bugs.openjdk.java.net/browse/JDK-8199149 |
> https://bugs.openjdk.java.net/browse/JDK-8199149 ] is the relevant RFE.
> Mandy
Yes, thanks.
Rémi
> On 12/12/20 8:07 AM, Remi Forax wrote:
>> A student of mine send me a code that can be reduced to this code
>> ---
>> import java.lang.invoke.MethodHandles;
>> import java.lang.invoke.VarHandle;
>> public class ThereIsABugButWhere {
>> private static final VarHandle TEXT;
>> static {
>> try {
>> TEXT = MethodHandles.lookup().findVarHandle(ThereIsABugButWhere.class, "text",
>> String.class);
>> } catch (NoSuchFieldException | IllegalAccessException e) {
>> throw new AssertionError(e);
>> }
>> }
>> private final String text;
>> ThereIsABugButWhere() {
>> text = "FOO";
>> }
>> public void update(String s) {
>> TEXT.compareAndSet(this, "FOO", s);
>> }
>> public static void main(String[] args) {
>> new ThereIsABugButWhere().update("BAR");
>> }
>> }
>> ---
>> If you execute it, you get
>> Exception in thread "main" java.lang.UnsupportedOperationException
>> at java.base/java.lang.invoke.VarForm.getMemberName(VarForm.java:99)
>> at
>> java.base/java.lang.invoke.VarHandleGuards.guard_LLL_Z(VarHandleGuards.java:77)
>> at ThereIsABugButWhere.update(ThereIsABugButWhere.java:22)
>> at ThereIsABugButWhere.main(ThereIsABugButWhere.java:26)
>> It takes me 20 mins to find the issue ...
>> I think we can improve the error message or even better report the issue at the
>> right location :)
>> regards,
>> Rémi
More information about the core-libs-dev
mailing list