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

Resolve constructor of new operation

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • repo-babylon
    • core-libs

      From Tagir:

      https://mail.openjdk.org/pipermail/babylon-dev/2024-July/001096.html

      "
      1. NewOp does not provide a direct way to resolve a constructor. For InvokeOp, one can use op.invokeDescriptor().resolveToHandle(lookup), but creating an instance having a NewOp in hands is more tricky. I do it like this

                Class<?>[] argTypes = newOp.constructorType().parameterTypes().stream()
                        .map(this::toClass).toArray(Class[]::new);
                Class<?> objType = toClass(newOp.type());
                Object result = objType.getConstructor(argTypes).newInstance(arguments.toArray());

      (where toClass is a helper method to get a class from the type). I feel that there should be a simple method to resolve to a Constructor or a MethodHandle.
      "

            Unassigned Unassigned
            psandoz Paul Sandoz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: