JuggerNET Runtime Library v3.6.54.0
3.6.54.0
|
The baseclass for all non-exception types that are proxy types for Java types. More...
Public Member Functions | |
JuggerNETProxyObject (string str) | |
Initializes a proxy object that corresponds with a Java java.lang.String instance of the specified value. More... | |
JuggerNETProxyObject (JNIHandle jobject) | |
Initializes a proxy object that corresponds with a preexisting Java object represented by the given object handle. More... | |
void | Dispose () |
Releases the reference to the corresponding Java object, thereby making it eligible for garbage collection if no other references to the same object are held. More... | |
void | Release () |
Forgets the reference to the corresponding Java object. Unless caller explicitly cleans up Java reference, this will cause the runtime to leak a Java object reference. More... | |
override bool | Equals (object obj) |
Implemented in terms of the Java equals() method. If the other object is not also a subclass of a JavaObject, the return value is always false. This is to ensure that the the results of a comparison is independent of the order, i.e. More... | |
override int | GetHashCode () |
Implemented in terms of the Java hashCode() method. More... | |
override string | ToString () |
Implemented in terms of the Java toString() method. More... | |
bool | IsInstanceOf (JavaClass clazz) |
Returns true if the instance is type compatible with the given Java type. More... | |
bool | IsSame (JavaProxy proxy) |
Returns true if the proxy instance wraps around the same Java object as the other proxy instance. More... | |
Protected Member Functions | |
JuggerNETProxyObject () | |
Initializes a proxy object that corresponds with a Java null reference. More... | |
Properties | |
long | JObject [get, set] |
A property giving access to the JNI object handle that represents the wrapped Java instance. More... | |
long | JObjectDuplicate [get] |
A property representing a duplicated JNI object handle. More... | |
HandleRef | Handle [get] |
Properties inherited from Codemesh.JuggerNET.JavaProxy | |
long | JObject [get, set] |
A property representing the JNI object handle. More... | |
HandleRef | Handle [get] |
A property representing the JNI object handle. More... | |
long | JObjectDuplicate [get] |
A property representing a duplicated JNI object handle. More... | |
The baseclass for all non-exception types that are proxy types for Java types.
All proxy objects implement the JavaProxy
interface and are IDisposable
. The fact that a proxy object is an IDisposable
means that you can use instances derived of this type with the using
directive.
By default, if you do nothing special, you will have to wait for the .NET garbage collector to run and call the Dispose()
method as part of its cleanup process. This delay can cause you trouble under certain circumstances. It means that the .NET side might not call the Dispose()
method for a long time because there are not many .NET objects that need to be collected.
On the Java side the picture may look quite different: the few .NET objects that are waiting to be collected might be hanging on to a lot of Java objects and your application might actually run out of Java heap space before the .NET garbage collector sees any reason to run.
This is not too common a scenario, but even without this scenario there are some possible negative consequences. As the Java objects are held on to longer than normal, they might migrate from an easily and efficiently collectable part of the heap into more expensive to collect areas of the heap. This can impact your application's performance.
You can prevent these problems by using a pattern such as this:
This pattern causes the .NET runtime to automatically call the Dispose()
method when the scope of the using
clause is exited. The Dispose()
method takes care of freeing the Java reference so that the corresponding Java object will be eligible for garbage collection right away.
|
inlineprotected |
Initializes a proxy object that corresponds with a Java null
reference.
|
inline |
Initializes a proxy object that corresponds with a Java java.lang.String
instance of the specified value.
str | the string value. |
References Codemesh.JuggerNET.JvmLoader.GetJvmLoader(), Codemesh.JuggerNET.IJvmLoader.JvmIfCreated, Codemesh.JuggerNET.JvmLoader.JvmLoaderIfCreated, and Codemesh.JuggerNET.IJvmLoader.Load().
|
inline |
Initializes a proxy object that corresponds with a preexisting Java object represented by the given object handle.
jobject | the object handle representing the already existing Java object. |
|
inline |
Releases the reference to the corresponding Java object, thereby making it eligible for garbage collection if no other references to the same object are held.
|
inline |
Implemented in terms of the Java equals()
method. If the other object is not also a subclass of a JavaObject, the return value is always false. This is to ensure that the the results of a comparison is independent of the order, i.e.
a.Equals( b ) == b.Equals( a )
which could not be guaranteed if we did special things for obj being of some special .NET type.
obj | the object we're comparing for equality. |
References Codemesh.JuggerNET.JavaMethod.CallBool().
|
inline |
Implemented in terms of the Java hashCode()
method.
References Codemesh.JuggerNET.JavaMethod.CallInt().
|
inline |
Returns true if the instance is type compatible with the given Java type.
clazz | the Java type. |
Implements Codemesh.JuggerNET.JavaProxy.
References Codemesh.JuggerNET.JuggerNETProxyObject.JObject.
|
inline |
Returns true if the proxy instance wraps around the same Java object as the other proxy instance.
proxy | The other proxy instance. |
Implements Codemesh.JuggerNET.JavaProxy.
|
inline |
Forgets the reference to the corresponding Java object. Unless caller explicitly cleans up Java reference, this will cause the runtime to leak a Java object reference.
Implements Codemesh.JuggerNET.JavaProxy.
|
inline |
Implemented in terms of the Java toString()
method.
References Codemesh.JuggerNET.JavaMethod.CallString().
|
getset |
A property giving access to the JNI object handle that represents the wrapped Java instance.
Referenced by Codemesh.JuggerNET.JuggerNETProxyObject.IsInstanceOf().
|
get |
A property representing a duplicated JNI object handle.
Accessing this property essentially duplicates the Java object handle. The returned handle needs to be released before the represented Java object can become eligible for garbage collection.