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

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

XMLWordPrintable

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

      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});

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

              Created:
              Updated:
              Resolved: