Merge branch 'unify-test' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into unify-test

This commit is contained in:
Martin Plümicke 2019-01-11 19:27:19 +01:00
commit c1e4f14fa4
67 changed files with 850 additions and 87 deletions

46
pom.xml
View File

@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.dhbwstuttgart</groupId>
<artifactId>JavaTXcompiler</artifactId>
@ -11,6 +11,12 @@
<name>JavaTXcompiler</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
@ -37,12 +43,6 @@
<artifactId>asm</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<!-- <scope>test</scope> -->
</dependency>
<!-- <dependency> <groupId>org.ow2.asm</groupId> <artifactId>asm-all</artifactId>
<version>[4.0.0,)</version> </dependency> -->
<!-- <dependency> <groupId>org.bitbucket.mstrobel</groupId> <artifactId>procyon-reflection</artifactId>
@ -54,8 +54,6 @@
<outputDirectory>target/classes</outputDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/</sourceDirectory>
<testSourceDirectory>test/</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
@ -83,7 +81,7 @@
</goals>
<configuration>
<sourceDirectory>src/main/antlr4/sat</sourceDirectory>
<outputDirectory>${project.basedir}/target/generated-sources/antlr4/de/dhbwstuttgart/sat/asp/parser/antlr/</outputDirectory>
<outputDirectory>${project.basedir}/target/generated-sources/antlr4/de/dhbwstuttgart/sat/asp/parser/antlr</outputDirectory>
<arguments>
<argument>-package</argument>
<argument>de.dhbwstuttgart.sat.asp.parser.antlr</argument>
@ -140,28 +138,10 @@
</execution>
</executions>
</plugin>
<!-- plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>archive-repository</goal>
</goals>
</execution>
</executions>
</plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>${project.basedir}/src/test/resources/testBytecode/generatedBC/*.java</exclude>
</excludes>
</configuration>
</plugin>
<!-- plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho.version}</version> <executions> <execution> <phase>package</phase>
<goals> <goal>archive-repository</goal> </goals> </execution> </executions>
</plugin -->
</plugins>
</build>
<pluginRepositories>
@ -189,3 +169,5 @@
</repository>
</distributionManagement>
</project>

View File

@ -1,24 +0,0 @@
#!/bin/bash
# A basic script to compile the necessary packages and their subpackages to work with the parser.
# Messages are logged to stderr.
>&2 echo "Building de.dhbwstuttgart.typecheck..."
javac -d ../bin ./de/dhbwstuttgart/typecheck/*.java
>&2 echo "Building de.dhbwstuttgart.syntaxtree..."
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/*.java
>&2 echo "Building de.dhbwstuttgart.syntaxtree.factory..."
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/factory/*.java
>&2 echo "Building de.dhbwstuttgart.syntaxtree.operator..."
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/operator/*.java
>&2 echo "Building de.dhbwstuttgart.syntaxtree.statement..."
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/statement/*.java
>&2 echo "Building de.dhbwstuttgart.syntaxtree.statement.literal..."
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/statement/literal/*.java
>&2 echo "Building de.dhbwstuttgart.syntaxtree.type..."
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/type/*.java
>&2 echo "Building de.dhbwstuttgart.parser..."
javac -d ../bin ./de/dhbwstuttgart/parser/*.java
>&2 echo "Building de.dhbwstuttgart.parser.SyntaxTreeGenerator..."
javac -d ../bin ./de/dhbwstuttgart/parser/SyntaxTreeGenerator/*.java
>&2 echo "Building de.dhbwstuttgart.parser.antlr..."
javac -d ../bin ./de/dhbwstuttgart/parser/antlr/*.java
echo "Done. Now its your turn to debug:)."

Binary file not shown.

View File

@ -70,6 +70,7 @@ public class BytecodeGen implements ASTVisitor {
// stores generics and their bounds of class
HashMap<String, String> genericsAndBounds = new HashMap<>();
private int constructorPos = 0;
private final TPHExtractor tphExtractor = new TPHExtractor();
private final ArrayList<GenericInsertPair> commonPairs = new ArrayList<>();
@ -272,7 +273,8 @@ public class BytecodeGen implements ASTVisitor {
for(String paramName : methodParamsAndTypes.keySet()) {
String typeOfParam = methodParamsAndTypes.get(paramName).acceptTV(new TypeToSignature());
if(genericsAndBounds.containsKey(typeOfParam) ||typeOfParam.substring(0, 4).equals("TPH ")
System.out.println(typeOfParam);
if(genericsAndBounds.containsKey(typeOfParam) ||typeOfParam.contains("$")
|| typeOfParam.contains("<")) {
hasGen = true;
break;
@ -291,10 +293,14 @@ public class BytecodeGen implements ASTVisitor {
desc = constructor.accept(new DescriptorToString(resultSet));
System.out.println("Constructor: " + field.getName() + " Sig: "+ sig + " Desc: " + desc);
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", desc, sig, null);
mv.visitCode();
mv.visitCode();
Block block = fieldInitializations.get().block;
constructorPos += 1;
BytecodeGenMethod gen = new BytecodeGenMethod(className,superClass,resultSet,field, mv,paramsAndLocals,cw,
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles, sf,path, block);
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles, sf,path, block, constructorPos);
if(!field.getParameterList().iterator().hasNext() && !(field.block.statements.get(field.block.statements.size()-1) instanceof ReturnVoid)) {
mv.visitInsn(Opcodes.RETURN);
}

View File

@ -85,13 +85,15 @@ public class BytecodeGenMethod implements StatementVisitor {
private boolean isRightSideALambda = false;
private KindOfLambda kindOfLambda;
private HashMap<String, byte[]> classFiles;
private int constructorPos = 0;
private ArrayList<RefTypeOrTPHOrWildcardOrGeneric> varsFunInterface = new ArrayList<>();;
// generate bytecode for constructor
public BytecodeGenMethod(String className, String superClass,ResultSet resultSet, Method m, MethodVisitor mv,
HashMap<String, Integer> paramsAndLocals, ClassWriter cw, HashMap<String, String> genericsAndBoundsMethod,
HashMap<String, String> genericsAndBounds, boolean isInterface, HashMap<String, byte[]> classFiles,
SourceFile sf,String path, Block block) {
SourceFile sf,String path, Block block, int constructorPos) {
this.className = className;
this.superClass = superClass;
@ -106,6 +108,7 @@ public class BytecodeGenMethod implements StatementVisitor {
this.classFiles = classFiles;
this.sf = sf;
this.path = path;
this.constructorPos = constructorPos;
if(block != null)
this.blockFieldInit = block;
this.m.block.accept(this);
@ -634,20 +637,20 @@ public class BytecodeGenMethod implements StatementVisitor {
// Desc: (this/nothing)TargetType
String fiMethodDesc = samMethod.accept(new DescriptorToString(resultSet));
mv.visitInvokeDynamicInsn("apply", fiMethodDesc, bootstrap, arg1, arg2, arg3);
MethodVisitor mvLambdaBody = cw.visitMethod(Opcodes.ACC_PRIVATE + staticOrInstance + Opcodes.ACC_SYNTHETIC,
methodName, newDesc, null, null);
ArrayList<String> usedVars = kindOfLambda.getUsedVars();
new BytecodeGenMethod(lambdaExpression, usedVars,this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
classFiles,this.path, lamCounter, sf);
mvLambdaBody.visitMaxs(0, 0);
mvLambdaBody.visitEnd();
cw.visitInnerClass("java/lang/invoke/MethodHandles$Lookup", "java/lang/invoke/MethodHandles", "Lookup",
Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL);
if(constructorPos<2) {
MethodVisitor mvLambdaBody = cw.visitMethod(Opcodes.ACC_PRIVATE + staticOrInstance + Opcodes.ACC_SYNTHETIC,
methodName, newDesc, null, null);
ArrayList<String> usedVars = kindOfLambda.getUsedVars();
new BytecodeGenMethod(lambdaExpression, usedVars,this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
classFiles,this.path, lamCounter, sf);
mvLambdaBody.visitMaxs(0, 0);
mvLambdaBody.visitEnd();
cw.visitInnerClass("java/lang/invoke/MethodHandles$Lookup", "java/lang/invoke/MethodHandles", "Lookup",
Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL);
}
// generateBCForFunN(lambdaExpression, typeErasure);
}

View File

@ -106,7 +106,14 @@ public class DescriptorToString implements DescriptorVisitor{
if(constructor.getGenericsAndBounds().containsKey(fpDesc)){
desc += "L"+constructor.getGenericsAndBounds().get(fpDesc)+ ";";
}else {
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
// desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
String resType = resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor());
if(resType.subSequence(0, 4).equals("TPH ")) {
// Bound ist immer Object
desc += "L"+Type.getInternalName(Object.class)+ ";";
} else {
desc += "L"+resType+ ";";
}
}
}else {
// System.out.println("Cons has NO Gens");

View File

@ -162,7 +162,7 @@ public class KindOfLambda implements StatementVisitor{
@Override
public void visit(UnaryExpr unaryExpr) {
throw new NotImplementedException();
}
@Override
@ -202,7 +202,8 @@ public class KindOfLambda implements StatementVisitor{
@Override
public void visit(WhileStmt whileStmt) {
// TODO Auto-generated method stub
whileStmt.expr.accept(this);
whileStmt.loopBlock.accept(this);
}

View File

@ -174,9 +174,11 @@ public class Simplify {
allCons.addAll(result.keySet());
if(!allCons.isEmpty() && allCons.size()<2) {
if(!result.containsKey(allCons.get(0)))
result.put(allCons.get(0), null);
TPHConstraint cons = allCons.get(0);
if(!result.containsKey(cons)) {
result.put(cons, null);
result.put(new ExtendsConstraint(cons.getRight(), Type.getInternalName(Object.class), Relation.EXTENDS), null);
}
return result;
}

View File

@ -122,7 +122,9 @@ public class JavaTXCompiler {
TypeUnify unify = new TypeUnify();
Set<Set<UnifyPair>> results = new HashSet<>();
try {
FileWriter logFile = new FileWriter(new File(System.getProperty("user.dir")+"/test/logFiles/"+"log"));
File logPath = new File(System.getProperty("user.dir")+"/target/logFiles/");
logPath.mkdirs();
FileWriter logFile = new FileWriter(new File(logPath, "log"));
logFile.write("FC:\\" + finiteClosure.toString()+"\n");
for(SourceFile sf : this.sourceFiles.values()) {
logFile.write(ASTTypePrinter.print(sf));
@ -223,7 +225,9 @@ public class JavaTXCompiler {
logFile.write("PLACEHOLDERS: " + PlaceholderType.EXISTING_PLACEHOLDERS);
logFile.flush();
}
catch (IOException e) { }
catch (IOException e) {
e.printStackTrace();
}
return results.stream().map((unifyPairs ->
new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList());
}

View File

@ -20,7 +20,7 @@ import java.util.Set;
public class ASPTest {
public static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/";
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/";
private static final List<File> filesToTest = new ArrayList<>();
protected File fileToTest = null;

View File

@ -27,7 +27,7 @@ public class FacultyTest {
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/Faculty.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode(System.getProperty("user.dir")+"//src/test/resources/testBytecode/generatedBC/");
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Faculty");

View File

@ -0,0 +1,49 @@
package bytecode;
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import org.junit.BeforeClass;
import org.junit.Test;
import de.dhbwstuttgart.core.JavaTXCompiler;
public class FieldTphConsMethTest {
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")+"/src/test/resources/bytecode/javFiles/FieldTphConsMeth.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("FieldTphConsMeth");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
}
@Test
public void test() throws Exception {
Field a = classToTest.getDeclaredField("a");
a.setAccessible(true);
Method m = classToTest.getDeclaredMethod("m", Object.class);
Object result = m.invoke(instanceOfClass, 42);
assertEquals(42,result);
}
}

View File

@ -0,0 +1,38 @@
package bytecode;
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLClassLoader;
import org.junit.BeforeClass;
import org.junit.Test;
import de.dhbwstuttgart.core.JavaTXCompiler;
public class IdTest {
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;
@Test
public void test() throws Exception {
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/Id.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Id");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
}
}

View File

@ -0,0 +1,45 @@
package bytecode;
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import org.junit.BeforeClass;
import org.junit.Test;
import de.dhbwstuttgart.core.JavaTXCompiler;
public class Tph6Test {
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")+"/src/test/resources/bytecode/javFiles/Tph6.jav";
fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest);
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
compiler.generateBytecode(pathToClassFile);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Tph6");
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
}
@Test
public void test() throws Exception {
// Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class, Object.class);
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
// Object result = m.invoke(instanceOfClass, "xx",2,3);
//assertEquals(2,result);
}
}

View File

@ -0,0 +1,9 @@
import java.lang.Integer;
import java.lang.Long;
public class AddLong{
Long add(Integer a, Long b) {
Long c = a+b;
return c;
}
}

View File

@ -0,0 +1,3 @@
public class EmptyClass{
}

View File

@ -0,0 +1,37 @@
public class EmptyMethod{
static String s1 ="";
String s2;
public void m1(){
//String s = "";
System.out.println("test");
//Integer ab = Math.abs(1);
//Math.abs(1);
//String lV = "local";
//s1 = "1";
//s1.concat("2");
s2 = s1;
//m2();
Clazz i = new Clazz();
Integer i = new Integer(1);
}
public void m2(){}
}
class Clazz{}
/*
public class EmptyMethod2{
public static test = "5";
public void m1(Integer i, String j, Boolean b){
//String s = "";
EmptyMethod em = new EmptyMethod();
em.m1();
em.s1 = "";
//Integer ab = Math.abs(1);
//Math.abs(1);
//String lV = "local";
//s1 = "1";
//s1.concat("2");
//s2 = s1;
}
}*/

