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

3.3.0.M1 - GrailsCompileStatic & CompileStatic throw exception in valid uses #10638

Closed
erichelgeson opened this Issue May 11, 2017 · 10 comments

Comments

Projects
None yet
5 participants
@erichelgeson
Copy link
Contributor

erichelgeson commented May 11, 2017

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

Given a controller or service with a plugin's service (tested with mail/ssc)
and
Annotated with GrailsCompileStatic or CompileStatic

import grails.compiler.GrailsCompileStatic
import grails.plugins.mail.MailService

@GrailsCompileStatic
class FooController {
    MailService mailService

    def index() {
        mailService.sendMail { }
     }
}

Expected Behaviour

App should build/run as it did under 3.2.9

Actual Behaviour

Exception:

| Running application...
startup failed:
General error during instruction selection: Unable to configure class node for class grails.plugins.mail.MailService due to malformed parameterized types

java.lang.RuntimeException: Unable to configure class node for class grails.plugins.mail.MailService due to malformed parameterized types
        at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:394)
        at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:275)
        at org.codehaus.groovy.ast.ClassNode.getAnnotations(ClassNode.java:1436)
        at org.codehaus.groovy.ast.ClassNode.getAnnotations(ClassNode.java:1435)
        at org.codehaus.groovy.transform.trait.Traits.isAnnotatedWithTrait(Traits.java:179)
        at org.codehaus.groovy.transform.trait.Traits.isTrait(Traits.java:160)
        at org.codehaus.groovy.transform.trait.Traits.collectSelfTypes(Traits.java:318)
        at org.codehaus.groovy.transform.trait.Traits.collectSelfTypes(Traits.java:300)
        at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.addSelfTypes(StaticTypeCheckingVisitor.java:3162)
        at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.makeOwnerList(StaticTypeCheckingVisitor.java:3143)
        at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2899)
        at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:358)
        at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:71)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:196)
        at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166)
        at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166)
        at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
        at org.codehaus.groovy.ast.CodeVisitorSupport.visitTryCatchFinally(CodeVisitorSupport.java:84)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitTryCatchFinally(ClassCodeVisitorSupport.java:231)
        at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitTryCatchFinally(StaticTypeCheckingVisitor.java:3395)
        at org.codehaus.groovy.ast.stmt.TryCatchStatement.visit(TryCatchStatement.java:44)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
        at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1816)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126)
        at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2151)
        at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2110)
        at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:185)
        at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1076)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53)
        at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:258)
        at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:143)
        at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:63)
        at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:134)
        at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:178)
        at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
        at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:537)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:178)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:60)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkerAdapter.execute(AbstractDaemonCompiler.java:73)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkerAdapter.execute(AbstractDaemonCompiler.java:64)
        at org.gradle.process.internal.daemon.WorkerDaemonServer.execute(WorkerDaemonServer.java:28)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerDaemonServer.execute(AbstractDaemonCompiler.java:91)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:87)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.MalformedParameterizedTypeException
        at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:58)
        at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:51)
        at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:92)
        at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
        at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
        at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
        at sun.reflect.generics.repository.MethodRepository.getReturnType(MethodRepository.java:68)
        at java.lang.reflect.Method.getGenericReturnType(Method.java:255)
        at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:365)
        ... 67 more

1 error

FAILURE: Build failed with an exception.

Environment Information

  • Operating System: Mac 10.12.4
  • Grails Version: 3.3.0.M1
  • JDK Version: 8u121

Example Application

  • n/a
@jeffbrown

This comment has been minimized.

Copy link
Member

jeffbrown commented May 11, 2017

At https://github.com/jeffbrown/issue10638 is a project with minimal dependencies which demonstrates the issue. The class at https://github.com/jeffbrown/issue10638/blob/87d77aee7ca3028749eeb81d87fb6fb645b4bc80/src/main/groovy/demo/Helper.groovy will not compile:

package demo

import grails.plugins.mail.MailService
import groovy.transform.CompileStatic

@CompileStatic
class Helper {

    void sendMail(MailService mailService) {
        mailService.sendMail {}
    }
}

Removing @CompileStatic will allow it to compile.

@magnomp

This comment has been minimized.

Copy link

magnomp commented May 14, 2017

I'm also receiving this exception after upgrading to 3.3.0.M1, but in my case it is from SpringSecurityService which don't use @[Grails]CompileStatic

@saw303

This comment has been minimized.

Copy link
Contributor

saw303 commented May 15, 2017

I'm receiving it with a service class in the browser detection plugin. See this Stackoverflow question.

@jeffbrown

This comment has been minimized.

Copy link
Member

jeffbrown commented May 15, 2017

I expect the problem will manifest with any plugin which provides a Service.

@jeffbrown

This comment has been minimized.

Copy link
Member

jeffbrown commented May 15, 2017

To clarify my previous comment, I expect the problem will manifest with any plugin which provides a Service AND was compiled with a version of Grails prior to 3.3.

@magnomp

This comment has been minimized.

Copy link

magnomp commented May 16, 2017

So, nothing to do on Grails side, and just wait for plugin developers to release compatible versions?

@jeffbrown

This comment has been minimized.

Copy link
Member

jeffbrown commented May 16, 2017

So, nothing to do on Grails side, and just wait for plugin developers to release compatible versions?

That is not necessarily the case. We still have to evaluate some things in Grails 3.3 and agree on the way forward.

@graemerocher

This comment has been minimized.

Copy link
Member

graemerocher commented May 18, 2017

This was an issue in the events plugin and can be resolved by upgrading to RC1 of the events plugin:

compile "org.grails.plugins:events:3.3.0.RC1"

Which will allow folks to continue testing 3.3 M1. I believe @sdelamo has release a spring-security-core version compatible with 3.3 as well.

@saw303

This comment has been minimized.

Copy link
Contributor

saw303 commented May 18, 2017

When I add the 3.3.0.RC1 events plugin I get the following ClassNotFoundException:

java.lang.RuntimeException: java.lang.NoClassDefFoundError: grails/artefact/Service
        at org.codehaus.groovy.control.CompilationUnit.convertUncaughtExceptionToCompilationError(CompilationUnit.java:1101)
        at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1079)
        at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:537)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:174)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:56)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkerAdapter.execute(AbstractDaemonCompiler.java:73)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkerAdapter.execute(AbstractDaemonCompiler.java:64)
        at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:29)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerDaemonServer.execute(AbstractDaemonCompiler.java:91)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:88)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:147)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:129)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: grails/artefact/Service
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:677)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:545)
        at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:185)
        at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:170)
        at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:126)
        at org.codehaus.groovy.control.ResolveVisitor.resolveToOuter(ResolveVisitor.java:676)
        at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:313)
        at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1236)
        at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:176)
        at org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit$1.call(JavaAwareCompilationUnit.java:71)
        at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
        ... 29 more
Caused by: java.lang.ClassNotFoundException: grails.artefact.Service
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 51 more
@graemerocher

This comment has been minimized.

Copy link
Member

graemerocher commented May 18, 2017

You probably lack compile "org.grails:grails-events-compat:3.3.0.RC1" on your classpath

@jglapa jglapa referenced this issue Jun 6, 2018

Closed

Missing classes grails/artefacts/*/* #11020

2 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment