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

spock-core-1.3-groovy-2.4 passes ASM4 opcode instead of ASM7 when using SpecClassFileSelector #1025

Open
chris-schwartz opened this issue Sep 3, 2019 · 3 comments

Comments

@chris-schwartz
Copy link

commented Sep 3, 2019

Issue description

When using the SpecClassFileSelector for selecting Spock tests for an Ant build using JDK 11, the following exception is thrown:

Caused by: java.lang.UnsupportedOperationException: This feature requires ASM7
	at org.objectweb.asm.ClassVisitor.visitNestHost(ClassVisitor.java:150)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:541)
	at org.objectweb.asm.ClassReader.accept(ClassReader.java:391)
	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.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:200)
	at org.spockframework.buildsupport.AsmClassReader.accept(AsmClassReader.java:57)
	at org.spockframework.buildsupport.SpecClassFileFinder.isRunnableSpec(SpecClassFileFinder.java:53)
	at org.spockframework.buildsupport.ant.SpecClassFileSelector.isSelected(SpecClassFileSelector.java:36)

Issue appears to be that the SpecClassFileVisitor class is passing an Opcode of ASM4 instead of ASM7 when calling its super constructor. This also appears to be happening in the EmptyAnnotationVisitor class. After changing this to ASM7, the issue appears to be resolved.

How to reproduce

Building with OpenJDK 11 use the SpecClassFileSelector to include Spock tests within the JUnit ant task

   <junit fork="true"
                   showoutput="true"
                   printsummary="yes"
                   forkmode="once"
                   haltonfailure="false"
                   maxmemory="256m"
                   failureproperty="tests.failed">
                <classpath>
                    <path>
                        <fileset dir="lib">
                            <patternset refid="pattern.test-run-jars"/>
                        </fileset>
                    </path>
                    <path refid="@{module}.classpath.compile"/>
                </classpath>
                <formatter type="xml" usefile="true"/>
                <batchtest fork="true" todir="@{module}/build/unittestreports">
                    <fileset dir="@{module}/src/test">
                        <include name="**/*Test.java"/>
                        <include name="**/*Tests.java"/>
                    </fileset>
                    <fileset dir="@{module}/build/test">
                        <custom classname="org.spockframework.buildsupport.ant.SpecClassFileSelector"
                                classpathref="spock.classpath"/>
                    </fileset>
                </batchtest>
            </junit>

Java/JDK

OpenJDK 11.0.3

Build tool version

Ant 1.10.6

Operating System

Windows 10

IDE

IntelliJ Ultimate 2018.2

Build-tool dependencies used

spock-core-1.3-groovy-2.4.jar

@szpak

This comment has been minimized.

Copy link
Contributor

commented Sep 3, 2019

Spock 1.3 should provide asm7 (build.gradle):

asm: "org.ow2.asm:asm:7.0",

Are you sure that nothing else causes asm4 on your classpath?

@Vampire

This comment has been minimized.

Copy link
Contributor

commented Sep 4, 2019

Actually ASM4 is used on two places, EmptyAnnotationVisitor and SpecClassFileVisitor.
@szpak what version you have on the classpath is irrelevant, as you specify the version you want to use by code.
The sonar-findbugs plugin had the same problem, specifying ASM5 instead of the latest: spotbugs/sonar-findbugs#253

@szpak

This comment has been minimized.

Copy link
Contributor

commented Sep 4, 2019

I missed that it was about "passing Opcode of ASM4", not that asm:4 was used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.