Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8210435

don't add local variable spots if they are DCE'ed by the compiler

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 12
    • 8-pool, 9-pool, 10, 11, 12
    • tools
    • None
    • b11

      for this source:

      class Test {
         String foo() {
             final String hello = "Hello!";
             return hello;
         }
      }

      javac generates this code, we are actually interested in the code for method foo():

      java.lang.String foo();
          descriptor: ()Ljava/lang/String;
          flags: (0x0000)
          Code:
            stack=1, locals=2, args_size=1
               0: ldc #2 // String Hello!
               2: areturn
            LineNumberTable:
              line 4: 0

      the max number of locals is set to 2 when actually there is no local used / needed

      this issue was initially reported by Remi at amber-dev: http://mail.openjdk.java.net/pipermail/amber-dev/2018-September/003407.html

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: