ZhiqiangGao / beanshell2

Automatically exported from code.google.com/p/beanshell2
0 stars 0 forks source link

Obsolete call to "j.l.reflect.AccessibleObject.setAccessible(true)" #88

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Running beanshell scripts in a restricted Environment (with installed 
SecurityManager) fails with SecurityException, even when 
"setAccessibility(true)" isn't called.

Original issue reported on code.google.com by pejob...@gmail.com on 20 Sep 2013 at 12:14

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by pejob...@gmail.com on 20 Sep 2013 at 2:15

GoogleCodeExporter commented 9 years ago
There are more of these calls, I (or tests) didn't spot them because of legacy 
code which automagically set "accessibility" to "true" if a class is generated 
from beanshell code.
This has been removed with rev#135 (in v2.1 branch). This revealed some more 
flaws. The major drawback of the change is compatibility - you can achieve the 
old behaviour if you explictly switch "accessibility" on. But legacy code 
couldn't be changed :(

One workaround is preserving the old behaviour for constructors: If the script 
defines a class with a protected constructor creating an instance would fail 
now. This is one use case I found by googling (and the only one - because of 
the lack of documentation for class creation in beanshell - surly because of 
the pure implementation). So the checkin contains a "fix" for this by setting 
the constructor(s) public - if "accessibility" is off, which is the default now.

#$%& wtf, great mess..

Original comment by pejob...@gmail.com on 27 Sep 2013 at 3:33

GoogleCodeExporter commented 9 years ago
One more thing: Initializing final fields from constructor failed, I can't see 
if this is also caused by driving with seat belts now ("accessibility" = 
false). Could be since setting final fields is allowed in the old mode. Fixed 
also by r135, change is 
http://code.google.com/p/beanshell2/source/diff?spec=svn135&r=135&format=side&pa
th=/branches/v2.1/src/bsh/Variable.java 

Original comment by pejob...@gmail.com on 27 Sep 2013 at 3:42

GoogleCodeExporter commented 9 years ago
Issue 97 has been merged into this issue.

Original comment by pejob...@gmail.com on 10 Feb 2014 at 9:55

GoogleCodeExporter commented 9 years ago
Issue 98 has been merged into this issue.

Original comment by pejob...@gmail.com on 10 Feb 2014 at 2:58

GoogleCodeExporter commented 9 years ago
Issue 99 has been merged into this issue.

Original comment by pejob...@gmail.com on 20 Feb 2014 at 12:12

GoogleCodeExporter commented 9 years ago
This change makes the accessibility.bsh fail in line 87 when accessing a static 
public member (in Java 1.6.0_45 ) ( mypackage.Accessibility1.supersfield4 )

Original comment by snap...@googlemail.com on 4 Jan 2015 at 7:00

GoogleCodeExporter commented 9 years ago
Is this really because of the changes here? There is a comment over the 
mentioned line: "why is this broken?".
Sounds for me like this was broken before (the script was never changed after 
the initial fork).

Original comment by pejob...@gmail.com on 12 Jan 2015 at 8:33