Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2019-01-19 23:09:38 +0000
committerAndrey Loskutov2019-01-20 11:36:06 +0000
commitbb0844db627b315f082b4f79615a4ba00f583453 (patch)
tree86cbab1a8038d0d6295e9adbbd0853db982d73f2
parent9046e04f52630ef84dd29d3db30e339f0fe02d36 (diff)
downloadeclipse.jdt.core-bb0844db627b315f082b4f79615a4ba00f583453.tar.gz
eclipse.jdt.core-bb0844db627b315f082b4f79615a4ba00f583453.tar.xz
eclipse.jdt.core-bb0844db627b315f082b4f79615a4ba00f583453.zip
Bug 543506 - added tests for opened file leaks after build
- added tests for leaking open file descriptors for bug 543506 - added tycho profiles to run with different compliances on Gerrit - changed save actions to remove unused imports, casts and NLS comments on save Change-Id: Ib80ba1c71f925720541c59e8958726b0732299d9 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.jdt.core.tests.builder/.settings/org.eclipse.jdt.ui.prefs16
-rw-r--r--org.eclipse.jdt.core.tests.builder/pom.xml114
-rw-r--r--org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java210
-rw-r--r--org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java61
-rw-r--r--org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java49
-rw-r--r--org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsAfter9.java48
-rw-r--r--org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java48
-rw-r--r--org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java12
8 files changed, 505 insertions, 53 deletions
diff --git a/org.eclipse.jdt.core.tests.builder/.settings/org.eclipse.jdt.ui.prefs b/org.eclipse.jdt.core.tests.builder/.settings/org.eclipse.jdt.ui.prefs
index fe50d63691..ab1a682988 100644
--- a/org.eclipse.jdt.core.tests.builder/.settings/org.eclipse.jdt.ui.prefs
+++ b/org.eclipse.jdt.core.tests.builder/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,3 @@
-#Thu Nov 04 13:38:23 EDT 2010
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
sp_cleanup.add_default_serial_version_id=true
@@ -14,10 +13,12 @@ sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=false
sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.insert_inferred_type_arguments=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
@@ -33,12 +34,15 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
-sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_redundant_modifiers=false
+sp_cleanup.remove_redundant_semicolons=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
-sp_cleanup.remove_unnecessary_casts=false
-sp_cleanup.remove_unnecessary_nls_tags=false
-sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
@@ -47,8 +51,10 @@ sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.update_ibm_copyright_to_current_year=true
+sp_cleanup.use_anonymous_class_creation=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
diff --git a/org.eclipse.jdt.core.tests.builder/pom.xml b/org.eclipse.jdt.core.tests.builder/pom.xml
index 3f429fc2d8..a29d9bf91f 100644
--- a/org.eclipse.jdt.core.tests.builder/pom.xml
+++ b/org.eclipse.jdt.core.tests.builder/pom.xml
@@ -5,7 +5,7 @@
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/org/documents/edl-v10.php
-
+
Contributors:
Igor Fedorenko - initial implementation
-->
@@ -26,4 +26,116 @@
<testClass>org.eclipse.jdt.core.tests.builder.BuilderTests</testClass>
<testSuite>${project.artifactId}</testSuite>
</properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho.version}</version>
+ <configuration>
+ <includes>
+ <include>org/eclipse/jdt/core/tests/builder/BuilderTests.class</include>
+ </includes>
+ <argLine>${tycho.surefire.argLine}</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>test-on-javase-9</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <id>JavaSE-9</id>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <tycho.surefire.argLine>--add-modules ALL-SYSTEM</tycho.surefire.argLine>
+ </properties>
+ </profile>
+ <profile>
+ <id>test-on-javase-10</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <id>JavaSE-10</id>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <!-- Overridden in https://ci.eclipse.org/jdt/job/eclipse.jdt.core-run.javac-10/configure -->
+ <tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,10</tycho.surefire.argLine>
+ </properties>
+ </profile>
+ <profile>
+ <id>test-on-javase-11</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <id>JavaSE-11</id>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <!-- Overridden in https://ci.eclipse.org/jdt/job/eclipse.jdt.core-run.javac-11/configure -->
+ <tycho.surefire.argLine>--add-modules ALL-SYSTEM -Dcompliance=1.4,1.7,1.8,11</tycho.surefire.argLine>
+ </properties>
+ </profile>
+ </profiles>
+
</project>
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java
new file mode 100644
index 0000000000..f851fd1696
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/AbstractLeakTest.java
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Andrey Loskutov and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Andrey Loskutov - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.builder;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.tests.util.Util;
+
+/**
+ * Base class for testing builder related opened file leak tests, see bug 543506
+ */
+public abstract class AbstractLeakTest extends BuilderTests {
+
+ static boolean WINDOWS;
+ static boolean LINUX;
+ static boolean MAC;
+ static {
+ String os = System.getProperty("os.name").toLowerCase();
+ WINDOWS = os.contains("windows");
+ LINUX = os.contains("linux");
+ MAC = os.contains("mac");
+ }
+
+ public AbstractLeakTest(String name) {
+ super(name);
+ }
+
+ protected void testLeaksOnIncrementalBuild() throws Exception {
+ if(MAC) {
+ return;
+ }
+ internalTestUsedLibraryLeaks(IncrementalProjectBuilder.INCREMENTAL_BUILD);
+ }
+
+ protected void testLeaksOnCleanBuild() throws Exception {
+ if(MAC) {
+ return;
+ }
+ internalTestUsedLibraryLeaks(IncrementalProjectBuilder.CLEAN_BUILD);
+ }
+
+ protected void testLeaksOnFullBuild() throws Exception {
+ if(MAC) {
+ return;
+ }
+ internalTestUsedLibraryLeaks(IncrementalProjectBuilder.FULL_BUILD);
+ }
+
+ private void internalTestUsedLibraryLeaks(int kind) throws Exception {
+ String projectName = getName();
+ IPath projectPath = env.addProject(projectName, getCompatibilityLevel());
+ env.setOutputFolder(projectPath, "");
+ env.addExternalJars(projectPath, Util.getJavaClassLibs());
+ IPath internalJar = addInternalJar(projectPath);
+
+ createJavaFile(projectPath);
+
+ switch (kind) {
+ case IncrementalProjectBuilder.CLEAN_BUILD:
+ cleanBuild(projectName);
+ assertNotLeaked(internalJar);
+ break;
+ case IncrementalProjectBuilder.FULL_BUILD:
+ fullBuild(projectPath);
+ assertNotLeaked(internalJar);
+ break;
+ case IncrementalProjectBuilder.INCREMENTAL_BUILD:
+ incrementalBuild(projectPath);
+ changeJavaFile(projectPath);
+ incrementalBuild(projectPath);
+ assertNotLeaked(internalJar);
+ break;
+ default:
+ fail("Unexpected build kind: " + kind);
+ }
+ }
+
+ abstract String getCompatibilityLevel();
+
+ private IPath addInternalJar(IPath projectPath) throws IOException, JavaModelException {
+ IPath internalJar = addEmptyInternalJar(projectPath, "test.jar");
+ return internalJar;
+ }
+
+ private void createJavaFile(IPath projectPath) {
+ IPath path = env.addClass(projectPath, "a", "Other",
+ "package a;\n" +
+ "public class Other {\n" +
+ "}"
+ );
+ IFile file = env.getWorkspace().getRoot().getFile(path);
+ assertTrue("File should exists: " + path, file.exists());
+ }
+
+ private void changeJavaFile(IPath projectPath) throws Exception {
+ IPath path = env.addClass(projectPath, "a", "Other",
+ "package a;\n" +
+ "public class Other {\n" +
+ " // an extra comment \n" +
+ "}"
+ );
+ IFile file = env.getWorkspace().getRoot().getFile(path);
+ assertTrue("FIle should exists: " + path, file.exists());
+ }
+
+ private void assertNotLeaked(IPath path) throws Exception {
+ expectingNoProblems();
+ IFile file = env.getWorkspace().getRoot().getFile(path);
+ assertTrue("FIle should exists: " + path, file.exists());
+ if(WINDOWS) {
+ tryRemoveFile(file);
+ } else if (LINUX) {
+ checkOpenDescriptors(file);
+ }
+ }
+
+ private void tryRemoveFile(IFile file) {
+ // Note: this is a lame attempt to check for leaked file descriptor
+ // This works on Windows only, because windows does not allow to delete
+ // files opened for reading.
+ // On Linux we need something like lsof -p <my_process_id> | grep file name
+ try {
+ file.delete(true, null);
+ } catch (CoreException e) {
+ try {
+ // second attempt to avoid delays on teardown
+ Files.deleteIfExists(file.getLocation().toFile().toPath());
+ } catch (Exception e2) {
+ file.getLocation().toFile().delete();
+ // ignore
+ }
+ throw new IllegalStateException("File leaked during build: " + file, e);
+ }
+ assertFalse("File should be deleted: " + file, file.exists());
+ }
+
+ private void checkOpenDescriptors(IFile file) throws Exception {
+ List<String> openDescriptors = getOpenDescriptors();
+ assertFalse("Failed to read opened file descriptors", openDescriptors.isEmpty());
+ if(openDescriptors.contains(file.getLocation().toOSString())) {
+ throw new IllegalStateException("File leaked during build: " + file);
+ }
+ }
+
+ private static List<String> getOpenDescriptors() throws Exception {
+ int pid = getPid();
+ if (pid > 0) {
+ // -F n : to print only name column (note: all lines start with "n")
+ // -a : to "and" all following options
+ // -b :to avoid blocking calls
+ // -p <pid>: to select process with opened files
+ List<String> lines = readLsofLines("lsof -F n -a -p " + pid + " / -b ", true);
+ return lines;
+ }
+ return Collections.emptyList();
+ }
+
+ private static int getPid() throws Exception {
+ try (BufferedReader rdr = new BufferedReader(new FileReader("/proc/self/stat"));) {
+ return Integer.parseInt(new StringTokenizer(rdr.readLine()).nextToken());
+ }
+ }
+
+ private static List<String> readLsofLines(String cmd, boolean skipFirst) throws Exception {
+ List<String> lines = new ArrayList<>();
+ Process process = Runtime.getRuntime().exec(cmd);
+ try (BufferedReader rdr = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
+ if (skipFirst) {
+ rdr.readLine();
+ }
+ String line;
+ while((line = rdr.readLine())!= null) {
+ // remove "n" prefix from lsof output
+ if(line.startsWith("n")) {
+ line = line.substring(1);
+ }
+ if(line.trim().length() > 1) {
+ lines.add(line);
+ }
+ }
+ }
+ lines.sort(null);
+ return lines;
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java
index e2451de87e..0c45e7ed5a 100644
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java
+++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java
@@ -13,23 +13,31 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
+import static org.eclipse.jdt.core.tests.util.AbstractCompilerTest.*;
+
+import java.io.FileInputStream;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
import java.util.Vector;
-import junit.framework.*;
-
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.tests.junit.extension.TestCase;
-import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.TestVerifier;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.core.compiler.CharOperation;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
/**
* Base class for Java image builder tests
@@ -50,7 +58,7 @@ public class BuilderTests extends TestCase {
env.cleanBuild();
this.debugRequestor.deactivate();
}
-
+
protected void cleanBuild(String name) {
this.debugRequestor.clearResult();
this.debugRequestor.activate();
@@ -536,18 +544,25 @@ public class BuilderTests extends TestCase {
TestAttributeBuilderTests.class,
Bug530366Test.class,
Bug531382Test.class,
- ParallelBuildTests.class
+ ParallelBuildTests.class,
+ LeakTestsBefore9.class,
};
-
- if ((AbstractCompilerTest.getPossibleComplianceLevels() & AbstractCompilerTest.F_1_5) != 0) {
- int length = classes.length;
- System.arraycopy(classes, 0, classes = new Class[length+4], 0, length);
- classes[length++] = Java50Tests.class;
- classes[length++] = PackageInfoTest.class;
- classes[length++] = ParticipantBuildTests.class;
- classes[length++] = AnnotationDependencyTests.class;
+ List<Class<?>> list = new ArrayList<>(Arrays.asList(classes));
+ if (matchesCompliance(F_1_5)) {
+ list.add(Java50Tests.class);
+ list.add(PackageInfoTest.class);
+ list.add(ParticipantBuildTests.class);
+ list.add(AnnotationDependencyTests.class);
}
- return classes;
+ if (matchesCompliance(F_9)) {
+ list.add(LeakTestsAfter9.class);
+ }
+ return list.toArray(new Class[0]);
+ }
+
+ static boolean matchesCompliance(int level) {
+ int complianceLevels = getPossibleComplianceLevels();
+ return complianceLevels >= level;
}
public static Test buildTestSuite(Class evaluationTestClass, long ordering) {
@@ -602,4 +617,18 @@ public class BuilderTests extends TestCase {
return suite;
}
+
+ static IPath addEmptyInternalJar(IPath projectPath, String jarName) throws IOException, JavaModelException {
+ IProject project = env.getProject(projectPath);
+ String jarFile = project.getLocation().append(jarName).toOSString();
+ Util.createEmptyJar(jarFile, JavaCore.VERSION_1_4);
+ IPath jarPath = null;
+ try (FileInputStream fis = new FileInputStream(jarFile)) {
+ int length = fis.available();
+ byte[] jarContent = new byte[length];
+ fis.read(jarContent);
+ jarPath = env.addInternalJar(projectPath, jarName, jarContent);
+ }
+ return jarPath;
+ }
}
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java
index 642f785b51..3f2e5dd2f2 100644
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java
+++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuildpathTests.java
@@ -13,25 +13,35 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.builder;
-import junit.framework.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.tests.util.AbstractCompilerTest;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.eclipse.jdt.internal.core.*;
+import org.eclipse.jdt.internal.core.JavaModel;
+import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.JavaProject;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.*;
+import junit.framework.Test;
@SuppressWarnings({"unchecked", "rawtypes"})
public class BuildpathTests extends BuilderTests {
@@ -115,27 +125,8 @@ public void testClasspathFileChange() throws JavaModelException {
public void testClosedProject() throws JavaModelException, IOException {
IPath project1Path = env.addProject("CP1"); //$NON-NLS-1$
- IProject project1 = ResourcesPlugin.getWorkspace().getRoot().getProject("CP1");
env.addExternalJars(project1Path, Util.getJavaClassLibs());
-
- String jarFile = project1.getLocation().toOSString() + File.separator + "temp.jar";
-
- org.eclipse.jdt.core.tests.util.Util.createEmptyJar(
- jarFile,
- JavaCore.VERSION_1_4);
-
- IPath jarPath = null;
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(jarFile);
- int length = fis.available();
- byte[] jarContent = new byte[length];
- fis.read(jarContent);
- jarPath = env.addInternalJar(project1Path, "temp.jar", jarContent); //$NON-NLS-1$
- }
- finally {
- if (fis != null) fis.close();
- }
+ IPath jarPath = addEmptyInternalJar(project1Path, "temp.jar");
IPath project2Path = env.addProject("CP2"); //$NON-NLS-1$
env.addExternalJars(project2Path, Util.getJavaClassLibs());
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsAfter9.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsAfter9.java
new file mode 100644
index 0000000000..826becf9bd
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsAfter9.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Andrey Loskutov and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Andrey Loskutov - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.builder;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+import junit.framework.Test;
+
+public class LeakTestsAfter9 extends AbstractLeakTest {
+
+ public LeakTestsAfter9(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return buildTestSuite(LeakTestsAfter9.class);
+ }
+
+ String getCompatibilityLevel() {
+ return CompilerOptions.VERSION_9;
+ }
+
+ @Override
+ public void testLeaksOnCleanBuild() throws Exception {
+ super.testLeaksOnCleanBuild();
+ }
+
+ @Override
+ public void testLeaksOnFullBuild() throws Exception {
+ super.testLeaksOnFullBuild();
+ }
+
+ @Override
+ public void testLeaksOnIncrementalBuild() throws Exception {
+ super.testLeaksOnIncrementalBuild();
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java
new file mode 100644
index 0000000000..b275096b5b
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/LeakTestsBefore9.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Andrey Loskutov and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Andrey Loskutov - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.builder;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+import junit.framework.Test;
+
+public class LeakTestsBefore9 extends AbstractLeakTest {
+
+ public LeakTestsBefore9(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return buildTestSuite(LeakTestsBefore9.class);
+ }
+
+ String getCompatibilityLevel() {
+ return CompilerOptions.VERSION_1_4;
+ }
+
+ @Override
+ public void testLeaksOnCleanBuild() throws Exception {
+ super.testLeaksOnCleanBuild();
+ }
+
+ @Override
+ public void testLeaksOnFullBuild() throws Exception {
+ super.testLeaksOnFullBuild();
+ }
+
+ @Override
+ public void testLeaksOnIncrementalBuild() throws Exception {
+ super.testLeaksOnIncrementalBuild();
+ }
+}
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java
index 97ec40e04b..49cdf411bb 100644
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java
+++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java
@@ -138,7 +138,7 @@ public void addClassFolder(IPath projectPath, IPath classFolderPath, boolean isE
}
public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName) throws JavaModelException {
- return addPackageFragmentRoot(projectPath, sourceFolderName, null, null); //$NON-NLS-1$
+ return addPackageFragmentRoot(projectPath, sourceFolderName, null, null);
}
public IPath addTestPackageFragmentRoot(IPath projectPath, String sourceFolderName) throws JavaModelException {
@@ -214,6 +214,14 @@ public void addClassFolder(IPath projectPath, IPath classFolderPath, boolean isE
requiredComplianceFlag = AbstractCompilerTest.F_9;
compilerVersion = CompilerOptions.VERSION_9;
}
+ else if ("10".equals(compliance)) {
+ requiredComplianceFlag = AbstractCompilerTest.F_10;
+ compilerVersion = CompilerOptions.VERSION_10;
+ }
+ else if ("11".equals(compliance)) {
+ requiredComplianceFlag = AbstractCompilerTest.F_11;
+ compilerVersion = CompilerOptions.VERSION_11;
+ }
else if (!"1.4".equals(compliance) && !"1.3".equals(compliance)) {
throw new UnsupportedOperationException("Test framework doesn't support compliance level: " + compliance);
}
@@ -501,7 +509,7 @@ public void cleanBuild(String projectName) {
}
return project;
}
-
+
/**
* Safely delete the given resource.
*/

Back to the top