[
https://issues.apache.org/jira/browse/GROOVY-11610?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Saravanan updated GROOVY-11610:
-------------------------------
Component/s: Static compilation
Description:
Nested record definitions are static by default in Java, but groovy treats them
differently. The byte code generated respects this definition, but constructing
the record in a groovy script creates a compile error (In static compilation)
{code:java}
Cannot find matching constructor
com.Records.RecordTesting$MyRecord(com.Records.RecordTesting,
java.lang.String). Please check if the declared type is correct and if the
method exists{code}
{code:java}
package com.Records;
public class RecordTesting {
// This is static in the bytecode (which is correct behavior)
public record MyRecord(String blah) {}
public String create() {
// This will cause a compile error (unless MyRecord was marked static)
new MyRecord("blah").blah();
}
}
{code}
was:
Nested record definitions are static by default in Java, but groovy treats them
differently. The byte code generated respects this definition, but constructing
the record in a groovy script creates a compile error
{code:java}
Cannot find matching constructor
com.Records.RecordTesting$MyRecord(com.Records.RecordTesting,
java.lang.String). Please check if the declared type is correct and if the
method exists{code}
{code:java}
package com.Records;
public class RecordTesting {
// This is static in the bytecode (which is correct behavior)
public record MyRecord(String blah) {}
public String create() {
// This will cause a compile error (unless MyRecord was marked static)
new MyRecord("blah").blah();
}
}
{code}
> Inner records are marked static in bytecode but are not recognized as static
> during compile
> -------------------------------------------------------------------------------------------
>
> Key: GROOVY-11610
> URL: https://issues.apache.org/jira/browse/GROOVY-11610
> Project: Groovy
> Issue Type: Bug
> Components: Compiler, Static compilation
> Affects Versions: 4.0.24
> Reporter: Saravanan
> Priority: Trivial
>
> Nested record definitions are static by default in Java, but groovy treats
> them differently. The byte code generated respects this definition, but
> constructing the record in a groovy script creates a compile error (In static
> compilation)
> {code:java}
> Cannot find matching constructor
> com.Records.RecordTesting$MyRecord(com.Records.RecordTesting,
> java.lang.String). Please check if the declared type is correct and if the
> method exists{code}
>
> {code:java}
> package com.Records;
> public class RecordTesting {
> // This is static in the bytecode (which is correct behavior)
> public record MyRecord(String blah) {}
> public String create() {
> // This will cause a compile error (unless MyRecord was marked static)
> new MyRecord("blah").blah();
> }
> }
> {code}
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)