Dispose GeneratedClassLoader
This commit is contained in:
+14
-10
@@ -246,22 +246,26 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GeneratedClassLoader classLoader = null;
|
||||||
try {
|
try {
|
||||||
ClassFileFactory factory = generationState.getFactory();
|
ClassFileFactory factory = generationState.getFactory();
|
||||||
try {
|
classLoader = new GeneratedClassLoader(factory,
|
||||||
GeneratedClassLoader classLoader = new GeneratedClassLoader(factory, new URLClassLoader(new URL[]{
|
new URLClassLoader(new URL[] {
|
||||||
// TODO: add all classpath
|
// TODO: add all classpath
|
||||||
paths.getRuntimePath().toURI().toURL()
|
paths.getRuntimePath().toURI().toURL()
|
||||||
},
|
},
|
||||||
parentLoader == null ? AllModules.class.getClassLoader() : parentLoader));
|
parentLoader == null ? AllModules.class.getClassLoader() : parentLoader));
|
||||||
JetFile scriptFile = environment.getSourceFiles().get(0);
|
|
||||||
return classLoader.loadClass(ScriptNameUtil.classNameForScript(scriptFile));
|
JetFile scriptFile = environment.getSourceFiles().get(0);
|
||||||
}
|
return classLoader.loadClass(ScriptNameUtil.classNameForScript(scriptFile));
|
||||||
catch (Exception e) {
|
}
|
||||||
throw new RuntimeException("Failed to evaluate script: " + e, e);
|
catch (Exception e) {
|
||||||
}
|
throw new RuntimeException("Failed to evaluate script: " + e, e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
if (classLoader != null) {
|
||||||
|
classLoader.dispose();
|
||||||
|
}
|
||||||
generationState.destroy();
|
generationState.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ public class ClassGenTest extends CodegenTestCase {
|
|||||||
|
|
||||||
public void testAbstractClass() throws Exception {
|
public void testAbstractClass() throws Exception {
|
||||||
loadText("abstract class SimpleClass() { }");
|
loadText("abstract class SimpleClass() { }");
|
||||||
final Class aClass = createClassLoader(generateClassesInFile()).loadClass("SimpleClass");
|
final Class aClass = generateClass("SimpleClass");
|
||||||
assertTrue((aClass.getModifiers() & Modifier.ABSTRACT) != 0);
|
assertTrue((aClass.getModifiers() & Modifier.ABSTRACT) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ public class ClassGenTest extends CodegenTestCase {
|
|||||||
|
|
||||||
public void testEnumClass() throws Exception {
|
public void testEnumClass() throws Exception {
|
||||||
loadText("enum class Direction { NORTH; SOUTH; EAST; WEST }");
|
loadText("enum class Direction { NORTH; SOUTH; EAST; WEST }");
|
||||||
final Class direction = createClassLoader(generateClassesInFile()).loadClass("Direction");
|
final Class direction = generateClass("Direction");
|
||||||
final Field north = direction.getField("NORTH");
|
final Field north = direction.getField("NORTH");
|
||||||
assertEquals(direction, north.getType());
|
assertEquals(direction, north.getType());
|
||||||
assertInstanceOf(north.get(null), direction);
|
assertInstanceOf(north.get(null), direction);
|
||||||
@@ -248,7 +248,7 @@ public class ClassGenTest extends CodegenTestCase {
|
|||||||
|
|
||||||
public void testEnumConstantConstructors() throws Exception {
|
public void testEnumConstantConstructors() throws Exception {
|
||||||
loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000); GREEN: Color(0x00FF00); }");
|
loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000); GREEN: Color(0x00FF00); }");
|
||||||
final Class colorClass = createClassLoader(generateClassesInFile()).loadClass("Color");
|
final Class colorClass = generateClass("Color");
|
||||||
final Field redField = colorClass.getField("RED");
|
final Field redField = colorClass.getField("RED");
|
||||||
final Object redValue = redField.get(null);
|
final Object redValue = redField.get(null);
|
||||||
final Method rgbMethod = colorClass.getMethod("getRgb");
|
final Method rgbMethod = colorClass.getMethod("getRgb");
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ import org.jetbrains.jet.codegen.state.Progress;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.*;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
@@ -64,6 +61,7 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
|||||||
|
|
||||||
protected Object scriptInstance;
|
protected Object scriptInstance;
|
||||||
private GenerationState alreadyGenerated;
|
private GenerationState alreadyGenerated;
|
||||||
|
private GeneratedClassLoader initializedClassLoader;
|
||||||
|
|
||||||
protected void createEnvironmentWithMockJdkAndIdeaAnnotations() {
|
protected void createEnvironmentWithMockJdkAndIdeaAnnotations() {
|
||||||
if (myEnvironment != null) {
|
if (myEnvironment != null) {
|
||||||
@@ -108,6 +106,12 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
|||||||
myEnvironment = null;
|
myEnvironment = null;
|
||||||
scriptInstance = null;
|
scriptInstance = null;
|
||||||
alreadyGenerated = null;
|
alreadyGenerated = null;
|
||||||
|
|
||||||
|
if (initializedClassLoader != null) {
|
||||||
|
initializedClassLoader.dispose();
|
||||||
|
initializedClassLoader = null;
|
||||||
|
}
|
||||||
|
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,8 +283,6 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
System.out.println(generateToText());
|
System.out.println(generateToText());
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} finally {
|
|
||||||
loader.dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,6 +319,10 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected GeneratedClassLoader createClassLoader(ClassFileFactory codegens, boolean classPathInTheSameClassLoader) {
|
protected GeneratedClassLoader createClassLoader(ClassFileFactory codegens, boolean classPathInTheSameClassLoader) {
|
||||||
|
if (initializedClassLoader != null) {
|
||||||
|
fail("Double initialization of class loader in same test");
|
||||||
|
}
|
||||||
|
|
||||||
List<URL> urls = Lists.newArrayList();
|
List<URL> urls = Lists.newArrayList();
|
||||||
for (File file : myEnvironment.getConfiguration().getList(JVMConfigurationKeys.CLASSPATH_KEY)) {
|
for (File file : myEnvironment.getConfiguration().getList(JVMConfigurationKeys.CLASSPATH_KEY)) {
|
||||||
try {
|
try {
|
||||||
@@ -326,15 +332,17 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final URL[] urlsArray = urls.toArray(new URL[0]);
|
final URL[] urlsArray = urls.toArray(new URL[urls.size()]);
|
||||||
|
|
||||||
if (!classPathInTheSameClassLoader) {
|
if (!classPathInTheSameClassLoader) {
|
||||||
ClassLoader parentClassLoader = new URLClassLoader(urlsArray, CodegenTestCase.class.getClassLoader());
|
ClassLoader parentClassLoader = new URLClassLoader(urlsArray, CodegenTestCase.class.getClassLoader());
|
||||||
return new GeneratedClassLoader(codegens, parentClassLoader);
|
initializedClassLoader = new GeneratedClassLoader(codegens, parentClassLoader);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return new GeneratedClassLoader(codegens, CodegenTestCase.class.getClassLoader(), urlsArray);
|
initializedClassLoader = new GeneratedClassLoader(codegens, CodegenTestCase.class.getClassLoader(), urlsArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return initializedClassLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String generateToText() {
|
protected String generateToText() {
|
||||||
@@ -370,7 +378,6 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
|||||||
|
|
||||||
protected Class generateNamespaceClass() {
|
protected Class generateNamespaceClass() {
|
||||||
ClassFileFactory state = generateClassesInFile();
|
ClassFileFactory state = generateClassesInFile();
|
||||||
|
|
||||||
return loadRootNamespaceClass(state);
|
return loadRootNamespaceClass(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,5 +484,4 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
|||||||
protected Class loadImplementationClass(@NotNull ClassFileFactory codegens, final String name) {
|
protected Class loadImplementationClass(@NotNull ClassFileFactory codegens, final String name) {
|
||||||
return loadClass(name, codegens);
|
return loadClass(name, codegens);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class EnumGenTest extends CodegenTestCase {
|
|||||||
|
|
||||||
public void testEnumConstantConstructors() throws Exception {
|
public void testEnumConstantConstructors() throws Exception {
|
||||||
loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000); GREEN: Color(0x00FF00); }");
|
loadText("enum class Color(val rgb: Int) { RED: Color(0xFF0000); GREEN: Color(0x00FF00); }");
|
||||||
final Class colorClass = createClassLoader(generateClassesInFile()).loadClass("Color");
|
final Class colorClass = generateClass("Color");
|
||||||
final Field redField = colorClass.getField("RED");
|
final Field redField = colorClass.getField("RED");
|
||||||
final Object redValue = redField.get(null);
|
final Object redValue = redField.get(null);
|
||||||
final Method rgbMethod = colorClass.getMethod("getRgb");
|
final Method rgbMethod = colorClass.getMethod("getRgb");
|
||||||
|
|||||||
@@ -145,25 +145,13 @@ public class StdlibTest extends CodegenTestCase {
|
|||||||
|
|
||||||
public void testKt1592 () throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
public void testKt1592 () throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||||
loadFile("regressions/kt1592.kt");
|
loadFile("regressions/kt1592.kt");
|
||||||
ClassFileFactory codegens = generateClassesInFile();
|
String fqName = NamespaceCodegen.getJVMClassNameForKotlinNs(JetPsiUtil.getFQName(myFiles.getPsiFile())).getFqName().getFqName();
|
||||||
GeneratedClassLoader loader = createClassLoader(codegens);
|
Class<?> namespaceClass = generateClass(fqName);
|
||||||
|
Method method = namespaceClass.getMethod("box", Method.class);
|
||||||
try {
|
method.setAccessible(true);
|
||||||
String fqName = NamespaceCodegen.getJVMClassNameForKotlinNs(JetPsiUtil.getFQName(myFiles.getPsiFile())).getFqName().getFqName();
|
Test annotation = method.getAnnotation(Test.class);
|
||||||
Class<?> namespaceClass = loader.loadClass(fqName);
|
assertEquals(annotation.timeout(), 0l);
|
||||||
Method method = namespaceClass.getMethod("box", Method.class);
|
assertEquals(annotation.expected(), Test.None.class);
|
||||||
method.setAccessible(true);
|
|
||||||
Test annotation = method.getAnnotation(Test.class);
|
|
||||||
assertEquals(annotation.timeout(), 0l);
|
|
||||||
assertEquals(annotation.expected(), Test.None.class);
|
|
||||||
}
|
|
||||||
catch (Throwable t) {
|
|
||||||
System.out.println(generateToText());
|
|
||||||
throw new RuntimeException(t);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
loader.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAnnotationClassWithClassProperty()
|
public void testAnnotationClassWithClassProperty()
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen;
|
package org.jetbrains.jet.codegen;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.UsefulTestCase;
|
||||||
import gnu.trove.THashSet;
|
import gnu.trove.THashSet;
|
||||||
|
import junit.extensions.TestSetup;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
@@ -42,7 +44,6 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
|||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@@ -51,107 +52,39 @@ import java.net.URL;
|
|||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class TestlibTest extends CodegenTestCase {
|
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
||||||
|
public class TestlibTest extends UsefulTestCase {
|
||||||
private File junitJar;
|
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new TestlibTest().buildSuite();
|
return new TestlibTest().buildTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TestSuite buildSuite() {
|
private TestSuite suite;
|
||||||
try {
|
private File junitJar;
|
||||||
setUp();
|
private GeneratedClassLoader classLoader;
|
||||||
return doBuildSuite();
|
private JetTypeMapper typeMapper;
|
||||||
} catch (Exception e) {
|
private GenerationState generationState;
|
||||||
throw ExceptionUtils.rethrow(e);
|
private JetCoreEnvironment myEnvironment;
|
||||||
}
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
tearDown();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw ExceptionUtils.rethrow(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestSuite doBuildSuite() {
|
private Test buildTestSuite() {
|
||||||
try {
|
suite = new TestSuite("stdlib_test");
|
||||||
GenerationState generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(myEnvironment, false);
|
|
||||||
|
|
||||||
if (generationState == null) {
|
return new TestSetup(suite) {
|
||||||
throw new RuntimeException("There were compilation errors");
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
TestlibTest.this.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassFileFactory classFileFactory = generationState.getFactory();
|
@Override
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
final GeneratedClassLoader loader = new GeneratedClassLoader(
|
TestlibTest.this.tearDown();
|
||||||
classFileFactory,
|
|
||||||
new URLClassLoader(new URL[]{ForTestCompileRuntime.runtimeJarForTests().toURI().toURL(), junitJar.toURI().toURL()},
|
|
||||||
TestCase.class.getClassLoader()));
|
|
||||||
|
|
||||||
JetTypeMapper typeMapper = generationState.getTypeMapper();
|
|
||||||
TestSuite suite = new TestSuite("stdlib_test");
|
|
||||||
try {
|
|
||||||
for(JetFile jetFile : myEnvironment.getSourceFiles()) {
|
|
||||||
for(JetDeclaration decl : jetFile.getDeclarations()) {
|
|
||||||
if (decl instanceof JetClass) {
|
|
||||||
JetClass jetClass = (JetClass) decl;
|
|
||||||
|
|
||||||
ClassDescriptor descriptor = (ClassDescriptor) generationState.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetClass);
|
|
||||||
Set<JetType> allSuperTypes = new THashSet<JetType>();
|
|
||||||
DescriptorUtils.addSuperTypes(descriptor.getDefaultType(), allSuperTypes);
|
|
||||||
|
|
||||||
for(JetType type : allSuperTypes) {
|
|
||||||
String internalName = typeMapper.mapType(type, JetTypeMapperMode.IMPL).getInternalName();
|
|
||||||
if(internalName.equals("junit/framework/Test")) {
|
|
||||||
String name = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
|
||||||
System.out.println(name);
|
|
||||||
Class<TestCase> aClass = (Class<TestCase>) loader.loadClass(name.replace('/', '.'));
|
|
||||||
if ((aClass.getModifiers() & Modifier.ABSTRACT) == 0
|
|
||||||
&& (aClass.getModifiers() & Modifier.PUBLIC) != 0) {
|
|
||||||
try {
|
|
||||||
Constructor<TestCase> constructor = aClass.getConstructor();
|
|
||||||
if (constructor != null && (constructor.getModifiers() & Modifier.PUBLIC) != 0) {
|
|
||||||
suite.addTestSuite(aClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//catch (final VerifyError e) {
|
|
||||||
// suite.addTest(new TestCase(aClass.getName()) {
|
|
||||||
// @Override
|
|
||||||
// public int countTestCases() {
|
|
||||||
// return 1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void run(TestResult result) {
|
|
||||||
// result.addError(this, new RuntimeException(e));
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//}
|
|
||||||
catch (NoSuchMethodException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
};
|
||||||
typeMapper = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return suite;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw ExceptionUtils.rethrow(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
CompilerConfiguration configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL,
|
CompilerConfiguration configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL,
|
||||||
TestJdkKind.FULL_JDK);
|
TestJdkKind.FULL_JDK);
|
||||||
configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, JetTestUtils.getAnnotationsJar());
|
configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, JetTestUtils.getAnnotationsJar());
|
||||||
@@ -165,5 +98,77 @@ public class TestlibTest extends CodegenTestCase {
|
|||||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
|
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollectorPlainTextToStream.PLAIN_TEXT_TO_SYSTEM_ERR);
|
||||||
|
|
||||||
myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), configuration);
|
myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), configuration);
|
||||||
|
|
||||||
|
generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(myEnvironment, false);
|
||||||
|
if (generationState == null) {
|
||||||
|
throw new RuntimeException("There were compilation errors");
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassFileFactory classFileFactory = generationState.getFactory();
|
||||||
|
|
||||||
|
classLoader = new GeneratedClassLoader(classFileFactory,
|
||||||
|
new URLClassLoader(new URL[] {ForTestCompileRuntime.runtimeJarForTests().toURI().toURL(), junitJar.toURI().toURL()},
|
||||||
|
TestCase.class.getClassLoader()));
|
||||||
|
|
||||||
|
typeMapper = generationState.getTypeMapper();
|
||||||
|
|
||||||
|
for (JetFile jetFile : myEnvironment.getSourceFiles()) {
|
||||||
|
for (JetDeclaration decl : jetFile.getDeclarations()) {
|
||||||
|
if (decl instanceof JetClass) {
|
||||||
|
JetClass jetClass = (JetClass) decl;
|
||||||
|
|
||||||
|
ClassDescriptor descriptor = (ClassDescriptor) generationState.getBindingContext().get(
|
||||||
|
BindingContext.DECLARATION_TO_DESCRIPTOR, jetClass);
|
||||||
|
|
||||||
|
assertNotNull("Descriptor for declaration " + jetClass + " shouldn't be null", descriptor);
|
||||||
|
|
||||||
|
Set<JetType> allSuperTypes = new THashSet<JetType>();
|
||||||
|
DescriptorUtils.addSuperTypes(descriptor.getDefaultType(), allSuperTypes);
|
||||||
|
|
||||||
|
for (JetType type : allSuperTypes) {
|
||||||
|
String internalName = typeMapper.mapType(type, JetTypeMapperMode.IMPL).getInternalName();
|
||||||
|
if (internalName.equals("junit/framework/Test")) {
|
||||||
|
String name = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
||||||
|
|
||||||
|
//noinspection UseOfSystemOutOrSystemErr
|
||||||
|
System.out.println(name);
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<TestCase> aClass = (Class<TestCase>) classLoader.loadClass(name.replace('/', '.'));
|
||||||
|
|
||||||
|
if ((aClass.getModifiers() & Modifier.ABSTRACT) == 0 && (aClass.getModifiers() & Modifier.PUBLIC) != 0) {
|
||||||
|
try {
|
||||||
|
Constructor<TestCase> constructor = aClass.getConstructor();
|
||||||
|
if ((constructor.getModifiers() & Modifier.PUBLIC) != 0) {
|
||||||
|
suite.addTestSuite(aClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NoSuchMethodException e) {
|
||||||
|
// Ignore test classes we can't instantiate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
typeMapper = null;
|
||||||
|
|
||||||
|
classLoader.dispose();
|
||||||
|
classLoader = null;
|
||||||
|
|
||||||
|
generationState = null;
|
||||||
|
|
||||||
|
myEnvironment = null;
|
||||||
|
|
||||||
|
junitJar = null;
|
||||||
|
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user