JLink`
JLink`

ReturnAsJavaObject

ReturnAsJavaObject[expr]

causes a Java method call or field access during the evaluation of expr to return its result as an object reference (a JavaObject expression), not a value.

Details

  • To use ReturnAsJavaObject, you first need to load J/Link using Needs["JLink`"].
  • Most Java objects are returned as references normally, but those that have a meaningful Wolfram Language representation are returned "by value". Such objects include strings, arrays, and the so-called wrapper classes like java.lang.Integer. ReturnAsJavaObject overrides the normal behavior and forces any object returned to the Wolfram Language to be sent only as a reference.
  • Typically used to avoid needlessly sending large arrays of numbers back and forth between Java and the Wolfram Language.
  • You can use ReturnAsJavaObject to cause only a reference to be sent, then use the JavaObjectToExpression function at the end if the final value is needed.
Wolfram Research (2007), ReturnAsJavaObject, Wolfram Language function, https://reference.wolfram.com/language/JLink/ref/ReturnAsJavaObject.html.

Text

Wolfram Research (2007), ReturnAsJavaObject, Wolfram Language function, https://reference.wolfram.com/language/JLink/ref/ReturnAsJavaObject.html.

BibTeX

@misc{reference.wolfram_2021_returnasjavaobject, author="Wolfram Research", title="{ReturnAsJavaObject}", year="2007", howpublished="\url{https://reference.wolfram.com/language/JLink/ref/ReturnAsJavaObject.html}", note=[Accessed: 25-September-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_returnasjavaobject, organization={Wolfram Research}, title={ReturnAsJavaObject}, year={2007}, url={https://reference.wolfram.com/language/JLink/ref/ReturnAsJavaObject.html}, note=[Accessed: 25-September-2021 ]}

CMS

Wolfram Language. 2007. "ReturnAsJavaObject." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/JLink/ref/ReturnAsJavaObject.html.

APA

Wolfram Language. (2007). ReturnAsJavaObject. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/JLink/ref/ReturnAsJavaObject.html