什么是GenerateMethodAccessor1、2等?为什么找不到它们?

发布于 2024-07-25 07:08:57 字数 2320 浏览 7 评论 0原文

我收到这样的堆栈跟踪:

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

GenerateMethodAccessor1、GenerateMethodAccessor2、GenerateMethodAccessorN 是什么以及可能导致找不到它们的原因是什么? 我在运行时进行一些字节代码重写,但仅在加载类之前进行,并且通过反射的前几次调用工作正常。 我想知道这是否是在 JIT 编译器获取我的代码之后发生的,但我什至不知道如何开始调试它。

I'm getting stack traces like this:

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

What are GeneratedMethodAccessor1, GeneratedMethodAccessor2, GeneratedMethodAccessorN and what might be causing them to not be found? I am doing some byte code rewriting at run time, but only before the class is loaded, and the first several calls through reflection work fine. I'm wondering if this is happening after the JIT compiler gets a hold of my code, but I don't even have a very good idea of how to start debugging this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗳卜坏 2024-08-01 07:08:57

GenerateMethodAccessor### 是运行时由反射实现生成的类,用于调用方法和构造函数。 这形成了从 MethodConstructor 实例到实际方法或构造函数的字节码桥。 源代码中提供了更多信息。

反序列化也执行类似的操作,共享一些相同的机制,以调用最派生的非Serialized构造函数。

GeneratedMethodAccessor### are classes generated at runtime by the reflection implementation to call methods and constructors. This form a bytecode bridge from instances of Method or Constructor to the actual method or constructor. More information is available in the source code.

Deserialisation also does something similar, sharing some of the same mechanism, to invoke the most derived non-Serializable constructor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文