public final class JCType extends JCHandler
System.Type.
JCType wraps a native reference to a CLR type and exposes operations
on that type: instantiation (NewObject(java.lang.Object...)), static method invocation
(Invoke(java.lang.String, java.lang.Object...)), and static property/field access (Get(java.lang.String), GetField(java.lang.String),
Set(java.lang.String, java.lang.Object), SetField(java.lang.String, java.lang.Object)). It mirrors the instance-level API of
JCObject but targets the type itself rather than an object instance.
Return values follow the same mapping as JCObject: CLR primitives become
Java primitives or String; all other CLR types are returned as
JCObject.
Instances are obtained via JCOBridge.GetType(String) or
JCAssembly.GetType(String) and must not be constructed directly.
See also: JCOReflector for usage examples.
| Modifier and Type | Method and Description |
|---|---|
Object |
Get(String propertyName)
Retrieves a static property value from the CLR type represented by this handle.
|
Object |
GetField(String field)
Retrieves a static field value from the CLR type represented by this handle.
|
Object |
GetOnType(String propertyName)
Retrieves a property from the CLR type using type-level dispatch.
|
int |
hashCode()
Returns the hash code of the underlying CLR type by delegating to the
CLR
GetHashCode method. |
Object |
Invoke(String method,
Object... params)
Invokes a static method on the CLR type represented by this handle.
|
Object |
InvokeOnType(String method,
Object... params)
Invokes a method on the CLR type using type-level (non-static) dispatch.
|
Object |
NewObject(Object... params)
Creates a new instance of the CLR type represented by this handle, passing
optional constructor arguments.
|
JCType |
Set(String propertyName,
Object value)
Sets a static property on the CLR type represented by this handle.
|
JCType |
SetField(String field,
Object value)
Sets a static field on the CLR type represented by this handle.
|
String |
toString()
Returns the string representation of the underlying CLR type by delegating to
the CLR
ToString method. |
getReferencepublic int hashCode()
GetHashCode method.public String toString()
ToString method. Typically returns the fully qualified type name.public Object NewObject(Object... params) throws JCNativeException
params - optional constructor arguments.JCObject.JCNativeException - if the constructor cannot be found or fails, or if a
CLR exception is thrown.public Object Invoke(String method, Object... params) throws JCNativeException
method - the name of the CLR static method to invoke.params - optional arguments to pass to the method.JCObject.JCNativeException - if the method cannot be found, the invocation fails,
or a CLR exception is thrown.public Object Get(String propertyName) throws JCNativeException
propertyName - the name of the CLR static property to read.JCObject.JCNativeException - if the property cannot be found or the read fails.public Object GetField(String field) throws JCNativeException
field - the name of the CLR static field to read.JCObject.JCNativeException - if the field cannot be found or the read fails.public JCType Set(String propertyName, Object value) throws JCNativeException
propertyName - the name of the CLR static property to write.value - the value to assign.JCType instance, for call chaining.JCNativeException - if the property cannot be found or the write fails.public JCType SetField(String field, Object value) throws JCNativeException
field - the name of the CLR static field to write.value - the value to assign.JCType instance, for call chaining.JCNativeException - if the field cannot be found or the write fails.public Object InvokeOnType(String method, Object... params) throws JCNativeException
Invoke(String, Object...) but with onType = true
to select the type-level overload resolution path.method - the name of the CLR method to invoke on the type.params - optional arguments to pass to the method.JCObject.JCNativeException - if the method cannot be found, the invocation fails,
or a CLR exception is thrown.public Object GetOnType(String propertyName) throws JCNativeException
propertyName - the name of the CLR property to read from the type.JCObject.JCNativeException - if the property cannot be found or the read fails.