Explorar o código

move fragile lambda reflection code from assira to assira.lambda

Mariusz Sieroń %!s(int64=6) %!d(string=hai) anos
pai
achega
105be49da6

+ 78 - 0
assira.lambda/pom.xml

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>assira.project</artifactId>
+        <groupId>net.ranides</groupId>
+        <version>2.3.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>assira.lambda</artifactId>
+
+    <properties>
+        <assira.junit.debug>false</assira.junit.debug>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>${maven.compiler.source}</source>
+                    <target>${maven.compiler.target}</target>
+                    <compilerArgs>
+                        <argument>-Xlint:unchecked</argument>
+                        <argument>-Xlint:removal</argument>
+                        <argument>-parameters</argument>
+                        <argument>--add-exports</argument>
+                        <argument>java.base/jdk.internal.reflect=ALL-UNNAMED</argument>
+                    </compilerArgs>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <excludedGroups>net.ranides.assira.junit.JCategories$Slow,net.ranides.assira.junit.JCategories$UnstableTest</excludedGroups>
+                    <argLine>--add-exports java.base/jdk.internal.reflect=ALL-UNNAMED</argLine>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>net/ranides/assira/test/**</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>net.ranides</groupId>
+            <artifactId>assira</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>net.ranides</groupId>
+            <artifactId>assira.junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

+ 19 - 0
assira.lambda/src/main/java/net/ranides/assira/reflection/LamdaReflect.java

@@ -0,0 +1,19 @@
+package net.ranides.assira.reflection;
+
+import net.ranides.assira.annotations.Meta;
+import net.ranides.assira.reflection.impl.LMethodFactory;
+
+@Meta.UnstableAPI
+//@Deprecated(forRemoval=true)
+public class LamdaReflect {
+
+    /**
+     * Collect information for lambda expression
+     * @param object
+     * @return
+     */
+    static IMethod typeinfo(Object object) {
+        return LMethodFactory.typeinfo(object);
+    }
+
+}

+ 4 - 3
assira/src/main/java/net/ranides/assira/reflection/impl/CPInspector.java

@@ -6,6 +6,10 @@
  */
 package net.ranides.assira.reflection.impl;
 
+import net.ranides.assira.collection.iterators.ForwardSpliterator;
+import net.ranides.assira.reflection.util.MethodUtils;
+import net.ranides.assira.trace.ExceptionUtils;
+
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -13,9 +17,6 @@ import java.util.function.Consumer;
 import java.util.function.IntFunction;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
-import net.ranides.assira.collection.iterators.ForwardSpliterator;
-import net.ranides.assira.reflection.util.MethodUtils;
-import net.ranides.assira.trace.ExceptionUtils;
 
 /**
  *

assira/src/main/java/net/ranides/assira/reflection/impl/LMethod.java → assira.lambda/src/main/java/net/ranides/assira/reflection/impl/LMethod.java


+ 43 - 0
assira.lambda/src/main/java/net/ranides/assira/reflection/impl/LMethodFactory.java

@@ -0,0 +1,43 @@
+package net.ranides.assira.reflection.impl;
+
+import net.ranides.assira.collection.maps.CacheMap;
+import net.ranides.assira.reflection.IClass;
+import net.ranides.assira.reflection.IContext;
+import net.ranides.assira.reflection.IMethod;
+
+import java.util.List;
+
+import static net.ranides.assira.reflection.IAttribute.*;
+
+public class LMethodFactory {
+
+    private static final CacheMap<Object, IMethod> FUNCTIONS = CacheMap.getInstance(LMethodFactory::inewFunction);
+
+    /**
+     * Collect information for lambda expression
+     * @param object
+     * @return
+     */
+    public static IMethod typeinfo(Object object) {
+        return FUNCTIONS.get(object);
+    }
+
+    private static IMethod inewFunction(Object object) {
+        IClass<?> type = IClass.typefor(object);
+        if(type.attributes().contains(SYNTHETIC)) {
+            List<IMethod> methods = type.methods().require(DECLARED).discard(STATIC).list();
+            if(1 == methods.size()) {
+                return new LMethod(methods.get(0), object);
+            }
+        }
+
+        int methods = type.interfaces().methods().require(ABSTRACT).stream().distinct().size();
+        if(1 == methods ) {
+            IMethod m = type.methods().require(DECLARED).discard(SYNTHETIC).discard(BRIDGE).first().get();
+            return new RMethod(true, IContext.DEFAULT, m.reflective(), object);
+        }
+
+        throw new IllegalArgumentException(type + " is not lambda");
+    }
+
+}

+ 370 - 0
assira.lambda/src/test/java/net/ranides/assira/reflection/LamdaReflectTest.java

