< prev index next >

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

Print this page

377             // parameter, i.e., the receiver
378             if (types[i] == LF_INVVIRTUAL || types[i] == LF_INVINTERFACE) {
379                 if (methodTypes[i].parameterCount() < 1 ||
380                         methodTypes[i].parameterType(0) != Object.class) {
381                     throw new InternalError("Invalid method type for " +
382                             (types[i] == LF_INVVIRTUAL ? "invokeVirtual" : "invokeInterface") +
383                             " DMH, needs at least two leading reference arguments: " +
384                             methodTypes[i]);
385                 }
386             }
387 
388             LambdaForm form = DirectMethodHandle.makePreparedLambdaForm(methodTypes[i], types[i]);
389             forms.add(form);
390             names.add(form.kind.defaultLambdaName);
391         }
392         for (Wrapper wrapper : Wrapper.values()) {
393             if (wrapper == Wrapper.VOID) {
394                 continue;
395             }
396             for (byte b = DirectMethodHandle.AF_GETFIELD; b < DirectMethodHandle.AF_LIMIT; b++) {
397                 int ftype = DirectMethodHandle.ftypeKind(wrapper.primitiveType());
398                 LambdaForm form = DirectMethodHandle
399                         .makePreparedFieldLambdaForm(b, /*isVolatile*/false, ftype);
400                 if (form.kind != LambdaForm.Kind.GENERIC) {
401                     forms.add(form);
402                     names.add(form.kind.defaultLambdaName);
403                 }
404                 // volatile
405                 form = DirectMethodHandle
406                         .makePreparedFieldLambdaForm(b, /*isVolatile*/true, ftype);
407                 if (form.kind != LambdaForm.Kind.GENERIC) {
408                     forms.add(form);
409                     names.add(form.kind.defaultLambdaName);
410                 }
411             }
412         }
413         return generateCodeBytesForLFs(className,
414                 names.toArray(new String[0]),
415                 forms.toArray(new LambdaForm[0]));
416     }
417 
418     /**
419      * Returns a {@code byte[]} representation of a class implementing
420      * DelegatingMethodHandles of each {@code MethodType} kind in the
421      * {@code methodTypes} argument.
422      */
423     static byte[] generateDelegatingMethodHandleHolderClassBytes(String className,
424             MethodType[] methodTypes) {
425 
426         HashSet<MethodType> dedupSet = new HashSet<>();

377             // parameter, i.e., the receiver
378             if (types[i] == LF_INVVIRTUAL || types[i] == LF_INVINTERFACE) {
379                 if (methodTypes[i].parameterCount() < 1 ||
380                         methodTypes[i].parameterType(0) != Object.class) {
381                     throw new InternalError("Invalid method type for " +
382                             (types[i] == LF_INVVIRTUAL ? "invokeVirtual" : "invokeInterface") +
383                             " DMH, needs at least two leading reference arguments: " +
384                             methodTypes[i]);
385                 }
386             }
387 
388             LambdaForm form = DirectMethodHandle.makePreparedLambdaForm(methodTypes[i], types[i]);
389             forms.add(form);
390             names.add(form.kind.defaultLambdaName);
391         }
392         for (Wrapper wrapper : Wrapper.values()) {
393             if (wrapper == Wrapper.VOID) {
394                 continue;
395             }
396             for (byte b = DirectMethodHandle.AF_GETFIELD; b < DirectMethodHandle.AF_LIMIT; b++) {
397                 int ftype = DirectMethodHandle.ftypeKind(wrapper.primitiveType(), true);
398                 LambdaForm form = DirectMethodHandle
399                         .makePreparedFieldLambdaForm(b, false /*isVolatile*/, ftype);
400                 if (form.kind != LambdaForm.Kind.GENERIC) {
401                     forms.add(form);
402                     names.add(form.kind.defaultLambdaName);
403                 }
404                 // volatile
405                 form = DirectMethodHandle
406                         .makePreparedFieldLambdaForm(b, true /*isVolatile*/, ftype);
407                 if (form.kind != LambdaForm.Kind.GENERIC) {
408                     forms.add(form);
409                     names.add(form.kind.defaultLambdaName);
410                 }
411             }
412         }
413         return generateCodeBytesForLFs(className,
414                 names.toArray(new String[0]),
415                 forms.toArray(new LambdaForm[0]));
416     }
417 
418     /**
419      * Returns a {@code byte[]} representation of a class implementing
420      * DelegatingMethodHandles of each {@code MethodType} kind in the
421      * {@code methodTypes} argument.
422      */
423     static byte[] generateDelegatingMethodHandleHolderClassBytes(String className,
424             MethodType[] methodTypes) {
425 
426         HashSet<MethodType> dedupSet = new HashSet<>();
< prev index next >