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

NoSuchMethodError unmodifiableCollection #556

Closed JonathanxD closed 6 years ago

JonathanxD commented 6 years ago

Avian does not find unmodifiableCollection method in Collections:

import java.util.Collections;

public class Unmod {
    public static void main(String[] args) {
        Collections.unmodifiableCollection(Collections.emptyList());
    }
}
javac Unmod.java
avian -cp .:/usr/lib/jvm/java-8-openjdk/jre/lib/rt.jar Unmod

Output:

java/lang/NoSuchMethodError: unmodifiableCollection (Ljava/util/Collection;)Ljava/util/Collection; not found in java/util/Collections
  at Unmod.main (line 5)
dicej commented 6 years ago

How did you build Avian? If you built with the openjdk option, you shouldn't need to set the classpath to rt.jar. If you did not build with the openjdk option, using rt.jar as the classpath simply won't work.

JonathanxD commented 6 years ago

I've build by calling make only, now I tried to build with jdk, that worked, but I think that this still a bug because does not work without linking openjdk, otherwise emptyList() should not work too.

dicej commented 6 years ago

The default build (without the openjdk option) uses Avian's built-in class library, which only contains a small subset of classes and methods from the JRE. As you can see, not all the methods in all the classes have been implemented: https://github.com/ReadyTalk/avian/blob/master/classpath/java/util/Collections.java. If you need a complete class library, you need to link with OpenJDK.

JonathanxD commented 6 years ago

Okay, Thanks!