From 8f55e549f6e21b77cc746f7467400f241dd46d93 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Sun, 24 May 2015 11:14:22 +0000 Subject: [PATCH] Address low priority findbugs warnings git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1681435 13f79535-47bb-0310-9956-ffa450edef68 --- findbugs-exclude.xml | 36 +++++++++++++++++++ .../fop/afp/goca/GraphicsSetProcessColor.java | 1 - .../org/apache/fop/area/AreaTreeObject.java | 9 +++-- .../fop/layoutmgr/PageBreakingAlgorithm.java | 3 ++ .../layoutmgr/PageSequenceLayoutManager.java | 5 ++- .../layoutmgr/inline/LineLayoutManager.java | 12 ++++--- .../inline/LineLayoutPossibilities.java | 16 ++++----- .../layoutmgr/inline/TextLayoutManager.java | 16 ++++++--- .../fop/layoutmgr/table/RowPainter.java | 1 + .../fop/layoutmgr/table/TableStepper.java | 1 + .../apache/fop/render/AbstractRenderer.java | 1 + .../fop/render/afp/AFPImageHandler.java | 6 ++-- .../render/afp/AFPImageHandlerGraphics2D.java | 4 ++- .../render/afp/AFPImageHandlerRawJPEG.java | 4 ++- .../afp/AFPImageHandlerRenderedImage.java | 4 ++- .../fop/render/afp/AFPImageHandlerSVG.java | 4 ++- .../render/awt/viewer/ImageProxyPanel.java | 2 +- .../fop/render/intermediate/IFParser.java | 19 +++++----- .../fop/render/intermediate/IFRenderer.java | 17 +++++---- .../fop/render/pdf/PDFRenderingUtil.java | 2 ++ .../pdf/extensions/PDFArrayElement.java | 5 +-- .../pdf/extensions/PDFDictionaryElement.java | 5 +-- .../pdf/extensions/PDFReferenceElement.java | 4 ++- .../apache/fop/render/xml/XMLRenderer.java | 3 +- .../org/apache/fop/svg/PDFGraphics2D.java | 3 +- 25 files changed, 133 insertions(+), 50 deletions(-) diff --git a/findbugs-exclude.xml b/findbugs-exclude.xml index 37a341de0..73796c128 100644 --- a/findbugs-exclude.xml +++ b/findbugs-exclude.xml @@ -47,6 +47,42 @@ --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java index 54826a2ec..f5808bda6 100644 --- a/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java +++ b/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java @@ -133,7 +133,6 @@ public class GraphicsSetProcessColor extends AbstractGraphicsDrawingOrder { dout.writeByte(a); dout.writeByte(b); } else { - IOUtils.closeQuietly(dout); IOUtils.closeQuietly(baout); throw new IllegalStateException(); } diff --git a/src/java/org/apache/fop/area/AreaTreeObject.java b/src/java/org/apache/fop/area/AreaTreeObject.java index 83bf98b55..02d81ef0a 100644 --- a/src/java/org/apache/fop/area/AreaTreeObject.java +++ b/src/java/org/apache/fop/area/AreaTreeObject.java @@ -41,13 +41,18 @@ public abstract class AreaTreeObject implements Cloneable { protected List extensionAttachments; /** {@inheritDoc} */ + @SuppressWarnings("unchecked") public Object clone() throws CloneNotSupportedException { AreaTreeObject ato = (AreaTreeObject) super.clone(); if (foreignAttributes != null) { - ato.foreignAttributes = (Map) ((HashMap) foreignAttributes).clone(); + // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION") + ato.foreignAttributes = (Map) + ((HashMap)foreignAttributes).clone(); } if (extensionAttachments != null) { - ato.extensionAttachments = (List) ((ArrayList) extensionAttachments).clone(); + // @SuppressFBWarnings("BC_BAD_CAST_TO_CONCRETE_COLLECTION") + ato.extensionAttachments = (List) + ((ArrayList) extensionAttachments).clone(); } return ato; } diff --git a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java index 008ec2265..9327f8f8c 100644 --- a/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java +++ b/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java @@ -941,6 +941,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { @Override protected void finish() { for (int i = startLine; i < endLine; i++) { + // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE") for (KnuthPageNode node = (KnuthPageNode) getNode(i); node != null; node = (KnuthPageNode) node.next) { @@ -978,6 +979,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { // footnoteElementIndex has already been set in getFootnoteSplit() } else { // cannot add any content: create a new node and start again + // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE") KnuthPageNode node = (KnuthPageNode) createNode(lastNode.position, prevNode.line + 1, 1, insertedFootnotesLength - prevNode.insertedFootnotes, @@ -992,6 +994,7 @@ class PageBreakingAlgorithm extends BreakingAlgorithm { } } // create the last node + // @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE") KnuthPageNode node = (KnuthPageNode) createNode(lastNode.position, prevNode.line + 1, 1, totalFootnotesLength - prevNode.insertedFootnotes, 0, 0, diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 20c4616bd..7d84a91ff 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -26,6 +26,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.area.Area; import org.apache.fop.area.AreaTreeHandler; import org.apache.fop.area.AreaTreeModel; import org.apache.fop.area.LineArea; @@ -112,7 +113,9 @@ public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager try { ContentLayoutManager clm = getLayoutManagerMaker() .makeContentLayoutManager(this, getPageSequence().getTitleFO()); - title = (LineArea) clm.getParentArea(null); + Area parentArea = clm.getParentArea(null); + assert (parentArea instanceof LineArea); + title = (LineArea) parentArea; } catch (IllegalStateException e) { // empty title; do nothing } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 6f31f038a..075199e5e 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -108,7 +108,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager * Each value holds the start and end indexes into a List of * inline break positions. */ - private static class LineBreakPosition extends LeafPosition { + static class LineBreakPosition extends LeafPosition { private final int parIndex; // index of the Paragraph this Position refers to private final int startIndex; //index of the first element this Position refers to private final int availableShrink; @@ -986,7 +986,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager keep.getContext(), context)); } - endIndex = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos(); + endIndex = llPoss.getChosenPosition(i).getLeafPos(); // create a list of the FootnoteBodyLM handling footnotes // whose citations are in this line List footnoteList = FootenoteUtil.getFootnotes( @@ -994,7 +994,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager List floats = FloatContentLayoutManager.checkForFloats(seq, startIndex, endIndex); startIndex = endIndex + 1; - LineBreakPosition lbp = (LineBreakPosition) llPoss.getChosenPosition(i); + LineBreakPosition lbp = llPoss.getChosenPosition(i); if (baselineOffset < 0) { baselineOffset = lbp.spaceBefore + lbp.baseline; } @@ -1186,7 +1186,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager /** {@inheritDoc} */ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { - LeafPosition pos = (LeafPosition)lastElement.getPosition(); + Position lastPos = lastElement.getPosition(); + assert (lastPos instanceof LeafPosition); + LeafPosition pos = (LeafPosition) lastPos; //if (lastElement.isPenalty()) { // totalAdj += lastElement.getWidth(); //} @@ -1230,7 +1232,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager // null penalty allowing a page break between lines returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false)); } - LineBreakPosition lbp = (LineBreakPosition) llPoss.getChosenPosition(i); + LineBreakPosition lbp = llPoss.getChosenPosition(i); //log.debug("LLM.getChangedKnuthElements> lineWidth= " // + lbp.lineWidth + " difference= " + lbp.difference); //log.debug(" shrink= " diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java index 49c97b7b6..54ca3e54f 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutPossibilities.java @@ -24,8 +24,6 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.fop.layoutmgr.Position; - /** * Line layout possibilities. */ @@ -37,12 +35,12 @@ public class LineLayoutPossibilities { private final class Possibility { private int lineCount; private double demerits; - private List breakPositions; + private List breakPositions; private Possibility(int lc, double dem) { lineCount = lc; demerits = dem; - breakPositions = new java.util.ArrayList(lc); + breakPositions = new java.util.ArrayList(lc); } private int getLineCount() { @@ -53,15 +51,15 @@ public class LineLayoutPossibilities { return demerits; } - private void addBreakPosition(Position pos) { + private void addBreakPosition(LineLayoutManager.LineBreakPosition pos) { // Positions are always added with index 0 because // they are created backward, from the last one to // the first one breakPositions.add(0, pos); } - private Position getBreakPosition(int i) { - return (Position)breakPositions.get(i); + private LineLayoutManager.LineBreakPosition getBreakPosition(int i) { + return breakPositions.get(i); } } @@ -181,7 +179,7 @@ public class LineLayoutPossibilities { * @param pos a position * @param i an index into posibilities list */ - public void addBreakPosition(Position pos, int i) { + public void addBreakPosition(LineLayoutManager.LineBreakPosition pos, int i) { ((Possibility)possibilitiesList.get(i)).addBreakPosition(pos); } @@ -245,7 +243,7 @@ public class LineLayoutPossibilities { * @param i the break position index * @return the chosen position */ - public Position getChosenPosition(int i) { + public LineLayoutManager.LineBreakPosition getChosenPosition(int i) { return ((Possibility)possibilitiesList.get(chosenIndex)).getBreakPosition(i); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index 2866b80da..638460866 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -209,7 +209,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager { */ GlyphMapping lastMapping = null; while (posIter.hasNext()) { - final LeafPosition tbpNext = (LeafPosition) posIter.next(); + Position nextPos = posIter.next(); + assert (nextPos instanceof LeafPosition); + final LeafPosition tbpNext = (LeafPosition) nextPos; if (tbpNext == null) { continue; //Ignore elements without Positions } @@ -961,7 +963,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager { ListIterator oldListIterator = oldList.listIterator(); KnuthElement knuthElement = (KnuthElement) oldListIterator.next(); Position pos = knuthElement.getPosition(); - LeafPosition leafPos = (LeafPosition) pos.getPosition(depth); + Position innerPosition = pos.getPosition(depth); + assert (innerPosition instanceof LeafPosition); + LeafPosition leafPos = (LeafPosition) innerPosition; int index = leafPos.getLeafPos(); //element could refer to '-1' position, for non-collapsed spaces (?) if (index > -1) { @@ -1082,14 +1086,18 @@ public class TextLayoutManager extends LeafNodeLayoutManager { ListIterator oldListIter; for (oldListIter = oldList.listIterator(); oldListIter.hasNext();) { Position pos = ((KnuthElement) oldListIter.next()).getPosition(); - startPos = (LeafPosition) pos.getPosition(depth); + Position innerPosition = pos.getPosition(depth); + assert (innerPosition == null || innerPosition instanceof LeafPosition); + startPos = (LeafPosition) innerPosition; if (startPos != null && startPos.getLeafPos() != -1) { break; } } for (oldListIter = oldList.listIterator(oldList.size()); oldListIter.hasPrevious();) { Position pos = ((KnuthElement) oldListIter.previous()).getPosition(); - endPos = (LeafPosition) pos.getPosition(depth); + Position innerPosition = pos.getPosition(depth); + assert (innerPosition instanceof LeafPosition); + endPos = (LeafPosition) innerPosition; if (endPos != null && endPos.getLeafPos() != -1) { break; } diff --git a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java index 4c45e62f8..40edca6f7 100644 --- a/src/java/org/apache/fop/layoutmgr/table/RowPainter.java +++ b/src/java/org/apache/fop/layoutmgr/table/RowPainter.java @@ -269,6 +269,7 @@ class RowPainter { } else { borderAfterWhich = ConditionalBorder.REST; } + assert (currentGU instanceof EmptyGridUnit); addAreaForEmptyGridUnit((EmptyGridUnit)currentGU, currentRow.getIndex(), i, actualRowHeight, diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 0906e9faa..7c98bd481 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -158,6 +158,7 @@ public class TableStepper { for (int i = 0; i < columnCount; i++) { GridUnit gu = row.getGridUnit(i); if (!gu.isEmpty() && gu.isPrimary()) { + assert (gu instanceof PrimaryGridUnit); activeCellList.add(new ActiveCell((PrimaryGridUnit) gu, row, rowIndex, previousRowsLength, getTableLM())); } diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 72a517efd..ae54e6539 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -301,6 +301,7 @@ public abstract class AbstractRenderer startVParea(regionReference.getCTM(), port.getClipRectangle()); // do after starting viewport area if (regionReference.getRegionClass() == FO_REGION_BODY) { + assert (regionReference instanceof BodyRegion); renderBodyRegion((BodyRegion) regionReference); } else { renderRegion(regionReference); diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandler.java b/src/java/org/apache/fop/render/afp/AFPImageHandler.java index 6404924a1..d3801c119 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandler.java @@ -31,6 +31,7 @@ import org.apache.fop.afp.AFPPaintingState; import org.apache.fop.afp.AFPResourceInfo; import org.apache.fop.afp.AFPUnitConverter; import org.apache.fop.render.ImageHandlerBase; +import org.apache.fop.render.RendererContext; /** * A base abstract AFP image handler @@ -71,8 +72,9 @@ public abstract class AFPImageHandler implements ImageHandlerBase { (int)Math.round(position.getWidth()), (int)Math.round(position.getHeight())); - AFPRendererContext rendererContext - = (AFPRendererContext)rendererImageInfo.getRendererContext(); + RendererContext context = rendererImageInfo.getRendererContext(); + assert (context instanceof AFPRendererContext); + AFPRendererContext rendererContext = (AFPRendererContext) context; AFPInfo afpInfo = rendererContext.getInfo(); AFPPaintingState paintingState = afpInfo.getPaintingState(); diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java index 2a0db08bb..ba0b5433f 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java @@ -82,7 +82,9 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler implements ImageH throws IOException { AFPRenderingContext afpContext = (AFPRenderingContext)context; - AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo(); + AFPDataObjectInfo info = createDataObjectInfo(); + assert (info instanceof AFPGraphicsObjectInfo); + AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo) info; // set resource information diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java index 7508c8ca0..e5f6f64cb 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java @@ -90,7 +90,9 @@ public class AFPImageHandlerRawJPEG extends AFPImageHandler implements ImageHand throws IOException { AFPRenderingContext afpContext = (AFPRenderingContext)context; - AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo(); + AFPDataObjectInfo info = createDataObjectInfo(); + assert (info instanceof AFPImageObjectInfo); + AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo) info; AFPPaintingState paintingState = afpContext.getPaintingState(); // set resource information diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java index aea7fe8c0..57a5143f6 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java @@ -107,7 +107,9 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima throws IOException { AFPRenderingContext afpContext = (AFPRenderingContext)context; - AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo(); + AFPDataObjectInfo info = createDataObjectInfo(); + assert (info instanceof AFPImageObjectInfo); + AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo) info; AFPPaintingState paintingState = afpContext.getPaintingState(); // set resource information diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java index 68d806a1c..f38da91e9 100644 --- a/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java +++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerSVG.java @@ -78,7 +78,9 @@ public class AFPImageHandlerSVG implements ImageHandler { ImageXMLDOM imageSVG = (ImageXMLDOM)image; FOUserAgent userAgent = afpContext.getUserAgent(); - AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)createDataObjectInfo(); + AFPDataObjectInfo info = createDataObjectInfo(); + assert (info instanceof AFPGraphicsObjectInfo); + AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo) info; AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo(); setDefaultToInlineResourceLevel(graphicsObjectInfo); diff --git a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java index 30b3af9dd..a1c740da8 100644 --- a/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java +++ b/src/java/org/apache/fop/render/awt/viewer/ImageProxyPanel.java @@ -43,7 +43,7 @@ import org.apache.fop.render.awt.AWTRenderer; public class ImageProxyPanel extends JPanel { /** The reference to the BufferedImage storing the page data */ - private Reference imageRef; + private transient Reference imageRef; /** The maximum and preferred size of the panel */ private Dimension size; diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java index 519726291..3d0bfd32f 100644 --- a/src/java/org/apache/fop/render/intermediate/IFParser.java +++ b/src/java/org/apache/fop/render/intermediate/IFParser.java @@ -107,14 +107,16 @@ public class IFParser implements IFConstants { transformer.transform(src, res); } catch (TransformerException te) { + Throwable cause = te.getCause(); //Unpack original IFException if applicable - if (te.getCause() instanceof SAXException) { - SAXException se = (SAXException)te.getCause(); - if (se.getCause() instanceof IFException) { - throw (IFException)se.getCause(); + if (cause instanceof SAXException) { + SAXException se = (SAXException) cause; + cause = se.getCause(); + if (cause instanceof IFException) { + throw (IFException) cause; } - } else if (te.getCause() instanceof IFException) { - throw (IFException)te.getCause(); + } else if (cause instanceof IFException) { + throw (IFException) cause; } throw te; } @@ -375,9 +377,10 @@ public class IFParser implements IFConstants { } private void handleIFException(IFException ife) throws SAXException { - if (ife.getCause() instanceof SAXException) { + Throwable cause = ife.getCause(); + if (cause instanceof SAXException) { //unwrap - throw (SAXException)ife.getCause(); + throw (SAXException) cause; } else { //wrap throw new SAXException(ife); diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index 176f74705..e0843ef74 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -197,8 +197,9 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } private void handleIFExceptionWithIOException(IFException ife) throws IOException { - if (ife.getCause() instanceof IOException) { - throw (IOException)ife.getCause(); + Throwable cause = ife.getCause(); + if (cause instanceof IOException) { + throw (IOException) cause; } else { handleIFException(ife); } @@ -1072,15 +1073,17 @@ public class IFRenderer extends AbstractPathOrientedRenderer { String s = word.getWord(); int[][] dp = word.getGlyphPositionAdjustments(); + Area parentArea = word.getParentArea(); + assert (parentArea instanceof AbstractTextArea); if (dp == null) { renderTextWithAdjustments(s, word.getLetterAdjustArray(), word.isReversed(), - font, (AbstractTextArea)word.getParentArea()); + font, (AbstractTextArea) parentArea); } else if (IFUtil.isDPOnlyDX(dp)) { renderTextWithAdjustments(s, IFUtil.convertDPToDX(dp), word.isReversed(), - font, (AbstractTextArea)word.getParentArea()); + font, (AbstractTextArea) parentArea); } else { renderTextWithAdjustments(s, dp, word.isReversed(), - font, (AbstractTextArea)word.getParentArea()); + font, (AbstractTextArea) parentArea); } super.renderWord(word); @@ -1091,7 +1094,9 @@ public class IFRenderer extends AbstractPathOrientedRenderer { Font font = getFontFromArea(space.getParentArea()); String s = space.getSpace(); - AbstractTextArea textArea = (AbstractTextArea)space.getParentArea(); + Area parentArea = space.getParentArea(); + assert (parentArea instanceof AbstractTextArea); + AbstractTextArea textArea = (AbstractTextArea) parentArea; renderTextWithAdjustments(s, (int[]) null, false, font, textArea); /* COMBINED is always false diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java index e8da29b7d..df6f26c65 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderingUtil.java @@ -388,6 +388,7 @@ class PDFRenderingUtil { } else if (type == PDFObjectType.Number) { array.add(new PDFNumber(entry.getValueAsNumber())); } else if (type == PDFObjectType.Reference) { + assert (entry instanceof PDFReferenceExtension); array.add(resolveReference((PDFReferenceExtension) entry)); } else if (type == PDFObjectType.String) { array.add(entry.getValue()); @@ -423,6 +424,7 @@ class PDFRenderingUtil { } else if (type == PDFObjectType.Number) { dictionary.put(key, new PDFNumber(entry.getValueAsNumber())); } else if (type == PDFObjectType.Reference) { + assert (entry instanceof PDFReferenceExtension); dictionary.put(key, resolveReference((PDFReferenceExtension) entry)); } else if (type == PDFObjectType.String) { dictionary.put(key, entry.getValue()); diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFArrayElement.java b/src/java/org/apache/fop/render/pdf/extensions/PDFArrayElement.java index 1f3ba22b2..34b11272f 100644 --- a/src/java/org/apache/fop/render/pdf/extensions/PDFArrayElement.java +++ b/src/java/org/apache/fop/render/pdf/extensions/PDFArrayElement.java @@ -44,8 +44,9 @@ public class PDFArrayElement extends PDFCollectionEntryElement { } public PDFArrayExtension getArrayExtension() { - assert getExtension() instanceof PDFArrayExtension; - return (PDFArrayExtension) getExtension(); + PDFCollectionEntryExtension extension = getExtension(); + assert (extension instanceof PDFArrayExtension); + return (PDFArrayExtension) extension; } @Override diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFDictionaryElement.java b/src/java/org/apache/fop/render/pdf/extensions/PDFDictionaryElement.java index 3da224290..d7b155e23 100644 --- a/src/java/org/apache/fop/render/pdf/extensions/PDFDictionaryElement.java +++ b/src/java/org/apache/fop/render/pdf/extensions/PDFDictionaryElement.java @@ -64,8 +64,9 @@ public class PDFDictionaryElement extends PDFCollectionEntryElement { } public PDFDictionaryExtension getDictionaryExtension() { - assert getExtension() instanceof PDFDictionaryExtension; - return (PDFDictionaryExtension) getExtension(); + PDFCollectionEntryExtension extension = getExtension(); + assert extension instanceof PDFDictionaryExtension; + return (PDFDictionaryExtension) extension; } @Override diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFReferenceElement.java b/src/java/org/apache/fop/render/pdf/extensions/PDFReferenceElement.java index 37aeeb890..c774a09a8 100644 --- a/src/java/org/apache/fop/render/pdf/extensions/PDFReferenceElement.java +++ b/src/java/org/apache/fop/render/pdf/extensions/PDFReferenceElement.java @@ -52,7 +52,9 @@ public class PDFReferenceElement extends PDFCollectionEntryElement { } else if (refid.length() == 0) { invalidPropertyValueError(ATT_REFID, refid, null); } else { - ((PDFReferenceExtension) getExtension()).setReferenceId(refid); + PDFCollectionEntryExtension extension = getExtension(); + assert (extension instanceof PDFReferenceExtension); + ((PDFReferenceExtension) extension).setReferenceId(refid); } } } diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index 6c392ab4d..c50508edb 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -514,7 +514,8 @@ public class XMLRenderer extends AbstractXMLRenderer { renderRegion(region); endElement("regionStart"); } else if (region.getRegionClass() == FO_REGION_BODY) { - BodyRegion body = (BodyRegion)region; + assert (region instanceof BodyRegion); + BodyRegion body = (BodyRegion) region; if (body.getColumnCount() != 1) { addAttribute("columnGap", body.getColumnGap()); addAttribute("columnCount", body.getColumnCount()); diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 9af8540e8..f415c5473 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -1029,7 +1029,8 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand resourceContext.addXObject(imageInfo); } else { Raster r = pctx.getRaster(devX, devY, devW, devH); - WritableRaster wr = (WritableRaster)r; + assert (r instanceof WritableRaster); + WritableRaster wr = (WritableRaster) r; wr = wr.createWritableTranslatedChild(0, 0); ColorModel pcm = pctx.getColorModel(); -- 2.39.5