gnodet-bot commented on code in PR #13588: URL: https://github.com/apache/maven/pull/13588#discussion_r4301612050
########## src/site/markdown/classloading.md: ########## @@ -0,0 +1,345 @@ +<!--- +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. +--> + +# Maven Classloading + +This document describes the classloading mechanism used by Maven 4.x. +Maven uses [Plexus Classworlds][classworlds] to build a hierarchy of isolated +classloaders (called **realms**) so that plugins, extensions and the +Maven core can each see only the classes they are supposed to see. + +The following diagram gives an overview of the realm hierarchy during a +typical Maven build: + +``` +JVM System ClassLoader +│ plexus-classworlds + -javaagent classes +│ +├── plexus.core ─────────────────────────────── Maven Core +│ │ ${maven.home}/lib/*.jar +│ │ +│ ├── maven.ext ───────────────────────────── Extensions aggregator +│ │ (only if core extensions or maven.ext.class.path exist) +│ │ +│ ├── coreExtension>G:A:V ─────────────────── Core Extension (one per entry) +│ │ +│ ├── maven.api ───────────────────────────── Maven API +│ │ │ (aggregates exported packages from core + core extensions) +│ │ │ Review Comment: ⚠️ **Diagram inaccuracy.** `maven.api.v4` is shown nested under `maven.api`, implying it is a child realm. It is not — both are created as siblings with `null` parent in `DefaultClassRealmManager`. `maven.api.v4` imports `org.apache.maven.api` and `org.slf4j` directly from the container realm. The diagram should show `maven.api.v4` at the same level as `maven.api`, not indented under it. ########## src/site/markdown/classloading.md: ########## @@ -0,0 +1,345 @@ +<!--- +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. +--> + +# Maven Classloading + +This document describes the classloading mechanism used by Maven 4.x. +Maven uses [Plexus Classworlds][classworlds] to build a hierarchy of isolated +classloaders (called **realms**) so that plugins, extensions and the +Maven core can each see only the classes they are supposed to see. + +The following diagram gives an overview of the realm hierarchy during a +typical Maven build: + +``` +JVM System ClassLoader +│ plexus-classworlds + -javaagent classes +│ +├── plexus.core ─────────────────────────────── Maven Core +│ │ ${maven.home}/lib/*.jar +│ │ +│ ├── maven.ext ───────────────────────────── Extensions aggregator +│ │ (only if core extensions or maven.ext.class.path exist) +│ │ +│ ├── coreExtension>G:A:V ─────────────────── Core Extension (one per entry) +│ │ +│ ├── maven.api ───────────────────────────── Maven API +│ │ │ (aggregates exported packages from core + core extensions) +│ │ │ +│ │ ├── maven.api.v4 ────────────────────── Maven 4 API +│ │ │ (org.apache.maven.api + org.slf4j only) +│ │ │ +│ │ └── project>G:A:V ──────────────────── Project +│ │ (parent=maven.api; imports build extension exports) +│ │ +│ ├── extension>G:A:V ─────────────────────── Build Extension (one per entry) +│ │ (parent=System CL; imports all of maven.api) +│ │ +│ └── plugin>G:A:V ────────────────────────── Plugin (one per GAV+deps) +│ (parent=System CL; imports maven.api or project realm) +``` + +Each realm is described in detail below. + +## ClassWorlds Bootstrap ClassLoader + +This classloader is created and managed by the calling environment: the +JVM launcher, an integration testing harness, or an IDE embedder. + +During a normal command-line invocation this is the JVM System +ClassLoader and contains: + +- `${maven.home}/boot/plexus-classworlds-*.jar` — the Plexus + Classworlds library that bootstraps all other realms +- Any `-javaagent` classes specified on the JVM command line + +## Maven Core Realm (`plexus.core`) + +Contains all Maven runtime classes: `MavenProject`, `AbstractMojo`, +Plexus/Sisu DI, SLF4J, Guice, the Aether resolver, and more. + +The contents are configured by `${maven.home}/bin/m2.conf` and +typically include: + +- `${maven.home}/lib/ext/*.jar` +- `${maven.home}/lib/*.jar` + Review Comment: ⚠️ **Wrong default.** `self-first` is the default per `core-extensions.mdo` (`<defaultValue>self-first</defaultValue>`), not `parent-first`. The table needs to be corrected — swap which row is marked "(default)". -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
