src/java.base/share/classes/java/lang/invoke/SimpleMethodHandle.java
changeset 59201 b24f4caa1411
parent 47753 a2008587c13f
equal deleted inserted replaced
59200:a686b67a59d9 59201:b24f4caa1411
    38 
    38 
    39     private SimpleMethodHandle(MethodType type, LambdaForm form) {
    39     private SimpleMethodHandle(MethodType type, LambdaForm form) {
    40         super(type, form);
    40         super(type, form);
    41     }
    41     }
    42 
    42 
    43     /*non-public*/ static BoundMethodHandle make(MethodType type, LambdaForm form) {
    43     /*non-public*/
       
    44     static BoundMethodHandle make(MethodType type, LambdaForm form) {
    44         return new SimpleMethodHandle(type, form);
    45         return new SimpleMethodHandle(type, form);
    45     }
    46     }
    46 
    47 
    47     /*non-public*/ static @Stable BoundMethodHandle.SpeciesData BMH_SPECIES;
    48     /*non-public*/
       
    49     static @Stable BoundMethodHandle.SpeciesData BMH_SPECIES;
    48 
    50 
    49     @Override
    51     @Override
    50     /*non-public*/ BoundMethodHandle.SpeciesData speciesData() {
    52     /*non-public*/
       
    53     BoundMethodHandle.SpeciesData speciesData() {
    51             return BMH_SPECIES;
    54             return BMH_SPECIES;
    52     }
    55     }
    53 
    56 
    54     @Override
    57     @Override
    55     /*non-public*/ BoundMethodHandle copyWith(MethodType mt, LambdaForm lf) {
    58     /*non-public*/
       
    59     BoundMethodHandle copyWith(MethodType mt, LambdaForm lf) {
    56         return make(mt, lf);
    60         return make(mt, lf);
    57     }
    61     }
    58 
    62 
    59     @Override
    63     @Override
    60     String internalProperties() {
    64     String internalProperties() {
    61         return "\n& Class="+getClass().getSimpleName();
    65         return "\n& Class="+getClass().getSimpleName();
    62     }
    66     }
    63 
    67 
    64     @Override
    68     @Override
    65     /*non-public*/ final BoundMethodHandle copyWithExtendL(MethodType mt, LambdaForm lf, Object narg) {
    69     /*non-public*/
       
    70     final BoundMethodHandle copyWithExtendL(MethodType mt, LambdaForm lf, Object narg) {
    66         return BoundMethodHandle.bindSingle(mt, lf, narg); // Use known fast path.
    71         return BoundMethodHandle.bindSingle(mt, lf, narg); // Use known fast path.
    67     }
    72     }
    68     @Override
    73     @Override
    69     /*non-public*/ final BoundMethodHandle copyWithExtendI(MethodType mt, LambdaForm lf, int narg) {
    74     /*non-public*/
       
    75     final BoundMethodHandle copyWithExtendI(MethodType mt, LambdaForm lf, int narg) {
    70         try {
    76         try {
    71             return (BoundMethodHandle) BMH_SPECIES.extendWith(I_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
    77             return (BoundMethodHandle) BMH_SPECIES.extendWith(I_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
    72         } catch (Throwable ex) {
    78         } catch (Throwable ex) {
    73             throw uncaughtException(ex);
    79             throw uncaughtException(ex);
    74         }
    80         }
    75     }
    81     }
    76     @Override
    82     @Override
    77     /*non-public*/ final BoundMethodHandle copyWithExtendJ(MethodType mt, LambdaForm lf, long narg) {
    83     /*non-public*/
       
    84     final BoundMethodHandle copyWithExtendJ(MethodType mt, LambdaForm lf, long narg) {
    78         try {
    85         try {
    79             return (BoundMethodHandle) BMH_SPECIES.extendWith(J_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
    86             return (BoundMethodHandle) BMH_SPECIES.extendWith(J_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
    80         } catch (Throwable ex) {
    87         } catch (Throwable ex) {
    81             throw uncaughtException(ex);
    88             throw uncaughtException(ex);
    82         }
    89         }
    83     }
    90     }
    84     @Override
    91     @Override
    85     /*non-public*/ final BoundMethodHandle copyWithExtendF(MethodType mt, LambdaForm lf, float narg) {
    92     /*non-public*/
       
    93     final BoundMethodHandle copyWithExtendF(MethodType mt, LambdaForm lf, float narg) {
    86         try {
    94         try {
    87             return (BoundMethodHandle) BMH_SPECIES.extendWith(F_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
    95             return (BoundMethodHandle) BMH_SPECIES.extendWith(F_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
    88         } catch (Throwable ex) {
    96         } catch (Throwable ex) {
    89             throw uncaughtException(ex);
    97             throw uncaughtException(ex);
    90         }
    98         }
    91     }
    99     }
    92     @Override
   100     @Override
    93     /*non-public*/ final BoundMethodHandle copyWithExtendD(MethodType mt, LambdaForm lf, double narg) {
   101     /*non-public*/
       
   102     final BoundMethodHandle copyWithExtendD(MethodType mt, LambdaForm lf, double narg) {
    94         try {
   103         try {
    95             return (BoundMethodHandle) BMH_SPECIES.extendWith(D_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
   104             return (BoundMethodHandle) BMH_SPECIES.extendWith(D_TYPE_NUM).factory().invokeBasic(mt, lf, narg);
    96         } catch (Throwable ex) {
   105         } catch (Throwable ex) {
    97             throw uncaughtException(ex);
   106             throw uncaughtException(ex);
    98         }
   107         }