harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Zhou (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-6042) [classlib][luni] Classes can not be loaded correctly in sealed-packages
Date Fri, 12 Dec 2008 02:08:44 GMT
[classlib][luni] Classes can not be loaded correctly in sealed-packages
-----------------------------------------------------------------------

                 Key: HARMONY-6042
                 URL: https://issues.apache.org/jira/browse/HARMONY-6042
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M8
            Reporter: Kevin Zhou
             Fix For: 5.0M9


Given a  test case [1], conduct it on HARMONY and RI.
RI works well while HARMONY can not.

In addition, to run this test, you need to deploy three new jars to [support]/src/test/java/tests/resources/Package.
(1) hyts_d.jar: unsealed/no-manifest
(2) hyts_d1.jar: unsealed/manifest
(3) hyts_d2.jar: sealed/mainfest 

[1] Test Case
public void test_SealedPackage_forName() throws Exception {
        Support_Resources.copyFile(resources, "Package", "hyts_c.jar");
        Support_Resources.copyFile(resources, "Package", "hyts_d.jar");
        Support_Resources.copyFile(resources, "Package", "hyts_d1.jar");
        Support_Resources.copyFile(resources, "Package", "hyts_d2.jar");
        URL resourceURL1 = new URL("file:/" + resPath + "/Package/hyts_c.jar");
        URL resourceURL2 = new URL("file:/" + resPath + "/Package/hyts_d.jar");
        URL resourceURL3 = new URL("file:/" + resPath + "/Package/hyts_d1.jar");
        URL resourceURL4 = new URL("file:/" + resPath + "/Package/hyts_d2.jar");
        URL resourceURL5 = new URL("file:/" + resPath + "/");
        URLClassLoader uclClassLoader;
        // load from the sealed jar, then an unsealed jar with no manifest
        uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
                resourceURL2 }, null);
        Class.forName("p.C", true, uclClassLoader);
        try {
            Class.forName("p.D", true, uclClassLoader);
            fail("should throw SecurityException");
        } catch (SecurityException e) {
            // Expected
        }
        // setup for next test
        Support_Resources.copyFile(resources, "p", "");
        InputStream in = uclClassLoader.getResourceAsStream("p/D.class");
        Support_Resources.copyLocalFileto(new File(resources.toString(),
                "p/D.class"), in);
        // load from a sealed jar, then the directory
        uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
                resourceURL5 }, null);
        Class.forName("p.C", true, uclClassLoader);
        try {
            Class.forName("p.D", true, uclClassLoader);
            fail("should throw SecurityException");
        } catch (SecurityException e) {
            // Expected
        }
        // load from a directory, then the sealed jar
        uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
                resourceURL5 }, null);
        Class.forName("p.D", true, uclClassLoader);
        try {
            Class.forName("p.C", true, uclClassLoader);
            fail("should throw SecurityException");
        } catch (SecurityException e) {
            // Expected
        }
        // load from an unsealed jar with no manifest, then the sealed jar
        uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
                resourceURL2 }, null);
        Class.forName("p.D", true, uclClassLoader);
        try {
            Class.forName("p.C", true, uclClassLoader);
            fail("should throw SecurityException");
        } catch (SecurityException e) {
            // Expected
        }
        // load from an unsealed jar with a manifest, then the sealed jar
        uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
                resourceURL3 }, null);
        Class.forName("p.C", true, uclClassLoader);
        try {
            Class.forName("p.D", true, uclClassLoader);
            fail("should throw SecurityException");
        } catch (SecurityException e) {
            // Expected
        }
        // load from an sealed jar, then the unsealed jar with a manifest
        uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
                resourceURL3 }, null);
        Class.forName("p.D", true, uclClassLoader);
        try {
            Class.forName("p.C", true, uclClassLoader);
            fail("should throw SecurityException");
        } catch (SecurityException e) {
            // Expected
        }
        // load from the sealed jar, then another sealed jar
        uclClassLoader = new java.net.URLClassLoader(new URL[] { resourceURL1,
                resourceURL4 }, null);
        Class.forName("p.C", true, uclClassLoader);
        try {
            Class.forName("p.D", true, uclClassLoader);
            fail("should throw SecurityException");
        } catch (SecurityException e) {
            // Expected
        }
    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message