[JIRA] (JENKINS-39719) MultipleCompilationErrorsException: You are not allowed to override the final method __cps__2() from class …

5 views
Skip to first unread message

jglick@cloudbees.com (JIRA)

unread,
Nov 15, 2016, 9:13:01 AM11/15/16
to jenkinsc...@googlegroups.com
Jesse Glick updated an issue
 
Jenkins / Bug JENKINS-39719
MultipleCompilationErrorsException: You are not allowed to override the final method __cps__2() from class …
Change By: Jesse Glick
Summary: MultipleCompilationErrorsException: You are not allowed to override the final method __cps__2() from class …
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

jglick@cloudbees.com (JIRA)

unread,
Nov 15, 2016, 9:14:01 AM11/15/16
to jenkinsc...@googlegroups.com
Jesse Glick updated an issue
When importing an internal library (as described at https://github.com/jenkinsci/workflow-cps-global-lib-plugin), I'm encountering an issue:

{code:none}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: -1: You are not allowed to override the final method ___cps___2() from class 'com.acme.foo.test.MyTest'.
@ line -1, column -1.
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1073)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:67)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:410)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:373)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:213)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Finished: FAILURE
{code}

Using the following libraries to produce this error:

{{ workflowLibs/src/com/acme/foo/test/MyTest.groovy }} :

{code}
#!groovy
package com.acme.foo.test
class MyTest
{
def mytest1() {}
}
{code}

{{
workflowLibs/src/com/acme/foo/test/MyOtherTest.groovy }} :

{code}
#!groovy
package com.acme.foo.test
class MyOtherTest {
def test1() {}
def test2() {}
}
{code}

Pipeline content:

{code}
#!groovy
import com.acme.foo.test.MyTest
import com.acme.foo.test.MyOtherTest

class MyTestExtended
extends MyTest
{
def mytestfunction() {}
}

node('localhost') {
def pipeline = new MyTestExtended()
}
{code}

Now here's the odd part. The error only manifests for certain class names. The error is thrown with the stack trace described above when the class/file is named "MyTest", "Test2", "Test3", or "What". If I change the name to "Test1" or "DoStuff", the same pipeline finishes successfully.

Additionally, the second (unused) import in the pipeline script, is required to produce the issue. When I remove the second import statement (
{{ import com.acme.foo.test.MyOtherTest }} ), the pipeline passes for all names of the primary class being expanded upon.

HemangLavana@java.net (JIRA)

unread,
Nov 15, 2016, 12:10:02 PM11/15/16
to jenkinsc...@googlegroups.com
HemangLavana commented on Bug JENKINS-39719
 
Re: MultipleCompilationErrorsException: You are not allowed to override the final method __cps__2() from class …

This is a blocker issue for us as we are not able to use "@grab" to import apache loggers libraries for use within our workflow code. Please prioritize this so that we can benefit from this feature. PS: we are not able to upgrade to latest jenkins LTS 2.19.2 due to this issue.

dtranter@cloudbees.com (JIRA)

unread,
Nov 15, 2016, 3:43:02 PM11/15/16
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jan 30, 2017, 4:01:01 PM1/30/17
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jan 30, 2017, 4:02:03 PM1/30/17
to jenkinsc...@googlegroups.com
Jesse Glick started work on Bug JENKINS-39719
 
Change By: Jesse Glick
Status: Open In Progress

jglick@cloudbees.com (JIRA)

unread,
Jan 30, 2017, 4:35:01 PM1/30/17
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Jan 30, 2017, 4:45:01 PM1/30/17
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-39719
 
Re: MultipleCompilationErrorsException: You are not allowed to override the final method __cps__2() from class …

Analysis: the class names only matter insofar as they may affect the order in which files are parsed, and the number of methods defined in each class. Basically the issue is manifested under certain conditions when

  • there is a Groovy class defined in a library which defines some methods
  • this class is extended in the main Pipeline script which defines some additional methods

For every method, Pipeline generates an internal ___cps___NNN method for the CPS transformation. The counter is incremented for each new method, but was effectively being reset at the transition between library and main script. Depending on the exact source structure, it can happen that a main script class was transformed to include a generated method with the same counter as its library superclass, producing an error by the Groovy compiler—though one of dubious correctness, since these are all private static final and so could not have been interpreted as an override (Java correctly permits this).

jglick@cloudbees.com (JIRA)

unread,
Feb 1, 2017, 5:00:02 PM2/1/17
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages