Created
October 13, 2014 19:38
-
-
Save JoshRosen/4e833694961e06c16263 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "JavaRDDLike bug repro" | |
version := "1.0" | |
scalaVersion := "2.11.3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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