author | sundar |
Tue, 12 Mar 2013 18:12:42 +0530 | |
changeset 16522 | d643e3ee819c |
parent 16234 | 86cb162cec6c |
child 16525 | 1409942e618e |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
16151 | 2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
16147 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.nashorn.internal.runtime; |
|
27 |
||
28 |
import java.security.CodeSource; |
|
16522 | 29 |
import java.security.ProtectionDomain; |
16147 | 30 |
|
31 |
/** |
|
16226
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16151
diff
changeset
|
32 |
* Responsible for loading script generated classes. |
16147 | 33 |
* |
34 |
*/ |
|
35 |
final class ScriptLoader extends NashornLoader { |
|
36 |
/** |
|
37 |
* Constructor. |
|
38 |
*/ |
|
16226
0e4f37e6cc40
8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
16151
diff
changeset
|
39 |
ScriptLoader(final StructureLoader parent, final Context context) { |
16147 | 40 |
super(parent, context); |
41 |
} |
|
42 |
||
16234
86cb162cec6c
8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents:
16226
diff
changeset
|
43 |
@Override |
86cb162cec6c
8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents:
16226
diff
changeset
|
44 |
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { |
86cb162cec6c
8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents:
16226
diff
changeset
|
45 |
checkPackageAccess(name); |
86cb162cec6c
8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents:
16226
diff
changeset
|
46 |
return super.loadClassTrusted(name, resolve); |
86cb162cec6c
8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents:
16226
diff
changeset
|
47 |
} |
86cb162cec6c
8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents:
16226
diff
changeset
|
48 |
|
16147 | 49 |
// package-private and private stuff below this point |
50 |
||
51 |
/** |
|
52 |
* Install a class for use by the Nashorn runtime |
|
53 |
* |
|
54 |
* @param name Binary name of class. |
|
55 |
* @param data Class data bytes. |
|
56 |
* @param cs CodeSource code source of the class bytes. |
|
57 |
* |
|
58 |
* @return Installed class. |
|
59 |
*/ |
|
60 |
synchronized Class<?> installClass(final String name, final byte[] data, final CodeSource cs) { |
|
16522 | 61 |
if (cs == null) { |
62 |
return defineClass(name, data, 0, data.length, new ProtectionDomain(null, getPermissions(null))); |
|
63 |
} else { |
|
64 |
return defineClass(name, data, 0, data.length, cs); |
|
65 |
} |
|
16147 | 66 |
} |
67 |
} |