Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5189

Character XOR behaves differently depending on JVM

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.4
    • 2.0.6, 1.8.9
    • groovy-jdk, primtive opts
    • None

    Description

      If you run this piece of code:

      println GroovySystem.version
      println( ('a' as char) ^ ('b' as char) )
      

      On OS X running with the Apple JVM, then you get:

      1.8.4
      3
      

      If you're running on the Java 6 OpenJDK (for example with Ubuntu, or the Groovy Web Console), you get:

      1.8.4
      groovy.lang.MissingMethodException: No signature of method: java.lang.Character.xor() is applicable for argument types: (java.lang.Character) values: [b]
      Possible solutions: div(java.lang.Character), any(), use([Ljava.lang.Object;), plus(java.lang.Character), is(java.lang.Object), any(groovy.lang.Closure)
      	at Script1.run(Script1.groovy:2)
      

      Is there anything that can be done to get the behaviour the same across the board?

      Jochen said on the mailing list that it was an issue to do with the native type optimisations.

      Maybe just adding xor to Character would get rid of the OpenJDK issue?

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            tim_yates Tim Yates
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: