From b04201de423c3a03a0123d7e96fcd30c250f83e5 Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Tue, 4 Jul 2023 11:40:23 +0200 Subject: [PATCH] Don't load classes that get compiled by a source file --- .../de/dhbwstuttgart/core/JavaTXCompiler.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index 04537c2c..958d7cea 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -548,16 +548,13 @@ public class JavaTXCompiler { SourceFile sf = sourceFiles.get(f); allClasses.addAll(getAvailableClasses(sf)); allClasses.addAll(sf.getClasses()); - var newClasses = CompilationEnvironment.loadDefaultPackageClasses(f,classLoader).stream().map(ASTFactory::createClass).collect(Collectors.toList()); + var newClasses = CompilationEnvironment.loadDefaultPackageClasses(f,classLoader).stream().map(ASTFactory::createClass).toList(); for (var clazz : newClasses) { - var found = false; - for (var old : allClasses) { - if (clazz.getClassName().equals(old.getClassName())) { - found = true; - break; - } - } - if (!found) allClasses.add(clazz); + // Don't load classes that get recompiled + if (sf.getClasses().stream().anyMatch(nf -> nf.getClassName().equals(clazz.getClassName()))) + continue; + if (allClasses.stream().noneMatch(old -> old.getClassName().equals(clazz.getClassName()))) + allClasses.add(clazz); } }