File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
compiler/tests/org/jetbrains/kotlin/codegen Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 47
47
import java .lang .reflect .Modifier ;
48
48
49
49
public class StdlibTest extends KotlinTestWithEnvironment {
50
+ private GeneratedClassLoader classLoader ;
51
+
50
52
@ Override
51
53
protected KotlinCoreEnvironment createEnvironment () {
52
54
CompilerConfiguration configuration = KotlinTestUtils .compilerConfigurationForTests (ConfigurationKind .ALL , TestJdkKind .FULL_JDK );
@@ -68,9 +70,7 @@ public void testStdlib() throws ClassNotFoundException {
68
70
fail ("There were compilation errors" );
69
71
}
70
72
71
- GeneratedClassLoader classLoader = new GeneratedClassLoader (
72
- state .getFactory (), ForTestCompileRuntime .runtimeAndReflectJarClassLoader ()
73
- ) {
73
+ classLoader = new GeneratedClassLoader (state .getFactory (), ForTestCompileRuntime .runtimeAndReflectJarClassLoader ()) {
74
74
@ Override
75
75
public Class <?> loadClass (@ NotNull String name ) throws ClassNotFoundException {
76
76
if (name .startsWith ("junit." ) || name .startsWith ("org.junit." )) {
@@ -107,6 +107,14 @@ public Class<?> loadClass(@NotNull String name) throws ClassNotFoundException {
107
107
}
108
108
}
109
109
110
+ @ Override
111
+ protected void tearDown () throws Exception {
112
+ super .tearDown ();
113
+
114
+ // This is important to prevent a memory leak (ClassFileFactory transitively retains all code generation results)
115
+ classLoader .dispose ();
116
+ }
117
+
110
118
@ Nullable
111
119
private static Test createTest (@ NotNull ClassLoader classLoader , @ NotNull String className ) {
112
120
try {
You can’t perform that action at this time.
0 commit comments