aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2012-07-19 14:28:30 (EDT)
committerJayaprakash Arthanareeswaran2012-08-10 02:57:19 (EDT)
commit46987bf94fa2fc88d9ab6cb36a5870450e66f8d9 (patch)
tree275d38b7fda469f0887ca24fc7754d006729d24d
parentb38eab4446e313b29ad4b2826620fef1620b6d6e (diff)
downloadeclipse.jdt.core-46987bf94fa2fc88d9ab6cb36a5870450e66f8d9.zip
eclipse.jdt.core-46987bf94fa2fc88d9ab6cb36a5870450e66f8d9.tar.gz
eclipse.jdt.core-46987bf94fa2fc88d9ab6cb36a5870450e66f8d9.tar.bz2
JDTCoreTests spend 1/3 of the time in ...batch.ClasspathJar#isPackage
-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 544885a..4f4f8e5 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
@@ -18,8 +18,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;
@@ -994,11 +994,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
@@ -1021,7 +1023,7 @@ protected static class JavacTestOptions {
}
protected String[] getDefaultClassPaths() {
- return Util.concatWithClassLibs(OUTPUT_DIR, false);
+ return DefaultJavaRuntimeEnvironment.getDefaultClassPaths();
}
protected IErrorHandlingPolicy getErrorHandlingPolicy() {
return new IErrorHandlingPolicy() {
@@ -1038,7 +1040,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;
/*