@@ -0,0 +1,370 @@
+package net.ranides.assira.reflection;
+
+import net.ranides.assira.generic.TypeToken;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Set;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+import static net.ranides.assira.junit.NewAssert.assertThrows;
+import static net.ranides.assira.reflection.IAttribute.*;
+import static org.junit.Assert.assertEquals;
+
+public class LamdaReflectTest {
+
+    public static final IClass<?> STRING = IClass.typeinfo(String.class);
+
+    public static final IClass<?> CHARACTER = IClass.typeinfo(Character.class);
+
+    public static final IClass<?> P_VOID = IClass.typeinfo(void.class);
+
+    public static final IClass<?> FLOAT = IClass.typeinfo(Float.class);
+
+    public static final IClass<?> IFLOAT_ARRAY = IClass.typeinfo(float[].class);
+
+    public static final IClass<?> FLOAT_ARRAY = IClass.typeinfo(Float[].class);
+
+    public static final IClass<?> INT_ARRAY = IClass.typeinfo(int[].class);
+
+    public static final IClass<?> OBJECT = IClass.OBJECT;
+
+    Set<IAttribute> ATTR_LAMBDA = IAttribute.collect(PUBLIC, STATIC, DECLARED, SYNTHETIC, LAMBDA);
+
+    Set<IAttribute> ATTR_FUNCTOR = IAttribute.collect(PUBLIC, DECLARED);
+
+    int                                  _value1    = 1;
+    int[]                                _array2    = new int[]{1,2,3,4,5};
+    Function<String, Character>          _function1 = s -> s.charAt(1);
+    Function<String, Character>          _function2 = s -> s.charAt(_array2[_value1]);
+    BiFunction<String, Float, Character> _function3 = (a, b) -> a.charAt(b.intValue());
+    Supplier<Character>                  _function4 = () -> 'z';
+    Runnable                             _function5 = () -> { };
+
+    @Test
+    public void testInvalidLambda() {
+        assertThrows(IllegalArgumentException.class, ()->{
+            LamdaReflect.typeinfo("Hello world");
+        });
+    }
+
+    @Test
+    public void testLambda() {
+        int value1 = 1;
+        int[] array2 = new int[]{1,2,3,4,5};
+        Function<String, Character> function1 = s -> s.charAt(1);
+        Function<String, Character> function2 = s -> s.charAt(array2[value1]);
+        BiFunction<String, Float, Character> function3 = (a,b) -> a.charAt(b.intValue());
+        Supplier<Character> function4 = () -> 'z';
+        Runnable function5 = () -> { };
+
+        // signature
+        assertFunction0(function1, CHARACTER, STRING);
+        assertFunction0(function2, CHARACTER, STRING);
+
+        assertFunction1(function1, CHARACTER, STRING);
+        assertFunction1(function2, CHARACTER, STRING);
+
+        assertFunction2(function1, CHARACTER, STRING);
+        assertFunction2(function2, CHARACTER, STRING);
+        assertFunction2(function3, CHARACTER, STRING, FLOAT);
+        assertFunction2(function4, CHARACTER);
+        assertFunction2(function5, P_VOID);
+
+        testAPI(ATTR_LAMBDA, function1, function2, function3, function4, function5);
+        testLambdaCall(function1, function2, function3, function4, function5);
+    }
+
+    @Test
+    public void testMember() {
+
+        // signature
+        assertFunction0(_function1, CHARACTER, STRING);
+        assertFunction0(_function2, CHARACTER, STRING);
+
+        assertFunction1(_function1, CHARACTER, STRING);
+        assertFunction1(_function2, CHARACTER, STRING);
+
+        assertFunction2(_function1, CHARACTER, STRING);
+        assertFunction2(_function2, CHARACTER, STRING);
+        assertFunction2(_function3, CHARACTER, STRING, FLOAT);
+        assertFunction2(_function4, CHARACTER);
+        assertFunction2(_function5, P_VOID);
+
+        testAPI(ATTR_LAMBDA, _function1, _function2, _function3, _function4, _function5);
+        testLambdaCall(_function1, _function2, _function3, _function4, _function5);
+    }
+
+    @Test
+    public void testFromFunctor() {
+        int value1 = 1;
+        int[] array2 = new int[]{1,2,3,4,5};
+        @SuppressWarnings("Convert2Lambda")
+        Function<String, Character> function1 = new Function<String, Character>(){
+            @Override
+            public Character apply(String s) {
+                return s.charAt(1);
+            }
+        };
+        @SuppressWarnings("Convert2Lambda")
+        Function<String, Character> function2 = new Function<String, Character>() {
+            @Override
+            public Character apply(String s) {
+                return s.charAt(array2[value1]);
+            }
+        };
+        @SuppressWarnings("Convert2Lambda")
+        BiFunction<String, Float, Character> function3 = new BiFunction<String, Float, Character>() {
+            @Override
+            public Character apply(String a, Float b) {
+                return a.charAt(b.intValue());
+            }
+        };
+        @SuppressWarnings("Convert2Lambda")
+        Supplier<Character> function4 = new Supplier<Character>() {
+            @Override
+            public Character get() {
+                return 'z';
+            }
+        };
+        @SuppressWarnings("Convert2Lambda")
+        Runnable function5 = new Runnable() {
+            @Override
+            public void run() {
+                // do nothing
+            }
+        };
+
+        // signature
+        assertFunction0(function1, CHARACTER, STRING);
+        assertFunction0(function2, CHARACTER, STRING);
+
+        assertFunction1(function1, CHARACTER, STRING);
+        assertFunction1(function2, CHARACTER, STRING);
+
+        assertFunction2(function1, CHARACTER, STRING);
+        assertFunction2(function2, CHARACTER, STRING);
+        assertFunction2(function3, CHARACTER, STRING, FLOAT);
+        assertFunction2(function4, CHARACTER);
+        assertFunction2(function5, P_VOID);
+
+        testAPI(ATTR_FUNCTOR, function1, function2, function3, function4, function5);
+        testFunctorCall(function1, function2, function3, function4, function5);
+    }
+
+    @Test
+    public void testInline() {
+        assertFunction0((int[] array) -> 5.7f, FLOAT, INT_ARRAY);
+        assertFunction0((int[] array) -> new float[2], IFLOAT_ARRAY, INT_ARRAY);
+        assertFunction0((int[] array) -> new Float[2], FLOAT_ARRAY, INT_ARRAY);
+
+        assertFunction1((int[] array) -> 5.7f, OBJECT, INT_ARRAY);
+        assertFunction1((int[] array) -> null, OBJECT, INT_ARRAY);
+        assertFunction1((String array) -> new Float[2], OBJECT, STRING);
+    }
+
+    @Test
+    public void testInlineCall() {
+        IMethod m21 = LamdaReflect.typeinfo(pass2((Integer a) -> 3*a));
+        IMethod m11 = LamdaReflect.typeinfo(pass1((Integer a) -> 3*a));
+
+        assertEquals(24, m21.call(8));
+        assertEquals(24, m21.invoke(null, 8));
+        assertThrows(IllegalArgumentException.class, ()->{
+            m21.invoke(m21, 8);
+        });
+
+        assertEquals(24, m11.call(8));
+        assertEquals(24, m11.invoke(null, 8));
+        assertThrows(IllegalArgumentException.class, ()->{
+            m21.invoke(m11, 8);
+        });
+
+    }
+
+    @Test
+    public void testToFunctorLambda() {
+        MTFunction.Lame f1 = (a,b,c) -> a.intValue() + b + c;
+        MTFunction.LameLong f2 = (a,b,c) -> (int)a + b + c;
+
+        IMethod m1 = LamdaReflect.typeinfo(f1);
+        IMethod m2 = LamdaReflect.typeinfo(f2);
+
+        MTFunction<Long> g1 = m1.handle(new TypeToken<MTFunction<Long>>(){});
+        MTFunction<Long> g2 = m2.handle(new TypeToken<MTFunction<Long>>(){});
+
+        assertEquals(503, g1.calculate(500L, 1, 2));
+        assertEquals(607, g2.calculate(600L, 3, 4));
+    }
+
+    private void testAPI(Set<IAttribute> exp, Object function1, Object function2, Object function3, Object function4, Object function5) {
+        IMethod m1 = LamdaReflect.typeinfo(function1);
+        IMethod m2 = LamdaReflect.typeinfo(function2);
+        IMethod m3 = LamdaReflect.typeinfo(function3);
+        IMethod m4 = LamdaReflect.typeinfo(function4);
+        IMethod m5 = LamdaReflect.typeinfo(function5);
+
+        // name
+        assertEquals("apply", m1.name());
+        assertEquals("apply", m2.name());
+        assertEquals("apply", m3.name());
+        assertEquals("get", m4.name());
+        assertEquals("run", m5.name());
+
+        // attributes
+        assertEquals(exp, m1.attributes());
+        assertEquals(exp, m2.attributes());
+        assertEquals(exp, m3.attributes());
+        assertEquals(exp, m4.attributes());
+        assertEquals(exp, m5.attributes());
+
+        // parent
+        assertEquals(IClass.typefor(function1), m1.parent());
+        assertEquals(IClass.typefor(function2), m2.parent());
+        assertEquals(IClass.typefor(function3), m3.parent());
+        assertEquals(IClass.typefor(function4), m4.parent());
+        assertEquals(IClass.typefor(function5), m5.parent());
+
+        // reflective
+        assertEquals(m1.name(), m1.reflective().getName());
+        assertEquals(m2.name(), m2.reflective().getName());
+        assertEquals(m3.name(), m3.reflective().getName());
+        assertEquals(m4.name(), m4.reflective().getName());
+        assertEquals(m5.name(), m5.reflective().getName());
+
+        // params
+        assertEquals(0, m1.params().size());
+        assertEquals(0, m2.params().size());
+        assertEquals(0, m3.params().size());
+        assertEquals(0, m4.params().size());
+        assertEquals(0, m5.params().size());
+
+        // annotations
+        assertEquals(0, count(m1.annotations()));
+        assertEquals(0, count(m2.annotations()));
+        assertEquals(0, count(m3.annotations()));
+        assertEquals(0, count(m4.annotations()));
+        assertEquals(0, count(m5.annotations()));
+    }
+
+    private static int count(IAnnotations list) {
+        return list.discard(a -> a.annotationType().getName().equals("java.lang.invoke.LambdaForm$Hidden")).count();
+    }
+
+    private void testLambdaCall(Object function1, Object function2, Object function3, Object function4, Object function5) {
+        IMethod m1 = LamdaReflect.typeinfo(function1);
+        IMethod m2 = LamdaReflect.typeinfo(function2);
+        IMethod m3 = LamdaReflect.typeinfo(function3);
+        IMethod m4 = LamdaReflect.typeinfo(function4);
+        IMethod m5 = LamdaReflect.typeinfo(function5);
+
+        // call
+        assertEquals('e', m1.call("hello!"));
+        assertEquals('e', m1.invoke(null, "hello!"));
+        assertThrows(IllegalArgumentException.class, ()->{
+            m1.invoke(new Object(), "hello!");
+        });
+        assertThrows(IllegalArgumentException.class, ()->{
+            m1.invoke(new Object());
+        });
+        assertThrows(ClassCastException.class, ()->{
+            m1.call(888);
+        });
+
+        assertEquals('r', m2.call("world!"));
+        assertEquals('r', m2.invoke(null, "world!"));
+
+        assertEquals('o', m3.call("hello!", 4.1f));
+        assertEquals('o', m3.invoke(null, "hello!", 4.1f));
+
+        assertEquals('z', m4.call());
+        assertEquals('z', m4.invoke());
+        assertEquals('z', m4.invoke(null));
+
+        assertEquals(null, m5.call());
+        assertEquals(null, m5.invoke());
+        assertEquals(null, m5.invoke(null));
+    }
+
+    private void testFunctorCall(Object function1, Object function2, Object function3, Object function4, Object function5) {
+        IMethod m1 = LamdaReflect.typeinfo(function1);
+        IMethod m2 = LamdaReflect.typeinfo(function2);
+        IMethod m3 = LamdaReflect.typeinfo(function3);
+        IMethod m4 = LamdaReflect.typeinfo(function4);
+        IMethod m5 = LamdaReflect.typeinfo(function5);
+
+        // call
+        assertEquals('e', m1.call("hello!"));
+        assertEquals('e', m1.invoke(function1, "hello!"));
+        assertThrows(IllegalArgumentException.class, ()->{
+            m1.invoke(new Object(), "hello!");
+        });
+        assertThrows(IllegalArgumentException.class, ()->{
+            m1.invoke(new Object());
+        });
+        assertThrows(ClassCastException.class, ()->{
+            m1.call(888);
+        });
+
+        assertEquals('r', m2.call("world!"));
+        assertEquals('r', m2.invoke(function2, "world!"));
+
+        assertEquals('o', m3.call("hello!", 4.1f));
+        assertEquals('o', m3.invoke(function3, "hello!", 4.1f));
+
+        assertEquals('z', m4.call());
+        assertThrows(IllegalArgumentException.class, ()->{
+            m4.invoke();
+        });
+
+        assertEquals('z', m4.invoke(function4));
+
+        assertEquals(null, m5.call());
+        assertThrows(IllegalArgumentException.class, ()->{
+            m5.invoke();
+        });
+        assertEquals(null, m5.invoke(function5));
+    }
+
+    private <T,R> void assertFunction0(Function<T,R> function, IClass<?> ret, IClass<?>... args) {
+        assertFunction2(function, ret, args);
+    }
+
+    private <T,R> Function<?,?> pass2(Function<?,?> function) {
+        return function;
+    }
+
+    private Function<?,?> pass1(Function<?,?> function) {
+        return function;
+    }
+
+    private void assertFunction1(Function<?,?> function, IClass<?> ret, IClass<?>... args) {
+        assertFunction2(function, ret, args);
+    }
+
+    private void assertFunction2(Object function, IClass<?> ret, IClass<?>... args) {
+        IMethod m = LamdaReflect.typeinfo(function);
+
+//        Class<?> type = function.getClass();
+//        System.out.printf(">>>> %s -> %s%n", m.arguments().types(), m.returns());
+//        CPInspector.getConstructors(type).forEach(v -> {
+//            System.out.printf(" - c: %s%n", v);
+//        });
+//        CPInspector.getMethods(type).forEach(v -> {
+//            System.out.printf(" - m: %s%n", v);
+//        });
+//        IClass.typefor(function).methods().require(IAttribute.DECLARED).each(v -> {
+//            System.out.printf(" - s: %s%n", v);
+//        });
+//        System.out.printf("%n");
+
+        assertEquals(ret, m.returns());
+        assertEquals(Arrays.asList(args), m.arguments().types().list());
+
+    }
+
+
+
+}

+ 58 - 0
assira.lambda/src/test/java/net/ranides/assira/reflection/MTFunction.java

@@ -0,0 +1,58 @@
+/*
+ * @author Ranides Atterwim <ranides@gmail.com>
+ * @copyright Ranides Atterwim
+ * @license WTFPL
+ * @url http://ranides.net/projects/assira
+ */
+package net.ranides.assira.reflection;
+
+import net.ranides.assira.generic.TypeToken;
+
+/**
+ *
+ * @author Ranides Atterwim <ranides@gmail.com>
+ */
+public interface MTFunction<T> {
+    
+//    IClass<MTFunction<MTRecord>> GENERIC = new TypeToken<MTFunction<MTRecord>>(){};
+    
+    IClass<MTFunction> RAW = new TypeToken<MTFunction>(){};
+    
+    int calculate(T action, int a, int b);
+    
+//    class MTRecord {
+//
+//        private final int seed;
+//
+//        public MTRecord(int seed) {
+//            this.seed = seed;
+//        }
+//
+//        public int sum(int a, int b) {
+//            return seed+a+b;
+//        }
+//
+//        public int mul(int a, int b) {
+//            return seed+a*b;
+//        }
+//
+//    }
+//
+//    interface Generator {
+//
+//        MTRecord build(int value);
+//
+//    }
+//
+    interface Lame {
+
+        int run(Long a, int b, int c);
+
+    }
+
+    interface LameLong {
+
+        int run(long a, int b, int c);
+
+    }
+}

