< prev index next >

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

Print this page

  27 
  28 import jdk.internal.access.JavaLangInvokeAccess;
  29 import jdk.internal.access.SharedSecrets;
  30 import jdk.internal.invoke.NativeEntryPoint;
  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.invoke.MethodHandles.Lookup;
  44 import java.lang.reflect.Array;
  45 import java.lang.reflect.Constructor;
  46 import java.lang.reflect.Field;

  47 import java.nio.ByteOrder;
  48 import java.util.Arrays;
  49 import java.util.Collections;
  50 import java.util.HashMap;
  51 import java.util.Iterator;
  52 import java.util.List;
  53 import java.util.Map;
  54 import java.util.Objects;
  55 import java.util.Set;
  56 import java.util.concurrent.ConcurrentHashMap;
  57 import java.util.function.Function;
  58 import java.util.stream.Stream;
  59 
  60 import static java.lang.invoke.LambdaForm.*;
  61 import static java.lang.invoke.MethodHandleStatics.*;
  62 import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
  63 import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE;
  64 import static jdk.internal.org.objectweb.asm.Opcodes.*;
  65 
  66 /**

1529                 case NF_throwException      -> new NamedFunction(MethodHandleImpl.class
1530                                                 .getDeclaredMethod("throwException", Throwable.class));
1531                 case NF_profileBoolean      -> new NamedFunction(MethodHandleImpl.class
1532                                                 .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
1533                 case NF_tableSwitch         -> new NamedFunction(MethodHandleImpl.class
1534                                                 .getDeclaredMethod("tableSwitch", int.class, MethodHandle.class, CasesHolder.class, Object[].class));
1535                 default -> throw new InternalError("Undefined function: " + func);
1536             };
1537         } catch (ReflectiveOperationException ex) {
1538             throw newInternalError(ex);
1539         }
1540     }
1541 
1542     static {
1543         SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() {
1544             @Override
1545             public Object newMemberName() {
1546                 return new MemberName();
1547             }
1548 





1549             @Override
1550             public String getName(Object mname) {
1551                 MemberName memberName = (MemberName)mname;
1552                 return memberName.getName();
1553             }
1554             @Override
1555             public Class<?> getDeclaringClass(Object mname) {
1556                 MemberName memberName = (MemberName)mname;
1557                 return memberName.getDeclaringClass();
1558             }
1559 
1560             @Override
1561             public MethodType getMethodType(Object mname) {
1562                 MemberName memberName = (MemberName)mname;
1563                 return memberName.getMethodType();
1564             }
1565 
1566             @Override
1567             public String getMethodDescriptor(Object mname) {
1568                 MemberName memberName = (MemberName)mname;

  27 
  28 import jdk.internal.access.JavaLangInvokeAccess;
  29 import jdk.internal.access.SharedSecrets;
  30 import jdk.internal.invoke.NativeEntryPoint;
  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.invoke.MethodHandles.Lookup;
  44 import java.lang.reflect.Array;
  45 import java.lang.reflect.Constructor;
  46 import java.lang.reflect.Field;
  47 import java.lang.reflect.Method;
  48 import java.nio.ByteOrder;
  49 import java.util.Arrays;
  50 import java.util.Collections;
  51 import java.util.HashMap;
  52 import java.util.Iterator;
  53 import java.util.List;
  54 import java.util.Map;
  55 import java.util.Objects;
  56 import java.util.Set;
  57 import java.util.concurrent.ConcurrentHashMap;
  58 import java.util.function.Function;
  59 import java.util.stream.Stream;
  60 
  61 import static java.lang.invoke.LambdaForm.*;
  62 import static java.lang.invoke.MethodHandleStatics.*;
  63 import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
  64 import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE;
  65 import static jdk.internal.org.objectweb.asm.Opcodes.*;
  66 
  67 /**

1530                 case NF_throwException      -> new NamedFunction(MethodHandleImpl.class
1531                                                 .getDeclaredMethod("throwException", Throwable.class));
1532                 case NF_profileBoolean      -> new NamedFunction(MethodHandleImpl.class
1533                                                 .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
1534                 case NF_tableSwitch         -> new NamedFunction(MethodHandleImpl.class
1535                                                 .getDeclaredMethod("tableSwitch", int.class, MethodHandle.class, CasesHolder.class, Object[].class));
1536                 default -> throw new InternalError("Undefined function: " + func);
1537             };
1538         } catch (ReflectiveOperationException ex) {
1539             throw newInternalError(ex);
1540         }
1541     }
1542 
1543     static {
1544         SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() {
1545             @Override
1546             public Object newMemberName() {
1547                 return new MemberName();
1548             }
1549 
1550             @Override
1551             public Object newMemberName(Method method) {
1552                 return new MemberName(method);
1553             }
1554 
1555             @Override
1556             public String getName(Object mname) {
1557                 MemberName memberName = (MemberName)mname;
1558                 return memberName.getName();
1559             }
1560             @Override
1561             public Class<?> getDeclaringClass(Object mname) {
1562                 MemberName memberName = (MemberName)mname;
1563                 return memberName.getDeclaringClass();
1564             }
1565 
1566             @Override
1567             public MethodType getMethodType(Object mname) {
1568                 MemberName memberName = (MemberName)mname;
1569                 return memberName.getMethodType();
1570             }
1571 
1572             @Override
1573             public String getMethodDescriptor(Object mname) {
1574                 MemberName memberName = (MemberName)mname;
< prev index next >