Marshalling (computer science)
≈ 3 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
In computer science, marshalling or marshaling (US spelling) is the process of transforming the memory representation of an object into a data format suitable for storage or transmission, especially between different runtimes. It is typically used when data must be moved between different parts of a computer program or from one program to another. Marshalling simplifies complex communications, because it allows using composite objects instead of being restricted to primitive objects.
In computer science, marshalling or marshaling (US spelling) is the process of transforming the memory representation of an object into a data format suitable for storage or transmission, especially between different runtimes. It is typically used when data must be moved between different parts of a computer program or from one program to another. Marshalling simplifies complex communications, because it allows using composite objects instead of being restricted to primitive objects.
Usage and examples
Marshalling is used within implementations of different remote procedure call (RPC) mechanisms, where it is necessary to transport data between processes and/or between threads. In Microsoft's Component Object Model (COM), interface pointers must be marshalled when crossing COM apartment boundaries. In the .NET Framework, the conversion between an unmanaged type and a CLR type, as in the P/Invoke process, is also an example of an action that requires marshalling to take place. Additionally, marshalling is used extensively within scripts and applications that use the XPCOM technologies provided within the Mozilla application framework. The Mozilla Firefox browser is a popular application built with this framework, that additionally allows scripting languages to use XPCOM through XPConnect (Cross-Platform Connect). public class Student { private String name; private int id; public String getName() { return this.name; } public int getId() { return this.id; } void setName(String name) { this.name = name; } void setId(int id) { this.id = id; } } XML representation of a specific Student object: Alice Bob Executable representation of that Student object: Student s1 = new Student(); s1.setId(11235813); s1.setName("Alice"); Student s2 = new Student(); s2.setId(21345589); s2.setName("Bob"); Unmarshalling is the process of converting the XML representation to the default executable Java representation, and running that very code to get a consistent, live object back. Had a different format been chosen, the unmarshalling process would have been different, but the end result in the target runtime would be the same. import java.io.File; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.Unmarshaller; JAXBContext jcon = JAXBContext.newInstance("com.acme.foo"); Unmarshaller umar = jcon.createUnmarshaller(); Object obj = umar.unmarshal(new File("input.xml"));
Text derived from https://en.wikipedia.org/w/index.php?oldid=1365191168 under CC BY-SA 4.0; modifications have been made.