Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Snippet] Throwable decorator with system and memory information

Featured Replies

Useful to spot nasty jvm, system and memory-specific issues (outdated java, exotic operating system, incorrect memory allocation, etc...).

I personally only decorate critical / fatal exceptions with this. There's no point in casually wrapping it around everything (unless you really love verbose stack traces).

 

Example:

public class Test {
	public static void main(String[] args) {
		try {
			System.out.println(1/0);
		} catch (Exception e) {
			ThrowableDecorator.withSystemAndMemoryInformation(e).printStackTrace();
		}
	}
} 

Snippet:

public final class ThrowableDecorator {

	private ThrowableDecorator() {
		
	}
	
	public static final Throwable withSystemAndMemoryInformation(Throwable throwable) {
		StringBuilder sb = new StringBuilder();
		//System
		sb.append("\n\tSystem information:");
		System.getProperties().entrySet().forEach(entry -> sb.append("\n\t\t" + entry.getKey().toString() + ": " + entry.getValue().toString()));
		//Memory
		sb.append("\n\tMemory information:");
		sb.append("\n\t\tAvailable processors (cores): " + Runtime.getRuntime().availableProcessors());
		sb.append("\n\t\tFree memory (bytes): " + Runtime.getRuntime().freeMemory());
		sb.append("\n\t\tMaximum memory (bytes): " + Runtime.getRuntime().maxMemory());
		sb.append("\n\t\tTotal memory (bytes): " + Runtime.getRuntime().totalMemory());
		return new Throwable(sb.toString(), throwable);
	}
	
} 

Example trace:

java.lang.Throwable: 
	System information:
		java.runtime.name: Java(TM) SE Runtime Environment
		sun.boot.library.path: C:\Program Files\Java\jre1.8.0_77\bin
		java.vm.version: 25.77-b03
		java.vm.vendor: Oracle Corporation
		java.vendor.url: http://java.oracle.com/
		path.separator: ;
		java.vm.name: Java HotSpot(TM) 64-Bit Server VM
		file.encoding.pkg: sun.io
		user.country: GB
		user.script: 
		sun.java.launcher: SUN_STANDARD
		sun.os.patch.level: 
		java.vm.specification.name: Java Virtual Machine Specification
		user.dir: *****
		java.runtime.version: 1.8.0_77-b03
		java.awt.graphicsenv: sun.awt.Win32GraphicsEnvironment
		java.endorsed.dirs: C:\Program Files\Java\jre1.8.0_77\lib\endorsed
		os.arch: amd64
		java.io.tmpdir: *****
		line.separator: 
		java.vm.specification.vendor: Oracle Corporation
		user.variant: 
		os.name: Windows 10
		sun.jnu.encoding: ******
		java.library.path: *****
		java.specification.name: Java Platform API Specification
		java.class.version: 52.0
		sun.management.compiler: HotSpot 64-Bit Tiered Compilers
		os.version: 10.0
		user.home:*****
		user.timezone: 
		java.awt.printerjob: sun.awt.windows.WPrinterJob
		file.encoding: Cp1252
		java.specification.version: 1.8
		java.class.path: *****
		user.name: bjorn
		java.vm.specification.version: 1.8
		sun.java.command: org.botre.exception.Test
		java.home: C:\Program Files\Java\jre1.8.0_77
		sun.arch.data.model: 64
		user.language: en
		java.specification.vendor: Oracle Corporation
		awt.toolkit: sun.awt.windows.WToolkit
		java.vm.info: mixed mode
		java.version: 1.8.0_77
		java.ext.dirs: *****
		java.vendor: Oracle Corporation
		file.separator: \
		java.vendor.url.bug: http://bugreport.sun.com/bugreport/
		sun.io.unicode.encoding: UnicodeLittle
		sun.cpu.endian: little
		sun.desktop: windows
		sun.cpu.isalist: amd64
	Memory information:
		Available processors (cores): 4
		Free memory (bytes): 253398816
		Maximum memory (bytes): 3795845120
		Total memory (bytes): 257425408
	at org.botre.exception.ThrowableDecorator.withSystemAndMemoryInformation(ThrowableDecorator.java:21)
	at org.botre.exception.Test.main(Test.java:9)
Caused by: java.lang.ArithmeticException: / by zero
	at org.botre.exception.Test.main(Test.java:7)

Edited by Botre

Nice little class, have you ever actually dealt with a weird system that could only be fixed by something like this?

 

 

  • Author

Nice little class, have you ever actually dealt with a weird system that could only be fixed by something like this?

 

Luckily enough I rarely have to rely on this information :D

When it's usefull it tends to be very usefull and often ends up saving quite a lot of time though :p

Luckily enough I rarely have to rely on this information biggrin.png

When it's usefull it tends to be very usefull and often ends up saving quite a lot of time though tongue.png

Makes sense, the only issue I can see is that you need a single try catch to decorate (A main one) or you need the foresight to include this decorator in the offending method! 

 

Ah, the struggles of programming :D

  • Author

Makes sense, the only issue I can see is that you need a single try catch to decorate (A main one) or you need the foresight to include this decorator in the offending method! 

 

Ah, the struggles of programming biggrin.png

 

Indeed x)

You can decorate strategically or just go all-in, I prefer the former approach so I don't get hugely verbose traces every time I forget a simple null check :p

 

I personally use them mostly to decorate IOException and its sub-classes and Swing-related exceptions.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.