View File

@ -0,0 +1,8 @@
class Expressions{
void test(){
var x = 2;
x = x + 2;
}
}

View File

@ -0,0 +1,10 @@
import java.util.Vector;
class Matrix extends Vector<Vector<Integer>> {
methode(m) {
m.add(1);
Matrix i;
methode(i);
}
}

View File

@ -0,0 +1,15 @@
import java.lang.Integer;
class Faculty {
Integer mul(Integer x, Integer y) {
return x;
}
m () {
var fact = (Integer x) -> {
return mul(x, fact.apply(x));
};
return fact;
}
}

View File

@ -0,0 +1,17 @@
import java.lang.Integer;
class Faculty {
m () {
var fact = (Integer x) -> {
if (x == 1) {
return x;
}
else {
return x * (fact.apply(x-1));
}
};
return fact;
}
}

View File

@ -0,0 +1,19 @@
import java.lang.Integer;
class Faculty {
Integer mul(Integer x, Integer y) {
return x;
}
Fun1<java.lang.Integer,java.lang.Integer> m () {
var fact = (Integer x) -> {
return mul(x, fact.apply(x));
};
return fact;
}
}
interface Fun1<A,B>{
B apply(A a);
}

View File

@ -0,0 +1,11 @@
import java.lang.String;
class Fields{
test2 = "test";
test;
m(){
var test3;
return test;
}
}

