Java Code Examples for com.sun.tools.javac.code.Type#isErroneous()
The following examples show how to use
com.sun.tools.javac.code.Type#isErroneous() .
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: JavacElements.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns all annotations of an element, whether * inherited or directly present. * * @param e the element being examined * @return all annotations of the element */ @Override @DefinedBy(Api.LANGUAGE_MODEL) public List<Attribute.Compound> getAllAnnotationMirrors(Element e) { Symbol sym = cast(Symbol.class, e); List<Attribute.Compound> annos = sym.getAnnotationMirrors(); while (sym.getKind() == ElementKind.CLASS) { Type sup = ((ClassSymbol) sym).getSuperclass(); if (!sup.hasTag(CLASS) || sup.isErroneous() || sup.tsym == syms.objectType.tsym) { break; } sym = sup.tsym; List<Attribute.Compound> oldAnnos = annos; List<Attribute.Compound> newAnnos = sym.getAnnotationMirrors(); for (Attribute.Compound anno : newAnnos) { if (isInherited(anno.type) && !containsAnnoOfType(oldAnnos, anno.type)) { annos = annos.prepend(anno); } } } return annos; }
Example 2
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** Check that usage of diamond operator is correct (i.e. diamond should not * be used with non-generic classes or in anonymous class creation expressions) */ Type checkDiamond(JCNewClass tree, Type t) { if (!TreeInfo.isDiamond(tree) || t.isErroneous()) { return checkClassType(tree.clazz.pos(), t, true); } else { if (tree.def != null && !allowDiamondWithAnonymousClassCreation) { log.error(DiagnosticFlag.SOURCE_LEVEL, tree.clazz.pos(), Errors.CantApplyDiamond1(t, Fragments.DiamondAndAnonClassNotSupportedInSource(source.name))); } if (t.tsym.type.getTypeArguments().isEmpty()) { log.error(tree.clazz.pos(), Errors.CantApplyDiamond1(t, Fragments.DiamondNonGeneric(t))); return types.createErrorType(t); } else if (tree.typeargs != null && tree.typeargs.nonEmpty()) { log.error(tree.clazz.pos(), Errors.CantApplyDiamond1(t, Fragments.DiamondAndExplicitParams(t))); return types.createErrorType(t); } else { return t; } } }
Example 3
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** Enter all interfaces of type `type' into the hash table `seensofar' * with their class symbol as key and their type as value. Make * sure no class is entered with two different types. */ void checkClassBounds(DiagnosticPosition pos, Map<TypeSymbol,Type> seensofar, Type type) { if (type.isErroneous()) return; for (List<Type> l = types.interfaces(type); l.nonEmpty(); l = l.tail) { Type it = l.head; Type oldit = seensofar.put(it.tsym, it); if (oldit != null) { List<Type> oldparams = oldit.allparams(); List<Type> newparams = it.allparams(); if (!types.containsTypeEquivalent(oldparams, newparams)) log.error(pos, Errors.CantInheritDiffArg(it.tsym, Type.toString(oldparams), Type.toString(newparams))); } checkClassBounds(pos, seensofar, it); } Type st = types.supertype(type); if (st != Type.noType) checkClassBounds(pos, seensofar, st); }
Example 4
Source File: Annotate.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Attribute getAnnotationClassValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) { Type result = attr.attribTree(tree, env, annotationValueInfo(expectedElementType)); if (result.isErroneous()) { // Does it look like an unresolved class literal? if (TreeInfo.name(tree) == names._class && ((JCFieldAccess) tree).selected.type.isErroneous()) { Name n = (((JCFieldAccess) tree).selected).type.tsym.flatName(); return new Attribute.UnresolvedClass(expectedElementType, types.createErrorType(n, syms.unknownSymbol, syms.classType)); } else { return new Attribute.Error(result.getOriginalType()); } } // Class literals look like field accesses of a field named class // at the tree level if (TreeInfo.name(tree) != names._class) { log.error(tree.pos(), Errors.AnnotationValueMustBeClassLiteral); return new Attribute.Error(syms.errType); } return new Attribute.Class(types, (((JCFieldAccess) tree).selected).type); }
Example 5
Source File: JavacTrees.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** @see com.sun.tools.javadoc.ClassDocImpl */ private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { if (paramTypes == null) return true; if (method.params().size() != paramTypes.size()) return false; List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); return (Type.isErroneous(paramTypes)) ? fuzzyMatch(paramTypes, methodParamTypes) : types.isSameTypes(paramTypes, methodParamTypes); }
Example 6
Source File: JavacTrees.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** @see com.sun.tools.javadoc.ClassDocImpl */ private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { if (paramTypes == null) return true; if (method.params().size() != paramTypes.size()) return false; List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); return (Type.isErroneous(paramTypes)) ? fuzzyMatch(paramTypes, methodParamTypes) : types.isSameTypes(paramTypes, methodParamTypes); }
Example 7
Source File: JavacTrees.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { if (paramTypes == null) return true; if (method.params().size() != paramTypes.size()) return false; List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); return (Type.isErroneous(paramTypes)) ? fuzzyMatch(paramTypes, methodParamTypes) : types.isSameTypes(paramTypes, methodParamTypes); }
Example 8
Source File: JavacTrees.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** @see com.sun.tools.javadoc.ClassDocImpl */ private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { if (paramTypes == null) return true; if (method.params().size() != paramTypes.size()) return false; List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); return (Type.isErroneous(paramTypes)) ? fuzzyMatch(paramTypes, methodParamTypes) : types.isSameTypes(paramTypes, methodParamTypes); }
Example 9
Source File: Infer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Make sure that the upper bounds we got so far lead to a solvable inference * variable by making sure that a glb exists. */ void checkCompatibleUpperBounds(UndetVar uv, InferenceContext inferenceContext) { List<Type> hibounds = Type.filter(uv.getBounds(InferenceBound.UPPER), new BoundFilter(inferenceContext)); final Type hb; if (hibounds.isEmpty()) hb = syms.objectType; else if (hibounds.tail.isEmpty()) hb = hibounds.head; else hb = types.glb(hibounds); if (hb == null || hb.isErroneous()) reportBoundError(uv, InferenceBound.UPPER); }
Example 10
Source File: JavacTrees.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** @see com.sun.tools.javadoc.ClassDocImpl */ private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { if (paramTypes == null) return true; if (method.params().size() != paramTypes.size()) return false; List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); return (Type.isErroneous(paramTypes)) ? fuzzyMatch(paramTypes, methodParamTypes) : types.isSameTypes(paramTypes, methodParamTypes); }
Example 11
Source File: Annotate.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Attribute getAnnotationPrimitiveValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) { Type result = attr.attribTree(tree, env, annotationValueInfo(expectedElementType)); if (result.isErroneous()) return new Attribute.Error(result.getOriginalType()); if (result.constValue() == null) { log.error(tree.pos(), Errors.AttributeValueMustBeConstant); return new Attribute.Error(expectedElementType); } result = cfolder.coerce(result, expectedElementType); return new Attribute.Constant(expectedElementType, result.constValue()); }
Example 12
Source File: JavacTrees.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** @see com.sun.tools.javadoc.ClassDocImpl */ private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { if (paramTypes == null) return true; if (method.params().size() != paramTypes.size()) return false; List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); return (Type.isErroneous(paramTypes)) ? fuzzyMatch(paramTypes, methodParamTypes) : types.isSameTypes(paramTypes, methodParamTypes); }
Example 13
Source File: JavacTrees.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** @see com.sun.tools.javadoc.ClassDocImpl */ private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { if (paramTypes == null) return true; if (method.params().size() != paramTypes.size()) return false; List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); return (Type.isErroneous(paramTypes)) ? fuzzyMatch(paramTypes, methodParamTypes) : types.isSameTypes(paramTypes, methodParamTypes); }
Example 14
Source File: JavacTrees.java From hottub with GNU General Public License v2.0 | 5 votes |
/** @see com.sun.tools.javadoc.ClassDocImpl */ private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { if (paramTypes == null) return true; if (method.params().size() != paramTypes.size()) return false; List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); return (Type.isErroneous(paramTypes)) ? fuzzyMatch(paramTypes, methodParamTypes) : types.isSameTypes(paramTypes, methodParamTypes); }
Example 15
Source File: JavacTrees.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** @see com.sun.tools.javadoc.ClassDocImpl */ private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) { if (paramTypes == null) return true; if (method.params().size() != paramTypes.size()) return false; List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes(); return (Type.isErroneous(paramTypes)) ? fuzzyMatch(paramTypes, methodParamTypes) : types.isSameTypes(paramTypes, methodParamTypes); }
Example 16
Source File: JavacResolution.java From EasyMPermission with MIT License | 4 votes |
private static JCExpression typeToJCTree0(Type type, JavacAST ast, boolean allowCompound, boolean allowVoid) throws TypeNotConvertibleException { // NB: There's such a thing as maker.Type(type), but this doesn't work very well; it screws up anonymous classes, captures, and adds an extra prefix dot for some reason too. // -- so we write our own take on that here. JavacTreeMaker maker = ast.getTreeMaker(); if (CTC_BOT.equals(typeTag(type))) return createJavaLangObject(ast); if (CTC_VOID.equals(typeTag(type))) return allowVoid ? primitiveToJCTree(type.getKind(), maker) : createJavaLangObject(ast); if (type.isPrimitive()) return primitiveToJCTree(type.getKind(), maker); if (type.isErroneous()) throw new TypeNotConvertibleException("Type cannot be resolved"); TypeSymbol symbol = type.asElement(); List<Type> generics = type.getTypeArguments(); JCExpression replacement = null; if (symbol == null) throw new TypeNotConvertibleException("Null or compound type"); if (symbol.name.length() == 0) { // Anonymous inner class if (type instanceof ClassType) { List<Type> ifaces = ((ClassType) type).interfaces_field; Type supertype = ((ClassType) type).supertype_field; if (ifaces != null && ifaces.length() == 1) { return typeToJCTree(ifaces.get(0), ast, allowCompound, allowVoid); } if (supertype != null) return typeToJCTree(supertype, ast, allowCompound, allowVoid); } throw new TypeNotConvertibleException("Anonymous inner class"); } if (type instanceof CapturedType || type instanceof WildcardType) { Type lower, upper; if (type instanceof WildcardType) { upper = ((WildcardType)type).getExtendsBound(); lower = ((WildcardType)type).getSuperBound(); } else { lower = type.getLowerBound(); upper = type.getUpperBound(); } if (allowCompound) { if (lower == null || CTC_BOT.equals(typeTag(lower))) { if (upper == null || upper.toString().equals("java.lang.Object")) { return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null); } if (upper.getTypeArguments().contains(type)) { return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null); } return maker.Wildcard(maker.TypeBoundKind(BoundKind.EXTENDS), typeToJCTree(upper, ast, false, false)); } else { return maker.Wildcard(maker.TypeBoundKind(BoundKind.SUPER), typeToJCTree(lower, ast, false, false)); } } if (upper != null) { if (upper.getTypeArguments().contains(type)) { return maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null); } return typeToJCTree(upper, ast, allowCompound, allowVoid); } return createJavaLangObject(ast); } String qName; if (symbol.isLocal()) { qName = symbol.getSimpleName().toString(); } else if (symbol.type != null && symbol.type.getEnclosingType() != null && typeTag(symbol.type.getEnclosingType()).equals(typeTag("CLASS"))) { replacement = typeToJCTree0(type.getEnclosingType(), ast, false, false); qName = symbol.getSimpleName().toString(); } else { qName = symbol.getQualifiedName().toString(); } if (qName.isEmpty()) throw new TypeNotConvertibleException("unknown type"); if (qName.startsWith("<")) throw new TypeNotConvertibleException(qName); String[] baseNames = qName.split("\\."); int i = 0; if (replacement == null) { replacement = maker.Ident(ast.toName(baseNames[0])); i = 1; } for (; i < baseNames.length; i++) { replacement = maker.Select(replacement, ast.toName(baseNames[i])); } return genericsToJCTreeNodes(generics, ast, replacement); }
Example 17
Source File: Infer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public boolean accepts(Type t) { return !t.isErroneous() && !inferenceContext.free(t) && !t.hasTag(BOT); }
Example 18
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public Boolean visitType(Type t, Void s) { return t.isErroneous(); }