rmannibucau commented on code in PR #1144:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/1144#discussion_r4131798786


##########
src/main/java/org/apache/maven/plugin/compiler/incremental/BytecodeAnalyzer.java:
##########
@@ -0,0 +1,366 @@
+/*
+ * 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.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+/**
+ * Analyzes compiled {@code .class} files using ASM to extract type references
+ * and compute bytecode-level ABI fingerprints.
+ *
+ * <p>Type references are collected from the class hierarchy, field/method
+ * descriptors, exception types, annotations, and bytecode instructions
+ * ({@code new}, {@code checkcast}, {@code instanceof}, field/method owners).
+ *
+ * <p>The bytecode ABI reflects erased types (no generics) and is computed from
+ * non-private, non-synthetic fields and methods.
+ *
+ * @see AbiExtractor
+ * @see DependencyScanner
+ */
+public class BytecodeAnalyzer {
+
+    public record ClassAnalysis(
+            String className, String abiFingerprint, String abiCanonical, 
Set<String> referencedTypes) {}
+
+    public static ClassAnalysis analyze(Path classFile) throws IOException {
+        return analyze(Files.readAllBytes(classFile));
+    }
+
+    public static ClassAnalysis analyze(byte[] classBytes) {

Review Comment:
   can't we go with classfile api only (and disable if java is too old?), this 
will bite us often enough to care I think



-- 
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