Groovy
  1. Groovy
  2. GROOVY-2126

ClassCastException when using java.util.prefs package

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1-rc-1
    • Component/s: XML Processing
    • Labels:
      None
    • Environment:
      tested on Mac OS X 10.4.10 with java version 1.5.0_07 and Fedora Core 5 (2.6.20-1.2320.fc5smp) with java version: 1.5.0_11

      Description

      The following code throws a java.lang.ClassCastException when run as a Groovy script, the same code compiled with groovyc and executed with java runs correctly.

      #prefsTest.groovy
      import java.util.prefs.*;
      def prefs = Preferences.userNodeForPackage(this.getClass());
      prefs.exportSubtree(System.out);
      #end prefsTest.groovy

      Test using the following:
      $ groovy prefsTest.groovy
      Caught: java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
      at prefsTest.run(prefsTest.groovy:4)
      at prefsTest.main(prefsTest.groovy)
      $groovyc prefsTest.groovy
      $java -cp .:$GROOVY_HOME/embeddable/groovy-all-1.0.jar prefsTest
      WARNING: Prefs file removed in background /home/mkennedy/.java/.userPrefs/<unnamed>/prefs.xml
      <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
      <preferences EXTERNAL_XML_VERSION="1.0"><root type="user"><map/><node name="<unnamed>"><map/></node></root></preferences>

      I'm not sure what causes this, I discovered it when converting some java code to Groovy that imports an xml preferences file and I reduced the case to this to reproduce the behavior in a clean environment.

      I apologize for the trouble if this is some stupid error on my part that I'm just not seeing my way around.

        Activity

        Matt Kennedy created issue -
        Matt Kennedy made changes -
        Field Original Value New Value
        Fix Version/s 1.1-beta-2 [ 10436 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Matt Kennedy made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Fixed [ 1 ]
        Guillaume Delcroix made changes -
        Fix Version/s 1.1-rc-1 [ 13165 ]
        Fix Version/s 1.1-beta-2 [ 10436 ]
        Paul King made changes -
        Assignee Paul King [ paulk ]
        Status Reopened [ 4 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12731213 ] Default workflow, editable Closed status [ 12743128 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12969393 ] Default workflow, editable Closed status [ 12977174 ]

          People

          • Assignee:
            Paul King
            Reporter:
            Matt Kennedy
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development