(已关闭)Maven在Java 11中不起作用,我应该降级吗?

huangapple go评论86阅读模式
英文:

(Closed) Maven is not work in Java 11 should I downgrade?

问题

我已经尝试了3个小时来解决这个问题,但我不知道问题出在哪里。

供参考,我正在使用Java 11,并且我正在使用java parbolied 1.18。这是我浪费了这么多时间的错误:

在线程 "main" 中的异常 "java.lang.RuntimeException":创建扩展解析器类时出错:null
at org.parboiled.Parboiled.createParser(Parboiled.java:58)
at com.mycompany.myname.Main.main(Main.java:15)
原因是:java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.parboiled.transform.AsmUtils.createClassReader(AsmUtils.java:56)
at org.parboiled.transform.ClassNodeInitializer.process(ClassNodeInitializer.java:62)
at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:44)
at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:39)
at org.parboiled.Parboiled.createParser(Parboiled.java:54)
... 1 more 

这是 pom.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>MyName</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
   <!-- https://mvnrepository.com/artifact/org.parboiled/parboiled-java -->
   <dependency>
       <groupId>org.parboiled</groupId>
       <artifactId>parboiled-java</artifactId>
       <version>1.1.8</version>
    </dependency>
</dependencies>
</project>
英文:

I have been trying to solve this issue for 3 hours and I don't know what the problem is.

For reference I am running Java 11 and I am using java parbolied 1.18. This the error that I have waisted so much time on:

Exception in thread &quot;main&quot; java.lang.RuntimeException: Error creating extended parser class: null
at org.parboiled.Parboiled.createParser(Parboiled.java:58)
at com.mycompany.myname.Main.main(Main.java:15)
Caused by: java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.&lt;init&gt;(Unknown Source)
at org.objectweb.asm.ClassReader.&lt;init&gt;(Unknown Source)
at org.objectweb.asm.ClassReader.&lt;init&gt;(Unknown Source)
at org.parboiled.transform.AsmUtils.createClassReader(AsmUtils.java:56)
at org.parboiled.transform.ClassNodeInitializer.process(ClassNodeInitializer.java:62)
at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:44)
at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:39)
at org.parboiled.Parboiled.createParser(Parboiled.java:54)
... 1 more 

>This is the pom.xml

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema- 
instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven- 
4.0.0.xsd&quot;&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;com.mycompany&lt;/groupId&gt;
&lt;artifactId&gt;MyName&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;packaging&gt;jar&lt;/packaging&gt;
&lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;maven.compiler.source&gt;11&lt;/maven.compiler.source&gt;
    &lt;maven.compiler.target&gt;11&lt;/maven.compiler.target&gt;
&lt;/properties&gt;

&lt;dependencies&gt;
   &lt;!-- https://mvnrepository.com/artifact/org.parboiled/parboiled-java --&gt;
   &lt;dependency&gt;
       &lt;groupId&gt;org.parboiled&lt;/groupId&gt;
       &lt;artifactId&gt;parboiled-java&lt;/artifactId&gt;
       &lt;version&gt;1.1.8&lt;/version&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;/project&gt;

答案1

得分: 3

问题出在使用的库中,导致了异常:

Exception in thread "main" java.lang.RuntimeException: Error creating extended parser class: null
at org.parboiled.Parboiled.createParser(Parboiled.java:58)
at com.mycompany.myname.Main.main(Main.java:15)
Caused by: java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.parboiled.transform.AsmUtils.createClassReader(AsmUtils.java:56)
at org.parboiled.transform.ClassNodeInitializer.process(ClassNodeInitializer.java:62)
at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:44)
at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:39)
at org.parboiled.Parboiled.createParser(Parboiled.java:54)

正好显示它正在使用 asm 访问类文件,这是依赖于 JDK 的,需要在代码中升级/更新以正确地与 JDK 11 一起使用。引用的库 在 JDK 11 下无法正常工作。已经有一些与 JDK 11 相关的问题。

这与 Maven 无关。Maven 可以在最新版本的 JDK 15...16(EA)...等上正常工作。

英文:

The problem is located in the used library cause the exception:

Exception in thread &quot;main&quot; java.lang.RuntimeException: Error creating extended parser class: null
at org.parboiled.Parboiled.createParser(Parboiled.java:58)
at com.mycompany.myname.Main.main(Main.java:15)
Caused by: java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.&lt;init&gt;(Unknown Source)
at org.objectweb.asm.ClassReader.&lt;init&gt;(Unknown Source)
at org.objectweb.asm.ClassReader.&lt;init&gt;(Unknown Source)
at org.parboiled.transform.AsmUtils.createClassReader(AsmUtils.java:56)
at org.parboiled.transform.ClassNodeInitializer.process(ClassNodeInitializer.java:62)
at org.parboiled.transform.ParserTransformer.extendParserClass(ParserTransformer.java:44)
at org.parboiled.transform.ParserTransformer.transformParser(ParserTransformer.java:39)
at org.parboiled.Parboiled.createParser(Parboiled.java:54)

exactly shows that it is using asm access to class files which is JDK dependent which needs to be upgraded/updated in the code to work correctly with JDK 11. The referenced library is not working with JDK 11. Already has several issues related to JDK11.

This has nothing to do with Maven. Maven works up to most recent versions of JDK 15...16(EA)...etc.

huangapple
  • 本文由 发表于 2020年9月8日 13:35:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63787664.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定