View File

@ -0,0 +1,22 @@
import java.lang.String;
class Generics<B> {
//<A extends B> A mt1(A a, B b){
B mt1(B a, B b){
return mt1(a, a);
}
}
class Test {
methode(String s){
return new Generics<String>().mt1(s,s);
}
}
/*
Problem:
auto test = new List<String>();
auto test2 = new List<Integer>();
... //code, welcher möglicherweise test und test2 vertauscht
test.add("hallo");
*/

View File

@ -0,0 +1,14 @@
import java.lang.Integer;
import java.lang.Boolean;
import java.lang.Object;
public class IfTest{
Object m1(b) {
Integer i;
if(b) {
return i;
}else{
return b;
}
}
}

View File

@ -0,0 +1,8 @@
import java.util.Vector;
class Import {
void methode(){
Vector v;
v.add(v);
}
}

View File

@ -0,0 +1,13 @@
class Apply { }
public class Lambda {
m () {
var lam1 = (x) -> {
return x;
};
return lam1.apply(new Apply());
}
}

View File

@ -0,0 +1,33 @@
import java.lang.String;
public class Lambda2
{
public static void main(List<String> args){
var listOfStrings = new List<String>();
var listOfObjects;
listOfObjects = map(listOfStrings, (a) -> a);
}
public map(a , b){
b.apply(a);
return a;
}
/*
public static <I,O> List<O> map(List<I> input, Function<I,O> func) {
List<O> output;
output = new List<O>();
output.add(func.apply(input.get()));
return output;
}
*/
}
class List<A>{
A get();
void add(A);
}
class Function<A,B>{
B apply(A a);
}

