jdk/src/share/classes/sun/dyn/MethodHandleImpl.java
changeset 8345 9e2483e6cfab
parent 7556 4a5711d43948
child 8346 3b891698c4ec
equal deleted inserted replaced
8126:c5df55701e91 8345:9e2483e6cfab
     1 /*
     1 /*
     2  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   182         }
   182         }
   183         DirectMethodHandle mh = new DirectMethodHandle(mtype, method, doDispatch, lookupClass);
   183         DirectMethodHandle mh = new DirectMethodHandle(mtype, method, doDispatch, lookupClass);
   184         if (!mh.isValid())
   184         if (!mh.isValid())
   185             throw newNoAccessException(method, lookupClass);
   185             throw newNoAccessException(method, lookupClass);
   186         assert(mh.type() == mtype);
   186         assert(mh.type() == mtype);
   187         return mh;
   187         if (!method.isVarargs())
       
   188             return mh;
       
   189         else
       
   190             return mh.asVarargsCollector(mtype.parameterType(mtype.parameterCount()-1));
   188     }
   191     }
   189 
   192 
   190     public static
   193     public static
   191     MethodHandle makeAllocator(Access token, MethodHandle rawConstructor) {
   194     MethodHandle makeAllocator(Access token, MethodHandle rawConstructor) {
   192         Access.check(token);
   195         Access.check(token);
  1261     public static MethodHandle getBootstrap(Access token, Class<?> callerClass) {
  1264     public static MethodHandle getBootstrap(Access token, Class<?> callerClass) {
  1262         Access.check(token);
  1265         Access.check(token);
  1263         return MethodHandleNatives.getBootstrap(callerClass);
  1266         return MethodHandleNatives.getBootstrap(callerClass);
  1264     }
  1267     }
  1265 
  1268 
  1266     public static MethodHandle withTypeHandler(Access token, MethodHandle target, MethodHandle typeHandler) {
  1269     public static MethodHandle asVarargsCollector(Access token, MethodHandle target, Class<?> arrayType) {
  1267         Access.check(token);
  1270         Access.check(token);
  1268         return AdapterMethodHandle.makeTypeHandler(token, target, typeHandler);
  1271         return AdapterMethodHandle.makeVarargsCollector(token, target, arrayType);
  1269     }
  1272     }
  1270 }
  1273 }