1 /*
2 * Copyright (c) 2008, 2012, 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
1233 //// Sub-classes can override these default implementations.
1234 //// All these methods assume arguments are already validated.
1235
1236 // Other transforms to do: convert, explicitCast, permute, drop, filter, fold, GWT, catch
1237
1238 /*non-public*/
1239 MethodHandle setVarargs(MemberName member) throws IllegalAccessException {
1240 if (!member.isVarargs()) return this;
1241 int argc = type().parameterCount();
1242 if (argc != 0) {
1243 Class<?> arrayType = type().parameterType(argc-1);
1244 if (arrayType.isArray()) {
1245 return MethodHandleImpl.makeVarargsCollector(this, arrayType);
1246 }
1247 }
1248 throw member.makeAccessException("cannot make variable arity", null);
1249 }
1250 /*non-public*/
1251 MethodHandle viewAsType(MethodType newType) {
1252 // No actual conversions, just a new view of the same method.
1253 if (!type.isViewableAs(newType))
1254 throw new InternalError();
1255 return MethodHandleImpl.makePairwiseConvert(this, newType, 0);
1256 }
1257
1258 // Decoding
1259
1260 /*non-public*/
1261 LambdaForm internalForm() {
1262 return form;
1263 }
1264
1265 /*non-public*/
1266 MemberName internalMemberName() {
1267 return null; // DMH returns DMH.member
1268 }
1269
1270 /*non-public*/
1271 Object internalValues() {
1272 return null;
1273 }
1274
1275 /*non-public*/
1276 Object internalProperties() {
1277 // Override to something like "/FOO=bar"
1278 return "";
1279 }
1280
1281 //// Method handle implementation methods.
1282 //// Sub-classes can override these default implementations.
1283 //// All these methods assume arguments are already validated.
1284
1285 /*non-public*/ MethodHandle convertArguments(MethodType newType) {
1286 // Override this if it can be improved.
1287 return MethodHandleImpl.makePairwiseConvert(this, newType, 1);
1288 }
1289
1290 /*non-public*/
|
1 /*
2 * Copyright (c) 2008, 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
1233 //// Sub-classes can override these default implementations.
1234 //// All these methods assume arguments are already validated.
1235
1236 // Other transforms to do: convert, explicitCast, permute, drop, filter, fold, GWT, catch
1237
1238 /*non-public*/
1239 MethodHandle setVarargs(MemberName member) throws IllegalAccessException {
1240 if (!member.isVarargs()) return this;
1241 int argc = type().parameterCount();
1242 if (argc != 0) {
1243 Class<?> arrayType = type().parameterType(argc-1);
1244 if (arrayType.isArray()) {
1245 return MethodHandleImpl.makeVarargsCollector(this, arrayType);
1246 }
1247 }
1248 throw member.makeAccessException("cannot make variable arity", null);
1249 }
1250 /*non-public*/
1251 MethodHandle viewAsType(MethodType newType) {
1252 // No actual conversions, just a new view of the same method.
1253 return MethodHandleImpl.makePairwiseConvert(this, newType, 0);
1254 }
1255
1256 // Decoding
1257
1258 /*non-public*/
1259 LambdaForm internalForm() {
1260 return form;
1261 }
1262
1263 /*non-public*/
1264 MemberName internalMemberName() {
1265 return null; // DMH returns DMH.member
1266 }
1267
1268 /*non-public*/
1269 boolean isInvokeSpecial() {
1270 return false; // DMH.Special returns true
1271 }
1272
1273 /*non-public*/
1274 Object internalValues() {
1275 return null;
1276 }
1277
1278 /*non-public*/
1279 Object internalProperties() {
1280 // Override to something like "/FOO=bar"
1281 return "";
1282 }
1283
1284 //// Method handle implementation methods.
1285 //// Sub-classes can override these default implementations.
1286 //// All these methods assume arguments are already validated.
1287
1288 /*non-public*/ MethodHandle convertArguments(MethodType newType) {
1289 // Override this if it can be improved.
1290 return MethodHandleImpl.makePairwiseConvert(this, newType, 1);
1291 }
1292
1293 /*non-public*/
|