Java Code Examples for java.rmi.server.RMIClassLoader#getClassAnnotation()

The following examples show how to use java.rmi.server.RMIClassLoader#getClassAnnotation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultProperty.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        ServiceConfiguration.installServiceConfigurationFile();

        System.setProperty(
            "java.rmi.server.RMIClassLoaderSpi", "default");

        String classname = "Foo";

        URL codebaseURL = null;
        try {
            codebaseURL = TestLibrary.installClassInCodebase(
                classname, "remote_codebase");
        } catch (MalformedURLException e) {
            TestLibrary.bomb(e);
        }

        TestLibrary.suggestSecurityManager(null);

        Class fooClass = RMIClassLoader.loadClass(codebaseURL, classname);
        if (!fooClass.getName().equals(classname)) {
            throw new RuntimeException(
                "wrong class name, expected: " + classname +
                ", received: " + fooClass.getName());
        }

        String annotation = RMIClassLoader.getClassAnnotation(fooClass);
        if (!annotation.equals(codebaseURL.toString())) {
            throw new RuntimeException(
                "wrong class annotation, expected: " + codebaseURL.toString() +
                ", received: " + annotation);
        }

        System.err.println("TEST PASSED");
    }
 
Example 2
Source File: DefaultProperty.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        ServiceConfiguration.installServiceConfigurationFile();

        System.setProperty(
            "java.rmi.server.RMIClassLoaderSpi", "default");

        String classname = "Foo";

        URL codebaseURL = null;
        try {
            codebaseURL = TestLibrary.installClassInCodebase(
                classname, "remote_codebase");
        } catch (MalformedURLException e) {
            TestLibrary.bomb(e);
        }

        TestLibrary.suggestSecurityManager(null);

        Class fooClass = RMIClassLoader.loadClass(codebaseURL, classname);
        if (!fooClass.getName().equals(classname)) {
            throw new RuntimeException(
                "wrong class name, expected: " + classname +
                ", received: " + fooClass.getName());
        }

        String annotation = RMIClassLoader.getClassAnnotation(fooClass);
        if (!annotation.equals(codebaseURL.toString())) {
            throw new RuntimeException(
                "wrong class annotation, expected: " + codebaseURL.toString() +
                ", received: " + annotation);
        }

        System.err.println("TEST PASSED");
    }
 
Example 3
Source File: LoadProxyClasses.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void checkLoad(Proxy proxy, ClassLoader expectedLoader) {
    ClassLoader proxyLoader = proxy.getClass().getClassLoader();

    String proxyAnnotation =
        RMIClassLoader.getClassAnnotation(proxy.getClass());

    if ((proxyAnnotation == null) ||
        !proxyAnnotation.equals(publicUrl.toString()))
    {
        TestLibrary.bomb("proxy class had incorrect annotation: " +
                         proxyAnnotation);
    } else {
        System.err.println("proxy class had correct annotation: " +
                           proxyAnnotation);
    }

    boolean proxyOk = false;

    if (boomerangSemantics) {
        ClassLoader ctxLoader =
            Thread.currentThread().getContextClassLoader();
        if (proxyLoader == ctxLoader) {
            proxyOk = true;
        }
    } else if (proxyLoader.getClass().
               getName().indexOf("sun.rmi") >= 0)
    {
        proxyOk = true;
    }

    if (proxyOk) {
        System.err.println("\ncase5: proxy loaded from" +
                           " correct loader: " + proxyLoader);
    } else {
        TestLibrary.bomb("case5: proxy interface loaded from " +
                         "incorrect loader: " + proxyLoader);
    }
}
 
Example 4
Source File: DefaultProperty.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        ServiceConfiguration.installServiceConfigurationFile();

        System.setProperty(
            "java.rmi.server.RMIClassLoaderSpi", "default");

        String classname = "Foo";

        URL codebaseURL = null;
        try {
            codebaseURL = TestLibrary.installClassInCodebase(
                classname, "remote_codebase");
        } catch (MalformedURLException e) {
            TestLibrary.bomb(e);
        }

        TestLibrary.suggestSecurityManager(null);

        Class fooClass = RMIClassLoader.loadClass(codebaseURL, classname);
        if (!fooClass.getName().equals(classname)) {
            throw new RuntimeException(
                "wrong class name, expected: " + classname +
                ", received: " + fooClass.getName());
        }

        String annotation = RMIClassLoader.getClassAnnotation(fooClass);
        if (!annotation.equals(codebaseURL.toString())) {
            throw new RuntimeException(
                "wrong class annotation, expected: " + codebaseURL.toString() +
                ", received: " + annotation);
        }

        System.err.println("TEST PASSED");
    }
 
