MCPcopy Create free account
hub / github.com/mozilla/rhino / MemberBox

Class MemberBox

rhino/src/main/java/org/mozilla/javascript/MemberBox.java:28–387  ·  view source on GitHub ↗

Wrapper class for Method and Constructor instances to cache getParameterTypes() results, recover from IllegalAccessException in some cases and provide serialization support. @author Igor Bukanov

Source from the content-addressed store, hash-verified

26 * @author Igor Bukanov
27 */
28final class MemberBox implements Serializable {
29 @Serial private static final long serialVersionUID = 8260700214130563887L;
30
31 private transient Member memberObject;
32 private transient Class<?>[] argTypes;
33 private transient Class<?> returnType;
34 private transient NullabilityDetector.NullabilityAccessor argNullability;
35
36 transient Function asGetterFunction;
37 transient Function asSetterFunction;
38 transient Object delegateTo;
39
40 final VarScope scope;
41
42 private static final NullabilityDetector nullDetector =
43 ScriptRuntime.loadOneServiceImplementation(NullabilityDetector.class);
44
45 MemberBox(VarScope scope, Method method) {
46 this.scope = scope;
47 init(method);
48 }
49
50 MemberBox(VarScope scope, Constructor<?> constructor) {
51 this.scope = scope;
52 init(constructor);
53 }
54
55 private void init(Method method) {
56 this.memberObject = method;
57 this.argTypes = method.getParameterTypes();
58 this.returnType = method.getReturnType();
59 }
60
61 private void init(Constructor<?> constructor) {
62 this.memberObject = constructor;
63 this.argTypes = constructor.getParameterTypes();
64 this.returnType = null;
65 }
66
67 Method method() {
68 return (Method) memberObject;
69 }
70
71 Constructor<?> ctor() {
72 return (Constructor<?>) memberObject;
73 }
74
75 Member member() {
76 return memberObject;
77 }
78
79 boolean isMethod() {
80 return memberObject instanceof Method;
81 }
82
83 boolean isCtor() {
84 return memberObject instanceof Constructor;
85 }

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected