src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java

changeset 111
a92b756a888f
parent 70
62fcf8d73dc5
child 119
1e83972f53fb
     1.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Tue Sep 09 10:28:21 2008 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Tue Sep 09 10:40:50 2008 -0700
     1.3 @@ -27,6 +27,7 @@
     1.4  
     1.5  import java.io.File;
     1.6  import java.io.IOException;
     1.7 +import java.nio.CharBuffer;
     1.8  import java.util.*;
     1.9  import java.util.concurrent.atomic.AtomicBoolean;
    1.10  
    1.11 @@ -45,7 +46,7 @@
    1.12  import com.sun.tools.javac.main.*;
    1.13  import com.sun.tools.javac.model.*;
    1.14  import com.sun.tools.javac.parser.Parser;
    1.15 -import com.sun.tools.javac.parser.Scanner;
    1.16 +import com.sun.tools.javac.parser.ParserFactory;
    1.17  import com.sun.tools.javac.tree.*;
    1.18  import com.sun.tools.javac.tree.JCTree.*;
    1.19  import com.sun.tools.javac.util.*;
    1.20 @@ -93,6 +94,9 @@
    1.21          args.getClass();
    1.22          context.getClass();
    1.23          fileObjects.getClass();
    1.24 +
    1.25 +        // force the use of the scanner that captures Javadoc comments
    1.26 +        com.sun.tools.javac.parser.DocCommentScanner.Factory.preRegister(context);
    1.27      }
    1.28  
    1.29      JavacTaskImpl(JavacTool tool,
    1.30 @@ -166,8 +170,6 @@
    1.31              if (!filenames.isEmpty())
    1.32                  throw new IllegalArgumentException("Malformed arguments " + filenames.toString(" "));
    1.33              compiler = JavaCompiler.instance(context);
    1.34 -            // force the use of the scanner that captures Javadoc comments
    1.35 -            com.sun.tools.javac.parser.DocCommentScanner.Factory.preRegister(context);
    1.36              compiler.keepComments = true;
    1.37              compiler.genEndPos = true;
    1.38              // NOTE: this value will be updated after annotation processing
    1.39 @@ -519,14 +521,12 @@
    1.40              throw new IllegalArgumentException();
    1.41          compiler = JavaCompiler.instance(context);
    1.42          JavaFileObject prev = compiler.log.useSource(null);
    1.43 -        Scanner.Factory scannerFactory = Scanner.Factory.instance(context);
    1.44 -        Parser.Factory parserFactory = Parser.Factory.instance(context);
    1.45 +        ParserFactory parserFactory = ParserFactory.instance(context);
    1.46          Attr attr = Attr.instance(context);
    1.47          try {
    1.48 -            Scanner scanner = scannerFactory.newScanner((expr+"\u0000").toCharArray(),
    1.49 -                                                        expr.length());
    1.50 -            Parser parser = parserFactory.newParser(scanner, false, false);
    1.51 -            JCTree tree = parser.type();
    1.52 +            CharBuffer buf = CharBuffer.wrap((expr+"\u0000").toCharArray(), 0, expr.length());
    1.53 +            Parser parser = parserFactory.newParser(buf, false, false, false);
    1.54 +            JCTree tree = parser.parseType();
    1.55              return attr.attribType(tree, (Symbol.TypeSymbol)scope);
    1.56          } finally {
    1.57              compiler.log.useSource(prev);

mercurial