Java Code Examples for com.sun.tools.javac.code.Type#noType()

The following examples show how to use com.sun.tools.javac.code.Type#noType() . 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: DeferredAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Type check(ResultInfo resultInfo, DeferredStuckPolicy deferredStuckPolicy,
        DeferredTypeCompleter deferredTypeCompleter) {
    DeferredAttrContext deferredAttrContext =
            resultInfo.checkContext.deferredAttrContext();
    Assert.check(deferredAttrContext != emptyDeferredAttrContext);
    if (deferredStuckPolicy.isStuck()) {
        pertinentToApplicability = false;
        deferredAttrContext.addDeferredAttrNode(this, resultInfo, deferredStuckPolicy);
        return Type.noType;
    } else {
        try {
            return deferredTypeCompleter.complete(this, resultInfo, deferredAttrContext);
        } finally {
            mode = deferredAttrContext.mode;
        }
    }
}
 
Example 2
Source File: Operators.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected Operators(Context context) {
    context.put(operatorsKey, this);
    syms = Symtab.instance(context);
    names = Names.instance(context);
    log = Log.instance(context);
    types = Types.instance(context);
    noOpSymbol = new OperatorSymbol(names.empty, Type.noType, -1, syms.noSymbol);
    initOperatorNames();
    initUnaryOperators();
    initBinaryOperators();
}
 
Example 3
Source File: ArgumentAttr.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
Type speculativeType(Symbol msym, MethodResolutionPhase phase) {
    if (pertinentToApplicability) {
        for (Map.Entry<ResultInfo, Type> _entry : speculativeTypes.entrySet()) {
            DeferredAttrContext deferredAttrContext = _entry.getKey().checkContext.deferredAttrContext();
            if (deferredAttrContext.phase == phase && deferredAttrContext.msym == msym) {
                return _entry.getValue();
            }
        }
        return Type.noType;
    } else {
        return super.speculativeType(msym, phase);
    }
}
 
Example 4
Source File: ArgumentAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
Type speculativeType(Symbol msym, MethodResolutionPhase phase) {
    if (pertinentToApplicability) {
        for (Map.Entry<ResultInfo, Type> _entry : speculativeTypes.entrySet()) {
            DeferredAttrContext deferredAttrContext = _entry.getKey().checkContext.deferredAttrContext();
            if (deferredAttrContext.phase == phase && deferredAttrContext.msym == msym) {
                return _entry.getValue();
            }
        }
        return Type.noType;
    } else {
        return super.speculativeType(msym, phase);
    }
}
 
Example 5
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void checkConflicts(DiagnosticPosition pos, Symbol sym, TypeSymbol c) {
    for (Type ct = c.type; ct != Type.noType ; ct = types.supertype(ct)) {
        for (Symbol sym2 : ct.tsym.members().getSymbolsByName(sym.name, NON_RECURSIVE)) {
            // VM allows methods and variables with differing types
            if (sym.kind == sym2.kind &&
                types.isSameType(types.erasure(sym.type), types.erasure(sym2.type)) &&
                sym != sym2 &&
                (sym.flags() & Flags.SYNTHETIC) != (sym2.flags() & Flags.SYNTHETIC) &&
                (sym.flags() & BRIDGE) == 0 && (sym2.flags() & BRIDGE) == 0) {
                syntheticError(pos, (sym2.flags() & SYNTHETIC) == 0 ? sym2 : sym);
                return;
            }
        }
    }
}
 
Example 6
Source File: DeferredAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Incrementally process all nodes, by skipping 'stuck' nodes and attributing
 * 'unstuck' ones. If at any point no progress can be made (no 'unstuck' nodes)
 * some inference variable might get eagerly instantiated so that all nodes
 * can be type-checked.
 */
void complete() {
    while (!deferredAttrNodes.isEmpty()) {
        boolean progress = false;
        //scan a defensive copy of the node list - this is because a deferred
        //attribution round can add new nodes to the list
        for (DeferredAttrNode deferredAttrNode : List.from(deferredAttrNodes)) {
            if (deferredAttrNode.process(this)) {
                deferredAttrNodes.remove(deferredAttrNode);
                progress = true;
            }
        }
        if (!progress) {
            if (insideOverloadPhase()) {
                for (DeferredAttrNode deferredNode: deferredAttrNodes) {
                    deferredNode.dt.tree.type = Type.noType;
                }
                return;
            }
            //remove all variables that have already been instantiated
            //from the list of stuck variables
            try {
                //find stuck expression to unstuck
                DeferredAttrNode toUnstuck = pickDeferredNode();
                inferenceContext.solveAny(List.from(toUnstuck.deferredStuckPolicy.stuckVars()), warn);
                inferenceContext.notifyChange();
            } catch (Infer.GraphStrategy.NodeNotFoundException ex) {
                //this means that we are in speculative mode and the
                //set of contraints are too tight for progess to be made.
                //Just leave the remaining expressions as stuck.
                break;
            }
        }
    }
}
 
