Java Code Examples for com.sun.tools.javac.code.Type.MethodType#getReturnType()
The following examples show how to use
com.sun.tools.javac.code.Type.MethodType#getReturnType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LambdaToMethod.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Generate an indy method call with given name, type and static bootstrap * arguments types */ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs, Name methName) { int prevPos = make.pos; try { make.at(pos); List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, syms.stringType, syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.<Type>nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, syms.noSymbol, bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, (MethodSymbol)bsm, indyType, staticArgs.toArray()); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); qualifier.sym = dynSym; qualifier.type = indyType.getReturnType(); JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs); proxyCall.type = indyType.getReturnType(); return proxyCall; } finally { make.at(prevPos); } }
Example 2
Source File: LambdaToMethod.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Generate an indy method call with given name, type and static bootstrap * arguments types */ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs, Name methName) { int prevPos = make.pos; try { make.at(pos); List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, syms.stringType, syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.<Type>nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, syms.noSymbol, bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, (MethodSymbol)bsm, indyType, staticArgs.toArray()); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); qualifier.sym = dynSym; qualifier.type = indyType.getReturnType(); JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs); proxyCall.type = indyType.getReturnType(); return proxyCall; } finally { make.at(prevPos); } }
Example 3
Source File: LambdaToMethod.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Generate an indy method call with given name, type and static bootstrap * arguments types */ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs, Name methName) { int prevPos = make.pos; try { make.at(pos); List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, syms.stringType, syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.<Type>nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, syms.noSymbol, bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, (MethodSymbol)bsm, indyType, staticArgs.toArray()); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); qualifier.sym = dynSym; qualifier.type = indyType.getReturnType(); JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs); proxyCall.type = indyType.getReturnType(); return proxyCall; } finally { make.at(prevPos); } }
Example 4
Source File: LambdaToMethod.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Generate an indy method call with given name, type and static bootstrap * arguments types */ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs, Name methName) { int prevPos = make.pos; try { make.at(pos); List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, syms.stringType, syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, syms.noSymbol, bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, (MethodSymbol)bsm, indyType, staticArgs.toArray()); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); qualifier.sym = dynSym; qualifier.type = indyType.getReturnType(); JCMethodInvocation proxyCall = make.Apply(List.nil(), qualifier, indyArgs); proxyCall.type = indyType.getReturnType(); return proxyCall; } finally { make.at(prevPos); } }
Example 5
Source File: LambdaToMethod.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Generate an indy method call with given name, type and static bootstrap * arguments types */ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs, Name methName) { int prevPos = make.pos; try { make.at(pos); List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, syms.stringType, syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.<Type>nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, syms.noSymbol, bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, (MethodSymbol)bsm, indyType, staticArgs.toArray()); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); qualifier.sym = dynSym; qualifier.type = indyType.getReturnType(); JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs); proxyCall.type = indyType.getReturnType(); return proxyCall; } finally { make.at(prevPos); } }
Example 6
Source File: LambdaToMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Generate an indy method call with given name, type and static bootstrap * arguments types */ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs, Name methName) { int prevPos = make.pos; try { make.at(pos); List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, syms.stringType, syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, syms.noSymbol, bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, (MethodSymbol)bsm, indyType, staticArgs.toArray()); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); qualifier.sym = dynSym; qualifier.type = indyType.getReturnType(); JCMethodInvocation proxyCall = make.Apply(List.nil(), qualifier, indyArgs); proxyCall.type = indyType.getReturnType(); return proxyCall; } finally { make.at(prevPos); } }
Example 7
Source File: LambdaToMethod.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Generate an indy method call with given name, type and static bootstrap * arguments types */ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs, Name methName) { int prevPos = make.pos; try { make.at(pos); List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, syms.stringType, syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.<Type>nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, syms.noSymbol, bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, (MethodSymbol)bsm, indyType, staticArgs.toArray()); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); qualifier.sym = dynSym; qualifier.type = indyType.getReturnType(); JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs); proxyCall.type = indyType.getReturnType(); return proxyCall; } finally { make.at(prevPos); } }
Example 8
Source File: LambdaToMethod.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Generate an indy method call with given name, type and static bootstrap * arguments types */ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs, Name methName) { int prevPos = make.pos; try { make.at(pos); List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, syms.stringType, syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.<Type>nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, syms.noSymbol, bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, (MethodSymbol)bsm, indyType, staticArgs.toArray()); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); qualifier.sym = dynSym; qualifier.type = indyType.getReturnType(); JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs); proxyCall.type = indyType.getReturnType(); return proxyCall; } finally { make.at(prevPos); } }
Example 9
Source File: LambdaToMethod.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Generate an indy method call with given name, type and static bootstrap * arguments types */ private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName, List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs, Name methName) { int prevPos = make.pos; try { make.at(pos); List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType, syms.stringType, syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs)); Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site, bsmName, bsm_staticArgs, List.<Type>nil()); DynamicMethodSymbol dynSym = new DynamicMethodSymbol(methName, syms.noSymbol, bsm.isStatic() ? ClassFile.REF_invokeStatic : ClassFile.REF_invokeVirtual, (MethodSymbol)bsm, indyType, staticArgs.toArray()); JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName); qualifier.sym = dynSym; qualifier.type = indyType.getReturnType(); JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs); proxyCall.type = indyType.getReturnType(); return proxyCall; } finally { make.at(prevPos); } }
Example 10
Source File: Infer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public PartiallyInferredMethodType(MethodType mtype, InferenceContext inferenceContext, Env<AttrContext> env, Warner warn) { super(mtype.getParameterTypes(), mtype.getReturnType(), mtype.getThrownTypes(), mtype.tsym); this.inferenceContext = inferenceContext; this.env = env; this.warn = warn; }
Example 11
Source File: Infer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Generate constraints from the generic method's return type. If the method * call occurs in a context where a type T is expected, use the expected * type to derive more constraints on the generic method inference variables. */ Type generateReturnConstraints(JCTree tree, Attr.ResultInfo resultInfo, MethodType mt, InferenceContext inferenceContext) { InferenceContext rsInfoInfContext = resultInfo.checkContext.inferenceContext(); Type from = mt.getReturnType(); if (mt.getReturnType().containsAny(inferenceContext.inferencevars) && rsInfoInfContext != emptyContext) { from = types.capture(from); //add synthetic captured ivars for (Type t : from.getTypeArguments()) { if (t.hasTag(TYPEVAR) && ((TypeVar)t).isCaptured()) { inferenceContext.addVar((TypeVar)t); } } } Type qtype = inferenceContext.asUndetVar(from); Type to = resultInfo.pt; if (qtype.hasTag(VOID)) { to = syms.voidType; } else if (to.hasTag(NONE)) { to = from.isPrimitive() ? from : syms.objectType; } else if (qtype.hasTag(UNDETVAR)) { if (needsEagerInstantiation((UndetVar)qtype, to, inferenceContext) && (allowGraphInference || !to.isPrimitive())) { to = generateReferenceToTargetConstraint(tree, (UndetVar)qtype, to, resultInfo, inferenceContext); } } else if (rsInfoInfContext.free(resultInfo.pt)) { //propagation - cache captured vars qtype = inferenceContext.asUndetVar(rsInfoInfContext.cachedCapture(tree, from, !resultInfo.checkMode.updateTreeType())); } Assert.check(allowGraphInference || !rsInfoInfContext.free(to), "legacy inference engine cannot handle constraints on both sides of a subtyping assertion"); //we need to skip capture? Warner retWarn = new Warner(); if (!resultInfo.checkContext.compatible(qtype, rsInfoInfContext.asUndetVar(to), retWarn) || //unchecked conversion is not allowed in source 7 mode (!allowGraphInference && retWarn.hasLint(Lint.LintCategory.UNCHECKED))) { throw inferenceException .setMessage("infer.no.conforming.instance.exists", inferenceContext.restvars(), mt.getReturnType(), to); } return from; }