[armedbear-devel] JSR-223: Return immutable lists in ScriptEngineFactory

Clemens Blamauer clemens.blamauer at gmx.net
Sun Sep 20 12:39:43 UTC 2009


Hi everyone,

I was looking through the JSR-223 code in org.armedbear.lisp.scripting  
as I noticed that AbclScriptEngineFactory is not fully compliant to  
JSR-223 [1].

For the methods:

- java.util.List<java.lang.String> getExtensions()
- java.util.List<java.lang.String> getMimeTypes()
- java.util.List<java.lang.String> getNames()

_immutable_ Lists should be returned.

Please find a remedying patch below.

Cheerz,
Clemens

[1] http://jcp.org/en/jsr/detail?id=223

----

Index: AbclScriptEngineFactory.java
===================================================================
--- AbclScriptEngineFactory.java	(revision 12157)
+++ AbclScriptEngineFactory.java	(working copy)
@@ -21,6 +21,7 @@
  package org.armedbear.lisp.scripting;

  import java.util.ArrayList;
+import java.util.Collections;
  import java.util.List;

  import javax.script.ScriptEngine;
@@ -44,7 +45,7 @@
  	public List<String> getExtensions() {
  		List<String> extensions = new ArrayList<String>(1);
  		extensions.add("lisp");
-		return extensions;
+		return Collections.unmodifiableList(extensions);
  	}

  	@Override
@@ -89,7 +90,7 @@

  	@Override
  	public List<String> getMimeTypes() {
-		return new ArrayList<String>();
+		return Collections.unmodifiableList(new ArrayList<String>());
  	}

  	@Override
@@ -99,7 +100,7 @@
  		names.add("cl");
  		names.add("Lisp");
  		names.add("Common Lisp");
-		return names;
+		return Collections.unmodifiableList(names);
  	}

  	@Override





More information about the armedbear-devel mailing list