Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1514

Class cast exception with BigInteger literals.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not A Bug
    • Affects Version/s: Jena 3.6.0, Jena 3.7.0
    • Fix Version/s: None
    • Component/s: Jena
    • Labels:
      None

      Description

      When saving a BigInteger as a literal it is converted into an XSDBaseNumericType.

      When that  type is read back it is converted into the smallest numeric data type that can hold the value; a narrowing if you will.

      While  this works fine for primitive and primitive wrapping types (e.g. int and Integer) there is no automatic boxing available for BigInteger so attempting to retrieve the value of a BigInteger that is smaller than the Long.MAX_VALUE will result in a class cast exception when the primitive type is cast to the BigInteger.

      I suspect the similar issues arise when BigDecimal is also used but I have not tested.

      Should we address this issue by creating a BigInteger and BigDecimal type that perhaps extends XSDBaseNumericType?  Should we address this issue at all and just post a warning?

      Test code is included to show the issue.

       

        Attachments

        1. BigIntIssue.java
          0.9 kB
          Claude Warren

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              claude Claude Warren
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: