Repository: jenkinsci/jenkins
File: core/src/main/java/hudson/lifecycle/Lifecycle.java (Java)

Code before:
import java.io.UncheckedIOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import jenkins.RestartRequiredException;
import jenkins.model.Jenkins;
import jenkins.util.SystemProperties;
import org.apache.commons.io.FileUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.Beta;
import org.kohsuke.accmod.restrictions.NoExternalUse;

/**
 * Provides the capability for starting/stopping/restarting/uninstalling Hudson.
 *
 * <p>
 * The steps to perform these operations depend on how Hudson is launched,
 * so the concrete instance of this method (which is VM-wide singleton) is discovered
 * by looking up a FQCN from the system property "hudson.lifecycle".
 * (This may be set to a class defined in a plugin,
 * in which case the singleton switches during startup.)
 * @author Kohsuke Kawaguchi
 * @since 1.254
 */
public abstract class Lifecycle implements ExtensionPoint {
    private static Lifecycle INSTANCE = null;

    /**
     * Gets the singleton instance.
     */
    @NonNull
    public static synchronized Lifecycle get() {
        if (INSTANCE == null) {
            Lifecycle instance;
            String p = SystemProperties.getString("hudson.lifecycle");
            if (p != null) {
                try {
                    ClassLoader cl = Jenkins.get().getPluginManager().uberClassLoader;
                    instance = (Lifecycle) cl.loadClass(p).getDeclaredConstructor().newInstance();
                } catch (NoSuchMethodException e) {
                    NoSuchMethodError x = new NoSuchMethodError(e.getMessage());
                    x.initCause(e);
                    throw x;
                } catch (InstantiationException e) {
                    InstantiationError x = new InstantiationError(e.getMessage());
                    x.initCause(e);
                    throw x;
                } catch (IllegalAccessException e) {
                    IllegalAccessError x = new IllegalAccessError(e.getMessage());

Review comment (security):
And `Lifecycle` does not even use the extension loader to begin with! Traditionally `ExtensionPoint` was just used as a very hand-wavy indicator for “things you might want to pay attention to in Javadoc as a plugin author”, rather than specifically meaning “a type which can be subtyped and marked with `@Extension` to register”. (A broad category of such mistakes is placing `ExtensionPoint` on a `Describable`. It is the `Descriptor` which is the extension point.)

Code after:
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import jenkins.RestartRequiredException;
import jenkins.model.Jenkins;
import jenkins.util.SystemProperties;
import org.apache.commons.io.FileUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.Beta;
import org.kohsuke.accmod.restrictions.NoExternalUse;

/**
 * Provides the capability for starting/stopping/restarting/uninstalling Hudson.
 *
 * <p>
 * The steps to perform these operations depend on how Hudson is launched,
 * so the concrete instance of this method (which is VM-wide singleton) is discovered
 * by looking up a FQCN from the system property "hudson.lifecycle".
 * (This may be set to a class defined in a plugin,
 * in which case the singleton switches during startup.)
 * @author Kohsuke Kawaguchi
 * @since 1.254
 */
public abstract class Lifecycle {
    private static Lifecycle INSTANCE = null;

    /**
     * Gets the singleton instance.
     */
    @NonNull
    public static synchronized Lifecycle get() {
        if (INSTANCE == null) {
            Lifecycle instance;
            String p = SystemProperties.getString("hudson.lifecycle");
            if (p != null) {
                try {
                    ClassLoader cl = Jenkins.get().getPluginManager().uberClassLoader;
                    instance = (Lifecycle) cl.loadClass(p).getDeclaredConstructor().newInstance();
                } catch (NoSuchMethodException e) {
                    NoSuchMethodError x = new NoSuchMethodError(e.getMessage());
                    x.initCause(e);
                    throw x;
                } catch (InstantiationException e) {
                    InstantiationError x = new InstantiationError(e.getMessage());
                    x.initCause(e);
                    throw x;
                } catch (IllegalAccessException e) {
                    IllegalAccessError x = new IllegalAccessError(e.getMessage());
                    x.initCause(e);