Bug 1029387

Summary: WFLY-2493 EL cannot access public methods/fields of non-public classes
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Jonáš Trantina <jtrantin>
Component: JSFAssignee: Farah Juma <fjuma>
Status: CLOSED CURRENTRELEASE QA Contact: Matous Jobanek <mjobanek>
Severity: unspecified Docs Contact: Russell Dickenson <rdickens>
Priority: unspecified    
Version: 6.1.0CC: aneelica, fjuma, kkhan, maschmid, rsmeral, smumford, ssilvert
Target Milestone: DR5   
Target Release: EAP 6.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
In previous versions of JBoss EAP 6 the BeanELResolver did not try to override Method.invoke access control to access public methods or fields of non-public classes. This caused issues when trying to access the public method or field of a non-public class via Expression Language (EL) the following error message resulted: ---- "java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class X with modifiers "private" ---- This issue has been resolved by calling setAccessible(true) as appropriate in the EL implementation. Public methods or fields of non-public class are now accessile via EL
Story Points: ---
Clone Of:
: 1076320 (view as bug list) Environment:
Last Closed: 2014-07-29 14:39:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1076061, 1076320    

Description Jonáš Trantina 2013-11-12 10:26:32 UTC
Description of problem:
When trying to access public method/field of non-public class via EL I get
"java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class X with modifiers "private"".
This is apparently caused by JDK-4071957 [1], but since that is opened for over 16 years, it should be probably worth it to implement a workaround.
Workaround for this issue is setting setAccessible(true) on the method before invoking it, thus suppress Java access checking.
I have attached a simple reproducer app as well as a stack trace of the exception. These attachments can be found in the JIRA [2]. 

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957
[2] https://issues.jboss.org/browse/WFLY-2493

Version-Release number of selected component (if applicable):
jboss-el-api_2.2_spec-1.0.2.Final

Comment 1 JBoss JIRA Server 2013-11-12 15:55:54 UTC
Jonáš Trantina <jtrantin> made a comment on jira WFLY-2493

Corrected description and added new reproducer, as the previous one was not correct.

Comment 2 Jonáš Trantina 2013-11-12 16:01:14 UTC
Edited description:
When trying to access public method/field of non-public class that implements public interface via EL I get
"java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class X with modifiers "private"".
E.g. accessing Collections.unmodifiableList(..) via EL will throw the exception, because #unmodifiableList returns non-public implementation of List interface.
This is apparently caused by JDK-4071957 [1], but since that is opened for over 16 years, it should be probably worth it to implement a workaround.
Workaround for this issue is setting setAccessible(true) on the method before invoking it, thus suppress Java access checking.
I have attached a simple reproducer app as well as a stack trace of the exception.

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957

Comment 3 JBoss JIRA Server 2013-11-14 21:23:30 UTC
Farah Juma <fjuma> made a comment on jira JBEE-146

I've created the following PR:
https://github.com/jboss/jboss-el-api_spec/pull/3

Comment 6 JBoss JIRA Server 2013-11-21 00:11:16 UTC
Shelly McGowan <smcgowan> made a comment on jira JBEE-146

Java EE 6 signature tests passed with jboss-el-api_2.2_spec-1.0.3.Final-SNAPSHOT.  Will do a release.

Comment 7 JBoss JIRA Server 2013-11-21 00:37:12 UTC
Shelly McGowan <smcgowan> made a comment on jira JBEE-146

JBoss EL 2.2 Spec API, v1.0.3.Final has been released:
https://repository.jboss.org/nexus/content/groups/public/org/jboss/spec/javax/el/jboss-el-api_2.2_spec/1.0.3.Final/

Comment 8 JBoss JIRA Server 2013-11-21 00:38:47 UTC
Shelly McGowan <smcgowan> made a comment on jira JBEE-146

Commit also merged to jboss-el-api_spec master:
https://github.com/jboss/jboss-el-api_spec/commit/a3955731753487a2fbce5024a66c23bb2b28b63e

Comment 9 JBoss JIRA Server 2013-11-21 14:39:50 UTC
Farah Juma <fjuma> updated the status of jira JBEE-146 to Resolved

Comment 12 Kabir Khan 2014-04-04 18:54:42 UTC
Fixed by upgrade for DR5

Comment 13 JBoss JIRA Server 2014-04-16 22:44:39 UTC
Tomaz Cerar <tomaz.cerar> updated the status of jira WFLY-2493 to Resolved

Comment 14 Matous Jobanek 2014-04-17 11:22:51 UTC
Verified in 6.3.0.DR5