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

        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.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: