mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-24 01:00:27 +00:00
7061125: Proposed javac argument processing performance improvement
Reviewed-by: jjg, dlsmith, mcimadamore, forax
This commit is contained in:
parent
01ee832f44
commit
5f2157a8bc
@ -158,10 +158,10 @@ public class JavacTaskImpl extends JavacTask {
|
||||
} else {
|
||||
initContext();
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new ListBuffer<File>();
|
||||
List<File> filenames = compilerMain.processArgs(CommandLine.parse(args));
|
||||
compilerMain.filenames = new LinkedHashSet<File>();
|
||||
Collection<File> filenames = compilerMain.processArgs(CommandLine.parse(args));
|
||||
if (!filenames.isEmpty())
|
||||
throw new IllegalArgumentException("Malformed arguments " + filenames.toString(" "));
|
||||
throw new IllegalArgumentException("Malformed arguments " + toString(filenames, " "));
|
||||
compiler = JavaCompiler.instance(context);
|
||||
compiler.keepComments = true;
|
||||
compiler.genEndPos = true;
|
||||
@ -177,6 +177,17 @@ public class JavacTaskImpl extends JavacTask {
|
||||
}
|
||||
}
|
||||
|
||||
<T> String toString(Iterable<T> items, String sep) {
|
||||
String currSep = "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (T item: items) {
|
||||
sb.append(currSep);
|
||||
sb.append(item.toString());
|
||||
currSep = sep;
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void initContext() {
|
||||
context.put(JavacTaskImpl.class, this);
|
||||
if (context.get(TaskListener.class) != null)
|
||||
|
||||
@ -31,7 +31,10 @@ import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Set;
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.annotation.processing.Processor;
|
||||
@ -107,8 +110,7 @@ public class Main {
|
||||
}
|
||||
|
||||
public void addFile(File f) {
|
||||
if (!filenames.contains(f))
|
||||
filenames.append(f);
|
||||
filenames.add(f);
|
||||
}
|
||||
|
||||
public void addClassName(String s) {
|
||||
@ -136,7 +138,7 @@ public class Main {
|
||||
|
||||
/** The list of source files to process
|
||||
*/
|
||||
public ListBuffer<File> filenames = null; // XXX sb protected
|
||||
public Set<File> filenames = null; // XXX sb protected
|
||||
|
||||
/** List of class files names passed on the command line
|
||||
*/
|
||||
@ -202,7 +204,7 @@ public class Main {
|
||||
* in `options' table and return all source filenames.
|
||||
* @param flags The array of command line arguments.
|
||||
*/
|
||||
public List<File> processArgs(String[] flags) { // XXX sb protected
|
||||
public Collection<File> processArgs(String[] flags) { // XXX sb protected
|
||||
int ac = 0;
|
||||
while (ac < flags.length) {
|
||||
String flag = flags[ac];
|
||||
@ -294,7 +296,7 @@ public class Main {
|
||||
showClass(showClass);
|
||||
}
|
||||
|
||||
return filenames.toList();
|
||||
return filenames;
|
||||
}
|
||||
// where
|
||||
private boolean checkDirectory(OptionName optName) {
|
||||
@ -342,7 +344,7 @@ public class Main {
|
||||
if (options == null)
|
||||
options = Options.instance(context); // creates a new one
|
||||
|
||||
filenames = new ListBuffer<File>();
|
||||
filenames = new LinkedHashSet<File>();
|
||||
classnames = new ListBuffer<String>();
|
||||
JavaCompiler comp = null;
|
||||
/*
|
||||
@ -356,7 +358,7 @@ public class Main {
|
||||
return EXIT_CMDERR;
|
||||
}
|
||||
|
||||
List<File> files;
|
||||
Collection<File> files;
|
||||
try {
|
||||
files = processArgs(CommandLine.parse(args));
|
||||
if (files == null) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -61,7 +61,7 @@ public class T6358166 extends AbstractProcessor {
|
||||
|
||||
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new ListBuffer<File>();
|
||||
compilerMain.filenames = new LinkedHashSet<File>();
|
||||
compilerMain.processArgs(args);
|
||||
|
||||
JavaCompiler c = JavaCompiler.instance(context);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -72,7 +72,7 @@ public class T6358168 extends AbstractProcessor {
|
||||
|
||||
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new ListBuffer<File>();
|
||||
compilerMain.filenames = new LinkedHashSet<File>();
|
||||
compilerMain.processArgs(new String[] { "-d", "." });
|
||||
|
||||
JavaCompiler compiler = JavaCompiler.instance(context);
|
||||
@ -91,7 +91,7 @@ public class T6358168 extends AbstractProcessor {
|
||||
|
||||
Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
|
||||
compilerMain.setOptions(Options.instance(context));
|
||||
compilerMain.filenames = new ListBuffer<File>();
|
||||
compilerMain.filenames = new LinkedHashSet<File>();
|
||||
compilerMain.processArgs(new String[] {
|
||||
"-XprintRounds",
|
||||
"-processorpath", testClasses,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user