public Type parseType(String expr, TypeElement scope) {
        if (expr == null || expr.equals(""))
            throw new IllegalArgumentException();
        compiler = JavaCompiler.instance(context);
        JavaFileObject prev = compiler.log.useSource(null);
        Scanner.Factory scannerFactory = Scanner.Factory.instance(context);
        Parser.Factory parserFactory = Parser.Factory.instance(context);
        Attr attr = Attr.instance(context);
        try {
            Scanner scanner = scannerFactory.newScanner((expr+"\u0000").toCharArray(),
                                                        expr.length());
            Parser parser = parserFactory.newParser(scanner, false, false);
            JCTree tree = parser.type();
            return attr.attribType(tree, (Symbol.TypeSymbol)scope);
        } finally {
            compiler.log.useSource(prev);
        }
    }