Skip to content

Commit 951b8e9

Browse files
committed
[Java] Remove Nashorn dependency.
1 parent a6f524d commit 951b8e9

2 files changed

Lines changed: 7 additions & 38 deletions

File tree

aeron-annotations/src/main/java/io/aeron/config/validation/Validator.java

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
import io.aeron.config.ExpectedCConfig;
2121
import io.aeron.validation.Grep;
2222

23-
import javax.script.ScriptContext;
24-
import javax.script.ScriptEngine;
25-
import javax.script.ScriptEngineManager;
26-
import javax.script.ScriptException;
2723
import java.util.Collection;
2824
import java.util.Objects;
2925
import java.util.regex.Matcher;
@@ -39,13 +35,11 @@ static ValidationReport validate(
3935
}
4036

4137
private final String sourceDir;
42-
private final ScriptEngine scriptEngine;
4338
private final ValidationReport report;
4439

4540
private Validator(final String sourceDir)
4641
{
4742
this.sourceDir = sourceDir;
48-
this.scriptEngine = new ScriptEngineManager().getEngineByName("JavaScript");
4943
this.report = new ValidationReport();
5044
}
5145

@@ -194,33 +188,13 @@ private void validateCDefaultNumeric(
194188
.replaceAll("([0-9]+)LL", "$1")
195189
.replaceAll("([0-9]+)L", "$1");
196190

197-
try
198-
{
199-
scriptEngine.getContext().setAttribute("INT32_MAX", Integer.MAX_VALUE, ScriptContext.ENGINE_SCOPE);
200-
201-
final String evaluatedFoundDefaultString = scriptEngine.eval(
202-
"AERON_TERM_BUFFER_LENGTH_DEFAULT = (16 * 1024 * 1024);\n" + // this feels like a (very) bad idea
203-
"(" + foundDefaultString + ").toFixed(0)" // avoid scientific notation
204-
).toString();
205-
206-
if (evaluatedFoundDefaultString.equals(c.defaultValue))
207-
{
208-
validation.valid("Expected Default '" + foundDefaultString + "'" +
209-
(foundDefaultString.equals(evaluatedFoundDefaultString) ?
210-
"" : " (" + evaluatedFoundDefaultString + ")") +
211-
" found in " + location);
212-
}
213-
else
214-
{
215-
validation.invalid("found " + foundDefaultString +
216-
" (" + evaluatedFoundDefaultString + ") but expected " + c.defaultValue);
217-
}
218-
}
219-
catch (final ScriptException e)
220-
{
221-
validation.invalid("Expected Default - unable to evaluate expression '" +
222-
originalFoundDefaultString + "' in " + location);
223-
e.printStackTrace(validation.out());
191+
if (foundDefaultString.equals(c.defaultValue))
192+
{
193+
validation.valid("Expected Default '" + foundDefaultString + "' found in " + location);
194+
}
195+
else
196+
{
197+
validation.invalid("found " + foundDefaultString + " but expected " + c.defaultValue);
224198
}
225199
}
226200
}

build.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def byteBuddyVersion = '1.15.1'
6464
def asmVersion = '9.7'
6565
def findbugsAnnotationsVersion = '3.0.1'
6666
def hdrHistogramVersion = '2.2.2'
67-
def nashornVersion = '15.4'
6867
def gitCommitHash = io.aeron.build.GithubUtil.currentGitHash("${projectDir}")
6968

7069
ext {
@@ -381,10 +380,6 @@ project(':aeron-annotations') {
381380
apply plugin: 'signing'
382381
apply plugin: 'biz.aQute.bnd.builder'
383382

384-
dependencies {
385-
implementation "org.openjdk.nashorn:nashorn-core:${nashornVersion}"
386-
}
387-
388383
jar {
389384
bundle {
390385
bnd """

0 commit comments

Comments
 (0)