Example 7
Source File: DeferredAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
    this.resultInfo = resultInfo;
    this.inferenceContext = deferredAttrContext.inferenceContext;
    this.env = dt.env;
    dt.tree.accept(this);
    dt.speculativeCache.put(stuckTree, resultInfo);
    return Type.noType;
}
 
Example 8
Source File: TypeEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void runPhase(Env<AttrContext> env) {
    JCClassDecl tree = env.enclClass;
    ClassSymbol sym = tree.sym;
    ClassType ct = (ClassType)sym.type;

    Env<AttrContext> baseEnv = baseEnv(tree, env);

    attribSuperTypes(env, baseEnv);

    if (sym.fullname == names.java_lang_Object) {
        if (tree.extending != null) {
            chk.checkNonCyclic(tree.extending.pos(),
                               ct.supertype_field);
            ct.supertype_field = Type.noType;
        }
        else if (tree.implementing.nonEmpty()) {
            chk.checkNonCyclic(tree.implementing.head.pos(),
                               ct.interfaces_field.head);
            ct.interfaces_field = List.nil();
        }
    }

    markDeprecated(sym, tree.mods.annotations, baseEnv);

    chk.checkNonCyclicDecl(tree);
}
 
Example 9
Source File: PackageGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
Type getTypeByName(String typeName, List<Type> tparams) {
    return new Type.ClassType(
               Type.noType,
               tparams,
               new Symbol.ClassSymbol(0, names.fromString(typeName), null));
}
 
Example 10
Source File: TypeHarness.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Class(long flags, Type... typeArgs) {
    ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol);
    csym.type = new ClassType(Type.noType, List.from(typeArgs), csym);
    ((ClassType)csym.type).supertype_field = predef.objectType;
    return (ClassType)csym.type;
}
 
Example 11
Source File: TypeHarness.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Class(long flags, Type... typeArgs) {
    ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol);
    csym.type = new ClassType(Type.noType, List.from(typeArgs), csym);
    ((ClassType)csym.type).supertype_field = predef.objectType;
    return (ClassType)csym.type;
}
 
Example 12
Source File: TypeHarness.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Class(long flags, Type... typeArgs) {
    ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol);
    csym.type = new ClassType(Type.noType, List.from(typeArgs), csym);
    ((ClassType)csym.type).supertype_field = predef.objectType;
    return (ClassType)csym.type;
}
 
Example 13
Source File: TypeEnter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected void attribSuperTypes(Env<AttrContext> env, Env<AttrContext> baseEnv) {
    JCClassDecl tree = env.enclClass;
    ClassSymbol sym = tree.sym;
    ClassType ct = (ClassType)sym.type;
    // Determine supertype.
    Type supertype;
    JCExpression extending;

    if (tree.extending != null) {
        extending = clearTypeParams(tree.extending);
        supertype = attr.attribBase(extending, baseEnv, true, false, true);
    } else {
        extending = null;
        supertype = ((tree.mods.flags & Flags.ENUM) != 0)
        ? attr.attribBase(enumBase(tree.pos, sym), baseEnv,
                          true, false, false)
        : (sym.fullname == names.java_lang_Object)
        ? Type.noType
        : syms.objectType;
    }
    ct.supertype_field = modelMissingTypes(baseEnv, supertype, extending, false);

    // Determine interfaces.
    ListBuffer<Type> interfaces = new ListBuffer<>();
    ListBuffer<Type> all_interfaces = null; // lazy init
    List<JCExpression> interfaceTrees = tree.implementing;
    for (JCExpression iface : interfaceTrees) {
        iface = clearTypeParams(iface);
        Type it = attr.attribBase(iface, baseEnv, false, true, true);
        if (it.hasTag(CLASS)) {
            interfaces.append(it);
            if (all_interfaces != null) all_interfaces.append(it);
        } else {
            if (all_interfaces == null)
                all_interfaces = new ListBuffer<Type>().appendList(interfaces);
            all_interfaces.append(modelMissingTypes(baseEnv, it, iface, true));
        }
    }

    if ((sym.flags_field & ANNOTATION) != 0) {
        ct.interfaces_field = List.of(syms.annotationType);
        ct.all_interfaces_field = ct.interfaces_field;
    }  else {
        ct.interfaces_field = interfaces.toList();
        ct.all_interfaces_field = (all_interfaces == null)
                ? ct.interfaces_field : all_interfaces.toList();
    }
}
 
