Skip to content

Instantly share code, notes, and snippets.

View rednaxelafx's full-sized avatar

Kris Mok rednaxelafx

View GitHub Profile
@rednaxelafx
rednaxelafx / JDK 6 update 23, client, Windows x86
Created February 15, 2011 05:43
The VM flags as set by HotSpot's ergonomics by default (-XX:+PrintFlagsFinal). See http://hg.openjdk.java.net/jdk6/jdk6/hotspot/file/tip/src/share/vm/runtime/globals.hpp
[Global flags]
uintx AdaptivePermSizeWeight = 20 {product}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product}
uintx AdaptiveSizePausePolicy = 0 {product}
uintx AdaptiveSizePolicyCollectionCostMargin = 50 {product}
uintx AdaptiveSizePolicyInitializingSteps = 20 {product}
uintx AdaptiveSizePolicyOutputInterval = 0 {product}
uintx AdaptiveSizePolicyWeight = 10 {product}
uintx AdaptiveSizeThroughPutPolicy = 0 {product}
@rednaxelafx
rednaxelafx / PrintThreadIds.java
Created February 25, 2011 10:31
find out the correspondence between the tid/nid of Java threads as shown from jstack/JMX, on HotSpot/Linux
package fx.jvm.hotspot.tools;
import java.util.List;
import sun.jvm.hotspot.tools.Tool;
public class PrintThreadIds extends Tool {
public static void main(String[] args) {
PrintThreadIds tool = new PrintThreadIds();
tool.start(args);
@rednaxelafx
rednaxelafx / F.java
Created March 7, 2011 02:28
show how the same Class file loaded by two classloaders become "incompatible"
import java.io.*;
import java.net.*;
public class F {
static F instance;
public static void main(String[] args) throws Exception {
ClassLoader l = new URLClassLoader(new URL[] { new File(".").toURI().toURL()}, null);
Class<?> clazz = l.loadClass("F");
F.class.getDeclaredField("instance").set(null, clazz.newInstance());
@rednaxelafx
rednaxelafx / TestStackOpsMain.java
Created March 26, 2011 08:03
Hack HotSpot's interpreter with return stack shellcode. Requires JRuby and BiteScript to build, works on WinXP 32-bit only. If run under a SecurityManager then it'll be caught and a security exception will be thrown before it wrecks havoc; it's configured
public class TestStackOpsMain {
public static void main(String[] args) {
// refer to earlier blog post, http://rednaxelafx.javaeye.com/blog/461787
byte[] code = {
// CODE SECTION
// push ebp
0x55,
// mov ebp,esp
(byte) 0x8B, (byte) 0xEC,
// push -0B ; /DevType = STD_OUTPUT_HANDLE
@rednaxelafx
rednaxelafx / demo.groovy
Created April 6, 2011 08:51
get properties from an object in Groovy, even when the object has an getProperties() method
def getPropertiesFrom(obj) {
obj.metaClass.properties.findAll { it.name != 'class' && it.name != 'metaClass' }.inject([:]) { acc, e -> acc[e.name] = e.getProperty(obj); acc }
}
class Foo {
int getBar() { 42; }
List getProperties() { [] }
}
def foo = new Foo();
foo.properties; //=> []
@rednaxelafx
rednaxelafx / jdk6u24_x86_server_Xint_interpreter.txt
Created April 18, 2011 06:33
difference in the generated interpreter between "-server -Xint" and "-client -Xint" HotSpot VMs (JDK6u24)
----------------------------------------------------------------------
Interpreter
code size = 65K bytes
total space = 167K bytes
wasted space = 102K bytes
# of codelets = 258
avg codelet size = 258 bytes
@rednaxelafx
rednaxelafx / jdk6u24_x86_client_Xint_interpreter.txt
Created April 18, 2011 06:37
difference in the generated interpreter between "-server -Xint" and "-client -Xint" HotSpot VMs (JDK6u24)
----------------------------------------------------------------------
Interpreter
code size = 56K bytes
total space = 167K bytes
wasted space = 111K bytes
# of codelets = 258
avg codelet size = 224 bytes
@rednaxelafx
rednaxelafx / jdk6u24_x86_client_Xint_flags.txt
Created April 18, 2011 06:39
difference in the ergonomics between "-server -Xint" and "-client -Xint" HotSpot VMs (JDK6u24)
[Global flags]
uintx AdaptivePermSizeWeight = 20 {product}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product}
uintx AdaptiveSizePausePolicy = 0 {product}
uintx AdaptiveSizePolicyCollectionCostMargin = 50 {product}
uintx AdaptiveSizePolicyInitializingSteps = 20 {product}
uintx AdaptiveSizePolicyOutputInterval = 0 {product}
uintx AdaptiveSizePolicyWeight = 10 {product}
uintx AdaptiveSizeThroughPutPolicy = 0 {product}
@rednaxelafx
rednaxelafx / gist:925044
Created April 18, 2011 09:11
example: make a NoClassDefFoundError without a class name in the message
[sajia@sajia ~]$ java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
@rednaxelafx
rednaxelafx / gist:925323
Last active October 25, 2023 05:30
Correspondence between Sun/Oracle JDK, OpenJDK and HotSpot VM versions

Correspondence between Sun/Oracle JDK, OpenJDK and HotSpot VM versions

build date Sun/Oracle JDK Version OpenJDK Version HotSpot VM Version
2006-11-29 1.6.0-b105 1.6.0-b105
2007-03-14 1.6.0_01-b06 1.6.0_01-b06
2007-06-22 1.6.0_02-b05 1.6.0_02-b05
2007-09-24 1.6.0_03-b05 1.6.0_03-b05
2007-12-14 1.6.0_04-b12 10.0-b19