Sealed classes don't compile, Eclipse compiler bug?

558 Views Asked by At

I am having those two classes in Eclipse 2020-09 and 2020-12:

Class A

package test;

public sealed class A permits B { }

Class B

package test;
import java.io.Serializable;

public final class B extends A implements Serializable  { }

However, the eclipse compiler is giving me a compiler error in class B:

The type B extending a sealed class Serializable should be a permitted subtype of Serializable

This seems odd, as Serializable isn't even a sealed class. I find nothing about that in JEP-360. Removing "implements Serializable" resolves that error.

Is that a bug in the Eclipse compiler?

2

There are 2 best solutions below

0
On BEST ANSWER

In case someone else is reading this:

My bug report has been fixed for Java 16.

2
On

I do not know if eclipse does fully support this (preview feature), but have you tried to use a command line compiler? (oracle or openjdk)

I just tested that code with Java 15.0.1 and it worked fine -> seams like eclipse is still not fully supporting that

Tested it with eclipse 2020-12 on another machine (had to be started first) - same error message [:-(

much probably it is a bug