@@ -0,0 +1,1732 @@
+package org.apache.markt.leaks.rmi;%0A%0Aimport java.lang.ref.WeakReference;%0Aimport java.net.URL;%0Aimport java.net.URLClassLoader;%0Aimport java.rmi.registry.LocateRegistry;%0Aimport java.rmi.registry.Registry;%0A%0Apublic class RegistryLeak %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        RegistryLeak registryLeak = new RegistryLeak();%0A%0A        // Switch TCCL%0A        registryLeak.start();%0A%0A        // Register new object in RMI%0A        registryLeak.register();%0A%0A        // Deregister object%0A        registryLeak.deregister();%0A%0A        // Restore TCCL%0A        registryLeak.stop();%0A%0A        // Trigger GC%0A        System.gc();%0A%0A        // Check for leak%0A        registryLeak.leakCheck();%0A    %7D%0A%0A    private static final ClassLoader ORIGINAL_CLASS_LOADER =%0A            Thread.currentThread().getContextClassLoader();%0A%0A    private WeakReference%3CClassLoader%3E moduleClassLoaderRef;%0A%0A%0A    private void start() %7B%0A        ClassLoader moduleClassLoader = new URLClassLoader(new URL%5B%5D %7B%7D, ORIGINAL_CLASS_LOADER);%0A%0A        Thread.currentThread().setContextClassLoader(moduleClassLoader);%0A        moduleClassLoaderRef = new WeakReference%3C%3E(moduleClassLoader);%0A    %7D%0A%0A%0A    private void register() %7B%0A        try %7B%0A            LocateRegistry.createRegistry(Registry.REGISTRY_PORT);%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A%0A    private void deregister() %7B%0A        // NO-OP. NO API available.%0A    %7D%0A%0A%0A    private void stop() %7B%0A        Thread.currentThread().setContextClassLoader(ORIGINAL_CLASS_LOADER);%0A    %7D%0A%0A%0A    private void leakCheck() %7B%0A        if (moduleClassLoaderRef.get() == null) %7B%0A            System.out.println(%22No leak%22);%0A        %7D else %7B%0A            System.out.println(%22Leak%22);%0A        %7D%0A    %7D%0A%7D

Add a simple Java app that demonstrates a TCCL memory leak with RMI registry creation.