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

StringConcatFactory::makeConcatWithConstants no longer throws NullPointerException when an unexpected constant is null

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 15
    • 15
    • core-libs
    • b26
    • 15
    • b27

    Description

      Initially, the method checked all incoming arguments for null:
      <<assembled from makeConcatWithConstants && removed doStringConcat>>
      public static CallSite makeConcatWithConstants(MethodHandles.Lookup lookup,
                                                         String name,
                                                         MethodType concatType,
                                                         String recipe,
                                                         Object... constants)
              throws StringConcatException
      {
               Objects.requireNonNull(lookup, "Lookup is null");
               Objects.requireNonNull(name, "Name is null");
               Objects.requireNonNull(concatType, "Concat type is null");
               Objects.requireNonNull(constants, "Constants are null");

      - for (Object o : constants) {
      - Objects.requireNonNull(o, "Cannot accept null constants");
      - }
       ....
      }
      right now the method does not take into account the constants parameter that might be {null}, {1, null} etc. and gets started parsing a recipe. If the recipe contains an error and at least one constant is null then the Method throws StringConcatException although firstly NPE is expected.
      If the recipe has no issues then the method throws NPE as expected.

      The issue was found by JCK test (JCK-7314262) that used a "wrong" recipe but waited for NPE:
      StringConcatFactory.makeConcatWithConstants(lookup(), "name", MethodType.methodType(String.class, String.class, String.class), "", {null});

      Attachments

        Issue Links

          Activity

            People

              redestad Claes Redestad
              lkuskov Leonid Kuskov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: