Login  Register

Re: Java Generics

Posted by Adrian Daerr on Jun 13, 2007; 4:07pm
URL: http://imagej.273.s1.nabble.com/Java-Generics-tp3699132p3699135.html

> AFAIK Compile and Run works, if you use a newer JDK to run ImageJ.

I am afraid not. The question of how to compile >=1.5 code from within
ImageJ has surfaced several times, the last time it was because of me :-),
see the thread "compiling java 1.5 code" starting 2007-4-16; this thread
contains two nice suggestions by Albert Cardona on how to patch/plugin
ImageJ to replace "Compile and Run" transparently, but some work is
involved. My guess is that the depreciated sun.tools.javac.Main compiler
interface used by ImageJ refuses to compile code >=1.5 to force the
transition to the new interface.

> I'd suggest to start writing a wrapper using generics, if only to prove
> that it really enhances plugin writing. This wrapper could live as a .jar
> file first, and if it proves popular, could even be folded into a Java5
> version of ImageJ.

That is a very good idea. Hoping that writing the wrapper is not
unreasonably longer that patching the source directly (just a remark,
haven't thought about it at all).

>[on prefering 'write("angle="+atan(sqrt(1+x*x)));' over
>'IJ.write("angle="+Math.atan(Math.sqrt(1+x*x)));']
>
> Sorry, I don't. There is a lot I really, really like about Java5. But it's
> not these shortcuts which make it easy to get confused with methods of the
> current class.

OK, it's a matter of taste. But consider this: at least in the early ages
of the macro language (I haven't looked at it for a long time) this was
about the only difference there was between macro-commands and
plugin-Java. Yet people have been pleading with Wayne to re-implement
NIHImage's macro language. I concluded (maybe I am wrong) that users not
comfortable with programming are very sensitive to this kind of scary
details, and readily sacrifice the greater power/flexibility of
Java-plugins.

> That is exactly the reason why I picked up ImageJA,

Thanks for the pointer, I will look at it.

Adrian