gnodet-bot commented on code in PR #1217:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/1217#discussion_r4727767305


##########
pom.xml:
##########
@@ -196,6 +228,48 @@ under the License.
         </plugin>
       </plugins>
     </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>enforce-java-build-version</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <requireJavaVersion>
+                  <!--
+                    Building this plugin requires JDK 24+ so that the 
java.lang.classfile
+                    classes in src/main/java24/ can always be compiled with 
-release 24.
+                    The compiled plugin JAR targets JDK 17 for main sources 
and JDK 24
+                    for the classfile-backed code, and runs on any JVM >= 17.
+                  -->
+                  <version>[24,)</version>
+                </requireJavaVersion>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+    <sources>
+      <!--
+        Main sources target JDK 17 (the minimum runtime version).
+        The JDK 22+ and 24+ override are compiled separately into
+        META-INF/versions/<version>/ to form a proper multi-release JAR.
+      -->
+      <source>
+        <directory>src/main/java</directory>
+        <targetVersion>17</targetVersion>
+      </source>
+      <source>
+        <directory>src/main/java22</directory>
+        <targetVersion>22</targetVersion>
+      </source>

Review Comment:
   ⚠️ The comment above says "JDK 22+ **and 24+** override" but 
`src/main/java24` is not declared here. If this PR is standalone (replacing 
#1158), add the java24 `<source>` entry after this one. If stacked on top of 
#1158, clarify in the PR description and fix the comment to say "JDK 22+ 
override" only.



##########
pom.xml:
##########
@@ -196,6 +228,48 @@ under the License.
         </plugin>
       </plugins>
     </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>enforce-java-build-version</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <requireJavaVersion>
+                  <!--
+                    Building this plugin requires JDK 24+ so that the 
java.lang.classfile
+                    classes in src/main/java24/ can always be compiled with 
-release 24.
+                    The compiled plugin JAR targets JDK 17 for main sources 
and JDK 24
+                    for the classfile-backed code, and runs on any JVM >= 17.
+                  -->
+                  <version>[24,)</version>

Review Comment:
   ⚠️ This comment references `src/main/java24/` and `java.lang.classfile`, but 
`src/main/java24` is not in the `<sources>` block. The comment and the `[24,)` 
minimum (JDK 22+ suffices to compile `src/main/java22`) are carried over from 
#1158 unchanged. Update to reflect what this PR actually requires.



##########
src/main/java22/org/apache/maven/plugin/compiler/ByteCodeTransformer.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugin.compiler;
+
+import org.apache.maven.api.plugin.Log;
+
+/**
+ * JDK 22+ override of the root {@code ByteCodeTransformer}.
+ * Since there is nothing to patch for version 22 and older, this method does 
nothing.
+ *
+ * <p>This class is loaded automatically by the JVM on JDK 22+ via
+ * the multi-release JAR mechanism ({@code META-INF/versions/22/}).
+ * On JDK 17–21, the root implementation backed by ASM is used instead.</p>
+ *
+ * @see <a href="https://bugs.openjdk.org/browse/JDK-8318913";>JDK-8318913</a>
+ */
+final class ByteCodeTransformer {
+    private ByteCodeTransformer() {}
+
+    /**
+     * Does nothing since JDK-8318913 is fixed in JDK 22+.
+     *
+     * @param originalBytecode the byte code to patch
+     * @return {@code null} since no change is needed
+     */

Review Comment:
   💡 `javaVersion` and `log` are not documented. Add `@param` tags for 
consistency with the root implementation.
   
   ```suggestion
       /**
        * Does nothing since JDK-8318913 is fixed in JDK 22+.
        *
        * @param originalBytecode the byte code to patch
        * @param javaVersion the target Java version (unused in this 
implementation)
        * @param log the build log (unused in this implementation)
        * @return {@code null} since no change is needed
        */
   ```



##########
src/main/java22/org/apache/maven/plugin/compiler/ByteCodeTransformer.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugin.compiler;
+
+import org.apache.maven.api.plugin.Log;
+
+/**
+ * JDK 22+ override of the root {@code ByteCodeTransformer}.
+ * Since there is nothing to patch for version 22 and older, this method does 
nothing.

Review Comment:
   💡 "this method does nothing" is in the class-level Javadoc — should refer to 
the class.
   
   ```suggestion
    * Since there is nothing to patch for JDK 22 and later, the method in this 
class does nothing.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to