Example 5
Source File: DefaultProperty.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        ServiceConfiguration.installServiceConfigurationFile();

        System.setProperty(
            "java.rmi.server.RMIClassLoaderSpi", "default");

        String classname = "Foo";

        URL codebaseURL = null;
        try {
            codebaseURL = TestLibrary.installClassInCodebase(
                classname, "remote_codebase");
        } catch (MalformedURLException e) {
            TestLibrary.bomb(e);
        }

        TestLibrary.suggestSecurityManager(null);

        Class fooClass = RMIClassLoader.loadClass(codebaseURL, classname);
        if (!fooClass.getName().equals(classname)) {
            throw new RuntimeException(
                "wrong class name, expected: " + classname +
                ", received: " + fooClass.getName());
        }

        String annotation = RMIClassLoader.getClassAnnotation(fooClass);
        if (!annotation.equals(codebaseURL.toString())) {
            throw new RuntimeException(
                "wrong class annotation, expected: " + codebaseURL.toString() +
                ", received: " + annotation);
        }

        System.err.println("TEST PASSED");
    }
 
Example 6
Source File: LoadProxyClasses.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void checkLoad(Proxy proxy, ClassLoader expectedLoader) {
    ClassLoader proxyLoader = proxy.getClass().getClassLoader();

    String proxyAnnotation =
        RMIClassLoader.getClassAnnotation(proxy.getClass());

    if ((proxyAnnotation == null) ||
        !proxyAnnotation.equals(publicUrl.toString()))
    {
        TestLibrary.bomb("proxy class had incorrect annotation: " +
                         proxyAnnotation);
    } else {
        System.err.println("proxy class had correct annotation: " +
                           proxyAnnotation);
    }

    boolean proxyOk = false;

    if (boomerangSemantics) {
        ClassLoader ctxLoader =
            Thread.currentThread().getContextClassLoader();
        if (proxyLoader == ctxLoader) {
            proxyOk = true;
        }
    } else if (proxyLoader.getClass().
               getName().indexOf("sun.rmi") >= 0)
    {
        proxyOk = true;
    }

    if (proxyOk) {
        System.err.println("\ncase5: proxy loaded from" +
                           " correct loader: " + proxyLoader);
    } else {
        TestLibrary.bomb("case5: proxy interface loaded from " +
                         "incorrect loader: " + proxyLoader);
    }
}
 
Example 7
Source File: LoadProxyClasses.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void checkLoad(Proxy proxy, ClassLoader expectedLoader) {
    ClassLoader proxyLoader = proxy.getClass().getClassLoader();

    String proxyAnnotation =
        RMIClassLoader.getClassAnnotation(proxy.getClass());

    if ((proxyAnnotation == null) ||
        !proxyAnnotation.equals(publicUrl.toString()))
    {
        TestLibrary.bomb("proxy class had incorrect annotation: " +
                         proxyAnnotation);
    } else {
        System.err.println("proxy class had correct annotation: " +
                           proxyAnnotation);
    }

    boolean proxyOk = false;

    if (boomerangSemantics) {
        ClassLoader ctxLoader =
            Thread.currentThread().getContextClassLoader();
        if (proxyLoader == ctxLoader) {
            proxyOk = true;
        }
    } else if (proxyLoader.getClass().
               getName().indexOf("sun.rmi") >= 0)
    {
        proxyOk = true;
    }

    if (proxyOk) {
        System.err.println("\ncase5: proxy loaded from" +
                           " correct loader: " + proxyLoader);
    } else {
        TestLibrary.bomb("case5: proxy interface loaded from " +
                         "incorrect loader: " + proxyLoader);
    }
}
 
Example 8
Source File: DefaultProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        ServiceConfiguration.installServiceConfigurationFile();

        System.setProperty(
            "java.rmi.server.RMIClassLoaderSpi", "default");

        String classname = "Foo";

        URL codebaseURL = null;
        try {
            codebaseURL = TestLibrary.installClassInCodebase(
                classname, "remote_codebase");
        } catch (MalformedURLException e) {
            TestLibrary.bomb(e);
        }

        TestLibrary.suggestSecurityManager(null);

        Class fooClass = RMIClassLoader.loadClass(codebaseURL, classname);
        if (!fooClass.getName().equals(classname)) {
            throw new RuntimeException(
                "wrong class name, expected: " + classname +
                ", received: " + fooClass.getName());
        }

        String annotation = RMIClassLoader.getClassAnnotation(fooClass);
        if (!annotation.equals(codebaseURL.toString())) {
            throw new RuntimeException(
                "wrong class annotation, expected: " + codebaseURL.toString() +
                ", received: " + annotation);
        }

        System.err.println("TEST PASSED");
    }
 
Example 9
Source File: LoadProxyClasses.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void checkLoad(Proxy proxy, ClassLoader expectedLoader) {
    ClassLoader proxyLoader = proxy.getClass().getClassLoader();

    String proxyAnnotation =
        RMIClassLoader.getClassAnnotation(proxy.getClass());

    if ((proxyAnnotation == null) ||
        !proxyAnnotation.equals(publicUrl.toString()))
    {
        TestLibrary.bomb("proxy class had incorrect annotation: " +
                         proxyAnnotation);
    } else {
        System.err.println("proxy class had correct annotation: " +
                           proxyAnnotation);
    }

    boolean proxyOk = false;

    if (boomerangSemantics) {
        ClassLoader ctxLoader =
            Thread.currentThread().getContextClassLoader();
        if (proxyLoader == ctxLoader) {
            proxyOk = true;
        }
    } else if (proxyLoader.getClass().
               getName().indexOf("sun.rmi") >= 0)
    {
        proxyOk = true;
    }

    if (proxyOk) {
        System.err.println("\ncase5: proxy loaded from" +
                           " correct loader: " + proxyLoader);
    } else {
        TestLibrary.bomb("case5: proxy interface loaded from " +
                         "incorrect loader: " + proxyLoader);
    }
}
 
Example 10
Source File: LoadProxyClasses.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void checkLoad(Proxy proxy, ClassLoader expectedLoader) {
    ClassLoader proxyLoader = proxy.getClass().getClassLoader();

    String proxyAnnotation =
        RMIClassLoader.getClassAnnotation(proxy.getClass());

    if ((proxyAnnotation == null) ||
        !proxyAnnotation.equals(publicUrl.toString()))
    {
        TestLibrary.bomb("proxy class had incorrect annotation: " +
                         proxyAnnotation);
    } else {
        System.err.println("proxy class had correct annotation: " +
                           proxyAnnotation);
    }

    boolean proxyOk = false;

    if (boomerangSemantics) {
        ClassLoader ctxLoader =
            Thread.currentThread().getContextClassLoader();
        if (proxyLoader == ctxLoader) {
            proxyOk = true;
        }
    } else if (proxyLoader.getClass().
               getName().indexOf("sun.rmi") >= 0)
    {
        proxyOk = true;
    }

    if (proxyOk) {
        System.err.println("\ncase5: proxy loaded from" +
                           " correct loader: " + proxyLoader);
    } else {
        TestLibrary.bomb("case5: proxy interface loaded from " +
                         "incorrect loader: " + proxyLoader);
    }
}
 
Example 11
Source File: DefaultProperty.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        ServiceConfiguration.installServiceConfigurationFile();

        System.setProperty(
            "java.rmi.server.RMIClassLoaderSpi", "default");

        String classname = "Foo";

        URL codebaseURL = null;
        try {
            codebaseURL = TestLibrary.installClassInCodebase(
                classname, "remote_codebase");
        } catch (MalformedURLException e) {
            TestLibrary.bomb(e);
        }

        TestLibrary.suggestSecurityManager(null);

        Class fooClass = RMIClassLoader.loadClass(codebaseURL, classname);
        if (!fooClass.getName().equals(classname)) {
            throw new RuntimeException(
                "wrong class name, expected: " + classname +
                ", received: " + fooClass.getName());
        }

        String annotation = RMIClassLoader.getClassAnnotation(fooClass);
        if (!annotation.equals(codebaseURL.toString())) {
            throw new RuntimeException(
                "wrong class annotation, expected: " + codebaseURL.toString() +
                ", received: " + annotation);
        }

        System.err.println("TEST PASSED");
    }
 
Example 12
Source File: LoadProxyClasses.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void checkLoad(Proxy proxy, ClassLoader expectedLoader) {
    ClassLoader proxyLoader = proxy.getClass().getClassLoader();

    String proxyAnnotation =
        RMIClassLoader.getClassAnnotation(proxy.getClass());

    if ((proxyAnnotation == null) ||
        !proxyAnnotation.equals(publicUrl.toString()))
    {
        TestLibrary.bomb("proxy class had incorrect annotation: " +
                         proxyAnnotation);
    } else {
        System.err.println("proxy class had correct annotation: " +
                           proxyAnnotation);
    }

    boolean proxyOk = false;

    if (boomerangSemantics) {
        ClassLoader ctxLoader =
            Thread.currentThread().getContextClassLoader();
        if (proxyLoader == ctxLoader) {
            proxyOk = true;
        }
    } else if (proxyLoader.getClass().
               getName().indexOf("sun.rmi") >= 0)
    {
        proxyOk = true;
    }

    if (proxyOk) {
        System.err.println("\ncase5: proxy loaded from" +
                           " correct loader: " + proxyLoader);
    } else {
        TestLibrary.bomb("case5: proxy interface loaded from " +
                         "incorrect loader: " + proxyLoader);
    }
}
 
