Skip to content

Commit 573c5a2

Browse files
authored
Load ScriptEngine plugins based on Nashorn.class (#3 to help with diffplug/spotless#803)
2 parents fe635c2 + e062d68 commit 573c5a2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# JScriptBox releases
22

33
## [Unreleased]
4+
### Fixed
5+
- Nashorn script engine is now searched for using the Nashorn classloader rather than the current thread context classloader ([#3](https://github.com/diffplug/jscriptbox/pull/3) to help fix [spotless#803](https://github.com/diffplug/spotless/issues/803)).
46

57
## [3.0.0] - 2015-09-21
68
- First stable release.

src/main/java/com/diffplug/jscriptbox/javascript/Nashorn.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2015 DiffPlug
2+
* Copyright (C) 2015-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,16 +15,14 @@
1515
*/
1616
package com.diffplug.jscriptbox.javascript;
1717

18+
import com.diffplug.jscriptbox.Language;
1819
import java.util.Arrays;
1920
import java.util.HashSet;
2021
import java.util.Set;
21-
2222
import javax.script.ScriptContext;
2323
import javax.script.ScriptEngine;
2424
import javax.script.ScriptEngineManager;
2525

26-
import com.diffplug.jscriptbox.Language;
27-
2826
public class Nashorn {
2927
/**
3028
* Language implementation for javascript using the nashorn engine.
@@ -39,7 +37,7 @@ public static Language language() {
3937
/** Language implementation for javascript using the given policy for resolving any potential conflicts with reserved keywords. */
4038
public static Language language(OnReservedKeyword policy) {
4139
return map -> {
42-
ScriptEngine jsEngine = new ScriptEngineManager().getEngineByName("nashorn");
40+
ScriptEngine jsEngine = new ScriptEngineManager(Nashorn.class.getClassLoader()).getEngineByName("nashorn");
4341
ScriptContext context = jsEngine.getContext();
4442

4543
String mapName = "nashornScriptBoxMap";

0 commit comments

Comments
 (0)