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

Method too large: com/gargoylesoftware/css/parser/javacc/CSS3ParserTokenManager #4

Closed
sepe81 opened this issue Jan 22, 2020 · 8 comments

Comments

@sepe81
Copy link

sepe81 commented Jan 22, 2020

If you are using https://www.eclemma.org/jacoco/ for code analysis and the project under test uses htmlunit-cssparser then you get the following output during analysis.

[...]
Caused by: java.io.IOException: Error while instrumenting com/gargoylesoftware/css/parser/javacc/CSS3ParserTokenManager.
	at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrumentError(Instrumenter.java:159)
	at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:109)
	at org.jacoco.agent.rt.internal_43f5073.CoverageTransformer.transform(CoverageTransformer.java:92)
	... 106 more
Caused by: org.jacoco.agent.rt.internal_43f5073.asm.MethodTooLargeException: Method too large: com/gargoylesoftware/css/parser/javacc/CSS3ParserTokenManager.jjMoveNfa_0 (II)I
	at org.jacoco.agent.rt.internal_43f5073.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2087)
	at org.jacoco.agent.rt.internal_43f5073.asm.ClassWriter.toByteArray(ClassWriter.java:447)
	at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:90)
	at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:107)

If I get it right, CSS3ParserTokenManager is part of generated code (https://github.com/HtmlUnit/htmlunit-cssparser/blob/master/pom.xml#L65).

Would it be possible to restructure some part of the code generation to decrease the method size under 64K?

You can find a similar issue at https://stackoverflow.com/questions/37666076/jacoco-method-code-too-large-when-using-ver-0-7-6-and-0-7-5

@alan-czajkowski
Copy link

alan-czajkowski commented Aug 2, 2020

i have the same problem

java.lang.instrument.IllegalClassFormatException: Error while instrumenting com/gargoylesoftware/htmlunit/javascript/host/css/StyleAttributes$Definition.
	at org.jacoco.agent.rt.internal_43f5073.CoverageTransformer.transform(CoverageTransformer.java:94)
	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:563)
...
Caused by: java.io.IOException: Error while instrumenting com/gargoylesoftware/htmlunit/javascript/host/css/StyleAttributes$Definition.
	at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrumentError(Instrumenter.java:159)
	at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:109)
	at org.jacoco.agent.rt.internal_43f5073.CoverageTransformer.transform(CoverageTransformer.java:92)
...
Caused by: org.jacoco.agent.rt.internal_43f5073.asm.MethodTooLargeException: Method too large: com/gargoylesoftware/htmlunit/javascript/host/css/StyleAttributes$Definition.<clinit> ()V
	at org.jacoco.agent.rt.internal_43f5073.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2087)
	at org.jacoco.agent.rt.internal_43f5073.asm.ClassWriter.toByteArray(ClassWriter.java:447)
	at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:90)
	at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:107)

@rbri
Copy link
Member

rbri commented Aug 3, 2020

The code is generated by javacc and i see no real chance to make the code smaller.
But on the other hand i also see no real need for a project to instrument the code - why not excluding the cssparser?

@sepe81
Copy link
Author

sepe81 commented Mar 12, 2021

Ok, thank you. I try to exclude it.

@sepe81 sepe81 closed this as completed Mar 12, 2021
@alan-czajkowski
Copy link

alan-czajkowski commented Mar 14, 2021

@sepe81 did an exclusion work? if so, can you please show how you excluded?

@sepe81
Copy link
Author

sepe81 commented Nov 5, 2021

@alan-czajkowski The following exclusion worked:

        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>
                <excludes>
                    <exclude>com/gargoylesoftware/**</exclude>
                </excludes>
            </configuration>
        </plugin>

@revusky
Copy link

revusky commented Dec 24, 2022

This problem has been resolved in JavaCC 21. See: https://javacc.com/2021/03/30/code-too-large-problem-fixed/

@jonathansp
Copy link

@sepe81 how would you achieve the same using gradle?

@alan-czajkowski
Copy link

alan-czajkowski commented Apr 5, 2024

@jonathansp this might help:
https://www.baeldung.com/jacoco-report-exclude

but I strongly recommend moving away from Gradle to Maven

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

No branches or pull requests

5 participants