File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/interop Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 46
46
47
47
import java .io .ByteArrayOutputStream ;
48
48
import java .io .IOException ;
49
+ import java .io .UnsupportedEncodingException ;
49
50
import java .util .Arrays ;
50
51
import java .util .List ;
51
- import java .io .UnsupportedEncodingException ;
52
52
53
53
import org .graalvm .polyglot .Context ;
54
54
import org .graalvm .polyglot .Context .Builder ;
55
+ import org .graalvm .polyglot .Engine ;
55
56
import org .graalvm .polyglot .Source ;
56
57
import org .graalvm .polyglot .Value ;
57
58
import org .junit .After ;
@@ -434,4 +435,19 @@ public void accessJavaObjectGetters() throws IOException {
434
435
"True <class 'bool'>\n " +
435
436
"c <class 'str'>\n " , out .toString ("UTF-8" ));
436
437
}
438
+
439
+ @ Test
440
+ public void testSharedEngineNoAccess () {
441
+ try (Engine engine = Engine .create ()) {
442
+ Source source = Source .create ("python" , "21 + 21" );
443
+ try (Context ctxt = Context .newBuilder ().engine (engine ).allowAllAccess (false ).build ()) {
444
+ int v = ctxt .eval (source ).asInt ();
445
+ assert v == 42 ;
446
+ }
447
+ try (Context ctxt = Context .newBuilder ().engine (engine ).allowAllAccess (false ).build ()) {
448
+ int v = ctxt .eval (source ).asInt ();
449
+ assert v == 42 ;
450
+ }
451
+ }
452
+ }
437
453
}
You can’t perform that action at this time.
0 commit comments