3939
4040import javax .script .ScriptEngineFactory ;
4141
42+ import org .scijava .log .LogService ;
4243import org .scijava .util .FileUtils ;
4344
4445/**
@@ -57,14 +58,32 @@ public class ScriptLanguageIndex extends HashSet<ScriptLanguage> {
5758 private final Map <String , ScriptLanguage > byName =
5859 new HashMap <String , ScriptLanguage >();
5960
61+ private final LogService log ;
62+
63+ @ Deprecated
64+ public ScriptLanguageIndex () {
65+ this (null );
66+ }
67+
68+ /**
69+ * Instantiates an index of the available script languages.
70+ *
71+ * @param logService the log service for errors and warnings
72+ */
73+ public ScriptLanguageIndex (final LogService logService ) {
74+ log = logService ;
75+ }
76+
6077 public boolean add (final ScriptEngineFactory factory , final boolean gently ) {
6178 final String duplicateName = checkDuplicate (factory );
6279 if (duplicateName != null ) {
6380 if (gently ) return false ;
64- throw new IllegalArgumentException ("Duplicate scripting language '" +
65- duplicateName + "': existing=" +
66- byName .get (duplicateName ).getClass ().getName () + ", new=" +
67- factory .getClass ().getName ());
81+ if (log != null ) {
82+ log .warn ("Duplicate scripting language '" +
83+ duplicateName + "': existing=" +
84+ byName .get (duplicateName ).getClass ().getName () +
85+ ", new=" + factory .getClass ().getName ());
86+ }
6887 }
6988
7089 final ScriptLanguage language = wrap (factory );
0 commit comments