Class loaders to use

2025-07-06 Thread Saravanan Palanichamy
Hello Groovy users I am looking for help in setting up my class loaders with the Groovy compiler. This is my understanding so far 1. The compiler is an external tool to compile (Groovy is a java based compiler) and therefore it must have its own class paths and a class loader to load lib

Re: Errors with using the builder annotation

2025-06-04 Thread Saravanan Palanichamy
.containsValidFieldValues([]) > > The normal usage is all set up to avoid any problems with class resolution. > > Cheers, Paul. > > > On Thu, Jun 5, 2025 at 2:59 AM Saravanan Palanichamy > wrote: > > > > Hello Users > > > > I am trying to use the b

Re: Errors with using the builder annotation

2025-06-04 Thread Saravanan Palanichamy
phase because it does not exist yet. What is the right way to add a new class generated (and used later on in code) during compile time to the module node? regards Saravanan On Wed, Jun 4, 2025 at 9:59 AM Saravanan Palanichamy wrote: > Hello Users > > I am trying to use the builder a

Errors with using the builder annotation

2025-06-04 Thread Saravanan Palanichamy
Hello Users I am trying to use the builder annotation and am seeing compile errors. I am not sure if I am doing something wrong package com.my.builder > > import groovy.transform.builder.Builder > > @Builder(builderClassName = "MyBuilder") > class NoMembers { > private int privateInt; > p

Error with functions using same name

2025-04-19 Thread Saravanan Palanichamy
When I define a class in Groovy with 2 methods with the same name, one private and one public, I get this error during static compilation Mixing private and public/protected methods of the same name causes > multimethods to be disabled and is forbidden to avoid surprising behaviour. > Renaming the

Re: Default for annotation members with type class

2025-04-15 Thread Saravanan Palanichamy
uot;default []". I don't think it supports > "default new Class[0]". Is this under Static Type Checking or Static > Compilation? > > NOTE: https://issues.apache.org/jira/browse/GROOVY-11492 item 3 covers > the missing "default {}" support. > > >

Default for annotation members with type class

2025-04-15 Thread Saravanan Palanichamy
Hello Groovy users What is the right way to define this java annotation in groovy? I am testing this out in Groovy 5.0, I have not tried 4.x. I tried using [] after the default keyword, but I get the error "Cannot return value of type java.util.ArrayList<#E> for method returning java.lang.Class[

Re: Compiling Java with Groovy

2025-04-10 Thread Saravanan Palanichamy
r 7, 2025 at 5:30 PM Jochen Theodorou wrote: > On 06.04.25 06:59, Saravanan Palanichamy wrote: > > Hello Groovy users/devs > > > > I am using the Groovy compiler to compile standard Java code (as in the > > developer wrote Java code, I am using the Groovy compiler behind the

Re: Compiling Java with Groovy

2025-04-07 Thread Saravanan Palanichamy
Hello OC I didnt have to change my file names to .groovy (I just use the compilation unit to create my source unit closure (from a .java file and it works). Additionally, there are a few reg ex updates I do to the code before adding them to the source unit compilation mechanism. This lets me side

Compiling Java with Groovy

2025-04-05 Thread Saravanan Palanichamy
Hello Groovy users/devs I am using the Groovy compiler to compile standard Java code (as in the developer wrote Java code, I am using the Groovy compiler behind the scenes). Most of it works, but I did see a few compatibility issues. Some seem like bugs, some seem like parsing differences. Will th

Re: Differences with Java

2024-11-02 Thread Saravanan Palanichamy
, Nov 2, 2024 at 8:48 PM Saravanan Palanichamy wrote: > I realize that I am trying to do something different, compile Java using > Groovy. I wonder if supporting this will open up a lot more usage of Groovy > (especially when doing AST transformations), which is exactly what I am

Re: Differences with Java

2024-11-02 Thread Saravanan Palanichamy
ases you showed. Furthermore, as this is a trap that's bitten me > before, I propose that it should be a compile-time error to use a bare > "return" statement in a method with a non-void return type; implied "return > null" is almost never what the programmer

Differences with Java

2024-11-02 Thread Saravanan Palanichamy
Hello there I am compiling standard Java code with Groovy (it works for the most part with some exceptions) and want to call out some differences. Is there a way for me to auto fix these discrepancies with say a text pre-processor or some AST parsing modifications? *Compile errors with new lines.

Re: Compatibility with Java syntax

2024-02-20 Thread Saravanan Palanichamy
Hello Groovy users I am trying to compile Java code using the Groovy compiler. 99% of it works which is awesome. There are however some constructs that dont play nice Annotation collections needs a [ ... ] instead of { ... } that is used in Java. @MyCollectionOfAnnotations({

Compatibility with Java syntax

2024-02-20 Thread Saravanan Palanichamy
Hello Groovy users I am trying to compile Java code using the Groovy compiler. 99% of it works which is awesome. There are however some constructs that dont play nice - Annotation collections needs a [ ... ] instead of { ... } that is used in Java @MyCollectionOfAnnotations({ >@

Re: Generics question

2023-08-27 Thread Saravanan Palanichamy
Hello Jochen Maybe its good for me to state the original problem separately from the solution I am pursuing to see if there are other ways to do it. Apologies if the email is too long. I tried to stick to a lot of example rather than text The problem. Entities in the DSL are either mutable or imm

Re: Generics question

2023-08-27 Thread Saravanan Palanichamy
able() > > List myThings = [] > myThings << new Immutable() > // myThings << new Mutable() forbidden > > List myMutables = [] > // myMutables << new Immutable() forbiddden > myMutables << new Mutable() > > On 27.08.23 14:59, Saravanan Palanicham

Generics question

2023-08-27 Thread Saravanan Palanichamy
Hello folks I am building an AST transformation that will allow me to define a concept of mutable and immutable objects. Java lets me hold mutable objects in immutable object lists (as per the code below). But my DSL also wants to allow immutable objects to be held in mutable lists. The meaning it

Restricting list extensions

2023-08-02 Thread Saravanan Palanichamy
Hello Groovy users/devs I have a derived class from List (lets call this MyImmutableList) and I want to only allow the use of certain extension functions. For example, collect is ok, but left shift is not myImmutableList << 100 // I want to prevent this because its an immutable list) myImmutableL

Duplicate visits to expressions defined in RHS of a setter

2023-04-02 Thread Saravanan Palanichamy
Hello Groovy Devs - I have a class defined MyTestClass in java/kotlin (does not matter) - I have a groovy class defined MyClassDefinedInGroovy - I have code in a groovy function that is creating these classes and setting a variable in the object. I compile this with static compilation

Closure params hint

2023-03-19 Thread Saravanan Palanichamy
Hello Everyone I am trying to define a method that will take a closure whose parameters are a generic type based on generic parameters on the function. The closure returns void class Result { > public Map pairs; > } > > class MyOtherClass { > // This closure takes an input of Result >

Re: Compiling several groovy files together

2022-03-10 Thread Saravanan Palanichamy
from a jar or class path. This only fails if I use the same class loader that compiled someMethod regards Saravanan On Fri, Mar 4, 2022 at 5:44 PM Jochen Theodorou wrote: > On 15.02.22 05:20, Saravanan Palanichamy wrote: > > Hello Groovy users > > > > I am using Groovy 3.0

Compiling several groovy files together

2022-02-14 Thread Saravanan Palanichamy
Hello Groovy users I am using Groovy 3.0.5 - I have a file A.groovy and B.groovy. B depends on A - I have ast transformations that add annotations to methods in A (specifically an annotation with a list expression that contains other annotations) - I compile A.groovy using the load

Re: Extracting groovy comments and source code

2021-09-29 Thread Saravanan Palanichamy
; trying to do. > > Cheers, Paul. > > On Wed, Sep 29, 2021 at 4:26 PM Saravanan Palanichamy > wrote: > > > Hello all, > > > > I am trying to do two things > > > > 1) Extract comments from inside a function code (not the function's groovy > >

Re: Extracting groovy comments and source code

2021-09-29 Thread Saravanan Palanichamy
gt; I don't know about Groovy specifically, but most parsers discard comments > >> (and whitespace, line endings, etc.) before building an AST. However, you > >> can reconstruct the missing text if you have the position information of > >> each AST node and the origina

Extracting groovy comments and source code

2021-09-28 Thread Saravanan Palanichamy
Hello all, I am trying to do two things 1) Extract comments from inside a function code (not the function's groovy doc, but comments embedded inside the function code itself) 2) Extract the source code of the function itself For example /* Comments about myFunction *./ void myFunction() {

Re: AST to add a new class

2021-04-12 Thread Saravanan Palanichamy
are compiling your other > classes at the same time, I'd just get the module node from one of those > classes and add your new class to it. > > Cheers, Paul. > > > On Mon, Apr 12, 2021 at 9:34 PM Saravanan Palanichamy > wrote: > >> Hello paul >> >> Thank y

Re: AST to add a new class

2021-04-12 Thread Saravanan Palanichamy
, 12 Apr, 2021, 16:52 Paul King, wrote: > The Builders and Sortable AST do something similar and use: > > https://github.com/apache/groovy/blob/master/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java#L129 > > > On Mon, Apr 12, 2021 at 8:36 PM Saravanan Palanichamy &

AST to add a new class

2021-04-12 Thread Saravanan Palanichamy
Hello What is the right way to add a new class through an AST during the Groovy compilation phase? What I am trying to do is this * Compile N different classes * During the compile process, create a new class for each of these N classes that denotes how it should be serialized (for example) * A

Default values for parameters in interface methods

2021-01-04 Thread Saravanan Palanichamy
Hello Are there plans to support default parameters in interface methods interface MyClass { def myFunction(String parameter1 = "1234") } the error I get is Cannot specify default value for method parameter inside an interface regards Saravanan

Re: IDE support for multi assignment statements

2020-12-11 Thread Saravanan Palanichamy
heers, > mg > > *I would also recommend closely following the ticket guidelines, i.e. > describe current (erronous) state, and the expected behavior - in short you > want to make it easy for them to work on this. > > > On 11/12/2020 15:40, Saravanan Palanichamy wrote: > >

IDE support for multi assignment statements

2020-12-10 Thread Saravanan Palanichamy
Hello I am using Groovy 3.0.5 and it supports multiple assignment statements from tuples when using static compile def(var1, var2) = Tuple.tuple("a", 1) but it looks like the Intellij IDE still calls this out as a compile error. Also it defaults to identifying var1 and var2 as objects. Thi

Closures in annotations over interface methods

2020-07-17 Thread Saravanan Palanichamy
Hello, I am using a closure inside an annotation over an interface method. I then decompile the class in intellij (open the .class file essentially) and I see that the closure class was created, but I dont see the class definition anywhere. I am however able to access it in code. Is this a limi

Re: Loading groovy files from a remote repository

2020-05-25 Thread Saravanan Palanichamy
better approach. > > All the best, > OC > > > On 24 May 2020, at 7:35, Saravanan Palanichamy wrote: > > > > Hello > > > > I have a requirement where I load all my groovy files into a remote > > database. I then have to pull them down to compile a

Loading groovy files from a remote repository

2020-05-23 Thread Saravanan Palanichamy
Hello I have a requirement where I load all my groovy files into a remote database. I then have to pull them down to compile and I am wondering what is the best way to do this. Right now I do this * I pull down the names of all files (not the actual file) * I then use a GroovyClassLoader to load