< prev index next >

src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java

Print this page

  1 /*
  2  * Copyright (c) 2008, 2023, 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

346                 assert(tType.parameterCount() == MH_AND_LF+1);
347                 final BasicType type = basicType((byte) whichtm);
348                 assert(tType.parameterType(MH_AND_LF) == type.basicTypeClass());
349             } else {
350                 return false;
351             }
352             return true;
353         }
354 
355         /*non-public*/
356         SpeciesData extendWith(BasicType basicType) {
357             int typeNum = basicType.ordinal();
358             SpeciesData sd = extensions[typeNum];
359             if (sd != null)  return sd;
360             sd = SPECIALIZER.findSpecies(key() + basicType.basicTypeChar());
361             extensions[typeNum] = sd;
362             return sd;
363         }
364     }
365 






366     /*non-public*/
367     static final Specializer SPECIALIZER = new Specializer();
368     static {
369         SimpleMethodHandle.BMH_SPECIES = BoundMethodHandle.SPECIALIZER.findSpecies("");
370         Species_L.BMH_SPECIES = BoundMethodHandle.SPECIALIZER.findSpecies("L");
371     }
372 
373     /*non-public*/
374     static final class Specializer
375             extends ClassSpecializer<BoundMethodHandle, String, SpeciesData> {
376 
377         private static final MemberName SPECIES_DATA_ACCESSOR;
378 
379         static {
380             try {
381                 SPECIES_DATA_ACCESSOR = IMPL_LOOKUP.resolveOrFail(REF_invokeVirtual, BoundMethodHandle.class,
382                         "speciesData", MethodType.methodType(BoundMethodHandle.SpeciesData.class));
383             } catch (ReflectiveOperationException ex) {
384                 throw newInternalError("Bootstrap link error", ex);
385             }
386         }
387 
388         private Specializer() {
389             super(  // Reified type parameters:
390                     BoundMethodHandle.class, String.class, BoundMethodHandle.SpeciesData.class,

  1 /*
  2  * Copyright (c) 2008, 2024, 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

346                 assert(tType.parameterCount() == MH_AND_LF+1);
347                 final BasicType type = basicType((byte) whichtm);
348                 assert(tType.parameterType(MH_AND_LF) == type.basicTypeClass());
349             } else {
350                 return false;
351             }
352             return true;
353         }
354 
355         /*non-public*/
356         SpeciesData extendWith(BasicType basicType) {
357             int typeNum = basicType.ordinal();
358             SpeciesData sd = extensions[typeNum];
359             if (sd != null)  return sd;
360             sd = SPECIALIZER.findSpecies(key() + basicType.basicTypeChar());
361             extensions[typeNum] = sd;
362             return sd;
363         }
364     }
365 
366     static class AOTHolder {
367         static final Specializer SPECIALIZER = new Specializer();
368         static final SpeciesData SimpleMethodHandle_BMH_SPECIES = SPECIALIZER.findSpecies("");
369         static final SpeciesData Species_L_BMH_SPECIES = SPECIALIZER.findSpecies("L");
370     }
371 
372     /*non-public*/
373     static final Specializer SPECIALIZER = AOTHolder.SPECIALIZER;
374     static {
375         SimpleMethodHandle.BMH_SPECIES = AOTHolder.SimpleMethodHandle_BMH_SPECIES;
376         Species_L.BMH_SPECIES = AOTHolder.Species_L_BMH_SPECIES;
377     }
378 
379     /*non-public*/
380     static final class Specializer
381             extends ClassSpecializer<BoundMethodHandle, String, SpeciesData> {
382 
383         private static final MemberName SPECIES_DATA_ACCESSOR;
384 
385         static {
386             try {
387                 SPECIES_DATA_ACCESSOR = IMPL_LOOKUP.resolveOrFail(REF_invokeVirtual, BoundMethodHandle.class,
388                         "speciesData", MethodType.methodType(BoundMethodHandle.SpeciesData.class));
389             } catch (ReflectiveOperationException ex) {
390                 throw newInternalError("Bootstrap link error", ex);
391             }
392         }
393 
394         private Specializer() {
395             super(  // Reified type parameters:
396                     BoundMethodHandle.class, String.class, BoundMethodHandle.SpeciesData.class,
< prev index next >