Skip to content

Instantly share code, notes, and snippets.

View kisimple's full-sized avatar

boshu Zheng kisimple

  • Hangzhou
View GitHub Profile
@rednaxelafx
rednaxelafx / DumpClassURL.java
Created December 7, 2011 09:48
Using the ProtectionDomain of an InstanceKlass to see where it was loaded from, with Attach API this time
import java.lang.instrument.Instrumentation;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.util.Arrays;
import java.util.Comparator;
public class DumpClassURL {
public static void agentmain(String agentArgs, Instrumentation inst) {
Class<?>[] classes = inst.getAllLoadedClasses();
@rednaxelafx
rednaxelafx / DumpClassURL.java
Created December 7, 2011 05:48
Using the ProtectionDomain of an InstanceKlass to see where it was loaded from
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
public class DumpClassURL extends Tool {
public void run() {