+ 88 - 97
assira/src/test/java/net/ranides/assira/reflection/impl/CPInspectorTest.java

@@ -1,11 +1,7 @@
-/*
- * @author Ranides Atterwim <ranides@gmail.com>
- * @copyright Ranides Atterwim
- * @license WTFPL
- * @url http://ranides.net/projects/assira
- */
 package net.ranides.assira.reflection.impl;
 
+import org.junit.Test;
+
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -16,151 +12,146 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import org.junit.Test;
-import static net.ranides.assira.junit.NewAssert.*;
-import net.ranides.assira.reflection.mockup.ForCPInspector;
+import static org.junit.Assert.*;
 
-/**
- *
- * @author Ranides Atterwim <ranides@gmail.com>
- */
 public class CPInspectorTest {
-	
+
     /**
      * Metoda "main" służy do sprawdzenia, jak sytuacja wygląda przy włączonym JRebel.
      * NetBeans z zainstalowanym pluginem JRebel uruchamia #main z włączonym JRebelem.
      * Sprawdzamy to, ponieważ JRebel dorzuca własne metody, które są widoczne w ConstantPool
      * i mogą nam one zepsuć inspektora.
-     * 
-     * @param args 
+     *
+     * @param args
      */
-	public static void main(String[] args) {
+    public static void main(String[] args) {
         System.out.printf("methods:%n");
         CPInspector.getMethods(ForCPInspector.class)
-            .map(v -> "   - " + v)
-            .forEach(System.out::println);
-        
+                .map(v -> "   - " + v)
+                .forEach(System.out::println);
+
         System.out.printf("fields:%n");
         CPInspector.getFields(ForCPInspector.class)
-            .map(v -> "   - " + v)
-            .forEach(System.out::println);
-        
+                .map(v -> "   - " + v)
+                .forEach(System.out::println);
+
         System.out.printf("classes:%n");
         CPInspector.getClasses(ForCPInspector.class)
-            .map(v -> "   - " + v.getName())
-            .forEach(System.out::println);
-	}
-    
+                .map(v -> "   - " + v.getName())
+                .forEach(System.out::println);
+    }
+
     @Test
     public void testFields() {
         int value = 1;
-		int[] array = new int[]{1,2,3,4,5};
-		Function<String, Character> function1 = s -> s.charAt(array[value]);
+        int[] array = new int[]{1,2,3,4,5};
+        Function<String, Character> function1 = s -> s.charAt(array[value]);
         assertFields(Arrays.asList("arg$1", "arg$2"), CPInspector.getFields(type0(function1)));
 
 //        CPInspector.getMethods(ForCPInspector.class).forEach(System.out::println);
 //        CPInspector.getFields(ForCPInspector.class).forEach(System.out::println);
 //        CPInspector.getClasses(ForCPInspector.class).map(Class::getSimpleName).forEach(System.out::println);
-        
+
         assertFields(Arrays.asList("S2", "index", "listener"), CPInspector.getFields(ForCPInspector.class));
         assertMethods(Arrays.asList("toUpperCase","length","handleEvent"), CPInspector.getMethods(ForCPInspector.class));
         assertClasses(Arrays.asList("ForCPInspector","EventListener","String"), CPInspector.getClasses(ForCPInspector.class));
     }
-	
-	@Test
-	public void testMethods() {
-
-		assertReturns(Float.class, CPInspector.getMethods(type1((int[] array) -> 5.7f)));
-		assertReturns(float[].class, CPInspector.getMethods(type1((int[] array) -> new float[2])));
-		assertReturns(Float[].class, CPInspector.getMethods(type1((int[] array) -> new Float[2])));
-		
-		assertReturns(Object.class, CPInspector.getMethods(type2((int[] array) -> 5.7f)));
-		assertReturns(Object.class, CPInspector.getMethods(type2((int[] array) -> new float[2])));
-		assertReturns(Object.class, CPInspector.getMethods(type2((int[] array) -> new Float[2])));
-		
-		int value = 1;
-		int[] array = new int[]{1,2,3,4,5};
-		Function<String, Character> function1 = s -> ' ';
-		Function<String, Character> function2 = s -> s.charAt(array[value]);
-		
-		assertReturns(Character.class, CPInspector.getMethods(type2(function1)));
-		assertReturns(Character.class, CPInspector.getMethods(type2(function2)));
-		assertReturns(Character.class, CPInspector.getMethods(type1((String s) -> s.charAt(array[value]))));
-
-	}
-    
+
     @Test
-	public void testConstructor() {
+    public void testMethods() {
+
+        assertReturns(Float.class, CPInspector.getMethods(type1((int[] array) -> 5.7f)));
+        assertReturns(float[].class, CPInspector.getMethods(type1((int[] array) -> new float[2])));
+        assertReturns(Float[].class, CPInspector.getMethods(type1((int[] array) -> new Float[2])));
+
+        assertReturns(Object.class, CPInspector.getMethods(type2((int[] array) -> 5.7f)));
+        assertReturns(Object.class, CPInspector.getMethods(type2((int[] array) -> new float[2])));
+        assertReturns(Object.class, CPInspector.getMethods(type2((int[] array) -> new Float[2])));
+
+        int value = 1;
+        int[] array = new int[]{1,2,3,4,5};
+        Function<String, Character> function1 = s -> ' ';
+        Function<String, Character> function2 = s -> s.charAt(array[value]);
+
+        assertReturns(Character.class, CPInspector.getMethods(type2(function1)));
+        assertReturns(Character.class, CPInspector.getMethods(type2(function2)));
+        assertReturns(Character.class, CPInspector.getMethods(type1((String s) -> s.charAt(array[value]))));
+
+    }
+
+    @Test
+    public void testConstructor() {
         Class<?>[] NONE = new Class<?>[0];
 
-		assertConstructors(NONE, CPInspector.getConstructors(type1((int[] array) -> 5.7f)));
-		assertConstructors(NONE, CPInspector.getConstructors(type1((int[] array) -> new float[2])));
-		assertConstructors(NONE, CPInspector.getConstructors(type1((int[] array) -> new Float[2])));
-		
-		assertConstructors(NONE, CPInspector.getConstructors(type2((int[] array) -> 5.7f)));
-		assertConstructors(NONE, CPInspector.getConstructors(type2((int[] array) -> new float[2])));
-		assertConstructors(NONE, CPInspector.getConstructors(type2((int[] array) -> new Float[2])));
-		
-		int value = 1;
-		int[] array = new int[]{1,2,3,4,5};
-		long[] array2 = new long[]{1,2,3,4,5};
+        assertConstructors(NONE, CPInspector.getConstructors(type1((int[] array) -> 5.7f)));
+        assertConstructors(NONE, CPInspector.getConstructors(type1((int[] array) -> new float[2])));
+        assertConstructors(NONE, CPInspector.getConstructors(type1((int[] array) -> new Float[2])));
+
+        assertConstructors(NONE, CPInspector.getConstructors(type2((int[] array) -> 5.7f)));
+        assertConstructors(NONE, CPInspector.getConstructors(type2((int[] array) -> new float[2])));
+        assertConstructors(NONE, CPInspector.getConstructors(type2((int[] array) -> new Float[2])));
+
+        int value = 1;
+        int[] array = new int[]{1,2,3,4,5};
+        long[] array2 = new long[]{1,2,3,4,5};
         char value2 = 'z';
-        
-		Function<String, Character> function1 = s -> ' ';
-		Function<String, Character> function2 = s -> s.charAt(array[value]);
-		Function<String, Character> function3 = s -> s.charAt((int)array2[value2]);
-        
+
+        Function<String, Character> function1 = s -> ' ';
+        Function<String, Character> function2 = s -> s.charAt(array[value]);
+        Function<String, Character> function3 = s -> s.charAt((int)array2[value2]);
+
         Class<?>[] exp1 = new Class<?>[]{int[].class, int.class};
         Class<?>[] exp2 = new Class<?>[]{long[].class, char.class};
-		
-		assertConstructors(NONE, CPInspector.getConstructors(type2(function1)));
-		assertConstructors(exp1, CPInspector.getConstructors(type2(function2)));
-		assertConstructors(exp1, CPInspector.getConstructors(type1((String s) -> s.charAt(array[value]))));
-		
+
+        assertConstructors(NONE, CPInspector.getConstructors(type2(function1)));
+        assertConstructors(exp1, CPInspector.getConstructors(type2(function2)));
+        assertConstructors(exp1, CPInspector.getConstructors(type1((String s) -> s.charAt(array[value]))));
+
         assertConstructors(exp2, CPInspector.getConstructors(type2(function3)));
-		assertConstructors(exp2, CPInspector.getConstructors(type1((String s) -> s.charAt((int)array2[value2]))));
+        assertConstructors(exp2, CPInspector.getConstructors(type1((String s) -> s.charAt((int)array2[value2]))));
+
+    }
 
-	}
-    
     private static void assertClasses(List<String> names, Stream<Class<?>> stream) {
         assertTrue("some types not found",stream.map(Class::getSimpleName).collect(Collectors.toSet()).containsAll(names));
     }
-    
+
     private static void assertMethods(List<String> names, Stream<Method> stream) {
         assertTrue("some methods not found",stream.map(Method::getName).collect(Collectors.toSet()).containsAll(names));
     }
-    
+
     private static void assertFields(List<String> names, Stream<Field> stream) {
         assertTrue("some fields not found", stream.map(Field::getName).collect(Collectors.toSet()).containsAll(names) );
     }
-    
+
     private static void assertReturns(Class<?> type, Stream<Method> stream) {
         Optional<Method> method = stream.findFirst();
         assertTrue("method not found", method.isPresent());
         assertEquals(type, method.get().getReturnType());
     }
-	
+
     private static <T> void assertConstructors(Class<?>[] types, Stream<Constructor<T>> stream) {
         List<Constructor<T>> list = stream.collect(Collectors.toList());
 
         assertTrue(list.stream().anyMatch(c -> {
             return "public java.lang.Object()".equals(c.toString());
-        }));        
+        }));
         assertTrue(list.stream().anyMatch(c -> {
             return Arrays.equals(types, c.getParameterTypes());
         }));
     }
