/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Adapters which manage inexact MethodHandle.invoke calls.
* The JVM calls one of these when the exact type match fails.
* @author jrose
*/
class InvokeGeneric {
// erased type for the call, which originates from an inexact invoke site
// an invoker of type (MT, MH; A...) -> R
/** Compute and cache information for this adapter, so that it can
* call out to targets of the erasure-family of the given erased type.
*/
this.erasedCallerType = erasedCallerType;
this.initialInvoker = makeInitialInvoker();
: initialInvoker.type();
}
return IMPL_LOOKUP;
}
/** Return the adapter information for this type's erasure. */
/*non-public*/ static MethodHandle generalInvokerOf(MethodType erasedCallerType) throws ReflectiveOperationException {
return gen.initialInvoker;
}
// postDispatch = #(MH'; MT, MH; A...){MH'(MT, MH; A)}
if (returnConversionPossible()) {
dispatcher("dispatchWithConversion"));
} else {
}
return invoker;
}
// Take (MH'; MT, MH; A...) and run MH'(MT, MH; A...).
}
}
MethodType.class, MethodHandle.class));
}
static final boolean USE_AS_TYPE_PATH = true;
/** Return a method handle to invoke on the callerType, target, and remaining arguments.
* The method handle must finish the call.
* This is the first look at the caller type and target.
*/
}
}
throw new RuntimeException("NYI");
}
return finisher;
}
private boolean returnConversionPossible() {
return !needType.isPrimitive();
}
return false; // no conversions possible, since must be primitive or Object
return false;
return true;
}
// FIXME: This is slow because it creates a closure node on every call that requires a return cast.
}
return "InvokeGeneric"+erasedCallerType;
}
}