< prev index next >

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

Print this page




  24  */
  25 
  26 package java.lang.invoke;
  27 
  28 import jdk.internal.access.JavaLangInvokeAccess;
  29 import jdk.internal.access.SharedSecrets;
  30 import jdk.internal.org.objectweb.asm.AnnotationVisitor;
  31 import jdk.internal.org.objectweb.asm.ClassWriter;
  32 import jdk.internal.org.objectweb.asm.MethodVisitor;
  33 import jdk.internal.reflect.CallerSensitive;
  34 import jdk.internal.reflect.Reflection;
  35 import jdk.internal.vm.annotation.ForceInline;
  36 import jdk.internal.vm.annotation.Hidden;
  37 import jdk.internal.vm.annotation.Stable;
  38 import sun.invoke.empty.Empty;
  39 import sun.invoke.util.ValueConversions;
  40 import sun.invoke.util.VerifyType;
  41 import sun.invoke.util.Wrapper;
  42 
  43 import java.lang.reflect.Array;

  44 import java.util.Arrays;
  45 import java.util.Collections;
  46 import java.util.HashMap;
  47 import java.util.Iterator;
  48 import java.util.List;
  49 import java.util.Map;
  50 import java.util.function.Function;
  51 import java.util.stream.Stream;
  52 
  53 import static java.lang.invoke.LambdaForm.*;
  54 import static java.lang.invoke.MethodHandleStatics.*;
  55 import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
  56 import static jdk.internal.org.objectweb.asm.Opcodes.*;
  57 
  58 /**
  59  * Trusted implementation code for MethodHandle.
  60  * @author jrose
  61  */
  62 /*non-public*/ abstract class MethodHandleImpl {
  63 


1713                             .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
1714                 case NF_throwException:
1715                     return new NamedFunction(MethodHandleImpl.class
1716                             .getDeclaredMethod("throwException", Throwable.class));
1717                 case NF_profileBoolean:
1718                     return new NamedFunction(MethodHandleImpl.class
1719                             .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
1720                 default:
1721                     throw new InternalError("Undefined function: " + func);
1722             }
1723         } catch (ReflectiveOperationException ex) {
1724             throw newInternalError(ex);
1725         }
1726     }
1727 
1728     static {
1729         SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() {
1730             @Override
1731             public Object newMemberName() {
1732                 return new MemberName();





1733             }
1734 
1735             @Override
1736             public String getName(Object mname) {
1737                 MemberName memberName = (MemberName)mname;
1738                 return memberName.getName();
1739             }
1740             @Override
1741             public Class<?> getDeclaringClass(Object mname) {
1742                 MemberName memberName = (MemberName)mname;
1743                 return memberName.getDeclaringClass();
1744             }
1745 
1746             @Override
1747             public MethodType getMethodType(Object mname) {
1748                 MemberName memberName = (MemberName)mname;
1749                 return memberName.getMethodType();
1750             }
1751 
1752             @Override




  24  */
  25 
  26 package java.lang.invoke;
  27 
  28 import jdk.internal.access.JavaLangInvokeAccess;
  29 import jdk.internal.access.SharedSecrets;
  30 import jdk.internal.org.objectweb.asm.AnnotationVisitor;
  31 import jdk.internal.org.objectweb.asm.ClassWriter;
  32 import jdk.internal.org.objectweb.asm.MethodVisitor;
  33 import jdk.internal.reflect.CallerSensitive;
  34 import jdk.internal.reflect.Reflection;
  35 import jdk.internal.vm.annotation.ForceInline;
  36 import jdk.internal.vm.annotation.Hidden;
  37 import jdk.internal.vm.annotation.Stable;
  38 import sun.invoke.empty.Empty;
  39 import sun.invoke.util.ValueConversions;
  40 import sun.invoke.util.VerifyType;
  41 import sun.invoke.util.Wrapper;
  42 
  43 import java.lang.reflect.Array;
  44 import java.lang.reflect.Method;
  45 import java.util.Arrays;
  46 import java.util.Collections;
  47 import java.util.HashMap;
  48 import java.util.Iterator;
  49 import java.util.List;
  50 import java.util.Map;
  51 import java.util.function.Function;
  52 import java.util.stream.Stream;
  53 
  54 import static java.lang.invoke.LambdaForm.*;
  55 import static java.lang.invoke.MethodHandleStatics.*;
  56 import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
  57 import static jdk.internal.org.objectweb.asm.Opcodes.*;
  58 
  59 /**
  60  * Trusted implementation code for MethodHandle.
  61  * @author jrose
  62  */
  63 /*non-public*/ abstract class MethodHandleImpl {
  64 


1714                             .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
1715                 case NF_throwException:
1716                     return new NamedFunction(MethodHandleImpl.class
1717                             .getDeclaredMethod("throwException", Throwable.class));
1718                 case NF_profileBoolean:
1719                     return new NamedFunction(MethodHandleImpl.class
1720                             .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
1721                 default:
1722                     throw new InternalError("Undefined function: " + func);
1723             }
1724         } catch (ReflectiveOperationException ex) {
1725             throw newInternalError(ex);
1726         }
1727     }
1728 
1729     static {
1730         SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() {
1731             @Override
1732             public Object newMemberName() {
1733                 return new MemberName();
1734             }
1735 
1736             @Override
1737             public Object newMemberName(Method method) {
1738                 return new MemberName(method);
1739             }
1740 
1741             @Override
1742             public String getName(Object mname) {
1743                 MemberName memberName = (MemberName)mname;
1744                 return memberName.getName();
1745             }
1746             @Override
1747             public Class<?> getDeclaringClass(Object mname) {
1748                 MemberName memberName = (MemberName)mname;
1749                 return memberName.getDeclaringClass();
1750             }
1751 
1752             @Override
1753             public MethodType getMethodType(Object mname) {
1754                 MemberName memberName = (MemberName)mname;
1755                 return memberName.getMethodType();
1756             }
1757 
1758             @Override


< prev index next >