-    
-	private static Class<?> type0(Object object) {
-		return object.getClass();
-	}
-	
-	private static <T,R> Class<?> type1(Function<T,R> object) {
-		return object.getClass();
-	}
-	
-	private static Class<?> type2(Function<?,?> object) {
-		return object.getClass();
-	}
-	
-}
+
+    private static Class<?> type0(Object object) {
+        return object.getClass();
+    }
+
+    private static <T,R> Class<?> type1(Function<T,R> object) {
+        return object.getClass();
+    }
+
+    private static Class<?> type2(Function<?,?> object) {
+        return object.getClass();
+    }
+
+
+}

+ 1 - 4
assira/src/test/java/net/ranides/assira/reflection/mockup/ForCPInspector.java

@@ -4,9 +4,8 @@
  * @license WTFPL
  * @url http://ranides.net/projects/assira
  */
-package net.ranides.assira.reflection.mockup;
+package net.ranides.assira.reflection.impl;
 
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import net.ranides.assira.events.Event;
 import net.ranides.assira.events.EventListener;
 
@@ -14,8 +13,6 @@ import net.ranides.assira.events.EventListener;
  *
  * @author Ranides Atterwim <ranides@gmail.com>
  */
-@SuppressWarnings("PMD")
-@SuppressFBWarnings
 public class ForCPInspector {
     
     private static final int S1 = 17;

+ 0 - 3
assira/pom.xml

@@ -76,8 +76,6 @@
                         <argument>-Xlint:unchecked</argument>
                         <argument>-Xlint:removal</argument>
                         <argument>-parameters</argument>
-                        <argument>--add-exports</argument>
-                        <argument>java.base/jdk.internal.reflect=ALL-UNNAMED</argument>
                     </compilerArgs>
                 </configuration>
             </plugin>
@@ -86,7 +84,6 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                     <excludedGroups>net.ranides.assira.junit.JCategories$Slow,net.ranides.assira.junit.JCategories$UnstableTest</excludedGroups>
-                    <argLine>--add-exports java.base/jdk.internal.reflect=ALL-UNNAMED</argLine>
                 </configuration>
             </plugin>
             <plugin>

+ 1 - 12
assira/src/main/java/net/ranides/assira/reflection/IMethod.java

@@ -24,18 +24,7 @@ public interface IMethod extends IExecutable {
     static IMethod typeinfo(Method method) {
         return FMethod.newMethod(method);
     }
-    
-    /**
-     * Collect information for lambda expression
-     * @param object
-     * @return 
-     */
-    @Meta.UnstableAPI
-    @Deprecated(forRemoval=true)
-    static IMethod function(Object object) {
-        return FMethod.newFunction(object);
-    }
-    
+
     @Override
     IMethods collect();
 

+ 3 - 10
assira/src/main/java/net/ranides/assira/reflection/IMethods.java

@@ -6,15 +6,14 @@
  */
 package net.ranides.assira.reflection;
 
+import net.ranides.assira.collection.query.CQuery;
+import net.ranides.assira.reflection.impl.FElements;
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.Set;
 import java.util.function.Predicate;
 
-import net.ranides.assira.annotations.Meta;
-import net.ranides.assira.collection.query.CQuery;
-import net.ranides.assira.reflection.impl.FElements;
-
 /**
  *
  * @author Ranides Atterwim <ranides@gmail.com>
@@ -25,12 +24,6 @@ public interface IMethods extends IExecutables<IMethod> {
         return FElements.newMethods(methods);
     }
 
-    @Meta.UnstableAPI
-    @Deprecated(forRemoval=true)
-    static IMethods function(Object... objects) {
-        return FElements.newFunctions(objects);
-    }
-
     @Override
     IMethods require(Predicate<? super IMethod> predicate);
 

+ 6 - 24
assira/src/main/java/net/ranides/assira/reflection/impl/FElements.java

@@ -7,29 +7,17 @@
 
 package net.ranides.assira.reflection.impl;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import net.ranides.assira.annotations.Meta;
 import net.ranides.assira.collection.maps.OrderedMap;
 import net.ranides.assira.collection.query.CQuery;
 import net.ranides.assira.collection.query.CQueryBuilder;
-import net.ranides.assira.reflection.IAnnotations;
-import net.ranides.assira.reflection.IArgument;
-import net.ranides.assira.reflection.IArguments;
-import net.ranides.assira.reflection.IAttribute;
-import net.ranides.assira.reflection.IClass;
-import net.ranides.assira.reflection.IConstructor;
-import net.ranides.assira.reflection.IExecutable;
-import net.ranides.assira.reflection.IField;
-import net.ranides.assira.reflection.IFields;
-import net.ranides.assira.reflection.IHints;
-import net.ranides.assira.reflection.IMethod;
-import net.ranides.assira.reflection.IMethods;
+import net.ranides.assira.reflection.*;
 import net.ranides.assira.reflection.util.AnnotationUtils;
 
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
 /**
  *
  * @author Ranides Atterwim <ranides@gmail.com>
@@ -114,11 +102,5 @@ public final class FElements {
     public static <T> AExecutables newExecutables(Constructor<T>... methods) {
         return newExecutables(AHints.EMPTY, CQueryBuilder.fromArray(methods).map(IConstructor::typeinfo));
     }
-
-    @Meta.UnstableAPI
-    @Deprecated(forRemoval=true)
-    public static IMethods newFunctions(Object... objects) {
-        return newMethods(AHints.EMPTY, CQueryBuilder.fromArray(objects).map(IMethod::function));
-    }
     
 }

+ 3 - 37
assira/src/main/java/net/ranides/assira/reflection/impl/FMethod.java

@@ -7,19 +7,10 @@
 
 package net.ranides.assira.reflection.impl;
 
+import net.ranides.assira.reflection.*;
+
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
-import java.util.List;
-
-import net.ranides.assira.annotations.Meta;
-import net.ranides.assira.collection.maps.CacheMap;
-import static net.ranides.assira.reflection.IAttribute.*;
-
-import net.ranides.assira.reflection.IClass;
-import net.ranides.assira.reflection.IConstructor;
-import net.ranides.assira.reflection.IContext;
-import net.ranides.assira.reflection.IExecutable;
-import net.ranides.assira.reflection.IMethod;
 
 /**
  *
@@ -29,8 +20,7 @@ public final class FMethod {
     
     private static final FCache<IExecutable> D_METHODS = new FCache<>();
     private static final FCache<IExecutable> R_METHODS = new FCache<>();
-    private static final CacheMap<Object, IMethod> FUNCTIONS = CacheMap.getInstance(FMethod::inewFunction);
-    
+
     private FMethod() {
         /* utility class */
     }
@@ -53,29 +43,5 @@ public final class FMethod {
         IContext c = IClass.typeinfo(method.getDeclaringClass()).context();
         return FMethod.newConstructor(c, method);
     }
-
-    @Meta.UnstableAPI
-    @Deprecated(forRemoval=true)
-    public static IMethod newFunction(Object object) {
-        return FUNCTIONS.get(object);
-    }
-    
-    private static IMethod inewFunction(Object object) {
-        IClass<?> type = IClass.typefor(object);
-        if(type.attributes().contains(SYNTHETIC)) {
-            List<IMethod> methods = type.methods().require(DECLARED).discard(STATIC).list();
-            if(1 == methods.size()) {
-                return new LMethod(methods.get(0), object);
-            }
-        }
-        
-        int methods = type.interfaces().methods().require(ABSTRACT).stream().distinct().size();
-        if(1 == methods ) {
-            IMethod m = type.methods().require(DECLARED).discard(SYNTHETIC).discard(BRIDGE).first().get();
-            return new RMethod(true, IContext.DEFAULT, m.reflective(), object);
-        }
-        
-        throw new IllegalArgumentException(type + " is not lambda");
-    }
     
 }

