0

The Problem

I recently updated Eclipse to 2020-03 build as well as moving to another PC with my old projects. Now i have a bugging message about the Java 12 preview features missing in all of my projects.

Clean switch expressions

enter image description here

As I don't want to move from the clean new switch expressions features and the fact that it compile and run just well lately, I want to keep this. I also don't have Java 13 installed at all.

Since the projects build with Maven, they still compile with --enable preview there. But the workspace compiler still bugs me. Enabling preview features to solve it, is not possible since it's greyed out.

Project Settings

My Research

Doing some research of the case I found out that it seems like Eclipse will only support the latest Java version with preview features if you upgrade to a new version (as I did von 2019-09 to 2020-03). But I don't understand the full scope of it.

Link: https://bugs.eclipse.org/bugs/show_bug.cgi?id=549258

You can read the full discussion with the link

  • 1
    You have to set the 'Compiler Compliance level' to 13 – greg-449 Mar 28 '20 at 11:25
  • I don't have Java 13 installed and only want to use Java 12. At least Maven builds with Java 12, so why having Eclipse handle it differently? – Kongola Nasif Mar 28 '20 at 11:39
  • The preview code is only in Java 13 you can't have this in Java 12. – greg-449 Mar 28 '20 at 11:41
  • Can you link me to why that is? I think it only used Java 12 and preview code there and nothing new of 13, since this was coded last year in summer i think. – Kongola Nasif Mar 28 '20 at 12:24
  • 1
    When code was written is irrelevant. Preview features are not a concept in the Java 12 Language Specification [here](https://docs.oracle.com/javase/specs/jls/se12/html/index.html) so allowing them with compliance level 12 would be a violation of the specification. Preview features are first defined in the Java 13 Language spec - [here](https://docs.oracle.com/javase/specs/jls/se13/html/jls-1.html#jls-1.5) – greg-449 Mar 28 '20 at 12:36
  • The idea of the _Preview Feautures_ is to ship a prototype of a potential future feature as part of the standard implementation so that it will be tested by many. _Preview Features_ should not be used for code for production. In addition, Java 12 became obsolete with the release of Java 13 and should therefore no longer be used. – howlger Mar 28 '20 at 13:08
  • https://www.eclipse.org/community/eclipse_newsletter/2019/june/java12.php That is what i used back then. It's not production code, it's code only maintained and used by me right now. Since Java 12 changed a lot of accessing static private fields with Reflection I already encountered draw backs to upgrading (https://stackoverflow.com/a/44410184/10785715). That is why i'm not sure if Java 13 is backwards compatible with all i have right now. Can anyone clearify this? I would upgrade to Java 14 if it's safe. – Kongola Nasif Mar 28 '20 at 13:27
  • 1
    In Java 12 and 13 switch expressions were _Preview Feautures_. In Java 13 `break ...;` became `yield ...`. Since Java 14 switch expressions are now standard - as far as I known - without further changes. See https://openjdk.java.net/jeps/361 – howlger Mar 28 '20 at 15:37
  • Right now, I installed Java 14 and disabled preview features overall. It works so far. The question is still persistent if upgrading is the only way to fix it. – Kongola Nasif Mar 28 '20 at 23:35
  • Not to upgrade is not an option. Java 12 has reached the end of its life. Using Java 12 is now wrong. Using preview features, except for the purpose of testing them, was and is wrong. – howlger Mar 29 '20 at 15:12

0 Answers0