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

HS with -XX:+AggressiveOpts optimize new StringBuffer(null) so it does not throw NPE as expected

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b06
    • CPU:
      x86
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        StringBuffer should throw NPE when invoked with null however with -XX:+AggressiveOpts it substitute null instead.

        Here is example.
        class TSB {
            public static void main (String[] args) {
                while(true) {
                    System.out.println(stringmakerBUG());
                }
            }

            public static String stringmakerBUG() {
               try {
                   return new StringBuffer(null).toString();
               } catch (NullPointerException e) {
                   return "NPE";
               }
            }
        }

        run:
        java -server -XX:+AggressiveOpts TSB

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                kvn Vladimir Kozlov
                Reporter:
                lmesnik Leonid Mesnik
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: