src/share/classes/java/lang/invoke/MethodHandleImpl.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7087570 Sdiff src/share/classes/java/lang/invoke

src/share/classes/java/lang/invoke/MethodHandleImpl.java

Print this page


   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


 350             int arrayLength = newArity - collectArg;
 351             MethodHandle collector;
 352             try {
 353                 collector = asFixedArity().asCollector(arrayType, arrayLength);
 354                 assert(collector.type().parameterCount() == newArity) : "newArity="+newArity+" but collector="+collector;
 355             } catch (IllegalArgumentException ex) {
 356                 throw new WrongMethodTypeException("cannot build collector", ex);
 357             }
 358             cache = collector;
 359             return collector.asType(newType);
 360         }
 361 
 362         @Override
 363         MethodHandle setVarargs(MemberName member) {
 364             if (member.isVarargs())  return this;
 365             return asFixedArity();
 366         }
 367 
 368         @Override
 369         MethodHandle viewAsType(MethodType newType) {
 370             MethodHandle mh = super.viewAsType(newType);


 371             // put back the varargs bit:
 372             MethodType type = mh.type();
 373             int arity = type.parameterCount();
 374             return mh.asVarargsCollector(type.parameterType(arity-1));
 375         }
 376 
 377         @Override
 378         MemberName internalMemberName() {
 379             return asFixedArity().internalMemberName();
 380         }
 381 






 382 
 383         @Override
 384         MethodHandle bindArgument(int pos, char basicType, Object value) {
 385             return asFixedArity().bindArgument(pos, basicType, value);
 386         }
 387 
 388         @Override
 389         MethodHandle bindReceiver(Object receiver) {
 390             return asFixedArity().bindReceiver(receiver);
 391         }
 392 
 393         @Override
 394         MethodHandle dropArguments(MethodType srcType, int pos, int drops) {
 395             return asFixedArity().dropArguments(srcType, pos, drops);
 396         }
 397 
 398         @Override
 399         MethodHandle permuteArguments(MethodType newType, int[] reorder) {
 400             return asFixedArity().permuteArguments(newType, reorder);
 401         }


   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


 350             int arrayLength = newArity - collectArg;
 351             MethodHandle collector;
 352             try {
 353                 collector = asFixedArity().asCollector(arrayType, arrayLength);
 354                 assert(collector.type().parameterCount() == newArity) : "newArity="+newArity+" but collector="+collector;
 355             } catch (IllegalArgumentException ex) {
 356                 throw new WrongMethodTypeException("cannot build collector", ex);
 357             }
 358             cache = collector;
 359             return collector.asType(newType);
 360         }
 361 
 362         @Override
 363         MethodHandle setVarargs(MemberName member) {
 364             if (member.isVarargs())  return this;
 365             return asFixedArity();
 366         }
 367 
 368         @Override
 369         MethodHandle viewAsType(MethodType newType) {
 370             if (newType.lastParameterType() != type().lastParameterType())
 371                 throw new InternalError();
 372             MethodHandle newTarget = asFixedArity().viewAsType(newType);
 373             // put back the varargs bit:
 374             return new AsVarargsCollector(newTarget, newType, arrayType);


 375         }
 376 
 377         @Override
 378         MemberName internalMemberName() {
 379             return asFixedArity().internalMemberName();
 380         }
 381 
 382         /*non-public*/
 383         @Override
 384         boolean isInvokeSpecial() {
 385             return asFixedArity().isInvokeSpecial();
 386         }
 387 
 388 
 389         @Override
 390         MethodHandle bindArgument(int pos, char basicType, Object value) {
 391             return asFixedArity().bindArgument(pos, basicType, value);
 392         }
 393 
 394         @Override
 395         MethodHandle bindReceiver(Object receiver) {
 396             return asFixedArity().bindReceiver(receiver);
 397         }
 398 
 399         @Override
 400         MethodHandle dropArguments(MethodType srcType, int pos, int drops) {
 401             return asFixedArity().dropArguments(srcType, pos, drops);
 402         }
 403 
 404         @Override
 405         MethodHandle permuteArguments(MethodType newType, int[] reorder) {
 406             return asFixedArity().permuteArguments(newType, reorder);
 407         }


src/share/classes/java/lang/invoke/MethodHandleImpl.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File