运行时面临Jacobo方法过大错误



面对方法太大对于drools库中的方法,来自jacoco的错误,如何解决?我还尝试在jacoco中的exlucdes中添加**DRL6Lexer.class,但没有成功。否则我该如何解决这个问题。

错误:

java.lang.instrument.IollegalClassFormatException:错误仪器org/drools/compiler/lang/DRL6LLexer。在org.jacoco.agent.rt.internal_f3994fa.CoverageTransformer.transform(CoverageTransformer.java:94)在java.instrument/java.lang.instrument.ClassFileTransformer.transform(ClassFileTransformer.java:246)在java.instrument/sun.instrument.TransferManager.transform(TransformerManager.java:188)在java.instrument/sun.instrument.InstrumentImpl.transform(InstrumentationImpl.java:563)位于java.base/java.lang.ClassLoader.defineClass1(本机方法)java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)在java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)在java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)在java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)在java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)在java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)位于java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)在org.drowls.compiler.compiler.DRLFactory.getDRLLexer(DRLFactor.java:112)在org.drowls.compiler.compiler.DRLFactory.buildLexer(DRLFactor.java:59)网址:org.drolls.compiler.compiler.DrlParser.parse(DrlParser.java:163)网址:org.drolls.compiler.compiler.DrlParser.parse(DrlParser.java:154)网址:org.drolls.compiler.compiler.DrlParser.parse(DrlParser.java:144)在DroolsParser.parseDrl(DroolsParser.java:36)DroolsParserTest.generateRules_success(DroolsParserTest.java:39)位于java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native方法)java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)位于java.base/java.lang.reflect.Method.ioke(Method.java:566)org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)在org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)在org.junit.runners.model.FrameworkMethod.invokeExploly(FrameworkMethod.java:56)在org.junit.internal.runners.statements.InvokeMethod.eevaluate(InvokeMethod.java:17)在org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)网址:org.junit.runners.ParentRunner$3.eevaluate(ParentRunner.java:306)在org.junit.runners.BlockJUnit4ClassRunner$1.eevaluate(BlockJUnit4ClassRunner.java:100)网址:org.junit.runners.ParentRunner.runLeaf(ParentRunner:java:366)org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)网址:org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)org.junit.runners.ParentRunner$2.eevaluate(ParentRunner.java:293)org.junit.runners.ParentRunner$3.评估(ParentRunner.java:306)org.junit.runners.ParentRunner.run(ParentRunner:413)org.junit.runner.JUnitCore.run(JUnitCores.java:137)org.junit.runner.JUnitCore.run(JUnitCores.java:115)org.junit.venty.engine.exexecution.RunnerExecution.execute(RunnerExecutior.java:40)在java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOperation.java:183)在java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePiperine.java:195)位于java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)在java.base/java.util.Splitterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)在java.base/java.util.stream.AbstractPipeline.copyTinto(AbstractPipeline.java:484)在java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)在java.base/java.util.stream.ForEachOps$ForEachOp.evalateSequential(ForEachOperation.java:150)在java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evalateSequential(ForEachOperation.java:173)在java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)在java.base/java.util.stream.ReferencePipeline.forEach(ReferencePiperine.java:497)在org.junit.venture.engine.VentageTestEngine.executeAllChildren(VintageTestEngine.java:80)在org.junit.ventive.engine.VentageTestEngine.execute(VintageTestEngine.java:71)在org.junit.platform.selauncher.core.DefaultLauncher.execute(DefaultLauncher.java:170)在org.junit.platform.selauncher.core.DefaultLauncher.execute(DefaultLauncher.java:154)在org.junit.platform.selauncher.core.DefaultLauncher.execute(DefaultLauncher.java:90)在org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150)在org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.ioke(JUnitPlatformProvider.java:124)在org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBuilder.java:384)在org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBBooter.java:345)在org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBouter.java:126)在org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBouter.java:418)引起原因:java.io.IOException:检测org/drools/compiler/lang/DRL6LLexer时出错。网址:org.jacoco.agent.rt.internal_f3994fa.core.instr.Instrumenter.instrumentError(Instrumenter.java:160)网址:org.jacoco.agent.rt.internal_f3994fa.core.instr.Instrumenter.instrument(Instrumenter.java:110)网址:org.jacoco.agent.rt.internal_f3994fa.CoverageTransformer.transform(CoverageTransformer.java:92)…还有64个由:org.jacoco.agent.rt.internal_f3994fa.asm.MethodTooLargeException引起:方法太大:org/drools/compiler/lang/DRL6Lexer.mID()V网址:org.jacoco.agent.rt.internal_f3994fa.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2087)网址:org.jacoco.agent.rt.internal_f3994fa.asm.ClassWriter.toByteArray(ClassWriter.java:496)网址:org.jacoco.agent.rt.internal_f3994fa.core.instr.Instrumenter.instrument(Instrumenter.java:91)网址:org.jacoco.agent.rt.internal_f3994fa.core.instr.Instrumenter.instrument(Instrumenter.java:108)…还有65个

pom.xml

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<compilerArgs>
<compilerArg>-Amapstruct.defaultComponentModel=spring</compilerArg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<dependencies>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<outputDirectory>
${project.parent.basedir}/target/site/jacoco/${project.artifactId}
</outputDirectory>
</configuration>
</execution>
<execution>
<id>default-report-integration</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.percentage.line}</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.percentage.branch}</minimum>
</limit>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>${jacoco.percentage.complexity}</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

使用Jacobo任务扩展(Jacoco为每个任务注入的扩展,类型为Test),可以排除有问题的DRL6Lexer类。

对我来说,这很有效。

test {
jacoco{
excludes = ['org/drools/**/*']
}
useJUnitPlatform()
finalizedBy jacocoTestReport
}

相关内容

  • 没有找到相关文章

最新更新