MCPcopy Index your code
hub / github.com/extism/java-sdk / Plugin

Method Plugin

src/main/java/org/extism/sdk/Plugin.java:27–57  ·  view source on GitHub ↗

@param manifestBytes The manifest for the plugin @param functions The Host functions for th eplugin @param withWASI Set to true to enable WASI

(byte[] manifestBytes, boolean withWASI, HostFunction[] functions)

Source from the content-addressed store, hash-verified

25 * @param withWASI Set to true to enable WASI
26 */
27 public Plugin(byte[] manifestBytes, boolean withWASI, HostFunction[] functions) {
28
29 Objects.requireNonNull(manifestBytes, "manifestBytes");
30
31 Pointer[] ptrArr = new Pointer[functions == null ? 0 : functions.length];
32
33 if (functions != null)
34 for (int i = 0; i < functions.length; i++) {
35 ptrArr[i] = functions[i].pointer;
36 }
37
38 Pointer[] errormsg = new Pointer[1];
39 Pointer p = LibExtism.INSTANCE.extism_plugin_new(manifestBytes, manifestBytes.length,
40 ptrArr,
41 functions == null ? 0 : functions.length,
42 withWASI,
43 errormsg);
44 if (p == null) {
45 if (functions != null) {
46 for (int i = 0; i < functions.length; i++) {
47 LibExtism.INSTANCE.extism_function_free(functions[i].pointer);
48 }
49 }
50 String msg = errormsg[0].getString(0);
51 LibExtism.INSTANCE.extism_plugin_new_error_free(errormsg[0]);
52 throw new ExtismException(msg);
53 }
54
55 this.functions = functions;
56 this.pluginPointer = p;
57 }
58
59
60 public Plugin(byte[] manifestBytes, boolean withWASI, HostFunction[] functions, long fuelLimit) {

Callers

nothing calls this directly

Calls 5

serializeMethod · 0.95
extism_plugin_newMethod · 0.80
extism_function_freeMethod · 0.80

Tested by

no test coverage detected