Java Code Examples for com.sun.tools.javac.code.Symbol#DynamicMethodSymbol

The following examples show how to use com.sun.tools.javac.code.Symbol#DynamicMethodSymbol . 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: TestInvokeDynamic.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        Object[] staticArgs = new Object[arity.arity];
        for (int i = 0; i < arity.arity ; i++) {
            staticArgs[i] = saks[i].getValue(syms, names, types);
        }
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
    }
    return null;
}
 
Example 2
Source File: TestInvokeDynamic.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        Object[] staticArgs = new Object[arity.arity];
        for (int i = 0; i < arity.arity ; i++) {
            staticArgs[i] = saks[i].getValue(syms, names, types);
        }
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
    }
    return null;
}
 
Example 3
Source File: TestInvokeDynamic.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        Object[] staticArgs = new Object[arity.arity];
        for (int i = 0; i < arity.arity ; i++) {
            staticArgs[i] = saks[i].getValue(syms, names, types);
        }
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
    }
    return null;
}
 
Example 4
Source File: TestInvokeDynamic.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        Object[] staticArgs = new Object[arity.arity];
        for (int i = 0; i < arity.arity ; i++) {
            staticArgs[i] = saks[i].getValue(syms, names, types);
        }
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
    }
    return null;
}
 
Example 5
Source File: TestInvokeDynamic.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        Object[] staticArgs = new Object[arity.arity];
        for (int i = 0; i < arity.arity ; i++) {
            staticArgs[i] = saks[i].getValue(syms, names, types);
        }
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
    }
    return null;
}
 
Example 6
Source File: TestInvokeDynamic.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        Object[] staticArgs = new Object[arity.arity];
        for (int i = 0; i < arity.arity ; i++) {
            staticArgs[i] = saks[i].getValue(syms, names, types);
        }
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
    }
    return null;
}
 
Example 7
Source File: TestInvokeDynamic.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        Object[] staticArgs = new Object[arity.arity];
        for (int i = 0; i < arity.arity ; i++) {
            staticArgs[i] = saks[i].getValue(syms, names, types);
        }
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
    }
    return null;
}
 
Example 8
Source File: TestInvokeDynamic.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        Object[] staticArgs = new Object[arity.arity];
        for (int i = 0; i < arity.arity ; i++) {
            staticArgs[i] = saks[i].getValue(syms, names, types);
        }
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
    }
    return null;
}
 
Example 9
Source File: StringConcat.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Produce the actual invokedynamic call to StringConcatFactory */
private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, List<Type> dynamicArgTypes) {
    Type.MethodType indyType = new Type.MethodType(dynamicArgTypes,
            type,
            List.nil(),
            syms.methodClass);

    int prevPos = make.pos;
    try {
        make.at(pos);

        List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
                syms.stringType,
                syms.methodTypeType);

        Symbol bsm = rs.resolveInternalMethod(pos,
                gen.getAttrEnv(),
                syms.stringConcatFactory,
                names.makeConcat,
                bsm_staticArgs,
                null);

        Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcat,
                syms.noSymbol,
                ClassFile.REF_invokeStatic,
                (Symbol.MethodSymbol)bsm,
                indyType,
                List.nil().toArray());

        Items.Item item = gen.getItems().makeDynamicItem(dynSym);
        item.invoke();
    } finally {
        make.at(prevPos);
    }
}
 
Example 10
Source File: TestBootstrapMethodsCount.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
    super.visitMethodInvocation(node, p);
    JCMethodInvocation apply = (JCMethodInvocation)node;
    JCIdent ident = (JCIdent)apply.meth;
    Symbol oldSym = ident.sym;
    if (!oldSym.isConstructor()) {
        ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
                oldSym.owner, REF_invokeStatic, bsm, oldSym.type, new Object[0]);
    }
    return null;
}
 
Example 11
Source File: StringConcat.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/** Produce the actual invokedynamic call to StringConcatFactory */
private void doCall(Type type, JCDiagnostic.DiagnosticPosition pos, String recipe, List<Object> staticArgs, List<Type> dynamicArgTypes) {
    Type.MethodType indyType = new Type.MethodType(dynamicArgTypes,
            type,
            List.nil(),
            syms.methodClass);

    int prevPos = make.pos;
    try {
        make.at(pos);

        ListBuffer<Type> constTypes = new ListBuffer<>();
        ListBuffer<Object> constants = new ListBuffer<>();
        for (Object t : staticArgs) {
            constants.add(t);
            constTypes.add(syms.stringType);
        }

        List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
                syms.stringType,
                syms.methodTypeType)
                .append(syms.stringType)
                .appendList(constTypes);

        Symbol bsm = rs.resolveInternalMethod(pos,
                gen.getAttrEnv(),
                syms.stringConcatFactory,
                names.makeConcatWithConstants,
                bsm_staticArgs,
                null);

        Symbol.DynamicMethodSymbol dynSym = new Symbol.DynamicMethodSymbol(names.makeConcatWithConstants,
                syms.noSymbol,
                ClassFile.REF_invokeStatic,
                (Symbol.MethodSymbol)bsm,
                indyType,
                List.<Object>of(recipe).appendList(constants).toArray());

        Items.Item item = gen.getItems().makeDynamicItem(dynSym);
        item.invoke();
    } finally {
        make.at(prevPos);
    }
}