gnodet-bot commented on code in PR #13588: URL: https://github.com/apache/maven/pull/13588#discussion_r4301620395
########## src/site/markdown/classloading.md: ########## @@ -0,0 +1,325 @@ +<!--- +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. Solid arrows indicate the parent classloader +relationship. Dashed blue arrows indicate package imports. Dashed green +arrows indicate export feeds. + + + +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 — still not fixed.** The table still marks `parent-first` as the default. Per `core-extensions.mdo`: ```xml <defaultValue>self-first</defaultValue> ``` The description reads: *"The class loading strategy: 'self-first' (the **default**), 'parent-first'…"* Swap the `(default)` annotation to the `self-first` row: ```suggestion | `parent-first` | Imports everything from the core realm. Classes from the core are preferred over the extension's own. | | `plugin` | Imports only `CoreExports` packages (the Maven API surface). Same isolation as build extensions. | | `self-first` (default) | Uses the core realm as parent but checks its own classes first. Allows the extension to override core classes. | ``` -- 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]
