Search in sources :

Example 11 with NewInstanceNode

use of org.graalvm.compiler.nodes.java.NewInstanceNode in project graal by oracle.

the class ReflectionSubstitutionType method throwIllegalArgumentException.

private static void throwIllegalArgumentException(HostedGraphKit graphKit, String message) {
    ResolvedJavaType exceptionType = graphKit.getMetaAccess().lookupJavaType(IllegalArgumentException.class);
    ValueNode ite = graphKit.append(new NewInstanceNode(exceptionType, true));
    ResolvedJavaMethod cons = null;
    for (ResolvedJavaMethod c : exceptionType.getDeclaredConstructors()) {
        if (c.getSignature().getParameterCount(false) == 2) {
            cons = c;
        }
    }
    JavaConstant msg = graphKit.getConstantReflection().forString(message);
    ValueNode msgNode = graphKit.createConstant(msg, JavaKind.Object);
    ValueNode cause = graphKit.createConstant(JavaConstant.NULL_POINTER, JavaKind.Object);
    graphKit.createJavaCallWithExceptionAndUnwind(InvokeKind.Special, cons, ite, msgNode, cause);
    graphKit.append(new UnwindNode(ite));
}
Also used : NewInstanceNode(org.graalvm.compiler.nodes.java.NewInstanceNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) JavaConstant(jdk.vm.ci.meta.JavaConstant) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

NewInstanceNode (org.graalvm.compiler.nodes.java.NewInstanceNode)11 ValueNode (org.graalvm.compiler.nodes.ValueNode)8 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)7 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)5 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)5 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)5 DebugContext (org.graalvm.compiler.debug.DebugContext)4 Node (org.graalvm.compiler.graph.Node)4 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 UnwindNode (org.graalvm.compiler.nodes.UnwindNode)4 NewArrayNode (org.graalvm.compiler.nodes.java.NewArrayNode)4 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 JavaKind (jdk.vm.ci.meta.JavaKind)3 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)3 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)3 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)3 StoreFieldNode (org.graalvm.compiler.nodes.java.StoreFieldNode)3 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)2 UserError (com.oracle.svm.core.util.UserError)2