This class defines static methods related to the runtime environment. @author Douglas Brown @author Wolfgang Christian @author Robert M. Hanson @version 1.0
| 92 | * @version 1.0 |
| 93 | */ |
| 94 | public class OSPRuntime { |
| 95 | |
| 96 | public static final String VERSION = "6.3.5"; //$NON-NLS-1$ |
| 97 | public static final String RELEASE_DATE = "22 Jun 2026"; //$NON-NLS-1$ |
| 98 | public static final String OSP_PROPERTY_LOCALE = "locale"; |
| 99 | |
| 100 | /** |
| 101 | * An interface with static methods that track implementing classes, adding them |
| 102 | * to array to "allocate" them, and running their dispose() method when |
| 103 | * "deallocation" is requested. |
| 104 | * |
| 105 | * @author hanson |
| 106 | * |
| 107 | */ |
| 108 | public interface Disposable { |
| 109 | |
| 110 | public void dispose(); |
| 111 | |
| 112 | static List<Object> allocated = new ArrayList<>(); |
| 113 | |
| 114 | static void allocate(Disposable obj) { |
| 115 | if (allocated.contains(obj)) |
| 116 | return; |
| 117 | allocated.add(obj); |
| 118 | OSPLog.notify(obj, "allocated"); |
| 119 | } |
| 120 | |
| 121 | static void allocate(Disposable[] objs, String name) { |
| 122 | allocated.add(objs); |
| 123 | OSPLog.notify(name + "[]", "allocated"); |
| 124 | } |
| 125 | |
| 126 | static void deallocate(Disposable[] objs) { |
| 127 | for (Disposable o : (Disposable[]) objs) { |
| 128 | if (o != null) |
| 129 | deallocate(o); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | static void deallocate(Disposable[] objs, int i) { |
| 134 | Disposable o = objs[i]; |
| 135 | if (o != null) { |
| 136 | deallocate(o); |
| 137 | objs[i] = null; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | static void deallocate(Disposable[] objs, BitSet bs) { |
| 142 | for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { |
| 143 | deallocate(objs, i); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | static void deallocate(Disposable obj) { |
| 148 | if (obj == null) |
| 149 | return; |
| 150 | obj.dispose(); |
| 151 | allocated.remove(obj); |
nothing calls this directly
no test coverage detected