2020import io .aeron .config .ExpectedCConfig ;
2121import 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 ;
2723import java .util .Collection ;
2824import java .util .Objects ;
2925import 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}
0 commit comments