Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support jdk runtime generated class? #42

Open
hengyunabc opened this issue Jun 26, 2018 · 0 comments
Open

Support jdk runtime generated class? #42

hengyunabc opened this issue Jun 26, 2018 · 0 comments

Comments

@hengyunabc
Copy link

Test code:

public class Test {

	public static void main(String[] args) throws Throwable {
		for(int i = 0; i < 15; ++ i) {
			newConstructor(Test.class);
		}

		// add breakpoint on java.lang.ClassLoader#loadClass(String), then continue
		System.in.read();

		newConstructor(Test.class); 
	}

	static Object newConstructor(Class<?> clazz) throws Throwable {
		return clazz.getConstructor().newInstance();
	}
}
  1. Debug application
  2. Add breakpoint on java.lang.ClassLoader#loadClass(String)
  3. Press any key to continue
Thread [main] (Suspended (breakpoint at line 357 in ClassLoader))	
	Launcher$AppClassLoader(ClassLoader).loadClass(String) line: 357	
	Unsafe.defineClass(String, byte[], int, int, ClassLoader, ProtectionDomain) line: not available [native method]	
	ClassDefiner.defineClass(String, byte[], int, int, ClassLoader) line: 63	
	MethodAccessorGenerator$1.run() line: 399	
	MethodAccessorGenerator$1.run() line: 394	
	AccessController.doPrivileged(PrivilegedAction<T>) line: not available [native method]	
	MethodAccessorGenerator.generate(Class<?>, String, Class<?>[], Class<?>, Class<?>[], int, boolean, boolean, Class<?>) line: 393	
	MethodAccessorGenerator.generateConstructor(Class<?>, Class<?>[], Class<?>[], int) line: 92	
	NativeConstructorAccessorImpl.newInstance(Object[]) line: 55	
	DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 45	
	Constructor<T>.newInstance(Object...) line: 423	
	Test.newConstructor(Class<?>) line: 16	
	Test.main(String[]) line: 12	

ecd can not decompile MethodAccessorGenerator$1:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant