01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: /* Generated by Together */
12:
13: package de.uka.ilkd.key.casetool.together.keydebugclassloader;
14:
15: import com.togethersoft.openapi.ide.IdeContext;
16: import com.togethersoft.openapi.ide.IdeScript;
17: import com.togethersoft.openapi.ide.IdeStartup;
18:
19: public abstract class KeyScript implements IdeScript, IdeStartup {
20:
21: public final void run(IdeContext context) {
22: KeyScript this clone;
23: if ("on".equals(System.getProperty("KeyDebugClassLoader"))) {
24: this clone = reloadClassDef();
25: } else {
26: this clone = this ;
27: }
28: this clone.run1(context);
29: }
30:
31: public final void autorun() {
32: KeyScript this clone;
33: if ("on".equals(System.getProperty("KeyDebugClassLoader"))) {
34: this clone = reloadClassDef();
35: } else {
36: this clone = this ;
37: }
38: this clone.autorun1();
39: }
40:
41: /** please be aware of the fact that Together calls autorun before
42: * run if the Time variable in the Manifest file of the script is
43: * set to 'User' thus KeyScript implementing the run1 method
44: * should not implement the autorun method at all.
45: */
46: public void run1(IdeContext context) {
47: }
48:
49: public void autorun1() {
50: }
51:
52: // reloads the class-definition of the this-object
53: // and returns a new instance of it.
54: private KeyScript reloadClassDef() {
55: String this ClassName = this .getClass().getName();
56: KeyScript script = null;
57: try {
58: KeyDebugClassLoader classLoader = new KeyDebugClassLoader();
59: // Because of the explicit cast later KeyScript must not be
60: // reloaded by KeyDebugClassLoader (otherwise we get an cast-error)
61: classLoader.setClassAlwaysAskParent(KeyScript.class);
62: Class cl = classLoader.loadClass(this ClassName);
63: script = (KeyScript) cl.newInstance();
64: } catch (ExceptionInInitializerError ei) {
65: System.err
66: .println("keyscript: the initialization provoked "
67: + "by this method fails.");
68: System.err.println("The exception was: " + ei);
69: ei.printStackTrace();
70: } catch (IllegalAccessException iae) {
71: System.err.println("keyscript: class or "
72: + "initializer is not accessible.");
73: System.err.println("The exception was: " + iae);
74: iae.printStackTrace();
75: } catch (InstantiationException ie) {
76: System.err
77: .println("keyscript: class tried to\n"
78: + "instantiate represents an abstract class, an interface,"
79: + "an array class, a primitive type, or void; or if the"
80: + "instantiation fails for some other reason.");
81: System.err.println("The exception was: " + ie);
82: ie.printStackTrace();
83: } catch (SecurityException se) {
84: System.err.println("keyscript: no permission to create"
85: + "a new instance");
86: System.err.println("The exception was: " + se);
87: se.printStackTrace();
88: }
89: return script;
90: }
91: }
|