View File

@ -0,0 +1,24 @@
import java.lang.String;
public class Lambda2
{
/*
public static <A> List<A> map(List<? extends A> input,
Function<? super A, ? extends A> func){
input.add(func.apply(input.get()));
}
*/
public map(input,func){
input.add(func.apply(input.get()));
return map(new List<String>(), func);
}
}
class List<A>{
A get();
void add(A);
}
class Function<A,B>{
B apply(A a);
}

View File

@ -0,0 +1,6 @@
public class LambdaField {
f = x -> x;
}

View File

@ -0,0 +1,14 @@
import java.lang.Runnable;
import java.lang.String;
import java.lang.System;
public class LamRunnable{
public LamRunnable(){
Runnable lam = () -> {System.out.println("lambda");};
lam.run();
}
}

View File

@ -0,0 +1,20 @@
import java.lang.Integer;
import java.lang.String;
class ListenerOverload{
call(p){
call(p.left);
call(p.right);
}
call(Integer i){}
call(String s){}
}
class Pair<A,B>{
A left;
B right;
}

View File

@ -0,0 +1,28 @@
import java.util.Vector;
import java.lang.Integer;
class Matrix extends Vector<Vector<Integer>> {
Integer mul1(Integer x, Integer y) { return x;}
Integer add1(Integer x, Integer y) { return x;}
mul(m) {
var ret = new Matrix();
var i = 0;
while(i < size()) {
var v1 = this.elementAt(i);
var v2 = new Vector<Integer>();
var j = 0;
while(j < v1.size()) {
var erg = 0;
var k = 0;
while(k < v1.size()) {
erg = erg + v1.elementAt(k) * m.elementAt(k).elementAt(j);
//erg = add1(erg, mul1(v1.elementAt(k),
// m.elementAt(k).elementAt(j)));
k++; }
v2.addElement(new Integer(erg));
j++; }
ret.addElement(v2);
i++; }
return ret;
}
}

