From 7254e4eab9fa736b5a47fd44617b7604d83ff576 Mon Sep 17 00:00:00 2001 From: Warren Levy Date: Tue, 13 Jun 2000 23:44:05 +0000 Subject: Test for PR java.lang/258: * libjava.lang/Class_1.java: New file. * libjava.lang/Class_1.out: New file. From-SVN: r34532 --- libjava/testsuite/libjava.lang/Class_1.java | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 libjava/testsuite/libjava.lang/Class_1.java (limited to 'libjava/testsuite/libjava.lang/Class_1.java') diff --git a/libjava/testsuite/libjava.lang/Class_1.java b/libjava/testsuite/libjava.lang/Class_1.java new file mode 100644 index 0000000..f2156eb --- /dev/null +++ b/libjava/testsuite/libjava.lang/Class_1.java @@ -0,0 +1,49 @@ +class C {} +class D extends C implements I {} +interface I {} +interface J extends I {} + +public class Class_1 +{ + static void printIsAssignableFrom(Class a, Class b, boolean c) + { + // The field 'c' can be viewed to see the expected value. + System.out.println(a.isAssignableFrom(b)); + } + + public static void main (String arg[]) + { + System.out.println("Testing class `Class_1'..."); + printIsAssignableFrom(C.class, Object.class, false); + printIsAssignableFrom(C.class, C.class, true); + printIsAssignableFrom(C.class, D.class, true); + printIsAssignableFrom(D.class, C.class, false); + + printIsAssignableFrom(Object.class, int[].class, true); + printIsAssignableFrom(int[].class, int[].class, true); + printIsAssignableFrom(C[].class, D.class, false); + printIsAssignableFrom(C[].class, D[].class, true); + // Known compiler limitation prevents next case from compiling. + // printIsAssignableFrom(C[].class, C[][].class, false); + System.out.println("printIsAssignableFrom(C[].class, C[][].class, false);" + + " case uncompilable due to known compiler limitation."); + + printIsAssignableFrom(Object.class, I.class, true); + printIsAssignableFrom(I.class, I.class, true); + printIsAssignableFrom(D.class, I.class, false); + printIsAssignableFrom(I.class, D.class, true); + + printIsAssignableFrom(D.class, J.class, false); + printIsAssignableFrom(J.class, D.class, false); + + printIsAssignableFrom(I.class, J.class, true); + printIsAssignableFrom(J.class, J.class, true); + printIsAssignableFrom(J.class, I.class, false); + + // Returns true iff both Class objects are equal. + printIsAssignableFrom(long.class, long.class, true); + + // Does not work for primitive types in general. + printIsAssignableFrom(long.class, int.class, false); + } +} -- cgit v1.1