41 lines
1.2 KiB
Java
Executable File
41 lines
1.2 KiB
Java
Executable File
/*
|
|
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
|
*/
|
|
|
|
package test;
|
|
|
|
import javax.script.ScriptEngine;
|
|
import javax.script.ScriptEngineManager;
|
|
|
|
public class Final {
|
|
public static class TestClass {
|
|
protected void method1() {
|
|
System.out.println("On protected");
|
|
}
|
|
final public void method2() {
|
|
System.out.println("On final public");
|
|
}
|
|
final protected void method3() {
|
|
System.out.println("On final protected");
|
|
}
|
|
}
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
|
|
|
|
engine.eval("import test.Final.TestClass");
|
|
|
|
engine.eval("class MyClass(test.Final.TestClass):\n"
|
|
+ " def m1(self):\n"
|
|
+ " self.method1()\n"
|
|
+ " def m2(self):\n"
|
|
+ " self.method2()\n"
|
|
+ " def m3(self):\n"
|
|
+ " self.method3()\n");
|
|
engine.eval("o = MyClass()");
|
|
|
|
engine.eval("o.m1()");
|
|
engine.eval("o.m2()");
|
|
engine.eval("o.m3()");
|
|
}
|
|
} |