+ 1 - 1
assira/src/test/java/net/ranides/assira/io/uri/impl/CFileHandlerTest.java

@@ -88,7 +88,7 @@ public class CFileHandlerTest {
         ));
         assertEquals("Hello world", IOStrings.read(handle6.reader()));
 
-        assertEquals(18, handle1.scan().size());
+        assertEquals(19, handle1.scan().size());
         assertEquals(Arrays.asList("indir","text"), handle3.parent().parent().scan().map(f-> asName(f)).sort().list());
         assertEquals(Arrays.asList("info.txt"), handle2.scan().map(f-> asName(f)).sort().list());
         assertThrows(IOException.class, ()->{

+ 3 - 346
assira/src/test/java/net/ranides/assira/reflection/IMethodTest.java

@@ -6,18 +6,12 @@
  */
 package net.ranides.assira.reflection;
 
-import java.util.Arrays;
-import java.util.Set;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Supplier;
 import net.ranides.assira.generic.TypeToken;
-import static net.ranides.assira.reflection.IAttribute.*;
-import static net.ranides.assira.reflection.mockup.ForIClass.*;
-import org.junit.Test;
-import static net.ranides.assira.junit.NewAssert.*;
 import net.ranides.assira.reflection.mockup.MTFunction;
 import net.ranides.assira.reflection.mockup.MTFunction.MTRecord;
+import org.junit.Test;
+
+import static net.ranides.assira.junit.NewAssert.assertEquals;
 
 /**
  *
@@ -25,160 +19,6 @@ import net.ranides.assira.reflection.mockup.MTFunction.MTRecord;
  */
 @SuppressWarnings("ALL")
 public class IMethodTest {
-    
-    Set<IAttribute> ATTR_LAMBDA = IAttribute.collect(PUBLIC, STATIC, DECLARED, SYNTHETIC, LAMBDA);
-    
-    Set<IAttribute> ATTR_FUNCTOR = IAttribute.collect(PUBLIC, DECLARED);
-    
-    int _value1 = 1;
-    int[] _array2 = new int[]{1,2,3,4,5};
-    Function<String, Character> _function1 = s -> s.charAt(1);
-    Function<String, Character> _function2 = s -> s.charAt(_array2[_value1]);
-    BiFunction<String, Float, Character> _function3 = (a,b) -> a.charAt(b.intValue());
-    Supplier<Character> _function4 = () -> 'z';
-    Runnable _function5 = () -> { };
-    
-    @Test
-    public void testInvalidLambda() {
-        assertThrows(IllegalArgumentException.class, ()->{
-            IMethod.function("Hello world");
-        });
-    }
-    
-    @Test
-    public void testLambda() {
-        int value1 = 1;
-		int[] array2 = new int[]{1,2,3,4,5};
-		Function<String, Character> function1 = s -> s.charAt(1);
-		Function<String, Character> function2 = s -> s.charAt(array2[value1]);
-		BiFunction<String, Float, Character> function3 = (a,b) -> a.charAt(b.intValue());
-        Supplier<Character> function4 = () -> 'z';
-        Runnable function5 = () -> { };
-        
-        // signature
-        assertFunction0(function1, CHARACTER, STRING);
-        assertFunction0(function2, CHARACTER, STRING);
-        
-        assertFunction1(function1, CHARACTER, STRING);
-        assertFunction1(function2, CHARACTER, STRING);
-        
-        assertFunction2(function1, CHARACTER, STRING);
-        assertFunction2(function2, CHARACTER, STRING);
-        assertFunction2(function3, CHARACTER, STRING, FLOAT);
-        assertFunction2(function4, CHARACTER);
-        assertFunction2(function5, P_VOID);
-        
-        testAPI(ATTR_LAMBDA, function1, function2, function3, function4, function5);
-        testLambdaCall(function1, function2, function3, function4, function5);
-    }
-    
-    @Test
-    public void testMember() {
-        
-        // signature
-        assertFunction0(_function1, CHARACTER, STRING);
-        assertFunction0(_function2, CHARACTER, STRING);
-        
-        assertFunction1(_function1, CHARACTER, STRING);
-        assertFunction1(_function2, CHARACTER, STRING);
-        
-        assertFunction2(_function1, CHARACTER, STRING);
-        assertFunction2(_function2, CHARACTER, STRING);
-        assertFunction2(_function3, CHARACTER, STRING, FLOAT);
-        assertFunction2(_function4, CHARACTER);
-        assertFunction2(_function5, P_VOID);
-        
-        testAPI(ATTR_LAMBDA, _function1, _function2, _function3, _function4, _function5);
-        testLambdaCall(_function1, _function2, _function3, _function4, _function5);
-    }
-    
-    @Test
-    public void testFromFunctor() {
-        int value1 = 1;
-		int[] array2 = new int[]{1,2,3,4,5};
-        @SuppressWarnings("Convert2Lambda")
-		Function<String, Character> function1 = new Function<String, Character>(){
-            @Override
-            public Character apply(String s) {
-                return s.charAt(1);
-            }
-        };
-        @SuppressWarnings("Convert2Lambda")
-		Function<String, Character> function2 = new Function<String, Character>() {
-            @Override
-            public Character apply(String s) {
-                return s.charAt(array2[value1]);
-            }
-        };
-        @SuppressWarnings("Convert2Lambda")
-		BiFunction<String, Float, Character> function3 = new BiFunction<String, Float, Character>() {
-            @Override
-            public Character apply(String a, Float b) {
-                return a.charAt(b.intValue());
-            }
-        };
-        @SuppressWarnings("Convert2Lambda")
-        Supplier<Character> function4 = new Supplier<Character>() {
-            @Override
-            public Character get() {
-                return 'z';
-            }
-        };
-        @SuppressWarnings("Convert2Lambda")
-        Runnable function5 = new Runnable() {
-            @Override
-            public void run() {
-                // do nothing
-            }
-        };
-        
-        // signature
-        assertFunction0(function1, CHARACTER, STRING);
-        assertFunction0(function2, CHARACTER, STRING);
-        
-        assertFunction1(function1, CHARACTER, STRING);
-        assertFunction1(function2, CHARACTER, STRING);
-        
-        assertFunction2(function1, CHARACTER, STRING);
-        assertFunction2(function2, CHARACTER, STRING);
-        assertFunction2(function3, CHARACTER, STRING, FLOAT);
-        assertFunction2(function4, CHARACTER);
-        assertFunction2(function5, P_VOID);
-        
-        testAPI(ATTR_FUNCTOR, function1, function2, function3, function4, function5);
-        testFunctorCall(function1, function2, function3, function4, function5);
-    }
-    
-    @Test
-    public void testInline() {
-		assertFunction0((int[] array) -> 5.7f, FLOAT, INT_ARRAY);
-		assertFunction0((int[] array) -> new float[2], IFLOAT_ARRAY, INT_ARRAY);
-		assertFunction0((int[] array) -> new Float[2], FLOAT_ARRAY, INT_ARRAY);
-        
-        assertFunction1((int[] array) -> 5.7f, OBJECT, INT_ARRAY);
-		assertFunction1((int[] array) -> null, OBJECT, INT_ARRAY);
-		assertFunction1((String array) -> new Float[2], OBJECT, STRING);
-    }
-    
-    @Test
-    public void testInlineCall() {
-        IMethod m21 = IMethod.function(pass2((Integer a) -> 3*a));
-        IMethod m11 = IMethod.function(pass1((Integer a) -> 3*a));
-        
-        assertEquals(24, m21.call(8));
-        assertEquals(24, m21.invoke(null, 8));
-        assertThrows(IllegalArgumentException.class, ()->{
-            m21.invoke(m21, 8);
-        });
-        
-        assertEquals(24, m11.call(8));
-        assertEquals(24, m11.invoke(null, 8));
-        assertThrows(IllegalArgumentException.class, ()->{
-            m21.invoke(m11, 8);
-        });
-        
-    }
-    
 
     @SuppressWarnings({"raw", "unchecked"})
     @Test
@@ -214,188 +54,5 @@ public class IMethodTest {
         assertEquals(503, g1.build(500).sum(1, 2));
         assertEquals(603, g2.build(600).sum(1, 2));
     }
-    
-    @Test
-    public void testToFunctorLambda() {
-        MTFunction.Lame f1 = (a,b,c) -> a.intValue() + b + c;
-        MTFunction.LameLong f2 = (a,b,c) -> (int)a + b + c;
 
-        IMethod m1 = IMethod.function(f1);
-        IMethod m2 = IMethod.function(f2);
-        
-        MTFunction<Long> g1 = m1.handle(new TypeToken<MTFunction<Long>>(){});
-        MTFunction<Long> g2 = m2.handle(new TypeToken<MTFunction<Long>>(){});
-
-        assertEquals(503, g1.calculate(500L, 1, 2));
-        assertEquals(607, g2.calculate(600L, 3, 4));
-    }
-    
-    private void testAPI(Set<IAttribute> exp, Object function1, Object function2, Object function3, Object function4, Object function5) {
-        IMethod m1 = IMethod.function(function1);
-		IMethod m2 = IMethod.function(function2);
-		IMethod m3 = IMethod.function(function3);
-		IMethod m4 = IMethod.function(function4);
-		IMethod m5 = IMethod.function(function5);
-        
-        // name
-        assertEquals("apply", m1.name());
-        assertEquals("apply", m2.name());
-        assertEquals("apply", m3.name());
-        assertEquals("get", m4.name());
-        assertEquals("run", m5.name());
-        
-        // attributes
-        assertEquals(exp, m1.attributes());
-        assertEquals(exp, m2.attributes());
-        assertEquals(exp, m3.attributes());
-        assertEquals(exp, m4.attributes());
-        assertEquals(exp, m5.attributes());
-
-        // parent
-        assertEquals(IClass.typefor(function1), m1.parent());
-        assertEquals(IClass.typefor(function2), m2.parent());
-        assertEquals(IClass.typefor(function3), m3.parent());
-        assertEquals(IClass.typefor(function4), m4.parent());
-        assertEquals(IClass.typefor(function5), m5.parent());
-
-        // reflective
-        assertEquals(m1.name(), m1.reflective().getName());
-        assertEquals(m2.name(), m2.reflective().getName());
-        assertEquals(m3.name(), m3.reflective().getName());
-        assertEquals(m4.name(), m4.reflective().getName());
-        assertEquals(m5.name(), m5.reflective().getName());
-        
-        // params
-        assertEquals(0, m1.params().size());
-        assertEquals(0, m2.params().size());
-        assertEquals(0, m3.params().size());
-        assertEquals(0, m4.params().size());
-        assertEquals(0, m5.params().size());
-        
-        // annotations
-        assertEquals(0, count(m1.annotations()));
-        assertEquals(0, count(m2.annotations()));
-        assertEquals(0, count(m3.annotations()));
-        assertEquals(0, count(m4.annotations()));
-        assertEquals(0, count(m5.annotations()));
-    }
-    
-    private static int count(IAnnotations list) {
-        return list.discard(a -> a.annotationType().getName().equals("java.lang.invoke.LambdaForm$Hidden")).count();
-    }
-    
-    private void testLambdaCall(Object function1, Object function2, Object function3, Object function4, Object function5) {
-        IMethod m1 = IMethod.function(function1);
-		IMethod m2 = IMethod.function(function2);
-		IMethod m3 = IMethod.function(function3);
-		IMethod m4 = IMethod.function(function4);
-		IMethod m5 = IMethod.function(function5);
-        
-        // call
-        assertEquals('e', m1.call("hello!"));
-        assertEquals('e', m1.invoke(null, "hello!"));
-        assertThrows(IllegalArgumentException.class, ()->{
-            m1.invoke(new Object(), "hello!");
-        });
-        assertThrows(IllegalArgumentException.class, ()->{
-            m1.invoke(new Object());
-        });
-        assertThrows(ClassCastException.class, ()->{
-            m1.call(888);
-        });
-        
-        assertEquals('r', m2.call("world!"));
-        assertEquals('r', m2.invoke(null, "world!"));
-        
-        assertEquals('o', m3.call("hello!", 4.1f));
-        assertEquals('o', m3.invoke(null, "hello!", 4.1f));
-        
-        assertEquals('z', m4.call());
-        assertEquals('z', m4.invoke());
-        assertEquals('z', m4.invoke(null));
-        
-        assertEquals(null, m5.call());
-        assertEquals(null, m5.invoke());
-        assertEquals(null, m5.invoke(null));
-    }
-    
-    private void testFunctorCall(Object function1, Object function2, Object function3, Object function4, Object function5) {
-        IMethod m1 = IMethod.function(function1);
-		IMethod m2 = IMethod.function(function2);
-		IMethod m3 = IMethod.function(function3);
-		IMethod m4 = IMethod.function(function4);
-		IMethod m5 = IMethod.function(function5);
-        
-        // call
-        assertEquals('e', m1.call("hello!"));
-        assertEquals('e', m1.invoke(function1, "hello!"));
-        assertThrows(IllegalArgumentException.class, ()->{
-            m1.invoke(new Object(), "hello!");
-        });
-        assertThrows(IllegalArgumentException.class, ()->{
-            m1.invoke(new Object());
-        });
-        assertThrows(ClassCastException.class, ()->{
-            m1.call(888);
-        });
-        
-        assertEquals('r', m2.call("world!"));
-        assertEquals('r', m2.invoke(function2, "world!"));
-        
-        assertEquals('o', m3.call("hello!", 4.1f));
-        assertEquals('o', m3.invoke(function3, "hello!", 4.1f));
-        
-        assertEquals('z', m4.call());
-        assertThrows(IllegalArgumentException.class, ()->{
-            m4.invoke();
-        });
-        
-        assertEquals('z', m4.invoke(function4));
-        
-        assertEquals(null, m5.call());
-        assertThrows(IllegalArgumentException.class, ()->{
-            m5.invoke();
-        });
-        assertEquals(null, m5.invoke(function5));
-    }
-    
-    private <T,R> void assertFunction0(Function<T,R> function, IClass<?> ret, IClass<?>... args) {
-        assertFunction2(function, ret, args);
-    }
-    
-    private <T,R> Function<?,?> pass2(Function<?,?> function) {
-        return function;
-    }
-    
-    private Function<?,?> pass1(Function<?,?> function) {
-        return function;
-    }
-    
-    private void assertFunction1(Function<?,?> function, IClass<?> ret, IClass<?>... args) {
-        assertFunction2(function, ret, args);
-    }
-    
-    private void assertFunction2(Object function, IClass<?> ret, IClass<?>... args) {
-        IMethod m = IMethod.function(function);
-        
-//        Class<?> type = function.getClass();
-//        System.out.printf(">>>> %s -> %s%n", m.arguments().types(), m.returns());
-//        CPInspector.getConstructors(type).forEach(v -> {
-//            System.out.printf(" - c: %s%n", v);
-//        });
-//        CPInspector.getMethods(type).forEach(v -> {
-//            System.out.printf(" - m: %s%n", v);
-//        });
-//        IClass.typefor(function).methods().require(IAttribute.DECLARED).each(v -> {
-//            System.out.printf(" - s: %s%n", v);
-//        });
-//        System.out.printf("%n");
-        
-        assertEquals(ret, m.returns());
-        assertEquals(Arrays.asList(args), m.arguments().types().list());
-        
-    }
-
-    
-    
 }

+ 0 - 11
assira/src/test/java/net/ranides/assira/reflection/IMethodsTest.java

@@ -19,17 +19,6 @@ import static org.junit.Assert.*;
  */
 public class IMethodsTest {
 
-    @Test
-    public void testInfo() throws Exception, Throwable {
-        IMethods m = IMethods.function(
-            (Function<String,Integer>)a -> Integer.parseInt(a),
-            (Supplier<String>)() -> "text"
-        );
-        
-        assertEquals(16, m.first().get().call("16"));
-        assertEquals("text", m.list().get(1).call());
-    }
-    
     @Test
     public void testInfo2() {
         Method m1 = IClass.typeinfo(ForMethodUtils.MCP.class).method("some1").get().reflective();

+ 7 - 0
pom.xml

@@ -37,6 +37,7 @@
         <module>assira.all</module>
         <module>assira.archetype</module>
         <module>assira.enterprise</module>
+        <module>assira.lambda</module>
     </modules>
 
     <distributionManagement>
@@ -254,6 +255,12 @@
                 <artifactId>jjwt</artifactId>
                 <version>0.9.0</version>
             </dependency>
+            <dependency>
+                <groupId>org.projectlombok</groupId>
+                <artifactId>lombok</artifactId>
+                <version>1.18.8</version>
+                <scope>provided</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>