Skip to content

Commit

Permalink
Load ScriptEngine plugins based on Nashorn.class (#3 to help with dif…
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Feb 5, 2023
2 parents fe635c2 + e062d68 commit 573c5a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# JScriptBox releases

## [Unreleased]
### Fixed
- 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)).

## [3.0.0] - 2015-09-21
- First stable release.
10 changes: 4 additions & 6 deletions src/main/java/com/diffplug/jscriptbox/javascript/Nashorn.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2015 DiffPlug
* Copyright (C) 2015-2023 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -15,16 +15,14 @@
*/
package com.diffplug.jscriptbox.javascript;

import com.diffplug.jscriptbox.Language;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

import com.diffplug.jscriptbox.Language;

public class Nashorn {
/**
* Language implementation for javascript using the nashorn engine.
Expand All @@ -39,7 +37,7 @@ public static Language language() {
/** Language implementation for javascript using the given policy for resolving any potential conflicts with reserved keywords. */
public static Language language(OnReservedKeyword policy) {
return map -> {
ScriptEngine jsEngine = new ScriptEngineManager().getEngineByName("nashorn");
ScriptEngine jsEngine = new ScriptEngineManager(Nashorn.class.getClassLoader()).getEngineByName("nashorn");
ScriptContext context = jsEngine.getContext();

String mapName = "nashornScriptBoxMap";
Expand Down

0 comments on commit 573c5a2

Please sign in to comment.