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

missing error: initializer must be able to complete normally

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • P4
    • None
    • 6u10
    • specification
    • x86
    • windows_xp

    Description

      FULL PRODUCT VERSION :
      java version 1.7.0-ea, build b76

      ADDITIONAL OS VERSION INFORMATION :
      XP ver 5.1.2600

      A DESCRIPTION OF THE PROBLEM :
      javac in java 1.6 as well as 1.7 b 76 allows the compilation of following:

      public class A
      {
        {
          if (true)
          throw new NullPointerException();
        }
        A() {
        }
      }

      while for the following case without the if(true), it gives error: initializer must be able to complete normally

      public class A
      {
        {
          throw new NullPointerException();
        }
        A() {
        }
      }

      This is ambiguous behaviour when we know that an intializer has to complete normally in all cases. The first case reported above hence is wrongly compiled.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use the example class A given above to compile.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Error : initializer must be able to complete normally
      ACTUAL -
      no error

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class A
      {
        {
          if (true)
          throw new NullPointerException();
        }
        A() {
        }
      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              dlsmith Dan Smith
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: