This obtains the value of a system property (if one is set) and returns its value. System properties are declared by the system and are used by applications to potentially modify their behavior. {@squirreljme.property java.io.tmpdir This is the temporary directory which indicates where temporary fi
(String __k)
| 257 | * @since 2016/05/21 |
| 258 | */ |
| 259 | public static String getProperty(String __k) |
| 260 | throws IllegalArgumentException, NullPointerException, |
| 261 | SecurityException |
| 262 | { |
| 263 | // Check |
| 264 | if (__k == null) |
| 265 | throw new NullPointerException("NARG"); |
| 266 | |
| 267 | // {@squirreljme.error ZZ1b Cannot request a system property which has |
| 268 | // a blank key.} |
| 269 | if (__k.equals("")) |
| 270 | throw new IllegalArgumentException("ZZ1b"); |
| 271 | |
| 272 | // Short circuit for run-time detection |
| 273 | if (__k.equals("cc.squirreljme.isruntime")) |
| 274 | return "true"; |
| 275 | |
| 276 | // Not allowed to do this? |
| 277 | getSecurityManager().checkPropertyAccess(__k); |
| 278 | |
| 279 | // Depends on the property |
| 280 | switch (__k) |
| 281 | { |
| 282 | // API level of SquirrelJME |
| 283 | case "cc.squirreljme.apilevel": |
| 284 | return ApiLevel.levelToString(ApiLevel.CURRENT_LEVEL); |
| 285 | |
| 286 | // SquirrelJME guest depth |
| 287 | case "cc.squirreljme.guests": |
| 288 | return Integer.toString(SystemProperties.guestDepth()); |
| 289 | |
| 290 | // SquirrelJME VM executable path |
| 291 | case "cc.squirreljme.vm.execpath": |
| 292 | return SystemProperties.executablePath(); |
| 293 | |
| 294 | // SquirrelJME free memory |
| 295 | case "cc.squirreljme.vm.freemem": |
| 296 | return Long.toString(Runtime.getRuntime().freeMemory()); |
| 297 | |
| 298 | // SquirrelJME total memory |
| 299 | case "cc.squirreljme.vm.totalmem": |
| 300 | return Long.toString(Runtime.getRuntime().totalMemory()); |
| 301 | |
| 302 | // SquirrelJME free memory |
| 303 | case "cc.squirreljme.vm.maxmem": |
| 304 | return Long.toString(Runtime.getRuntime().maxMemory()); |
| 305 | |
| 306 | // The version of the Java virtual machine (fixed value) |
| 307 | case "java.version": |
| 308 | return "1.8.0"; |
| 309 | |
| 310 | // The version of the JVM (full) |
| 311 | case "java.vm.version": |
| 312 | return SystemProperties.javaVMVersion(); |
| 313 | |
| 314 | // The name of the JVM |
| 315 | case "java.vm.name": |
| 316 | return SystemProperties.javaVMName(); |