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

List:       openjdk-hotspot-runtime-dev
Subject:    =?utf-8?Q?Re:_=E5=9B=9E=E5=A4=8D=EF=BC=9A=E5=9B=9E=E5=A4=8D=EF=BC=9AV?= =?utf-8?Q?M_crashed_a?= =?ut
From:       Remi Forax <forax () univ-mlv ! fr>
Date:       2020-02-26 13:03:16
Message-ID: 138049504.1219824.1582722196655.JavaMail.zimbra () u-pem ! fr
[Download RAW message or body]



----- Mail original -----
> De: "向伟(识月)" <shiyue.xw@alibaba-inc.com>
> À: "Florian Weimer" <fweimer@redhat.com>
> Cc: "core-libs-dev" <core-libs-dev@openjdk.java.net>, "hotspot-runtime-dev" \
> <hotspot-runtime-dev@openjdk.java.net> Envoyé: Mercredi 26 Février 2020 13:45:52
> Objet: 回复:回复:VM crashed at StringTable expansion

> Hi Florian, Alan,
> 
> public static void main(String[] args) throws Exception {
> String s1 = "s1".intern();
> System.out.println("before reflect s1 = " + s1);
> Field f = String.class.getDeclaredField("value");
> f.setAccessible(true);
> f.set("s1".intern(), f.get("s2"));
> System.out.println("after reflect s1 = " + s1);
> }
> Print:
> before reflect s1 = s1
> after reflect s1 = s2
> 
> I see the warning, but it isn't forbidden for the usage in JDK11 or a higher
> version.

It is !
It's what "illegal" means.

> When we modify a normal String, we also get the same warning message.
> 
> It is an internal library, we may suggest the user to change their code.
> But actually, it isn't easy to find the code if the other users have similar
> usage.

It's easy, run your program with --illegal-access=deny

At some point in the future (and sooner than you think), --illegal-access=deny will \
be the default. I think Mark Reinhold said something along that line at last JFokus.

> 
> We may need a way to avoid the crash or locate the problem in user code quickly.
> 
> Thanks,
> Wei Xiang

regards,
Rémi

> 
> 
> ------------------------------------------------------------------
> 发件人:Florian Weimer <fweimer@redhat.com>
> 发送时间:2020年2月26日(星期三) 20:08
> 收件人:向伟(识月) <shiyue.xw@alibaba-inc.com>
> 抄 送:core-libs-dev <core-libs-dev@openjdk.java.net>; hotspot-runtime-dev
> <hotspot-runtime-dev@openjdk.java.net>
> 主 题:Re: 回复:VM crashed at StringTable expansion
> 
> * 向伟(识月):
> 
> > 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