Grails
  1. Grails
  2. GRAILS-8871

@CompileStatic / @TypeChecked compatibility

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0.1
    • Fix Version/s: None
    • Component/s: Commons
    • Labels:
      None

      Description

      Groovy 2 will bring a new couple of annotations for static dispatching and type checking. Integrating these require some rework of artefacts to not depend on any dynamic features (using compile-time injection, ast visitor on builders, reloading workarounds for typed injected properties etc).

      Eventually, a config option to globally enable the static checking/compilation will be provided.

      Quick bytecode sample:

      //original action code :
      def blabla() {
          println "test2-dd"
          def results = userService.findAllWantedUser(55)
      
          render results as XML
      }
      
      //without @CompileStatic
      @Action
      public Object blabla() { 
          CallSite[] arrayOfCallSite = $getCallSiteArray(); 
          arrayOfCallSite[5].callCurrent(this, "test2-dd");
          Object results = arrayOfCallSite[6].call(userService, Integer.valueOf(55));
      
          return arrayOfCallSite[7].callCurrent(this, 
              ScriptBytecodeAdapter.createPojoWrapper(
                  (XML)ScriptBytecodeAdapter.asType(results, XML.class),
                   XML.class
              )
          );
          return null;
      }
      
      
      //with @CompileStatic
      @Action
      public Object blabla() { 
          DefaultGroovyMethods.println(this, "test2-dd");
          null;
          List results = userService.findAllWantedUser(55);
      
          render((XML)ScriptBytecodeAdapter.asType(results, XML.class));
          return null;
          return null;
      }
      

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Stéphane Maldini
              Reporter:
              Stéphane Maldini
            • Votes:
              5 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development