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

Paul King commented on GROOVY-10148:
------------------------------------

The latest sealed related issue was GROOVY-11292. I'd create a separate issue.

> Groovy should support sealed classes
> ------------------------------------
>
>                 Key: GROOVY-10148
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10148
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Compiler
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 4.0.0-beta-1
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> For Java 15/16 under preview and targeted for 17+, sealed classes and 
> interfaces can be created. It would be good for Groovy to support a similar 
> capability.
> In addition, Groovy should behave properly in the presence of such 
> Java-created classes, e.g. currently the compiler allows Groovy classes to 
> extend sealed Java classes or implement sealed interfaces, but such classes 
> when loaded will give a runtime error:
> {noformat}
> java.lang.RuntimeException: java.lang.IncompatibleClassChangeError:
> class MyGroovyChildClass cannot inherit from sealed class MyJavaSealedClass
> {noformat}
> Possible features:
> * Java allows the permitted list to be inferred where the classes are from 
> the same source file.
> * Java allows sealed/non-sealed parts to the hierarchy.
> * We could use an annotation to carry sealed information for JDK8-16 versions.
> Advanced options should also be explored:
> * When creating sealed classes, Java currently requires all mentioned 
> permitted children to be compiled in the source set. However, it does allow 
> subsequent compilation steps to include just one of the children (and have 
> the parent pre-compiled) though this can lead to IncompatibleClassChangeError 
> problems. If these problems can be overcome, it might be possible to have 
> mixed Java/Groovy hierarchies by using stubs initially. This should be 
> explored further to understand if it is indeed possible.
> We should create a GEP which outlines what we want to do with respect to 
> Groovy support for sealed hierarchies and discuss further there how we might 
> implement the feature.
> GEP: https://groovy.apache.org/wiki/GEP-13.html



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to