|
Last change
on this file since 3103 was 2, checked in by bird, 23 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | // Extended regression test for the PR 179.
|
|---|
| 2 | //
|
|---|
| 3 | // This tests the ".class" language syntax, initialization behaviour for
|
|---|
| 4 | // Class.isInstance() and Class.isAssignableFrom(), and isAssignableFrom()
|
|---|
| 5 | // functionality in the event that an interface argument that is not
|
|---|
| 6 | // implemented by any loaded class is given.
|
|---|
| 7 | //
|
|---|
| 8 | // Bryce McKinlay <[email protected]>
|
|---|
| 9 |
|
|---|
| 10 | class A
|
|---|
| 11 | {
|
|---|
| 12 | static
|
|---|
| 13 | {
|
|---|
| 14 | System.out.println("A initialized");
|
|---|
| 15 | }
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | interface IA {}
|
|---|
| 19 |
|
|---|
| 20 | class B implements IA
|
|---|
| 21 | {
|
|---|
| 22 | static
|
|---|
| 23 | {
|
|---|
| 24 | System.out.println("B initialized");
|
|---|
| 25 | }
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | class C
|
|---|
| 29 | {
|
|---|
| 30 | static
|
|---|
| 31 | {
|
|---|
| 32 | System.out.println("C initialized");
|
|---|
| 33 | }
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | interface IB {}
|
|---|
| 37 |
|
|---|
| 38 | public class pr179
|
|---|
| 39 | {
|
|---|
| 40 | public static void main(String[] args)
|
|---|
| 41 | {
|
|---|
| 42 | System.out.println (A.class.isAssignableFrom (Object.class));
|
|---|
| 43 | System.out.println (IB.class.isAssignableFrom (B.class));
|
|---|
| 44 | System.out.println (IA.class.isAssignableFrom (B.class));
|
|---|
| 45 | A a = new A();
|
|---|
| 46 | System.out.println (C.class.isInstance (a));
|
|---|
| 47 | C c = new C();
|
|---|
| 48 | System.out.println (C.class.isInstance (c));
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | /* Expected Output:
|
|---|
| 53 | A initialized
|
|---|
| 54 | false
|
|---|
| 55 | B initialized
|
|---|
| 56 | false
|
|---|
| 57 | true
|
|---|
| 58 | C initialized
|
|---|
| 59 | false
|
|---|
| 60 | true
|
|---|
| 61 | */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.