Type Mapping Between Java Types and .NET Types

Predefined Types

The following table illustrates the type mapping between the primitive types of the CLR and Java.

CLR Type Java Type Description
void void Void value
bool/System.Boolean boolean True/false value
char/System.Char char Unicode character (16 bit)
string/System.String java.lang.String Unicode String
float32/System.Single float IEEE 32-bit float
float64/System.Double double IEEE 64-bit float
int8/System.Int8 byte Signed 8-bit integer
int16/System.Int16 short Signed 16-bit integer
int32/System.Int32 int Signed 32-bit integer
int64/System.Int64 long Signed 64-bit integer
unsigned int8/System.Byte byte Unsigned 8-bit integer
unsigned int16/System.UInt16 short Unsigned 16-bit integer
unsigned int32/System.UInt32 int Unsigned 32-bit integer
unsigned int64/System.UInt64 long Unsigned 64-bit integer
System.Object java.lang.Object Base class for all objects
System.MarshalByRefObject java.lang.Object Base class for all objects passed by reference
System.DateTime java.util.Date Dates will always be serialized (passed by value), according to .NET Remoting
System.Decimal java.math.BigDecimal Will always be serialized (passed by value), according to .NET Remoting

Collections

The following tables illustrate the type mapping between CLR collections and Java collections.

From Java Collection To CLR Collection
java.util.ArrayList System.Collections.IList
java.util.LinkedList System.Collections.IList
java.util.Vector System.Collections.IList
java.util.Hashtable System.Collections.IDictionary
java.util.Hashmap System.Collections.IDictionary
java.util.TreeMap System.Collections.IDictionary
java.util.Properties System.Collections.IDictionary
 
From CLR Collection To Java Collection
System.Collections.ArrayList java.util.List
System.Collections.Hashtable java.util.Map
Note: In order to retain these mappings, parameters and return types *must* be of the specific type (for e.g. type java.util.Vector) and not of an interface that is implemented by that type (for e.g. java.util.List).

User defined types

See the Generated Proxies API for further information.

Exceptions

Exceptions are propagated across remote boundaries, in both directions. Currently the mapping of exceptions is simple, and follows the .NET Remoting standard. In future releases of J-Integra® for .NET, the user will be able to define their own mapping of exceptions.

From Java To .NET

java.lang.ArithmeticException

System.ArithmeticException

java.lang.ArrayIndexOutOfBoundsException

System.IndexOutOfRangeException

java.lang.ArrayStoreException

System.ArrayTypeMismatchException

java.lang.ClassCastException

System.InvalidCastException

java.lang.NoSuchFieldError

System.MissingFieldException

java.lang.NoSuchMethodError

System.MissingMethodException

java.lang.NullPointerException

System.NullReferenceException

java.lang.NumberFormatException

System.FormatException

java.lang.IncompatibleClassChangeError

System.MissingMemberException

java.lang.IllegalAccessError

System.MemberAccessException

java.lang.IllegalArgumentException

System.ArgumentException

java.lang.IllegalMonitorStateException

System.Threading.SynchronizationLockException

java.lang.IllegalThreadStateException

System.Threading.ThreadStateException

java.lang.InternalError

System.NotSupportedException

java.lang.InterruptedException

System.Threading.ThreadInterruptedException

java.lang.UnsatisfiedLinkError

System.EntryPointNotFoundException

java.lang.NoClassDefFoundError

System.TypeLoadException

java.lang.OutOfMemoryError

System.OutOfMemoryException

java.lang.SecurityException

System.Security.SecurityException

java.lang.StackOverflowError

System.StackOverflowException

java.lang.VerifyError

System.Security.VerificationException

java.lang.VirtualMachineError

System.ExecutionEngineException

Any other exception

System.Runtime.Remoting.RemotingException

 
From .NET To Java
Any exception com.intrinsyc.janet.RemoteException

Arrays

.NET supports two forms of arrays, multidimensional arrays and jagged arrays. Java only supports one form of array which is equivalent to .NET's jagged arrays. Below are some examples of array mappings.

From Java To .NET
int[][][] int32[][][]
java.lang.Object[] System.Object[]
 
From .NET To Java
string[][] java.lang.String[][]
bool[,,] boolean[][][]
SomeNameSpace.UserDefinedClass[] SomeNameSpace.UserDefinedClass[]
 

© 2007 Intrinsyc Software International, Inc. All rights reserved. Legal