Compare commits
7 Commits
a0367d5464
...
669c778af8
Author | SHA1 | Date | |
---|---|---|---|
|
669c778af8 | ||
|
5071406b3f | ||
|
9d2d076215 | ||
|
6262c9434c | ||
|
59c5e48201 | ||
|
1cf1c99e72 | ||
|
5c60918c47 |
@ -592,7 +592,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
this.lamCounter++;
|
this.lamCounter++;
|
||||||
|
|
||||||
String typeErasure = createDescriptorWithTypeErasure(lambdaExpression);
|
String typeErasure = createDescriptorWithTypeErasure(lambdaExpression);
|
||||||
//ToDo Etienne: Double Check
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(lambdaExpression.getReturnType());
|
RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(lambdaExpression.getReturnType());
|
||||||
List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = lambdaExpression
|
List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = lambdaExpression
|
||||||
.params
|
.params
|
||||||
@ -828,7 +827,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
} else if(!helper.isInCurrPkg(clazz)){
|
} else if(!helper.isInCurrPkg(clazz)){
|
||||||
if(clazz.contains(CONSTANTS.$$)) {
|
if(clazz.contains(CONSTANTS.$$)) {
|
||||||
mDesc = helper.getDescriptorOfApplyMethod(methCallType);
|
mDesc = helper.getDescriptorOfApplyMethod(methCallType);
|
||||||
//ToDo Etienne: Double Check
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(methodCall.getType());
|
RefTypeOrTPHOrWildcardOrGeneric returnType = resolver.resolve(methodCall.getType());
|
||||||
List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = methodCall
|
List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes = methodCall
|
||||||
.arglist
|
.arglist
|
||||||
|
@ -153,7 +153,6 @@ public class DescriptorToString implements DescriptorVisitor, CONSTANTS {
|
|||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ToDo Etienne: ändern
|
|
||||||
@Override
|
@Override
|
||||||
public String visit(Lambda lambdaExpression) {
|
public String visit(Lambda lambdaExpression) {
|
||||||
String desc = "(";
|
String desc = "(";
|
||||||
|
@ -113,7 +113,7 @@ public final class FunNGenerator implements FunNUtilities{
|
|||||||
public String getSpecializedClassName(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) {
|
public String getSpecializedClassName(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) {
|
||||||
Objects.requireNonNull(argumentTypes);
|
Objects.requireNonNull(argumentTypes);
|
||||||
Objects.requireNonNull(returnType);
|
Objects.requireNonNull(returnType);
|
||||||
return String.format("Fun%d$$%s%s",
|
return String.format("Fun%d$$$_$%s%s",
|
||||||
argumentTypes.size(),
|
argumentTypes.size(),
|
||||||
argumentTypes
|
argumentTypes
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -20,7 +20,8 @@ public class ASTToTargetAST {
|
|||||||
public TargetClass convert(ClassOrInterface input, Map<TypePlaceholder, TargetType> sigma){
|
public TargetClass convert(ClassOrInterface input, Map<TypePlaceholder, TargetType> sigma){
|
||||||
List<TargetConstructor> targetConstructors = new ArrayList<>();
|
List<TargetConstructor> targetConstructors = new ArrayList<>();
|
||||||
//TODO constructor conversion -> also reduce syntactic sugar
|
//TODO constructor conversion -> also reduce syntactic sugar
|
||||||
return new TargetClass(input.getModifiers(),input.getClassName().toString(), sigma.get(input.getSuperClass()),
|
return new TargetClass(input.getModifiers(),input.getClassName().toString(), null,
|
||||||
|
sigma.get(input.getSuperClass()),
|
||||||
input.getSuperInterfaces().stream().map(it -> sigma.get(it)).collect(Collectors.toList()),
|
input.getSuperInterfaces().stream().map(it -> sigma.get(it)).collect(Collectors.toList()),
|
||||||
targetConstructors,
|
targetConstructors,
|
||||||
input.getFieldDecl().stream().map(it -> convert(it, sigma)).collect(Collectors.toList()),
|
input.getFieldDecl().stream().map(it -> convert(it, sigma)).collect(Collectors.toList()),
|
||||||
@ -42,7 +43,7 @@ public class ASTToTargetAST {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TargetField convert(Field input, Map<TypePlaceholder, TargetType> sigma) {
|
private TargetField convert(Field input, Map<TypePlaceholder, TargetType> sigma) {
|
||||||
return null;
|
return new TargetField(convert(input.getType(), sigma), input.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private TargetType convert(RefTypeOrTPHOrWildcardOrGeneric input, Map<TypePlaceholder, TargetType> sigma) {
|
private TargetType convert(RefTypeOrTPHOrWildcardOrGeneric input, Map<TypePlaceholder, TargetType> sigma) {
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package de.dhbwstuttgart.target.tree;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||||
|
import de.dhbwstuttgart.target.tree.type.TargetType;
|
||||||
|
|
||||||
|
public record GenericDeclaration(GenericRefType generic, TargetType bound) {
|
||||||
|
}
|
@ -5,6 +5,7 @@ import de.dhbwstuttgart.target.tree.type.TargetType;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public record TargetClass(int modifiers, String qualifiedName, TargetType superType, List<TargetType> implementingInterfaces,
|
public record TargetClass(int modifiers, String qualifiedName, List<GenericDeclaration> generics, TargetType superType,
|
||||||
|
List<TargetType> implementingInterfaces,
|
||||||
List<TargetConstructor> constructors, List<TargetField> fields, List<TargetMethod> methods) {}
|
List<TargetConstructor> constructors, List<TargetField> fields, List<TargetMethod> methods) {}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package de.dhbwstuttgart.target.tree;
|
package de.dhbwstuttgart.target.tree;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.target.tree.expression.TargetBlock;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public record TargetConstructor(List<MethodParameter> parameterTypes) {
|
public record TargetConstructor(List<MethodParameter> parameterTypes, TargetBlock block) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package de.dhbwstuttgart.target.tree.type;
|
package de.dhbwstuttgart.target.tree.type;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public record TargetExtendsWildcard(TargetType innerType) implements TargetType{
|
public record TargetExtendsWildcard(TargetType innerType) implements TargetType{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,34 +38,38 @@ public class OLFun2Test {
|
|||||||
compiler.generateBytecode(generatedByteCodeDirectory);
|
compiler.generateBytecode(generatedByteCodeDirectory);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)});
|
||||||
classToTest = loader.loadClass("OLFun2");
|
classToTest = loader.loadClass("OLFun2");
|
||||||
classFun1IntInt = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$");
|
classFun1IntInt = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$");
|
||||||
classFun1IntDouble = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Double$_$");
|
classFun1IntDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Double$_$");
|
||||||
classFun1DoubleDouble = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Double$_$");
|
classFun1DoubleDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Double$_$");
|
||||||
classFun1DoubleInt = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Integer$_$");
|
classFun1DoubleInt = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Integer$_$");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mExistsWithIntegerInteger() throws Exception{
|
public void mExistsWithIntegerInteger() throws Exception{
|
||||||
Method m = classToTest.getDeclaredMethod("m", classFun1IntInt);
|
Method m = classToTest.getDeclaredMethod("m", classFun1IntInt);
|
||||||
assertNotNull(m);
|
assertNotNull(m);
|
||||||
|
assertEquals(Integer.class, m.getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mExistsWithIntegerDouble() throws Exception{
|
public void mExistsWithIntegerDouble() throws Exception{
|
||||||
Method m = classToTest.getDeclaredMethod("m", classFun1IntDouble);
|
Method m = classToTest.getDeclaredMethod("m", classFun1IntDouble);
|
||||||
assertNotNull(m);
|
assertNotNull(m);
|
||||||
|
assertEquals(Double.class, m.getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mExistsWithDoubleInteger() throws Exception{
|
public void mExistsWithDoubleInteger() throws Exception{
|
||||||
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleInt);
|
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleInt);
|
||||||
assertNotNull(m);
|
assertNotNull(m);
|
||||||
|
assertEquals(Integer.class, m.getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mExistsWithDoubleDouble() throws Exception{
|
public void mExistsWithDoubleDouble() throws Exception{
|
||||||
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleDouble);
|
Method m = classToTest.getDeclaredMethod("m", classFun1DoubleDouble);
|
||||||
assertNotNull(m);
|
assertNotNull(m);
|
||||||
|
assertEquals(Double.class, m.getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -40,12 +40,12 @@ public class OLFunTest {
|
|||||||
compiler.generateBytecode(generatedByteCodeDirectory);
|
compiler.generateBytecode(generatedByteCodeDirectory);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)});
|
||||||
classToTest = loader.loadClass("OLFun");
|
classToTest = loader.loadClass("OLFun");
|
||||||
classFun1IntInt = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$");
|
classFun1IntInt = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$");
|
||||||
classFun1IntDouble = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Double$_$");
|
classFun1IntDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Double$_$");
|
||||||
classFun1DoubleDouble = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Double$_$");
|
classFun1DoubleDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Double$_$");
|
||||||
classFun1DoubleInt = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Integer$_$");
|
classFun1DoubleInt = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Integer$_$");
|
||||||
classFun1StringInt = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$Integer$_$");
|
classFun1StringInt = loader.loadClass("Fun1$$$_$Ljava$lang$String$_$Ljava$lang$Integer$_$");
|
||||||
classFun1StringDouble = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$Double$_$");
|
classFun1StringDouble = loader.loadClass("Fun1$$$_$Ljava$lang$String$_$Ljava$lang$Double$_$");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -49,70 +49,70 @@ public class FunNGeneratorTest {
|
|||||||
@Test
|
@Test
|
||||||
public void specializedClassName_VoidVoid(){
|
public void specializedClassName_VoidVoid(){
|
||||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), voidType);
|
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), voidType);
|
||||||
assertEquals("Fun0$$Ljava$lang$Void$_$", specializedClassName);
|
assertEquals("Fun0$$$_$Ljava$lang$Void$_$", specializedClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specializedClassName_VoidInt(){
|
public void specializedClassName_VoidInt(){
|
||||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), integerType);
|
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), integerType);
|
||||||
assertEquals("Fun0$$Ljava$lang$Integer$_$", specializedClassName);
|
assertEquals("Fun0$$$_$Ljava$lang$Integer$_$", specializedClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specializedClassName_IntInt(){
|
public void specializedClassName_IntInt(){
|
||||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), integerType);
|
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), integerType);
|
||||||
assertEquals("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", specializedClassName);
|
assertEquals("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", specializedClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specializedClassName_IntT(){
|
public void specializedClassName_IntT(){
|
||||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), genericT);
|
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), genericT);
|
||||||
assertEquals("Fun1$$Ljava$lang$Integer$_$LT$_$", specializedClassName);
|
assertEquals("Fun1$$$_$Ljava$lang$Integer$_$LT$_$", specializedClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specializedClassName_IntTPH(){
|
public void specializedClassName_IntTPH(){
|
||||||
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), TypePlaceholder.fresh(null));
|
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), TypePlaceholder.fresh(null));
|
||||||
assertEquals("Fun1$$Ljava$lang$Integer$_$LTPH$_$", specializedClassName);
|
assertEquals("Fun1$$$_$Ljava$lang$Integer$_$LTPH$_$", specializedClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void signature_IntInt(){
|
public void signature_IntInt(){
|
||||||
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), integerType);
|
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), integerType);
|
||||||
assertEquals("LFun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$;", classSignature);
|
assertEquals("LFun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$;", classSignature);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void signature_IntT(){
|
public void signature_IntT(){
|
||||||
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), genericT);
|
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), genericT);
|
||||||
assertEquals("LFun1$$Ljava$lang$Integer$_$LT$_$<TT;>;", classSignature);
|
assertEquals("LFun1$$$_$Ljava$lang$Integer$_$LT$_$<TT;>;", classSignature);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void signature_TPHTPH(){
|
public void signature_TPHTPH(){
|
||||||
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(tph), tph);
|
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(tph), tph);
|
||||||
assertEquals(String.format("LFun1$$LTPH$_$LTPH$_$<T%s$;T%s$;>;",tph.getName(), tph.getName()), classSignature);
|
assertEquals(String.format("LFun1$$$_$LTPH$_$LTPH$_$<T%s$;T%s$;>;",tph.getName(), tph.getName()), classSignature);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void descriptor_IntInt(){
|
public void descriptor_IntInt(){
|
||||||
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), integerType);
|
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), integerType);
|
||||||
//does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well
|
//does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well
|
||||||
assertEquals("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", classDescriptor);
|
assertEquals("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", classDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void descriptor_IntT(){
|
public void descriptor_IntT(){
|
||||||
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), genericT);
|
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), genericT);
|
||||||
//does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well
|
//does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well
|
||||||
assertEquals("Fun1$$Ljava$lang$Integer$_$LT$_$", classDescriptor);
|
assertEquals("Fun1$$$_$Ljava$lang$Integer$_$LT$_$", classDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void descriptor_TPHTPH(){
|
public void descriptor_TPHTPH(){
|
||||||
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(tph), tph);
|
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(tph), tph);
|
||||||
//does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well
|
//does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well
|
||||||
assertEquals("Fun1$$LTPH$_$LTPH$_$", classDescriptor);
|
assertEquals("Fun1$$$_$LTPH$_$LTPH$_$", classDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -227,21 +227,21 @@ public class FunNGeneratorTest {
|
|||||||
//specialized bytecode reference methods
|
//specialized bytecode reference methods
|
||||||
private static byte[] specializedBytecodeReference_VoidInt() {
|
private static byte[] specializedBytecodeReference_VoidInt() {
|
||||||
ClassWriter classWriter = new ClassWriter(0);
|
ClassWriter classWriter = new ClassWriter(0);
|
||||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun0$$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun0$$<Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun0$$"});
|
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun0$$$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun0$$<Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun0$$"});
|
||||||
classWriter.visitEnd();
|
classWriter.visitEnd();
|
||||||
return classWriter.toByteArray();
|
return classWriter.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] specializedBytecodeReference_IntInt() {
|
private static byte[] specializedBytecodeReference_IntInt() {
|
||||||
ClassWriter classWriter = new ClassWriter(0);
|
ClassWriter classWriter = new ClassWriter(0);
|
||||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun1$$<Ljava/lang/Integer;Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun1$$"});
|
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun1$$<Ljava/lang/Integer;Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun1$$"});
|
||||||
classWriter.visitEnd();
|
classWriter.visitEnd();
|
||||||
return classWriter.toByteArray();
|
return classWriter.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] specializedBytecodeReference_TIntInt() {
|
private static byte[] specializedBytecodeReference_TIntInt() {
|
||||||
ClassWriter classWriter = new ClassWriter(0);
|
ClassWriter classWriter = new ClassWriter(0);
|
||||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun2$$LT$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "<T:Ljava/lang/Object;>Ljava/lang/Object;LFun2$$<TT;Ljava/lang/Integer;Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun2$$"});
|
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun2$$$_$LT$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "<T:Ljava/lang/Object;>Ljava/lang/Object;LFun2$$<TT;Ljava/lang/Integer;Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun2$$"});
|
||||||
classWriter.visitEnd();
|
classWriter.visitEnd();
|
||||||
return classWriter.toByteArray();
|
return classWriter.toByteArray();
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,6 @@ public class OLFun2 {
|
|||||||
m(f){
|
m(f){
|
||||||
var x = 1;
|
var x = 1;
|
||||||
var y = f.apply(x + x) + 1;
|
var y = f.apply(x + x) + 1;
|
||||||
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,10 @@
|
|||||||
public class OLFunTest{
|
public class OLFunTest{
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
var olFun2 = new OLFun2();
|
var olFun2 = new OLFun2();
|
||||||
olFun2.m((Integer x) -> x);
|
Integer i = olFun2.m((Integer x) -> x);
|
||||||
olFun2.m((Integer x) -> (Double) Double.valueOf(x));
|
i = olFun2.m((Double x) -> x.intValue());
|
||||||
olFun2.m((Double x) -> x);
|
|
||||||
olFun2.m((Double x) -> x.intValue());
|
Double d = olFun2.m((Integer x) -> Double.valueOf(x));
|
||||||
|
d = olFun2.m((Double x) -> x);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user