< prev index next >

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

Print this page




 183         for (Class<?> c : markerInterfaces) {
 184             if (!c.isInterface()) {
 185                 throw new LambdaConversionException(String.format(
 186                         "Marker interface %s is not an interface",
 187                         c.getName()));
 188             }
 189         }
 190     }
 191 
 192     /**
 193      * Build the CallSite.
 194      *
 195      * @return a CallSite, which, when invoked, will return an instance of the
 196      * functional interface
 197      * @throws ReflectiveOperationException
 198      */
 199     abstract CallSite buildCallSite()
 200             throws LambdaConversionException;
 201 
 202     /**











 203      * Check the meta-factory arguments for errors
 204      * @throws LambdaConversionException if there are improper conversions
 205      */
 206     void validateMetafactoryArgs() throws LambdaConversionException {
 207         // Check arity: captured + SAM == impl
 208         final int implArity = implMethodType.parameterCount();
 209         final int capturedArity = invokedType.parameterCount();
 210         final int samArity = samMethodType.parameterCount();
 211         final int instantiatedArity = instantiatedMethodType.parameterCount();
 212         if (implArity != capturedArity + samArity) {
 213             throw new LambdaConversionException(
 214                     String.format("Incorrect number of parameters for %s method %s; %d captured parameters, %d functional interface method parameters, %d implementation parameters",
 215                                   implIsInstanceMethod ? "instance" : "static", implInfo,
 216                                   capturedArity, samArity, implArity));
 217         }
 218         if (instantiatedArity != samArity) {
 219             throw new LambdaConversionException(
 220                     String.format("Incorrect number of parameters for %s method %s; %d instantiated parameters, %d functional interface method parameters",
 221                                   implIsInstanceMethod ? "instance" : "static", implInfo,
 222                                   instantiatedArity, samArity));




 183         for (Class<?> c : markerInterfaces) {
 184             if (!c.isInterface()) {
 185                 throw new LambdaConversionException(String.format(
 186                         "Marker interface %s is not an interface",
 187                         c.getName()));
 188             }
 189         }
 190     }
 191 
 192     /**
 193      * Build the CallSite.
 194      *
 195      * @return a CallSite, which, when invoked, will return an instance of the
 196      * functional interface
 197      * @throws ReflectiveOperationException
 198      */
 199     abstract CallSite buildCallSite()
 200             throws LambdaConversionException;
 201 
 202     /**
 203      * Builds an instance of the functional interface directly.
 204      *
 205      * @return an instance of the functional interface
 206      * @throws ReflectiveOperationException
 207      * @throws LambdaConversionException If properly formed functional interface
 208      * is not found or if creating the functional interface requires parameters
 209      */
 210     abstract Object buildFunctionalInterfaceInstance()
 211             throws LambdaConversionException;
 212 
 213     /**
 214      * Check the meta-factory arguments for errors
 215      * @throws LambdaConversionException if there are improper conversions
 216      */
 217     void validateMetafactoryArgs() throws LambdaConversionException {
 218         // Check arity: captured + SAM == impl
 219         final int implArity = implMethodType.parameterCount();
 220         final int capturedArity = invokedType.parameterCount();
 221         final int samArity = samMethodType.parameterCount();
 222         final int instantiatedArity = instantiatedMethodType.parameterCount();
 223         if (implArity != capturedArity + samArity) {
 224             throw new LambdaConversionException(
 225                     String.format("Incorrect number of parameters for %s method %s; %d captured parameters, %d functional interface method parameters, %d implementation parameters",
 226                                   implIsInstanceMethod ? "instance" : "static", implInfo,
 227                                   capturedArity, samArity, implArity));
 228         }
 229         if (instantiatedArity != samArity) {
 230             throw new LambdaConversionException(
 231                     String.format("Incorrect number of parameters for %s method %s; %d instantiated parameters, %d functional interface method parameters",
 232                                   implIsInstanceMethod ? "instance" : "static", implInfo,
 233                                   instantiatedArity, samArity));


< prev index next >