ConcurrentModificationException with ASTTransformation (Groovy) - groovy

I'm a contributor of Vert.x for Groovy (https://github.com/vert-x3/vertx-lang-groovy) and recently see a curious behaviour regarding AST Transformation.
Until Groovy 3.0.4 the VertxTransformation class (https://github.com/vert-x3/vertx-lang-groovy/blob/3.9/vertx-lang-groovy-gen/src/main/java/io/vertx/lang/groovy/VertxTransformation.java) was working just fine. When I tried to use Groovy 3.0.5 it started to appear some ConcurrentModificationException.
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
at java.util.ArrayList$Itr.next(ArrayList.java:859)
at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1044)
at io.vertx.lang.groovy.VertxTransformation.visit(VertxTransformation.java:82)
at io.vertx.lang.groovy.VertxTransformation.visit(VertxTransformation.java:77)
at io.vertx.lang.groovy.VertxTransformation.lambda$visit$0(VertxTransformation.java:68)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:647)
at io.vertx.lang.groovy.VertxTransformation.visit(VertxTransformation.java:68)
Below there are two links: the first one shows the project building fine with 3.0.4 and the second one failing with 3.0.5. The only thing different is the Groovy version.
https://travis-ci.org/github/vert-x3/vertx-lang-groovy/builds/712642226 (3.0.4)
https://travis-ci.org/github/aaloise/vertx-lang-groovy/builds/712638741 (3.0.5, the exception appears from line 1818 onwards)
Don't know if something changed in 3.0.5 regarding AST. I even raised an issue (https://issues.apache.org/jira/projects/GROOVY/issues/GROOVY-9666). If is not a bug, but an improvement, would like some suggestions for an workaround.

Related

Java 14 support in Groovy?

All groovyconsole binary distros I have found don't support Java 14. The console complains if you try to specify a Jar file that has been compiled with Java 14, for example.
The obvious solution, I thought, was to build Groovy with Java 14. That seems non-trivial.
gradle.wrapper.properties files contain
distributionUrl=http://services.gradle.org/distributions/gradle-2.3-bin.zip
which is a broken URL. Change that to https and then it works, partially.
You then get
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '14.0.2'.
Reading the docs for gradle makes it clear that most (all?) versions of gradle do not support Java 14. Definitely version 2.3 does not. Why - I have no idea.
So... back to my original question. How can I get a groovy installation to support Java 14?
Thanks!
If the Jar cannot be loaded, it is most likely the asm lib, which is unable to read it. To read Java14 you need at least ASM 7.2 I think. ASM in Groovy is not provided as standalone library, because of possible conflicts with other jar dependencies it is shadowed (bytecode is transformed by renaming the packages and directly added to the Groovy jar). I see here 2 options:
compile Groovy yourself and change the dependencies to have at least ASM 7.2. It does not matter if you build Groovy with a lower version of the JDK, the JDK still allows to read "old" jars.
use at least Groovy 2.5.9, 3.0.0 or 2.4.19, as they include asm 7.2 or higher
Of course this does not mean it will change the Groovy Gradle is using easily. For that I would use Groovy 2.5 and read Bumping Groovy version in Gradle?
If this does not solve the problem or answer the question I would need more details.

What version of Mockito is springockito-annotations compatible with?

I'm using (or rather: tried using) Mockito 1.10.19 and springockito-annotatinos 1.0.9, but they don't agree with each other.
(I get a ClassNotFoundException: org.mockito.internal.MockitoInvocationHandler and have raised a bug with springockito.)
Does anyone have a list of what version of Mockito springockito-annotatinos works with? (Or is someone successfully using springockito-annotatinos and can share what version of Mockito they use?)
I'm expecting the compatibilities will be as confusing as those between PowerMock and Mockito for PowerMockito...

java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller

