You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Pe...@ibi.com on 2009/01/20 09:26:08 UTC

ClassCastException in COSDictionaryMap

The Findbugs tool reported this as an issue, 

I don't have a reproduction of the case, but it is easy to see why it
reported the issue.

Just take a look at the code, it was probably a cut and paste typo that
happened when the code was written.

This is a very easy thing to fix.

 

Thanks,

Peter


Impossible cast 


This cast will always throw a ClassCastException. 

In this method, there is a small issue that is easy to resolve.

package org.apache.pdfbox.pdmodel.common;

 

public static COSDictionaryMap convertBasicTypesToMap( COSDictionary map
) throws IOException  

 

else if( cosObj instanceof COSFloat )

                {

                    actualObject = new Float(
((COSInteger)cosObj).floatValue() );

                }

 

Perhaps you meant to code it like this with a cast to COSFloat.

 

  else if( cosObj instanceof COSFloat )

                {

                    actualObject = new Float(
((COSFloat)cosObj).floatValue() );

                }

 

Peter Lenahan