[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-hotspot-runtime-dev
Subject:    Re: =?utf-8?B?5Zue5aSN77yaVk0=?= crashed at StringTable expansion
From:       Florian Weimer <fweimer () redhat ! com>
Date:       2020-02-26 12:08:01
Message-ID: 87d0a17dr2.fsf () oldenburg2 ! str ! redhat ! com
[Download RAW message or body]

* ε‘δΌŸ(θ―†ζœˆ):

> Hi Florian,
>
> This isn't a common usage.
> For the below code:
>
> String s1 = "s1".intern();
> f.set("s1".intern(), f.get("s2"));
>
> After calling reflection, the value of s1 is changed to "s2".
> In some special scenarios, the original jar file can't be modified. But the user 
> expects to change the value of some string, and uses the above code to
> implement it.
>
> Although this usage isn't recommended, it isn't forbidden. We don't expect
> the crash because of the usage.

That's not what I see.  A modified reproducer:

import java.lang.reflect.Field;
public class StringTableTest {
    public static void main(String[] args) throws Exception {
        Field f = String.class.getDeclaredField("value");
        f.setAccessible(true);
        f.set("s1".intern(), f.get("s2"));
        System.out.println("s1");
        System.out.println("s2");
    }
}

Prints this:

s2
s2

It also has a clear warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by StringTableTest (file:/tmp/) to field java.lang.String.value
WARNING: Please consider reporting this to the maintainers of StringTableTest
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

I'm not sure what else we can do.

Thanks,
Florian

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic