src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java

Print this page
rev 9343 : 8033716: Fix raw and unchecked lint warnings in com.sun.imageio
Reviewed-by: darcy, prr, bae

*** 1,7 **** /* ! * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 76,86 **** /** * List of stream positions for images, reinitialized every time * a new input source is set. */ ! private List imagePositions = null; /** * The number of images in the stream, or 0. */ private int numImages = 0; --- 76,86 ---- /** * List of stream positions for images, reinitialized every time * a new input source is set. */ ! private List<Long> imagePositions = null; /** * The number of images in the stream, or 0. */ private int numImages = 0;
*** 221,233 **** /** The DisposerRecord that handles the actual disposal of this reader. */ private DisposerRecord disposerRecord; /** Sets up static C structures. */ ! private static native void initReaderIDs(Class iisClass, ! Class qTableClass, ! Class huffClass); public JPEGImageReader(ImageReaderSpi originator) { super(originator); structPointer = initJPEGImageReader(); disposerRecord = new JPEGReaderDisposerRecord(structPointer); --- 221,233 ---- /** The DisposerRecord that handles the actual disposal of this reader. */ private DisposerRecord disposerRecord; /** Sets up static C structures. */ ! private static native void initReaderIDs(Class<?> iisClass, ! Class<?> qTableClass, ! Class<?> huffClass); public JPEGImageReader(ImageReaderSpi originator) { super(originator); structPointer = initJPEGImageReader(); disposerRecord = new JPEGReaderDisposerRecord(structPointer);
*** 373,383 **** imagePositions.add(new Long(savePos)); // And set current image since we've read it now currentImage = 0; } if (seekForwardOnly) { ! Long pos = (Long) imagePositions.get(imagePositions.size()-1); iis.flushBefore(pos.longValue()); } tablesOnlyChecked = true; } --- 373,383 ---- imagePositions.add(new Long(savePos)); // And set current image since we've read it now currentImage = 0; } if (seekForwardOnly) { ! Long pos = imagePositions.get(imagePositions.size()-1); iis.flushBefore(pos.longValue()); } tablesOnlyChecked = true; }
*** 390,399 **** --- 390,400 ---- } finally { clearThreadLock(); } } + @SuppressWarnings("fallthrough") private int getNumImagesOnThread(boolean allowSearch) throws IOException { if (numImages != 0) { return numImages; }
*** 479,494 **** } if (!tablesOnlyChecked) { checkTablesOnly(); } if (imageIndex < imagePositions.size()) { ! iis.seek(((Long)(imagePositions.get(imageIndex))).longValue()); } else { // read to start of image, saving positions // First seek to the last position we already have, and skip the // entire image ! Long pos = (Long) imagePositions.get(imagePositions.size()-1); iis.seek(pos.longValue()); skipImage(); // Now add all intervening positions, skipping images for (int index = imagePositions.size(); index <= imageIndex; --- 480,495 ---- } if (!tablesOnlyChecked) { checkTablesOnly(); } if (imageIndex < imagePositions.size()) { ! iis.seek(imagePositions.get(imageIndex).longValue()); } else { // read to start of image, saving positions // First seek to the last position we already have, and skip the // entire image ! Long pos = imagePositions.get(imagePositions.size()-1); iis.seek(pos.longValue()); skipImage(); // Now add all intervening positions, skipping images for (int index = imagePositions.size(); index <= imageIndex;
*** 764,784 **** } finally { clearThreadLock(); } } ! public Iterator getImageTypes(int imageIndex) throws IOException { setThreadLock(); try { return getImageTypesOnThread(imageIndex); } finally { clearThreadLock(); } } ! private Iterator getImageTypesOnThread(int imageIndex) throws IOException { if (currentImage != imageIndex) { cbLock.check(); readHeader(imageIndex, true); } --- 765,785 ---- } finally { clearThreadLock(); } } ! public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException { setThreadLock(); try { return getImageTypesOnThread(imageIndex); } finally { clearThreadLock(); } } ! private Iterator<ImageTypeSpecifier> getImageTypesOnThread(int imageIndex) throws IOException { if (currentImage != imageIndex) { cbLock.check(); readHeader(imageIndex, true); }
*** 1061,1071 **** WritableRaster imRas = null; int numImageBands = 0; if (!wantRaster){ // Can we read this image? ! Iterator imageTypes = getImageTypes(imageIndex); if (imageTypes.hasNext() == false) { throw new IIOException("Unsupported Image Type"); } image = getDestination(param, imageTypes, width, height); --- 1062,1072 ---- WritableRaster imRas = null; int numImageBands = 0; if (!wantRaster){ // Can we read this image? ! Iterator<ImageTypeSpecifier> imageTypes = getImageTypes(imageIndex); if (imageTypes.hasNext() == false) { throw new IIOException("Unsupported Image Type"); } image = getDestination(param, imageTypes, width, height);
*** 1185,1196 **** initProgressData(); // if we have a metadata object, we can count the scans // and set knownPassCount if (imageIndex == imageMetadataIndex) { // We have metadata knownPassCount = 0; ! for (Iterator iter = imageMetadata.markerSequence.iterator(); ! iter.hasNext();) { if (iter.next() instanceof SOSMarkerSegment) { knownPassCount++; } } } --- 1186,1197 ---- initProgressData(); // if we have a metadata object, we can count the scans // and set knownPassCount if (imageIndex == imageMetadataIndex) { // We have metadata knownPassCount = 0; ! for (Iterator<MarkerSegment> iter = ! imageMetadata.markerSequence.iterator(); iter.hasNext();) { if (iter.next() instanceof SOSMarkerSegment) { knownPassCount++; } } }
*** 1563,1573 **** // reset C structures resetReader(structPointer); // reset local Java structures numImages = 0; ! imagePositions = new ArrayList(); currentImage = -1; image = null; raster = null; target = null; buffer = null; --- 1564,1574 ---- // reset C structures resetReader(structPointer); // reset local Java structures numImages = 0; ! imagePositions = new ArrayList<>(); currentImage = -1; image = null; raster = null; target = null; buffer = null;