NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 53 - TrakEM2 doesn't build under openjdk
TrakEM2 doesn't build under openjdk
Status: RESOLVED FIXED
Product: Fiji
Classification: Unclassified
Component: TrakEM2
unspecified
PC Linux
: P2 normal
Assigned To: Albert Cardona
Depends on:
Blocks:
 
Reported: 2009-05-01 09:48 CDT by Mark Longair
Modified: 2009-11-20 15:22 CST
1 user (show)

See Also:

Description Mark Longair 2009-05-01 09:48:52 CDT
TrakEM2 builds successfully under openjdk apart from
ini/trakem2/io/ImageSaver.java - the JPEG encoding here
could be replaced by ImageIO as with 52eb5b6f0f9 in
ImageJ.  These errors and those in ImageJ (Bug 52) are
the only ones stopping Fiji from building under openjdk
at the moment.

 JAVA_HOME=/usr/lib/jvm/java-6-openjdk/ make
sh Build.sh run
Building plugins/TrakEM2_.jar <- ij.jar plugins/VIB_.jar plugins/m...
Building in TrakEM2/
Building TrakEM2_.jar <- ini/trakem2/Open_Project.java ini/trakem2...
./TrakEM2/ini/trakem2/io/ImageSaver.java:116: warning: com.sun.image.codec.jpeg.JPEGImageEncoder is Sun proprietary API and may be removed in a future release
			final JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(f);
			      ^
./TrakEM2/ini/trakem2/io/ImageSaver.java:116: warning: com.sun.image.codec.jpeg.JPEGCodec is Sun proprietary API and may be removed in a future release
			final JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(f);
			                                 ^
./TrakEM2/ini/trakem2/io/ImageSaver.java:117: warning: com.sun.image.codec.jpeg.JPEGEncodeParam is Sun proprietary API and may be removed in a future release
			final JPEGEncodeParam param = as_grey ? encoder.getDefaultJPEGEncodeParam(bi.getRaster(), JPEGDecodeParam.COLOR_ID_GRAY)
			      ^
./TrakEM2/ini/trakem2/io/ImageSaver.java:117: warning: com.sun.image.codec.jpeg.JPEGDecodeParam is Sun proprietary API and may be removed in a future release
			final JPEGEncodeParam param = as_grey ? encoder.getDefaultJPEGEncodeParam(bi.getRaster(), JPEGDecodeParam.COLOR_ID_GRAY)
			                                                                                          ^
./TrakEM2/ini/trakem2/io/ImageSaver.java:117: getDefaultJPEGEncodeParam(java.awt.image.BufferedImage) in com.sun.image.codec.jpeg.JPEGImageEncoder cannot be applied to (java.awt.image.WritableRaster,int)
			final JPEGEncodeParam param = as_grey ? encoder.getDefaultJPEGEncodeParam(bi.getRaster(), JPEGDecodeParam.COLOR_ID_GRAY)
			                                               ^
./TrakEM2/ini/trakem2/io/ImageSaver.java:136: warning: com.sun.image.codec.jpeg.JPEGDecodeParam is Sun proprietary API and may be removed in a future release
		return openJpeg(path, JPEGDecodeParam.COLOR_ID_GRAY);
		                      ^
./TrakEM2/ini/trakem2/io/ImageSaver.java:209: warning: com.sun.image.codec.jpeg.JPEGCodec is Sun proprietary API and may be removed in a future release
		return JPEGCodec.createJPEGDecoder(stream, JPEGCodec.getDefaultJPEGEncodeParam(1, color_id)).decodeAsBufferedImage();
		                                           ^
./TrakEM2/ini/trakem2/io/ImageSaver.java:209: warning: com.sun.image.codec.jpeg.JPEGCodec is Sun proprietary API and may be removed in a future release
		return JPEGCodec.createJPEGDecoder(stream, JPEGCodec.getDefaultJPEGEncodeParam(1, color_id)).decodeAsBufferedImage();
		       ^
./TrakEM2/ini/trakem2/io/ImageSaver.java:209: cannot find symbol
symbol  : method createJPEGDecoder(java.io.InputStream,com.sun.image.codec.jpeg.JPEGEncodeParam)
location: class com.sun.image.codec.jpeg.JPEGCodec
		return JPEGCodec.createJPEGDecoder(stream, JPEGCodec.getDefaultJPEGEncodeParam(1, color_id)).decodeAsBufferedImage();
		                ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
7 warnings
Fake failed: Compile error
	in rule TrakEM2_.jar <- ini/trakem2/Open_Project.java ini/trakem2...
	in rule all <- TrakEM2_.jar
	in rule plugins/TrakEM2_.jar <- ij.jar plugins/VIB_.jar plugins/m...
	in rule all <- fiji ij.jar plugins/loci_tools.jar plugins/VIB_.ja...
	in rule run <- all run-fiji
	in rule  <- run
