I mentioned this in another thread. Here it is.
From 9ae6cb869ae909396d71000ad7804f49640e51ca Mon Sep 17 00:00:00 2001
From: Ian Martins
Date: Tue, 27 Oct 2020 07:00:58 -0400
Subject: [PATCH] ob-java.el: Change the default back to scripting mode
* lisp/ob-java.el: Change the default to scripting mode. Add name to
authors.
* testing/lisp/test-ob-java.el: Modify the first test to use the
default for `:results' and all others to specify it. Add name to
authors.
A recent commit added functional mode and made it default, but this
would break java source blocks for anyone that relied on the old
default. This sets the default back to scripting mode.
I missed a name when I put the authors of ob-C and ob-python as the
authors of ob-java. Added it.
---
lisp/ob-java.el | 11 +--
testing/lisp/test-ob-java.el | 30 --
2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/lisp/ob-java.el b/lisp/ob-java.el
index 05231bee2..c08ede1e7 100644
--- a/lisp/ob-java.el
+++ b/lisp/ob-java.el
@@ -3,6 +3,7 @@
;; Copyright (C) 2011-2020 Free Software Foundation, Inc.
;; Authors: Eric Schulte
+;; Thierry Banel
;; Dan Davison
;; Maintainer: Ian Martins
;; Keywords: literate programming, reproducible research
@@ -35,8 +36,14 @@
(defvar org-babel-temporary-directory) ; from ob-core
-(defvar org-babel-default-header-args:java '()
- "Default header args for java source blocks.")
+(defvar org-babel-default-header-args:java '((:results . "output"))
+ "Default header args for java source blocks.
+The docs say functional mode should be the default [1], but
+ob-java didn't support functional mode until recently, so we keep
+scripting mode as the default for now to maintain existing
+behavior.
+
+[1] https://orgmode.org/manual/Results-of-Evaluation.html";)
(defconst org-babel-header-args:java '((imports . :any))
"Java-specific header arguments.")
diff --git a/testing/lisp/test-ob-java.el b/testing/lisp/test-ob-java.el
index b8f34253f..b055f5a02 100644
--- a/testing/lisp/test-ob-java.el
+++ b/testing/lisp/test-ob-java.el
@@ -2,6 +2,7 @@
;; Copyright (c) 2020 Free Software Foundation, Inc.
;; Authors: Eric Schulte
+;; Thierry Banel
;; Dan Davison
;; Maintainer: Ian Martins
@@ -37,9 +38,10 @@
; simple tests
(ert-deftest ob-java/simple ()
- "Hello world program that writes output."
+ "Hello world program that writes output. Also tests that
+ob-java defaults to scripting mode."
(org-test-with-temp-text
- "#+begin_src java :results output silent
+ "#+begin_src java :results silent
System.out.print(42);
#+end_src"
(should (string= "42" (org-babel-execute-src-block)
@@ -63,7 +65,7 @@ System.out.print(\"\\\"42\\\"\");
(ert-deftest ob-java/simple-return-int ()
"Hello world program that returns an int value."
(org-test-with-temp-text
- "#+begin_src java :results silent
+ "#+begin_src java :results value silent
return 42;
#+end_src"
(should (eq 42 (org-babel-execute-src-block)
@@ -71,7 +73,7 @@ return 42;
(ert-deftest ob-java/simple-return-float ()
"Hello world program that returns a float value."
(org-test-with-temp-text
- "#+begin_src java :results silent
+ "#+begin_src java :results value silent
return 42.0;
#+end_src"
(should (equal 42.0 (org-babel-execute-src-block)
@@ -79,7 +81,7 @@ return 42.0;
(ert-deftest ob-java/simple-return-string ()
"Hello world program that returns a string value."
(org-test-with-temp-text
- "#+begin_src java :results silent
+ "#+begin_src java :results value silent
return \"forty two\";
#+end_src"
(should (string= "forty two" (org-babel-execute-src-block)
@@ -291,7 +293,7 @@ System.out.print(String.format(\"%s, len=%d\", a, a.length()));
(ert-deftest ob-java/return-vector-using-list ()
"Return a vector using a list."
(org-test-with-temp-text
- "#+begin_src java :results vector silent
+ "#+begin_src java :results value vector silent
import java.util.List;
import java.util.Arrays;
List> a = Arrays.asList(Arrays.asList(4),
@@ -304,7 +306,7 @@ return a;
(ert-deftest ob-java/return-vector-using-array ()
"Return a vector using an array."
(org-test-with-temp-text
- "#+begin_src java :results vector silent
+ "#+begin_src java :results value vector silent
Integer[][] a = {{4}, {2}};
return a;
#+end_src"
@@ -314,7 +316,7 @@ return a;
(ert-deftest ob-java/read-return-list ()
"Read and return a list."
(org-test-with-temp-text
- "#+begin_src java :var a=java_list :results silent
+ "#+begin_src java :var a=java_list :results value silent
import java.util.List;
import java.util.Arrays;
List b = Arrays.asList(a.get(0).get(0),
@@ -331,7 +333,7 @@ return b;
(ert-deftest ob-java/read-list-return-array ()
"Read a list and return an array."
(org-test-with-temp-text
- "#+begin_src java :var a=java_list :results silent
+ "#+begin