aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2012-07-19 14:28:30 (EDT)
committerTomasz Zarna2012-07-19 14:28:30 (EDT)
commit50277bed1b7d3674704379315eda186ae8d5bd1b (patch)
tree7db9c1a1dedeac7fe71a00b685e2536f4edca6ab
parentae52a28648d52b5eafe0fdcc634d32123f7b745b (diff)
downloadeclipse.jdt.core-50277bed1b7d3674704379315eda186ae8d5bd1b.zip
eclipse.jdt.core-50277bed1b7d3674704379315eda186ae8d5bd1b.tar.gz
eclipse.jdt.core-50277bed1b7d3674704379315eda186ae8d5bd1b.tar.bz2
JDTCoreTests spend 1/3 of the time in ...batch.ClasspathJar#isPackagerefs/changes/48/6848/3
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java12
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultJavaRuntimeEnvironment.java46
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java4
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java4
4 files changed, 56 insertions, 10 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index 8241a53..c88eb4c 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -14,8 +14,8 @@ package org.eclipse.jdt.core.tests.compiler.regression;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
@@ -985,11 +985,13 @@ protected static class JavacTestOptions {
return null;
}
- protected INameEnvironment[] getClassLibs() {
+ protected INameEnvironment[] getClassLibs(boolean useDefaultClasspaths) {
String encoding = (String)getCompilerOptions().get(CompilerOptions.OPTION_Encoding);
if ("".equals(encoding))
encoding = null;
-
+ if (useDefaultClasspaths && encoding == null)
+ return DefaultJavaRuntimeEnvironment.create(this.classpaths);
+ // fall back to FileSystem
INameEnvironment[] classLibs = new INameEnvironment[1];
classLibs[0] = new FileSystem(this.classpaths, new String[]{}, // ignore initial file names
encoding // default encoding
@@ -1012,7 +1014,7 @@ protected static class JavacTestOptions {
}
protected String[] getDefaultClassPaths() {
- return Util.concatWithClassLibs(OUTPUT_DIR, false);
+ return DefaultJavaRuntimeEnvironment.getDefaultClassPaths();
}
protected IErrorHandlingPolicy getErrorHandlingPolicy() {
return new IErrorHandlingPolicy() {
@@ -1029,7 +1031,7 @@ protected static class JavacTestOptions {
*/
protected INameEnvironment getNameEnvironment(final String[] testFiles, String[] classPaths) {
this.classpaths = classPaths == null ? getDefaultClassPaths() : classPaths;
- return new InMemoryNameEnvironment(testFiles, getClassLibs());
+ return new InMemoryNameEnvironment(testFiles, getClassLibs(classPaths == null));
}
protected IProblemFactory getProblemFactory() {
return new DefaultProblemFactory(Locale.getDefault());
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultJavaRuntimeEnvironment.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultJavaRuntimeEnvironment.java
new file mode 100644
index 0000000..7d89a84
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DefaultJavaRuntimeEnvironment.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.internal.compiler.batch.FileSystem;
+import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+
+public class DefaultJavaRuntimeEnvironment extends FileSystem {
+
+ private DefaultJavaRuntimeEnvironment(String[] jreClasspaths) {
+ super(jreClasspaths, new String[] {} /* ignore initial file names */, null);
+ }
+
+ private static INameEnvironment[] defaultJreClassLibs;
+
+ public static INameEnvironment[] create(String[] jreClasspaths) {
+ if (defaultJreClassLibs == null) {
+ defaultJreClassLibs = new INameEnvironment[1];
+ defaultJreClassLibs[0] = new DefaultJavaRuntimeEnvironment(jreClasspaths);
+ }
+ return defaultJreClassLibs;
+ }
+
+ public void cleanup() {
+ // reset output folder only, which is the last entry on the classpath list
+ // see #getDefaultClassPaths()
+ this.classpaths[this.classpaths.length - 1].reset();
+ }
+
+ private static String[] javaLibsAndOutputDir;
+
+ static String[] getDefaultClassPaths() {
+ if (javaLibsAndOutputDir == null)
+ javaLibsAndOutputDir = Util.concatWithClassLibs(AbstractRegressionTest.OUTPUT_DIR, false);
+ return javaLibsAndOutputDir;
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java
index 70415af..52d132f 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -718,8 +718,6 @@ public static int getFreePort() {
/**
* Search the user hard-drive for a Java class library.
* Returns null if none could be found.
- *
- * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJavaClassLib()]
*/
public static String[] getJavaClassLibs() {
// check bootclasspath properties for Sun, JRockit and Harmony VMs
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
index 0b0086f..af1b7e9 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -100,7 +100,7 @@ public class FileSystem implements INameEnvironment, SuffixConstants {
}
}
- Classpath[] classpaths;
+ protected Classpath[] classpaths;
Set knownFileNames;
/*