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

MethodHandleImpl.makeArrays throws and swallows java.lang.NoSuchFieldError in normal flow

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b39
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        A couple of java.lang.NoSuchFieldError shows up in startup profiles which initializes MethodHandleImpl$Lazy, e.g., any nashorn program:

            private static MethodHandle[] makeArrays() {
                ArrayList<MethodHandle> mhs = new ArrayList<>();
                for (;;) {
                    MethodHandle mh = findCollector("array", mhs.size(), Object[].class);
                    if (mh == null) break;
                    mh = makeIntrinsic(mh, Intrinsic.NEW_ARRAY);
                    mhs.add(mh);
                }
                assert(mhs.size() == 11); // current number of methods
                return mhs.toArray(new MethodHandle[MAX_ARITY+1]);
            }

        Simply rewriting the for (;;) to for (int i = 0; i < 11; i++) should ensure we don't have to throw exceptions here.

        Same goes for makeFillArray, where a for (int i = 1; i < 11; i++) would seem to similarly avoid throwing an exception.

        (Since we assert that size == 11 in both cases, it seems we could also do toArray(new MethodHandle[11]) in both methods)

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  redestad Claes Redestad
                  Reporter:
                  redestad Claes Redestad
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: