Skip to content

Commit

Permalink
[Java] Remove Nashorn dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
vyazelenko committed Aug 30, 2024
1 parent a6f524d commit 951b8e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
import io.aeron.config.ExpectedCConfig;
import io.aeron.validation.Grep;

import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.Collection;
import java.util.Objects;
import java.util.regex.Matcher;
Expand All @@ -39,13 +35,11 @@ static ValidationReport validate(
}

private final String sourceDir;
private final ScriptEngine scriptEngine;
private final ValidationReport report;

private Validator(final String sourceDir)
{
this.sourceDir = sourceDir;
this.scriptEngine = new ScriptEngineManager().getEngineByName("JavaScript");
this.report = new ValidationReport();
}

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

try
{
scriptEngine.getContext().setAttribute("INT32_MAX", Integer.MAX_VALUE, ScriptContext.ENGINE_SCOPE);

final String evaluatedFoundDefaultString = scriptEngine.eval(
"AERON_TERM_BUFFER_LENGTH_DEFAULT = (16 * 1024 * 1024);\n" + // this feels like a (very) bad idea
"(" + foundDefaultString + ").toFixed(0)" // avoid scientific notation
).toString();

if (evaluatedFoundDefaultString.equals(c.defaultValue))
{
validation.valid("Expected Default '" + foundDefaultString + "'" +
(foundDefaultString.equals(evaluatedFoundDefaultString) ?
"" : " (" + evaluatedFoundDefaultString + ")") +
" found in " + location);
}
else
{
validation.invalid("found " + foundDefaultString +
" (" + evaluatedFoundDefaultString + ") but expected " + c.defaultValue);
}
}
catch (final ScriptException e)
{
validation.invalid("Expected Default - unable to evaluate expression '" +
originalFoundDefaultString + "' in " + location);
e.printStackTrace(validation.out());
if (foundDefaultString.equals(c.defaultValue))
{
validation.valid("Expected Default '" + foundDefaultString + "' found in " + location);
}
else
{
validation.invalid("found " + foundDefaultString + " but expected " + c.defaultValue);
}
}
}
5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def byteBuddyVersion = '1.15.1'
def asmVersion = '9.7'
def findbugsAnnotationsVersion = '3.0.1'
def hdrHistogramVersion = '2.2.2'
def nashornVersion = '15.4'
def gitCommitHash = io.aeron.build.GithubUtil.currentGitHash("${projectDir}")

ext {
Expand Down Expand Up @@ -381,10 +380,6 @@ project(':aeron-annotations') {
apply plugin: 'signing'
apply plugin: 'biz.aQute.bnd.builder'

dependencies {
implementation "org.openjdk.nashorn:nashorn-core:${nashornVersion}"
}

jar {
bundle {
bnd """
Expand Down

0 comments on commit 951b8e9

Please sign in to comment.