Java 14 support in Groovy? - 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.

Related

Groovy-Eclipse 2.5.2: java.lang.ClassNotFoundException: picocli.CommandLine$ParameterException

I'm using Eclipse 4.5 with the Groovy-Eclipse 2.9.2/4.5 plugin which I thought was supposed to have the Groovy 2.5 compiler. However, it didn't have any picocli support so I added the groovy-cli-picocli-2.5.2-indy.jar to my classpath and was able to compile. However #2, when trying to run the script via Eclipse I get:
java.lang.ClassNotFoundException: picocli.CommandLine$ParameterException
It looks like groovy-cli-picocli-2.5.2-indy.jar does not have CommandLine class at all.
I would just throw jars at this from the fullblown picocli distribution but I'm under the impression they all have to somehow wrap nicely into Eclipse Groovy library via groovy.cli.picocli.CliBuilder.
Is my Groovy 2.5.2 missing this or am I somehow missing the boat on how it's supposed to work because picocli is not working for me in this configuration. Thanks!
You are correct: groovy-cli-picocli-2.5.2.jar (and groovy-cli-picocli-2.5.2-indy.jar) do not contain the picocli classes.
You need to add the picocli jar to the classpath.
If you use Maven, the groovy-all POM should include all dependencies.
(My original answer mentioned picocli classes that are shaded into the groovy-2.5.x.jar under the groovyjarjarpicocli package but these are intended for use internally by Groovy and not meant to be used by applications.)

JDK 9: JUnit 5 test compile with SpringExtension produces java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS

I believe this problem not to be related to module exclusions in JDK 9 (as with java.se.ee), but rather with the fact that JDK 9 includes a newer version of org.w3c.dom.ls in the java.xml module that does not have the DocumentLS class.
The important bit of the stack trace is this:
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [spring-test/test-container.xml]; nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
Even if I include a runtime dependency with this class, like xerces:xerces 2.4.0, the JDK java.xml module is preferred (I guess).
I am using Gradle 4.1. Is there any way to restrict the scope of a
JDK provided module?
As you have correctly analyzed, the package org.w3c.dom.ls is present in the platform module java.xml. Any class on the class path that is in the same package will be ignored. That's called a split package and several fixes exist - the following two might help you.
Patch java.xml
You can add the classes of the Xerxes JAR to the java.xml module with --patch-module:
java --patch-module java.xml=xerxes-4.0.0.jar ...
I've never tried that with a JAR that contains some of the same classes. As I understand it, the JDK classes will then be replaced with the Xerxes classes, which means they better be a fully binary compatible replacement.
Upgrade java.xml
Another hope is to replace java.xml with the upgrade module path:
The upgrade module path (--upgrade-module-path) contains compiled definitions of modules intended to be used in place of upgradeable modules built-in to the environment (compile time and run time).
You face two problems:
the upgrade module path is supposed to be used only for upgradable modules (which java.xml is not), but I think I've read somewhere that that's not enforced (yet?) - didn't try it
the artifact you replace java.xml with needs to be fully binary compatible update - would that be the case for Xerxes?
From what I can tell, DocumentLS is from a 2002 draft of the W3C API, it doesn't appear to have made it into a released version. It looks like xerces-2.4.0 (from 2006?) includes it but newer versions don't. So upgrading to a more recent Xerces may be needed here. If Spring really depends on DocumentLS then it will need to be updated too.

which plugin does RedHawk 1.10 use for IDL editing

RedHawk installs JARs for eclipse plugins from redhawk-yum-1.10.2-5-el6-x86_64.tar.gz. In RedHawk 1.9 it only installed 4 JARs for IDL parsing and editing, but in RedHawk 1.10 it installs these 4 but also 2 from Eclipse Corba Package.
gov.redhawk.eclipsecorba.idl_7.1.0.201501292343.jar
gov.redhawk.eclipsecorba.idl.source_7.1.0.201501292343.jar
gov.redhawk.eclipsecorba.idl.edit_4.1.0.201501292343.jar
gov.redhawk.eclipsecorba.idl.edit.source_4.1.0.201501292343.jar
net.sf.eclipsecorba.idl_0.7.0.218.jar
net.sf.eclipsecorba.idl.edit_0.7.0.218.jar
Many java files have the same names but there are also many differences.
From comments in the source java files it appears that the gov jars used JavaCC to build the parser while those from ECP used SableCC.
Which ones are actually used in RedHawk 1.10 or are they both used for different purposes?
I am trying to look into a parser bug and would like to know which parser to look at.
Sorry, I am not familiar with Eclipse plugin development and have not figured out how to tell what plugins are actually loaded or how they are used.
Redhawk uses the Eclipse Corba Plugin (ECP) project to provide an editor for IDL files:
http://eclipsecorba.sourceforge.net/
The editor does not support constant IDL expresions (e.g. const foo = bar + 1). Unfortunately, the project is not maintained any more (last release in 2008).
For all other IDL functions in the IDE, such as displaying IDLs under the "Target SDR" in the explorer view, the Redhawk IDE has its own parser code which handles this. The IDE's parser currently has the same limitation - it does not recognize constant IDL expressions.
RedHawk uses three distinct IDL parsers. 1) omnicpp (omniorbs version of idl2cpp) uses its own parser. 2) the code that builds a tree for the IDL Repository in Target SDR uses a plugin in gov.redhawk.eclipsecorba.idl.* which has a parser based on JavaCC compiler-compiler. 3) the IDL editor that was introduced in RedHawk 1.9 uses a different plugin in net.sf.eclipsecorba.idl.* which as a parser based on SableCC, a different compiler-compiler.

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.

Error compiling JasperReport 4.1.3 created from iReport 4.1.3 with Groovy 1.8.1

I'm on Windows 7 64-bit, using JDK 1.6.0_29, groovy 1.8.1, and JasperReports/iReport 4.1.3.
I have the following jars from the JasperReports distribution in my CLASSPATH:
commons-beanutils-1.8.0.jar, commons-collections-2.1.1.jar, commons-digester-1.7.jar, commons-logging-1.0.4.jar, jasperreports-4.1.3.jar, poi-3.7-20101029.jar
I have also tried adding all the jars in the ${JASPER_HOME}/lib distribution in case I was missing some important jar.
The jasper report is to be generated by a groovy script. I have created a very simple report with iReport that contains only some static text in the title. I am able to compile and view the report from within iReport.
When I try and compile the report from the script:
def jasperReport = JasperCompileManager.compileReport("filename")
I get the following error:
Caught: java.lang.AbstractMethodError
java.lang.AbstractMethodError
at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:96)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:188)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:212)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:145)
at net.sf.jasperreports.engine.JasperCompileManager$compileReport.call(Unknown Source)
at wis_validate_environment.run(wis_validate_environment.groovy:58)
Is there possibly some conflict between the groovy that JasperReports is using (JRGroovyCompiler? from the stacktrace) and the groovy that I am using to compile the report?
There were a couple of things I had to change in order to resolve this issue.
Creating a report using the Report Wizard and the default settings creates the language="groovy" parameter in the jasperReport tag. When I remove language parameter, I no longer get the AbstractMethodError mentioned above.
I also needed to add the jdt-compiler-3.1.1.jar in my classpath.
I found the problem was explained here:
http://www.mail-archive.com/user#ofbiz.apache.org/msg23404.html
There seems to be a problem with the versions of one of the dependent libraries that our project uses that conflicts with groovy's.
In short use groovy-all.jar or make sure are your dependancies match those of the version of groovy you are using.

Resources