View File

@ -0,0 +1,11 @@
class Meth_Gen {
m1(x, y) {
m2(x);
x = y;
}
m2(y) {
m1(y, y);
}
}

View File

@ -0,0 +1,14 @@
import java.lang.String;
class Generics<B> {
//<A extends B> A mt1(A a, B b){
B mt1(B a, B b){
return mt1(a, a);
}
}
class Test {
methode(String s){
return new Generics<String>().mt1(s,s);
}
}

View File

@ -0,0 +1,17 @@
class Methods {
mt4(a,b,c) { return a.add(b).sub(c) ; }
mt1(a) {return a;}
mt2(a) {return a.f; }
mt3(a) {return a.add(); }
}
class Test {
java.lang.Object f;
add(){}
add(b){return b;}
sub(b){}
}

View File

@ -0,0 +1,7 @@
class Methods {
mt4(a,b,c) { return a.mt3(b).mt3(c) ; }
mt3(a) {return a.mt3(a); }
}

View File

@ -0,0 +1,11 @@
public class Op1{
public Op1() {
Runnable lam = () -> {
String test = "";
String b = "b";
test = b;
System.out.println(test);};
//lam.run();
}
}

View File

@ -0,0 +1,5 @@
package strucType.input;
class Neu
{
}

View File

@ -0,0 +1,8 @@
import java.util.List;
import java.util.Collection;
class Sorting{
void merge(a, b){
a.addAll(b);
}
}

View File

@ -0,0 +1,6 @@
public class Subclass extends Superclass {
public void printMethod() {
super.printMethod();
}
}

View File

@ -0,0 +1,6 @@
public class Superclass {
public void printMethod() {
System.out.println("Printed in Superclass.");
}
}

View File

@ -0,0 +1,23 @@
import java.util.ArrayList;
import java.util.Vector;
import java.lang.Object;
class MyVector{
id(x){
Object i;
x.add(i);
x.add(i);
x.add(i);
x.add(i);
x.add(i);
x.add(i);
x.add(i);
x.add(i);
x.add(i);
x.add(i);
x.add(i);
x.add(i);
return x;
}
}

View File

@ -0,0 +1,18 @@
import java.util.List;
class Test{
methode(param1, param2, param3) {
param2.add(param3);
return param1.meth(param2);
}
}
interface Klasse1{
Klasse1 meth(List p);
Klasse1 meth(Klasse2 p);
}
interface Klasse2{
Klasse1 meth(Klasse1 p);
Klasse2 meth(Klasse2 p);
}

View File

@ -0,0 +1,13 @@
class mathStruc<A> {
mathStruc(A a) { }
A model(){ A a; return a; }
methode(){
var innerOp = o -> ms ->
new mathStruc<A>(o.apply(this.model(),ms.model()));
return innerOp;
}
}

View File

