From e59accf7ee2636fd63900692c0d9ad7037fda79d Mon Sep 17 00:00:00 2001 From: Daniel Holle Date: Mon, 8 Apr 2024 11:40:46 +0200 Subject: [PATCH] Fix #308 --- src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java | 6 +++--- src/test/java/TestPackages.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index b230c097..b5300198 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -58,6 +58,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.lang.reflect.Modifier; +import java.nio.file.Path; import java.sql.Array; import java.util.*; import java.util.Map.Entry; @@ -769,9 +770,8 @@ public class JavaTXCompiler { for (JavaClassName name : classFiles.keySet()) { byte[] bytecode = classFiles.get(name); System.out.println("generating " + name + ".class file ..."); - // output = new FileOutputStream(new File(System.getProperty("user.dir") + - // "/testBytecode/generatedBC/" +name+".class")); - File outputFile = new File(path, name.getClassName() + ".class"); + var subPath = Path.of(path.toString(), name.getPackageName().split("\\.")).toFile(); + File outputFile = new File(subPath, name.getClassName() + ".class"); outputFile.getAbsoluteFile().getParentFile().mkdirs(); output = new FileOutputStream(outputFile); output.write(bytecode); diff --git a/src/test/java/TestPackages.java b/src/test/java/TestPackages.java index d4d7128f..045eb739 100644 --- a/src/test/java/TestPackages.java +++ b/src/test/java/TestPackages.java @@ -7,7 +7,7 @@ import java.util.List; public class TestPackages { - private static final String bytecodeDirectory = System.getProperty("user.dir") + "targetTest"; + private static final String bytecodeDirectory = System.getProperty("user.dir") + "/targetTest"; @Test public void testPackages() throws Exception {