make: *** [run] Error 1
Comment 1 Albert Cardona 2009-05-05 15:07:15 CDT
The ini.trakem2.io.ImageSaver class uses the old com.sun.image.codec.jpeg.JPEGCode classes. Unfortunately, there isn't a one-to-one correspondence between these and the new java.io.ImageIO library.
TrakEM2 is very sensitive to jpeg file generation, and uses three types:

A - grey jpegs (single channel)
B - color jpegs (RGB, which get compressed to 2 channels in jpeg image)
C - color jpegs with alpha (RGBA, which I have no idea how are they compressed)

The last, C, is already compressed and read using ImageIO.

If anybody knows how to reliably create types A and B of jpegs using ImageIO, please let me know. Patches welcome.
Comment 2 Mark Longair 2009-05-05 17:46:38 CDT
To generate A, you should be able to just use BufferedImage.TYPE_BYTE_GRAY
when creating the BufferedImage that you write out.  The same should work
with other image types, although of course alpha channels don't necessarily
work well with JPEG anyway. [1]

Sorry, I'm afraid don't have time to work on a patch at the moment myself :(

[1] http://www.faqs.org/faqs/jpeg-faq/part1/section-12.html which I guess
you know about anyway, but just in case...
Comment 3 Mark Longair 2009-09-29 21:11:56 CDT
I've pushed a branch of TrakEM2 called openjdk-jpeg2 which builds under OpenJDK (6b14-1.4.1-0ubuntu11) for me [1]:

  http://repo.or.cz/w/trakem2.git?a=log;h=refs/heads/openjdk-jpeg2

I haven't had much success in testing this, since I'm having trouble getting TrakEM2 to work in the current version, but I thought I should push it anyway so you can try it out under openjdk-6-* and sun-java6-*.  As I mentioned in IRC, testDebugAlpha() doesn't seem to work under OpenJDK but presumably still works under Sun Java 6, since that code path is unchanged.

The key thing, I think, is to check that this doesn't cause any regressions under Sun Java 6 - we can always add warnings about features that may not work due to current bugs or missing features in OpenJDK.

[1] Built without any of the java/ submodules and with "JAVA_HOME=/usr/lib/jvm/java-6-openjdk/ make"
Comment 4 Johannes Schindelin 2009-11-12 00:50:39 CST
Albert, does Mark's work fix the issue?  I see that you did not merge it into TrakEM2 yet.  This is probably a major show-stopper for Fiji's Ubuntu packaging.
Comment 5 Mark Longair 2009-11-16 19:44:32 CST
Just to confirm, I do need to have an answer about #3 before putting up the
up-do-date packages, which depend on openjdk-6-jdk instead of the sun-java6
versions...
Comment 6 Albert Cardona 2009-11-16 23:56:55 CST
Mark, to move forward with this bug, I need someone to test:

Add an 8-bit gray, and 8-bit with lut,
an 8-bit color, a 16-bit gray, a 16-bit with lut, a 32-bit gray, a
32-bit with lut, and an RGB, to a TrakEM2 canvas. Then do it again and
add an alpha mask to each image. Observe how the images render on the
canvas. To be fair, use min/max ranges other than 0,255 for all images. Use high min/max ranges for 16-bit and 32-bit images.

Now merge your changes and make a new trakem2 project and repeat all,
with sun-java. See that everything looks exactly the same---if so, then all is OK.

I have no time for all this.
Comment 7 Albert Cardona 2009-11-19 20:04:52 CST
Mark,
According to your own commit, it says:

"An (as yet largely untested) patch to let TrakEM2 build..."

The situation is the following: the jpeg storage of TrakEM2 is a core function of TrakEM2 that has to "just work", not "maybe". Your patch cannot be accepted into master without testing. Please test and then merge; meanwhile, please revert the commit.
Comment 8 Mark Longair 2009-11-19 21:15:07 CST
(In reply to comment #7)
> Mark,
> According to your own commit, it says:
> 
> "An (as yet largely untested) patch to let TrakEM2 build..."
> 
> The situation is the following: the jpeg storage of TrakEM2 is a core function
> of TrakEM2 that has to "just work", not "maybe". Your patch cannot be accepted
> into master without testing. Please test and then merge; meanwhile, please
> revert the commit.

I should have altered the commit message before pushing it, but it has been
tested now, at least in the way you asked for.  The situation (see IRC logs
for today) is that Johannes did the test above that you asked for above and
confirmed that the behaviour was the same when using sun-java6.

I've reverted it anyway, but I had assumed that since you said "if so, then
all is OK" then having passed that test it was fine.
Comment 9 Johannes Schindelin 2009-11-20 01:05:31 CST
Please revert the revert, otherwise my time to do the tests was spent in vain.  Yes, I left the original commit message, but on purpose: it serves as a reminder that the main authors of TrakEM2 did not yet have time to test properly, but the footer states (quite clearly!) that it was tested in the requested way!!!
Comment 10 Albert Cardona 2009-11-20 15:22:54 CST
This "bug" is now finally fixed, after adding a number of fixes to ImageSaver--the most important, a native memory leak (aka lack of flushing a BufferedImage).

Thanks Mark and Johannes for all the work!