Proper ClassLoader with ClassShutter
Sundararajan Athijegannathan
sundararajan.athijegannathan at oracle.com
Mon Mar 21 15:12:45 UTC 2016
By default Nashorn uses the thread context loader - which is usually
ClassLoader.getSystemClassLoader() [ which is the launcher loader ].
So, your API call looks fine. What is the specific issue, if any,
you've in mind?
Thanks
-Sundar
On 3/20/2016 10:45 PM, Tony Zakula wrote:
> Hey All,
>
> I am using a ClassShutter to limit the Java classes scripts can use, but I
> am wondering how to use the proper ClassLoader in the constructor. The
> following seems to work fine, but is there a better way? Our
> initialization code looks like the following:
>
> // There is a bug on startup sometimes with persistent code cache
> where you get a null pointer
> // https://bugs.openjdk.java.net/browse/JDK-8134304 - We can
> swallow it because things run normally
> ScriptEngine engine = null;
>
> // Custom ClassFilter
> NashornClassFilter nashornClassFilter = new NashornClassFilter();
>
> try {
> engine = new NashornScriptEngineFactory().getScriptEngine(new
> String[]{"-ccs=1000", "-ot=true", "-pcc=true"},
> ClassLoader.getSystemClassLoader(), nashornClassFilter);
> }
> catch (Exception e) {}
>
> Thanks,
>
> Tony
More information about the nashorn-dev
mailing list