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

java.lang.VerifyError: Bad local variable type - local final String

XMLWordPrintable

    • b46
    • x86_64
    • windows_7
    • Verified

        FULL PRODUCT VERSION :
        java version "1.8.0_25"
        Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
        Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Windows 7 64bit (Microsoft Windows [6.1.7601])

        A DESCRIPTION OF THE PROBLEM :
        After migration to java 1.8u25, it's impossible to run method containing local final String, used on setter method of some other class. Result of running such code is: "java.lang.VerifyError: Bad local variable type"

        REGRESSION. Last worked in version 7u72

        ADDITIONAL REGRESSION INFORMATION:
        java version "1.8.0_25"
        Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
        Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compiling and running attached code ends with error.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Successful execution.
        ACTUAL -
        Error.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        java.lang.VerifyError: Bad local variable type
        Exception Details:
          Location:
            FinalLocalStringUsedInSetter.test()V @9: aload_1
          Reason:
            Type top (current frame, locals[1]) is not assignable to reference type
          Current Frame:
            bci: @9
            flags: { }
            locals: { 'FinalLocalStringUsedInSetter', top, top, 'FinalLocalStringUsedInSetter$Tmp' }
            stack: { 'FinalLocalStringUsedInSetter$Tmp' }
          Bytecode:
            0x0000000: bb00 0259 b700 034e 2d2b b600 04b1

                at java.lang.Class.getDeclaredMethods0(Native Method)
                at java.lang.Class.privateGetDeclaredMethods(Class.java:2693)
                at java.lang.Class.privateGetMethodRecursive(Class.java:3040)
                at java.lang.Class.getMethod0(Class.java:3010)
                at java.lang.Class.getMethod(Class.java:1776)
                at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
                at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
        [Loaded java.lang.Shutdown from c:\Program Files\Java\jdk1.8.0_25\jre\lib\rt.jar]
        [Loaded java.lang.Shutdown$Lock from c:\Program Files\Java\jdk1.8.0_25\jre\lib\rt.jar]


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class FinalLocalStringUsedInSetter {

        static class Tmp {

        private String value;

        public void setValue(String tmpStr) {
        this.value = tmpStr;
        }

        }

        public void test() {

        final String y = "Y";
        final String n = "N";

        Tmp tmp = new Tmp();
        tmp.setValue(true ? y : n);

        }

        public static void main(String[] args) {
        new FinalLocalStringUsedInSetter().test();
        }

        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Remove "final" from local variables.

              sadayapalam Srikanth Adayapalam (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: