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

通过agent方式做字节码增强引起ClassLoader.loadClass加载Narhon引擎时报错Nest-host class_info_index 21 has bad constant type #388

Closed
howardliu-cn opened this issue Jun 15, 2022 · 5 comments

Comments

@howardliu-cn
Copy link

howardliu-cn commented Jun 15, 2022

启动参数:-javaagent:transmittable-thread-local-2.12.1.jar

运行时报错:Caused by: java.lang.ClassFormatError: Nest-host class_info_index 21 has bad constant type in class file jdk/nashorn/internal/codegen/OptimisticTypesPersistence$5

代码:

ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
Object result = engine.eval(formula);

异常栈:

Caused by: java.lang.ClassFormatError: Nest-host class_info_index 21 has bad constant type in class file jdk/nashorn/internal/codegen/OptimisticTypesPersistence$5
    at java.base/java.lang.ClassLoader.defineClass2(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1109)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:206)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:759)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:680)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:605)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.getCompiler(RecompilableScriptFunctionData.java:669)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.getCompiler(RecompilableScriptFunctionData.java:650)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.compileTypeSpecialization(RecompilableScriptFunctionData.java:726)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.getBest(RecompilableScriptFunctionData.java:907)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.getGeneric(ScriptFunctionData.java:402)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.createGenericInvoker(ScriptFunctionData.java:297)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.getGenericInvoker(ScriptFunctionData.java:291)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:638)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
    at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527)
    at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:456)
    at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:413)
    at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:409)
    at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:162)
    at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)

删除这个agent就能够表现正常。

@oldratlee
Copy link
Member

oldratlee commented Jun 16, 2022

搜索了一下,应该要升级javassist

@howardliu-cn 可以改一下TTLPOM

  • 升级java到 8
  • 升级javassist到最新版本

打个TTL包试一下能不能解决问题。

如果 OK,我发布个TTL新版本出来。

@oldratlee oldratlee self-assigned this Jun 16, 2022
@oldratlee oldratlee added the ❓question Further information is requested label Jun 16, 2022
@oldratlee
Copy link
Member

oldratlee commented Jun 16, 2022

@howardliu-cn 发布了v2.13.0,升级试一下;看看问题解决没有? ❤️

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>transmittable-thread-local</artifactId>
    <version>2.13.0</version>
</dependency>

Release Note:
https://github.com/alibaba/transmittable-thread-local/releases/tag/v2.13.0

@oldratlee
Copy link
Member

oldratlee commented Jun 23, 2022

@howardliu-cn 先 close 了。如有问题可以继续讨论 ❤️

@howardliu-cn
Copy link
Author

多谢,线下环境已验证可行,今晚线上环境验证一下。

@howardliu-cn
Copy link
Author

已在线上验证,可行

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

No branches or pull requests

2 participants