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

This code compiles but gives VerifyError when run

    Details

    • Subcomponent:
    • Resolved In Build:
      b78
    • CPU:
      generic, x86
    • OS:
      generic, windows_2000
    • Verification:
      Verified

      Description

      FULL PRODUCT VERSION :
      1.5.0_04
      1.4.2_05


      ADDITIONAL OS VERSION INFORMATION :
      Windows 2000


      A DESCRIPTION OF THE PROBLEM :
      Compiler does not properly detect all situations in which a variable may be referenced before it is assigned.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the code below.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      CompilerBug.java:5: variable x might be assigned in loop
          while(true) {
          ^
      CompilerBug.java:11: variable x might not have been initialized
          System.out.println(x);
                             ^
      2 errors


      (this is the correct behaviour, produced by JDK 1.3.1_08)

      ACTUAL -
      Exception in thread "main" java.lang.VerifyError: (class: CompilerBug, method: m
      ain signature: ([Ljava/lang/String;)V) Accessing value from uninitialized register 1

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.VerifyError: (class: CompilerBug, method: m
      ain signature: ([Ljava/lang/String;)V) Accessing value from uninitialized register 1

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class CompilerBug {

        public static void main(String[] args) {
          final int x;
          while(true) {
            if (true) {
              break;
            }
            x = 1;
          }
          System.out.println(x);
        }
      }

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

        Attachments

          Activity

            People

            • Assignee:
              wtaosunw Wei Tao (Inactive)
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: