2009-06-21 135 views
8

我得到的堆棧跟蹤是這樣的:什麼是GeneratedMethodAccessor1,2等,爲什麼他們不能找到?

java.lang.NoClassDefFoundError: sun/reflect/GeneratedMethodAccessor1 
    at sun.reflect.GeneratedMethodAccessor1.<clinit>(Unknown Source) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
    at java.lang.Class.newInstance0(Class.java:355) 
    at java.lang.Class.newInstance(Class.java:308) 
    at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377) 
    at sun.reflect.MethodAccessorGenerator.generateMethod(MethodAccessorGenerator.java:59) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:28) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at edu.tufts.cs.testsim.LogicalProcess.dispatchMessage(LogicalProcess.java:214) 
    at edu.tufts.cs.testsim.LogicalProcess.processForward(LogicalProcess.java:287) 
    at edu.tufts.cs.testsim.LogicalProcess.doOperation(LogicalProcess.java:423) 
    at edu.tufts.cs.testsim.LogicalProcess.run(LogicalProcess.java:434) 
    at java.lang.Thread.run(Thread.java:637) 
Caused by: java.lang.ClassNotFoundException: sun.reflect.GeneratedMethodAccessor1 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:316) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:288) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251) 
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) 
    ... 19 more 

什麼GeneratedMethodAccessor1,GeneratedMethodAccessor2,GeneratedMethodAccessorN和什麼可能導致他們不會被發現?我在運行時正在做一些字節碼重寫,但只在類被加載之前,通過反射的前幾個調用工作正常。我想知道是否在JIT編譯器獲得我的代碼之後發生這種情況,但我甚至沒有很好的關於如何開始調試的想法。

回答

7

GeneratedMethodAccessor###是由反射實現在運行時生成的用於調用方法和構造函數的類。這形成了從實例MethodConstructor到實際方法或構造函數的字節碼橋。源代碼中提供了更多信息。

反序列化也會做類似的事情,共享某些相同的機制,以調用最衍生的非構造函數。

相關問題