public final class JCNull extends Object
When a CLR method or constructor expects a typed null argument (e.g.
null for a parameter of type System.IO.Stream), passing a Java
null directly is ambiguous — the bridge cannot determine the CLR type to
use for overload resolution. JCNull solves this by carrying the CLR type
information alongside the null value.
The CLR type can be provided either as a fully qualified name string
(JCNull(String)) or as a pre-resolved JCType handle
(JCNull(JCType)).
Example — calling a CLR method that accepts a nullable Stream:
// null typed as System.IO.Stream
jcObject.Invoke("MethodThatAcceptsStream", new JCNull("System.IO.Stream"));
| Constructor and Description |
|---|
JCNull(JCType type)
Constructs a typed null from a pre-resolved
JCType handle. |
JCNull(String typeName)
Constructs a typed null for a CLR type identified by its fully qualified name.
|
| Modifier and Type | Method and Description |
|---|---|
JCType |
getType()
Returns the pre-resolved CLR type handle, or
null if this instance
was constructed with a type name string. |
String |
getTypeName()
Returns the fully qualified CLR type name, or
null if this instance
was constructed with a JCType handle. |
public JCNull(String typeName)
typeName - the fully qualified CLR type name, e.g. "System.IO.Stream".public JCNull(JCType type)
JCType handle.
Use this overload when the type has already been resolved via
JCOBridge.GetType(String) to avoid redundant lookups.type - the pre-resolved CLR type handle.