Trouble with cleanupAtExit property
Closed this issue · 2 comments
In the discussion chat for the library Symja, we discussed an problem that occured when I tried to use the library mentioned in an Elasticsearch plugin. We noticed that the issue originates from ApfloatContext.java. The problem is that ApfloatContext seems to set the property cleanupAtExit
to true
all the time. This leads to the following error:
[2021-05-14T18:30:37,109][WARN ][stderr ] [TIM] java.lang.ExceptionInInitializerError
[2021-05-14T18:30:37,109][WARN ][stderr ] [TIM] at org.matheclipse.core.expression.F.<clinit>(F.java:599)
[2021-05-14T18:30:37,110][WARN ][stderr ] [TIM] at org.matheclipse.core.eval.ExprEvaluator.<clinit>(ExprEvaluator.java:133)
...
[2021-05-14T18:30:37,120][WARN ][stderr ] [TIM] Caused by: org.apfloat.ApfloatConfigurationException: Error setting property "cleanupAtExit" to value "true"
[2021-05-14T18:30:37,120][WARN ][stderr ] [TIM] at org.apfloat.ApfloatContext.setProperty(ApfloatContext.java:1025)
...
[2021-05-14T18:30:37,122][WARN ][stderr ] [TIM] Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "shutdownHooks")
...
[2021-05-14T18:30:37,124][WARN ][stderr ] [TIM] ... 31 more
Since I'm not allowed to have the RunTimePermission shutdownHooks
, I would like to not set cleanupAtExit
to true
. @axkr from Symja noticed that he cannot
[...] find a properties file in the apfloat's JAR itself.
How are the properties to be set in order to avoid the stuff mentioned above to happen?
There are a few possible ways to achieve this, at least the following:
- Put a file
apfloat.properties
to the (root of) the classpath, with file contents like this:
cleanupAtExit=false
- Implement a Java class named
apfloat
in the default package with something like the following code:
import java.util.ListResourceBundle;
import org.apfloat.ApfloatContext;
public class apfloat
extends ListResourceBundle
{
@Override
public Object[][] getContents()
{
Object[][] contents = {{ ApfloatContext.CLEANUP_AT_EXIT, "false" }};
return contents;
}
}
-
Define the system property
apfloat.cleanupAtExit
to be the stringfalse
e.g. add-Dapfloat.cleanupAtExit=false
to your java command line -
Put applet.jar to your classpath, which basically does 2. but it also does a couple of other things (via maven this is the org.apfloat:apfloat-applet artifact)
I tried approach 1, which didn't work, but maybe I just took your advice insufficiently.
Nevertheless, approach 4 worked perfectly: I added implementation "org.apfloat:apfloat-applet:1.10.0-SNAPSHOT"
to my gradle.build
and after a few adjustments with other packages, everything ran as it's been supposed to! :)