| Server IP : 217.160.0.212 / Your IP : 216.73.216.15 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/share/emacs/28.2/lisp/org/ |
Upload File : |
;ELC
;;; Compiled
;;; in Emacs version 28.2
;;; with all optimizations.
(byte-code "\300\301!\210\302\303\304\"\207" [require ob add-to-list org-babel-tangle-lang-exts ("java" . "java")] 3)
#@467 Default header args for java source blocks.
The docs say functional mode should be the default [1], but
ob-java didn't originally support functional mode, so we keep
scripting mode as the default for now to maintain previous
behavior.
Most languages write tempfiles to babel's temporary directory,
but ob-java originally had to write them to the current
directory, so we keep that as the default behavior.
[1] https://orgmode.org/manual/Results-of-Evaluation.html
(defvar org-babel-default-header-args:java '((:results . "output") (:dir . ".")) (#$ . 203))
#@33 Java-specific header arguments.
(defconst org-babel-header-args:java '((imports . :any)) (#$ . 768))
(byte-code "\300\301\302\303\304DD\305\306\307\310\311\312\313& \210\300\314\302\303\315DD\316\306\307\310\317\312\313& \210\300\320\302\303\321DD\322\306\307\310\323\312\313& \210\300\324\302\303\325DD\326\306\307\310\327\312\330& \207" [custom-declare-variable org-babel-java-command funcall function #[0 "\300\207" ["java"] 1 #1=""] "Name of the java command.\nMay be either a command in the path, like java or an absolute\npath name, like /usr/local/bin/java. Parameters may be used,\nlike java -verbose." :group org-babel :package-version (Org . "9.5") :type string org-babel-java-compiler #[0 "\300\207" ["javac"] 1 #1#] "Name of the java compiler.\nMay be either a command in the path, like javac or an absolute\npath name, like /usr/local/bin/javac. Parameters may be used,\nlike javac -verbose." (Org . "9.5") org-babel-java-hline-to #[0 "\300\207" ["null"] 1 #1#] "Replace hlines in incoming tables with this when translating to java." (Org . "9.5") org-babel-java-null-to #[0 "\300\207" [hline] 1 #1#] "Replace `null' in java tables with this before returning." (Org . "9.5") symbol] 10)
#@35 Regexp for the package statement.
(defconst org-babel-java--package-re "^[[:space:]]*package[[:space:]]+\\([._[:alnum:]]+\\)[[:space:]]*;$" (#$ . 1976))
#@31 Regexp for import statements.
(defconst org-babel-java--imports-re "^[[:space:]]*import\\(?:[[:space:]]+static\\)?[[:space:]]+\\([*._[:alnum:]]+\\)[[:space:]]*;$" (#$ . 2135))
#@35 Regexp for the class declaration.
(defconst org-babel-java--class-re "^[[:space:]]*\\(?:public[[:space:]]+\\)?class[[:space:]]+\\([_[:alnum:]]+\\)[[:space:]]*{" (#$ . 2317))
#@41 Regexp for the main method declaration.
(defconst org-babel-java--main-re "^[[:space:]]*public[[:space:]]+static[[:space:]]+void[[:space:]]+main[[:space:]]*([[:space:]]*String[][_[:alnum:][:space:]]+)[[:space:]]*\\(?:throws[,._[:alnum:][:space:]]+\\)?{" (#$ . 2497))
#@24 Regexp for any method.
(defconst org-babel-java--any-method-re "^[[:space:]]*\\(?:[[:alnum:]]+[[:space:]]+\\)?\\(?:static[[:space:]]+\\)?[][_[:alnum:]]+[[:space:]]+[_[:alnum:]]+[[:space:]]*([],[_[:alnum:][:space:]]*)[[:space:]]*\\(?:throws[,._[:alnum:][:space:]]+\\)?{" (#$ . 2770))
#@348 Code to inject into a class so that we can capture the value it returns.
This implementation was inspired by ob-python, although not as
elegant. This modified the source block to write out the value
it wants to return to a temporary file so that ob-java can read
it back. The name of the temporary file to write must be
replaced in this string.
(defconst org-babel-java--result-wrapper "\n public static String __toString(Object val) {\n if (val instanceof String) {\n return \"\\\"\" + val + \"\\\"\";\n } else if (val == null) {\n return \"null\";\n } else if (val.getClass().isArray()) {\n StringBuffer sb = new StringBuffer();\n Object[] vals = (Object[])val;\n sb.append(\"[\");\n for (int ii=0; ii<vals.length; ii++) {\n sb.append(__toString(vals[ii]));\n if (ii<vals.length-1)\n sb.append(\",\");\n }\n sb.append(\"]\");\n return sb.toString();\n } else if (val instanceof List) {\n StringBuffer sb = new StringBuffer();\n List vals = (List)val;\n sb.append(\"[\");\n for (int ii=0; ii<vals.size(); ii++) {\n sb.append(__toString(vals.get(ii)));\n if (ii<vals.size()-1)\n sb.append(\",\");\n }\n sb.append(\"]\");\n return sb.toString();\n } else {\n return String.valueOf(val);\n }\n }\n\n public static void main(String[] args) throws IOException {\n BufferedWriter output = new BufferedWriter(new FileWriter(\"%s\"));\n output.write(__toString(_main(args)));\n output.close();\n }" (#$ . 3060))
#@81 Execute a java source block with BODY code and PARAMS params.
(fn BODY PARAMS)
(defalias 'org-babel-execute:java #[514 "\306\236A\206 \307\236A\206 \310\236A?\311\236A\206! \312!\313\314\315\"!@\315\316\317\320#)\266\203\205; \321!\322\203R \323!\203N \323!\fP\202S
\202S !\204i \203i \322\324\315\325#P!\202j \211\211\326Q\327\236A\206w \330\331 \236A\206\200 \330\332\n\236A\206\211 \330\333\333\334\335\"\336 \337\334\335\"\333\333\203\250 \202\252 \333\260\340\f\236A\341
\236A\342=\205\302 \343\344!\345\" \203\332 \346\n!\204\332 \347\n\350\"\210\351$\262\352\353\317\"\354\355\"\216r\211q\210c\210)r\211q\210\356\316\211\f\316\357%\210*\210\360\361$\362\363\236A\364\236A\"\362\365\236A\366\236A\"#*\207" [org-babel-java-compiler org-babel-java-command inhibit-changing-match-data default-directory org-babel-remote-temporary-directory org-babel-temporary-directory :javac :java :dir :classname org-babel-java-find-classname last split-string "\\." nil t string-match file-name-base file-name-as-directory file-remote-p replace-regexp-in-string "/" ".java" :cmpflag "" :cmdline :cmdargs " " org-babel-process-file-name noquote " && " " -cp " :result-type :result-params value org-babel-temp-file "java-" org-babel-expand-body:java file-exists-p make-directory parents org-babel-java--expand-for-evaluation generate-new-buffer " *temp file*" make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] write-region 0 org-babel-reassemble-table org-babel-java-evaluate org-babel-pick-name :colname-names :colnames :rowname-names :rownames] 27 (#$ . 4833)])
#@256 Try to find fully qualified class name in BODY.
Look through BODY for the package and class. If found, put them
together into a fully qualified class name and return. Else just
return class name. If that isn't found either, default to Main.
(fn BODY)
(defalias 'org-babel-java-find-classname #[257 "\302\"\205 \303\304\"\302 \"\205 \303\304\"\203% \211\203% \305Q\2068 \211\203- \211\2068 \2037 \306P\2068 \307\207" [org-babel-java--package-re org-babel-java--class-re string-match match-string 1 "." ".Main" "Main"] 6 (#$ . 6509)])
#@569 Expand source block for evaluation.
In order to return a value we have to add a __toString method.
In order to prevent classes without main methods from erroring we
add a dummy main method if one is not provided. These
manipulations are done outside of `org-babel--expand-body' so
that they are hidden from tangles.
BODY is the file content before instrumentation.
SUPPRESS-PACKAGE-P if true, suppress the package statement.
RESULT-TYPE is taken from params.
RESULT-FILE is the temp file to write the result.
(fn BODY SUPPRESS-PACKAGE-P RESULT-TYPE RESULT-FILE)
(defalias 'org-babel-java--expand-for-evaluation #[1028 "\304\305\306\"r\211q\210\307\310\"\216c\210eb\210\203# \311\312\306#\203# \313\314!\210eb\210\311 \312\306#\2045 \315\n!\210\316c\210\317=\203S eb\210\315\n!\210\320\321\322\"\"c\210\323\324!\210\313\325!\210\326\327\330\"\210\326\327\331\"\210\326\332\333\"\210\326\332\334\"\210\326\332\335\"\210\336 *\207" [org-babel-java--package-re org-babel-java--main-re org-babel-java--class-re org-babel-java--result-wrapper generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] re-search-forward nil replace-match "" org-babel-java--move-past "\n public static void main(String[] args) {\n System.out.print(\"success\");\n }\n\n" value format org-babel-process-file-name noquote search-forward "public static void main(" "public static Object _main(" org-babel-java--import-maybe "java.util" "List" "Arrays" "java.io" "BufferedWriter" "FileWriter" "IOException" buffer-string] 10 (#$ . 7065)])
#@71 Move point past the first occurrence of the given regexp RE.
(fn RE)
(defalias 'org-babel-java--move-past #[257 "\300\301\302#\205 \303\225Tb\210\202 \207" [re-search-forward nil t 0] 5 (#$ . 8662)])
#@97 Import from PACKAGE the given CLASS if it is used and not already imported.
(fn PACKAGE CLASS)
(defalias 'org-babel-java--import-maybe #[514 "\301\211eb\210\302\301\303#\262eb\210\302\304\305\306\260\301\303#\262\2052 \211?\2052 \307!\210\310\311\312\260c\207" [org-babel-java--package-re nil re-search-forward t "^import .*" ".*\\(?:\\*\\|" "\\);" org-babel-java--move-past "import " "." ";\n"] 10 (#$ . 8872)])
#@291 Expand BODY with PARAMS.
BODY could be a few statements, or could include a full class
definition specifying package, imports, and class. Because we
allow this flexibility in what the source block can contain, it
is simplest to expand the code block from the inside out.
(fn BODY PARAMS)
(defalias 'org-babel-expand-body:java #[514 "\306\236A\206\n \307!\310\311\312\"!@\312\313\314\315#)\266\203\205$ \316!\317!\320\236\211\2056 \311\321A\313\"\322\"\323\324\314\"r\211q\210\325\326\"\216c\210eb\210\327 \313\314#\204q \327\n\313\314#\204q \330!\210\330\f!\210\331c\210\332`d\333#\210db\210\334c\210eb\210\327
\313\314#\204\231 \330!\210\330\f!\210\335\316!\336Qc\210\332`d\333#\210db\210\334c\210eb\210\203\261 eb\210\330
!\210\337\340\341#c\210\341c\210\203\305 eb\210\330!\210\337\342\341#\341\261\210eb\210\203\332 \327\313\314#\204\332 \343\344Qc\210\345 *\207" [inhibit-changing-match-data org-babel-java--main-re org-babel-java--any-method-re org-babel-java--package-re org-babel-java--imports-re org-babel-java--class-re :classname org-babel-java-find-classname last split-string "\\." nil t string-match file-name-base org-babel-variable-assignments:java :imports org-babel-read " " generate-new-buffer " *temp*" make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] re-search-forward org-babel-java--move-past "public static void main(String[] args) {\n" indent-code-rigidly 4 "\n}" "\npublic class " " {\n" mapconcat identity "\n" #[257 "\300\301Q\207" ["import " ";"] 4 "\n\n(fn PACKAGE)"] "package " ";\n" buffer-string] 13 (#$ . 9305)])
#@115 Return a list of java statements assigning the block's variables.
variables are contained in PARAMS.
(fn PARAMS)
(defalias 'org-babel-variable-assignments:java #[257 "\300\301\302!\"\207" [mapcar #[257 "\300A!\211@\301\302\303A@ A\"$\207" [org-babel-java-val-to-type #[514 "\300\"\207" [org-babel-java-var-to-java] 5 "\n\n(fn BASETYPE VAR)"] format " static %s %s = %s;"] 11 "\n\n(fn PAIR)"] org-babel--get-vars] 5 (#$ . 10921)])
#@184 Convert an elisp value to a java variable.
Convert an elisp value, VAR, of type BASETYPE into a string of
java source code specifying a variable of the same value.
(fn VAR BASETYPE)
(defalias 'org-babel-java-var-to-java #[514 "\302!\203 ;\204 \303\304\"\305\306\307#\310Q\207\311=\203 \207\211\312\267\202N \313\314\"\207\313\315\"\207;\203I \316\317\320\321#)\266\203\203I \322\323!\207\313\324\"\207\311=\205U \207" [org-babel-java-hline-to inhibit-changing-match-data sequencep make-closure #[257 "\301\300\"\207" [V0 org-babel-java-var-to-java] 4 "\n\n(fn VAR)"] "Arrays.asList(" mapconcat ", " ")" hline #s(hash-table size 3 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (integerp 38 floatp 43 stringp 48)) format "%d" "%f" ".\n+." nil t string-match error "Java does not support multiline string literals" "\"%s\""] 9 (#$ . 11373)])
#@237 Determine the type of VAL.
Return (BASETYPE . LISTTYPE), where BASETYPE is a symbol
representing the type of the individual items in VAL, and
LISTTYPE is a string name of the type parameter for a container
for BASETYPE items.
(fn VAL)
(defalias 'org-babel-java-val-to-type #[257 "\300!\211\301\267\202 \302\202 \303\202 \304\202 \305\306\"<\203+ @<\203+ \307\310\"B\207<\2046 \311!\203= \307\312\"B\207B\207" [org-babel-java-val-to-base-type #s(hash-table size 3 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (integerp 9 floatp 13 stringp 17)) "Integer" "Double" "String" error "Unknown type %S" format "List<List<%s>>" vectorp "List<%s>"] 7 (#$ . 12260)])
#@185 Determine the base type of VAL.
VAL may be
`integerp' if all base values are integers
`floatp' if all base values are either floating points or integers
`stringp' otherwise.
(fn VAL)
(defalias 'org-babel-java-val-to-base-type #[257 "\211\250\203 \300\207\301!\203 \301\207\211<\204 \302!\203'