Example 13
Source File: DefaultProperty.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        ServiceConfiguration.installServiceConfigurationFile();

        System.setProperty(
            "java.rmi.server.RMIClassLoaderSpi", "default");

        String classname = "Foo";

        URL codebaseURL = null;
        try {
            codebaseURL = TestLibrary.installClassInCodebase(
                classname, "remote_codebase");
        } catch (MalformedURLException e) {
            TestLibrary.bomb(e);
        }

        TestLibrary.suggestSecurityManager(null);

        Class fooClass = RMIClassLoader.loadClass(codebaseURL, classname);
        if (!fooClass.getName().equals(classname)) {
            throw new RuntimeException(
                "wrong class name, expected: " + classname +
                ", received: " + fooClass.getName());
        }

        String annotation = RMIClassLoader.getClassAnnotation(fooClass);
        if (!annotation.equals(codebaseURL.toString())) {
            throw new RuntimeException(
                "wrong class annotation, expected: " + codebaseURL.toString() +
                ", received: " + annotation);
        }

        System.err.println("TEST PASSED");
    }
 
Example 14
Source File: LoadProxyClasses.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void checkLoad(Proxy proxy, ClassLoader expectedLoader) {
    ClassLoader proxyLoader = proxy.getClass().getClassLoader();

    String proxyAnnotation =
        RMIClassLoader.getClassAnnotation(proxy.getClass());

    if ((proxyAnnotation == null) ||
        !proxyAnnotation.equals(publicUrl.toString()))
    {
        TestLibrary.bomb("proxy class had incorrect annotation: " +
                         proxyAnnotation);
    } else {
        System.err.println("proxy class had correct annotation: " +
                           proxyAnnotation);
    }

    boolean proxyOk = false;

    if (boomerangSemantics) {
        ClassLoader ctxLoader =
            Thread.currentThread().getContextClassLoader();
        if (proxyLoader == ctxLoader) {
            proxyOk = true;
        }
    } else if (proxyLoader.getClass().
               getName().indexOf("sun.rmi") >= 0)
    {
        proxyOk = true;
    }

    if (proxyOk) {
        System.err.println("\ncase5: proxy loaded from" +
                           " correct loader: " + proxyLoader);
    } else {
        TestLibrary.bomb("case5: proxy interface loaded from " +
                         "incorrect loader: " + proxyLoader);
    }
}
 
Example 15
Source File: LoadProxyClasses.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void checkLoad(Proxy proxy, ClassLoader expectedLoader) {
    ClassLoader proxyLoader = proxy.getClass().getClassLoader();

    String proxyAnnotation =
        RMIClassLoader.getClassAnnotation(proxy.getClass());

    if ((proxyAnnotation == null) ||
        !proxyAnnotation.equals(publicUrl.toString()))
    {
        TestLibrary.bomb("proxy class had incorrect annotation: " +
                         proxyAnnotation);
    } else {
        System.err.println("proxy class had correct annotation: " +
                           proxyAnnotation);
    }

    boolean proxyOk = false;

    if (boomerangSemantics) {
        ClassLoader ctxLoader =
            Thread.currentThread().getContextClassLoader();
        if (proxyLoader == ctxLoader) {
            proxyOk = true;
        }
    } else if (proxyLoader.getClass().
               getName().indexOf("sun.rmi") >= 0)
    {
        proxyOk = true;
    }

    if (proxyOk) {
        System.err.println("\ncase5: proxy loaded from" +
                           " correct loader: " + proxyLoader);
    } else {
        TestLibrary.bomb("case5: proxy interface loaded from " +
                         "incorrect loader: " + proxyLoader);
    }
}
 
Example 16
Source File: Util.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the codebase, if any, for the given class.
 * @param clz the class to get a codebase for.
 * @return a space-separated list of URLs, or null.
 */
public String getCodebase(java.lang.Class clz) {
    return RMIClassLoader.getClassAnnotation(clz);
}
 
Example 17
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the codebase, if any, for the given class.
 * @param clz the class to get a codebase for.
 * @return a space-separated list of URLs, or null.
 */
public String getCodebase(java.lang.Class clz) {
    return RMIClassLoader.getClassAnnotation(clz);
}
 
Example 18
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the codebase, if any, for the given class.
 * @param clz the class to get a codebase for.
 * @return a space-separated list of URLs, or null.
 */
public String getCodebase(java.lang.Class clz) {
    return RMIClassLoader.getClassAnnotation(clz);
}
 
Example 19
Source File: Util.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the codebase, if any, for the given class.
 * @param clz the class to get a codebase for.
 * @return a space-separated list of URLs, or null.
 */
public String getCodebase(java.lang.Class clz) {
    return RMIClassLoader.getClassAnnotation(clz);
}
 
Example 20
Source File: Util.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the codebase, if any, for the given class.
 * @param clz the class to get a codebase for.
 * @return a space-separated list of URLs, or null.
 */
public String getCodebase(java.lang.Class clz) {
    return RMIClassLoader.getClassAnnotation(clz);
}