[ImageJ-devel] @Parameter fields - don't make them final

Johannes Schindelin Johannes.Schindelin at gmx.de
Thu May 26 02:35:16 CDT 2011


Hi,

On Wed, 25 May 2011, Grant B. Harris wrote:

> On 5/25/2011 2:53 AM, Johannes Schindelin wrote:
> > Can we have some check when the class is parsed to make sure that
> > @Parameter fields are not final?
> >
> Johannes,
> Ya, I was thinking the same thing.   We can add a check using
> Field.getModifiers() and not add an input widget if the field is final.  I've
> filed a ticket for it.

Maybe this is already half the solution?

-- snipsnap --
diff --git a/core/plugin/src/main/java/imagej/plugin/PluginModuleInfo.java b/core/plugin/src/main/java/imagej/plugin/PluginModuleInfo.java
index d520260..bd6d988 100644
--- a/core/plugin/src/main/java/imagej/plugin/PluginModuleInfo.java
+++ b/core/plugin/src/main/java/imagej/plugin/PluginModuleInfo.java
@@ -165,6 +165,8 @@ public class PluginModuleInfo<T extends BasePlugin> implements ModuleInfo {
 			if (param == null) continue; // not a parameter
 
 			final String name = f.getName();
+			if (Modifier.isFinal(f.getModifiers()))
+				throw new RuntimeException("Invalid 'final' parameter: " + name);
 			if (presets.containsKey(name)) {
 				// assign preset value to field, and exclude from the list of inputs
 				PluginModule.setValue(f, plugin, presets.get(name));




More information about the ImageJ-devel mailing list