From issues-return-92003-archive-asf-public=cust-asf.ponee.io@commons.apache.org Fri Sep 4 01:25:04 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-he-de.apache.org (mxout1-he-de.apache.org [95.216.194.37]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 99375180636 for ; Fri, 4 Sep 2020 03:25:04 +0200 (CEST) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-he-de.apache.org (ASF Mail Server at mxout1-he-de.apache.org) with SMTP id CBA6E635F6 for ; Fri, 4 Sep 2020 01:25:03 +0000 (UTC) Received: (qmail 2382 invoked by uid 500); 4 Sep 2020 01:25:02 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 2254 invoked by uid 99); 4 Sep 2020 01:25:02 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Sep 2020 01:25:02 +0000 Received: from jira-he-de.apache.org (static.172.67.40.188.clients.your-server.de [188.40.67.172]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A6EEB41970 for ; Fri, 4 Sep 2020 01:25:01 +0000 (UTC) Received: from jira-he-de.apache.org (localhost.localdomain [127.0.0.1]) by jira-he-de.apache.org (ASF Mail Server at jira-he-de.apache.org) with ESMTP id 368767809A4 for ; Fri, 4 Sep 2020 01:25:00 +0000 (UTC) Date: Fri, 4 Sep 2020 01:25:00 +0000 (UTC) From: "Gary D. Gregory (Jira)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LANG-1383) Illegal Reflective Access Operation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-1383?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D17190= 466#comment-17190466 ]=20 Gary D. Gregory commented on LANG-1383: --------------------------------------- No, the reflection used breaks encapsulation by design. The only solution i= s to NOT used the class. At work, I am migrating code as I got to use Eclip= se generated toString() methods instead. =C2=A0 > Illegal Reflective Access Operation > ----------------------------------- > > Key: LANG-1383 > URL: https://issues.apache.org/jira/browse/LANG-1383 > Project: Commons Lang > Issue Type: Bug > Components: lang.builder.* > Affects Versions: 3.7 > Reporter: Brian Schack > Priority: Major > Attachments: Test.java > > > ReflectionToStringBuilder::toString prints an illegal access warning to S= ystem.err. The warning suggests to report this issue to the Apache Commons = maintainers. > Boolean.TRUE is such a simple value that I don't really need ReflectionTo= StringBuilder. But more complex types (such as HashMap) print the same warn= ing. I chose Boolean.TRUE in order to simplify this example. > When I searched for this warning message, I found a StackOverflow answer = which suggested to report it to the package maintainers ([JDK9: An illegal = reflective access operation has occurred. org.python.core.PySystemState|htt= ps://stackoverflow.com/questions/46230413/jdk9-an-illegal-reflective-access= -operation-has-occurred-org-python-core-pysys/46230678]). > I also asked my own StackOverflow question about how to throw an exceptio= n for this warning ([How can I throw an exception for an illegal reflective= access warning?|https://stackoverflow.com/questions/49076972/how-can-i-thr= ow-an-exception-for-an-illegal-reflective-access-warning]). > I will try to change my code to avoid this warning, but it=C2=A0also seem= s that Apache Commons should not cause the warning. Perhaps it could use di= fferent methods to get the values of the fields, or skip the private fields= , or throw an exception?=C2=A0The warning message suggests that the Java ma= intainers want the Apache Commons maintainers to avoid this warning. And wh= en they disable this illegal access in the future, then it could impact Apa= che Commons. > Code: > {{import org.apache.commons.lang3.builder.*;}} > {{class Test {}} > {{public static void main(String[] args)=C2=A0{}} > {{System.out.println(ReflectionToStringBuilder.toString(Boolean.TRUE));}} > {{}}} > {{}}} > Output: > {{WARNING: An illegal reflective access operation has occurred}} > {{WARNING: Illegal reflective access by org.apache.commons.lang3.builder= .ReflectionToStringBuilder ([file:/Users/brianschack/eclipse-workspace/User= %20Libraries/com|file:///Users/brianschack/eclipse-workspace/User%20Librari= es/com]mons-lang3-3.7/commons-lang3-3.7.jar) to field java.lang.Boolean.val= ue}} > {{WARNING: Please consider reporting this to the maintainers of org.apac= he.commons.lang3.builder.ReflectionToStringBuilder}} > {{WARNING: Use --illegal-access=3Dwarn to enable warnings of further ill= egal reflective access operations}} > {{WARNING: All illegal access operations will be denied in a future relea= se}} -- This message was sent by Atlassian Jira (v8.3.4#803005)