ReadyTalk / avian

[INACTIVE] Avian is a lightweight virtual machine and class library designed to provide a useful subset of Java's features, suitable for building self-contained applications.
https://readytalk.github.io/avian/
Other
1.22k stars 172 forks source link

Yet another lambda problem #563

Open teras opened 6 years ago

teras commented 6 years ago

Hello I think I found another lambda problem

Let's consider this interface:

public interface MyFunction<T, R> {
  R apply(T t);
  default <V> MyFunction<T, V> andThen(MyFunction<? super R, ? extends V> after) {
    return t -> after.apply(apply(t));
  }
  static <T> MyFunction<T, T> identity() {
    return t -> t;
  }
}

When I try to call this:

System.out.println(MyFunction.identity().andThen(MyFunction.identity()).apply("* Test"));

The application crashes at this point:

error: memory read failed for 0x1000fa000
#0  0x00000001000fa160 in 0x1000fa160 ()
#1  0x0000000101bd901a in test/base/Hello.<init>()V ()
#2  0x0000000101c9983d in (anonymous namespace)::local::invoke(vm::Thread*, vm::GcMethod*, (anonymous namespace)::local::ArgumentList*) at /Users/teras/avian/scripts/avian/src/compile.cpp:8548
#3  0x0000000101c829c7 in (anonymous namespace)::local::MyProcessor::invokeList(vm::Thread*, vm::GcMethod*, vm::GcObject*, bool, __va_list_tag*) at /Users/teras/avian/scripts/avian/src/compile.cpp:9189
#4  0x0000000101cc8d87 in (anonymous namespace)::local::callIntMethodV(vm::Thread*, unsigned long*) at /Users/teras/avian/scripts/avian/src/jnienv.cpp:707
#5  0x0000000101cee9ad in vmRun ()
...

Any idea what is wrong?