author | darcy |
Thu, 27 Jun 2013 19:02:02 -0700 | |
changeset 18569 | 0e46c17766b7 |
parent 16034 | cb5fbea1ecec |
child 18716 | 9723e722b955 |
permissions | -rw-r--r-- |
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
1 |
/* |
18569 | 2 |
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
4 |
* |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
10 |
* |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
15 |
* accompanied this code). |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
16 |
* |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
20 |
* |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
23 |
* questions. |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
24 |
*/ |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
25 |
package java.lang.invoke; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
26 |
|
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
27 |
import java.io.Serializable; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
28 |
import java.lang.reflect.Method; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
29 |
import java.security.AccessController; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
30 |
import java.security.PrivilegedActionException; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
31 |
import java.security.PrivilegedExceptionAction; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
32 |
import java.util.Objects; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
33 |
|
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
34 |
/** |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
35 |
* Serialized form of a lambda expression. The properties of this class represent the information that is present |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
36 |
* at the lambda factory site, including the identity of the primary functional interface method, the identity of the |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
37 |
* implementation method, and any variables captured from the local environment at the time of lambda capture. |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
38 |
* |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
39 |
* @see LambdaMetafactory |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
40 |
*/ |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
41 |
public final class SerializedLambda implements Serializable { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
42 |
private static final long serialVersionUID = 8025925345765570181L; |
16034
cb5fbea1ecec
8008770: SerializedLambda incorrect class loader for lambda deserializing class
rfield
parents:
16001
diff
changeset
|
43 |
private final Class<?> capturingClass; |
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
44 |
private final String functionalInterfaceClass; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
45 |
private final String functionalInterfaceMethodName; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
46 |
private final String functionalInterfaceMethodSignature; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
47 |
private final int functionalInterfaceMethodKind; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
48 |
private final String implClass; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
49 |
private final String implMethodName; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
50 |
private final String implMethodSignature; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
51 |
private final int implMethodKind; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
52 |
private final String instantiatedMethodType; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
53 |
private final Object[] capturedArgs; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
54 |
|
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
55 |
/** |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
56 |
* Create a {@code SerializedLambda} from the low-level information present at the lambda factory site. |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
57 |
* |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
58 |
* @param capturingClass The class in which the lambda expression appears |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
59 |
* @param functionalInterfaceMethodKind Method handle kind (see {@link MethodHandleInfo}) for the |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
60 |
* functional interface method handle present at the lambda factory site |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
61 |
* @param functionalInterfaceClass Name, in slash-delimited form, for the functional interface class present at the |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
62 |
* lambda factory site |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
63 |
* @param functionalInterfaceMethodName Name of the primary method for the functional interface present at the |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
64 |
* lambda factory site |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
65 |
* @param functionalInterfaceMethodSignature Signature of the primary method for the functional interface present |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
66 |
* at the lambda factory site |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
67 |
* @param implMethodKind Method handle kind for the implementation method |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
68 |
* @param implClass Name, in slash-delimited form, for the class holding the implementation method |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
69 |
* @param implMethodName Name of the implementation method |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
70 |
* @param implMethodSignature Signature of the implementation method |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
71 |
* @param instantiatedMethodType The signature of the primary functional interface method after type variables |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
72 |
* are substituted with their instantiation from the capture site |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
73 |
* @param capturedArgs The dynamic arguments to the lambda factory site, which represent variables captured by |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
74 |
* the lambda |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
75 |
*/ |
16034
cb5fbea1ecec
8008770: SerializedLambda incorrect class loader for lambda deserializing class
rfield
parents:
16001
diff
changeset
|
76 |
public SerializedLambda(Class<?> capturingClass, |
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
77 |
int functionalInterfaceMethodKind, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
78 |
String functionalInterfaceClass, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
79 |
String functionalInterfaceMethodName, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
80 |
String functionalInterfaceMethodSignature, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
81 |
int implMethodKind, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
82 |
String implClass, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
83 |
String implMethodName, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
84 |
String implMethodSignature, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
85 |
String instantiatedMethodType, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
86 |
Object[] capturedArgs) { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
87 |
this.capturingClass = capturingClass; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
88 |
this.functionalInterfaceMethodKind = functionalInterfaceMethodKind; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
89 |
this.functionalInterfaceClass = functionalInterfaceClass; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
90 |
this.functionalInterfaceMethodName = functionalInterfaceMethodName; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
91 |
this.functionalInterfaceMethodSignature = functionalInterfaceMethodSignature; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
92 |
this.implMethodKind = implMethodKind; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
93 |
this.implClass = implClass; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
94 |
this.implMethodName = implMethodName; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
95 |
this.implMethodSignature = implMethodSignature; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
96 |
this.instantiatedMethodType = instantiatedMethodType; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
97 |
this.capturedArgs = Objects.requireNonNull(capturedArgs).clone(); |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
98 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
99 |
|
18569 | 100 |
/** |
101 |
* Get the name of the class that captured this lambda. |
|
102 |
* @return the name of the class that captured this lambda |
|
103 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
104 |
public String getCapturingClass() { |
16034
cb5fbea1ecec
8008770: SerializedLambda incorrect class loader for lambda deserializing class
rfield
parents:
16001
diff
changeset
|
105 |
return capturingClass.getName().replace('.', '/'); |
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
106 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
107 |
|
18569 | 108 |
/** |
109 |
* Get the name of the functional interface class to which this |
|
110 |
* lambda has been converted |
|
111 |
* @return the name of the functional interface this lambda has |
|
112 |
* been converted to |
|
113 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
114 |
public String getFunctionalInterfaceClass() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
115 |
return functionalInterfaceClass; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
116 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
117 |
|
18569 | 118 |
/** |
119 |
* Get the name of the primary method for the functional interface |
|
120 |
* to which this lambda has been converted. |
|
121 |
* @return the name of the primary methods of the functional interface |
|
122 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
123 |
public String getFunctionalInterfaceMethodName() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
124 |
return functionalInterfaceMethodName; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
125 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
126 |
|
18569 | 127 |
/** |
128 |
* Get the signature of the primary method for the functional |
|
129 |
* interface to which this lambda has been converted. |
|
130 |
* @return the signature of the primary method of the functional |
|
131 |
* interface |
|
132 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
133 |
public String getFunctionalInterfaceMethodSignature() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
134 |
return functionalInterfaceMethodSignature; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
135 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
136 |
|
18569 | 137 |
/** |
138 |
* Get the method handle kind (see {@link MethodHandleInfo}) of |
|
139 |
* the primary method for the functional interface to which this |
|
140 |
* lambda has been converted |
|
141 |
* @return the method handle kind of the primary method of |
|
142 |
* functional interface |
|
143 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
144 |
public int getFunctionalInterfaceMethodKind() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
145 |
return functionalInterfaceMethodKind; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
146 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
147 |
|
18569 | 148 |
/** |
149 |
* Get the name of the class containing the implementation |
|
150 |
* method. |
|
151 |
* @return the name of the class containing the implementation |
|
152 |
* method |
|
153 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
154 |
public String getImplClass() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
155 |
return implClass; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
156 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
157 |
|
18569 | 158 |
/** |
159 |
* Get the name of the implementation method. |
|
160 |
* @return the name of the implementation method |
|
161 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
162 |
public String getImplMethodName() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
163 |
return implMethodName; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
164 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
165 |
|
18569 | 166 |
/** |
167 |
* Get the signature of the implementation method. |
|
168 |
* @return the signature of the implementation method |
|
169 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
170 |
public String getImplMethodSignature() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
171 |
return implMethodSignature; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
172 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
173 |
|
18569 | 174 |
/** |
175 |
* Get the method handle kind (see {@link MethodHandleInfo}) of |
|
176 |
* the implementation method. |
|
177 |
* @return the method handle kind of the implementation method |
|
178 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
179 |
public int getImplMethodKind() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
180 |
return implMethodKind; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
181 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
182 |
|
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
183 |
/** |
18569 | 184 |
* Get the signature of the primary functional interface method |
185 |
* after type variables are substituted with their instantiation |
|
186 |
* from the capture site. |
|
187 |
* @return the signature of the primary functional interface method |
|
188 |
* after type variable processing |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
189 |
*/ |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
190 |
public final String getInstantiatedMethodType() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
191 |
return instantiatedMethodType; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
192 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
193 |
|
18569 | 194 |
/** |
195 |
* Get the count of dynamic arguments to the lambda capture site. |
|
196 |
* @return the count of dynamic arguments to the lambda capture site |
|
197 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
198 |
public int getCapturedArgCount() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
199 |
return capturedArgs.length; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
200 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
201 |
|
18569 | 202 |
/** |
203 |
* Get a dynamic argument to the lambda capture site. |
|
204 |
* @param i the argument to capture |
|
205 |
* @return a dynamic argument to the lambda capture site |
|
206 |
*/ |
|
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
207 |
public Object getCapturedArg(int i) { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
208 |
return capturedArgs[i]; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
209 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
210 |
|
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
211 |
private Object readResolve() throws ReflectiveOperationException { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
212 |
try { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
213 |
Method deserialize = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
214 |
@Override |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
215 |
public Method run() throws Exception { |
16034
cb5fbea1ecec
8008770: SerializedLambda incorrect class loader for lambda deserializing class
rfield
parents:
16001
diff
changeset
|
216 |
Method m = capturingClass.getDeclaredMethod("$deserializeLambda$", SerializedLambda.class); |
16001
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
217 |
m.setAccessible(true); |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
218 |
return m; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
219 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
220 |
}); |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
221 |
|
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
222 |
return deserialize.invoke(null, this); |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
223 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
224 |
catch (PrivilegedActionException e) { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
225 |
Exception cause = e.getException(); |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
226 |
if (cause instanceof ReflectiveOperationException) |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
227 |
throw (ReflectiveOperationException) cause; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
228 |
else if (cause instanceof RuntimeException) |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
229 |
throw (RuntimeException) cause; |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
230 |
else |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
231 |
throw new RuntimeException("Exception in SerializedLambda.readResolve", e); |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
232 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
233 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
234 |
|
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
235 |
@Override |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
236 |
public String toString() { |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
237 |
return String.format("SerializedLambda[capturingClass=%s, functionalInterfaceMethod=%s %s.%s:%s, " + |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
238 |
"implementation=%s %s.%s:%s, instantiatedMethodType=%s, numCaptured=%d]", |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
239 |
capturingClass, MethodHandleInfo.getReferenceKindString(functionalInterfaceMethodKind), |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
240 |
functionalInterfaceClass, functionalInterfaceMethodName, functionalInterfaceMethodSignature, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
241 |
MethodHandleInfo.getReferenceKindString(implMethodKind), implClass, implMethodName, |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
242 |
implMethodSignature, instantiatedMethodType, capturedArgs.length); |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
243 |
} |
fd4c8d3becf8
8004970: Implement serialization in the lambda metafactory
rfield
parents:
diff
changeset
|
244 |
} |