Issue Details (XML | Word | Printable)

Key: HARMONY-6042
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Sean Qiu
Reporter: Kevin Zhou
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Harmony

[classlib][luni] Classes can not be loaded correctly in sealed-packages

Created: 12/Dec/08 02:07 AM   Updated: 12/Jan/09 07:35 AM
Return to search
Component/s: Classlib
Affects Version/s: 5.0M8
Fix Version/s: 5.0M9

Time Tracking:
Original Estimate: 24h
Original Estimate - 24h
Remaining Estimate: 24h
Remaining Estimate - 24h
Time Spent: Not Specified
Remaining Estimate - 24h

File Attachments:
  Size
File Licensed for inclusion in ASF works HARMONY-6042.diff 2008-12-12 02:17 AM Kevin Zhou 7 kB
Java Archive File Licensed for inclusion in ASF works hyts_d.jar 2008-12-12 02:08 AM Kevin Zhou 0.6 kB
Java Archive File Licensed for inclusion in ASF works hyts_d1.jar 2008-12-12 02:08 AM Kevin Zhou 1 kB
Java Archive File Licensed for inclusion in ASF works hyts_d2.jar 2008-12-12 02:08 AM Kevin Zhou 1 kB

Estimated Complexity: Moderate
Resolution Date: 12/Jan/09 03:21 AM


 Description  « Hide
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
        }
    }

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #733589 Mon Jan 12 03:04:22 UTC 2009 qiuxx Apply for HARMONY-6042,([classlib][luni] Classes can not be loaded correctly in sealed-packages) Add support jar files for testing which will be used by the fix.
Files Changed
ADD /harmony/enhanced/classlib/trunk/support/src/test/java/tests/resources/Package/hyts_d1.jar
ADD /harmony/enhanced/classlib/trunk/support/src/test/java/tests/resources/Package/hyts_d2.jar
ADD /harmony/enhanced/classlib/trunk/support/src/test/java/tests/resources/Package/hyts_d.jar

Repository Revision Date User Message
ASF #733590 Mon Jan 12 03:07:33 UTC 2009 qiuxx Apply for HARMONY-6042,([classlib][luni] Classes can not be loaded correctly in sealed-packages)
Files Changed
MODIFY /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
MODIFY /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/PackageTest.java
MODIFY /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLClassLoader.java