From 5dc127e69cae1d88aa6910ea6378ad5dc1aaeaab Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Thu, 23 Jun 2011 10:26:42 +0000 Subject: getting the revamped getClass to work on Java 5 hunch by adriaan (needed to change Object to Any in strategic location), location + fix determined by paul, menial work (reverts of obsolete spears and introduction of fix) by adriaan review by extempore Revert "A line missed from spear thrust, no review. Revert " "Thrusting spear into darkened alcove attempting to slay java5 " Revert "New theory: fails running on java 1.5. Put in hack to " discover Revert "Everything builds for me, but apparently not for " jenkins. First " --- test/disabled/run/getClassTest.check | 18 ---------- test/disabled/run/getClassTest.scala | 66 ------------------------------------ test/files/run/getClassTest.check | 18 ++++++++++ test/files/run/getClassTest.scala | 66 ++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 84 deletions(-) delete mode 100644 test/disabled/run/getClassTest.check delete mode 100644 test/disabled/run/getClassTest.scala create mode 100644 test/files/run/getClassTest.check create mode 100644 test/files/run/getClassTest.scala (limited to 'test') diff --git a/test/disabled/run/getClassTest.check b/test/disabled/run/getClassTest.check deleted file mode 100644 index 94e86c3889..0000000000 --- a/test/disabled/run/getClassTest.check +++ /dev/null @@ -1,18 +0,0 @@ -f1: java.lang.Class -f2: java.lang.Class -f3: java.lang.Class -f4: java.lang.Class -f5: java.lang.Class -f0: T -f1: class java.lang.Object -f2: class java.lang.Object -f3: class AnyRefs$A -f4: class AnyRefs$B -f5: class java.lang.Object -f6: class java.lang.Object -f7: class AnyRefs$A -f8: class AnyRefs$B -f1: java.lang.Class -f2: java.lang.Class -f3: java.lang.Class -f4: java.lang.Class diff --git a/test/disabled/run/getClassTest.scala b/test/disabled/run/getClassTest.scala deleted file mode 100644 index 951cc8d931..0000000000 --- a/test/disabled/run/getClassTest.scala +++ /dev/null @@ -1,66 +0,0 @@ -class AnyVals { - def f1 = (5: Any).getClass - def f2 = (5: AnyVal).getClass - def f3 = 5.getClass - def f4 = (5: java.lang.Integer).getClass - def f5 = (5.asInstanceOf[AnyRef]).getClass - - // scalap says: - // - // def f1 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } - // def f2 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } - // def f3 : java.lang.Class[scala.Int] = { /* compiled code */ } - // def f4 : java.lang.Class[?0] forSome {type ?0 <: java.lang.Integer} = { /* compiled code */ } - // def f5 : java.lang.Class[?0] forSome {type ?0 <: scala.AnyRef} = { /* compiled code */ } - // - // java generic signature says: - // - // f1: java.lang.Class - // f2: java.lang.Class - // f3: java.lang.Class - // f4: java.lang.Class - // f5: java.lang.Class -} - -class AnyRefs { - class A - class B extends A - - def f1 = (new B: Any).getClass().newInstance() - def f2 = (new B: AnyRef).getClass().newInstance() - def f3 = (new B: A).getClass().newInstance() - def f4 = (new B: B).getClass().newInstance() - - def f0[T >: B] = (new B: T).getClass().newInstance() - - def f5 = f0[Any] - def f6 = f0[AnyRef] - def f7 = f0[A] - def f8 = f0[B] -} - -class MoreAnyRefs { - trait A - trait B - - // don't leak anon/refinements - def f1 = (new A with B { }).getClass() - def f2 = (new B with A { }).getClass() - def f3 = (new { def bippy() = 5 }).getClass() - def f4 = (new A { def bippy() = 5 }).getClass() -} - -object Test { - def returnTypes[T: Manifest] = ( - manifest[T].erasure.getMethods.toList - filter (_.getName startsWith "f") - sortBy (_.getName) - map (m => m.getName + ": " + m.getGenericReturnType.toString) - ) - - def main(args: Array[String]): Unit = { - returnTypes[AnyVals] foreach println - returnTypes[AnyRefs] foreach println - returnTypes[MoreAnyRefs] foreach println - } -} diff --git a/test/files/run/getClassTest.check b/test/files/run/getClassTest.check new file mode 100644 index 0000000000..94e86c3889 --- /dev/null +++ b/test/files/run/getClassTest.check @@ -0,0 +1,18 @@ +f1: java.lang.Class +f2: java.lang.Class +f3: java.lang.Class +f4: java.lang.Class +f5: java.lang.Class +f0: T +f1: class java.lang.Object +f2: class java.lang.Object +f3: class AnyRefs$A +f4: class AnyRefs$B +f5: class java.lang.Object +f6: class java.lang.Object +f7: class AnyRefs$A +f8: class AnyRefs$B +f1: java.lang.Class +f2: java.lang.Class +f3: java.lang.Class +f4: java.lang.Class diff --git a/test/files/run/getClassTest.scala b/test/files/run/getClassTest.scala new file mode 100644 index 0000000000..951cc8d931 --- /dev/null +++ b/test/files/run/getClassTest.scala @@ -0,0 +1,66 @@ +class AnyVals { + def f1 = (5: Any).getClass + def f2 = (5: AnyVal).getClass + def f3 = 5.getClass + def f4 = (5: java.lang.Integer).getClass + def f5 = (5.asInstanceOf[AnyRef]).getClass + + // scalap says: + // + // def f1 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } + // def f2 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } + // def f3 : java.lang.Class[scala.Int] = { /* compiled code */ } + // def f4 : java.lang.Class[?0] forSome {type ?0 <: java.lang.Integer} = { /* compiled code */ } + // def f5 : java.lang.Class[?0] forSome {type ?0 <: scala.AnyRef} = { /* compiled code */ } + // + // java generic signature says: + // + // f1: java.lang.Class + // f2: java.lang.Class + // f3: java.lang.Class + // f4: java.lang.Class + // f5: java.lang.Class +} + +class AnyRefs { + class A + class B extends A + + def f1 = (new B: Any).getClass().newInstance() + def f2 = (new B: AnyRef).getClass().newInstance() + def f3 = (new B: A).getClass().newInstance() + def f4 = (new B: B).getClass().newInstance() + + def f0[T >: B] = (new B: T).getClass().newInstance() + + def f5 = f0[Any] + def f6 = f0[AnyRef] + def f7 = f0[A] + def f8 = f0[B] +} + +class MoreAnyRefs { + trait A + trait B + + // don't leak anon/refinements + def f1 = (new A with B { }).getClass() + def f2 = (new B with A { }).getClass() + def f3 = (new { def bippy() = 5 }).getClass() + def f4 = (new A { def bippy() = 5 }).getClass() +} + +object Test { + def returnTypes[T: Manifest] = ( + manifest[T].erasure.getMethods.toList + filter (_.getName startsWith "f") + sortBy (_.getName) + map (m => m.getName + ": " + m.getGenericReturnType.toString) + ) + + def main(args: Array[String]): Unit = { + returnTypes[AnyVals] foreach println + returnTypes[AnyRefs] foreach println + returnTypes[MoreAnyRefs] foreach println + } +} -- cgit v1.2.3