meta = null;
InputStream metaStream = BaseKernel.class.getClassLoader().getResourceAsStream("kernel-metadata.json");
@@ -83,8 +85,8 @@ public abstract class BaseKernel {
meta.put("project", "unknown");
}
- return meta;
- }).get();
+ KERNEL_META = meta;
+ }
private final JupyterIO io;
private boolean shouldReplaceStdStreams;
@@ -161,7 +163,28 @@ public HistoryManager getHistoryManager() {
return null;
}
- public abstract DisplayData eval(String expr) throws Exception;
+ /**
+ * Evaluates a code expression in the kernel's language environment and returns the result
+ * as display data. This is the core evaluation method called when executing code cells
+ * in a Jupyter notebook.
+ *
+ * The implementation should:
+ *
+ * - Parse and evaluate the provided expression string
+ * - Convert the evaluation result into appropriate display data formats
+ * - Handle any language-specific evaluation context/scope
+ *
+ *
+ * The returned {@link DisplayData} can contain multiple representations of the result
+ * (e.g. text/plain, text/html, image/png) to allow rich display in the notebook.
+ * Return null if the expression produces no displayable result.
+ *
+ * @param expr The code expression to evaluate as received from the Jupyter frontend
+ *
+ * @return A {@link DisplayData} object containing the evaluation result in one or more
+ * MIME formats, or null if there is no displayable result
+ */
+ public abstract DisplayData eval(String expr);
/**
* Inspect the code to get things such as documentation for a function. This is
@@ -178,10 +201,9 @@ public HistoryManager getHistoryManager() {
*
* @return an output bundle for displaying the documentation or null if nothing is found
*
- * @throws Exception if the code cannot be inspected for some reason (such as it not
- * compiling)
+ * @throws RuntimeException if the code cannot be inspected for some reason (such as it not compiling)
*/
- public DisplayData inspect(String code, int at, boolean extraDetail) throws Exception {
+ public DisplayData inspect(String code, int at, boolean extraDetail) {
return null;
}
@@ -204,11 +226,11 @@ public DisplayData inspect(String code, int at, boolean extraDetail) throws Exce
* @return the replacement options containing a list of replacement texts and a
* source range to overwrite with a user selected replacement from the list
*
- * @throws Exception if code cannot be completed due to code compilation issues, or
- * similar. This should not be thrown if not replacements are available but rather just
- * an empty replacements returned.
+ * @throws RuntimeException if code cannot be completed due to code compilation issues, or similar.
+ * This should not be thrown if not replacements are available but rather just
+ * an empty replacements returned.
*/
- public ReplacementOptions complete(String code, int at) throws Exception {
+ public ReplacementOptions complete(String code, int at) {
return null;
}
@@ -283,7 +305,7 @@ public void interrupt() {
* not include strings with newlines but rather separate strings each to go on a
* new line.
*/
- public List formatError(Exception e) {
+ public List formatError(Throwable e) {
List lines = new LinkedList<>();
lines.add(this.errorStyler.secondary("---------------------------------------------------------------------------"));