manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.42k stars 125 forks source link

Add support for jdk 22 #565

Closed EotT123 closed 7 months ago

EotT123 commented 7 months ago

Compiling with jdk 22 (even if targeting 21) doesn't work at the moment, and is also not officially supported (see documentation: All fully supported in JDK LTS releases 8 - 21). Are you working on supporting it?

rsmckinney commented 7 months ago

It is supported and documented as "JDK LTS releases 8 - 21 + latest", where "latest" is whatever the latest JDK is, currently 22.

What kind of trouble are you experiencing? If you are building with IntelliJ, make sure you are using IDEA 2024.1, which is the only IJ release that supports JDK 22.

EotT123 commented 7 months ago

It doesn't work for me. Even when trying to build my small sample project doesn't work. Compiling with java 21 works fine, but errors when using java 22, both with maven and latest IntelliJ.

Output when building with maven:

[ERROR] Compilation failure: Compilation failure:
[ERROR] /java/net/URL.java:[264,35] package jdk.internal.misc does not exist
[ERROR] /java/net/URL.java:[21,29] cannot find symbol
[ERROR]   symbol:   class UrlDeserializedState
[ERROR]   location: package java.net
[ERROR] /java/lang/Object.java:[6,30] package jdk.internal.vm.annotation does not exist
[ERROR] /java/lang/Object.java:[10,30] package jdk.internal.vm.annotation does not exist
[ERROR] /java/lang/Object.java:[14,30] package jdk.internal.vm.annotation does not exist
[ERROR] /java/lang/Object.java:[21,30] package jdk.internal.vm.annotation does not exist
[ERROR] /java/lang/Object.java:[28,30] package jdk.internal.vm.annotation does not exist
[ERROR] /java/lang/Object.java:[32,30] package jdk.internal.vm.annotation does not exist
[ERROR] /java/net/URL.java:[264,78] package jdk.internal.misc does not exist
[ERROR] -> [Help 1]
[ERROR]

Maven info:

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Java version: 22, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-latest
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

When removing all manifold related things, the build works.

Building other projects results in different (but similar) error messages.

But it seems that not all builds are failing in IntelliJ. However, they are always failing when building with maven.

rsmckinney commented 7 months ago

With maven you need to change your pom file to use the maven.compiler.source/target settings and remove the source, target, and release settings from the build.

      <properties>
          <manifold.version>2024.1.10</manifold.version>
<!--  add these -->
          <maven.compiler.source>22</maven.compiler.source>
          <maven.compiler.target>22</maven.compiler.target>
      </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.12.1</version>
                <configuration>
<!--  remove these -->
<!--                    <release>22</release>-->
<!--                    <source>22</source>-->
<!--                    <target>22</target>-->
EotT123 commented 7 months ago

Thanks, that fixed it!