From e0d71a6003a213f251f3b61b96de6ce96fc2ba4e Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Fri, 12 Apr 2024 14:17:15 +0200 Subject: [PATCH] fix console --- resources/bytecode/javFiles/Bug309.jav | 5 ++++- resources/bytecode/javFiles/BugXXX.jav | 16 ++++++++++++++++ .../de/dhbwstuttgart/core/JavaTXCompiler.java | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 resources/bytecode/javFiles/BugXXX.jav diff --git a/resources/bytecode/javFiles/Bug309.jav b/resources/bytecode/javFiles/Bug309.jav index d37fc7a1..23ae44ed 100644 --- a/resources/bytecode/javFiles/Bug309.jav +++ b/resources/bytecode/javFiles/Bug309.jav @@ -4,10 +4,13 @@ import java.lang.Integer; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.function.Function; +import java.util.function.Predicate; +import java.util.Optional; public class Bug309 { public main() { List list = new ArrayList<>(List.of(1,2,3,4,5,6,7,8,9)); - list.stream().map(x -> x * 2); + var res = list.stream().filter(x -> x == 5).map(x -> x * 2).findFirst(); + return res; } } diff --git a/resources/bytecode/javFiles/BugXXX.jav b/resources/bytecode/javFiles/BugXXX.jav new file mode 100644 index 00000000..c25acdf0 --- /dev/null +++ b/resources/bytecode/javFiles/BugXXX.jav @@ -0,0 +1,16 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.lang.String; +import java.util.stream.Stream; +import java.util.function.Function; +import java.util.function.Predicate; +import java.lang.Integer; + +class BugXXX { + public main() { + List i = new ArrayList<>(List.of(1,2,3,4,5,6,7,8,9,10)); + Optional tmp = i.stream().filter(x -> x == 5).map(x -> x*2).findFirst(); + return tmp; + } +} diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index d39dd50a..9993d98a 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -705,7 +705,8 @@ public class JavaTXCompiler { public void generateBytecode() throws ClassNotFoundException, IOException { for (var file : sourceFiles.keySet()) { - generateBytecode(file); + var classes = generateBytecode(file); + writeClassFile(classes, outputPath, outputPath == null); } }