ICEpdf
  1. ICEpdf
  2. PDF-786

ClassCastException: Expression cannot be cast to java.lang.Float

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.6_P01, 5.0.7
    • Fix Version/s: 5.1
    • Component/s: Core/Parsing
    • Labels:
      None
    • Environment:
      All

      Description

      When rendering the provided PDF file, the following error is thrown and the PDF fails to render:

      java.lang.ClassCastException: org.icepdf.core.pobjects.functions.postscript.Expression cannot be cast to java.lang.Float
      at org.icepdf.core.pobjects.functions.postscript.OperatorFactory$18.eval(OperatorFactory.java:328)
      at org.icepdf.core.pobjects.functions.postscript.Lexer.operandStart(Lexer.java:225)
      at org.icepdf.core.pobjects.functions.postscript.Lexer.parse(Lexer.java:112)
      at org.icepdf.core.pobjects.functions.Function_4.calculate(Function_4.java:95)
      at org.icepdf.core.pobjects.graphics.Separation.getColor(Separation.java:179)
      at org.icepdf.core.util.content.AbstractContentParser.consume_sc(AbstractContentParser.java:414)
      at org.icepdf.core.util.content.NContentParser.parse(Unknown Source)
      at org.icepdf.core.pobjects.Page.init(Page.java:370)
      at org.icepdf.ri.common.views.PageViewComponentImpl$PageInitializer.run(PageViewComponentImpl.java:1065)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:745)

        Activity

        Arran Mccullough created issue -
        Patrick Corless made changes -
        Field Original Value New Value
        Fix Version/s 5.1 [ 10675 ]
        Hide
        Patrick Corless added a comment -

        The type 4 function in question uses a few operands we didn't previously have a test case for. Our lexer gets into trouble when we encounters the ifelse and exp operands.

        The lexer has been rewords and the notation of a Procedure has been introduce to aid in the property handling of the ifelse and if statements. After implementing the Procedures class it as also noticed the most of the Math.* functions where putting double values on the stack. This methods were updated to return float values.

        For references purposes the function is defined as:

        {dup 0 lt

        {pop 0 }{dup 1 gt {pop 1 } if } ifelse 0 index 1 exp 1 mul 0 add dup 0 lt {pop 0 }

        {dup 1 gt

        {pop 1 } if } ifelse 1 index 1 exp 0 mul 0 add dup 0 lt {pop 0 }{dup 1 gt {pop 1 }

        if } ifelse 2 index 1 exp 0 mul 0 add dup 0 lt

        {pop 0 }{dup 1 gt {pop 1 } if } ifelse 3 index 1 exp 0 mul 0 add dup 0 lt {pop 0 }

        {dup 1 gt

        {pop 1 }

        if } ifelse 5 4 roll pop }

        Show
        Patrick Corless added a comment - The type 4 function in question uses a few operands we didn't previously have a test case for. Our lexer gets into trouble when we encounters the ifelse and exp operands. The lexer has been rewords and the notation of a Procedure has been introduce to aid in the property handling of the ifelse and if statements. After implementing the Procedures class it as also noticed the most of the Math.* functions where putting double values on the stack. This methods were updated to return float values. For references purposes the function is defined as: {dup 0 lt {pop 0 }{dup 1 gt {pop 1 } if } ifelse 0 index 1 exp 1 mul 0 add dup 0 lt {pop 0 } {dup 1 gt {pop 1 } if } ifelse 1 index 1 exp 0 mul 0 add dup 0 lt {pop 0 }{dup 1 gt {pop 1 } if } ifelse 2 index 1 exp 0 mul 0 add dup 0 lt {pop 0 }{dup 1 gt {pop 1 } if } ifelse 3 index 1 exp 0 mul 0 add dup 0 lt {pop 0 } {dup 1 gt {pop 1 } if } ifelse 5 4 roll pop }
        Hide
        Patrick Corless added a comment -

        Marking as resolved.

        Show
        Patrick Corless added a comment - Marking as resolved.
        Patrick Corless made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #42567 Tue Sep 16 12:42:33 MDT 2014 patrick.corless PDF-786 updatd lexer to correctly handle ifelse operand.
        Files Changed
        Commit graph ADD /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/functions/postscript/Procedure.java
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/functions/postscript/OperatorFactory.java
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/functions/postscript/OperatorNames.java
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/functions/postscript/LexerText.java
        Commit graph MODIFY /icepdf/branches/icepdf-5.0.1/icepdf/core/src/org/icepdf/core/pobjects/functions/postscript/Lexer.java
        Patrick Corless made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Patrick Corless
            Reporter:
            Arran Mccullough
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: