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

duplicate checkcasts sometimes added

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Cannot Reproduce
    • 1.8-rc-3
    • None
    • bytecode
    • None

    Description

      Sometimes I see groovy is adding checkcasts twice in the bytecode. Here is a simple example:

      Code.groovy:
      
      java.lang.reflect.Field[] fs = Code.class.getDeclaredFields();
      

      The bytecode looks like this:

      public java.lang.Object run();
        Code:
         Stack=2, Locals=4, Args_size=1
         0:   invokestatic    #20; //Method $getCallSiteArray:()[Lorg/codehaus/groovy/runtime/callsite/CallSite;
         3:   astore_1
         4:   aload_1
         5:   ldc     #59; //int 1
         7:   aaload
         8:   invokestatic    #48; //Method $get$$class$Code:()Ljava/lang/Class;
         11:  invokeinterface #62,  2; //InterfaceMethod org/codehaus/groovy/runtime/callsite/CallSite.call:(Ljava/lang/Object;)Ljava/lang/Object;
         16:  astore_2
         17:  aload_2
         18:  invokestatic    #65; //Method $get$array$$class$java$lang$reflect$Field:()Ljava/lang/Class;
         21:  invokestatic    #69; //Method org/codehaus/groovy/runtime/ScriptBytecodeAdapter.castToType:(Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;
         24:  checkcast       #71; //class "[Ljava/lang/reflect/Field;"
         27:  checkcast       #71; //class "[Ljava/lang/reflect/Field;"
         30:  astore_3
         31:  aload_2
         32:  areturn
         33:  aconst_null
         34:  areturn
      
      

      I think I might be seeing it after every call to castToType.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            aclement Andy Clement
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: