gpt4 book ai didi

从 Java 9 开始,javassist.NotFoundException

转载 作者:行者123 更新时间:2023-12-02 02:00:11 25 4
gpt4 key购买 nike

JavaFX不允许WebView透明,所以我发现this patch它使用 javassist 修改 Java 的 com.sun.webkit.WebPage

这在 Java 8 之前工作正常,但在 Java 9 中停止工作:

> Patching com/sun/webkit/WebPage ...
javassist.CannotCompileException: [source error] no such class: com.sun.webkit.graphics.WCRectangle
at javassist.CtBehavior.setBody(CtBehavior.java:446)
at javassist.CtBehavior.setBody(CtBehavior.java:412)
at com.github.micheljung.transparentwebview.TransparentWebViewPatch.transform(TransparentWebViewPatch.java:64)
at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:246)
at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:550)
at java.base/java.lang.ClassLoader.defineClass2(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1099)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:206)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
at javafx.web/javafx.scene.web.WebEngine.<clinit>(WebEngine.java:338)
at javafx.web/javafx.scene.web.WebView.<init>(WebView.java:260)
at com.github.micheljung.transparentwebview.Demo.start(Demo.java:21)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: compile error: no such class: com.sun.webkit.graphics.WCRectangle
at javassist.compiler.MemberResolver.searchImports(MemberResolver.java:468)
at javassist.compiler.MemberResolver.lookupClass(MemberResolver.java:412)
at javassist.compiler.MemberResolver.lookupClassByName(MemberResolver.java:315)
at javassist.compiler.TypeChecker.atNewExpr(TypeChecker.java:146)
at javassist.compiler.ast.NewExpr.accept(NewExpr.java:73)
at javassist.compiler.JvstTypeChecker.atMethodArgs(JvstTypeChecker.java:221)
at javassist.compiler.TypeChecker.atMethodCallCore(TypeChecker.java:735)
at javassist.compiler.TypeChecker.atCallExpr(TypeChecker.java:695)
at javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:157)
at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:242)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:330)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:351)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
at javassist.compiler.CodeGen.atMethodBody(CodeGen.java:292)
at javassist.compiler.Javac.compileBody(Javac.java:223)
at javassist.CtBehavior.setBody(CtBehavior.java:438)
... 25 more
/!\ com/sun/webkit/WebPage patching failed :(
javassist.NotFoundException: com.sun.webkit.graphics.WCRectangle
at javassist.ClassPool.get(ClassPool.java:452)
at com.github.micheljung.transparentwebview.TransparentWebViewPatch.transform(TransparentWebViewPatch.java:84)
at java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:246)
at java.instrument/sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at java.instrument/sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:550)
at java.base/java.lang.ClassLoader.defineClass2(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1099)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:206)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
at javafx.web/javafx.scene.web.WebEngine.<clinit>(WebEngine.java:342)
at javafx.web/javafx.scene.web.WebView.<init>(WebView.java:260)
at com.github.micheljung.transparentwebview.Demo.start(Demo.java:21)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175)
at java.base/java.lang.Thread.run(Thread.java:844)
> Patching com/sun/javafx/webkit/prism/WCGraphicsPrismContext ...
/!\ com/sun/javafx/webkit/prism/WCGraphicsPrismContext patching failed :(

由于我不明白 javassist 如何查找类,所以我迷失了方向。我认为它与 Java 9 模块有关。有人知道吗?该类仍然存在,具有相同的包名称。

Demo Application for Java 8

Demo Application for Java 9

最佳答案

您在两个演示中使用的是过时版本的 javassist:3.20.0-GA。

dependencies {
compile 'org.javassist:javassist:3.20.0-GA'
}

这适用于 Java 8,但不适用于 Java 9。如果您查看他们的 releases GitHub 页面直到版本 3.22.0-GA该库与 Java 9 兼容。但是,该版本也已过时,因为他们的最新版本(截至撰写此答案时)是 3.23.1-GA .

更改您的依赖声明以使用最新版本,您的问题应该得到解决。

dependencies {
compile 'org.javassist:javassist:3.23.1-GA'
}
<小时/>

与您的问题无关:我不知道您使用的是哪个版本的 Gradle,但在更高版本中,compile 配置已弃用;它已被实现取代。请参阅here了解更多信息。

关于从 Java 9 开始,javassist.NotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51696506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com