Selaed classes cant permit private classes

Pavel Rappo pavel.rappo at oracle.com
Mon Aug 26 13:00:46 UTC 2024


On a cursory search, I haven't found anything in JLS on that. Yet, a similar example is mentioned as if it were compilable here (it isn't): https://openjdk.org/jeps/409#Future-Work

Interestingly, if you wrap your example into a class/interface and add `static` to Tmp, the example will compile.

-Pavel

> On 26 Aug 2024, at 13:28, Olexandr Rotan <rotanolexandr842 at gmail.com> wrote:
> 
> Hello. Recently, I have started a new project to explore Babylon code reflection API (LInq), and thought that using sealed classes to represent operand type would be really suitable (function calls, column refs etc.). However, I want to only expose one interface/abstract class for each of those types, while actual implementations are private classes inside sealed classes. However, when I tried to compile something like this (simplified for brevity):
> 
> sealed class Tmp permits Tmp.A {
> 
> private static final class A extends Tmp {
> }
> }
> 
> 
> I got following error:
> error: A has private access in Tmp
> 
> 
> Is this behaviour expected or not? 
> (I would assume second since intellij code analysis didn't mark this as error)
> 
> If it's later, I would ask some JDK member to file a bug report (I noticed that they 
> are processed faster then non-member requests), and I will try to fix this. If it`s 
> premier, then what is the motivation behind this?
> 
> 



More information about the amber-dev mailing list