Search in sources :

Example 1 with UnresolvedJavaType

use of jdk.vm.ci.meta.UnresolvedJavaType in project graal by oracle.

the class InvalidVTableEntryFeature method makeMethod.

private void makeMethod(AnalysisMethod aMethod) {
    HostedType holder;
    holder = lookupType(aMethod.getDeclaringClass());
    Signature signature = makeSignature(aMethod.getSignature(), holder);
    ConstantPool constantPool = makeConstantPool(aMethod.getConstantPool(), holder);
    ExceptionHandler[] aHandlers = aMethod.getExceptionHandlers();
    ExceptionHandler[] sHandlers = new ExceptionHandler[aHandlers.length];
    for (int i = 0; i < aHandlers.length; i++) {
        ExceptionHandler h = aHandlers[i];
        JavaType catchType = h.getCatchType();
        if (h.getCatchType() instanceof AnalysisType) {
            catchType = lookupType((AnalysisType) catchType);
        } else {
            assert catchType == null || catchType instanceof UnresolvedJavaType;
        }
        sHandlers[i] = new ExceptionHandler(h.getStartBCI(), h.getEndBCI(), h.getHandlerBCI(), h.catchTypeCPI(), catchType);
    }
    HostedMethod sMethod = new HostedMethod(hUniverse, aMethod, holder, signature, constantPool, sHandlers, null);
    assert !hUniverse.methods.containsKey(aMethod);
    hUniverse.methods.put(aMethod, sMethod);
    boolean isCFunction = aMethod.getAnnotation(CFunction.class) != null;
    boolean hasCFunctionOptions = aMethod.getAnnotation(CFunctionOptions.class) != null;
    if (hasCFunctionOptions && !isCFunction) {
        unsupportedFeatures.addMessage(aMethod.format("%H.%n(%p)"), aMethod, "Method annotated with @" + CFunctionOptions.class.getSimpleName() + " must also be annotated with @" + CFunction.class);
    }
    if (isCFunction) {
        if (!aMethod.isNative()) {
            unsupportedFeatures.addMessage(aMethod.format("%H.%n(%p)"), aMethod, "Method annotated with @" + CFunction.class.getSimpleName() + " must be declared native");
        }
    } else if (aMethod.isNative() && !aMethod.isIntrinsicMethod() && !(aMethod.getWrapped() instanceof CustomSubstitutionMethod) && aMethod.isImplementationInvoked() && !NativeImageOptions.ReportUnsupportedElementsAtRuntime.getValue()) {
        unsupportedFeatures.addMessage(aMethod.format("%H.%n(%p)"), aMethod, AnnotationSubstitutionProcessor.deleteErrorMessage(aMethod, DeletedMethod.NATIVE_MESSAGE, true));
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) CFunction(org.graalvm.nativeimage.c.function.CFunction) UnresolvedJavaType(jdk.vm.ci.meta.UnresolvedJavaType) ExceptionHandler(jdk.vm.ci.meta.ExceptionHandler) JavaType(jdk.vm.ci.meta.JavaType) WrappedJavaType(com.oracle.graal.pointsto.infrastructure.WrappedJavaType) UnresolvedJavaType(jdk.vm.ci.meta.UnresolvedJavaType) ConstantPool(jdk.vm.ci.meta.ConstantPool) WrappedConstantPool(com.oracle.graal.pointsto.infrastructure.WrappedConstantPool) CFunctionOptions(com.oracle.svm.core.c.function.CFunctionOptions) WrappedSignature(com.oracle.graal.pointsto.infrastructure.WrappedSignature) Signature(jdk.vm.ci.meta.Signature) CustomSubstitutionMethod(com.oracle.svm.hosted.annotation.CustomSubstitutionMethod)

Example 2 with UnresolvedJavaType

use of jdk.vm.ci.meta.UnresolvedJavaType in project graal by oracle.

the class HSTruffleCompilerRuntime method resolveType.

@Override
public ResolvedJavaType resolveType(MetaAccessProvider metaAccess, String className, boolean required) {
    String internalName = getInternalName(className);
    JavaType jt = runtime().lookupType(internalName, (HotSpotResolvedObjectType) classLoaderDelegate, true);
    if (jt instanceof UnresolvedJavaType) {
        if (required) {
            throw new NoClassDefFoundError(internalName);
        } else {
            return null;
        }
    }
    ResolvedJavaType resolvedType = (ResolvedJavaType) jt;
    // In some situations, we may need the class to be linked now, especially if we are
    // compiling immediately (e.g., to successfully devirtualize FrameWithoutBoxing methods).
    resolvedType.link();
    return resolvedType;
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) UnresolvedJavaType(jdk.vm.ci.meta.UnresolvedJavaType) JString(org.graalvm.jniutils.JNI.JString) UnresolvedJavaType(jdk.vm.ci.meta.UnresolvedJavaType) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Aggregations

JavaType (jdk.vm.ci.meta.JavaType)2 UnresolvedJavaType (jdk.vm.ci.meta.UnresolvedJavaType)2 WrappedConstantPool (com.oracle.graal.pointsto.infrastructure.WrappedConstantPool)1 WrappedJavaType (com.oracle.graal.pointsto.infrastructure.WrappedJavaType)1 WrappedSignature (com.oracle.graal.pointsto.infrastructure.WrappedSignature)1 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)1 CFunctionOptions (com.oracle.svm.core.c.function.CFunctionOptions)1 CustomSubstitutionMethod (com.oracle.svm.hosted.annotation.CustomSubstitutionMethod)1 ConstantPool (jdk.vm.ci.meta.ConstantPool)1 ExceptionHandler (jdk.vm.ci.meta.ExceptionHandler)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 Signature (jdk.vm.ci.meta.Signature)1 JString (org.graalvm.jniutils.JNI.JString)1 CFunction (org.graalvm.nativeimage.c.function.CFunction)1