Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.scripting/share/classes/javax/script/Invocable.java
41149 views
1
/*
2
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
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 javax.script;
27
28
/**
29
* The optional interface implemented by ScriptEngines whose methods allow the invocation of
30
* procedures in scripts that have previously been executed.
31
*
32
* @author Mike Grogan
33
* @author A. Sundararajan
34
* @since 1.6
35
*/
36
public interface Invocable {
37
/**
38
* Calls a method on a script object compiled during a previous script execution,
39
* which is retained in the state of the <code>ScriptEngine</code>.
40
*
41
* @param name The name of the procedure to be called.
42
*
43
* @param thiz If the procedure is a member of a class
44
* defined in the script and thiz is an instance of that class
45
* returned by a previous execution or invocation, the named method is
46
* called through that instance.
47
*
48
* @param args Arguments to pass to the procedure. The rules for converting
49
* the arguments to scripting variables are implementation-specific.
50
*
51
* @return The value returned by the procedure. The rules for converting the scripting
52
* variable returned by the script method to a Java Object are implementation-specific.
53
*
54
* @throws ScriptException if an error occurs during invocation of the method.
55
* @throws NoSuchMethodException if method with given name or matching argument types cannot be found.
56
* @throws NullPointerException if the method name is null.
57
* @throws IllegalArgumentException if the specified thiz is null or the specified Object is
58
* does not represent a scripting object.
59
*/
60
public Object invokeMethod(Object thiz, String name, Object... args)
61
throws ScriptException, NoSuchMethodException;
62
63
/**
64
* Used to call top-level procedures and functions defined in scripts.
65
*
66
* @param name of the procedure or function to call
67
* @param args Arguments to pass to the procedure or function
68
* @return The value returned by the procedure or function
69
*
70
* @throws ScriptException if an error occurs during invocation of the method.
71
* @throws NoSuchMethodException if method with given name or matching argument types cannot be found.
72
* @throws NullPointerException if method name is null.
73
*/
74
public Object invokeFunction(String name, Object... args)
75
throws ScriptException, NoSuchMethodException;
76
77
78
/**
79
* Returns an implementation of an interface using functions compiled in
80
* the interpreter. The methods of the interface
81
* may be implemented using the <code>invokeFunction</code> method.
82
*
83
* @param <T> the type of the interface to return
84
* @param clasz The <code>Class</code> object of the interface to return.
85
*
86
* @return An instance of requested interface - null if the requested interface is unavailable,
87
* i. e. if compiled functions in the <code>ScriptEngine</code> cannot be found matching
88
* the ones in the requested interface.
89
*
90
* @throws IllegalArgumentException if the specified <code>Class</code> object
91
* is null or is not an interface.
92
*/
93
public <T> T getInterface(Class<T> clasz);
94
95
/**
96
* Returns an implementation of an interface using member functions of
97
* a scripting object compiled in the interpreter. The methods of the
98
* interface may be implemented using the <code>invokeMethod</code> method.
99
*
100
* @param <T> the type of the interface to return
101
* @param thiz The scripting object whose member functions are used to implement the methods of the interface.
102
* @param clasz The <code>Class</code> object of the interface to return.
103
*
104
* @return An instance of requested interface - null if the requested interface is unavailable,
105
* i. e. if compiled methods in the <code>ScriptEngine</code> cannot be found matching
106
* the ones in the requested interface.
107
*
108
* @throws IllegalArgumentException if the specified <code>Class</code> object
109
* is null or is not an interface, or if the specified Object is
110
* null or does not represent a scripting object.
111
*/
112
public <T> T getInterface(Object thiz, Class<T> clasz);
113
114
}
115
116