Search in sources :

Example 61 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class LoggerSubstitutions method findResourceBundle.

@Substitute
private ResourceBundle findResourceBundle(String name, boolean useCallersClassLoader) {
    /* TODO: the method was originally synchronized. */
    if (name == null) {
        return null;
    }
    /* Same caching as in original implementation. */
    Locale currentLocale = Locale.getDefault();
    if (catalog != null && currentLocale.equals(catalogLocale) && name.equals(catalogName)) {
        return catalog;
    }
    /*
         * Call our (also substituted) resource bundle lookup, without any references to
         * ClassLoader.
         */
    catalog = ResourceBundle.getBundle(name, currentLocale);
    catalogName = name;
    catalogLocale = currentLocale;
    return catalog;
}
Also used : Locale(java.util.Locale) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 62 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class DynamicHub method getResourceAsStream.

@Substitute
private InputStream getResourceAsStream(String resourceName) {
    final String path = resolveName(getName(), resourceName);
    List<byte[]> arr = Resources.get(path);
    return arr == null ? null : new ByteArrayInputStream(arr.get(0));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 63 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class CharsetSubstitutions method availableCharsets.

@Substitute
private static SortedMap<String, Charset> availableCharsets() {
    TreeMap<String, Charset> result = new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
    Map<String, Charset> charsets = ImageSingletons.lookup(LocalizationSupport.class).charsets;
    for (Charset charset : charsets.values()) {
        result.put(charset.name(), charset);
    }
    return Collections.unmodifiableSortedMap(result);
}
Also used : Charset(java.nio.charset.Charset) TreeMap(java.util.TreeMap) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 64 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class Target_com_oracle_truffle_api_nodes_Node method get.

@Substitute
public static NodeClass get(Class<?> clazz) {
    CompilerAsserts.neverPartOfCompilation();
    NodeClass nodeClass = (NodeClass) DynamicHub.fromClass(clazz).getMetaType();
    if (nodeClass == null) {
        throw shouldNotReachHere("Unknown node class: " + clazz.getName());
    }
    return nodeClass;
}
Also used : NodeClass(com.oracle.truffle.api.nodes.NodeClass) Substitute(com.oracle.svm.core.annotate.Substitute)

Example 65 with Substitute

use of com.oracle.svm.core.annotate.Substitute in project graal by oracle.

the class Target_com_oracle_truffle_nfi_impl_NFIContext method loadLibrary.

@Substitute
@TruffleBoundary
static long loadLibrary(@SuppressWarnings("unused") long nativeContext, String name, int flags) {
    PointerBase ret = PosixUtils.dlopen(name, flags);
    if (ret.equal(WordFactory.zero())) {
        CompilerDirectives.transferToInterpreter();
        String error = PosixUtils.dlerror();
        throw new UnsatisfiedLinkError(error);
    }
    return ret.rawValue();
}
Also used : PointerBase(org.graalvm.word.PointerBase) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary) Substitute(com.oracle.svm.core.annotate.Substitute)

Aggregations

Substitute (com.oracle.svm.core.annotate.Substitute)69 CCharPointer (org.graalvm.nativeimage.c.type.CCharPointer)18 SocketException (java.net.SocketException)11 IOException (java.io.IOException)10 CIntPointer (org.graalvm.nativeimage.c.type.CIntPointer)10 PinnedObject (org.graalvm.nativeimage.PinnedObject)9 Util_java_io_FileDescriptor (com.oracle.svm.core.posix.PosixOSInterface.Util_java_io_FileDescriptor)8 FileDescriptor (java.io.FileDescriptor)8 CCharPointerHolder (org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder)8 ServerSocket (java.net.ServerSocket)7 Socket (com.oracle.svm.core.posix.headers.Socket)6 NativeTruffleContext (com.oracle.svm.truffle.nfi.NativeAPI.NativeTruffleContext)6 SignedWord (org.graalvm.word.SignedWord)6 InterruptedIOException (java.io.InterruptedIOException)5 Time.timeval (com.oracle.svm.core.posix.headers.Time.timeval)4 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)3 Stat.fstat (com.oracle.svm.core.posix.headers.Stat.fstat)3 Stat.stat (com.oracle.svm.core.posix.headers.Stat.stat)3 Time.timezone (com.oracle.svm.core.posix.headers.Time.timezone)3 LibFFI.ffi_cif (com.oracle.svm.truffle.nfi.libffi.LibFFI.ffi_cif)3