You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2026/02/18 14:14:23 UTC

(skywalking-graalvm-distro) branch main updated (cb8291f -> 2040bc9)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-graalvm-distro.git


    from cb8291f  Merge phase1/build-system-setup: build infrastructure + OAL export tool
     new 9a4c809  Add OAL immigration: same-FQCN replacement classes + annotation manifests
     new daac54d  Update PLAN.md and OAL-IMMIGRATION.md for completed OAL immigration
     new 0a40450  Add MAL-IMMIGRATION.md: plan for MAL/LAL build-time pre-compilation
     new 2040bc9  Merge phase2/oal-immigration: OAL same-FQCN replacements + MAL plan

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 MAL-IMMIGRATION.md                                 | 444 +++++++++++++++++++++
 OAL-IMMIGRATION.md                                 | 161 ++++----
 PLAN.md                                            |  80 ++--
 .../server/buildtools/oal/OALClassExporter.java    |  87 +++-
 .../buildtools/oal/OALClassExporterTest.java       |  26 ++
 oap-graalvm-server/pom.xml                         |  15 +
 .../oap/server/core/annotation/AnnotationScan.java | 125 ++++++
 .../server/core/oal/rt/OALEngineLoaderService.java | 129 ++++++
 .../oap/server/core/source/SourceReceiverImpl.java | 112 ++++++
 .../graalvm/PrecompiledRegistrationTest.java       | 392 ++++++++++++++++++
 10 files changed, 1462 insertions(+), 109 deletions(-)
 create mode 100644 MAL-IMMIGRATION.md
 create mode 100644 oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/annotation/AnnotationScan.java
 create mode 100644 oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/oal/rt/OALEngineLoaderService.java
 create mode 100644 oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/source/SourceReceiverImpl.java
 create mode 100644 oap-graalvm-server/src/test/java/org/apache/skywalking/oap/server/graalvm/PrecompiledRegistrationTest.java


(skywalking-graalvm-distro) 04/04: Merge phase2/oal-immigration: OAL same-FQCN replacements + MAL plan

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-graalvm-distro.git

commit 2040bc9a9435804d8768f4c85748e168c26c8d57
Merge: cb8291f 0a40450
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Feb 18 22:06:22 2026 +0800

    Merge phase2/oal-immigration: OAL same-FQCN replacements + MAL plan

 MAL-IMMIGRATION.md                                 | 444 +++++++++++++++++++++
 OAL-IMMIGRATION.md                                 | 161 ++++----
 PLAN.md                                            |  80 ++--
 .../server/buildtools/oal/OALClassExporter.java    |  87 +++-
 .../buildtools/oal/OALClassExporterTest.java       |  26 ++
 oap-graalvm-server/pom.xml                         |  15 +
 .../oap/server/core/annotation/AnnotationScan.java | 125 ++++++
 .../server/core/oal/rt/OALEngineLoaderService.java | 129 ++++++
 .../oap/server/core/source/SourceReceiverImpl.java | 112 ++++++
 .../graalvm/PrecompiledRegistrationTest.java       | 392 ++++++++++++++++++
 10 files changed, 1462 insertions(+), 109 deletions(-)


(skywalking-graalvm-distro) 01/04: Add OAL immigration: same-FQCN replacement classes + annotation manifests

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-graalvm-distro.git

commit 9a4c809699d35130f33ea0714cab253c601cf8ad
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Feb 18 22:03:57 2026 +0800

    Add OAL immigration: same-FQCN replacement classes + annotation manifests
    
    Replace 3 upstream classes via Maven classpath precedence to eliminate
    runtime Javassist code generation and Guava ClassPath scanning:
    
    - OALEngineLoaderService: loads pre-compiled OAL classes from build-time
      manifests instead of running the OAL engine at startup
    - AnnotationScan: reads annotation manifests from META-INF/annotation-scan/
      instead of Guava ClassPath.from() scanning
    - SourceReceiverImpl: reads dispatcher/decorator manifests instead of
      Guava classpath scanning
    
    OALClassExporter enhanced to scan 6 annotation/interface types at build
    time (ScopeDeclaration, Stream, Disable, MultipleDisable, SourceDispatcher,
    ISourceDecorator) and write manifests.
    
    Verification: OALClassExporterTest (3 tests) + PrecompiledRegistrationTest
    (12 tests) covering manifest-vs-classpath comparison, class loading, scope
    registration, and source→dispatcher→metrics chain consistency.
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
 .../server/buildtools/oal/OALClassExporter.java    |  87 ++++-
 .../buildtools/oal/OALClassExporterTest.java       |  26 ++
 oap-graalvm-server/pom.xml                         |  15 +
 .../oap/server/core/annotation/AnnotationScan.java | 125 +++++++
 .../server/core/oal/rt/OALEngineLoaderService.java | 129 +++++++
 .../oap/server/core/source/SourceReceiverImpl.java | 112 ++++++
 .../graalvm/PrecompiledRegistrationTest.java       | 392 +++++++++++++++++++++
 7 files changed, 881 insertions(+), 5 deletions(-)

diff --git a/build-tools/oal-exporter/src/main/java/org/apache/skywalking/oap/server/buildtools/oal/OALClassExporter.java b/build-tools/oal-exporter/src/main/java/org/apache/skywalking/oap/server/buildtools/oal/OALClassExporter.java
index ded57e7..614763d 100644
--- a/build-tools/oal-exporter/src/main/java/org/apache/skywalking/oap/server/buildtools/oal/OALClassExporter.java
+++ b/build-tools/oal-exporter/src/main/java/org/apache/skywalking/oap/server/buildtools/oal/OALClassExporter.java
@@ -17,8 +17,12 @@
 
 package org.apache.skywalking.oap.server.buildtools.oal;
 
+import com.google.common.collect.ImmutableSet;
+import com.google.common.reflect.ClassPath;
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -31,12 +35,17 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.skywalking.aop.server.receiver.mesh.MeshOALDefine;
 import org.apache.skywalking.oal.v2.OALEngineV2;
 import org.apache.skywalking.oal.v2.generator.OALClassGeneratorV2;
+import org.apache.skywalking.oap.server.core.analysis.Disable;
 import org.apache.skywalking.oap.server.core.analysis.DisableRegister;
+import org.apache.skywalking.oap.server.core.analysis.ISourceDecorator;
+import org.apache.skywalking.oap.server.core.analysis.MultipleDisable;
+import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
 import org.apache.skywalking.oap.server.core.annotation.AnnotationScan;
 import org.apache.skywalking.oap.server.core.oal.rt.CoreOALDefine;
 import org.apache.skywalking.oap.server.core.oal.rt.DisableOALDefine;
 import org.apache.skywalking.oap.server.core.oal.rt.OALDefine;
 import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
+import org.apache.skywalking.oap.server.core.source.ScopeDeclaration;
 import org.apache.skywalking.oap.server.core.storage.StorageBuilderFactory;
 import org.apache.skywalking.oap.server.fetcher.cilium.CiliumOALDefine;
 import org.apache.skywalking.oap.server.receiver.browser.provider.BrowserOALDefine;
