org.jnetpcap.nio
Class JReference

java.lang.Object
  extended by org.jnetpcap.nio.JMemory
      extended by org.jnetpcap.nio.JStruct
          extended by org.jnetpcap.nio.JReference

public class JReference
extends JStruct

A specialized class that is used for managing JNI global object references. Global JNI references once allocated need to be explicitely deallocated or they will always hold on to the the java object reference preventing the objects of ever going out of scope. This class allows a native structure to create and use global JNI references while JReference class keeps track of the created references for deallocation purposes when the time comes.

This class is internally maintained by JMemory and the user usually does not have to ever deal with it directly. References are maintained automatically. References objects are transfered during the peering and copy process just like JMemory keeper objects. This makes sure that JNI global references are not released too soon but are when the last object using them is GCed. The references array is a native structure, peered with JReference from JNI space.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory
JMemory.Type
 
Field Summary
 
Fields inherited from class org.jnetpcap.nio.JMemory
JNETPCAP_LIBRARY_NAME
 
Constructor Summary
JReference()
          This type of structure is always allocated natively and peered with a java counter part.
 
Method Summary
protected  void cleanup()
          Called to clean up and release any allocated memory.
 int getCapacity()
           
 java.lang.String toDebugString()
          Returns a debug string about this JMemory state.
 
Methods inherited from class org.jnetpcap.nio.JStruct
getStructName, toString
 
Methods inherited from class org.jnetpcap.nio.JMemory
check, finalize, isInitialized, isJMemoryBasedOwner, isOwner, peer, peer, peer, setSize, size, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JReference

public JReference()
This type of structure is always allocated natively and peered with a java counter part.

Method Detail

cleanup

protected void cleanup()
Description copied from class: JMemory
Called to clean up and release any allocated memory. This method should be overriden if the allocated memory is not simply a single memory block and something more complex. This method is safe to call at anytime even if the object does not hold any allocated memory or is not the owner of the memory it is peered with. The method will reset this object to orignal unpeered state releasing any allocated and own memory at the same time if neccessary.

Overrides:
cleanup in class JMemory

toDebugString

public java.lang.String toDebugString()
Description copied from class: JMemory
Returns a debug string about this JMemory state. Example:
 JMemory@b052fa8: size=1506, owner=nio.JMemoryPool$Block.class(size=10240/offset=4064)
 

Overrides:
toDebugString in class JMemory
Returns:
a summary string describing the state of this memory object

getCapacity

public int getCapacity()