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

        No work has yet been logged on this issue.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development