Merge branch 'targetBytecode' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into targetBytecode
This commit is contained in:
commit
d87ea005b1
@ -5,6 +5,8 @@ import org.junit.BeforeClass;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.TypeVariable;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@ -22,10 +24,67 @@ public class TphTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test1() throws Exception {
|
public void test1() throws Exception {
|
||||||
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
var classFiles = TestCodegen.generateClassFiles("Tph7.jav", new ByteArrayClassLoader());
|
||||||
Object result = m.invoke(instanceOfClass, 1,2);
|
classToTest = classFiles.get("Tph7");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
assertEquals(1,result);
|
//public <DZN, DZL, DZU extends DZN, DZM extends DZU> DZU m(DZL, DZM);
|
||||||
|
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
||||||
|
|
||||||
|
//System.out.println(m.toString());
|
||||||
|
|
||||||
|
//Argumenttypes of the method m
|
||||||
|
var paraTypes = m.getGenericParameterTypes();
|
||||||
|
|
||||||
|
//Typeparameters of the method m
|
||||||
|
var typeParaTypes = m.getTypeParameters();
|
||||||
|
|
||||||
|
//Typeparameters are extracted from the argumenttypes
|
||||||
|
//Conditions for the extracted typeparameters are set
|
||||||
|
|
||||||
|
//paraTypes[0] = DLZ
|
||||||
|
var boundFstArg = Arrays.stream(typeParaTypes)
|
||||||
|
.filter(x -> x.equals(paraTypes[0])).findFirst().get().getBounds();
|
||||||
|
|
||||||
|
//Bound of DLZ has to be Object
|
||||||
|
assertEquals(Object.class, Arrays.stream(boundFstArg).findFirst().get());
|
||||||
|
|
||||||
|
//paraTypes[0] = DZM
|
||||||
|
var boundSndArg = Arrays.stream(typeParaTypes)
|
||||||
|
.filter(x -> x.equals(paraTypes[1])).findFirst().get().getBounds();
|
||||||
|
|
||||||
|
//Bound of DZM has to be the return type of m
|
||||||
|
assertEquals(Arrays.stream(boundSndArg).findFirst().get(), m.getGenericReturnType());
|
||||||
|
|
||||||
|
//Bound of the bound of DZM
|
||||||
|
var boundBoundSndArg = Arrays.stream(typeParaTypes).filter(x -> x.equals(Arrays.stream(boundSndArg)
|
||||||
|
.findFirst().get())).findFirst().get().getBounds();
|
||||||
|
|
||||||
|
//boundBoundSndArg have to be a type variable (type of the local variable c)
|
||||||
|
assertEquals(true, Arrays.stream(boundBoundSndArg).findFirst().get() instanceof TypeVariable);
|
||||||
|
m.getGenericParameterTypes();
|
||||||
|
|
||||||
|
//public <DZU> DZU m2(DZU);
|
||||||
|
Method m2 = classToTest.getDeclaredMethod("m2", Object.class);
|
||||||
|
|
||||||
|
//Argumenttypes of the method m2
|
||||||
|
var paraTypesm2 = m2.getGenericParameterTypes();
|
||||||
|
|
||||||
|
//Typeparameters of the method m2
|
||||||
|
var typeParaTypesm2 = m2.getTypeParameters();
|
||||||
|
|
||||||
|
//Typeparameters are extracted from the argumenttypes
|
||||||
|
//Conditions for the extracted typeparameters are set
|
||||||
|
|
||||||
|
//paraTypes[0] = DZU
|
||||||
|
var fstArgm2 = Arrays.stream(typeParaTypesm2)
|
||||||
|
.filter(x -> x.equals(paraTypesm2[0])).findFirst().get();
|
||||||
|
|
||||||
|
//Bound of DZU has to be Object
|
||||||
|
assertEquals(Object.class, Arrays.stream(fstArgm2.getBounds()).findFirst().get());
|
||||||
|
|
||||||
|
//DZU has to be the return type of m
|
||||||
|
assertEquals(fstArgm2, m2.getGenericReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -12,8 +12,44 @@ public class Inf {
|
|||||||
b=a;
|
b=a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// v w
|
|
||||||
// \ /
|
/*
|
||||||
// z y b
|
TPH M m(TPH N x, TPH O y, TPH P a)({
|
||||||
// \ / \ /
|
TPH Q z;
|
||||||
// x a
|
TPH R v;
|
||||||
|
TPH S w;
|
||||||
|
TPH T b;
|
||||||
|
(y)::TPH O = (x)::TPH N;
|
||||||
|
(z)::TPH Q = (x)::TPH N;
|
||||||
|
(v)::TPH R = (y)::TPH O;
|
||||||
|
(w)::TPH S = (y)::TPH O;
|
||||||
|
(y)::TPH O = (a)::TPH P;
|
||||||
|
(b)::TPH T = (a)::TPH P;
|
||||||
|
return;
|
||||||
|
})::TPH U
|
||||||
|
|
||||||
|
Inf()({
|
||||||
|
super(());
|
||||||
|
})::TPH X
|
||||||
|
|
||||||
|
}
|
||||||
|
// v::R w::S
|
||||||
|
// \ /
|
||||||
|
// z::Q y::O b::T
|
||||||
|
// \ / \ /
|
||||||
|
// x::N a::P
|
||||||
|
|
||||||
|
RESULT Final: [[(TPH O < TPH S), (TPH P < TPH O), (TPH O < TPH R), (TPH P < TPH T), (TPH M = void), (TPH N < TPH O), (TPH N < TPH Q)]]
|
||||||
|
Simplified constraints: [(TPH O < TPH S), (TPH P < TPH O), (TPH O < TPH R), (TPH P < TPH T), (TPH N < TPH O), (TPH N < TPH Q)]
|
||||||
|
m: [(TPH DDV = java.lang.Object), (TPH DDX = java.lang.Object), (TPH DDX < TPH DDV), (TPH N < TPH DDX), (TPH P < TPH DDX)]
|
||||||
|
Class Inf: []
|
||||||
|
Inf: []
|
||||||
|
|
||||||
|
Unify nach Oder-Constraints-Anpassung:
|
||||||
|
UND:[(void =. M, , -1 WC: false, IT: false), (N <. O, 1 WC: false, IT: false, 1 WC: false, IT: false), (P <. O, 1 WC: false, IT: false, 1 WC: false, IT: false), (N <. Q, 1 WC: false, IT: false, 0 WC: true, IT: false), (O <. S, 1 WC: false, IT: false, 0 WC: true, IT: false), (O <. R, 1 WC: false, IT: false, 0 WC: true, IT: false), (P <. T, 1 WC: false, IT: false, 0 WC: true, IT: false)]
|
||||||
|
isInherited = false
|
||||||
|
isStatement = false
|
||||||
|
|
||||||
|
ODER:
|
||||||
|
*/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user