Skip to content

Commit

Permalink
Fixed an AccessControlException with JRE 7.
Browse files Browse the repository at this point in the history
  • Loading branch information
aunkrig committed Aug 31, 2022
1 parent 0c93017 commit dbadfa8
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.security.AccessControlException;
import java.security.ProtectionDomain;
import java.util.Collections;
import java.util.Map;

Expand Down Expand Up @@ -82,12 +84,20 @@ class ByteArrayClassLoader extends ClassLoader {
// JNLP. See
// http://jira.codehaus.org/browse/JANINO-104
// http://www.nabble.com/-Help-jel--java.security.AccessControlException-to13073723.html
ProtectionDomain protectionDomain;
try {

// With JRE 7, "getProtectionDomain" sometimes is not allowed.
protectionDomain = this.getClass().getProtectionDomain();
} catch (AccessControlException ace) {
protectionDomain = null;
}
return super.defineClass(
name, // name
data, // b
0, // off
data.length, // len
this.getClass().getProtectionDomain() // protectionDomain
name, // name
data, // b
0, // off
data.length, // len
protectionDomain // protectionDomain
);
}

Expand Down

0 comments on commit dbadfa8

Please sign in to comment.