desruisseaux commented on code in PR #1162: URL: https://github.com/apache/maven-compiler-plugin/pull/1162#discussion_r4732303258
########## src/main/java24/org/apache/maven/plugin/compiler/incremental/ClassfileClassAnalyzer.java: ########## @@ -0,0 +1,510 @@ +/* + * 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.incremental; + +import java.lang.classfile.Annotation; +import java.lang.classfile.Attributes; +import java.lang.classfile.ClassFile; +import java.lang.classfile.ClassModel; +import java.lang.classfile.FieldModel; +import java.lang.classfile.MethodModel; +import java.lang.classfile.attribute.ModuleAttribute; +import java.lang.classfile.attribute.ModuleProvideInfo; +import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.instruction.FieldInstruction; +import java.lang.classfile.instruction.InvokeInstruction; +import java.lang.classfile.instruction.NewMultiArrayInstruction; +import java.lang.classfile.instruction.NewObjectInstruction; +import java.lang.classfile.instruction.TypeCheckInstruction; +import java.lang.reflect.AccessFlag; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +/** + * {@link ClassAnalyzer} implementation using the standard {@code java.lang.classfile} + * API, available since JDK 24. + * + * <p>This implementation lives in {@code META-INF/versions/24/} as part of the + * multi-release JAR. It is instantiated directly by the JDK 24+ override of + * {@link BytecodeAnalyzer} — no reflection required. On JDK < 24, the root + * {@code BytecodeAnalyzer} stub is loaded instead. + * + * <p>Type references are classified into two sets: + * <ul> + * <li><b>signatureTypes</b> — types from the public API surface: supertype, interfaces, + * field/method descriptors of non-private members, exception types, annotations. + * These are what downstream consumers structurally depend on.</li> + * <li><b>implementationTypes</b> — types referenced only in method body bytecode + * instructions (INVOKE*, field access, NEW, CHECKCAST, etc.), and descriptor + * types of private members. Changes to these do not cascade to the class's + * signature consumers.</li> + * </ul> + * + * <p>{@code module-info.class} is handled specially: its signature types are derived + * from the {@code Module} attribute directives (uses, provides), and no + * implementation types are collected. + * + * @see BytecodeAnalyzer + * @see ClassAnalyzer + */ +class ClassfileClassAnalyzer extends ClassAnalyzer { Review Comment: After the moves or removals proposed in above comments, the `BytecodeAnalyzer` contains only one method which invoke `ClassfileClassAnalyser.analyze(byte[])`. Therefore, the content of this class can be moved entirely inside `BytecodeAnalyzer` with no added complexity (it is almost just a renaming of this class). It would avoid unnecessary redirections, thus reducing the complexity in this regard. -- 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]
