Disposer.java revision 0
/*
* Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* This class is used for registering and disposing the native
* data associated with java objects.
*
* The object can register itself by calling one of the addRecord
* methods and providing either the pointer to the native disposal
* method or a descendant of the DisposerRecord class with overridden
* dispose() method.
*
* When the object becomes unreachable, the dispose() method
* of the associated DisposerRecord object will be called.
*
* @see DisposerRecord
*/
private static Disposer disposerInstance;
public static final int WEAK = 0;
public static final int PHANTOM = 1;
static {
initIDs();
} else {
}
}
disposerInstance = new Disposer();
/* The thread must be a member of a thread group
* which will not get GCed before VM exit.
* Make its parent the top-level thread group.
*/
Thread t =
t.setDaemon(true);
t.start();
return null;
}
}
);
}
/**
* Registers the object and the native data for later disposal.
* @param target Object to be registered
* @param disposeMethod pointer to the native disposal method
* @param pData pointer to the data to be passed to the
* native disposal method
*/
long disposeMethod, long pData)
{
}
/**
* Registers the object and the native data for later disposal.
* @param target Object to be registered
* @param rec the associated DisposerRecord object
* @see DisposerRecord
*/
}
/**
* Performs the actual registration of the target object to be disposed.
* @param target Object to be registered, or if target is an instance
* of DisposerTarget, its associated disposer referent
* will be the Object that is registered
* @param rec the associated DisposerRecord object
* @see DisposerRecord
*/
if (target instanceof DisposerTarget) {
}
} else {
}
}
public void run() {
while (true) {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
}
private static native void initIDs();
/*
* This was added for use by the 2D font implementation to avoid creation
* of an additional disposer thread.
* WARNING: this thread class monitors a specific queue, so a reference
* added here must have been created with this queue. Failure to do
* so will clutter the records hashmap and no one will be cleaning up
* the reference queue.
*/
}
}
/* This is intended for use in conjunction with addReference(..)
*/
public static ReferenceQueue getQueue() {
return queue;
}
}