Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JoshRosen
Created October 13, 2014 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshRosen/4e833694961e06c16263 to your computer and use it in GitHub Desktop.
Save JoshRosen/4e833694961e06c16263 to your computer and use it in GitHub Desktop.
name := "JavaRDDLike bug repro"
version := "1.0"
scalaVersion := "2.11.3"
import java.util.Comparator
trait RDDLike[T] {
def max(comp: Comparator[T]): T = {
(1.0).asInstanceOf[T]
}
}
class DoubleRDD extends RDDLike[java.lang.Double] {
// This space intentionally left blank.
}
import java.util.Comparator;
public class Test {
private static class DoubleComparator implements Comparator<Double> {
public int compare(Double o1, Double o2) {
return o1.compareTo(o2);
}
}
public static void main(String[] args) {
DoubleRDD rdd = new DoubleRDD();
RDDLike<Double> rddLike = rdd;
// This call works fine:
double rddLikeMax = rddLike.max(new DoubleComparator());
// This call fails at runtime:
// java.lang.NoSuchMethodError: DoubleRDD.max(Ljava/util/Comparator;)Ljava/lang/Double;
double rddMax = rdd.max(new DoubleComparator());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment