You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Saravanan Palanichamy <ch...@gmail.com> on 2024/02/21 07:18:37 UTC
Compatibility with Java syntax
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({
> @MyAnnotation(name = "blah", value = 1.0),
> @MyAnnotation(name = "blah", value = 1.0)
> } )
>
- It does not seem to like stream generics
// The error I get with this one is
>
// Cannot call someFunction(java.util.List<SomethingElseType>) with
> arguments [java.util.List<#T>]
>
someFunction(
> result.someList().stream().map(requestConverter::toSomethingElse).collect(Collectors.toList()))
>
Are there any plans to achieve compatibility? Some of it is more of
syntactic sugar, Some there are ways to achieve in other ways in Groovy
regards
Saravanan
Re: Compatibility with Java syntax
Posted by Saravanan Palanichamy <ch...@gmail.com>.
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({
@MyAnnotation(name = "blah", value = 1.0),
@MyAnnotation(name = "blah", value = 1.0)
} )
It does not seem to like stream generics.
// The error I get with this one is
// Cannot call someFunction(java.util.List<SomethingElseType>) with
arguments [java.util.List<#T>]
someFunction(
result.someList().stream().map(requestConverter::toSomethingElse).collect(Collectors.toList()))
Are there any plans to achieve compatibility? Some of it is more of
syntactic sugar, Some there are ways to achieve in other ways in Groovy
regards
Saravanan