Janino

AccessControlException thrown with Janino compiled code under Java Webstart

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.5.12
  • Component/s: None
  • Labels:
    None
  • Environment:
    Janino 2.5.9, Java Webstart, jnlp file includes all-permissions
  • Patch Submitted:
    Yes
  • Number of attachments :
    0

Description

Under webstart, Janino compiled code does not inherit the protection domain of the current code and causes the SecurityManager to throw AccessControlException when doing something non-trivial, e.g. network access.

The same bug was found and fixed in Jel recently. The original report is here:
http://www.nabble.com/-Help-jel--java.security.AccessControlException-t4579923.html

The fix is a one-liner. When calling defineClass, the protection domain must be specified. In the Janino codebase 2.5.9, ByteArrayClassLoader, line 87 should be changed to add an extra parameter:

return super.defineClass(
name,
data, 0, data.length,
this.getClass().getProtectionDomain() // add this line
);

The original Jel report includes a nice test case.

Activity

Hide
Arno Unkrig added a comment -

Done; please test.

Show
Arno Unkrig added a comment - Done; please test.
Hide
Wouter Lievens added a comment - - edited

I get the error again, using janino 2.5.16
I have <all-permissions/> in my jnlp file.

Show
Wouter Lievens added a comment - - edited I get the error again, using janino 2.5.16 I have <all-permissions/> in my jnlp file.
Hide
Arno Unkrig added a comment -

The relevant code was not changed. Which version(s) of JANINO worked for you?

Please paste a stack trace.

Show
Arno Unkrig added a comment - The relevant code was not changed. Which version(s) of JANINO worked for you? Please paste a stack trace.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: