How Data Types are Marshaled

Visual Studio 6.0

Simply put, the Microsoft VM evaluates Java arguments, then converts them to native C++ types. The Microsoft VM infers the native type of each parameter and the return value from the declared (compile-time) Java type of the parameter. For example, a parameter declared as a Java integer is passed as a 32-bit integer; a parameter declared as a Java String object is passed as a null-terminated string, and so forth. There are no invisible attributes that provide information about the native types. In Java, what you see is what you get.

The following topics describe in detail how the Java data types map to native data types:

  • Quick Reference   Provides tables that list the Java type that maps to each native type.

  • Basic Scalar Types   Describes the mappings for int, byte, short, long, float, and double.

  • Chars   Explains the mapping of the char data type.

  • Booleans   Explains the mapping of the boolean data type.

  • Strings   Explains how to pass and receive strings.

  • Arrays   Explains how to pass arrays of scalars.

  • Structures   Explains how to use the @dll.struct directive to pass and receive structures and how to use @dll.structmap to embed fixed-sized arrays within structures.

  • Pointers   Explains how to handle DLLs that have multiple return values and how to read and write data through raw pointers.

  • Polymorphic Parameters   Explains how to simulate polymorphic parameters.

  • Callbacks   Explains how to declare and invoke a DLL function that takes a Callback parameter and how to embed a Callback inside a structure.