test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java
changeset 52015 821bfc24d750
parent 51700 0fa33d4e721e
child 52705 53a407ab6d22
equal deleted inserted replaced
52014:1aa9beac610e 52015:821bfc24d750
    55     output.shouldHaveExitValue(0);
    55     output.shouldHaveExitValue(0);
    56   }
    56   }
    57 
    57 
    58   static class Test {
    58   static class Test {
    59     public static void test() throws Exception {
    59     public static void test() throws Exception {
    60       Unsafe unsafe = Unsafe.getUnsafe();
       
    61       TestClassLoader classloader = new TestClassLoader();
    60       TestClassLoader classloader = new TestClassLoader();
    62       ProtectionDomain pd = new ProtectionDomain(null, null);
    61       ProtectionDomain pd = new ProtectionDomain(null, null);
    63       byte klassbuf[] = InMemoryJavaCompiler.compile("TestClass", "class TestClass { }");
    62       byte klassbuf[] = InMemoryJavaCompiler.compile("TestClass", "class TestClass { }");
    64       Class klass = unsafe.defineClass(null, klassbuf, 0, klassbuf.length, classloader, pd);
    63       Class<?> klass = classloader.defineClass("TestClass", klassbuf, pd);
    65     }
    64     }
    66 
    65 
    67     public static void main(String[] args) throws Exception {
    66     public static void main(String[] args) throws Exception {
    68       WhiteBox wb = WhiteBox.getWhiteBox();
    67       WhiteBox wb = WhiteBox.getWhiteBox();
    69       int removedCountOrig =  wb.protectionDomainRemovedCount();
    68       int removedCountOrig =  wb.protectionDomainRemovedCount();
    89 
    88 
    90     private static class TestClassLoader extends ClassLoader {
    89     private static class TestClassLoader extends ClassLoader {
    91       public TestClassLoader() {
    90       public TestClassLoader() {
    92         super();
    91         super();
    93       }
    92       }
       
    93 
       
    94       public Class<?> defineClass(String name, byte[] bytes, ProtectionDomain pd) {
       
    95         return defineClass(name, bytes, 0, bytes.length, pd);
       
    96       }
    94     }
    97     }
    95   }
    98   }
    96 }
    99 }