Example 14
Source File: TypeHarness.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Class(long flags, Type... typeArgs) {
    ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol);
    csym.type = new ClassType(Type.noType, List.from(typeArgs), csym);
    ((ClassType)csym.type).supertype_field = predef.objectType;
    return (ClassType)csym.type;
}
 
Example 15
Source File: UClassType.java    From Refaster with Apache License 2.0 4 votes vote down vote up
@Override
public ClassType inline(Inliner inliner) throws CouldNotResolveImportException {
  ClassSymbol classSymbol = inliner.resolveClass(fullyQualifiedClass());
  return new ClassType(
      Type.noType, inliner.<Type, UType>inlineList(typeArguments()), classSymbol);
}
 
Example 16
Source File: DeferredAttr.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Get the type that has been computed during a speculative attribution round
 */
Type speculativeType(Symbol msym, MethodResolutionPhase phase) {
    SpeculativeCache.Entry e = speculativeCache.get(msym, phase);
    return e != null ? e.speculativeTree.type : Type.noType;
}
 
Example 17
Source File: TypeHarness.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Class(long flags, Type... typeArgs) {
    ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol);
    csym.type = new ClassType(Type.noType, List.from(typeArgs), csym);
    ((ClassType)csym.type).supertype_field = predef.objectType;
    return (ClassType)csym.type;
}
 
Example 18
Source File: ClassReader.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public Type javaTypeToType(java.lang.reflect.Type type){
    if(type instanceof Class) return classToType((Class) type);
    else if(type instanceof java.lang.reflect.WildcardType){
        java.lang.reflect.Type[] lowerBounds=((java.lang.reflect.WildcardType) type).getLowerBounds();
        java.lang.reflect.Type[] upperBounds=((java.lang.reflect.WildcardType) type).getUpperBounds();
        if(lowerBounds.length>0){
            if(upperBounds.length>1||lowerBounds.length!=1) {//always have object as its upper bound
                throw badClassFile("bad.class.file",type.toString());
            }
            return new WildcardType(javaTypeToType(lowerBounds[0]),BoundKind.SUPER,syms.boundClass);
        }else if(upperBounds.length>0){
            if(upperBounds.length!=1) {
                throw badClassFile("bad.class.file",type.toString());
            }
            return new WildcardType(javaTypeToType(upperBounds[0]),BoundKind.EXTENDS,syms.boundClass);
        }
        return new WildcardType(syms.objectType,BoundKind.UNBOUND,syms.boundClass);
    }else if(type instanceof ParameterizedType){
        java.lang.reflect.Type[] args=((ParameterizedType) type).getActualTypeArguments();
        List<Type> params=StreamSupport.stream(Arrays.asList(args)).map(this::javaTypeToType).collect(List.collector());
        ClassSymbol symbol=syms.enterClass(currentModule,names.fromString(((Class)((ParameterizedType) type).getRawType()).getName()));
        return new ClassType(Type.noType,params,symbol){
            boolean completed;
            @Override
            public Type getEnclosingType() {
                if(!completed){
                    completed=true;
                    tsym.complete();
                    super.setEnclosingType(tsym.type.getEnclosingType());
                }
                return super.getEnclosingType();
            }

            @Override
            public void setEnclosingType(Type outer) {
                throw new UnsupportedOperationException();
            }
        };
    }else if(type instanceof GenericArrayType){
        return types.makeArrayType(javaTypeToType(((GenericArrayType) type).getGenericComponentType()));
    }else if(type instanceof TypeVariable)
        return findTypeVar(names.fromString(type.toString()));
    return null;
}
 
Example 19
Source File: TypeHarness.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Class(long flags, Type... typeArgs) {
    ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol);
    csym.type = new ClassType(Type.noType, List.from(typeArgs), csym);
    ((ClassType)csym.type).supertype_field = predef.objectType;
    return (ClassType)csym.type;
}
 
Example 20
Source File: TypeHarness.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public ClassType Class(long flags, Type... typeArgs) {
    ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol);
    csym.type = new ClassType(Type.noType, List.from(typeArgs), csym);
    ((ClassType)csym.type).supertype_field = predef.objectType;
    return (ClassType)csym.type;
}