Important Note
This class is intended to be subclassed only within the SWT implementation. However, it has not been marked final to allow those outside of the SWT development team to implement patched versions of the class in order to get around specific limitations in advance of when those limitations can be addressed by the team. Any class built using subclassing to access the internals of this class will likely fail to compile or run between releases and may be strongly platform specific. Subclassing should not be attempted without an intimate and detailed understanding of the workings of the hierarchy. No support is provided for user-written classes which are implemented as subclasses of this class.
dispose, isDisposed, Sample code and further information
| Modifier and Type | Class and Description |
|---|---|
| private static class | Resource.
Used to track not disposed SWT resource. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Device | device
the device where this resource was created |
| private static Consumer | nonDisposedReporter
Used to report not disposed SWT resources, null by default |
| private Resource. | tracker
Used to track not disposed SWT resource |
| Access | Constructor and Description |
|---|---|
| public | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public void | |
| public Device | Returns: Device the device of the receiverReturns the |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | |
| public abstract boolean | Returns: true when the resource is disposed and false otherwiseReturns |
| public static void | setNonDisposeHandler(Consumer<Error>
object used to report detected errors. Use
null to disable tracking. Setting a new
reporter has an immediate effect. reporter)Enables detection of Resource objects for which |
| device | back to summary |
|---|---|
| pack-priv Device device the device where this resource was created | |
| nonDisposedReporter | back to summary |
|---|---|
| private static Consumer<Error> nonDisposedReporter Used to report not disposed SWT resources, null by default | |
| tracker | back to summary |
|---|---|
| private Resource. Used to track not disposed SWT resource | |
| Resource | back to summary |
|---|---|
| public Resource() | |
| Resource | back to summary |
|---|---|
| pack-priv Resource(Device device) | |
| destroy | back to summary |
|---|---|
| pack-priv void destroy() | |
| dispose | back to summary |
|---|---|
| public void dispose() Disposes of the operating system resources associated with this resource. Applications must dispose of all resources which they allocate. This method does nothing if the resource is already disposed. | |
| getDevice | back to summary |
|---|---|
| public Device getDevice() Returns the
| |
| ignoreNonDisposed | back to summary |
|---|---|
| pack-priv void ignoreNonDisposed() | |
| init | back to summary |
|---|---|
| pack-priv void init() | |
| initNonDisposeTracking | back to summary |
|---|---|
| pack-priv void initNonDisposeTracking() | |
| isDisposed | back to summary |
|---|---|
| public abstract boolean isDisposed() Returns
This method gets the dispose state for the resource.
When a resource has been disposed, it is an error to
invoke any other method (except
| |
| setNonDisposeHandler | back to summary |
|---|---|
| public static void setNonDisposeHandler(Consumer<Error> reporter) Enables detection of Resource objects for which Warning the reporter will be called from a different thread. Do not block it and do not throw any exceptions. It's best to queue the errors for some other worker to process. | |
finalize when tracking is disabled, avoiding
possible performance issues in GC.
| Modifier and Type | Field and Description |
|---|---|
| private Error | allocationStack
Recorded at Resource creation if |
| pack-priv boolean | ignoreMe
Allows to ignore specific Resources even if they are not disposed properly, used for example for Fonts that SWT doesn't own. |
| private Resource | resource
Resource that is tracked here |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | finalize()
Overrides java. |
| allocationStack | back to summary |
|---|---|
| private Error allocationStack Recorded at Resource creation if | |
| ignoreMe | back to summary |
|---|---|
| pack-priv boolean ignoreMe Allows to ignore specific Resources even if they are not disposed properly, used for example for Fonts that SWT doesn't own. | |
| resource | back to summary |
|---|---|
| private Resource resource Resource that is tracked here | |
| ResourceTracker | back to summary |
|---|---|
| pack-priv ResourceTracker(Resource resource, Error allocationStack) | |
| finalize | back to summary |
|---|---|
| protected void finalize() Overrides java. Doc from java. Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the
When running in a Java virtual machine in which finalization has been
disabled or removed, the garbage collector will never call
The general contract of
The
The Java programming language does not guarantee which thread will
invoke the
After the
The
Any exception thrown by the
| |