Java Code Examples for com.sun.tools.javac.code.Symbol#isConstructor()
The following examples show how to use
com.sun.tools.javac.code.Symbol#isConstructor() .
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 lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 2
Source File: TestInvokeDynamic.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@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: LambdaToMethod.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 4
Source File: TestInvokeDynamic.java From hottub with GNU General Public License v2.0 | 6 votes |
@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: LambdaToMethod.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 6
Source File: TestInvokeDynamic.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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: LambdaToMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 8
Source File: TestInvokeDynamic.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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: LambdaToMethod.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 10
Source File: LambdaToMethod.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 11
Source File: TestInvokeDynamic.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@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 12
Source File: TestInvokeDynamic.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@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 13
Source File: LambdaToMethod.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 14
Source File: TestInvokeDynamic.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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 15
Source File: LambdaToMethod.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Get the opcode associated with this method reference */ private int referenceKind(Symbol refSym) { if (refSym.isConstructor()) { return ClassFile.REF_newInvokeSpecial; } else { if (refSym.isStatic()) { return ClassFile.REF_invokeStatic; } else if ((refSym.flags() & PRIVATE) != 0) { return ClassFile.REF_invokeSpecial; } else if (refSym.enclClass().isInterface()) { return ClassFile.REF_invokeInterface; } else { return ClassFile.REF_invokeVirtual; } } }
Example 16
Source File: TestInvokeDynamic.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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 17
Source File: HandleDelegate.java From EasyMPermission with MIT License | 5 votes |
public void addMethodBindings(List<MethodSig> signatures, ClassType ct, JavacTypes types, Set<String> banList) throws DelegateRecursion { TypeSymbol tsym = ct.asElement(); if (tsym == null) return; for (Symbol member : tsym.getEnclosedElements()) { for (Compound am : member.getAnnotationMirrors()) { String name = null; try { name = am.type.tsym.flatName().toString(); } catch (Exception ignore) {} if ("lombok.Delegate".equals(name) || "lombok.experimental.Delegate".equals(name)) { throw new DelegateRecursion(ct.tsym.name.toString(), member.name.toString()); } } if (member.getKind() != ElementKind.METHOD) continue; if (member.isStatic()) continue; if (member.isConstructor()) continue; ExecutableElement exElem = (ExecutableElement)member; if (!exElem.getModifiers().contains(Modifier.PUBLIC)) continue; ExecutableType methodType = (ExecutableType) types.asMemberOf(ct, member); String sig = printSig(methodType, member.name, types); if (!banList.add(sig)) continue; //If add returns false, it was already in there boolean isDeprecated = (member.flags() & DEPRECATED) != 0; signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem)); } if (ct.supertype_field instanceof ClassType) addMethodBindings(signatures, (ClassType) ct.supertype_field, types, banList); if (ct.interfaces_field != null) for (Type iface : ct.interfaces_field) { if (iface instanceof ClassType) addMethodBindings(signatures, (ClassType) iface, types, banList); } }
Example 18
Source File: TestBootstrapMethodsCount.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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 19
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** Is the annotation applicable to the symbol? */ boolean annotationApplicable(JCAnnotation a, Symbol s) { Attribute.Array arr = getAttributeTargetAttribute(a.annotationType.type.tsym); Name[] targets; if (arr == null) { targets = defaultTargetMetaInfo(a, s); } else { // TODO: can we optimize this? targets = new Name[arr.values.length]; for (int i=0; i<arr.values.length; ++i) { Attribute app = arr.values[i]; if (!(app instanceof Attribute.Enum)) { return true; // recovery } Attribute.Enum e = (Attribute.Enum) app; targets[i] = e.value.name; } } for (Name target : targets) { if (target == names.TYPE) { if (s.kind == TYP) return true; } else if (target == names.FIELD) { if (s.kind == VAR && s.owner.kind != MTH) return true; } else if (target == names.METHOD) { if (s.kind == MTH && !s.isConstructor()) return true; } else if (target == names.PARAMETER) { if (s.kind == VAR && s.owner.kind == MTH && (s.flags() & PARAMETER) != 0) { return true; } } else if (target == names.CONSTRUCTOR) { if (s.kind == MTH && s.isConstructor()) return true; } else if (target == names.LOCAL_VARIABLE) { if (s.kind == VAR && s.owner.kind == MTH && (s.flags() & PARAMETER) == 0) { return true; } } else if (target == names.ANNOTATION_TYPE) { if (s.kind == TYP && (s.flags() & ANNOTATION) != 0) { return true; } } else if (target == names.PACKAGE) { if (s.kind == PCK) return true; } else if (target == names.TYPE_USE) { if (s.kind == VAR && s.owner.kind == MTH && s.type.hasTag(NONE)) { //cannot type annotate implictly typed locals return false; } else if (s.kind == TYP || s.kind == VAR || (s.kind == MTH && !s.isConstructor() && !s.type.getReturnType().hasTag(VOID)) || (s.kind == MTH && s.isConstructor())) { return true; } } else if (target == names.TYPE_PARAMETER) { if (s.kind == TYP && s.type.hasTag(TYPEVAR)) return true; } else return true; // Unknown ElementType. This should be an error at declaration site, // assume applicable. } return false; }
Example 20
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public boolean accepts(Symbol s) { return s.kind == MTH && (s.flags() & DEFAULT) != 0 && s.isInheritedIn(site.tsym, types) && !s.isConstructor(); }