From 1b6cae1be0004333188ea1dfd1fa2663c729b215 Mon Sep 17 00:00:00 2001 From: Fayez Abu Alia Date: Wed, 25 Apr 2018 16:44:27 +0200 Subject: [PATCH] =?UTF-8?q?GenTest=20angef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../descriptor/DescriptorToString.java | 7 ++-- test/bytecode/GenTest.java | 41 +++++++++++++++++++ test/bytecode/javFiles/Gen.jav | 3 ++ 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 test/bytecode/GenTest.java diff --git a/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorToString.java b/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorToString.java index c9725a828..c5f378fed 100644 --- a/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorToString.java +++ b/src/de/dhbwstuttgart/bytecode/descriptor/DescriptorToString.java @@ -49,9 +49,10 @@ public class DescriptorToString implements DescriptorVisitor{ desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";"; } } -// else if(((RefType) fp.getType()).getParaList().size() > 0){ -// desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.toString().replace(".", "%").replace("<", "%%").replace(">", "%%")+ ";"; -// } + //TODO: generate a class java%% ... %% + else if(((RefType) fp.getType()).getParaList().size() > 0){ + desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.toString().replace(".", "%").replace("<", "%%").replace(">", "%%")+ ";"; + } else { desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";"; } diff --git a/test/bytecode/GenTest.java b/test/bytecode/GenTest.java new file mode 100644 index 000000000..d0067d084 --- /dev/null +++ b/test/bytecode/GenTest.java @@ -0,0 +1,41 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; + +import org.junit.BeforeClass; +import org.junit.Test; + +import de.dhbwstuttgart.core.JavaTXCompiler; + +public class GenTest { + + private static String path; + private static File fileToTest; + private static JavaTXCompiler compiler; + private static ClassLoader loader; + private static Class classToTest; + private static String pathToClassFile; + private static Object instanceOfClass; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Gen.jav"; + fileToTest = new File(path); + compiler = new JavaTXCompiler(fileToTest); + compiler.generateBytecode(); + pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/"; + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass("Gen"); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + } + + @Test + public void test() { + fail("Not yet implemented"); + } + +} diff --git a/test/bytecode/javFiles/Gen.jav b/test/bytecode/javFiles/Gen.jav index 1f8739192..b94ec4459 100644 --- a/test/bytecode/javFiles/Gen.jav +++ b/test/bytecode/javFiles/Gen.jav @@ -1,3 +1,6 @@ +import java.lang.Integer; +import java.util.Vector; + public class Gen{ Vector m(Vector v){ return v;