@ -0,0 +1,15 @@
class Test{
methode(param1, param2, param3) {
return param1.meth(param2.meth(param3));
}
}
interface Klasse1{
Klasse1 meth(Klasse1 p);
Klasse1 meth(Klasse2 p);
}
interface Klasse2{
Klasse1 meth(Klasse1 p);
Klasse2 meth(Klasse2 p);
}

View File

@ -0,0 +1,7 @@
class Faculty {
int a;
m (int x) {
return a+x;
}
}

24
src/test/java/log4jTesting.xml Executable file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="de.dhbwstuttgart.logger.PatternLayout">
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
</layout>
</appender>
<logger name="trtest">
<level value="DEBUG"/>
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="funcTest">
<level value="DEBUG"/>
<appender-ref ref="CONSOLE"/>
</logger>
</log4j:configuration>

View File

@ -22,7 +22,7 @@ import java.util.Set;
public class JavaTXCompilerTest {
public static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/";
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/";
@Test
public void finiteClosure() throws IOException, ClassNotFoundException {
execute(new File(rootDirectory+"fc.jav"));

View File

@ -22,7 +22,7 @@ import java.util.Set;
public class Meth_GenTest {
public static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/";
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/";
/*
@Test
public void finiteClosure() throws IOException, ClassNotFoundException {

View File

@ -22,7 +22,7 @@ import java.util.Set;
public class UnifyTest {
public static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/";
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/";
/*
@Test
public void finiteClosure() throws IOException, ClassNotFoundException {

View File

@ -0,0 +1,11 @@
public class FieldTphConsMeth {
a;
public FieldTphConsMeth(c) {
a = m(c);
}
m(b) {
return b;
}
}

View File

@ -0,0 +1,6 @@
public class Id {
id(b){
return b;
}
}

View File

@ -0,0 +1,14 @@
public class Tph6 {
// m(a,b,c){
// a = c;
// b = c;
// return a;
// }
m(x,y){
var c = m2(y);
c = m2(x);
}
m2(y) { return y; }
}

View File

@ -0,0 +1,6 @@
public class Field{
public void m(){
MethFieldVar mF = new MethFieldVar();
mF.s1 = "Field S1";
}
}

View File

@ -0,0 +1,8 @@
import java.util.Vector;
class Import {
void methode(){
Vector v = new Vector();
v.add(v);
}
}

View File

@ -0,0 +1,10 @@
import java.util.function.Function;
public class Lam1{
public Lam1() {
Function<String,String> fun = (x) -> x+"1";
fun.apply("2");
Runnable lam = () -> System.out.println("lambda");
lam.run();
}
}

View File

@ -0,0 +1,8 @@
public class LamRun{
public void mRun(){
Runnable lam = () -> System.out.println("lambda");
lam.run();
}
}

View File

@ -0,0 +1,38 @@
public class MethFieldVar{
String s1;// = "";
String s2;
/* public void meth(Integer i, String j, Boolean b){
//String local = "a";
//int localL = local.length();
//int l = s.length();
String s = null;
//s = "";
//return s.length();//l+localL;
}
*/
public void mm(){
// return "mm";
}
public void m2(){
System.out.println("");
// Math.abs(1);
// String lV = "local";
// s1 = "1";
// s1.concat("2");
s2 = s1;
mm();
Clazz i = new Clazz();
Runnable lam = ()->{
String test = "";
String b = "b";
test = b;
System.out.println(test);
};
}
}
class Clazz{}

View File

@ -0,0 +1,6 @@
public class Subclass extends Superclass {
public void printMethod() {
super.printMethod();
}
}

View File

@ -0,0 +1,14 @@
public class Superclass {
public void printMethod() {
System.out.println("Printed in Superclass.");
}
}
public class Subclass extends Superclass {
public void printMethod() {
super.printMethod();
}
}

View File

@ -0,0 +1,6 @@
public class Superclass {
public void printMethod() {
System.out.println("Printed in Superclass.");
}
}

View File

@ -0,0 +1,11 @@
class TestMyTest{
public static void main(String[] a){
//test1
//new TestClass();
//test if statement
//new TestIf(new Boolean(true));
// test lambda
//new TestClass();
new LamRun();
}
}

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,5 @@
public class testTets(){
public static void main(String[] args){
new tetsF();
}
}

View File

@ -0,0 +1,5 @@
public class testTets{
public static void main(String[] args){
new TetsF();
}
}

View File

@ -0,0 +1,5 @@
public class testTets(){
public static void main(String[] args){
new tetsF();
}
}