test/script/sandbox/classloader.js

changeset 717
eca774d33fa4
parent 7
5a1b0714df0e
child 952
6d5471a497fb
child 962
ac62e33a99b0
equal deleted inserted replaced
716:a43c125b03dc 717:eca774d33fa4
24 /** 24 /**
25 * Try to extend ClassLoader. 25 * Try to extend ClassLoader.
26 * 26 *
27 * @test 27 * @test
28 * @security 28 * @security
29 * @bug JDK-8032954: Nashorn: extend Java.extend
29 */ 30 */
30 31
31 try { 32 try {
32 var l = new (Java.extend(java.lang.ClassLoader))({}); 33 var l = new (Java.extend(java.lang.ClassLoader))({});
33 fail("should have thrown SecurityException"); 34 fail("should have thrown SecurityException");
37 } else { 38 } else {
38 fail("expected SecurityException, got " + e); 39 fail("expected SecurityException, got " + e);
39 } 40 }
40 } 41 }
41 42
43 try {
44 Java.extend(Java.type('java.lang.ClassLoader'));
45 fail("should have thrown SecurityException");
46 } catch (e) {
47 if (e instanceof java.lang.SecurityException) {
48 print(e);
49 } else {
50 fail("expected SecurityException, got " + e);
51 }
52 }
53
54 try {
55 Java.extend(Java.type("javax.management.loading.MLet"));
56 fail("should have thrown SecurityException");
57 } catch (e) {
58 if (e instanceof java.lang.SecurityException) {
59 print(e);
60 } else {
61 fail("expected SecurityException, got " + e);
62 }
63 }

mercurial