I am trying to generate Excel using Xssf API because its memory footprint is small.
It is working fine in my local machine which is having jdk1.7.
But when I try to run it on UNIX where java version is 1.6.0_75 it gives me the following error.
java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller
I have following jars in my classpath
poi-3.11-20141221.jar
poi-excelant-3.11-20141221.jar
poi-ooxml-3.11-20141221.jar
poi-ooxml-schemas-3.11-20141221.jar
xmlbeans-2.6.0.jar
xercesImpl.jar
I have verified that poi-3.11-20141221.jar has the ZipPackagePropertiesMarshaller class.
Seems that some jar is missing.
Am I missing something?
I have found a solution to my own problem.
I replaced poi-3.11-20141221.jar with poi-ooxml-3.9.jar. That worked.
Java version 1.6.0_75 does not exists, I suppose you make a typo. The last update of Java 6 is the update 45 (6u45).
The class ZipPackagePropertiesMarshaller is loaded at run-time for sure. The exception NoClassDefFoundError occurs during the initialization phase; if the exception had been ClassNotFoundException, it would have been different...
The class ZipPackagePropertiesMarshaller is unaltered between the versions 3.11 and 3.9, but the class PackagePropertiesMarshaller extended by ZipPackagePropertiesMarshaller is changed: the main change regards the use of StAX in the newer version.
The distribution of StAX coming with Java 6, but the version of Java 6 update 18 (http://www.oracle.com/technetwork/java/javase/6u18-142093.html) introduces the StAX 1.2 API version.
Consider to use Java 6u18 or newer. This should solve your problem.
In the official FAQ there are some indications about a similar problem: https://poi.apache.org/faq.html#faq-N1017E.
Moreover, the workaround you found is not the best one, see the last FAQ of POI.

Could not instantiate global transform class org.spockframework.compiler.SpockTransform

I am trying to use a different location for external jar in soapUI. I updated the soapUI batch file by adding the below line.
set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.libraries="C:\Program Files\Groovy\Groovy-2.1.6\lib"
Now when i open soapUI and try to create an activexobject using scriptom(see below)
import org.codehaus.groovy.scriptom.*
def tdc = new ActiveXObject ('TDApiOle80.TDConnection')
I get the following error, the error seems weird because i know i am using groovy 2.1.6 as you can see from the path.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/C:/Program%20Files/Groovy/Groovy-2.1.6/lib/spock-core-0.7-groovy-2.0-20120930.020057-22.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception org.spockframework.util.IncompatibleGroovyVersionException: The Spock compiler plugin cannot execute because Spock 0.7.0-groovy-2.0 is not compatible with Groovy 1.8.0. For more information, see http://versioninfo.spockframework.org Spock location: file:/C:/Program%20Files/Groovy/Groovy-2.1.6/lib/spock-core-0.7-groovy-2.0-20120930.020057-22.jar Groovy location: file:/C:/Program%20Files/SmartBear/soapUI-Pro-4.5.2/lib/groovy-all-1.8.0.jar 1 error
Does anyone know why i am getting this error and what i can do to fix it?
I believe SoapUI (at least 4.5.1) is bundled with Groovy 1.8.0
At least is was back in May this year (2013)
You could try the suggestion posted on the page to upgrade, or I guess you're stuck with 1.8.0 functionality (and the non-2.0 spock dependency)

Can not use groovy step definitions with cuke4duke

I have a working environment to run acceptance tests using cucumber/capybara, recently I have been trying to use cuke4duke from the command line through jruby (no maven, no ant) so I can define my step definitions in groovy as I am more proficient in groovy/java than ruby. Using the Calculator example from https://github.com/cucumber/cuke4duke/tree/master/examples/groovy
I get the following error:
groovy/lang/Closure (Java::JavaLang::NoClassDefFoundError)
looks like this line is failing for some reason 'this.metaClass.mixin(cuke4duke.GroovyDsl)'
and obviously I need it to make the groovy dsl available.
I've tried to run cuke4duke --jars 'folder where groovy.jar is' but I get the same result :(
Env:
jruby 1.6.3
cuke4duke 1.0.2
ubuntu 10.x
groovy 1.7.8
jdk 1.6
Any help will be much appreciated as I have not found anything relevant on google..
Cheers,
Rafael.
Interesting question. The best source of information is the Cukes mailing list. This has come up before, see http://groups.google.com/group/cukes/browse_frm/thread/7a9787cd17134c4d/0e42f88225335db2. Hopefully that will get you started. Also, if all else fails, it really wouldn't take long to get proficient with Ruby :).

Resources