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

Issue when running Micronaut app build #978

Open
venkyvb opened this Issue Mar 10, 2019 · 3 comments

Comments

Projects
None yet
4 participants
@venkyvb
Copy link

venkyvb commented Mar 10, 2019

Issue description

When I run a build for a Micronaut app in IntelliJ I get the following error:

Error:Groovyc: While compiling tests of user-service_test: Unexpected error during compilation of spec 'user.service.UserServiceSpec'. Maybe you have used invalid Spock syntax? Anyway, please file a bug report at http://issues.spockframework.org.
java.lang.UnsupportedOperationException
	at groovyjarjarasm.asm.ClassVisitor.visitNestMemberExperimental(ClassVisitor.java:248)
	at groovyjarjarasm.asm.ClassReader.accept(ClassReader.java:651)
	at groovyjarjarasm.asm.ClassReader.accept(ClassReader.java:391)
	at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:83)
	at org.codehaus.groovy.control.ClassNodeResolver.findDecompiled(ClassNodeResolver.java:254)
	at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:192)
	at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:172)
	at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:128)
	at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveClassNullable(AsmReferenceResolver.java:59)
	at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveClass(AsmReferenceResolver.java:46)
	at org.codehaus.groovy.ast.decompiled.TypeSignatureParser.visitEnd(TypeSignatureParser.java:112)
	at groovyjarjarasm.asm.signature.SignatureReader.parseType(SignatureReader.java:206)
	at groovyjarjarasm.asm.signature.SignatureReader.parseType(SignatureReader.java:235)
	at groovyjarjarasm.asm.signature.SignatureReader.accept(SignatureReader.java:111)
	at org.codehaus.groovy.ast.decompiled.MemberSignatureParser.createMethodNode(MemberSignatureParser.java:95)
	at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.lazyInitMembers(DecompiledClassNode.java:195)
	at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.getDeclaredMethods(DecompiledClassNode.java:121)
	at org.codehaus.groovy.ast.ClassNode.getDeclaredMethods(ClassNode.java:897)
	at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:912)
	at org.spockframework.compiler.SpecialMethodCall.checkIsConditionBlock(SpecialMethodCall.java:211)
	at org.spockframework.compiler.SpecialMethodCall.parse(SpecialMethodCall.java:168)
	at org.spockframework.compiler.AbstractDeepBlockRewriter.visitMethodCallExpression(AbstractDeepBlockRewriter.java:110)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:70)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitListOfExpressions(CodeVisitorSupport.java:326)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitTupleExpression(CodeVisitorSupport.java:231)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitArgumentlistExpression(CodeVisitorSupport.java:336)
	at org.codehaus.groovy.ast.expr.ArgumentListExpression.visit(ArgumentListExpression.java:76)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitMethodCallExpression(CodeVisitorSupport.java:184)
	at org.spockframework.compiler.AbstractDeepBlockRewriter.doVisitMethodCallExpression(AbstractDeepBlockRewriter.java:157)
	at org.spockframework.compiler.DeepBlockRewriter.doVisitMethodCallExpression(DeepBlockRewriter.java:95)
	at org.spockframework.compiler.AbstractDeepBlockRewriter.visitMethodCallExpression(AbstractDeepBlockRewriter.java:119)
	at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:70)
	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:122)
	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:197)
	at org.spockframework.compiler.AbstractDeepBlockRewriter.doVisitExpressionStatement(AbstractDeepBlockRewriter.java:149)
	at org.spockframework.compiler.DeepBlockRewriter.doVisitExpressionStatement(DeepBlockRewriter.java:64)
	at org.spockframework.compiler.AbstractDeepBlockRewriter.visitExpressionStatement(AbstractDeepBlockRewriter.java:87)
	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
	at org.spockframework.compiler.StatementReplacingVisitorSupport.replace(StatementReplacingVisitorSupport.java:44)
	at org.spockframework.compiler.AbstractDeepBlockRewriter.visit(AbstractDeepBlockRewriter.java:71)
	at org.spockframework.compiler.DeepBlockRewriter.visit(DeepBlockRewriter.java:51)
	at org.spockframework.compiler.SpecRewriter.visitAnyBlock(SpecRewriter.java:317)
	at org.spockframework.compiler.model.WhenBlock.accept(WhenBlock.java:32)
	at org.spockframework.compiler.model.Method.accept(Method.java:70)
	at org.spockframework.compiler.model.Spec.accept(Spec.java:112)
	at org.spockframework.compiler.SpockTransform$Impl.processSpec(SpockTransform.java:77)
	at org.spockframework.compiler.SpockTransform$Impl.visit(SpockTransform.java:64)
	at org.spockframework.compiler.SpockTransform.visit(SpockTransform.java:47)
	at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:331)
	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:968)
	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:609)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:586)
	at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:62)
	at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:118)
	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.jetbrains.groovy.compiler.rt.GroovycRunner.intMain2(GroovycRunner.java:91)
	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.jetbrains.jps.incremental.groovy.InProcessGroovyc.runGroovycInThisProcess(InProcessGroovyc.java:160)
	at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.lambda$runGroovyc$0(InProcessGroovyc.java:89)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

How to reproduce

Project generated using micronaut CLI https://docs.micronaut.io/

I have a Simple Java class UserServiceImpl as follows:

package user.service;

import io.reactivex.Maybe;
import io.reactivex.Single;

import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Singleton
public class UserServiceImpl implements UserService{

    private static Map<String,User> userStore = new ConcurrentHashMap<>();

    @Override
    public List<User> getUsers() {
        return new ArrayList<>(userStore.values());
    }

    @Override
    public Single<User> createUser(Single<User> user) {
        return user.map(u -> {
            userStore.put(u.getEmailId(), u);
            return u;
        });
    }

    @Override
    public Single<User> modifyUser(Single<User> user) {
        return user.map(u -> {
            userStore.put(u.getEmailId(), u);
            return u;
        });
    }

    @Override
    public Maybe<User> getUserByEmail(String email) {
        return Maybe.just(userStore.get(email));
    }
}

Corresponding Spec is

package user.service

import io.reactivex.Single
import spock.lang.Specification

class UserServiceSpec extends Specification{

    void "create user with params"() {

        given:
        UserService userService = new UserServiceImpl();

        when:
        userService.createUser(Single.just(new User("abc@gmail.com", "123")));

        then:
        def user = userService.getUserByEmail("abc@gmail.com");
        user.blockingGet().emailId == "abc@zoo.com";
    }
}

When I build this I get the above error.

Additional Environment information

OSX
IntelliJ Idea

Java/JDK

openjdk version "11.0.2"

Groovy version

Groovy Version: 2.5.6 JVM: 11.0.2 Vendor: Oracle Corporation OS: Mac OS X

Build tool version

Gradle

4.10

Operating System

Mac etc.

IDE

IntelliJ

Build-tool dependencies used

Gradle/Grails

testCompile("org.spockframework:spock-core") {
    exclude group: "org.codehaus.groovy", module: "groovy-all"
}
testCompile "io.micronaut:micronaut-inject-groovy"
@szpak

This comment has been minimized.

Copy link
Contributor

szpak commented Mar 10, 2019

For sanity you can bump Spock to 1.3-groovy-2.5 and asm to 7.1 (in gradle.properties) and try it again

@tburny

This comment has been minimized.

Copy link

tburny commented Mar 24, 2019

void "create user with params"() {
Does the problem go away when changing void to def?

@leonard84

This comment has been minimized.

Copy link
Member

leonard84 commented Mar 24, 2019

Is this just happening in IntelliJ or does it also happen with gradle? Which supports java 11 starting with gradle 5.0 IIRC, so you might want to update that as well (current is gradle 5.3).
Which Spock version are you using?
Can you create a SSCCE.

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