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

IllegalArgumentException: null argument for primitive parameter

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-3
    • groovy-runtime
    • None

    Description

      Consider the following:

      void setX(int x) {
        print x
      }
      def map = [:]
      x = map.x // ParameterTypes#coerceArgumentsToClasses does not deal with null and primitive
      

      The call to setX(int) via property write throws IllegalArgumentException at runtime. The exception message and stack-trace don't provide much context.

      java.lang.IllegalArgumentException
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at Scratch.run(Scratch.groovy:5)
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: