gpt4 book ai didi

java - OpenJDK 11 java.lang.ClassCastException : class sun. font.CompositeFont 无法转换为类 sun.font.PhysicalFont

转载 作者:行者123 更新时间:2023-12-02 07:40:43 30 4
gpt4 key购买 nike

我在 Linux 上使用 openJDK 11 运行 junit 测试并收到以下错误:

java.lang.ClassCastException: class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap')
at java.desktop/sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1086)
at java.desktop/sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:965)
at java.desktop/sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:903)
at java.desktop/sun.font.SunFontManager.findDeferredFont(SunFontManager.java:919)
at java.desktop/sun.font.SunFontManager.findFont2D(SunFontManager.java:2120)
at java.desktop/java.awt.Font.getFont2D(Font.java:506)
at java.desktop/java.awt.Font.canDisplayUpTo(Font.java:2246)
at java.desktop/java.awt.font.TextLayout.singleFont(TextLayout.java:469)
at java.desktop/java.awt.font.TextLayout.<init>(TextLayout.java:530)
at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:275)
at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117)
at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:82)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:658)
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:679)
at com.textb2.ui.controller.ExcelCreator.newSheet(ExcelCreator.java:135)
at com.textb2.ui.controller.ExcelCreator.buildExcel(ExcelCreator.java:182)
at com.textb2.ui.controller.ExcelCreatorTest.testNoData(ExcelCreatorTest.java:91)
at com.textb2.ui.controller.ExcelCreatorTest.testGermany(ExcelCreatorTest.java:53)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

不确定,但一定与/usr/share/fonts 中的字体有关。目前我那里没有字体。我知道openJdk11不再包含字体了。但我不知道该怎么办。

谢谢...

刚刚在旧版本中发现了一个错误,该错误已经修复: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8144703

最佳答案

OpenJDK 11 似乎不再包含一些与字体相关的内容,并且您的操作系统当前本身不提供任何内容。

您可以尝试在操作系统中安装一些与字体相关的软件包,看看能否解决问题。

另请参阅发行说明:https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html#JDK-8191522

关于java - OpenJDK 11 java.lang.ClassCastException : class sun. font.CompositeFont 无法转换为类 sun.font.PhysicalFont,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54554625/

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