@@ -47,13 +56,11 @@ import org.apache.skywalking.oap.server.receiver.jvm.provider.JVMOALDefine;
 
 /**
  * Build-time tool that runs the OAL engine for all 9 OALDefine configurations,
- * exports generated .class files (metrics, builders, dispatchers), and writes
- * manifest files listing all generated class names.
+ * exports generated .class files and manifest files, and scans the classpath for
+ * hardcoded annotated classes and interface implementations used at runtime.
  *
  * OAL script files are loaded from the skywalking submodule directly via
  * additionalClasspathElements in the exec-maven-plugin configuration.
- *
- * Uses the existing SW_OAL_ENGINE_DEBUG export mechanism in OALClassGeneratorV2.
  */
 @Slf4j
 public class OALClassExporter {
@@ -129,8 +136,31 @@ public class OALClassExporter {
         writeManifest(metaInf.resolve("oal-dispatcher-classes.txt"), dispatcherClasses);
         writeManifest(metaInf.resolve("oal-disabled-sources.txt"), disabledSources);
 
-        log.info("OAL Class Exporter: done - {} metrics, {} dispatchers, {} disabled sources",
+        log.info("OAL Class Exporter: {} metrics, {} dispatchers, {} disabled sources",
             metricsClasses.size(), dispatcherClasses.size(), disabledSources.size());
+
+        // ---- Annotation & interface scanning for hardcoded classes ----
+        Path annotationScanDir = metaInf.resolve("annotation-scan");
+        Files.createDirectories(annotationScanDir);
+
+        ImmutableSet<ClassPath.ClassInfo> allClasses = ClassPath
+            .from(OALClassExporter.class.getClassLoader())
+            .getTopLevelClassesRecursive("org.apache.skywalking");
+
+        writeManifest(annotationScanDir.resolve("ScopeDeclaration.txt"),
+            scanAnnotation(allClasses, ScopeDeclaration.class));
+        writeManifest(annotationScanDir.resolve("Stream.txt"),
+            scanAnnotation(allClasses, org.apache.skywalking.oap.server.core.analysis.Stream.class));
+        writeManifest(annotationScanDir.resolve("Disable.txt"),
+            scanAnnotation(allClasses, Disable.class));
+        writeManifest(annotationScanDir.resolve("MultipleDisable.txt"),
+            scanAnnotation(allClasses, MultipleDisable.class));
+        writeManifest(annotationScanDir.resolve("SourceDispatcher.txt"),
+            scanInterface(allClasses, SourceDispatcher.class));
+        writeManifest(annotationScanDir.resolve("ISourceDecorator.txt"),
+            scanInterface(allClasses, ISourceDecorator.class));
+
+        log.info("OAL Class Exporter: done");
     }
 
     /**
@@ -195,6 +225,53 @@ public class OALClassExporter {
         return result;
     }
 
+    /**
+     * Scan for classes annotated with the given annotation type.
+     */
+    private static List<String> scanAnnotation(
+        ImmutableSet<ClassPath.ClassInfo> allClasses,
+        Class<? extends Annotation> annotationType) {
+
+        List<String> result = new ArrayList<>();
+        for (ClassPath.ClassInfo classInfo : allClasses) {
+            try {
+                Class<?> aClass = classInfo.load();
+                if (aClass.isAnnotationPresent(annotationType)) {
+                    result.add(aClass.getName());
+                }
+            } catch (NoClassDefFoundError | Exception ignored) {
+                // Some classes may fail to load due to missing optional dependencies
+            }
+        }
+        Collections.sort(result);
+        log.info("Scanned @{}: {} classes", annotationType.getSimpleName(), result.size());
+        return result;
+    }
+
+    /**
+     * Scan for concrete classes implementing the given interface.
+     */
+    private static List<String> scanInterface(
+        ImmutableSet<ClassPath.ClassInfo> allClasses, Class<?> interfaceType) {
+
+        List<String> result = new ArrayList<>();
+        for (ClassPath.ClassInfo classInfo : allClasses) {
+            try {
+                Class<?> aClass = classInfo.load();
+                if (!aClass.isInterface()
+                    && !Modifier.isAbstract(aClass.getModifiers())
+                    && interfaceType.isAssignableFrom(aClass)) {
+                    result.add(aClass.getName());
+                }
+            } catch (NoClassDefFoundError | Exception ignored) {
+                // Some classes may fail to load due to missing optional dependencies
+            }
+        }
+        Collections.sort(result);
+        log.info("Scanned {}: {} classes", interfaceType.getSimpleName(), result.size());
+        return result;
+    }
+
     private static void writeManifest(Path path, List<String> lines) throws IOException {
         Files.write(path, lines, StandardCharsets.UTF_8);
     }
diff --git a/build-tools/oal-exporter/src/test/java/org/apache/skywalking/oap/server/buildtools/oal/OALClassExporterTest.java b/build-tools/oal-exporter/src/test/java/org/apache/skywalking/oap/server/buildtools/oal/OALClassExporterTest.java
index 27a1866..8384d51 100644
--- a/build-tools/oal-exporter/src/test/java/org/apache/skywalking/oap/server/buildtools/oal/OALClassExporterTest.java
+++ b/build-tools/oal-exporter/src/test/java/org/apache/skywalking/oap/server/buildtools/oal/OALClassExporterTest.java
@@ -126,5 +126,31 @@ class OALClassExporterTest {
         // Verify disabled sources manifest exists (may be empty when all disable() calls are commented out)
         Path disabledManifest = tempDir.resolve("META-INF/oal-disabled-sources.txt");
         assertTrue(Files.exists(disabledManifest), "disabled sources manifest should exist");
+
+        // Verify annotation scan manifests
+        Path annotationScanDir = tempDir.resolve("META-INF/annotation-scan");
+        assertTrue(Files.isDirectory(annotationScanDir), "annotation-scan directory should exist");
+
+        assertManifestNotEmpty(annotationScanDir, "ScopeDeclaration.txt");
+        assertManifestNotEmpty(annotationScanDir, "Stream.txt");
+        assertManifestNotEmpty(annotationScanDir, "SourceDispatcher.txt");
+        assertManifestNotEmpty(annotationScanDir, "ISourceDecorator.txt");
+
+        // Disable/MultipleDisable manifests exist but may be empty (no classes use these annotations currently)
+        assertTrue(
+            Files.exists(annotationScanDir.resolve("Disable.txt")),
+            "Disable manifest should exist"
+        );
+        assertTrue(
+            Files.exists(annotationScanDir.resolve("MultipleDisable.txt")),
+            "MultipleDisable manifest should exist"
+        );
+    }
+
+    private void assertManifestNotEmpty(Path dir, String fileName) throws Exception {
+        Path manifest = dir.resolve(fileName);
+        assertTrue(Files.exists(manifest), fileName + " should exist");
+        List<String> lines = Files.readAllLines(manifest);
+        assertFalse(lines.isEmpty(), fileName + " should not be empty");
     }
 }
diff --git a/oap-graalvm-server/pom.xml b/oap-graalvm-server/pom.xml
index dfc7881..37dec83 100644
--- a/oap-graalvm-server/pom.xml
+++ b/oap-graalvm-server/pom.xml
@@ -241,10 +241,25 @@
             <artifactId>server-starter</artifactId>
         </dependency>
 
+        <!-- Pre-compiled OAL classes + annotation manifests from build-time export -->
+        <dependency>
+            <groupId>org.apache.skywalking</groupId>
+            <artifactId>oal-exporter</artifactId>
+            <version>${project.version}</version>
+            <classifier>generated</classifier>
+        </dependency>
+
         <!-- Lombok -->
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
         </dependency>
+
+        <!-- Test -->
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
\ No newline at end of file
diff --git a/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/annotation/AnnotationScan.java b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/annotation/AnnotationScan.java
new file mode 100644
index 0000000..9ec96fa
--- /dev/null
+++ b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/annotation/AnnotationScan.java
@@ -0,0 +1,125 @@
+/*
+ * 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.skywalking.oap.server.core.annotation;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.annotation.Annotation;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.storage.StorageException;
+
+/**
+ * GraalVM replacement for upstream AnnotationScan.
+ * Same FQCN — shadows the upstream class via Maven classpath precedence.
+ *
+ * Instead of Guava ClassPath scanning, reads pre-built manifest files
+ * produced by OALClassExporter at build time.
+ * Manifest path: META-INF/annotation-scan/{AnnotationSimpleName}.txt
+ */
+@Slf4j
+public class AnnotationScan {
+
+    private static final String MANIFEST_PREFIX = "META-INF/annotation-scan/";
+
+    private final List<AnnotationListenerCache> listeners;
+
+    public AnnotationScan() {
+        this.listeners = new LinkedList<>();
+    }
+
+    public void registerListener(AnnotationListener listener) {
+        listeners.add(new AnnotationListenerCache(listener));
+    }
+
+    public void scan() throws IOException, StorageException {
+        for (AnnotationListenerCache listener : listeners) {
+            String annotationName = listener.annotation().getSimpleName();
+            String manifestPath = MANIFEST_PREFIX + annotationName + ".txt";
+
+            List<String> classNames = readManifest(manifestPath);
+            for (String className : classNames) {
+                try {
+                    Class<?> aClass = Class.forName(className);
+                    if (aClass.isAnnotationPresent(listener.annotation())) {
+                        listener.addMatch(aClass);
+                    }
+                } catch (ClassNotFoundException e) {
+                    log.warn("Class not found from manifest {}: {}", manifestPath, className);
+                }
+            }
+        }
+
+        for (AnnotationListenerCache listener : listeners) {
+            listener.complete();
+        }
+    }
+
+    private static List<String> readManifest(String resourcePath) throws IOException {
+        List<String> lines = new ArrayList<>();
+        ClassLoader cl = AnnotationScan.class.getClassLoader();
+        try (InputStream is = cl.getResourceAsStream(resourcePath)) {
+            if (is == null) {
+                log.warn("Annotation manifest not found: {}", resourcePath);
+                return lines;
+            }
+            try (BufferedReader reader = new BufferedReader(
+                new InputStreamReader(is, StandardCharsets.UTF_8))) {
+                String line;
+                while ((line = reader.readLine()) != null) {
+                    line = line.trim();
+                    if (!line.isEmpty()) {
+                        lines.add(line);
+                    }
+                }
+            }
+        }
+        return lines;
+    }
+
+    private static class AnnotationListenerCache {
+        private final AnnotationListener listener;
+        private final List<Class<?>> matchedClass;
+
+        private AnnotationListenerCache(AnnotationListener listener) {
+            this.listener = listener;
+            this.matchedClass = new LinkedList<>();
+        }
+
+        private Class<? extends Annotation> annotation() {
+            return this.listener.annotation();
+        }
+
+        private void addMatch(Class<?> aClass) {
+            matchedClass.add(aClass);
+        }
+
+        private void complete() throws StorageException {
+            matchedClass.sort(Comparator.comparing(Class::getName));
+            for (Class<?> aClass : matchedClass) {
+                listener.notify(aClass);
+            }
+        }
+    }
+}
diff --git a/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/oal/rt/OALEngineLoaderService.java b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/oal/rt/OALEngineLoaderService.java
new file mode 100644
index 0000000..fa40c7b
--- /dev/null
+++ b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/oal/rt/OALEngineLoaderService.java
@@ -0,0 +1,129 @@
+/*
+ * 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.skywalking.oap.server.core.oal.rt;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.analysis.DisableRegister;
+import org.apache.skywalking.oap.server.core.analysis.StreamAnnotationListener;
+import org.apache.skywalking.oap.server.core.source.SourceReceiver;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+import org.apache.skywalking.oap.server.library.module.ModuleStartException;
+import org.apache.skywalking.oap.server.library.module.Service;
+
+/**
+ * GraalVM replacement for upstream OALEngineLoaderService.
+ * Same FQCN — shadows the upstream class via Maven classpath precedence.
+ *
+ * Instead of running the OAL engine (Javassist code generation) at runtime,
+ * loads pre-compiled classes from build-time manifests produced by OALClassExporter.
+ */
+@Slf4j
+public class OALEngineLoaderService implements Service {
+
+    private static final String METRICS_MANIFEST = "META-INF/oal-metrics-classes.txt";
+    private static final String DISPATCHER_MANIFEST = "META-INF/oal-dispatcher-classes.txt";
+    private static final String DISABLED_MANIFEST = "META-INF/oal-disabled-sources.txt";
+
+    private final Set<OALDefine> oalDefineSet = new HashSet<>();
+    private final ModuleManager moduleManager;
+    private boolean loaded;
+
+    public OALEngineLoaderService(ModuleManager moduleManager) {
+        this.moduleManager = moduleManager;
+    }
+
+    public void load(OALDefine define) throws ModuleStartException {
+        if (oalDefineSet.contains(define)) {
+            return;
+        }
+
+        if (!loaded) {
+            loadAllPrecompiledClasses();
+            loaded = true;
+        }
+
+        oalDefineSet.add(define);
+    }
+
+    private void loadAllPrecompiledClasses() throws ModuleStartException {
+        try {
+            // 1. Register disabled sources before processing metrics
+            List<String> disabledSources = readManifest(DISABLED_MANIFEST);
+            for (String name : disabledSources) {
+                DisableRegister.INSTANCE.add(name);
+            }
+            log.info("Loaded {} disabled sources from manifest", disabledSources.size());
+
+            // 2. Load and register pre-compiled metrics classes
+            StreamAnnotationListener streamListener = new StreamAnnotationListener(moduleManager);
+            List<String> metricsClassNames = readManifest(METRICS_MANIFEST);
+            for (String className : metricsClassNames) {
+                Class<?> metricsClass = Class.forName(className);
+                streamListener.notify(metricsClass);
+            }
+            log.info("Registered {} pre-compiled OAL metrics classes", metricsClassNames.size());
+
+            // 3. Load and register pre-compiled dispatcher classes
+            var dispatcherListener = moduleManager.find(CoreModule.NAME)
+                                                  .provider()
+                                                  .getService(SourceReceiver.class)
+                                                  .getDispatcherDetectorListener();
+            List<String> dispatcherClassNames = readManifest(DISPATCHER_MANIFEST);
+            for (String className : dispatcherClassNames) {
+                Class<?> dispatcherClass = Class.forName(className);
+                dispatcherListener.addIfAsSourceDispatcher(dispatcherClass);
+            }
+            log.info("Registered {} pre-compiled OAL dispatcher classes", dispatcherClassNames.size());
+
+        } catch (Exception e) {
+            throw new ModuleStartException("Failed to load pre-compiled OAL classes", e);
+        }
+    }
+
+    private static List<String> readManifest(String resourcePath) throws IOException {
+        List<String> lines = new ArrayList<>();
+        ClassLoader cl = OALEngineLoaderService.class.getClassLoader();
+        try (InputStream is = cl.getResourceAsStream(resourcePath)) {
+            if (is == null) {
+                log.warn("Manifest not found: {}", resourcePath);
+                return lines;
+            }
+            try (BufferedReader reader = new BufferedReader(
+                new InputStreamReader(is, StandardCharsets.UTF_8))) {
+                String line;
+                while ((line = reader.readLine()) != null) {
+                    line = line.trim();
+                    if (!line.isEmpty()) {
+                        lines.add(line);
+                    }
+                }
+            }
+        }
+        return lines;
+    }
+}
diff --git a/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/source/SourceReceiverImpl.java b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/source/SourceReceiverImpl.java
new file mode 100644
index 0000000..08c7b02
--- /dev/null
+++ b/oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/core/source/SourceReceiverImpl.java
@@ -0,0 +1,112 @@
+/*
+ * 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.skywalking.oap.server.core.source;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.analysis.DispatcherDetectorListener;
+import org.apache.skywalking.oap.server.core.analysis.DispatcherManager;
+import org.apache.skywalking.oap.server.core.analysis.SourceDecoratorManager;
+
+/**
+ * GraalVM replacement for upstream SourceReceiverImpl.
+ * Same FQCN — shadows the upstream class via Maven classpath precedence.
+ *
+ * Instead of Guava ClassPath scanning, reads pre-built manifest files
+ * produced by OALClassExporter at build time.
+ */
+@Slf4j
+public class SourceReceiverImpl implements SourceReceiver {
+
+    private static final String DISPATCHER_MANIFEST = "META-INF/annotation-scan/SourceDispatcher.txt";
+    private static final String DECORATOR_MANIFEST = "META-INF/annotation-scan/ISourceDecorator.txt";
+
+    @Getter
+    private final DispatcherManager dispatcherManager;
+
+    @Getter
+    private final SourceDecoratorManager sourceDecoratorManager;
+
+    public SourceReceiverImpl() {
+        this.dispatcherManager = new DispatcherManager();
+        this.sourceDecoratorManager = new SourceDecoratorManager();
+    }
+
+    @Override
+    public void receive(ISource source) {
+        dispatcherManager.forward(source);
+    }
+
+    @Override
+    public DispatcherDetectorListener getDispatcherDetectorListener() {
+        return getDispatcherManager();
+    }
+
+    public void scan() throws IOException, InstantiationException, IllegalAccessException {
+        List<String> dispatcherNames = readManifest(DISPATCHER_MANIFEST);
+        for (String className : dispatcherNames) {
+            try {
+                Class<?> aClass = Class.forName(className);
+                dispatcherManager.addIfAsSourceDispatcher(aClass);
+            } catch (ClassNotFoundException e) {
+                log.warn("Dispatcher class not found: {}", className);
+            }
+        }
+        log.info("Registered {} source dispatchers from manifest", dispatcherNames.size());
+
+        List<String> decoratorNames = readManifest(DECORATOR_MANIFEST);
+        for (String className : decoratorNames) {
+            try {
+                Class<?> aClass = Class.forName(className);
+                sourceDecoratorManager.addIfAsSourceDecorator(aClass);
+            } catch (ClassNotFoundException e) {
+                log.warn("Decorator class not found: {}", className);
+            }
+        }
+        log.info("Registered {} source decorators from manifest", decoratorNames.size());
+    }
+
+    private static List<String> readManifest(String resourcePath) throws IOException {
+        List<String> lines = new ArrayList<>();
+        ClassLoader cl = SourceReceiverImpl.class.getClassLoader();
+        try (InputStream is = cl.getResourceAsStream(resourcePath)) {
+            if (is == null) {
+                log.warn("Manifest not found: {}", resourcePath);
+                return lines;
+            }
+            try (BufferedReader reader = new BufferedReader(
+                new InputStreamReader(is, StandardCharsets.UTF_8))) {
+                String line;
+                while ((line = reader.readLine()) != null) {
+                    line = line.trim();
+                    if (!line.isEmpty()) {
+                        lines.add(line);
+                    }
+                }
+            }
+        }
+        return lines;
+    }
+}
diff --git a/oap-graalvm-server/src/test/java/org/apache/skywalking/oap/server/graalvm/PrecompiledRegistrationTest.java b/oap-graalvm-server/src/test/java/org/apache/skywalking/oap/server/graalvm/PrecompiledRegistrationTest.java
new file mode 100644
index 0000000..eafa1c0
--- /dev/null
+++ b/oap-graalvm-server/src/test/java/org/apache/skywalking/oap/server/graalvm/PrecompiledRegistrationTest.java
@@ -0,0 +1,392 @@
+/*
+ * 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.skywalking.oap.server.graalvm;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.reflect.ClassPath;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import org.apache.skywalking.oap.server.core.analysis.ISourceDecorator;
+import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
+import org.apache.skywalking.oap.server.core.analysis.Stream;
+import org.apache.skywalking.oap.server.core.annotation.AnnotationScan;
+import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
+import org.apache.skywalking.oap.server.core.source.ISource;
+import org.apache.skywalking.oap.server.core.source.ScopeDeclaration;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+/**
+ * Verifies that pre-compiled manifests produced by OALClassExporter are complete
+ * and consistent. Checks:
+ * 1. Manifest contents match live Guava ClassPath scan (for hardcoded classes)
+ * 2. All OAL-generated classes are loadable and properly annotated
+ * 3. DefaultScopeDefine initializes correctly from manifests
+ * 4. Source -> Dispatcher -> Metrics chain is consistent
+ */
+class PrecompiledRegistrationTest {
+
+    private static final String OAL_RT_PACKAGE =
+        "org.apache.skywalking.oap.server.core.source.oal.rt.";
+
+    @BeforeAll
+    static void initScopeDefine() throws Exception {
+        DefaultScopeDefine.reset();
+        AnnotationScan scopeScan = new AnnotationScan();
+        scopeScan.registerListener(new DefaultScopeDefine.Listener());
+        scopeScan.scan();
+    }
+
+    @AfterAll
+    static void cleanUp() {
+        DefaultScopeDefine.reset();
+    }
+
+    // =========================================================================
+    // 1. Manifest vs Guava ClassPath comparison (hardcoded classes only)
+    // =========================================================================
+
+    @Test
+    void scopeDeclarationManifestMatchesClasspath() throws Exception {
+        Set<String> manifest = readManifestAsSet("META-INF/annotation-scan/ScopeDeclaration.txt");
+        Set<String> scanned = guavaScanAnnotation(ScopeDeclaration.class);
+        assertFalse(manifest.isEmpty(), "ScopeDeclaration manifest is empty");
+        assertEquals(scanned, manifest,
+            "ScopeDeclaration manifest does not match classpath scan");
+    }
+
+    @Test
+    void hardcodedStreamManifestMatchesClasspath() throws Exception {
+        Set<String> manifest = readManifestAsSet("META-INF/annotation-scan/Stream.txt");
+        Set<String> scanned = guavaScanAnnotation(Stream.class);
+        // Filter out OAL-generated classes from Guava scan
+        scanned.removeIf(name -> name.startsWith(OAL_RT_PACKAGE));
+        assertFalse(manifest.isEmpty(), "Stream manifest is empty");
+        assertEquals(scanned, manifest,
+            "Hardcoded @Stream manifest does not match classpath scan");
+    }
+
+    @Test
+    void sourceDispatcherManifestMatchesClasspath() throws Exception {
+        Set<String> manifest = readManifestAsSet("META-INF/annotation-scan/SourceDispatcher.txt");
+        Set<String> scanned = guavaScanInterface(SourceDispatcher.class);
+        // Filter out OAL-generated dispatchers from Guava scan
+        scanned.removeIf(name -> name.startsWith(OAL_RT_PACKAGE));
+        assertFalse(manifest.isEmpty(), "SourceDispatcher manifest is empty");
+        assertEquals(scanned, manifest,
+            "SourceDispatcher manifest does not match classpath scan");
+    }
+
+    @Test
+    void sourceDecoratorManifestMatchesClasspath() throws Exception {
+        Set<String> manifest = readManifestAsSet("META-INF/annotation-scan/ISourceDecorator.txt");
+        Set<String> scanned = guavaScanInterface(ISourceDecorator.class);
+        assertFalse(manifest.isEmpty(), "ISourceDecorator manifest is empty");
+        assertEquals(scanned, manifest,
+            "ISourceDecorator manifest does not match classpath scan");
+    }
+
+    // =========================================================================
+    // 2. OAL-generated classes: loadable and properly annotated
+    // =========================================================================
+
+    @Test
+    void allOalMetricsClassesLoadAndHaveStreamAnnotation() throws Exception {
+        List<String> classes = readManifest("META-INF/oal-metrics-classes.txt");
+        assertFalse(classes.isEmpty(), "OAL metrics manifest is empty");
+        for (String className : classes) {
+            Class<?> clazz = Class.forName(className);
+            assertTrue(clazz.isAnnotationPresent(Stream.class),
+                "OAL metrics class missing @Stream: " + className);
+        }
+    }
+
+    @Test
+    void allOalDispatcherClassesLoadAndImplementInterface() throws Exception {
+        List<String> classes = readManifest("META-INF/oal-dispatcher-classes.txt");
+        assertFalse(classes.isEmpty(), "OAL dispatcher manifest is empty");
+        for (String className : classes) {
+            Class<?> clazz = Class.forName(className);
+            assertTrue(SourceDispatcher.class.isAssignableFrom(clazz),
+                "OAL dispatcher doesn't implement SourceDispatcher: " + className);
+        }
+    }
+
+    // =========================================================================
+    // 3. Scope registration verification
+    // =========================================================================
+
+    @Test
+    void allDeclaredScopesRegisteredInDefaultScopeDefine() throws Exception {
+        List<String> classes = readManifest("META-INF/annotation-scan/ScopeDeclaration.txt");
+        for (String className : classes) {
+            Class<?> clazz = Class.forName(className);
+            ScopeDeclaration decl = clazz.getAnnotation(ScopeDeclaration.class);
+            assertNotNull(decl, "Missing @ScopeDeclaration on " + className);
+
+            String registeredName = DefaultScopeDefine.nameOf(decl.id());
+            assertEquals(decl.name(), registeredName,
+                "Scope name mismatch for id=" + decl.id() + " on " + className);
+        }
+    }
+
+    @Test
+    void wellKnownScopesAreRegistered() {
+        // Verify essential scopes exist after manifest-based initialization
+        assertNotNull(DefaultScopeDefine.nameOf(DefaultScopeDefine.SERVICE));
+        assertNotNull(DefaultScopeDefine.nameOf(DefaultScopeDefine.SERVICE_INSTANCE));
+        assertNotNull(DefaultScopeDefine.nameOf(DefaultScopeDefine.ENDPOINT));
+    }
+
+    // =========================================================================
+    // 4. Source -> Dispatcher -> Metrics chain
+    // =========================================================================
+
+    @Test
+    void allStreamAnnotationsReferenceValidScopes() throws Exception {
+        // Check hardcoded @Stream classes
+        List<String> hardcoded = readManifest("META-INF/annotation-scan/Stream.txt");
+        for (String className : hardcoded) {
+            Class<?> clazz = Class.forName(className);
+            Stream stream = clazz.getAnnotation(Stream.class);
+            assertNotNull(stream, "Missing @Stream on " + className);
+            assertScopeExists(stream.scopeId(), className);
+        }
+
+        // Check OAL-generated @Stream classes
+        List<String> oalMetrics = readManifest("META-INF/oal-metrics-classes.txt");
+        for (String className : oalMetrics) {
+            Class<?> clazz = Class.forName(className);
+            Stream stream = clazz.getAnnotation(Stream.class);
+            assertNotNull(stream, "Missing @Stream on OAL class " + className);
+            assertScopeExists(stream.scopeId(), className);
+        }
+    }
+
+    @Test
+    @SuppressWarnings("deprecation")
+    void hardcodedDispatchersHaveDeclaredSourceScopes() throws Exception {
+        List<String> dispatchers = readManifest("META-INF/annotation-scan/SourceDispatcher.txt");
+        for (String className : dispatchers) {
+            Class<?> clazz = Class.forName(className);
+            Class<?> sourceType = extractSourceType(clazz);
+            if (sourceType == null) {
+                fail("Cannot extract source type from " + className);
+            }
+            ISource source = (ISource) sourceType.newInstance();
+            int scopeId = source.scope();
+            assertScopeExists(scopeId,
+                className + " (source=" + sourceType.getSimpleName() + ")");
+        }
+    }
+
+    @Test
+    @SuppressWarnings("deprecation")
+    void oalDispatchersHaveDeclaredSourceScopes() throws Exception {
+        List<String> dispatchers = readManifest("META-INF/oal-dispatcher-classes.txt");
+        for (String className : dispatchers) {
+            Class<?> clazz = Class.forName(className);
+            Class<?> sourceType = extractSourceType(clazz);
+            if (sourceType == null) {
+                fail("Cannot extract source type from " + className);
+            }
+            ISource source = (ISource) sourceType.newInstance();
+            int scopeId = source.scope();
+            assertScopeExists(scopeId,
+                className + " (source=" + sourceType.getSimpleName() + ")");
+        }
+    }
+
+    @Test
+    void knownScopesHaveDispatchersAndStreamMetrics() throws Exception {
+        // Build scope -> dispatchers map from both hardcoded and OAL manifests
+        Map<Integer, List<String>> scopeDispatchers = buildScopeDispatcherMap();
+
+        // Build scope -> @Stream metrics map from both hardcoded and OAL manifests
+        Map<Integer, List<String>> scopeStreams = buildScopeStreamMap();
+
+        // Verify key scopes have both dispatchers and stream metrics
+        int[] keyScopeIds = {
+            DefaultScopeDefine.SERVICE,
+            DefaultScopeDefine.ENDPOINT,
+            DefaultScopeDefine.SERVICE_INSTANCE,
+            DefaultScopeDefine.SERVICE_RELATION,
+        };
+
+        for (int scopeId : keyScopeIds) {
+            String scopeName = DefaultScopeDefine.nameOf(scopeId);
+
+            assertTrue(
+                scopeDispatchers.containsKey(scopeId)
+                    && !scopeDispatchers.get(scopeId).isEmpty(),
+                "Scope " + scopeName + " (id=" + scopeId + ") has no dispatchers"
+            );
+
+            assertTrue(
+                scopeStreams.containsKey(scopeId)
+                    && !scopeStreams.get(scopeId).isEmpty(),
+                "Scope " + scopeName + " (id=" + scopeId + ") has no @Stream metrics"
+            );
+        }
+    }
+
+    // =========================================================================
+    // Helpers
+    // =========================================================================
+
+    private static void assertScopeExists(int scopeId, String context) {
+        try {
+            DefaultScopeDefine.nameOf(scopeId);
+        } catch (Exception e) {
+            fail("Invalid scope id=" + scopeId + " referenced by " + context);
+        }
+    }
+
+    @SuppressWarnings("deprecation")
+    private Map<Integer, List<String>> buildScopeDispatcherMap() throws Exception {
+        Map<Integer, List<String>> map = new HashMap<>();
+
+        List<String> allDispatchers = new ArrayList<>();
+        allDispatchers.addAll(readManifest("META-INF/annotation-scan/SourceDispatcher.txt"));
+        allDispatchers.addAll(readManifest("META-INF/oal-dispatcher-classes.txt"));
+
+        for (String className : allDispatchers) {
+            Class<?> clazz = Class.forName(className);
+            Class<?> sourceType = extractSourceType(clazz);
+            if (sourceType != null) {
+                ISource source = (ISource) sourceType.newInstance();
+                map.computeIfAbsent(source.scope(), k -> new ArrayList<>()).add(className);
+            }
+        }
+        return map;
+    }
+
+    private Map<Integer, List<String>> buildScopeStreamMap() throws Exception {
+        Map<Integer, List<String>> map = new HashMap<>();
+
+        List<String> allStreams = new ArrayList<>();
+        allStreams.addAll(readManifest("META-INF/annotation-scan/Stream.txt"));
+        allStreams.addAll(readManifest("META-INF/oal-metrics-classes.txt"));
+
+        for (String className : allStreams) {
+            Class<?> clazz = Class.forName(className);
+            Stream stream = clazz.getAnnotation(Stream.class);
+            if (stream != null) {
+                map.computeIfAbsent(stream.scopeId(), k -> new ArrayList<>()).add(className);
+            }
+        }
+        return map;
+    }
+
+    private static Class<?> extractSourceType(Class<?> dispatcherClass) {
+        for (Type genericInterface : dispatcherClass.getGenericInterfaces()) {
+            if (genericInterface instanceof ParameterizedType) {
+                ParameterizedType parameterized = (ParameterizedType) genericInterface;
+                if (parameterized.getRawType().getTypeName().equals(
+                    SourceDispatcher.class.getName())) {
+                    Type[] args = parameterized.getActualTypeArguments();
+                    if (args.length == 1 && args[0] instanceof Class<?>) {
+                        return (Class<?>) args[0];
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    private static Set<String> guavaScanAnnotation(
+        Class<? extends java.lang.annotation.Annotation> annotationType) throws IOException {
+        ClassPath classpath = ClassPath.from(
+            PrecompiledRegistrationTest.class.getClassLoader());
+        ImmutableSet<ClassPath.ClassInfo> classes =
+            classpath.getTopLevelClassesRecursive("org.apache.skywalking");
+        Set<String> result = new TreeSet<>();
+        for (ClassPath.ClassInfo info : classes) {
+            try {
+                Class<?> clazz = info.load();
+                if (clazz.isAnnotationPresent(annotationType)) {
+                    result.add(clazz.getName());
+                }
+            } catch (NoClassDefFoundError | Exception ignored) {
+            }
+        }
+        return result;
+    }
+
+    private static Set<String> guavaScanInterface(Class<?> interfaceType) throws IOException {
+        ClassPath classpath = ClassPath.from(
+            PrecompiledRegistrationTest.class.getClassLoader());
+        ImmutableSet<ClassPath.ClassInfo> classes =
+            classpath.getTopLevelClassesRecursive("org.apache.skywalking");
+        Set<String> result = new TreeSet<>();
+        for (ClassPath.ClassInfo info : classes) {
+            try {
+                Class<?> clazz = info.load();
+                if (!clazz.isInterface()
+                    && !Modifier.isAbstract(clazz.getModifiers())
+                    && interfaceType.isAssignableFrom(clazz)) {
+                    result.add(clazz.getName());
+                }
+            } catch (NoClassDefFoundError | Exception ignored) {
+            }
+        }
+        return result;
+    }
+
+    private static Set<String> readManifestAsSet(String resourcePath) throws IOException {
+        return new TreeSet<>(readManifest(resourcePath));
+    }
+
+    private static List<String> readManifest(String resourcePath) throws IOException {
+        List<String> lines = new ArrayList<>();
+        ClassLoader cl = PrecompiledRegistrationTest.class.getClassLoader();
+        try (InputStream is = cl.getResourceAsStream(resourcePath)) {
+            assertNotNull(is, "Manifest not found: " + resourcePath);
+            try (BufferedReader reader = new BufferedReader(
+                new InputStreamReader(is, StandardCharsets.UTF_8))) {
+                String line;
+                while ((line = reader.readLine()) != null) {
+                    line = line.trim();
+                    if (!line.isEmpty()) {
+                        lines.add(line);
+                    }
+                }
+            }
+        }
+        return lines;
+    }
+}


(skywalking-graalvm-distro) 02/04: Update PLAN.md and OAL-IMMIGRATION.md for completed OAL immigration

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-graalvm-distro.git

commit daac54d3d8783a748672ce9af94097bf609917b4
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Feb 18 22:04:20 2026 +0800

    Update PLAN.md and OAL-IMMIGRATION.md for completed OAL immigration
    
    PLAN.md:
    - Phase 1 marked COMPLETE, Phase 2 split into done/remaining items
    - Challenge 1 (OAL) marked SOLVED with implementation details
    - Challenge 2 (MAL/LAL) rewritten to reflect actual architecture
    - Challenge 3 marked PARTIALLY SOLVED (AnnotationScan + SourceReceiverImpl done)
    - Challenge 4 gains Phase 1 implementation summary
    - Upstream tracker: OAL done (no upstream change needed)
    
    OAL-IMMIGRATION.md:
    - All 3 steps marked DONE
    - Step 1 rewritten: no collecting listeners, scans output directory
    - Step 2 rewritten: same-FQCN replacement (3 classes) instead of
      extending + hooking via ModuleWiringBridge
    - Step 3 updated: MeterSystem deferred to MAL, reflect-config to Phase 3
    - Files section updated to list all 6 actual files created/modified
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
 OAL-IMMIGRATION.md | 161 +++++++++++++++++++++++++++--------------------------
 PLAN.md            |  80 +++++++++++++++++---------
 2 files changed, 137 insertions(+), 104 deletions(-)

diff --git a/OAL-IMMIGRATION.md b/OAL-IMMIGRATION.md
index 01d70fd..1917177 100644
--- a/OAL-IMMIGRATION.md
+++ b/OAL-IMMIGRATION.md
@@ -1,39 +1,37 @@
-# Phase 2: OAL Build-Time Pre-Compilation
+# Phase 2: OAL Build-Time Pre-Compilation — COMPLETE
 
 ## Context
 
-OAL engine generates metrics, builder, and dispatcher classes at runtime via Javassist (`ClassPool.makeClass()` → `CtClass.toClass()`). GraalVM native image doesn't support runtime bytecode generation. Additionally, Guava's `ClassPath.from()` — used by `AnnotationScan.scan()` and `SourceReceiverImpl.scan()` — doesn't work in native image (no JAR-based classpath). So we cannot rely on classpath scanning to discover pre-generated classes.
+OAL engine generates metrics, builder, and dispatcher classes at runtime via Javassist (`ClassPool.makeClass()` → `CtClass.toClass()`). GraalVM native image doesn't support runtime bytecode generation. Additionally, Guava's `ClassPath.from()` — used by `AnnotationScan.scan()` and `SourceReceiverImpl.scan()` — doesn't work in native image (no JAR-based classpath).
 
-**Solution**: Run OAL engine at build time, export `.class` files + a manifest of class names. At runtime, load classes by name from the manifest and register them **directly** with `StreamAnnotationListener` and `DispatcherManager` — no classpath scanning.
+**Solution**: Run OAL engine at build time, export `.class` files + manifests. Replace upstream classes with same-FQCN versions that load from manifests instead of scanning or generating code.
 
 ---
 
-## Step 1: Build-Time OAL Class Export Tool
+## Step 1: Build-Time OAL Class Export Tool — DONE
 
-**Module**: `build-tools/oal-exporter` (skeleton exists)
+**Module**: `build-tools/oal-exporter`
 
-**Create**: `OALClassExporter.java` — main class that:
+**Created**: `OALClassExporter.java` — main class that:
 
-1. For each of the 9 `OALDefine` configs: instantiate `OALEngineV2`, set `StorageBuilderFactory.Default`, call `engine.start()` (Javassist generates classes in the build JVM)
-2. Export bytecode via existing debug mechanism: `generator.setOpenEngineDebug(true)` + `OALClassGeneratorV2.setGeneratedFilePath(outputDir)` — `writeGeneratedFile()` writes `.class` files using `ctClass.toBytecode(DataOutputStream)`
-3. After each engine run, call `engine.notifyAllListeners()` with **collecting listeners** that record class names (not real registration)
-4. Write manifest files:
-   - `META-INF/oal-metrics-classes.txt` — one fully-qualified class name per line
-   - `META-INF/oal-dispatcher-classes.txt` — one fully-qualified class name per line
-   - `META-INF/oal-disabled-sources.txt` — one source name per line
-5. Package output directory into a JAR artifact
+1. Validates all 9 OAL script files are on the classpath
+2. Initializes `DefaultScopeDefine` by scanning `@ScopeDeclaration` annotations (OAL enricher needs scope metadata)
+3. For each of the 9 `OALDefine` configs: instantiates `OALEngineV2`, enables debug output (`setOpenEngineDebug(true)` + `setGeneratedFilePath()`), calls `engine.start()` which parses OAL → enriches → generates `.class` files via Javassist
+4. Scans the output directory for generated `.class` files and writes OAL manifests:
+   - `META-INF/oal-metrics-classes.txt` — ~620 fully-qualified class names
+   - `META-INF/oal-dispatcher-classes.txt` — ~45 fully-qualified class names
+   - `META-INF/oal-disabled-sources.txt` — disabled source names from `disable.oal`
+5. Runs Guava `ClassPath.from()` scan at build time to produce 6 annotation/interface manifests under `META-INF/annotation-scan/`:
+   - `ScopeDeclaration.txt` — classes annotated with `@ScopeDeclaration`
+   - `Stream.txt` — classes annotated with `@Stream` (hardcoded only, not OAL-generated)
+   - `Disable.txt` — classes annotated with `@Disable`
+   - `MultipleDisable.txt` — classes annotated with `@MultipleDisable`
+   - `SourceDispatcher.txt` — concrete implementations of `SourceDispatcher` interface (hardcoded only)
+   - `ISourceDecorator.txt` — concrete implementations of `ISourceDecorator` interface
 
-**Note on listeners**: `engine.start()` already generates and loads classes, storing them in internal `metricsClasses`/`dispatcherClasses` lists. `notifyAllListeners()` iterates these lists. We provide lightweight listeners that just collect class names for the manifest, not real stream processors.
+**Key difference from original plan**: No "collecting listeners" needed. `engine.start()` generates `.class` files directly to disk via the debug API. We scan the output directory for class files rather than hooking into engine callbacks.
 
-**Dependencies** for `oal-exporter/pom.xml`:
-- `oal-rt` — engine, generator, parser, enricher, FreeMarker templates
-- `server-core` — `OALDefine` subclasses, source classes, annotations, `StorageBuilderFactory`
-- `server-starter` — OAL script resource files (`oal/*.oal`)
-- Receiver plugins that define `OALDefine` subclasses (for `BrowserOALDefine`, `MeshOALDefine`, etc.)
-
-**Build integration**: `exec-maven-plugin` runs `OALClassExporter.main()` during `process-classes` phase. Then `maven-jar-plugin` with a custom classifier packages the generated `.class` files + manifest into `oal-generated-classes.jar`.
-
-### 9 OAL Defines to process
+### 9 OAL Defines processed
 
 | Define | Config File | Source Package | Catalog |
 |--------|-------------|----------------|---------|
@@ -55,73 +53,82 @@ OAL engine generates metrics, builder, and dispatcher classes at runtime via Jav
 
 ---
 
-## Step 2: Runtime Direct Registration (No Classpath Scanning)
+## Step 2: Runtime Registration via Same-FQCN Replacement Classes — DONE
 
-**Create**: `PrecompiledOALEngineLoaderService.java` in `oap-graalvm-server`
+Instead of extending upstream classes or hooking via `ModuleWiringBridge`, we use **same-FQCN replacement**: create classes in `oap-graalvm-server` with the exact same fully-qualified class name as the upstream class. Maven classpath precedence ensures our version is loaded instead of the upstream version.
 
-Extends `OALEngineLoaderService`. Overrides `load()` to:
-1. On first invocation: read manifest files from classpath resources
-2. For each metrics class name: `Class.forName(name)` → `streamAnnotationListener.notify(clazz)` (same as `StreamAnnotationListener` — routes to `MetricsStreamProcessor.create()`)
-3. For each dispatcher class name: `Class.forName(name)` → `dispatcherDetectorListener.addIfAsSourceDispatcher(clazz)` (same as `DispatcherManager.addIfAsSourceDispatcher()`)
-4. For each disabled source: `DisableRegister.INSTANCE.add(name)`
-5. All subsequent `load()` calls → no-op (classes already registered)
+### 3 replacement classes created:
 
-```
-// Pseudocode
-public void load(OALDefine define) throws ModuleStartException {
-    if (registered) return;
-    registered = true;
-
-    StreamAnnotationListener streamListener = new StreamAnnotationListener(moduleManager);
-    DispatcherDetectorListener dispatcherListener = moduleManager.find(CoreModule.NAME)
-        .provider().getService(SourceReceiver.class).getDispatcherDetectorListener();
-
-    for (String className : readManifest("META-INF/oal-metrics-classes.txt")) {
-        streamListener.notify(Class.forName(className));
-    }
-    for (String className : readManifest("META-INF/oal-dispatcher-classes.txt")) {
-        dispatcherListener.addIfAsSourceDispatcher(Class.forName(className));
-    }
-    for (String source : readManifest("META-INF/oal-disabled-sources.txt")) {
-        DisableRegister.INSTANCE.add(source);
-    }
-}
-```
+**1. `OALEngineLoaderService`** (`oap-graalvm-server/.../core/oal/rt/OALEngineLoaderService.java`)
+
+Same FQCN as upstream `org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService`. On first `load()` call:
+- Reads `META-INF/oal-disabled-sources.txt` → registers with `DisableRegister`
+- Reads `META-INF/oal-metrics-classes.txt` → `Class.forName()` → `StreamAnnotationListener.notify()`
+- Reads `META-INF/oal-dispatcher-classes.txt` → `Class.forName()` → `DispatcherDetectorListener.addIfAsSourceDispatcher()`
+- All subsequent `load()` calls are no-ops (all classes registered on first call regardless of which `OALDefine` triggered it)
+
+**2. `AnnotationScan`** (`oap-graalvm-server/.../core/annotation/AnnotationScan.java`)
+
+Same FQCN as upstream `org.apache.skywalking.oap.server.core.annotation.AnnotationScan`. Instead of Guava `ClassPath.from()` scanning, reads manifest files from `META-INF/annotation-scan/{AnnotationSimpleName}.txt`. Each registered `AnnotationListener` is matched against its corresponding manifest.
+
+**3. `SourceReceiverImpl`** (`oap-graalvm-server/.../core/source/SourceReceiverImpl.java`)
 
-**Wiring**: Replace the default `OALEngineLoaderService` after `CoreModuleProvider.prepare()`. `registerServiceImplementation()` uses `HashMap.put()` — re-registration overwrites. Add a post-prepare hook in `ModuleWiringBridge` for `CoreModuleProvider` to swap in `PrecompiledOALEngineLoaderService`.
+Same FQCN as upstream `org.apache.skywalking.oap.server.core.source.SourceReceiverImpl`. `scan()` reads from `META-INF/annotation-scan/SourceDispatcher.txt` and `META-INF/annotation-scan/ISourceDecorator.txt` instead of Guava classpath scanning.
 
-**Timing**: `CoreModuleProvider.start()` calls `oalEngineLoaderService.load(DisableOALDefine.INSTANCE)` first, then `annotationScan.scan()` and `receiver.scan()`. Our `PrecompiledOALEngineLoaderService.load()` runs first and registers ALL pre-generated classes (not just disable.oal). The subsequent `annotationScan.scan()` and `receiver.scan()` will also run, but for Phase 2 (JVM mode), they work fine via `ClassPath.from()` and simply re-discover static classes. The OAL classes are alread [...]
+### Key differences from original plan:
+- **No extending** — same-FQCN replacement instead of subclassing
+- **No `ModuleWiringBridge` changes** — classpath precedence handles the swap automatically
+- **3 replacement classes, not 1** — `AnnotationScan` and `SourceReceiverImpl` also needed replacement
+- **Classpath scanning fully eliminated** — not deferred to Phase 3; annotation manifests solve it now
 
 ---
 
-## Step 3: Why Class.forName() Works for Native Image
+## Step 3: Class Loading and Remaining Scans — DONE
 
-`Class.forName()` is supported in GraalVM native image when classes are registered in `reflect-config.json`. Since all pre-generated classes are on the classpath at native-image build time, the GraalVM compiler includes them in the binary. The `reflect-config.json` entries (Phase 3 task) enable runtime `Class.forName()` lookup. For Phase 2 (JVM mode), `Class.forName()` works naturally.
+### `Class.forName()` in native image
+`Class.forName()` is supported in GraalVM native image when classes are registered in `reflect-config.json`. Since all pre-generated classes are on the classpath at native-image build time, the GraalVM compiler includes them in the binary. The `reflect-config.json` entries (Phase 3 task) will enable runtime `Class.forName()` lookup. For Phase 2 (JVM mode), `Class.forName()` works naturally.
 
-The 3 OAL-internal scans (`MetricsHolder`, `DefaultMetricsFunctionRegistry`, `FilterMatchers`) only run during OAL engine execution — they happen at **build time** in our tool, not at runtime. So they're automatically solved.
+### OAL-internal scans — build-time only
+The 3 OAL-internal scans (`MetricsHolder`, `DefaultMetricsFunctionRegistry`, `FilterMatchers`) only run inside the OAL engine during `engine.start()`. They happen at **build time** in `OALClassExporter`, not at runtime. Automatically solved.
+
+### `MeterSystem` — deferred to MAL immigration
+`MeterSystem` uses Guava `ClassPath.from()` to discover meter function classes at runtime. This is part of the MAL/meter subsystem, not OAL. Will be addressed as part of MAL immigration (Phase 2 remaining work).
+
+### `reflect-config.json` — deferred to Phase 3
+GraalVM reflection configuration for `Class.forName()` calls on OAL-generated and manifest-listed classes will be generated in Phase 3.
 
 ---
 
-## Files to Create
+## Files Created
+
+1. **`build-tools/oal-exporter/src/main/java/.../OALClassExporter.java`**
+   - Build-time tool: runs 9 OAL defines, exports `.class` files, writes OAL manifests + annotation/interface manifests
+
+2. **`oap-graalvm-server/src/main/java/.../core/oal/rt/OALEngineLoaderService.java`**
+   - Same-FQCN replacement: loads pre-compiled OAL classes from manifests
 
-1. **`build-tools/oal-exporter/src/main/java/org/apache/skywalking/oap/server/buildtools/oal/OALClassExporter.java`**
-   - Main class: iterates 9 OAL defines, runs engine, exports bytecode + writes manifest files
+3. **`oap-graalvm-server/src/main/java/.../core/annotation/AnnotationScan.java`**
+   - Same-FQCN replacement: reads annotation manifests instead of Guava classpath scanning
 
-2. **`oap-graalvm-server/src/main/java/org/apache/skywalking/oap/server/graalvm/PrecompiledOALEngineLoaderService.java`**
-   - Extends `OALEngineLoaderService`, loads from manifest + direct registration
+4. **`oap-graalvm-server/src/main/java/.../core/source/SourceReceiverImpl.java`**
+   - Same-FQCN replacement: reads dispatcher/decorator manifests instead of Guava classpath scanning
 
-## Files to Modify
+5. **`build-tools/oal-exporter/src/test/java/.../OALClassExporterTest.java`**
+   - 3 tests: OAL script coverage, classpath availability, full export with manifest verification
 
-1. **`build-tools/oal-exporter/pom.xml`** — add dependencies, configure `exec-maven-plugin` + `maven-jar-plugin`
-2. **`oap-graalvm-server/pom.xml`** — add dependency on `oal-exporter` generated JAR
-3. **`oap-graalvm-server/.../ModuleWiringBridge.java`** — post-prepare hook to replace `OALEngineLoaderService` with `PrecompiledOALEngineLoaderService`
-4. **`Makefile`** — ensure build order: skywalking → oal-exporter → oap-graalvm-server
+6. **`oap-graalvm-server/src/test/java/.../PrecompiledRegistrationTest.java`**
+   - 12 tests: manifest vs Guava scan comparison, OAL class loading, scope registration, source→dispatcher→metrics chain consistency
+
+## Files Modified
+
+1. **`build-tools/oal-exporter/pom.xml`** — dependencies + `exec-maven-plugin` + `maven-jar-plugin`
+2. **`oap-graalvm-server/pom.xml`** — dependency on `oal-exporter` generated JAR
 
 ## Key Upstream Files (read-only)
 
 - `OALEngineV2.java` — `start()` (parse → enrich → generate), `notifyAllListeners()` (register)
 - `OALClassGeneratorV2.java` — `setOpenEngineDebug(true)`, `setGeneratedFilePath()`, `writeGeneratedFile()` exports via `ctClass.toBytecode()`
-- `OALEngineLoaderService.java` — `load()` creates engine, sets listeners, calls `start()`+`notifyAllListeners()`
+- `OALEngineLoaderService.java` (upstream) — `load()` creates engine, sets listeners, calls `start()`+`notifyAllListeners()`
 - `StorageBuilderFactory.java:67-78` — `Default` impl uses `metrics-builder` template path
 - `StreamAnnotationListener.java` — `notify(Class)` reads `@Stream`, routes to `MetricsStreamProcessor.create()`
 - `CoreModuleProvider.java:356-357` — registers `OALEngineLoaderService` in `prepare()`
@@ -136,18 +143,16 @@ The 3 OAL-internal scans (`MetricsHolder`, `DefaultMetricsFunctionRegistry`, `Fi
 make build-distro
 
 # 2. Check generated classes exist
-ls build-tools/oal-exporter/target/generated-oal-classes/
-# Should have: org/apache/skywalking/.../oal/rt/metrics/*.class
-#              org/apache/skywalking/.../oal/rt/metrics/builder/*.class
-#              org/apache/skywalking/.../oal/rt/dispatcher/*.class
+ls build-tools/oal-exporter/target/generated-oal-classes/org/apache/skywalking/oap/server/core/source/oal/rt/metrics/
+ls build-tools/oal-exporter/target/generated-oal-classes/org/apache/skywalking/oap/server/core/source/oal/rt/dispatcher/
 
 # 3. Check manifest files
 cat build-tools/oal-exporter/target/generated-oal-classes/META-INF/oal-metrics-classes.txt
 cat build-tools/oal-exporter/target/generated-oal-classes/META-INF/oal-dispatcher-classes.txt
-# Should list all generated class names
 
-# 4. Verify JAR packaging
-jar tf build-tools/oal-exporter/target/oal-generated-classes.jar
+# 4. Check annotation scan manifests
+ls build-tools/oal-exporter/target/generated-oal-classes/META-INF/annotation-scan/
 
-# 5. Verify oap-graalvm-server compiles with the generated JAR dependency
-```
\ No newline at end of file
+# 5. Verify tests pass
+make build-distro   # runs both OALClassExporterTest and PrecompiledRegistrationTest
+```
diff --git a/PLAN.md b/PLAN.md
index 74d0845..a89051a 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -37,40 +37,54 @@ Build and package Apache SkyWalking OAP server as a GraalVM native image on JDK
 
 ---
 
-## Challenge 1: OAL Runtime Class Generation (Javassist)
+## Challenge 1: OAL Runtime Class Generation (Javassist) — SOLVED
 
 ### What Happens
 OAL V2 generates metrics/builder/dispatcher classes at startup via Javassist (`ClassPool.makeClass()` → `CtClass.toClass()`). Already has `writeGeneratedFile()` for debug export.
 
 ### Approach (this repo)
-All `.oal` scripts are known. Run OAL engine at build time, export `.class` files, load them directly in native-image mode.
+All `.oal` scripts are known. Run OAL engine at build time, export `.class` files, load them directly at runtime from manifests. See [OAL-IMMIGRATION.md](OAL-IMMIGRATION.md) for details.
+
+### What Was Built
+- `OALClassExporter` processes all 9 OAL defines, exports ~620 metrics classes, ~620 builder classes, ~45 dispatchers
+- 3 manifest files: `oal-metrics-classes.txt`, `oal-dispatcher-classes.txt`, `oal-disabled-sources.txt`
+- Same-FQCN replacement `OALEngineLoaderService` loads pre-compiled classes from manifests instead of running Javassist
 
 ### Upstream Changes Needed
-- Potentially expose build-time class export as a stable API (currently debug-only)
+- None. Build-time class export works via existing debug API (`setOpenEngineDebug(true)` + `setGeneratedFilePath()`)
 
 ---
 
-## Challenge 2: MAL and LAL (Groovy)
+## Challenge 2: MAL and LAL (Groovy + Javassist)
 
 ### What Happens
-MAL uses `GroovyShell` + `Binding` for meter rules. LAL uses `GroovyShell` + `DelegatingScript` + `Closure` + AST customizers.
+- MAL uses `GroovyShell` + `DelegatingScript` for meter rule expressions (~1188 rules). Also, `MeterSystem.create()` uses Javassist to dynamically generate one meter subclass per metric rule.
+- LAL uses `GroovyShell` + `@CompileStatic` + `LALPrecompiledExtension` for log analysis scripts (10 rules).
 
 ### Approach (this repo)
-Groovy static compilation (`@CompileStatic`). Pre-compile all MAL/LAL rule files at build time, export `.class` files.
+Run full MAL/LAL initialization at build time via `build-tools/mal-compiler`. Export Javassist-generated `.class` files + compiled Groovy script bytecode. At runtime, load from manifests. See [MAL-IMMIGRATION.md](MAL-IMMIGRATION.md) for details.
+
+### Key finding: MAL cannot use @CompileStatic
+MAL expressions rely on `propertyMissing()` for sample name resolution and `ExpandoMetaClass` on `Number` for arithmetic operators — fundamentally dynamic Groovy features. Pre-compilation uses standard dynamic Groovy (same `CompilerConfiguration` as upstream). LAL already uses `@CompileStatic`.
 
 ### Risks
-- `@CompileStatic` may not cover all dynamic features (track and work around)
-- May need DSL adjustments (upstream PRs)
+- Dynamic Groovy MOP may not work in GraalVM native image (Phase 3 concern)
+- If `ExpandoMetaClass` fails in native image: fallback to upstream DSL changes
 
 ---
 
-## Challenge 3: Classpath Scanning (Guava ClassPath)
+## Challenge 3: Classpath Scanning (Guava ClassPath) — PARTIALLY SOLVED
 
 ### What Happens
 `ClassPath.from()` used in `SourceReceiverImpl.scan()`, `AnnotationScan`, `MeterSystem`, `DefaultMetricsFunctionRegistry`, `FilterMatchers`, `MetricsHolder`.
 
-### Approach (this repo)
-Run classpath scanning during build-time pre-compilation. Verify all metrics/log-processing classes are discovered. Export scan results as static class index. Native-image mode loads from index.
+### What Was Solved
+`AnnotationScan` and `SourceReceiverImpl` replaced with same-FQCN classes that read from build-time manifests. 6 annotation/interface manifests under `META-INF/annotation-scan/`: `ScopeDeclaration`, `Stream`, `Disable`, `MultipleDisable`, `SourceDispatcher`, `ISourceDecorator`.
+
+`DefaultMetricsFunctionRegistry`, `FilterMatchers`, `MetricsHolder` — these only run inside the OAL engine at build time, not at runtime. Automatically solved.
+
+### What Remains
+`MeterSystem` uses Guava `ClassPath.from()` to scan for meter function classes at runtime. This needs a manifest or build-time scan as part of MAL immigration.
 
 ---
 
@@ -84,6 +98,12 @@ Run classpath scanning during build-time pre-compilation. Verify all metrics/log
 2. **Simplified config file**: Only knobs for selected providers
 3. **Config loading**: **No reflection.** At build time, read `application.yml` + scan `ModuleConfig` subclass fields → generate Java code that directly sets config fields (e.g. `config.restPort = 12800;`). Eliminates `Field.setAccessible`/`field.set` and the need for `reflect-config.json` for config classes.
 
+### What Was Built (Phase 1)
+- `FixedModuleManager` — direct module/provider construction, no SPI
+- `ModuleWiringBridge` — wires all selected modules/providers
+- `GraalVMOAPServerStartUp` — entry point
+- `application.yml` — simplified config for selected providers
+
 ---
 
 ## Challenge 5: Additional GraalVM Risks
@@ -102,19 +122,26 @@ Run classpath scanning during build-time pre-compilation. Verify all metrics/log
 
 ## Proposed Phases
 
-### Phase 1: Build System Setup
-- [ ] Set up Maven + Makefile in this repo
-- [ ] Build skywalking submodule as a dependency
+### Phase 1: Build System Setup — COMPLETE
+- [x] Set up Maven + Makefile in this repo
+- [x] Build skywalking submodule as a dependency
 - [ ] Set up GraalVM JDK 25 in CI
-- [ ] Create a JVM-mode starter with fixed module wiring (validate approach before native-image)
-- [ ] Simplified config file for selected modules
-
-### Phase 2: Build-Time Pre-Compilation & Verification
-- [ ] Makefile/Maven step: run OAL engine → export `.class` files
-- [ ] Makefile/Maven step: static-compile MAL Groovy scripts → export `.class` files
-- [ ] Makefile/Maven step: static-compile LAL Groovy scripts → export `.class` files
-- [ ] Makefile/Maven step: run classpath scanning → export class index
-- [ ] Verify all metrics/log-processing classes are correctly discovered
+- [x] Create a JVM-mode starter with fixed module wiring (`FixedModuleManager` + `ModuleWiringBridge` + `GraalVMOAPServerStartUp`)
+- [x] Simplified config file for selected modules (`application.yml`)
+
+### Phase 2: Build-Time Pre-Compilation & Verification — IN PROGRESS
+
+**OAL immigration — COMPLETE:**
+- [x] OAL engine → export `.class` files (`OALClassExporter`, 9 defines, ~620 metrics, ~45 dispatchers)
+- [x] Classpath scanning → export class index (6 annotation/interface manifests in `oal-exporter`)
+- [x] Runtime registration from manifests (3 same-FQCN replacement classes: `OALEngineLoaderService`, `AnnotationScan`, `SourceReceiverImpl`)
+- [x] Verification tests (`OALClassExporterTest` — 3 tests, `PrecompiledRegistrationTest` — 12 tests)
+
+**Remaining:**
+- [ ] MAL Groovy pre-compilation (`build-tools/mal-compiler` skeleton exists)
+- [ ] LAL Groovy pre-compilation (can be part of mal-compiler)
+- [ ] `MeterSystem` classpath scan: uses Guava scanning for meter function classes — needs manifest or build-time scan (part of MAL immigration)
+- [ ] Config generator (`build-tools/config-generator` skeleton exists) — eliminate `Field.setAccessible` reflection in config loading
 - [ ] Package everything into native-image classpath
 
 ### Phase 3: Native Image Build
@@ -122,6 +149,7 @@ Run classpath scanning during build-time pre-compilation. Verify all metrics/log
 - [ ] Run tracing agent to capture reflection/resource/JNI metadata
 - [ ] Configure gRPC/Netty/Protobuf for native image
 - [ ] GraalVM Feature class for SkyWalking-specific registrations
+- [ ] `reflect-config.json` for OAL-generated classes (`Class.forName()` calls)
 - [ ] Get OAP server booting as native image with BanyanDB
 
 ### Phase 4: Harden & Test
@@ -135,6 +163,6 @@ Run classpath scanning during build-time pre-compilation. Verify all metrics/log
 ---
 
 ## Upstream Changes Tracker
-- [ ] OAL engine: stable build-time class export API
-- [ ] MAL/LAL: DSL adjustments for Groovy static compilation (if needed)
-- [ ] Other findings during implementation
\ No newline at end of file
+- [x] OAL engine: build-time class export works via existing debug API (no upstream change needed)
+- [ ] MAL/LAL: Groovy static compilation / DSL adjustments (not started)
+- [ ] Other findings during implementation


(skywalking-graalvm-distro) 03/04: Add MAL-IMMIGRATION.md: plan for MAL/LAL build-time pre-compilation

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-graalvm-distro.git

commit 0a40450918b24206a3e9c51a71f7c565f5cc84c1
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Feb 18 22:04:58 2026 +0800

    Add MAL-IMMIGRATION.md: plan for MAL/LAL build-time pre-compilation
    
    Detailed technical document covering 3 GraalVM-incompatible patterns:
    1. MeterSystem ClassPath scanning (16 @MeterFunction classes)
    2. MeterSystem Javassist dynamic class generation (~1188 rules)
    3. Groovy runtime compilation (MAL dynamic + LAL @CompileStatic)
    
    Solution structured in 3 steps:
    - Step 1: MeterFunction manifest + same-FQCN MeterSystem replacement
    - Step 2: Build-time MAL/LAL pre-compilation + MeterSystem class
      generation via build-tools/mal-compiler
    - Step 3: Verification tests
    
    Key finding: MAL cannot use @CompileStatic due to propertyMissing(),
    ExpandoMetaClass on Number, and dynamic closures. Pre-compilation uses
    standard dynamic Groovy; native image compatibility is a Phase 3 concern.
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
 MAL-IMMIGRATION.md | 444 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 444 insertions(+)

diff --git a/MAL-IMMIGRATION.md b/MAL-IMMIGRATION.md
new file mode 100644
index 0000000..4121900
--- /dev/null
+++ b/MAL-IMMIGRATION.md
@@ -0,0 +1,444 @@
+# Phase 2: MAL/LAL Build-Time Pre-Compilation
+
+## Context
+
+MAL (Meter Analysis Language) and LAL (Log Analysis Language) have three GraalVM-incompatible runtime patterns:
+
+1. **MeterSystem ClassPath scanning**: `MeterSystem` constructor uses Guava `ClassPath.from()` to discover `@MeterFunction`-annotated classes (16 meter functions).
+2. **MeterSystem Javassist dynamic class generation**: `MeterSystem.create()` uses Javassist `ClassPool.makeClass()` to create one dynamic meter subclass per metric rule at runtime (~1188 rules across all MAL sources). Classes live in `org.apache.skywalking.oap.server.core.analysis.meter.dynamic.*`.
+3. **Groovy runtime compilation**: MAL uses `GroovyShell.parse()` with dynamic Groovy features. LAL uses `GroovyShell.parse()` with `@CompileStatic`. Both compile scripts at startup.
+
+**Key architectural difference from OAL**: MAL initialization is a tightly coupled pipeline where Groovy compilation, static analysis, and Javassist generation are interleaved:
+
+```
+Rule YAML → MetricConvert constructor → Analyzer.build()
+  → DSL.parse()               [Groovy compilation]
+  → e.parse()                  [static analysis → scopeType, functionName, metricType]
+  → meterSystem.create()       [Javassist class generation + MetricsStreamProcessor registration]
+```
+
+The build tool must execute this entire chain — Groovy pre-compilation and Javassist pre-generation cannot be separated.
+
+**Solution**: Run the full MAL/LAL initialization at build time. Export Javassist-generated `.class` files + compiled Groovy script bytecode. At runtime, load pre-generated classes from manifests — no ClassPath scanning, no Javassist, no Groovy compilation.
+
+---
+
+## Rule file inventory
+
+| Source | Path | Loader | Files | Metric Rules |
+|--------|------|--------|-------|--------------|
+| Agent meter | `meter-analyzer-config/` | `MeterConfigs.loadConfig()` | 11 | ~147 |
+| OTel metrics | `otel-rules/` | `Rules.loadRules()` | 55 | ~1039 |
+| Log MAL | `log-mal-rules/` | `Rules.loadRules()` | 2 | ~2 |
+| LAL scripts | `lal/` | `LALConfigs.load()` | 8 | 10 |
+| **Total** | | | **76** | **~1198** |
+
+Each MAL metric rule generates one Groovy script + one Javassist dynamic meter class. Each LAL rule generates one Groovy script.
+
+---
+
+## Step 1: MeterFunction Manifest + Same-FQCN MeterSystem
+
+### Problem
+
+`MeterSystem` constructor (`MeterSystem.java:75-96`) scans the classpath:
+
+```java
+ClassPath classpath = ClassPath.from(MeterSystem.class.getClassLoader());
+ImmutableSet<ClassPath.ClassInfo> classes = classpath.getTopLevelClassesRecursive("org.apache.skywalking");
+for (ClassPath.ClassInfo classInfo : classes) {
+    Class<?> functionClass = classInfo.load();
+    if (functionClass.isAnnotationPresent(MeterFunction.class)) {
+        functionRegister.put(metricsFunction.functionName(), functionClass);
+    }
+}
+```
+
+### 16 Meter Function classes
+
+| Function Name | Class | Accept Type |
+|---|---|---|
+| `avg` | `AvgFunction` | `Long` |
+| `avgLabeled` | `AvgLabeledFunction` | `DataTable` |
+| `avgHistogram` | `AvgHistogramFunction` | `BucketedValues` |
+| `avgHistogramPercentile` | `AvgHistogramPercentileFunction` | `PercentileArgument` |
+| `latest` | `LatestFunction` | `Long` |
+| `latestLabeled` | `LatestLabeledFunction` | `DataTable` |
+| `max` | `MaxFunction` | `Long` |
+| `maxLabeled` | `MaxLabeledFunction` | `DataTable` |
+| `min` | `MinFunction` | `Long` |
+| `minLabeled` | `MinLabeledFunction` | `DataTable` |
+| `sum` | `SumFunction` | `Long` |
+| `sumLabeled` | `SumLabeledFunction` | `DataTable` |
+| `sumHistogram` | `HistogramFunction` | `BucketedValues` |
+| `sumHistogramPercentile` | `SumHistogramPercentileFunction` | `PercentileArgument` |
+| `sumPerMin` | `SumPerMinFunction` | `Long` |
+| `sumPerMinLabeled` | `SumPerMinLabeledFunction` | `DataTable` |
+
+### Approach
+
+1. Extend `OALClassExporter` to scan `@MeterFunction` annotation at build time. Write `META-INF/annotation-scan/MeterFunction.txt` with format `functionName=FQCN` (one entry per line).
+
+2. Create same-FQCN replacement `MeterSystem` in `oap-graalvm-server` that reads function registry from the manifest instead of `ClassPath.from()`:
+
+```java
+// Pseudocode for replacement MeterSystem constructor
+public MeterSystem(ModuleManager manager) {
+    this.manager = manager;
+    this.classPool = ClassPool.getDefault();
+
+    // Read from manifest instead of ClassPath.from()
+    for (String line : readManifest("META-INF/annotation-scan/MeterFunction.txt")) {
+        String[] parts = line.split("=", 2);
+        String functionName = parts[0];
+        Class<?> functionClass = Class.forName(parts[1]);
+        functionRegister.put(functionName, (Class<? extends AcceptableValue>) functionClass);
+    }
+}
+```
+
+At this step, `create()` still uses Javassist — this is fine for JVM mode. Step 2 eliminates it.
+
+---
+
+## Step 2: Build-Time MAL/LAL Pre-Compilation + MeterSystem Class Generation
+
+**Module**: `build-tools/mal-compiler` (skeleton exists)
+
+### MALCompiler.java — main build tool
+
+The tool executes the full initialization pipeline at build time:
+
+#### Phase A: Initialize infrastructure
+
+```java
+// 1. Initialize scope registry (same as OALClassExporter)
+DefaultScopeDefine.reset();
+AnnotationScan scopeScan = new AnnotationScan();
+scopeScan.registerListener(new DefaultScopeDefine.Listener());
+scopeScan.scan();
+
+// 2. Create ExportingMeterSystem — intercepts Javassist to export .class files
+ExportingMeterSystem meterSystem = new ExportingMeterSystem(outputDir);
+```
+
+#### Phase B: Load and compile all MAL rules
+
+```java
+// 3. Agent meter rules (meter-analyzer-config/)
+List<MeterConfig> agentConfigs = MeterConfigs.loadConfig("meter-analyzer-config", activeFiles);
+for (MeterConfig config : agentConfigs) {
+    new MetricConvert(config, meterSystem);  // triggers: Groovy compile + parse + Javassist
+}
+
+// 4. OTel rules (otel-rules/)
+List<Rule> otelRules = Rules.loadRules("otel-rules", enabledOtelRules);
+for (Rule rule : otelRules) {
+    new MetricConvert(rule, meterSystem);
+}
+
+// 5. Log MAL rules (log-mal-rules/)
+List<Rule> logMalRules = Rules.loadRules("log-mal-rules", enabledLogMalRules);
+for (Rule rule : logMalRules) {
+    new MetricConvert(rule, meterSystem);
+}
+```
+
+#### Phase C: Load and compile all LAL rules
+
+```java
+// 6. LAL rules (lal/)
+List<LALConfigs> lalConfigs = LALConfigs.load("lal", lalFiles);
+for (LALConfig config : flattenedConfigs) {
+    DSL.of(moduleManager, logConfig, config.getDsl());  // Groovy compile with @CompileStatic
+}
+```
+
+#### Phase D: Export bytecode + write manifests
+
+The tool intercepts both Groovy and Javassist class generation to capture bytecode:
+
+**Javassist interception** (`ExportingMeterSystem`): Override `create()` to call `ctClass.toBytecode()` and write `.class` files to the output directory. Also records metadata for the manifest.
+
+**Groovy script capture**: Use Groovy's `CompilationUnit` API or intercept `GroovyShell.parse()` to extract compiled script bytecode. Each MAL expression compiles to a unique script class (name based on hash or sequential index).
+
+**Manifest files**:
+
+`META-INF/mal-meter-classes.txt` — Javassist-generated meter classes:
+```
+# format: metricsName|scopeId|functionName|dataType|FQCN
+meter_java_agent_created_tracing_context_count|1|sum|java.lang.Long|org.apache.skywalking.oap.server.core.analysis.meter.dynamic.meter_java_agent_created_tracing_context_count
+...
+```
+
+`META-INF/mal-groovy-scripts.txt` — Pre-compiled MAL Groovy scripts:
+```
+# format: metricName=scriptClassName
+meter_java_agent_created_tracing_context_count=org.apache.skywalking.oap.server.core.analysis.meter.script.Script0001
+...
+```
+
+`META-INF/lal-scripts.txt` — Pre-compiled LAL Groovy scripts:
+```
+# format: layer:ruleName=scriptClassName
+GENERAL:default=org.apache.skywalking.oap.server.core.analysis.lal.script.LALScript0001
+NGINX:nginx-access-log=org.apache.skywalking.oap.server.core.analysis.lal.script.LALScript0002
+...
+```
+
+### ExportingMeterSystem — Javassist interception
+
+This is a build-time variant of `MeterSystem` that exports bytecode instead of loading classes:
+
+```java
+// Pseudocode
+public class ExportingMeterSystem extends MeterSystem {
+    private final Path outputDir;
+    private final List<MeterClassMetadata> metadata = new ArrayList<>();
+
+    @Override
+    public synchronized <T> void create(String metricsName, String functionName,
+                                         ScopeType type, Class<T> dataType) {
+        // Same Javassist logic as upstream MeterSystem.create()
+        CtClass metricsClass = classPool.makeClass(METER_CLASS_PACKAGE + className, parentClass);
+        // ... add constructor and createNew() method ...
+
+        // Instead of toClass(), write bytecode to disk
+        byte[] bytecode = metricsClass.toBytecode();
+        Path classFile = outputDir.resolve(packageToPath(METER_CLASS_PACKAGE + className) + ".class");
+        Files.createDirectories(classFile.getParent());
+        Files.write(classFile, bytecode);
+
+        // Record metadata for manifest
+        metadata.add(new MeterClassMetadata(metricsName, type.getScopeId(),
+            functionName, dataType.getName(), METER_CLASS_PACKAGE + className));
+    }
+}
+```
+
+### Same-FQCN replacement classes
+
+**1. MAL `DSL`** (`oap-graalvm-server/.../meter/analyzer/dsl/DSL.java`)
+
+Same FQCN as `org.apache.skywalking.oap.meter.analyzer.dsl.DSL`. `parse()` loads a pre-compiled Groovy script class instead of calling `GroovyShell.parse()`:
+
+```java
+// Pseudocode
+public static Expression parse(String metricName, String expression) {
+    // Look up pre-compiled script class from manifest
+    String scriptClassName = lookupScript(metricName);
+    Class<?> scriptClass = Class.forName(scriptClassName);
+    DelegatingScript script = (DelegatingScript) scriptClass.getDeclaredConstructor().newInstance();
+
+    // Same CompilerConfiguration setup (imports, security) is baked into the pre-compiled class
+    return new Expression(metricName, expression, script);
+}
+```
+
+The `Expression.empower()` method still runs at runtime — it calls `setDelegate()` and `ExpandoMetaClass` registration. These are Java API calls on the Groovy runtime, not compilation.
+
+**2. `FilterExpression`** (`oap-graalvm-server/.../meter/analyzer/dsl/FilterExpression.java`)
+
+Same FQCN. Loads pre-compiled filter closure class instead of `GroovyShell.evaluate()`.
+
+**3. LAL `DSL`** (`oap-graalvm-server/.../log/analyzer/dsl/DSL.java`)
+
+Same FQCN as `org.apache.skywalking.oap.log.analyzer.dsl.DSL`. `of()` loads pre-compiled LAL script class (already `@CompileStatic`) instead of calling `GroovyShell.parse()`:
+
+```java
+// Pseudocode
+public static DSL of(ModuleManager moduleManager, LogAnalyzerModuleConfig config, String dsl) {
+    String scriptClassName = lookupLALScript(layer, ruleName);
+    Class<?> scriptClass = Class.forName(scriptClassName);
+    DelegatingScript script = (DelegatingScript) scriptClass.getDeclaredConstructor().newInstance();
+    FilterSpec filterSpec = new FilterSpec(moduleManager, config);
+    script.setDelegate(filterSpec);
+    return new DSL(script, filterSpec);
+}
+```
+
+**4. `MeterSystem`** (enhanced from Step 1)
+
+The `create()` method becomes a manifest lookup + `MetricsStreamProcessor` registration:
+
+```java
+// Pseudocode
+public synchronized <T> void create(String metricsName, String functionName,
+                                     ScopeType type, Class<T> dataType) {
+    if (meterPrototypes.containsKey(metricsName)) {
+        return; // already registered
+    }
+
+    // Load pre-generated class from classpath
+    MeterClassMetadata meta = lookupMeterClass(metricsName);
+    Class<?> targetClass = Class.forName(meta.fqcn);
+    AcceptableValue prototype = (AcceptableValue) targetClass.getDeclaredConstructor().newInstance();
+    meterPrototypes.put(metricsName, new MeterDefinition(type, prototype, dataType));
+
+    // Register with stream processor (same as upstream)
+    MetricsStreamProcessor.getInstance().create(
+        manager,
+        new StreamDefinition(metricsName, type.getScopeId(), prototype.builder(),
+            MetricsStreamProcessor.class),
+        targetClass
+    );
+}
+```
+
+`buildMetrics()` and `doStreamingCalculation()` work unchanged — they use the prototype map.
+
+### MAL Groovy: Why @CompileStatic is NOT possible
+
+MAL expressions rely on three dynamic Groovy features:
+
+1. **`propertyMissing(String)`** (`Expression.java:126`): When an expression references `counter` or `jvm_memory_bytes_used`, Groovy calls `ExpressionDelegate.propertyMissing(sampleName)` which looks up the sample family from a `ThreadLocal<Map<String, SampleFamily>>`. Static compilation cannot resolve these properties.
+
+2. **`ExpandoMetaClass` on `Number`** (`Expression.java:104-111`): The `empower()` method registers `plus`, `minus`, `multiply`, `div` closures on `Number.class` to allow expressions like `100 * server_cpu_seconds`. This is runtime metaclass manipulation.
+
+3. **Closure arguments** in DSL methods: Expressions like `.tag({tags -> tags.gc = 'young_gc'})` and `.filter({tags -> tags.job_name == 'mysql'})` pass Groovy closures with dynamic property access.
+
+**Approach**: Pre-compile using standard dynamic Groovy (same `CompilerConfiguration` as upstream — `DelegatingScript` base class, `SecureASTCustomizer`, `ImportCustomizer`). The compiled `.class` files contain the same bytecode that `GroovyShell.parse()` would produce. At runtime, `Class.forName()` + `newInstance()` loads the pre-compiled script, and `Expression.empower()` sets up the delegate and `ExpandoMetaClass`.
+
+**GraalVM native image risk** (Phase 3 concern): Dynamic Groovy compiled classes use `invokedynamic` and Groovy's MOP (Meta-Object Protocol) for method resolution. In native image, this may need:
+- `reflect-config.json` for all compiled script classes
+- Groovy MOP runtime classes registered for reachability
+- If `ExpandoMetaClass` does not work in native image: fallback to upstream DSL changes (replace operator overloading with explicit `SampleFamily.multiply(100, sf)` calls)
+
+Phase 2 focuses on JVM mode — pre-compilation for startup speed. Phase 3 addresses native image compatibility.
+
+### LAL Groovy: Already @CompileStatic
+
+LAL already uses `@CompileStatic` with `LALPrecompiledExtension` for type checking. The `CompilationUnit` approach works directly. Compiled scripts extend `LALDelegatingScript` and are fully statically typed.
+
+---
+
+## Step 3: Verification Tests
+
+### MALCompilerTest (in `build-tools/mal-compiler/src/test/`)
+
+```
+- allRuleYamlFilesLoadable:
+    Verify all 76 rule files exist on classpath
+
+- fullCompilationGeneratesExpectedCounts:
+    Run MALCompiler.main(), verify:
+    - Generated meter .class count > 0 for each rule source
+    - Groovy script .class count matches rule count
+    - All 3 manifest files exist and are non-empty
+
+- manifestEntriesAreWellFormed:
+    Parse manifest files, verify format and field count per line
+```
+
+### MALPrecompiledRegistrationTest (in `oap-graalvm-server/src/test/`)
+
+```
+- meterFunctionManifestMatchesClasspath:
+    Compare manifest against Guava ClassPath scan of @MeterFunction
+    (same pattern as PrecompiledRegistrationTest for OAL)
+
+- all16MeterFunctionsInManifest:
+    Verify all 16 known function names appear
+
+- precompiledMeterClassesLoadable:
+    For each entry in mal-meter-classes.txt:
+    - Class.forName() succeeds
+    - Class extends the correct meter function parent
+
+- precompiledGroovyScriptsLoadable:
+    For each entry in mal-groovy-scripts.txt:
+    - Class.forName() succeeds
+    - Class is assignable to DelegatingScript
+
+- precompiledLALScriptsLoadable:
+    For each entry in lal-scripts.txt:
+    - Class.forName() succeeds
+    - Class is assignable to LALDelegatingScript
+```
+
+---
+
+## Files to Create
+
+1. **`build-tools/mal-compiler/src/main/java/.../buildtools/mal/MALCompiler.java`**
+   - Main build tool: loads all MAL/LAL rules, runs full initialization pipeline, exports .class files + manifests
+
+2. **`build-tools/mal-compiler/src/main/java/.../buildtools/mal/ExportingMeterSystem.java`**
+   - MeterSystem variant that exports Javassist bytecode to disk via `toBytecode()` instead of `toClass()`
+
+3. **`oap-graalvm-server/src/main/java/.../core/analysis/meter/MeterSystem.java`**
+   - Same-FQCN replacement: reads function registry from manifest, loads pre-generated classes in `create()`
+
+4. **`oap-graalvm-server/src/main/java/.../meter/analyzer/dsl/DSL.java`**
+   - Same-FQCN replacement: loads pre-compiled MAL Groovy scripts from manifest
+
+5. **`oap-graalvm-server/src/main/java/.../meter/analyzer/dsl/FilterExpression.java`**
+   - Same-FQCN replacement: loads pre-compiled filter closures from manifest
+
+6. **`oap-graalvm-server/src/main/java/.../log/analyzer/dsl/DSL.java`**
+   - Same-FQCN replacement: loads pre-compiled LAL scripts from manifest
+
+7. **`build-tools/mal-compiler/src/test/java/.../buildtools/mal/MALCompilerTest.java`**
+   - Build-time compilation tests
+
+8. **`oap-graalvm-server/src/test/java/.../graalvm/MALPrecompiledRegistrationTest.java`**
+   - Runtime registration and loading tests
+
+## Files to Modify
+
+1. **`build-tools/oal-exporter/src/main/java/.../buildtools/oal/OALClassExporter.java`**
+   - Add `@MeterFunction` annotation scan → `META-INF/annotation-scan/MeterFunction.txt`
+
+2. **`build-tools/mal-compiler/pom.xml`**
+   - Add dependencies (server-core, meter-analyzer, log-analyzer, agent-analyzer, all receiver plugins for rule YAMLs)
+   - Configure `exec-maven-plugin` + `maven-jar-plugin`
+
+3. **`oap-graalvm-server/pom.xml`**
+   - Add dependency on `mal-compiler` generated JAR
+
+4. **`build-tools/oal-exporter/src/test/java/.../OALClassExporterTest.java`**
+   - Add test for MeterFunction manifest
+
+## Key Upstream Files (read-only)
+
+- `MeterSystem.java` — ClassPath scan (`constructor:75-96`) + Javassist class gen (`create():180-259`)
+- `DSL.java` (meter-analyzer) — MAL Groovy compilation: `GroovyShell.parse()` with `DelegatingScript`, `SecureASTCustomizer`
+- `Expression.java` — Script execution: `DelegatingScript.run()`, `ExpandoMetaClass` on Number, `ExpressionDelegate.propertyMissing()`
+- `FilterExpression.java` — Filter closure compilation: `GroovyShell.evaluate()`
+- `Analyzer.java` — Initialization chain: `build()` → `DSL.parse()` → `e.parse()` → `meterSystem.create()`
+- `MetricConvert.java` — Rule → Analyzer creation: `new MetricConvert(rule, meterSystem)` triggers full pipeline
+- `DSL.java` (log-analyzer) — LAL Groovy compilation: `@CompileStatic` + `LALPrecompiledExtension`
+- `LALDelegatingScript.java` — LAL script base class: `filter()`, `json()`, `text()`, `extractor()`, `sink()`
+- `LogFilterListener.java` — LAL DSL factory: `DSL.of()` for each rule, stores in `Map<Layer, Map<String, DSL>>`
+- `Rules.java` — OTel/log-MAL rule loading: `loadRules(path, enabledRules)`
+- `MeterConfigs.java` — Agent meter rule loading: `loadConfig(path, fileNames)`
+- `LALConfigs.java` — LAL rule loading: `load(path, files)`
+- `MeterFunction.java` — Annotation: `@MeterFunction(functionName = "...")` on meter function classes
+- `AcceptableValue.java` — Interface all meter functions implement
+- `MeterClassPackageHolder.java` — Package anchor for Javassist-generated classes
+
+---
+
+## Verification
+
+```bash
+# 1. Build everything
+make build-distro
+
+# 2. Check generated meter classes exist
+ls build-tools/mal-compiler/target/generated-mal-classes/org/apache/skywalking/oap/server/core/analysis/meter/dynamic/
+
+# 3. Check Groovy script classes exist
+ls build-tools/mal-compiler/target/generated-mal-classes/org/apache/skywalking/oap/server/core/analysis/meter/script/
+
+# 4. Check manifest files
+cat build-tools/mal-compiler/target/generated-mal-classes/META-INF/mal-meter-classes.txt | wc -l
+cat build-tools/mal-compiler/target/generated-mal-classes/META-INF/mal-groovy-scripts.txt | wc -l
+cat build-tools/mal-compiler/target/generated-mal-classes/META-INF/lal-scripts.txt | wc -l
+
+# 5. Check MeterFunction manifest (produced by oal-exporter)
+cat build-tools/oal-exporter/target/generated-oal-classes/META-INF/annotation-scan/MeterFunction.txt
+
+# 6. Verify tests pass
+make build-distro  # runs MALCompilerTest + MALPrecompiledRegistrationTest
+```