Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 8 lambda causes NoClassDefFoundError: java.util.function.Function #559

Closed
1 task done
davidgiga1993 opened this issue Feb 13, 2021 · 1 comment
Closed
1 task done

Comments

@davidgiga1993
Copy link

davidgiga1993 commented Feb 13, 2021

Please ensure you have given all the following requested information in your report.

Issue details

The following cause causes a java.lang.NoClassDefFoundError: java.util.function.Function

public void sortByName()
{
	sort(Comparator.comparing(a -> a.productName));
}

Reproduction steps/code

See issue

Configuration

Build Tools:

  • Gradle plugin

Versions:

Please provide the version of RoboVM, XCode and JDK used

  • Robovm: 2.3.11
  • XCode: 12.2
  • JDK: openJDK 13

Build Targets:
iOS 14.3


Stacktrace

See issue

@davidgiga1993
Copy link
Author

davidgiga1993 commented Feb 13, 2021

When I replace the lambda with a simple comparator I get the following:

public class MidiPortList extends ArrayList<MidiPort> {
  public void sortByName()
  {
	  sort(new Comparator<T>()
	  {
		  @Override
		  public int compare(T o1, T o2)
		  {
			  return o1.productName.compareTo(o2.productName);
		  }
	  });
  }
}
java.lang.NoSuchMethodError: abc.MidiPortList.sort(Ljava/util/Comparator;)V
at abc.MidiPortList.sortByName

But the ArrayList.sort method should be included in jdk8, or am I missing something here?

When using the java 7 Collections.sort instead it's working fine:

Collections.sort(this, new Comparator<T>()
{
	@Override
	public int compare(T o1, T o2)
	{
		return o1.productName.compareTo(o2.productName);
	}
});

Oh I just noticed: This is related / duplicate to #555

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant