Mercurial > hg > release > icedtea6-1.11
changeset 2633:944778c61e3c
PR icedtea/752: Increase binary compatibility of JPEG classes.
2011-07-06 Andrew John Hughes <ahughes@redhat.com>
Make JPEG classes more binary compatible with
Oracle versions.
* overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/ImageFormatException.java:
Extend RuntimeException.
(ImageFormatException()): Call superclass constructor.
* overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGCodec.java:
(JPEGCodec()): Make explicit private constructor to prevent implicit public one.
* overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGHuffmanTable.java:
Don't extend javax.imageio.plugins.jpeg.JPEGHuffmanTable.
(lengths): Added.
(symbols): Added.
(JPEGHuffmanTable(short[], short[])): Perform checks outlined in documentation.
(getLengths()): Added.
(getSymbols()): Return symbols.
* overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGImageEncoder.java:
(getDefaultColorId(ColorModel)): Fix typo (was DefaultColorID).
* overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/TruncatedFileException.java:
(TruncatedFileException(BufferedImage)): Add missing constructor.
(TruncatedFileException(Raster)): Likewise.
(getBufferedImage()): Implemented.
(getRaster()): Add missing method.
(TruncatedFileException()): Removed.
(TruncatedFileException(String)): Likewise.
* overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageDecoderImpl.java:
(decodeAsBufferedImage()): Remove unneeded qualification and convert from com.sun JPEGHuffmanTable
to javax.imageio one.
* overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageEncoderImpl.java:
(getDefaultColorId(ColorModel)): Fix typo (was DefaultColorID).
* NEWS: Updated.
author | Andrew John Hughes <ahughes@redhat.com> |
---|---|
date | Wed, 06 Jul 2011 23:24:30 +0100 |
parents | bfbd7ccaa20c |
children | 922f35a6bf90 380a9db76b36 |
files | ChangeLog NEWS overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/ImageFormatException.java overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGCodec.java overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGHuffmanTable.java overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGImageEncoder.java overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/TruncatedFileException.java overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageDecoderImpl.java overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageEncoderImpl.java |
diffstat | 9 files changed, 133 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Jul 06 20:55:06 2011 +0100 +++ b/ChangeLog Wed Jul 06 23:24:30 2011 +0100 @@ -1,3 +1,35 @@ +2011-07-06 Andrew John Hughes <ahughes@redhat.com> + + Make JPEG classes more binary compatible with + Oracle versions. + * overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/ImageFormatException.java: + Extend RuntimeException. + (ImageFormatException()): Call superclass constructor. + * overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGCodec.java: + (JPEGCodec()): Make explicit private constructor to prevent implicit public one. + * overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGHuffmanTable.java: + Don't extend javax.imageio.plugins.jpeg.JPEGHuffmanTable. + (lengths): Added. + (symbols): Added. + (JPEGHuffmanTable(short[], short[])): Perform checks outlined in documentation. + (getLengths()): Added. + (getSymbols()): Return symbols. + * overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGImageEncoder.java: + (getDefaultColorId(ColorModel)): Fix typo (was DefaultColorID). + * overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/TruncatedFileException.java: + (TruncatedFileException(BufferedImage)): Add missing constructor. + (TruncatedFileException(Raster)): Likewise. + (getBufferedImage()): Implemented. + (getRaster()): Add missing method. + (TruncatedFileException()): Removed. + (TruncatedFileException(String)): Likewise. + * overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageDecoderImpl.java: + (decodeAsBufferedImage()): Remove unneeded qualification and convert from com.sun JPEGHuffmanTable + to javax.imageio one. + * overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageEncoderImpl.java: + (getDefaultColorId(ColorModel)): Fix typo (was DefaultColorID). + * NEWS: Updated. + 2011-07-06 Andrew John Hughes <ahughes@redhat.com> * overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/ImageFormatException.java,
--- a/NEWS Wed Jul 06 20:55:06 2011 +0100 +++ b/NEWS Wed Jul 06 23:24:30 2011 +0100 @@ -52,6 +52,7 @@ - S7031385, PR680: Incorrect register allocation in orderAccess_linux_x86.inline.hpp - PR748: Icedtea6 fails to build with Linux 3.0. - PR744: icedtea6-1.10.2 : patching error + - PR752: ImageFormatException extends Exception not RuntimeException * Allow selection of test suites using the jtreg_checks argument e.g. jtreg_checks="langtools" * CACAO - Threadlist & threadobject improvements.
--- a/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/ImageFormatException.java Wed Jul 06 20:55:06 2011 +0100 +++ b/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/ImageFormatException.java Wed Jul 06 23:24:30 2011 +0100 @@ -1,5 +1,6 @@ /* ImageFormatException.java * Copyright (C) 2007 Matthew Flaschen + * Copyright (C) 2011 Red Hat, Inc. * * This file is part of IcedTea * @@ -38,9 +39,10 @@ package com.sun.image.codec.jpeg; -public class ImageFormatException extends Exception { +public class ImageFormatException extends RuntimeException { + public ImageFormatException() { - this(""); + super(); } public ImageFormatException(String s) {
--- a/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGCodec.java Wed Jul 06 20:55:06 2011 +0100 +++ b/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGCodec.java Wed Jul 06 23:24:30 2011 +0100 @@ -56,6 +56,8 @@ */ public class JPEGCodec { + private JPEGCodec() {} + /** * This creates an instance of a JPEGImageDecoder that can be used to decode * JPEG Data streams.
--- a/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGHuffmanTable.java Wed Jul 06 20:55:06 2011 +0100 +++ b/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGHuffmanTable.java Wed Jul 06 23:24:30 2011 +0100 @@ -21,8 +21,7 @@ /** * A class to encapsulate a JPEG Huffman table. */ -public class JPEGHuffmanTable extends - javax.imageio.plugins.jpeg.JPEGHuffmanTable { +public class JPEGHuffmanTable { /** * The standard DC luminance Huffman table. @@ -44,8 +43,14 @@ */ public static final JPEGHuffmanTable StdACChrominance; + private short[] lengths; + + private short[] symbols; + static { - javax.imageio.plugins.jpeg.JPEGHuffmanTable temp = javax.imageio.plugins.jpeg.JPEGHuffmanTable.StdDCLuminance; + javax.imageio.plugins.jpeg.JPEGHuffmanTable temp; + + temp = javax.imageio.plugins.jpeg.JPEGHuffmanTable.StdDCLuminance; StdDCLuminance = new JPEGHuffmanTable(temp.getLengths(), temp.getValues()); @@ -82,16 +87,43 @@ * zero, or if the arrays do not describe a valid Huffman table. */ public JPEGHuffmanTable(short lengths[], short symbols[]) { - super(lengths, symbols); + if (lengths == null) + throw new IllegalArgumentException("lengths array can not be null."); + if (symbols == null) + throw new IllegalArgumentException("symbols array can not be null."); + if (lengths.length > 17) + throw new IllegalArgumentException("lengths array can not be longer than 17."); + if (symbols.length > 256) + throw new IllegalArgumentException("symbols array can not be longer than 256."); + for (int a = 0; a < lengths.length; ++a) + if (lengths[a] < 0) + throw new IllegalArgumentException("length " + a + " is smaller than zero."); + for (int a = 0; a < symbols.length; ++a) + if (symbols[a] < 0) + throw new IllegalArgumentException("symbol " + a + " is smaller than zero."); + this.lengths = lengths; + this.symbols = symbols; + } + + /** + * Return an array containing the number of symbols for each length in + * the Huffman table. + * + * @return A short array where length[a] is equal to the number of symbols + * in the Huffman table of length a. The first element (length[0]) + * is unused. + */ + public short[] getLengths() { + return lengths; } /** * Return an array containing the Huffman symbols arranged by increasing - * length. To make use of this array you must refer the the lengths array. + * length. To make use of this array you must refer to the lengths array. * * @return A short array of Huffman symbols */ public short[] getSymbols() { - return getValues(); + return symbols; } }
--- a/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGImageEncoder.java Wed Jul 06 20:55:06 2011 +0100 +++ b/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/JPEGImageEncoder.java Wed Jul 06 23:24:30 2011 +0100 @@ -204,5 +204,5 @@ * The ColorModel to map to an jpeg encoded COLOR_ID. * @return */ - public int getDefaultColorID(ColorModel cm); + public int getDefaultColorId(ColorModel cm); }
--- a/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/TruncatedFileException.java Wed Jul 06 20:55:06 2011 +0100 +++ b/overlays/jpeg/openjdk/jdk/src/share/classes/com/sun/image/codec/jpeg/TruncatedFileException.java Wed Jul 06 23:24:30 2011 +0100 @@ -1,5 +1,6 @@ /* TruncatedFileException.java Copyright (C) 2007 Matthew Flaschen + Copyright (C) 2011 Red Hat, Inc. This file is part of IcedTea @@ -38,17 +39,54 @@ package com.sun.image.codec.jpeg; import java.awt.image.BufferedImage; +import java.awt.image.Raster; public class TruncatedFileException extends RuntimeException { - public TruncatedFileException() { - this(""); + + private final BufferedImage bufferedImage; + + private final Raster raster; + + /** + * Creates a new exception with the specified {@link BufferedImage} + * containing the partially read image data. + * + * @param bufferedImage the partially decoded image (may be null). + */ + public TruncatedFileException(BufferedImage bufferedImage) { + this.bufferedImage = bufferedImage; + this.raster = null; } - public TruncatedFileException(String s) { - super(s); + /** + * Creates a new exception with the specified {@link Raster} + * containing the partially read image data. + * + * @param raster the partially decoded image (may be null). + */ + public TruncatedFileException(Raster raster) { + this.raster = raster; + this.bufferedImage = null; } + /** + * Returns the partially read data as a {@link BufferedImage} + * if available, or {@code null} if not. + * + * @return the partially read data. + */ public BufferedImage getBufferedImage() { - return null; + return bufferedImage; } + + /** + * Returns the partially read data as a {@link Raster} + * if available, or {@code null} if not. + * + * @return the partially read data. + */ + public Raster getRaster() { + return raster; + } + }
--- a/overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageDecoderImpl.java Wed Jul 06 20:55:06 2011 +0100 +++ b/overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageDecoderImpl.java Wed Jul 06 23:24:30 2011 +0100 @@ -27,6 +27,7 @@ import javax.imageio.ImageReader; import javax.imageio.plugins.jpeg.JPEGHuffmanTable; import javax.imageio.plugins.jpeg.JPEGImageReadParam; +import javax.imageio.plugins.jpeg.JPEGQTable; import javax.imageio.stream.MemoryCacheImageInputStream; import com.sun.image.codec.jpeg.ImageFormatException; @@ -67,14 +68,18 @@ if (param != null) { // We should do more than this, but it's a start. - javax.imageio.plugins.jpeg.JPEGQTable[] qTables = new javax.imageio.plugins.jpeg.JPEGQTable[4]; - javax.imageio.plugins.jpeg.JPEGHuffmanTable[] DCHuffmanTables = new JPEGHuffmanTable[4]; - javax.imageio.plugins.jpeg.JPEGHuffmanTable[] ACHuffmanTables = new JPEGHuffmanTable[4]; + JPEGQTable[] qTables = new JPEGQTable[4]; + JPEGHuffmanTable[] DCHuffmanTables = new JPEGHuffmanTable[4]; + JPEGHuffmanTable[] ACHuffmanTables = new JPEGHuffmanTable[4]; for (int i = 0; i < 4; i++) { - qTables[i] = new javax.imageio.plugins.jpeg.JPEGQTable(param.getQTable(i).getTable()); - DCHuffmanTables[i] = param.getDCHuffmanTable(i); - ACHuffmanTables[i] = param.getACHuffmanTable(i); + qTables[i] = new JPEGQTable(param.getQTable(i).getTable()); + com.sun.image.codec.jpeg.JPEGHuffmanTable dcHuffman = param.getDCHuffmanTable(i); + com.sun.image.codec.jpeg.JPEGHuffmanTable acHuffman = param.getACHuffmanTable(i); + DCHuffmanTables[i] = new JPEGHuffmanTable(dcHuffman.getLengths(), + dcHuffman.getSymbols()); + ACHuffmanTables[i] = new JPEGHuffmanTable(acHuffman.getLengths(), + dcHuffman.getSymbols()); } irp = new JPEGImageReadParam();
--- a/overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageEncoderImpl.java Wed Jul 06 20:55:06 2011 +0100 +++ b/overlays/jpeg/openjdk/jdk/src/share/classes/sun/awt/image/codec/JPEGImageEncoderImpl.java Wed Jul 06 23:24:30 2011 +0100 @@ -142,7 +142,7 @@ } @Override - public int getDefaultColorID(ColorModel cm) { + public int getDefaultColorId(ColorModel cm) { ColorSpace cs = cm.getColorSpace(); int type = cs.getType(); int id = -1;