[ 
https://issues.apache.org/jira/browse/GROOVY-9556?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17108922#comment-17108922
 ] 

Daniel Sun edited comment on GROOVY-9556 at 5/16/20, 9:46 AM:
--------------------------------------------------------------

As Java stubs are generated at the CONVERSION phase, if groovy source code uses 
AST tranformation which will change the AST at the phases after CONVERSION, 
e.g. {{@InheritConstructors}}, the generated Java stubs will not include the 
changes specified in the AST tranformation.

If the changes are relied by the Java compilation, e.g. super class has its own 
constructors and its sub class should have some of the relevant constructors, 
the Java compilation will fail.

If Java compilation does not  use the Java stubs, e.g. Java source code does 
not use any Groovy classes which contain the AST transformation mentioned 
above, we can workaround the issue as 2.5.x does via the JVM option 
{{-sourcepath}}. If Java compilation does use the Java stubs, the 
{{-sourcepath}} can take effect and help Java compiler find the Java stubs.

But for the Java stubs in memory, no workaround found, in other words, we can 
not specify {{-sourcepath}} to some virtual path and no Java compiler API found 
could be used to simulate {{-sourcepath}}






was (Author: daniel_sun):
As Java stubs are generated at the CONVERSION phase, if groovy source code uses 
AST tranformation which will change the AST at the phases after CONVERSION, 
e.g. {{@InheritConstructors}}, the generated Java stubs will not include the 
changes specified in the AST tranformation.

If the changes are relied by the Java compilation, e.g. super class has its own 
constructors, its sub class should have some of the relevant constructors, the 
Java compilation will fail.

If Java compilation does not  use the Java stubs, e.g. Java source code does 
not use any Groovy classes which contain the AST transformation mentioned 
above, we can workaround the issue as 2.5.x does via the JVM option 
{{-sourcepath}}. If Java compilation does use the Java stubs, the 
{{-sourcepath}} can take effect and help Java compiler find the Java stubs.

But for the Java stubs in memory, no workaround found, in other words, we can 
not specify {{-sourcepath}} to some virtual path and no Java compiler API found 
could be used to simulate {{-sourcepath}}





> Stub generated without the effect of AST transformation makes joint 
> compilation fail
> ------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9556
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9556
>             Project: Groovy
>          Issue Type: Bug
>          Components: Stub generator / Joint compiler
>    Affects Versions: 3.0.3
>            Reporter: Daniel Sun
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 4.0.0-alpha-1, 3.0.4
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> http://groovy.329449.n5.nabble.com/More-Groovy-3-woes-td5768022.html
> {code:java}
> ===
> 194 ocs /tmp> <CreateSignatureBase.java
> /*
>  * Copyright 2015 The Apache Software Foundation.
>  * OC: removed almost all code, leaving just what's needed to crash
>  */
> package org.apache.pdfbox.examples.signature;
> import java.io.IOException;
> import java.io.InputStream;
> import java.security.KeyStore;
> import java.security.KeyStoreException;
> import java.security.NoSuchAlgorithmException;
> import java.security.UnrecoverableKeyException;
> import java.security.cert.CertificateException;
> import 
> org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface;
> public abstract class CreateSignatureBase implements SignatureInterface
> {
>     public CreateSignatureBase(KeyStore keystore, char[] pin)
>             throws KeyStoreException, UnrecoverableKeyException, 
> NoSuchAlgorithmException, IOException, CertificateException
>     { }
>     @Override
>     public byte[] sign(InputStream content) throws IOException
>     {
>         return null;
>     }
> }
> 195 ocs /tmp> <myclass.groovy
> package cz.ocs.utilities
> import groovy.transform.*
> import org.apache.pdfbox.pdmodel.*
> import org.apache.pdfbox.examples.signature.CreateSignatureBase
> @InheritConstructors class CreateSignature extends CreateSignatureBase {
>     void signPDF(PDDocument pdd, OutputStream out) {
>     }
> }
> 196 ocs /tmp> /usr/local/groovy-2.4.17/bin/groovyc -cp 
> /Extensions/pdfbox-2.0.17.jar -j myclass.groovy CreateSignatureBase.java
> 197 ocs /tmp> /usr/local/groovy-3.0.3/bin/groovyc -cp 
> /Extensions/pdfbox-2.0.17.jar -j myclass.groovy CreateSignatureBase.java
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> Compile error during compilation with javac.
> /var/folders/zh/h4cv6xjx033frtt9y72ch8980000gp/T/groovy-generated-8946934250394256568-java-source/cz/ocs/utilities/CreateSignature.java:12:
>  error: constructor CreateSignatureBase in class CreateSignatureBase cannot 
> be applied to given types;
> @groovy.transform.InheritConstructors() public class CreateSignature
>                                                ^
>   required: KeyStore,char[]
>   found: no arguments
>   reason: actual and formal argument lists differ in length
> 1 error
> 1 error
> 198 ocs /tmp>
> ===
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to