janino-compiler / janino

Janino is a super-small, super-fast Java™ compiler.
http://janino-compiler.github.io/janino
Other
1.21k stars 205 forks source link

Issue #202: Gracefully fallback if policy blocks reading system properties #203

Open karlrwjohnson opened 1 year ago

karlrwjohnson commented 1 year ago

(Implementation for https://github.com/janino-compiler/janino/issues/202)

I'm trying to run Janino in an environment where the Java Security Manager restricts reading system properties unless specifically permitted. (Yes, my organization's IT department relies on Java's Security Manager, despite the fact Oracle has deprecated it and plans to remove it. I'm not in charge of that decision.)

When the Security Manager blocks reading a property, it throws a security exception where the read was attempted. I can petition my IT department to add new system properties, but the process is bureaucratic and slow.

Between 3.1.6 and 3.1.9, Janino started reading several System Properties while loading the classes AbstractCompiler and SimpleCompiler. I have successfully petitioned the security folks to permit loading system properties from a wildcard (org.janino.*), but the fallback mechanism in SystemProperties.java -- whereby it checks for a full classpath, but falls back to the class' simple name if another value is not found -- makes it very difficult to write a policy exception because every time a new class in Janino reads a system property, we'd have to account for it.

I propose wrapping these reads in a simple try/catch block.

enexusde commented 1 month ago

The requested functionality is already implemented. Please consider to close this ticket and the pullrequest. It has been implemented different from this pull-request but I think this ticket is solved.