예제 #1
0
 private static DirectMethodHandle makeAllocator(MemberName ctor) {
   assert (ctor.isConstructor() && ctor.getName().equals("<init>"));
   Class<?> instanceClass = ctor.getDeclaringClass();
   ctor = ctor.asConstructor();
   assert (ctor.isConstructor() && ctor.getReferenceKind() == REF_newInvokeSpecial) : ctor;
   MethodType mtype = ctor.getMethodType().changeReturnType(instanceClass);
   LambdaForm lform = preparedLambdaForm(ctor);
   MemberName init = ctor.asSpecial();
   assert (init.getMethodType().returnType() == void.class);
   return new Constructor(mtype, lform, ctor, init, instanceClass);
 }
예제 #2
0
  // Constructors and factory methods in this class *must* be package scoped or private.
  private DirectMethodHandle(MethodType mtype, LambdaForm form, MemberName member) {
    super(mtype, form);
    if (!member.isResolved()) throw new InternalError();

    if (member.getDeclaringClass().isInterface() && member.isMethod() && !member.isAbstract()) {
      // Check for corner case: invokeinterface of Object method
      MemberName m =
          new MemberName(
              Object.class, member.getName(), member.getMethodType(), member.getReferenceKind());
      m = MemberName.getFactory().resolveOrNull(m.getReferenceKind(), m, null);
      if (m != null && m.isPublic()) {
        assert (member.getReferenceKind() == m.getReferenceKind()); // else this.form is wrong
        member = m;
      }
    }

    this.member = member;
  }