Source Code Cross Referenced for ClassHierarchyTest.java in  » Apache-Harmony-Java-SE » java-package » java » lang » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
0003:         *  contributor license agreements.  See the NOTICE file distributed with
0004:         *  this work for additional information regarding copyright ownership.
0005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
0006:         *  (the "License"); you may not use this file except in compliance with
0007:         *  the License.  You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         *  Unless required by applicable law or agreed to in writing, software
0012:         *  distributed under the License is distributed on an "AS IS" BASIS,
0013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         *  See the License for the specific language governing permissions and
0015:         *  limitations under the License.
0016:         */
0017:
0018:        /**
0019:         * @author Serguei S.Zapreyev
0020:         * @version $Revision$
0021:         */package java.lang;
0022:
0023:        /**
0024:         *   Areas for supposed testing a classes' hierarchy
0025:         *   and new 1.5 getEnclosingClass, getEnumConstants, isEnum, asSubclass,
0026:         *   getEnclosingMethod, getEnclosingConstructor, isMemberClass, isLocalClass,
0027:         *   isAnonymousClass, isSynthetic, getCanonicalName, getSimpleName methods:
0028:         *   I.   member, inner, nested, local, annonymous, proxy, synthetic classes;
0029:         *        different packages classes;
0030:         *        casting, naming, IS...ing, GET...ing, enums, ...;
0031:         *   II.  member interfaces;
0032:         *   III. the same for annotations and annotated;
0033:         *   IV.  the same for enums;
0034:         *   V.   the same for generalized.
0035:         **/
0036:
0037:        import java.lang.annotation.Annotation;
0038:
0039:        import junit.framework.TestCase;
0040:
0041:        /*
0042:         * Created on April 03, 2006
0043:         *
0044:         * This ClassHierarchyTest class is used to test the Core API 1.5 Class class
0045:         * 
0046:         */
0047:
0048:        /**
0049:         * ###############################################################################
0050:         * ###############################################################################
0051:         * TODO: 1.
0052:         * ###############################################################################
0053:         * ###############################################################################
0054:         */
0055:        import java.lang.annotation.Retention;
0056:        import java.lang.annotation.RetentionPolicy;
0057:        import java.lang.reflect.GenericDeclaration;
0058:
0059:        @Retention(value=RetentionPolicy.RUNTIME)
0060:        @interface i {
0061:            abstract String author() default "Zapreyev";
0062:        };
0063:
0064:        @SuppressWarnings(value={"unchecked"})
0065:        public class ClassHierarchyTest extends TestCase {
0066:            @i
0067:            public class MC001 {
0068:                @i
0069:                public class MC001_01 {
0070:                    @i
0071:                    public class MC001_01_01 {
0072:                        @i
0073:                        public class MC001_01_01_01 {
0074:                            @i
0075:                            public class MC001_01_01_01_01 {
0076:                                @i
0077:                                public class MC001_01_01_01_01_01 {
0078:                                    @i
0079:                                    public class MC001_01_01_01_01_01_01 {
0080:                                    };
0081:                                };
0082:                            };
0083:                        };
0084:                    };
0085:                };
0086:            };
0087:
0088:            @Retention(value=RetentionPolicy.RUNTIME)
0089:            @interface anna {
0090:                abstract String author() default "Zapreyev";
0091:            };
0092:
0093:            @i
0094:            public class MC002<X, Y, Z> {
0095:                @i
0096:                public class MC002_01<X1, Y1, Z1> {
0097:                    @i
0098:                    public class MC002_01_01<X2, Y2, Z2> {
0099:                        @i
0100:                        public class MC002_01_01_01<X3, Y3, Z3> {
0101:                            @i
0102:                            public class MC002_01_01_01_01<X4, Y4, Z4> {
0103:                                @i
0104:                                public class MC002_01_01_01_01_01<X5, Y5, Z5> {
0105:                                    @i
0106:                                    public class MC002_01_01_01_01_01_01<X6, Y6, Z6> {
0107:                                    };
0108:                                };
0109:                            };
0110:                        };
0111:                    };
0112:                };
0113:            };
0114:
0115:            @Retention(value=RetentionPolicy.RUNTIME)
0116:            @interface ii {
0117:                abstract String author() default "Zapreyev";
0118:
0119:                @Retention(value=RetentionPolicy.RUNTIME)
0120:                @interface iii {
0121:                    abstract String author() default "Zapreyev";
0122:                };
0123:            };
0124:
0125:            @i
0126:            interface MI001 {
0127:                @i
0128:                interface MI001_01 {
0129:                    @i
0130:                    interface MI001_01_01 {
0131:                        @i
0132:                        interface MI001_01_01_01 {
0133:                            @i
0134:                            interface MI001_01_01_01_01 {
0135:                                @i
0136:                                interface MI001_01_01_01_01_01 {
0137:                                    @i
0138:                                    interface MI001_01_01_01_01_01_01 {
0139:                                        @Retention(value=RetentionPolicy.RUNTIME)
0140:                                        @interface iiii {
0141:                                            abstract String author() default "Zapreyev";
0142:                                        };
0143:                                    };
0144:                                };
0145:                            };
0146:                        };
0147:                    };
0148:                };
0149:            };
0150:
0151:            @i
0152:            interface MI002<X, Y, Z> {
0153:                @i
0154:                interface MI002_01<X1, Y1, Z1> {
0155:                    @i
0156:                    interface MI002_01_01<X2, Y2, Z2> {
0157:                        @i
0158:                        interface MI002_01_01_01<X3, Y3, Z3> {
0159:                            @i
0160:                            interface MI002_01_01_01_01<X4, Y4, Z4> {
0161:                                @i
0162:                                interface MI002_01_01_01_01_01<X5, Y5, Z5> {
0163:                                    @i
0164:                                    interface MI002_01_01_01_01_01_01<X6, Y6, Z6> {
0165:                                        @Retention(value=RetentionPolicy.RUNTIME)
0166:                                        @interface iiii {
0167:                                            abstract String author() default "Zapreyev";
0168:                                        };
0169:                                    };
0170:                                };
0171:                            };
0172:                        };
0173:                    };
0174:                };
0175:            };
0176:
0177:            @Retention(value=RetentionPolicy.RUNTIME)
0178:            @interface MA001 {
0179:                @Retention(value=RetentionPolicy.RUNTIME)
0180:                @interface MA001_01 {
0181:                    @Retention(value=RetentionPolicy.RUNTIME)
0182:                    @interface MA001_01_01 {
0183:                        @Retention(value=RetentionPolicy.RUNTIME)
0184:                        @interface MA001_01_01_01 {
0185:                            @Retention(value=RetentionPolicy.RUNTIME)
0186:                            @interface MA001_01_01_01_01 {
0187:                                @Retention(value=RetentionPolicy.RUNTIME)
0188:                                @interface MA001_01_01_01_01_01 {
0189:                                    @Retention(value=RetentionPolicy.RUNTIME)
0190:                                    @interface MA001_01_01_01_01_01_01 {
0191:                                        @Retention(value=RetentionPolicy.RUNTIME)
0192:                                        @interface iiii {
0193:                                            abstract String author() default "Zapreyev 1";
0194:                                        };
0195:
0196:                                        abstract String author() default "Zapreyev 2";
0197:                                    };
0198:
0199:                                    abstract String author() default "Zapreyev 3";
0200:                                };
0201:
0202:                                abstract String author() default "Zapreyev 4";
0203:                            };
0204:
0205:                            abstract String author() default "Zapreyev 5";
0206:                        };
0207:
0208:                        abstract String author() default "Zapreyev 6";
0209:                    };
0210:
0211:                    abstract String author() default "Zapreyev 7";
0212:                };
0213:
0214:                abstract String author() default "Zapreyev 8";
0215:            };
0216:
0217:            //===================================================================================================
0218:            //===================================================================================================
0219:            //===================================================================================================
0220:
0221:            ///////////////////////// I:    
0222:            /**
0223:             * member classes
0224:             */
0225:            public void test_1() {
0226:                if (!MC001.class.getEnclosingClass().equals(
0227:                        ClassHierarchyTest.class))
0228:                    fail("test_1, case 004 FAILED: "
0229:                            + MC001.class.getEnclosingClass());
0230:                if (MC001.class.getEnumConstants() != null)
0231:                    fail("test_1, case 009 FAILED: "
0232:                            + MC001.class.getEnumConstants());
0233:                if (MC001.class.isEnum())
0234:                    fail("test_1, case 000 FAILED: " + MC001.class.isEnum());
0235:                try {
0236:                    MC001.class.asSubclass(ClassHierarchyTest.class);
0237:                    fail("test_1, case 011 FAILED: "
0238:                            + MC001.class.asSubclass(ClassHierarchyTest.class));
0239:                } catch (Exception e) {/*e.printStackTrace();*/
0240:                }
0241:                if (MC001.class.getEnclosingMethod() != null)
0242:                    fail("test_1, case 013 FAILED: "
0243:                            + MC001.class.getEnclosingMethod());
0244:                if (MC001.class.getEnclosingConstructor() != null)
0245:                    fail("test_1, case 014 FAILED: "
0246:                            + MC001.class.getEnclosingConstructor());
0247:                if (!MC001.class.isMemberClass())
0248:                    fail("test_1, case 017 FAILED: "
0249:                            + MC001.class.isMemberClass());
0250:                if (MC001.class.isLocalClass())
0251:                    fail("test_1, case 018 FAILED: "
0252:                            + MC001.class.isLocalClass());
0253:                if (MC001.class.isAnonymousClass())
0254:                    fail("test_1, case 019 FAILED: "
0255:                            + MC001.class.isAnonymousClass());
0256:                if (MC001.class.isSynthetic())
0257:                    fail("test_1, case 020 FAILED: "
0258:                            + MC001.class.isSynthetic());
0259:                if (!MC001.class.getCanonicalName().equals(
0260:                        "java.lang.ClassHierarchyTest.MC001"))
0261:                    fail("test_1, case 021 FAILED: "
0262:                            + MC001.class.getCanonicalName());
0263:                if (!MC001.class.getSimpleName().equals("MC001"))
0264:                    fail("test_1, case 022 FAILED: "
0265:                            + MC001.class.getSimpleName());
0266:            }
0267:
0268:            /**
0269:             * member interface
0270:             */
0271:            public void test_1_1() {
0272:                if (!MI001.class.getEnclosingClass().equals(
0273:                        ClassHierarchyTest.class))
0274:                    fail("test_1, case 004 FAILED: "
0275:                            + MI001.class.getEnclosingClass());
0276:                if (MI001.class.getEnumConstants() != null)
0277:                    fail("test_1, case 009 FAILED: "
0278:                            + MI001.class.getEnumConstants());
0279:                if (MI001.class.isEnum())
0280:                    fail("test_1, case 000 FAILED: " + MI001.class.isEnum());
0281:                try {
0282:                    MI001.class.asSubclass(ClassHierarchyTest.class);
0283:                    fail("test_1, case 011 FAILED: "
0284:                            + MI001.class.asSubclass(ClassHierarchyTest.class));
0285:                } catch (Exception e) {/*e.printStackTrace();*/
0286:                }
0287:                if (MI001.class.getEnclosingMethod() != null)
0288:                    fail("test_1, case 013 FAILED: "
0289:                            + MI001.class.getEnclosingMethod());
0290:                if (MI001.class.getEnclosingConstructor() != null)
0291:                    fail("test_1, case 014 FAILED: "
0292:                            + MI001.class.getEnclosingConstructor());
0293:                if (!MI001.class.isMemberClass())
0294:                    fail("test_1, case 017 FAILED: "
0295:                            + MI001.class.isMemberClass());
0296:                if (MI001.class.isLocalClass())
0297:                    fail("test_1, case 018 FAILED: "
0298:                            + MI001.class.isLocalClass());
0299:                if (MI001.class.isAnonymousClass())
0300:                    fail("test_1, case 019 FAILED: "
0301:                            + MI001.class.isAnonymousClass());
0302:                if (MI001.class.isSynthetic())
0303:                    fail("test_1, case 020 FAILED: "
0304:                            + MI001.class.isSynthetic());
0305:                if (!MI001.class.getCanonicalName().equals(
0306:                        "java.lang.ClassHierarchyTest.MI001"))
0307:                    fail("test_1, case 021 FAILED: "
0308:                            + MI001.class.getCanonicalName());
0309:                if (!MI001.class.getSimpleName().equals("MI001"))
0310:                    fail("test_1, case 022 FAILED: "
0311:                            + MI001.class.getSimpleName());
0312:            }
0313:
0314:            /**
0315:             * deeply nested member classes
0316:             */
0317:            public void test_2() {
0318:                Class cuCla = MC001.MC001_01.MC001_01_01.MC001_01_01_01.MC001_01_01_01_01.MC001_01_01_01_01_01.MC001_01_01_01_01_01_01.class;
0319:                String caNa = cuCla.getCanonicalName();
0320:                //String name[] = caNa.split("\\$");
0321:                String name[] = caNa.split("\\.");
0322:                int i = name.length - 1;
0323:                while (cuCla != null) {
0324:                    if (cuCla.getEnclosingClass() != null
0325:                            && cuCla.getEnclosingClass().getSimpleName()
0326:                                    .equals(name[i]))
0327:                        fail("test_2, case 002 FAILED: "
0328:                                + cuCla.getEnclosingClass().getSimpleName());
0329:                    if (cuCla.getEnumConstants() != null)
0330:                        fail("test_2, case 009 FAILED: "
0331:                                + cuCla.getEnumConstants());
0332:                    if (cuCla.isEnum())
0333:                        fail("test_2, case 000 FAILED: " + cuCla.isEnum());
0334:                    try {
0335:                        cuCla
0336:                                .asSubclass(cuCla.getEnclosingClass() != null ? cuCla
0337:                                        .getEnclosingClass()
0338:                                        : cuCla);
0339:                        if (!cuCla.getCanonicalName().equals(
0340:                                "java.lang.ClassHierarchyTest"))
0341:                            fail("test_2, case 011 FAILED: "
0342:                                    + cuCla
0343:                                            .asSubclass(cuCla
0344:                                                    .getEnclosingClass() != null ? cuCla
0345:                                                    .getEnclosingClass()
0346:                                                    : cuCla));
0347:                    } catch (Exception e) {/*e.printStackTrace();*/
0348:                    }
0349:                    if (cuCla.getEnclosingMethod() != null)
0350:                        fail("test_2, case 013 FAILED: "
0351:                                + cuCla.getEnclosingMethod());
0352:                    if (cuCla.getEnclosingConstructor() != null)
0353:                        fail("test_2, case 014 FAILED: "
0354:                                + cuCla.getEnclosingConstructor());
0355:                    if (cuCla.getEnclosingClass() != null
0356:                            && !cuCla.isMemberClass())
0357:                        fail("test_1, case 017 FAILED: "
0358:                                + cuCla.isMemberClass());
0359:                    if (cuCla.isLocalClass())
0360:                        fail("test_2, case 018 FAILED: " + cuCla.isLocalClass());
0361:                    if (cuCla.isAnonymousClass())
0362:                        fail("test_2, case 019 FAILED: "
0363:                                + cuCla.isAnonymousClass());
0364:                    if (cuCla.isSynthetic())
0365:                        fail("test_2, case 020 FAILED: " + cuCla.isSynthetic());
0366:                    if (!cuCla.getCanonicalName().equals(caNa))
0367:                        fail("test_2, case 021 FAILED: "
0368:                                + cuCla.getCanonicalName());
0369:                    caNa = caNa.substring(0, caNa.lastIndexOf('.'));
0370:                    if (!cuCla.getSimpleName().equals(name[i]))
0371:                        fail("test_2, case 022 FAILED: "
0372:                                + cuCla.getSimpleName());
0373:                    i--;
0374:                    cuCla = cuCla.getEnclosingClass();
0375:                }
0376:            }
0377:
0378:            /**
0379:             * deeply nested member interfaces
0380:             */
0381:            public void test_2_1() {
0382:                Class cuCla = MI001.MI001_01.MI001_01_01.MI001_01_01_01.MI001_01_01_01_01.MI001_01_01_01_01_01.MI001_01_01_01_01_01_01.class;
0383:                String caNa = cuCla.getCanonicalName();
0384:                //String name[] = caNa.split("\\$");
0385:                String name[] = caNa.split("\\.");
0386:                int i = name.length - 1;
0387:                while (cuCla != null) {
0388:                    if (cuCla.getEnclosingClass() != null
0389:                            && cuCla.getEnclosingClass().getSimpleName()
0390:                                    .equals(name[i]))
0391:                        fail("test_2, case 002 FAILED: "
0392:                                + cuCla.getEnclosingClass().getSimpleName());
0393:                    if (cuCla.getEnumConstants() != null)
0394:                        fail("test_2, case 009 FAILED: "
0395:                                + cuCla.getEnumConstants());
0396:                    if (cuCla.isEnum())
0397:                        fail("test_2, case 000 FAILED: " + cuCla.isEnum());
0398:                    try {
0399:                        cuCla
0400:                                .asSubclass(cuCla.getEnclosingClass() != null ? cuCla
0401:                                        .getEnclosingClass()
0402:                                        : cuCla);
0403:                        if (!cuCla.getCanonicalName().equals(
0404:                                "java.lang.ClassHierarchyTest"))
0405:                            fail("test_2, case 011 FAILED: "
0406:                                    + cuCla
0407:                                            .asSubclass(cuCla
0408:                                                    .getEnclosingClass() != null ? cuCla
0409:                                                    .getEnclosingClass()
0410:                                                    : cuCla));
0411:                    } catch (Exception e) {/*e.printStackTrace();*/
0412:                    }
0413:                    if (cuCla.getEnclosingMethod() != null)
0414:                        fail("test_2, case 013 FAILED: "
0415:                                + cuCla.getEnclosingMethod());
0416:                    if (cuCla.getEnclosingConstructor() != null)
0417:                        fail("test_2, case 014 FAILED: "
0418:                                + cuCla.getEnclosingConstructor());
0419:                    if (cuCla.getEnclosingClass() != null
0420:                            && !cuCla.isMemberClass())
0421:                        fail("test_1, case 017 FAILED: "
0422:                                + cuCla.isMemberClass());
0423:                    if (cuCla.isLocalClass())
0424:                        fail("test_2, case 018 FAILED: " + cuCla.isLocalClass());
0425:                    if (cuCla.isAnonymousClass())
0426:                        fail("test_2, case 019 FAILED: "
0427:                                + cuCla.isAnonymousClass());
0428:                    if (cuCla.isSynthetic())
0429:                        fail("test_2, case 020 FAILED: " + cuCla.isSynthetic());
0430:                    if (!cuCla.getCanonicalName().equals(caNa))
0431:                        fail("test_2, case 021 FAILED: "
0432:                                + cuCla.getCanonicalName());
0433:                    caNa = caNa.substring(0, caNa.lastIndexOf('.'));
0434:                    if (!cuCla.getSimpleName().equals(name[i]))
0435:                        fail("test_2, case 022 FAILED: "
0436:                                + cuCla.getSimpleName());
0437:                    i--;
0438:                    cuCla = cuCla.getEnclosingClass();
0439:                }
0440:            }
0441:
0442:            /**
0443:             * unnested local class
0444:             */
0445:            public void test_3() {
0446:                @i
0447:                class LC001 {
0448:                }
0449:                ;
0450:                if (!LC001.class.getEnclosingClass().equals(
0451:                        ClassHierarchyTest.class))
0452:                    fail("test_3, case 004 FAILED: "
0453:                            + LC001.class.getEnclosingClass());
0454:                if (LC001.class.getEnumConstants() != null)
0455:                    fail("test_3, case 009 FAILED: "
0456:                            + LC001.class.getEnumConstants());
0457:                if (LC001.class.isEnum())
0458:                    fail("test_3, case 000 FAILED: " + LC001.class.isEnum());
0459:                try {
0460:                    LC001.class.asSubclass(ClassHierarchyTest.class);
0461:                    fail("test_3, case 011 FAILED: "
0462:                            + LC001.class.asSubclass(ClassHierarchyTest.class));
0463:                } catch (Exception e) {/*e.printStackTrace();*/
0464:                }
0465:                if (!LC001.class.getEnclosingMethod().getName()
0466:                        .equals("test_3"))
0467:                    fail("test_3, case 013 FAILED: "
0468:                            + LC001.class.getEnclosingMethod().getName());
0469:                if (LC001.class.getEnclosingConstructor() != null)
0470:                    fail("test_3, case 014 FAILED: "
0471:                            + LC001.class.getEnclosingConstructor());
0472:                if (LC001.class.isMemberClass())
0473:                    fail("test_3, case 017 FAILED: "
0474:                            + LC001.class.isMemberClass());
0475:                if (!LC001.class.isLocalClass())
0476:                    fail("test_3, case 018 FAILED: "
0477:                            + LC001.class.isLocalClass());
0478:                if (LC001.class.isAnonymousClass())
0479:                    fail("test_3, case 019 FAILED: "
0480:                            + LC001.class.isAnonymousClass());
0481:                if (LC001.class.isSynthetic())
0482:                    fail("test_3, case 020 FAILED: "
0483:                            + LC001.class.isSynthetic());
0484:                if (LC001.class.getCanonicalName() != null)
0485:                    fail("test_3, case 021 FAILED: "
0486:                            + LC001.class.getCanonicalName());
0487:                if (!LC001.class.getSimpleName().equals("LC001"))
0488:                    fail("test_3, case 022 FAILED: "
0489:                            + LC001.class.getSimpleName());
0490:            }
0491:
0492:            /**
0493:             * local               ClassHierarchyTest$1$LC003$1A.class   (1)
0494:             * anonymous           ClassHierarchyTest$1$LC003$1.class    (2)
0495:             * member of anonymous ClassHierarchyTest$1$LC003$1$A.class  (3)
0496:             * local               ClassHierarchyTest$1$LC003$1AAA.class (4)
0497:             */
0498:            static int f = 0;
0499:            static Object ooo = null;
0500:
0501:            public void test_4() { // now it is a class access control bug, so, closed for a while
0502:                // It's strange that if we use javac instead of ecj
0503:                // then we have no such problem
0504:                //   <<< A member of the "class java.lang.ClassHierarchyTest$1" with "" modifiers can not be accessed from the "class java.lang.ClassHierarchyTest">>>
0505:                // so it should be investigated.
0506:                @i
0507:                class LC002 {
0508:                }
0509:                ;
0510:                class $LC003 {
0511:                    public Class value() {
0512:                        class A extends $LC003 { // (1)
0513:                        }
0514:                        ;
0515:                        Object o = new LC002() { // (2)
0516:                            class A { // (3)
0517:                            }
0518:
0519:                            Class m1() {
0520:                                return A.class;
0521:                            }
0522:
0523:                            Class m2() {
0524:                                return m3() == null ? m1() : m3();
0525:                            }
0526:
0527:                            Class m3() {
0528:                                return m2();
0529:                            }
0530:                        };
0531:                        ooo = o;
0532:                        if (f < 1) {
0533:                            f += 1;
0534:                            return A.class;
0535:                        }
0536:                        f += 1;
0537:                        return o.getClass();
0538:                    }
0539:
0540:                    public Class value2() {
0541:                        class AAA { // (4)
0542:                        }
0543:                        ;
0544:                        return AAA.class;
0545:                    }
0546:                }
0547:                class X$1Y {
0548:                }
0549:                class X {
0550:                    Class m2() {
0551:                        class Y { // it has "X$2Y" name!!! So, compiler provides the
0552:                            // difference with the previous "X$1Y"
0553:                        }
0554:                        return Y.class;
0555:                    }
0556:
0557:                    Class m4() {
0558:                        return m5() == null ? m2() : m5();
0559:                    }
0560:
0561:                    Class m5() {
0562:                        return m4();
0563:                    }
0564:                }
0565:                Class cuCla = new $LC003().value(); // ClassHierarchyTest$1$LC003$1A.class   (1)
0566:                if (!cuCla.getEnclosingClass().equals($LC003.class))
0567:                    fail("test_4, case 004 FAILED: "
0568:                            + cuCla.getEnclosingClass());
0569:                if (cuCla.getEnumConstants() != null)
0570:                    fail("test_4, case 009 FAILED: " + cuCla.getEnumConstants());
0571:                if (cuCla.isEnum())
0572:                    fail("test_4, case 000 FAILED: " + cuCla.isEnum());
0573:                try {
0574:                    cuCla.asSubclass(ClassHierarchyTest.class);
0575:                    fail("test_4, case 011 FAILED: "
0576:                            + cuCla.asSubclass(ClassHierarchyTest.class));
0577:                } catch (Exception e) {/*e.printStackTrace();*/
0578:                }
0579:                if (!cuCla.getEnclosingMethod().getName().equals("value"))
0580:                    fail("test_4, case 013 FAILED: "
0581:                            + cuCla.getEnclosingMethod().getName());
0582:                if (cuCla.getEnclosingConstructor() != null)
0583:                    fail("test_4, case 014 FAILED: "
0584:                            + cuCla.getEnclosingConstructor());
0585:                if (cuCla.isMemberClass())
0586:                    fail("test_4, case 017 FAILED: " + cuCla.isMemberClass());
0587:                if (!cuCla.isLocalClass())
0588:                    fail("test_4, case 018 FAILED: " + cuCla.isLocalClass());
0589:                if (cuCla.isAnonymousClass())
0590:                    fail("test_4, case 019 FAILED: " + cuCla.isAnonymousClass());
0591:                if (cuCla.isSynthetic())
0592:                    fail("test_4, case 020 FAILED: " + cuCla.isSynthetic());
0593:                if (cuCla.getCanonicalName() != null)
0594:                    fail("test_4, case 021 FAILED: " + cuCla.getCanonicalName());
0595:                if (!cuCla.getSimpleName().equals("A"))
0596:                    fail("test_4, case 022 FAILED: " + cuCla.getSimpleName());
0597:
0598:                cuCla = new $LC003().value(); // ClassHierarchyTest$1$LC003$1.class    (2)
0599:                if (!cuCla.getEnclosingClass().equals($LC003.class))
0600:                    fail("test_4, case 023 FAILED: "
0601:                            + cuCla.getEnclosingClass());
0602:                if (cuCla.getEnumConstants() != null)
0603:                    fail("test_4, case 024 FAILED: " + cuCla.getEnumConstants());
0604:                if (cuCla.isEnum())
0605:                    fail("test_4, case 025 FAILED: " + cuCla.isEnum());
0606:                try {
0607:                    cuCla.asSubclass(ClassHierarchyTest.class);
0608:                    fail("test_4, case 026 FAILED: "
0609:                            + cuCla.asSubclass(ClassHierarchyTest.class));
0610:                } catch (Exception e) {/*e.printStackTrace();*/
0611:                }
0612:                if (!cuCla.getEnclosingMethod().getName().equals("value"))
0613:                    fail("test_4, case 027 FAILED: "
0614:                            + cuCla.getEnclosingMethod().getName());
0615:                if (cuCla.getEnclosingConstructor() != null)
0616:                    fail("test_4, case 028 FAILED: "
0617:                            + cuCla.getEnclosingConstructor());
0618:                if (cuCla.isMemberClass())
0619:                    fail("test_4, case 029 FAILED: " + cuCla.isMemberClass());
0620:                if (cuCla.isLocalClass())
0621:                    fail("test_4, case 030 FAILED: " + cuCla.isLocalClass());
0622:                if (!cuCla.isAnonymousClass())
0623:                    fail("test_4, case 031 FAILED: " + cuCla.isAnonymousClass());
0624:                if (cuCla.isSynthetic())
0625:                    fail("test_4, case 032 FAILED: " + cuCla.isSynthetic());
0626:                if (cuCla.getCanonicalName() != null)
0627:                    fail("test_4, case 033 FAILED: " + cuCla.getCanonicalName());
0628:                if (!cuCla.getSimpleName().equals(""))
0629:                    fail("test_4, case 034 FAILED: " + cuCla.getSimpleName());
0630:
0631:                cuCla = new $LC003().value2(); // ClassHierarchyTest$1$LC003$1AAA.class (4)
0632:                if (!cuCla.getEnclosingClass().equals($LC003.class))
0633:                    fail("test_4, case 035 FAILED: "
0634:                            + cuCla.getEnclosingClass());
0635:                if (cuCla.getEnumConstants() != null)
0636:                    fail("test_4, case 036 FAILED: " + cuCla.getEnumConstants());
0637:                if (cuCla.isEnum())
0638:                    fail("test_4, case 037 FAILED: " + cuCla.isEnum());
0639:                try {
0640:                    cuCla.asSubclass(ClassHierarchyTest.class);
0641:                    fail("test_4, case 038 FAILED: "
0642:                            + cuCla.asSubclass(ClassHierarchyTest.class));
0643:                } catch (Exception e) {/*e.printStackTrace();*/
0644:                }
0645:                if (!cuCla.getEnclosingMethod().getName().equals("value2"))
0646:                    fail("test_4, case 039 FAILED: "
0647:                            + cuCla.getEnclosingMethod().getName());
0648:                if (cuCla.getEnclosingConstructor() != null)
0649:                    fail("test_4, case 040 FAILED: "
0650:                            + cuCla.getEnclosingConstructor());
0651:                if (cuCla.isMemberClass())
0652:                    fail("test_4, case 041 FAILED: " + cuCla.isMemberClass());
0653:                if (!cuCla.isLocalClass())
0654:                    fail("test_4, case 042 FAILED: " + cuCla.isLocalClass());
0655:                if (cuCla.isAnonymousClass())
0656:                    fail("test_4, case 043 FAILED: " + cuCla.isAnonymousClass());
0657:                if (cuCla.isSynthetic())
0658:                    fail("test_4, case 044 FAILED: " + cuCla.isSynthetic());
0659:                if (cuCla.getCanonicalName() != null)
0660:                    fail("test_4, case 045 FAILED: " + cuCla.getCanonicalName());
0661:                if (!cuCla.getSimpleName().equals("AAA"))
0662:                    fail("test_4, case 046 FAILED: " + cuCla.getSimpleName());
0663:
0664:                try {
0665:                    cuCla = (Class) new $LC003().value()
0666:                            .getDeclaredMethod("m1").invoke(ooo,
0667:                                    (Object[]) null); // ClassHierarchyTest$1$LC003$1$A.class  (3)
0668:                    Class tc = Class
0669:                            .forName("java.lang.ClassHierarchyTest$1$LC003$1");
0670:                    if (!cuCla.getEnclosingClass().equals(tc))
0671:                        fail("test_4, case 047 FAILED: "
0672:                                + cuCla.getEnclosingClass());
0673:                    if (cuCla.getEnumConstants() != null)
0674:                        fail("test_4, case 048 FAILED: "
0675:                                + cuCla.getEnumConstants());
0676:                    if (cuCla.isEnum())
0677:                        fail("test_4, case 049 FAILED: " + cuCla.isEnum());
0678:                    try {
0679:                        cuCla.asSubclass(ClassHierarchyTest.class);
0680:                        fail("test_4, case 050 FAILED: "
0681:                                + cuCla.asSubclass(ClassHierarchyTest.class));
0682:                    } catch (Exception e) {/*e.printStackTrace();*/
0683:                    }
0684:                    if (cuCla.getEnclosingMethod() != null)
0685:                        fail("test_4, case 051 FAILED: "
0686:                                + cuCla.getEnclosingMethod());
0687:                    if (cuCla.getEnclosingConstructor() != null)
0688:                        fail("test_4, case 052 FAILED: "
0689:                                + cuCla.getEnclosingConstructor());
0690:                    if (!cuCla.isMemberClass())
0691:                        fail("test_4, case 053 FAILED: "
0692:                                + cuCla.isMemberClass());
0693:                    if (cuCla.isLocalClass())
0694:                        fail("test_4, case 054 FAILED: " + cuCla.isLocalClass());
0695:                    if (cuCla.isAnonymousClass())
0696:                        fail("test_4, case 055 FAILED: "
0697:                                + cuCla.isAnonymousClass());
0698:                    if (cuCla.isSynthetic())
0699:                        fail("test_4, case 056 FAILED: " + cuCla.isSynthetic());
0700:                    if (cuCla.getCanonicalName() != null)
0701:                        fail("test_4, case 057 FAILED: "
0702:                                + cuCla.getCanonicalName());
0703:                    if (!cuCla.getSimpleName().equals("A"))
0704:                        fail("test_4, case 058 FAILED: "
0705:                                + cuCla.getSimpleName());
0706:                } catch (ClassNotFoundException e) {
0707:                    fail(e.getMessage());
0708:                } catch (IllegalAccessException e) {
0709:                    fail(e.getMessage());
0710:                } catch (IllegalArgumentException e) {
0711:                    fail(e.getMessage());
0712:                } catch (java.lang.reflect.InvocationTargetException e) {
0713:                    fail(e.getMessage());
0714:                } catch (NoSuchMethodException e) {
0715:                    fail(e.getMessage());
0716:                }
0717:
0718:                cuCla = X$1Y.class; // ClassHierarchyTest$1X$1Y.class  (3)
0719:                if (!cuCla.getEnclosingClass().equals(ClassHierarchyTest.class))
0720:                    fail("test_4, case 059 FAILED: "
0721:                            + cuCla.getEnclosingClass());
0722:                if (cuCla.getEnumConstants() != null)
0723:                    fail("test_4, case 060 FAILED: " + cuCla.getEnumConstants());
0724:                if (cuCla.isEnum())
0725:                    fail("test_4, case 061 FAILED: " + cuCla.isEnum());
0726:                try {
0727:                    cuCla.asSubclass(ClassHierarchyTest.class);
0728:                    fail("test_4, case 062 FAILED: "
0729:                            + cuCla.asSubclass(ClassHierarchyTest.class));
0730:                } catch (Exception e) {/*e.printStackTrace();*/
0731:                }
0732:                if (!cuCla.getEnclosingMethod().getName().equals("test_4"))
0733:                    fail("test_4, case 063 FAILED: "
0734:                            + cuCla.getEnclosingMethod().getName());
0735:                if (cuCla.getEnclosingConstructor() != null)
0736:                    fail("test_4, case 064 FAILED: "
0737:                            + cuCla.getEnclosingConstructor());
0738:                if (cuCla.isMemberClass())
0739:                    fail("test_4, case 065 FAILED: " + cuCla.isMemberClass());
0740:                if (!cuCla.isLocalClass())
0741:                    fail("test_4, case 066 FAILED: " + cuCla.isLocalClass());
0742:                if (cuCla.isAnonymousClass())
0743:                    fail("test_4, case 067 FAILED: " + cuCla.isAnonymousClass());
0744:                if (cuCla.isSynthetic())
0745:                    fail("test_4, case 068 FAILED: " + cuCla.isSynthetic());
0746:                if (cuCla.getCanonicalName() != null)
0747:                    fail("test_4, case 069 FAILED: " + cuCla.getCanonicalName());
0748:                if (!cuCla.getSimpleName().equals("X$1Y"))
0749:                    fail("test_4, case 070 FAILED: " + cuCla.getSimpleName());
0750:
0751:                try {
0752:                    cuCla = (Class) X.class.getDeclaredMethod("m2").invoke(
0753:                            new X(), (Object[]) null); // ClassHierarchyTest$1$LC003$1$A.class  (3)
0754:                    if (!cuCla.getEnclosingClass().equals(X.class))
0755:                        fail("test_4, case 071 FAILED: "
0756:                                + cuCla.getEnclosingClass());
0757:                    if (cuCla.getEnumConstants() != null)
0758:                        fail("test_4, case 072 FAILED: "
0759:                                + cuCla.getEnumConstants());
0760:                    if (cuCla.isEnum())
0761:                        fail("test_4, case 073 FAILED: " + cuCla.isEnum());
0762:                    try {
0763:                        cuCla.asSubclass(ClassHierarchyTest.class);
0764:                        fail("test_4, case 074 FAILED: "
0765:                                + cuCla.asSubclass(ClassHierarchyTest.class));
0766:                    } catch (Exception e) {/*e.printStackTrace();*/
0767:                    }
0768:                    if (!cuCla.getEnclosingMethod().getName().equals("m2"))
0769:                        fail("test_4, case 075 FAILED: "
0770:                                + cuCla.getEnclosingMethod().getName());
0771:                    if (cuCla.getEnclosingConstructor() != null)
0772:                        fail("test_4, case 076 FAILED: "
0773:                                + cuCla.getEnclosingConstructor());
0774:                    if (cuCla.isMemberClass())
0775:                        fail("test_4, case 077 FAILED: "
0776:                                + cuCla.isMemberClass());
0777:                    if (!cuCla.isLocalClass())
0778:                        fail("test_4, case 078 FAILED: " + cuCla.isLocalClass());
0779:                    if (cuCla.isAnonymousClass())
0780:                        fail("test_4, case 079 FAILED: "
0781:                                + cuCla.isAnonymousClass());
0782:                    if (cuCla.isSynthetic())
0783:                        fail("test_4, case 080 FAILED: " + cuCla.isSynthetic());
0784:                    if (cuCla.getCanonicalName() != null)
0785:                        fail("test_4, case 081 FAILED: "
0786:                                + cuCla.getCanonicalName());
0787:                    if (!cuCla.getSimpleName().equals("Y"))
0788:                        fail("test_4, case 082 FAILED: "
0789:                                + cuCla.getSimpleName());
0790:                } catch (IllegalAccessException e) {
0791:                    fail(e.getMessage());
0792:                } catch (IllegalArgumentException e) {
0793:                    fail(e.getMessage());
0794:                } catch (java.lang.reflect.InvocationTargetException e) {
0795:                    fail(e.getMessage());
0796:                } catch (NoSuchMethodException e) {
0797:                    fail(e.getMessage());
0798:                }
0799:            }
0800:
0801:            /**
0802:             * Constructor's local class
0803:             */
0804:            public void test_4_1() {
0805:                @i
0806:                class LC001 {
0807:                    public Class c;
0808:
0809:                    public LC001() {
0810:                        @i
0811:                        class LC001_01 {
0812:                        }
0813:                        c = LC001_01.class;
0814:                    }
0815:                }
0816:                ;
0817:                LC001 lc = new LC001();
0818:                if (!lc.c.getEnclosingClass().getName().equals(
0819:                        "java.lang.ClassHierarchyTest$2LC001"))
0820:                    fail("test_3, case 004 FAILED: "
0821:                            + lc.c.getEnclosingClass().getName());
0822:                if (lc.c.getEnumConstants() != null)
0823:                    fail("test_3, case 009 FAILED: " + lc.c.getEnumConstants());
0824:                if (lc.c.isEnum())
0825:                    fail("test_3, case 000 FAILED: " + lc.c.isEnum());
0826:                try {
0827:                    lc.c.asSubclass(ClassHierarchyTest.class);
0828:                    fail("test_3, case 011 FAILED: "
0829:                            + lc.c.asSubclass(ClassHierarchyTest.class));
0830:                } catch (Exception e) {/*e.printStackTrace();*/
0831:                }
0832:                if (lc.c.getEnclosingMethod() != null)
0833:                    fail("test_3, case 013 FAILED: "
0834:                            + lc.c.getEnclosingMethod().getName());
0835:                if (!lc.c.getEnclosingConstructor().getName().equals(
0836:                        "java.lang.ClassHierarchyTest$2LC001"))
0837:                    fail("test_3, case 014 FAILED: "
0838:                            + lc.c.getEnclosingConstructor());
0839:                if (lc.c.isMemberClass())
0840:                    fail("test_3, case 017 FAILED: " + lc.c.isMemberClass());
0841:                if (!lc.c.isLocalClass())
0842:                    fail("test_3, case 018 FAILED: " + lc.c.isLocalClass());
0843:                if (lc.c.isAnonymousClass())
0844:                    fail("test_3, case 019 FAILED: " + lc.c.isAnonymousClass());
0845:                if (lc.c.isSynthetic())
0846:                    fail("test_3, case 020 FAILED: " + lc.c.isSynthetic());
0847:                if (lc.c.getCanonicalName() != null)
0848:                    fail("test_3, case 021 FAILED: " + lc.c.getCanonicalName());
0849:                if (!lc.c.getSimpleName().equals("LC001_01"))
0850:                    fail("test_3, case 022 FAILED: " + lc.c.getSimpleName());
0851:            }
0852:
0853:            /**
0854:             * proxy class
0855:             */
0856:            public void test_5() {
0857:                class LIH implements  java.lang.reflect.InvocationHandler {
0858:                    public Object invoke(Object proxy,
0859:                            java.lang.reflect.Method method, Object[] args)
0860:                            throws Throwable {
0861:                        return null;
0862:                    }
0863:                }
0864:                Class cuCla = java.lang.reflect.Proxy.newProxyInstance(
0865:                        java.io.Serializable.class.getClassLoader(),
0866:                        new Class[] { java.io.Serializable.class }, new LIH())
0867:                        .getClass();
0868:
0869:                if (cuCla.getEnclosingClass() != null)
0870:                    fail("test_5, case 004 FAILED: "
0871:                            + cuCla.getEnclosingClass());
0872:                if (cuCla.getEnumConstants() != null)
0873:                    fail("test_5, case 009 FAILED: " + cuCla.getEnumConstants());
0874:                if (cuCla.isEnum())
0875:                    fail("test_5, case 000 FAILED: " + cuCla.isEnum());
0876:                try {
0877:                    cuCla.asSubclass(ClassHierarchyTest.class);
0878:                    fail("test_5, case 011 FAILED: "
0879:                            + cuCla.asSubclass(ClassHierarchyTest.class));
0880:                } catch (Exception e) {/*e.printStackTrace();*/
0881:                }
0882:                if (cuCla.getEnclosingMethod() != null)
0883:                    fail("test_5, case 013 FAILED: "
0884:                            + cuCla.getEnclosingMethod());
0885:                if (cuCla.getEnclosingConstructor() != null)
0886:                    fail("test_5, case 014 FAILED: "
0887:                            + cuCla.getEnclosingConstructor());
0888:                if (cuCla.isMemberClass())
0889:                    fail("test_5, case 017 FAILED: " + cuCla.isMemberClass());
0890:                if (cuCla.isLocalClass())
0891:                    fail("test_5, case 018 FAILED: " + cuCla.isLocalClass());
0892:                if (cuCla.isAnonymousClass())
0893:                    fail("test_5, case 019 FAILED: " + cuCla.isAnonymousClass());
0894:                if (cuCla.isSynthetic())
0895:                    fail("test_5, case 020 FAILED: " + cuCla.isSynthetic());
0896:                if (!cuCla.getCanonicalName().replaceFirst("\\$Proxy", "")
0897:                        .matches("\\d+"))
0898:                    fail("test_5, case 021 FAILED: " + cuCla.getCanonicalName());
0899:                if (!cuCla.getSimpleName().replaceFirst("\\$Proxy", "")
0900:                        .matches("\\d+"))
0901:                    fail("test_5, case 022 FAILED: " + cuCla.getSimpleName());
0902:            }
0903:
0904:            ///////////////////////// II:   
0905:            /**
0906:             * member interfaces
0907:             */
0908:            public void test_6() {
0909:                if (!MI001.class.getEnclosingClass().equals(
0910:                        ClassHierarchyTest.class))
0911:                    fail("test_1, case 004 FAILED: "
0912:                            + MI001.class.getEnclosingClass());
0913:                if (MI001.class.getEnumConstants() != null)
0914:                    fail("test_1, case 009 FAILED: "
0915:                            + MI001.class.getEnumConstants());
0916:                if (MI001.class.isEnum())
0917:                    fail("test_1, case 000 FAILED: " + MI001.class.isEnum());
0918:                try {
0919:                    MI001.class.asSubclass(ClassHierarchyTest.class);
0920:                    fail("test_1, case 011 FAILED: "
0921:                            + MI001.class.asSubclass(ClassHierarchyTest.class));
0922:                } catch (Exception e) {/*e.printStackTrace();*/
0923:                }
0924:                if (MI001.class.getEnclosingMethod() != null)
0925:                    fail("test_1, case 013 FAILED: "
0926:                            + MI001.class.getEnclosingMethod());
0927:                if (MI001.class.getEnclosingConstructor() != null)
0928:                    fail("test_1, case 014 FAILED: "
0929:                            + MI001.class.getEnclosingConstructor());
0930:                if (!MI001.class.isMemberClass())
0931:                    fail("test_1, case 017 FAILED: "
0932:                            + MI001.class.isMemberClass());
0933:                if (MI001.class.isLocalClass())
0934:                    fail("test_1, case 018 FAILED: "
0935:                            + MI001.class.isLocalClass());
0936:                if (MI001.class.isAnonymousClass())
0937:                    fail("test_1, case 019 FAILED: "
0938:                            + MI001.class.isAnonymousClass());
0939:                if (MI001.class.isSynthetic())
0940:                    fail("test_1, case 020 FAILED: "
0941:                            + MI001.class.isSynthetic());
0942:                if (!MI001.class.getCanonicalName().equals(
0943:                        "java.lang.ClassHierarchyTest.MI001"))
0944:                    fail("test_1, case 021 FAILED: "
0945:                            + MI001.class.getCanonicalName());
0946:                if (!MI001.class.getSimpleName().equals("MI001"))
0947:                    fail("test_1, case 022 FAILED: "
0948:                            + MI001.class.getSimpleName());
0949:            }
0950:
0951:            /**
0952:             * deeply nested member interfaces
0953:             */
0954:            public void test_7() {
0955:                Class cuCla = MI001.MI001_01.MI001_01_01.MI001_01_01_01.MI001_01_01_01_01.MI001_01_01_01_01_01.MI001_01_01_01_01_01_01.class;
0956:                String caNa = cuCla.getCanonicalName();
0957:                //String name[] = caNa.split("\\$");
0958:                String name[] = caNa.split("\\.");
0959:                int i = name.length - 1;
0960:                while (cuCla != null) {
0961:                    if (cuCla.getEnclosingClass() != null
0962:                            && cuCla.getEnclosingClass().getSimpleName()
0963:                                    .equals(name[i]))
0964:                        fail("test_2, case 002 FAILED: "
0965:                                + cuCla.getEnclosingClass().getSimpleName());
0966:                    if (cuCla.getEnumConstants() != null)
0967:                        fail("test_2, case 009 FAILED: "
0968:                                + cuCla.getEnumConstants());
0969:                    if (cuCla.isEnum())
0970:                        fail("test_2, case 000 FAILED: " + cuCla.isEnum());
0971:                    try {
0972:                        cuCla
0973:                                .asSubclass(cuCla.getEnclosingClass() != null ? cuCla
0974:                                        .getEnclosingClass()
0975:                                        : cuCla);
0976:                        if (!cuCla.getCanonicalName().equals(
0977:                                "java.lang.ClassHierarchyTest"))
0978:                            fail("test_2, case 011 FAILED: "
0979:                                    + cuCla
0980:                                            .asSubclass(cuCla
0981:                                                    .getEnclosingClass() != null ? cuCla
0982:                                                    .getEnclosingClass()
0983:                                                    : cuCla));
0984:                    } catch (Exception e) {/*e.printStackTrace();*/
0985:                    }
0986:                    if (cuCla.getEnclosingMethod() != null)
0987:                        fail("test_2, case 013 FAILED: "
0988:                                + cuCla.getEnclosingMethod());
0989:                    if (cuCla.getEnclosingConstructor() != null)
0990:                        fail("test_2, case 014 FAILED: "
0991:                                + cuCla.getEnclosingConstructor());
0992:                    if (cuCla.getEnclosingClass() != null
0993:                            && !cuCla.isMemberClass())
0994:                        fail("test_1, case 017 FAILED: "
0995:                                + cuCla.isMemberClass());
0996:                    if (cuCla.isLocalClass())
0997:                        fail("test_2, case 018 FAILED: " + cuCla.isLocalClass());
0998:                    if (cuCla.isAnonymousClass())
0999:                        fail("test_2, case 019 FAILED: "
1000:                                + cuCla.isAnonymousClass());
1001:                    if (cuCla.isSynthetic())
1002:                        fail("test_2, case 020 FAILED: " + cuCla.isSynthetic());
1003:                    if (!cuCla.getCanonicalName().equals(caNa))
1004:                        fail("test_2, case 021 FAILED: "
1005:                                + cuCla.getCanonicalName());
1006:                    caNa = caNa.substring(0, caNa.lastIndexOf('.'));
1007:                    if (!cuCla.getSimpleName().equals(name[i]))
1008:                        fail("test_2, case 022 FAILED: "
1009:                                + cuCla.getSimpleName());
1010:                    i--;
1011:                    cuCla = cuCla.getEnclosingClass();
1012:                }
1013:            }
1014:
1015:            ///////////////////////// III:  
1016:            /**
1017:             * member annotations as interfaces
1018:             */
1019:            @MA001
1020:            @MA001.MA001_01
1021:            @MA001.MA001_01.MA001_01_01
1022:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01
1023:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01.MA001_01_01_01_01
1024:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01.MA001_01_01_01_01.MA001_01_01_01_01_01
1025:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01.MA001_01_01_01_01.MA001_01_01_01_01_01.MA001_01_01_01_01_01_01
1026:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01.MA001_01_01_01_01.MA001_01_01_01_01_01.MA001_01_01_01_01_01_01.iiii
1027:            public void test_8() {
1028:                Class cuCla = MA001.MA001_01.MA001_01_01.MA001_01_01_01.MA001_01_01_01_01.MA001_01_01_01_01_01.MA001_01_01_01_01_01_01.class;
1029:                String caNa = cuCla.getCanonicalName();
1030:                //String name[] = caNa.split("\\$");
1031:                String name[] = caNa.split("\\.");
1032:                int i = name.length - 1;
1033:                while (cuCla != null) {
1034:                    if (cuCla.getEnclosingClass() != null
1035:                            && cuCla.getEnclosingClass().getSimpleName()
1036:                                    .equals(name[i]))
1037:                        fail("test_2, case 002 FAILED: "
1038:                                + cuCla.getEnclosingClass().getSimpleName());
1039:                    if (cuCla.getEnumConstants() != null)
1040:                        fail("test_2, case 009 FAILED: "
1041:                                + cuCla.getEnumConstants());
1042:                    if (cuCla.isEnum())
1043:                        fail("test_2, case 000 FAILED: " + cuCla.isEnum());
1044:                    try {
1045:                        cuCla
1046:                                .asSubclass(cuCla.getEnclosingClass() != null ? cuCla
1047:                                        .getEnclosingClass()
1048:                                        : cuCla);
1049:                        if (!cuCla.getCanonicalName().equals(
1050:                                "java.lang.ClassHierarchyTest"))
1051:                            fail("test_2, case 011 FAILED: "
1052:                                    + cuCla
1053:                                            .asSubclass(cuCla
1054:                                                    .getEnclosingClass() != null ? cuCla
1055:                                                    .getEnclosingClass()
1056:                                                    : cuCla));
1057:                    } catch (Exception e) {/*e.printStackTrace();*/
1058:                    }
1059:                    if (cuCla.getEnclosingMethod() != null)
1060:                        fail("test_2, case 013 FAILED: "
1061:                                + cuCla.getEnclosingMethod());
1062:                    if (cuCla.getEnclosingConstructor() != null)
1063:                        fail("test_2, case 014 FAILED: "
1064:                                + cuCla.getEnclosingConstructor());
1065:                    if (cuCla.getEnclosingClass() != null
1066:                            && !cuCla.isMemberClass())
1067:                        fail("test_1, case 017 FAILED: "
1068:                                + cuCla.isMemberClass());
1069:                    if (cuCla.isLocalClass())
1070:                        fail("test_2, case 018 FAILED: " + cuCla.isLocalClass());
1071:                    if (cuCla.isAnonymousClass())
1072:                        fail("test_2, case 019 FAILED: "
1073:                                + cuCla.isAnonymousClass());
1074:                    if (cuCla.isSynthetic())
1075:                        fail("test_2, case 020 FAILED: " + cuCla.isSynthetic());
1076:                    if (!cuCla.getCanonicalName().equals(caNa))
1077:                        fail("test_2, case 021 FAILED: "
1078:                                + cuCla.getCanonicalName());
1079:                    caNa = caNa.substring(0, caNa.lastIndexOf('.'));
1080:                    if (!cuCla.getSimpleName().equals(name[i]))
1081:                        fail("test_2, case 022 FAILED: "
1082:                                + cuCla.getSimpleName());
1083:                    i--;
1084:                    cuCla = cuCla.getEnclosingClass();
1085:                }
1086:            }
1087:
1088:            /**
1089:             * member annotations as annotations
1090:             */
1091:            @MA001
1092:            @MA001.MA001_01
1093:            @MA001.MA001_01.MA001_01_01
1094:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01
1095:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01.MA001_01_01_01_01
1096:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01.MA001_01_01_01_01.MA001_01_01_01_01_01
1097:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01.MA001_01_01_01_01.MA001_01_01_01_01_01.MA001_01_01_01_01_01_01
1098:            @MA001.MA001_01.MA001_01_01.MA001_01_01_01.MA001_01_01_01_01.MA001_01_01_01_01_01.MA001_01_01_01_01_01_01.iiii
1099:            public void test_9() {
1100:                Annotation aa[] = null;
1101:                try {
1102:                    aa = ClassHierarchyTest.class.getMethod("test_9")
1103:                            .getAnnotations();
1104:                } catch (NoSuchMethodException e) {
1105:                    fail("test_9, case 009 FAILED: " + e.toString());
1106:                }
1107:                for (int i = 0; i < aa.length; i++) {
1108:                    Class cuCla = aa[i].annotationType();
1109:                    String caNa = cuCla.getCanonicalName();
1110:                    String name[] = caNa.split("\\.");
1111:                    int j = name.length - 1;
1112:                    while (cuCla != null) {
1113:                        if (cuCla.getEnclosingClass() != null
1114:                                && cuCla.getEnclosingClass().getSimpleName()
1115:                                        .equals(name[j]))
1116:                            fail("test_9, case 002 FAILED: "
1117:                                    + cuCla.getEnclosingClass().getSimpleName());
1118:                        if (cuCla.getEnumConstants() != null)
1119:                            fail("test_9, case 009 FAILED: "
1120:                                    + cuCla.getEnumConstants());
1121:                        if (cuCla.isEnum())
1122:                            fail("test_9, case 000 FAILED: " + cuCla.isEnum());
1123:                        try {
1124:                            cuCla
1125:                                    .asSubclass(cuCla.getEnclosingClass() != null ? cuCla
1126:                                            .getEnclosingClass()
1127:                                            : cuCla);
1128:                            if (!cuCla.getCanonicalName().equals(
1129:                                    "java.lang.ClassHierarchyTest"))
1130:                                fail("test_9, case 011 FAILED: "
1131:                                        + cuCla
1132:                                                .asSubclass(cuCla
1133:                                                        .getEnclosingClass() != null ? cuCla
1134:                                                        .getEnclosingClass()
1135:                                                        : cuCla));
1136:                        } catch (Exception e) {/*e.printStackTrace();*/
1137:                        }
1138:                        if (cuCla.getEnclosingMethod() != null)
1139:                            fail("test_9, case 013 FAILED: "
1140:                                    + cuCla.getEnclosingMethod());
1141:                        if (cuCla.getEnclosingConstructor() != null)
1142:                            fail("test_9, case 014 FAILED: "
1143:                                    + cuCla.getEnclosingConstructor());
1144:                        if (cuCla.getEnclosingClass() != null
1145:                                && !cuCla.isMemberClass())
1146:                            fail("test_9, case 017 FAILED: "
1147:                                    + cuCla.isMemberClass());
1148:                        if (cuCla.isLocalClass())
1149:                            fail("test_9, case 018 FAILED: "
1150:                                    + cuCla.isLocalClass());
1151:                        if (cuCla.isAnonymousClass())
1152:                            fail("test_9, case 019 FAILED: "
1153:                                    + cuCla.isAnonymousClass());
1154:                        if (cuCla.isSynthetic())
1155:                            fail("test_9, case 020 FAILED: "
1156:                                    + cuCla.isSynthetic());
1157:                        if (!cuCla.getCanonicalName().equals(caNa))
1158:                            fail("test_9, case 021 FAILED: "
1159:                                    + cuCla.getCanonicalName());
1160:                        caNa = caNa.substring(0, caNa.lastIndexOf('.'));
1161:                        if (!cuCla.getSimpleName().equals(name[j]))
1162:                            fail("test_9, case 022 FAILED: "
1163:                                    + cuCla.getSimpleName());
1164:                        j--;
1165:                        cuCla = cuCla.getEnclosingClass();
1166:                    }
1167:                }
1168:            }
1169:
1170:            ///////////////////////// IV:    
1171:            /**
1172:             * member enums
1173:             */
1174:            public static enum ME001 {
1175:                F_S(2), M_S(3), C_S(4), CL_S(1);
1176:                ME001(int value) {
1177:                    cccccc1 = ME001_01_.class;
1178:                    this .value = value;
1179:                }
1180:
1181:                private final int value;
1182:                public static Class cccc2;
1183:                public Class ccccc3;
1184:                public Class cccccc1;
1185:                {
1186:                    class XXXX {
1187:                    }
1188:                    ;
1189:                    ccccc3 = ME001_01_.class;
1190:                }
1191:
1192:                public int value() {
1193:                    class XXX {
1194:                    }
1195:                    ;
1196:                    cccc2 = ME001_01_.class;
1197:                    return value;
1198:                }
1199:
1200:                public static enum ME001_01_ {
1201:                    G_A_T, P_T, V_T, W_T;
1202:                    public static enum ME001_01_1 {
1203:                        G_A_T, P_T, V_T, W_T;
1204:                        public static enum ME001_01_2 {
1205:                            G_A_T, P_T, V_T, W_T;
1206:                            public static enum ME001_01_3 {
1207:                                G_A_T, P_T, V_T, W_T;
1208:                                public static enum ME001_01_4 {
1209:                                    G_A_T, P_T, V_T, W_T;
1210:                                    public static enum ME001_01_5 {
1211:                                        G_A_T, P_T, V_T, W_T;
1212:                                        private final int value = 0;
1213:
1214:                                        public int value() {
1215:                                            return value;
1216:                                        }
1217:
1218:                                        public static Class pop() {
1219:                                            class XXX {
1220:                                            }
1221:                                            ;
1222:                                            return XXX.class;
1223:                                        }
1224:                                    };
1225:                                };
1226:                            };
1227:                        };
1228:                    };
1229:                };
1230:            };
1231:
1232:            public static enum ME001_01_ {
1233:                G_A_T, P_T, V_T, W_T
1234:            };
1235:
1236:            public void test_10() {
1237:                //Class cuCla = ME001.cccc2; - null
1238:                //Class cuCla = new ME001(77).cccccc1;
1239:                Class cuCla = ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5.class;
1240:                if (!cuCla
1241:                        .getEnclosingClass()
1242:                        .equals(
1243:                                java.lang.ClassHierarchyTest.ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.class))
1244:                    fail("test_1, case 004 FAILED: "
1245:                            + cuCla.getEnclosingClass());
1246:                if (cuCla.getEnumConstants() == null)
1247:                    fail("test_1, case 009 FAILED: " + cuCla.getEnumConstants());
1248:                ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5 ae[] = (ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5[]) cuCla
1249:                        .getEnumConstants();
1250:                for (int i = 0; i < ae.length; i++) {
1251:                    if (!ae[i]
1252:                            .equals(ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5.G_A_T)
1253:                            && !ae[i]
1254:                                    .equals(ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5.P_T)
1255:                            && !ae[i]
1256:                                    .equals(ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5.V_T)
1257:                            && !ae[i]
1258:                                    .equals(ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5.W_T)) {
1259:                        fail("test_1, case 001 FAILED: " + ae[i]
1260:                                + " is not this enum's constant");
1261:                    }
1262:                }
1263:                if (!cuCla.isEnum())
1264:                    fail("test_1, case 000 FAILED: " + cuCla.isEnum());
1265:                try {
1266:                    cuCla
1267:                            .asSubclass(ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.class);
1268:                    fail("test_1, case 011 FAILED: "
1269:                            + cuCla.asSubclass(ClassHierarchyTest.class));
1270:                } catch (Exception e) {/*e.printStackTrace();*/
1271:                }
1272:                if (cuCla.getEnclosingMethod() != null)
1273:                    fail("test_1, case 013 FAILED: "
1274:                            + cuCla.getEnclosingMethod());
1275:                if (cuCla.getEnclosingConstructor() != null)
1276:                    fail("test_1, case 014 FAILED: "
1277:                            + cuCla.getEnclosingConstructor());
1278:                if (!cuCla.isMemberClass())
1279:                    fail("test_1, case 017 FAILED: " + cuCla.isMemberClass());
1280:                if (cuCla.isLocalClass())
1281:                    fail("test_1, case 018 FAILED: " + cuCla.isLocalClass());
1282:                if (cuCla.isAnonymousClass())
1283:                    fail("test_1, case 019 FAILED: " + cuCla.isAnonymousClass());
1284:                if (cuCla.isSynthetic())
1285:                    fail("test_1, case 020 FAILED: " + cuCla.isSynthetic());
1286:                if (!cuCla
1287:                        .getCanonicalName()
1288:                        .equals(
1289:                                "java.lang.ClassHierarchyTest.ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5"))
1290:                    fail("test_1, case 021 FAILED: " + cuCla.getCanonicalName());
1291:                if (!cuCla.getSimpleName().equals("ME001_01_5"))
1292:                    fail("test_1, case 022 FAILED: " + cuCla.getSimpleName());
1293:
1294:                if (RuntimeAdditionalSupport1.openingFlag) {
1295:                    cuCla = ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5
1296:                            .pop();
1297:                    if (!cuCla
1298:                            .getEnclosingClass()
1299:                            .equals(
1300:                                    java.lang.ClassHierarchyTest.ME001.ME001_01_.ME001_01_1.ME001_01_2.ME001_01_3.ME001_01_4.ME001_01_5.class))
1301:                        fail("test_1, case 004 FAILED: "
1302:                                + cuCla.getEnclosingClass());
1303:                    if (cuCla.getEnumConstants() != null)
1304:                        fail("test_1, case 009 FAILED: "
1305:                                + cuCla.getEnumConstants());
1306:                    if (cuCla.isEnum())
1307:                        fail("test_1, case 000 FAILED: " + cuCla.isEnum());
1308:                    try {
1309:                        cuCla.asSubclass(ClassHierarchyTest.class);
1310:                        fail("test_1, case 011 FAILED: "
1311:                                + cuCla.asSubclass(ClassHierarchyTest.class));
1312:                    } catch (Exception e) {/*e.printStackTrace();*/
1313:                    }
1314:                    if (!cuCla.getEnclosingMethod().getName().equals("pop"))
1315:                        fail("test_1, case 013 FAILED: "
1316:                                + cuCla.getEnclosingMethod());
1317:                    if (cuCla.getEnclosingConstructor() != null)
1318:                        fail("test_1, case 014 FAILED: "
1319:                                + cuCla.getEnclosingConstructor());
1320:                    if (cuCla.isMemberClass())
1321:                        fail("test_1, case 017 FAILED: "
1322:                                + cuCla.isMemberClass());
1323:                    if (!cuCla.isLocalClass())
1324:                        fail("test_1, case 018 FAILED: " + cuCla.isLocalClass());
1325:                    if (cuCla.isAnonymousClass())
1326:                        fail("test_1, case 019 FAILED: "
1327:                                + cuCla.isAnonymousClass());
1328:                    if (cuCla.isSynthetic())
1329:                        fail("test_1, case 020 FAILED: " + cuCla.isSynthetic());
1330:                    if (cuCla.getCanonicalName() != null)
1331:                        fail("test_1, case 021 FAILED: "
1332:                                + cuCla.getCanonicalName());
1333:                    if (!cuCla.getSimpleName().equals("XXX"))
1334:                        fail("test_1, case 022 FAILED: "
1335:                                + cuCla.getSimpleName());
1336:                }
1337:
1338:            }
1339:
1340:            ///////////////////////// V:    
1341:            /**
1342:             * casting
1343:             */
1344:            interface XXX {
1345:            };
1346:
1347:            enum tmp15$ implements  XXX {
1348:                PENNY(1), NICKEL(5), DIME(10), QUARTER(25);
1349:                tmp15$(int value) {
1350:                    this .value = value;
1351:                }
1352:
1353:                private final int value;
1354:
1355:                public int value() {
1356:                    return value;
1357:                }
1358:
1359:                enum yyy$1$2$3 {
1360:                    WHITE, GREY, BLACK
1361:                };
1362:            }
1363:
1364:            static Object obj;
1365:
1366:            public void test_11() {
1367:                class A {
1368:                }
1369:                class B extends A {
1370:                }
1371:                class $tmp15 {
1372:                }
1373:                class $tmp16 {
1374:                }
1375:                try {
1376:                    Object o = new $tmp16();
1377:                    tmp15$.class.cast(o);
1378:                    tmp15$ x = (tmp15$) o;
1379:                    obj = x;
1380:                    fail("test_11, case 001 FAILED: ClassCastException should be risen");
1381:                } catch (ClassCastException e) {
1382:                }
1383:                try {
1384:                    Object o = new $tmp16();
1385:                    tmp15$ i = (tmp15$) o;
1386:                    obj = i;
1387:                    fail("test_11, case 002 FAILED: ClassCastException should be risen");
1388:                } catch (ClassCastException e) {
1389:                }
1390:                class CC<T extends Number> {
1391:                }
1392:                CC<Integer> io = new CC<Integer>();
1393:                CC<Float> fo = new CC<Float>();
1394:                fo.getClass().cast(io);
1395:                class Str {
1396:                }
1397:                class CCC<T extends Str & java.io.Serializable> {
1398:                }
1399:                class CCCc<T1 extends Str & java.io.Serializable, T2> {
1400:                }
1401:                class Xx extends Str implements  java.io.Serializable {
1402:                    static final long serialVersionUID = 0;
1403:                }
1404:                class Yy extends Str implements  java.io.Serializable {
1405:                    static final long serialVersionUID = 0;
1406:                }
1407:                CCC<?> io2 = new CCC<Xx>();
1408:                CCC<? extends Str> fo2 = new CCC<Yy>();
1409:                if (!io2.getClass().getName().equals(
1410:                        "java.lang.ClassHierarchyTest$1CCC")) {
1411:                    fail("test_11, case 003 FAILED: "
1412:                            + io2.getClass().getName());
1413:                }
1414:                if (!fo2.getClass().cast(io2).getClass().getName().equals(
1415:                        "java.lang.ClassHierarchyTest$1CCC")) {
1416:                    fail("test_11, case 004 FAILED: "
1417:                            + io2.getClass().getName());
1418:                }
1419:                CCCc<Xx, Yy> fo3 = new CCCc<Xx, Yy>();
1420:                Object o = new CCCc<Yy, Yy>();
1421:                try {
1422:                    // fo3 = (CCCc<Xx,Yy>) new CCCc<Yy,Yy>(); // inconvertible types: found : CCCc<Yy,Yy> - required: CCCc<Xx,Yy>
1423:                    fo3 = (CCCc<Xx, Yy>) o; // but it is run (look just above)!
1424:                    // so, it's expected the exceptions will risen while running deeply
1425:                    fo3.getClass().cast(new CCCc<Yy, Yy>()); // so, looks like our cast() implementation is not worse
1426:                } catch (Exception e) {
1427:                    fail("test_11, case 005 FAILED: " + e.toString());
1428:                }
1429:                try {
1430:                    Object ooo = (Object) fo2;
1431:                    if (fo3.getClass().isAssignableFrom(fo2.getClass())) {
1432:                        fail("test_11, case 006 FAILED");
1433:                    }
1434:                    if (ooo instanceof  CCCc) {
1435:                        fail("test_11, case 007 FAILEDn");
1436:                    }
1437:                    fo3.getClass().cast(fo2);
1438:                    fail("test_11, case 008 FAILED: ClassCastException should be risen");
1439:                } catch (ClassCastException e) {
1440:                    //e.printStackTrace();
1441:                }
1442:                try {
1443:                    Object o1 = new CCCc<Xx, Yy>();
1444:                    Object o2 = new CCCc<Xx, Yy>();
1445:                    Object o3 = o1.getClass().cast(o2);
1446:                    obj = o3;
1447:                    Object o4 = o2.getClass().cast(o1);
1448:                    obj = o4;
1449:                    Object o5 = o2.getClass().cast(null);
1450:                    obj = o5;
1451:                    Class cuCla1 = o1.getClass();
1452:                    Class cuCla2 = o2.getClass();
1453:                    Class cuCla3 = cuCla1.asSubclass(cuCla2);
1454:                    obj = cuCla3;
1455:                } catch (ClassCastException e) {
1456:                    fail("test_11, case 009 FAILED: ClassCastException should not be risen");
1457:                }
1458:                try {
1459:                    Object o1 = new CCCc<Xx, Xx>();
1460:                    Object o2 = new CCCc<Xx, Yy>();
1461:                    Object o3 = o1.getClass().cast(o2);
1462:                    obj = o3;
1463:                    Object o4 = o2.getClass().cast(o1);
1464:                    obj = o4;
1465:                    Object o5 = o2.getClass().cast(null);
1466:                    obj = o5;
1467:                    Class cuCla1 = o1.getClass();
1468:                    Class cuCla2 = o2.getClass();
1469:                    Class cuCla3 = cuCla1.asSubclass(cuCla2);
1470:                    obj = cuCla3;
1471:                } catch (ClassCastException e) {
1472:                    fail("test_11, case 010 FAILED: ClassCastException should  notbe risen");
1473:                }
1474:                try {
1475:                    Object o1 = new CCCc<Xx, Xx>();
1476:                    Object o2 = new CCCc<Yy, Yy>();
1477:                    Object o3 = o1.getClass().cast(o2);
1478:                    obj = o3;
1479:                    Object o4 = o2.getClass().cast(o1);
1480:                    obj = o4;
1481:                    Object o5 = o2.getClass().cast(null);
1482:                    obj = o5;
1483:                    Class cuCla1 = o1.getClass();
1484:                    Class cuCla2 = o2.getClass();
1485:                    Class cuCla3 = cuCla1.asSubclass(cuCla2);
1486:                    obj = cuCla3;
1487:                } catch (ClassCastException e) {
1488:                    fail("test_11, case 011 FAILED: ClassCastException should not be risen");
1489:                }
1490:                try {
1491:                    Object o1 = new CCCc<Xx, Xx>();
1492:                    Object o2 = new CCCc<Yy, Xx>();
1493:                    Object o3 = o1.getClass().cast(o2);
1494:                    obj = o3;
1495:                    Object o4 = o2.getClass().cast(o1);
1496:                    obj = o4;
1497:                    Object o5 = o2.getClass().cast(null);
1498:                    obj = o5;
1499:                    Class cuCla1 = o1.getClass();
1500:                    Class cuCla2 = o2.getClass();
1501:                    Class cuCla3 = cuCla1.asSubclass(cuCla2);
1502:                    obj = cuCla3;
1503:                } catch (ClassCastException e) {
1504:                    fail("test_11, case 012 FAILED: ClassCastException should not be risen");
1505:                }
1506:                try {
1507:                    Object o1 = new CCCc();
1508:                    Object o2 = new CCCc<Xx, Yy>();
1509:                    Object o3 = o1.getClass().cast(o2);
1510:                    obj = o3;
1511:                    Object o4 = o2.getClass().cast(o1);
1512:                    obj = o4;
1513:                    Object o5 = o2.getClass().cast(null);
1514:                    obj = o5;
1515:                    Class cuCla1 = o1.getClass();
1516:                    Class cuCla2 = o2.getClass();
1517:                    Class cuCla3 = cuCla1.asSubclass(cuCla2);
1518:                    obj = cuCla3;
1519:                } catch (ClassCastException e) {
1520:                    fail("test_11, case 013 FAILED: ClassCastException should not be risen");
1521:                }
1522:                try {
1523:                    Object o1 = new CCCc<Xx, Yy>();
1524:                    Object o2 = new CCCc();
1525:                    Object o3 = o1.getClass().cast(o2);
1526:                    obj = o3;
1527:                    Object o4 = o2.getClass().cast(o1);
1528:                    obj = o4;
1529:                    Object o5 = o2.getClass().cast(null);
1530:                    obj = o5;
1531:                    Class cuCla1 = o1.getClass();
1532:                    Class cuCla2 = o2.getClass();
1533:                    Class cuCla3 = cuCla1.asSubclass(cuCla2);
1534:                    obj = cuCla3;
1535:                } catch (ClassCastException e) {
1536:                    fail("test_11, case 014 FAILED: ClassCastException should not be risen");
1537:                }
1538:
1539:                class Str2 {
1540:                }
1541:                class CCC2<T extends Str & java.io.Serializable> {
1542:                }
1543:                class CCCc2<T1 extends Str & java.io.Serializable, T2> {
1544:                }
1545:                class Xx2 extends Str implements  java.io.Serializable {
1546:                    static final long serialVersionUID = 0;
1547:                }
1548:                class Yy2 extends Str implements  java.io.Serializable {
1549:                    static final long serialVersionUID = 0;
1550:                }
1551:                CCC2<? extends Str> fo22 = new CCC2<Yy2>();
1552:                CCCc2<Xx2, Yy2> fo33 = new CCCc2<Xx2, Yy2>();
1553:                Object o2 = new CCCc2<Yy, Yy>();
1554:                try {
1555:                    fo33 = (CCCc2<Xx2, Yy2>) o2;
1556:                    fo33.getClass().cast(new CCCc2<Yy2, Yy2>());
1557:                    try {
1558:                        fo33.getClass().cast(new CCCc<Yy2, Yy2>());
1559:                        fail("test_11, case 015 FAILED: ClassCastException should be risen");
1560:                    } catch (ClassCastException e) {
1561:                    }
1562:                    fo33.getClass().cast(new CCCc2<Yy, Yy>());
1563:                } catch (Exception e) {
1564:                    e.printStackTrace();
1565:                    fail("test_11, case 016 FAILED: " + e.toString());
1566:                }
1567:                try {
1568:                    fo33.getClass().cast(fo22);
1569:                    fail("test_11, case 017 FAILED: ClassCastException should be risen");
1570:                } catch (ClassCastException e) {
1571:                    //e.printStackTrace();
1572:                }
1573:
1574:            }
1575:
1576:            /**
1577:             * generalized member class
1578:             */
1579:            @anna
1580:            public void test_12() {
1581:                Class cuCla = new MC002<Object, java.lang.reflect.Proxy, MC002<Integer, Void, Character>.MC002_01<Integer, Void, Character>.MC002_01_01<Integer, Void, Character>.MC002_01_01_01<Integer, Void, Character>.MC002_01_01_01_01<Integer, Void, Character>.MC002_01_01_01_01_01<Integer, Void, Character>.MC002_01_01_01_01_01_01<Integer, Void, Character>>()
1582:                        .getClass();
1583:                if (!cuCla.getEnclosingClass().equals(ClassHierarchyTest.class))
1584:                    fail("test_1, case 004 FAILED: "
1585:                            + cuCla.getEnclosingClass());
1586:                if (cuCla.getEnumConstants() != null)
1587:                    fail("test_1, case 009 FAILED: " + cuCla.getEnumConstants());
1588:                if (cuCla.isEnum())
1589:                    fail("test_1, case 000 FAILED: " + cuCla.isEnum());
1590:                try {
1591:                    cuCla.asSubclass(ClassHierarchyTest.class);
1592:                    fail("test_1, case 011 FAILED: "
1593:                            + cuCla.asSubclass(ClassHierarchyTest.class));
1594:                } catch (Exception e) {/*e.printStackTrace();*/
1595:                }
1596:                if (cuCla.getEnclosingMethod() != null)
1597:                    fail("test_1, case 013 FAILED: "
1598:                            + cuCla.getEnclosingMethod());
1599:                if (cuCla.getEnclosingConstructor() != null)
1600:                    fail("test_1, case 014 FAILED: "
1601:                            + cuCla.getEnclosingConstructor());
1602:                if (!cuCla.isMemberClass())
1603:                    fail("test_1, case 017 FAILED: " + cuCla.isMemberClass());
1604:                if (cuCla.isLocalClass())
1605:                    fail("test_1, case 018 FAILED: " + cuCla.isLocalClass());
1606:                if (cuCla.isAnonymousClass())
1607:                    fail("test_1, case 019 FAILED: " + cuCla.isAnonymousClass());
1608:                if (cuCla.isSynthetic())
1609:                    fail("test_1, case 020 FAILED: " + cuCla.isSynthetic());
1610:                if (!cuCla.getCanonicalName().equals(
1611:                        "java.lang.ClassHierarchyTest.MC002"))
1612:                    fail("test_1, case 021 FAILED: " + cuCla.getCanonicalName());
1613:                if (!cuCla.getSimpleName().equals("MC002"))
1614:                    fail("test_1, case 022 FAILED: " + cuCla.getSimpleName());
1615:
1616:                if (cuCla.getGenericInterfaces().length != 0)
1617:                    fail("test_1, case 022 FAILED: "
1618:                            + cuCla.getGenericInterfaces().length);
1619:                if (!((Class) cuCla.getGenericSuperclass()).getName().equals(
1620:                        "java.lang.Object"))
1621:                    fail("test_1, case 022 FAILED: "
1622:                            + ((Class) cuCla.getGenericSuperclass()).getName());
1623:                if (cuCla.getTypeParameters().length == 0)
1624:                    fail("test_1, case 022 FAILED: "
1625:                            + cuCla.getTypeParameters().length);
1626:                /* !!! */System.out.println(111);
1627:
1628:                Annotation aaa = null;
1629:                try {
1630:                    aaa = ClassHierarchyTest.class.getMethod("test_12")
1631:                            .getAnnotations()[0];
1632:                } catch (NoSuchMethodException e) {
1633:                    fail("test_1, case 022 FAILED: Internal Error");
1634:                }
1635:                try {
1636:                    if (cuCla.cast(aaa) == null)
1637:                        fail("test_1, case 022 FAILED: "
1638:                                + cuCla.getSimpleName());
1639:                } catch (Exception e) {/*e.printStackTrace();*/
1640:                }
1641:
1642:                if (cuCla.getAnnotation(aaa.annotationType()) != null)
1643:                    fail("test_1, case 022 FAILED: " + cuCla.getSimpleName());
1644:                if (cuCla.getAnnotations().length == 0)
1645:                    fail("test_1, case 022 FAILED: " + cuCla.getSimpleName());
1646:                if (cuCla.getDeclaredAnnotations().length == 0)
1647:                    fail("test_1, case 022 FAILED: " + cuCla.getSimpleName());
1648:                if (cuCla.isAnnotation())
1649:                    fail("test_1, case 022 FAILED: " + cuCla.getSimpleName());
1650:                if (cuCla.isAnnotationPresent(aaa.annotationType()))
1651:                    fail("test_1, case 022 FAILED: " + cuCla.getSimpleName());
1652:            }
1653:
1654:            /**
1655:             * generalized member interface
1656:             */
1657:            //Commented because of the drlvm issue
1658:            public void te_st_12_1() { // it is eclipse's bug
1659:                // It's strange that if we use javac instead of ecj
1660:                // then we have no such problem
1661:                //   <<< java.lang.NoClassDefFoundError: Ajava/lang/ClassHierarchyTest$1xxx: class name in class data does not match class name passed>>>
1662:                // so it should be investigated.
1663:
1664:                // The wollowing crashes bvm:
1665:                //class x implements MI002.MI002_01.MI002_01_01.MI002_01_01_01.MI002_01_01_01_01.MI002_01_01_01_01_01.MI002_01_01_01_01_01_01<java.io.Serializable, java.lang.reflect.Type, java.lang.reflect.InvocationHandler> {};
1666:                //Class cuCla = (Class)x.class.getGenericInterfaces()[0];
1667:                class xxx
1668:                        implements 
1669:                        MI002.MI002_01.MI002_01_01.MI002_01_01_01.MI002_01_01_01_01.MI002_01_01_01_01_01.MI002_01_01_01_01_01_01<java.io.Serializable, java.lang.reflect.Type, java.lang.reflect.InvocationHandler> {
1670:                }
1671:                ;
1672:                Class cuCla = (Class) ((java.lang.reflect.ParameterizedType) xxx.class
1673:                        .getGenericInterfaces()[0]).getRawType();
1674:                if (!cuCla
1675:                        .getEnclosingClass()
1676:                        .equals(
1677:                                MI002.MI002_01.MI002_01_01.MI002_01_01_01.MI002_01_01_01_01.MI002_01_01_01_01_01.class))
1678:                    fail("test_1, case 004 FAILED: "
1679:                            + cuCla.getEnclosingClass());
1680:                if (cuCla.getEnumConstants() != null)
1681:                    fail("test_1, case 009 FAILED: " + cuCla.getEnumConstants());
1682:                if (cuCla.isEnum())
1683:                    fail("test_1, case 000 FAILED: " + cuCla.isEnum());
1684:                try {
1685:                    cuCla.asSubclass(ClassHierarchyTest.class);
1686:                    fail("test_1, case 011 FAILED: "
1687:                            + cuCla.asSubclass(ClassHierarchyTest.class));
1688:                } catch (Exception e) {/*e.printStackTrace();*/
1689:                }
1690:                if (cuCla.getEnclosingMethod() != null)
1691:                    fail("test_1, case 013 FAILED: "
1692:                            + cuCla.getEnclosingMethod());
1693:                if (cuCla.getEnclosingConstructor() != null)
1694:                    fail("test_1, case 014 FAILED: "
1695:                            + cuCla.getEnclosingConstructor());
1696:                if (!cuCla.isMemberClass())
1697:                    fail("test_1, case 017 FAILED: " + cuCla.isMemberClass());
1698:                if (cuCla.isLocalClass())
1699:                    fail("test_1, case 018 FAILED: " + cuCla.isLocalClass());
1700:                if (cuCla.isAnonymousClass())
1701:                    fail("test_1, case 019 FAILED: " + cuCla.isAnonymousClass());
1702:                if (cuCla.isSynthetic())
1703:                    fail("test_1, case 020 FAILED: " + cuCla.isSynthetic());
1704:                if (!cuCla
1705:                        .getCanonicalName()
1706:                        .equals(
1707:                                "java.lang.ClassHierarchyTest.MI002.MI002_01.MI002_01_01.MI002_01_01_01.MI002_01_01_01_01.MI002_01_01_01_01_01.MI002_01_01_01_01_01_01"))
1708:                    fail("test_1, case 021 FAILED: " + cuCla.getCanonicalName());
1709:                if (!cuCla.getSimpleName().equals("MI002_01_01_01_01_01_01"))
1710:                    fail("test_1, case 022 FAILED: " + cuCla.getSimpleName());
1711:            }
1712:
1713:            /**
1714:             * deeply nested generalized member classes
1715:             */
1716:            public void test_13() {
1717:                Class cuCla = new MC002<Object, java.lang.reflect.Proxy, MC002<Integer, Void, Character>.MC002_01<Integer, Void, Character>.MC002_01_01<Integer, Void, Character>.MC002_01_01_01<Integer, Void, Character>.MC002_01_01_01_01<Integer, Void, Character>.MC002_01_01_01_01_01<Integer, Void, Character>.MC002_01_01_01_01_01_01<Integer, Void, Character>>()
1718:                        .getClass();
1719:                String caNa = cuCla.getCanonicalName();
1720:                //String name[] = caNa.split("\\$");
1721:                String name[] = caNa.split("\\.");
1722:                int i = name.length - 1;
1723:                while (cuCla != null) {
1724:                    if (cuCla.getEnclosingClass() != null
1725:                            && cuCla.getEnclosingClass().getSimpleName()
1726:                                    .equals(name[i]))
1727:                        fail("test_2, case 002 FAILED: "
1728:                                + cuCla.getEnclosingClass().getSimpleName());
1729:                    if (cuCla.getEnumConstants() != null)
1730:                        fail("test_2, case 009 FAILED: "
1731:                                + cuCla.getEnumConstants());
1732:                    if (cuCla.isEnum())
1733:                        fail("test_2, case 000 FAILED: " + cuCla.isEnum());
1734:                    try {
1735:                        cuCla
1736:                                .asSubclass(cuCla.getEnclosingClass() != null ? cuCla
1737:                                        .getEnclosingClass()
1738:                                        : cuCla);
1739:                        if (!cuCla.getCanonicalName().equals(
1740:                                "java.lang.ClassHierarchyTest"))
1741:                            fail("test_2, case 011 FAILED: "
1742:                                    + cuCla
1743:                                            .asSubclass(cuCla
1744:                                                    .getEnclosingClass() != null ? cuCla
1745:                                                    .getEnclosingClass()
1746:                                                    : cuCla));
1747:                    } catch (Exception e) {/*e.printStackTrace();*/
1748:                    }
1749:                    if (cuCla.getEnclosingMethod() != null)
1750:                        fail("test_2, case 013 FAILED: "
1751:                                + cuCla.getEnclosingMethod());
1752:                    if (cuCla.getEnclosingConstructor() != null)
1753:                        fail("test_2, case 014 FAILED: "
1754:                                + cuCla.getEnclosingConstructor());
1755:                    if (cuCla.getEnclosingClass() != null
1756:                            && !cuCla.isMemberClass())
1757:                        fail("test_1, case 017 FAILED: "
1758:                                + cuCla.isMemberClass());
1759:                    if (cuCla.isLocalClass())
1760:                        fail("test_2, case 018 FAILED: " + cuCla.isLocalClass());
1761:                    if (cuCla.isAnonymousClass())
1762:                        fail("test_2, case 019 FAILED: "
1763:                                + cuCla.isAnonymousClass());
1764:                    if (cuCla.isSynthetic())
1765:                        fail("test_2, case 020 FAILED: " + cuCla.isSynthetic());
1766:                    if (!cuCla.getCanonicalName().equals(caNa))
1767:                        fail("test_2, case 021 FAILED: "
1768:                                + cuCla.getCanonicalName());
1769:                    caNa = caNa.substring(0, caNa.lastIndexOf('.'));
1770:                    if (!cuCla.getSimpleName().equals(name[i]))
1771:                        fail("test_2, case 022 FAILED: "
1772:                                + cuCla.getSimpleName());
1773:                    i--;
1774:                    cuCla = cuCla.getEnclosingClass();
1775:                }
1776:            }
1777:
1778:            /**
1779:             * deeply nested generalized member interfaces
1780:             */
1781:            //Commented because of the drlvm issue
1782:            public void te_st_13_1() { // it is eclipse's bug
1783:                // It's strange that if we use javac instead of ecj
1784:                // then we have no such problem
1785:                //   <<< java.lang.NoClassDefFoundError: Ajava/lang/ClassHierarchyTest$1xxx: class name in class data does not match class name passed>>>
1786:                // so it should be investigated.
1787:                //Class cuCla = MI001.MI001_01.MI001_01_01.MI001_01_01_01.MI001_01_01_01_01.MI001_01_01_01_01_01.MI001_01_01_01_01_01_01.class;
1788:                class xxx
1789:                        implements 
1790:                        MI002.MI002_01.MI002_01_01.MI002_01_01_01.MI002_01_01_01_01.MI002_01_01_01_01_01.MI002_01_01_01_01_01_01<java.io.Serializable, java.lang.reflect.Type, java.lang.reflect.InvocationHandler> {
1791:                }
1792:                ;
1793:                Class cuCla = (Class) ((java.lang.reflect.ParameterizedType) xxx.class
1794:                        .getGenericInterfaces()[0]).getRawType();
1795:                String caNa = cuCla.getCanonicalName();
1796:                //String name[] = caNa.split("\\$");
1797:                String name[] = caNa.split("\\.");
1798:                int i = name.length - 1;
1799:                while (cuCla != null) {
1800:                    if (cuCla.getEnclosingClass() != null
1801:                            && cuCla.getEnclosingClass().getSimpleName()
1802:                                    .equals(name[i]))
1803:                        fail("test_2, case 002 FAILED: "
1804:                                + cuCla.getEnclosingClass().getSimpleName());
1805:                    if (cuCla.getEnumConstants() != null)
1806:                        fail("test_2, case 009 FAILED: "
1807:                                + cuCla.getEnumConstants());
1808:                    if (cuCla.isEnum())
1809:                        fail("test_2, case 000 FAILED: " + cuCla.isEnum());
1810:                    try {
1811:                        cuCla
1812:                                .asSubclass(cuCla.getEnclosingClass() != null ? cuCla
1813:                                        .getEnclosingClass()
1814:                                        : cuCla);
1815:                        if (!cuCla.getCanonicalName().equals(
1816:                                "java.lang.ClassHierarchyTest"))
1817:                            fail("test_2, case 011 FAILED: "
1818:                                    + cuCla
1819:                                            .asSubclass(cuCla
1820:                                                    .getEnclosingClass() != null ? cuCla
1821:                                                    .getEnclosingClass()
1822:                                                    : cuCla));
1823:                    } catch (Exception e) {/*e.printStackTrace();*/
1824:                    }
1825:                    if (cuCla.getEnclosingMethod() != null)
1826:                        fail("test_2, case 013 FAILED: "
1827:                                + cuCla.getEnclosingMethod());
1828:                    if (cuCla.getEnclosingConstructor() != null)
1829:                        fail("test_2, case 014 FAILED: "
1830:                                + cuCla.getEnclosingConstructor());
1831:                    if (cuCla.getEnclosingClass() != null
1832:                            && !cuCla.isMemberClass())
1833:                        fail("test_1, case 017 FAILED: "
1834:                                + cuCla.isMemberClass());
1835:                    if (cuCla.isLocalClass())
1836:                        fail("test_2, case 018 FAILED: " + cuCla.isLocalClass());
1837:                    if (cuCla.isAnonymousClass())
1838:                        fail("test_2, case 019 FAILED: "
1839:                                + cuCla.isAnonymousClass());
1840:                    if (cuCla.isSynthetic())
1841:                        fail("test_2, case 020 FAILED: " + cuCla.isSynthetic());
1842:                    if (!cuCla.getCanonicalName().equals(caNa))
1843:                        fail("test_2, case 021 FAILED: "
1844:                                + cuCla.getCanonicalName());
1845:                    caNa = caNa.substring(0, caNa.lastIndexOf('.'));
1846:                    if (!cuCla.getSimpleName().equals(name[i]))
1847:                        fail("test_2, case 022 FAILED: "
1848:                                + cuCla.getSimpleName());
1849:                    i--;
1850:                    cuCla = cuCla.getEnclosingClass();
1851:                }
1852:            }
1853:
1854:            /**
1855:             * unnested generalized local class
1856:             */
1857:            public <T0> void test_14() {
1858:                @i
1859:                class LC000<T1 extends T0> {
1860:
1861:                }
1862:                //@i class LC001<T1 extends T0 &java.io.Serializable &java.lang.reflect.Type &java.lang.reflect.GenericDeclaration> {
1863:                @i
1864:                class LC001<T1 extends LC000 & java.io.Serializable & java.lang.reflect.Type & GenericDeclaration> {
1865:                    java.lang.reflect.TypeVariable<?>[] getTypeParameters() {
1866:                        return (java.lang.reflect.TypeVariable<?>[]) null;
1867:                    }
1868:                }
1869:                ;
1870:                new LC001().getTypeParameters();
1871:                if (!LC001.class.getEnclosingClass().equals(
1872:                        ClassHierarchyTest.class))
1873:                    fail("test_3, case 004 FAILED: "
1874:                            + LC001.class.getEnclosingClass());
1875:                if (LC001.class.getEnumConstants() != null)
1876:                    fail("test_3, case 009 FAILED: "
1877:                            + LC001.class.getEnumConstants());
1878:                if (LC001.class.isEnum())
1879:                    fail("test_3, case 000 FAILED: " + LC001.class.isEnum());
1880:                try {
1881:                    LC001.class.asSubclass(ClassHierarchyTest.class);
1882:                    fail("test_3, case 011 FAILED: "
1883:                            + LC001.class.asSubclass(ClassHierarchyTest.class));
1884:                } catch (Exception e) {/*e.printStackTrace();*/
1885:                }
1886:                if (!LC001.class.getEnclosingMethod().getName().equals(
1887:                        "test_14"))
1888:                    fail("test_3, case 013 FAILED: "
1889:                            + LC001.class.getEnclosingMethod().getName());
1890:                if (LC001.class.getEnclosingConstructor() != null)
1891:                    fail("test_3, case 014 FAILED: "
1892:                            + LC001.class.getEnclosingConstructor());
1893:                if (LC001.class.isMemberClass())
1894:                    fail("test_3, case 017 FAILED: "
1895:                            + LC001.class.isMemberClass());
1896:                if (!LC001.class.isLocalClass())
1897:                    fail("test_3, case 018 FAILED: "
1898:                            + LC001.class.isLocalClass());
1899:                if (LC001.class.isAnonymousClass())
1900:                    fail("test_3, case 019 FAILED: "
1901:                            + LC001.class.isAnonymousClass());
1902:                if (LC001.class.isSynthetic())
1903:                    fail("test_3, case 020 FAILED: "
1904:                            + LC001.class.isSynthetic());
1905:                if (LC001.class.getCanonicalName() != null)
1906:                    fail("test_3, case 021 FAILED: "
1907:                            + LC001.class.getCanonicalName());
1908:                if (!LC001.class.getSimpleName().equals("LC001"))
1909:                    fail("test_3, case 022 FAILED: "
1910:                            + LC001.class.getSimpleName());
1911:            }
1912:
1913:            /**
1914:             * generalized local               ClassHierarchyTest$1$LC003$1A.class   (1)
1915:             * generalized anonymous           ClassHierarchyTest$1$LC003$1.class    (2)
1916:             * generalized member of anonymous ClassHierarchyTest$1$LC003$1$A.class  (3)
1917:             * generalized local               ClassHierarchyTest$1$LC003$1AAA.class (4)
1918:             */
1919:            static int f2 = 0;
1920:            static Object ooo2 = null;
1921:
1922:            public <T0 extends MC002> void test_15() { // it is eclipse's bug
1923:                // It's strange that if we use javac instead of ecj
1924:                // then we have no such problem
1925:                //   <<< java.lang.NoClassDefFoundError: Ajava/lang/ClassHierarchyTest$1xxx: class name in class data does not match class name passed>>>
1926:                // so it should be investigated.
1927:                @i
1928:                class LC002<T1 extends T0> {
1929:                }
1930:                ;
1931:                class $LC003<T2 extends ClassHierarchyTest & java.lang.reflect.ParameterizedType> {
1932:                    public Class value() {
1933:                        class A<T3 extends T2> extends $LC003 { // (1)
1934:                        }
1935:                        ;
1936:                        Object o = new LC002<T0>() { // (2)
1937:                            class A<T5, T6, T7, T8, T9> { // (3)
1938:                            }
1939:
1940:                            Class m1() {
1941:                                return A.class;
1942:                            }
1943:
1944:                            Class m2() {
1945:                                return m1() == null ? m3() : m1();
1946:                            }
1947:
1948:                            Class m3() {
1949:                                return m2() == null ? m1() : m2();
1950:                            }
1951:                        };
1952:                        ooo2 = o;
1953:                        if (f2 < 1) {
1954:                            f2 += 1;
1955:                            return A.class;
1956:                        }
1957:                        f2 += 1;
1958:                        return o.getClass();
1959:                    }
1960:
1961:                    public Class value2() {
1962:                        class AAA<T10> { // (4)
1963:                        }
1964:                        ;
1965:                        return AAA.class;
1966:                    }
1967:                }
1968:                class X$1Y<T11> {
1969:                }
1970:                class X<T12, T13 extends ClassHierarchyTest> {
1971:                    Class m2() {
1972:                        class Y<T121, T131> { // it has "X$2Y" name!!! So, compiler provides the
1973:                            // difference with the previous "X$1Y"
1974:                        }
1975:                        return Y.class;
1976:                    }
1977:                }
1978:                new X().m2();
1979:                Class cuCla = new $LC003().value(); // ClassHierarchyTest$1$LC003$1A.class   (1)
1980:                if (!cuCla.getEnclosingClass().equals($LC003.class))
1981:                    fail("test_4, case 004 FAILED: "
1982:                            + cuCla.getEnclosingClass());
1983:                if (cuCla.getEnumConstants() != null)
1984:                    fail("test_4, case 009 FAILED: " + cuCla.getEnumConstants());
1985:                if (cuCla.isEnum())
1986:                    fail("test_4, case 000 FAILED: " + cuCla.isEnum());
1987:                try {
1988:                    cuCla.asSubclass(ClassHierarchyTest.class);
1989:                    fail("test_4, case 011 FAILED: "
1990:                            + cuCla.asSubclass(ClassHierarchyTest.class));
1991:                } catch (Exception e) {/*e.printStackTrace();*/
1992:                }
1993:                if (!cuCla.getEnclosingMethod().getName().equals("value"))
1994:                    fail("test_4, case 013 FAILED: "
1995:                            + cuCla.getEnclosingMethod().getName());
1996:                if (cuCla.getEnclosingConstructor() != null)
1997:                    fail("test_4, case 014 FAILED: "
1998:                            + cuCla.getEnclosingConstructor());
1999:                if (cuCla.isMemberClass())
2000:                    fail("test_4, case 017 FAILED: " + cuCla.isMemberClass());
2001:                if (!cuCla.isLocalClass())
2002:                    fail("test_4, case 018 FAILED: " + cuCla.isLocalClass());
2003:                if (cuCla.isAnonymousClass())
2004:                    fail("test_4, case 019 FAILED: " + cuCla.isAnonymousClass());
2005:                if (cuCla.isSynthetic())
2006:                    fail("test_4, case 020 FAILED: " + cuCla.isSynthetic());
2007:                if (cuCla.getCanonicalName() != null)
2008:                    fail("test_4, case 021 FAILED: " + cuCla.getCanonicalName());
2009:                if (!cuCla.getSimpleName().equals("A"))
2010:                    fail("test_4, case 022 FAILED: " + cuCla.getSimpleName());
2011:
2012:                cuCla = new $LC003().value(); // ClassHierarchyTest$1$LC003$1.class    (2)
2013:                if (!cuCla.getEnclosingClass().equals($LC003.class))
2014:                    fail("test_4, case 023 FAILED: "
2015:                            + cuCla.getEnclosingClass());
2016:                if (cuCla.getEnumConstants() != null)
2017:                    fail("test_4, case 024 FAILED: " + cuCla.getEnumConstants());
2018:                if (cuCla.isEnum())
2019:                    fail("test_4, case 025 FAILED: " + cuCla.isEnum());
2020:                try {
2021:                    cuCla.asSubclass(ClassHierarchyTest.class);
2022:                    fail("test_4, case 026 FAILED: "
2023:                            + cuCla.asSubclass(ClassHierarchyTest.class));
2024:                } catch (Exception e) {/*e.printStackTrace();*/
2025:                }
2026:                if (!cuCla.getEnclosingMethod().getName().equals("value"))
2027:                    fail("test_4, case 027 FAILED: "
2028:                            + cuCla.getEnclosingMethod().getName());
2029:                if (cuCla.getEnclosingConstructor() != null)
2030:                    fail("test_4, case 028 FAILED: "
2031:                            + cuCla.getEnclosingConstructor());
2032:                if (cuCla.isMemberClass())
2033:                    fail("test_4, case 029 FAILED: " + cuCla.isMemberClass());
2034:                if (cuCla.isLocalClass())
2035:                    fail("test_4, case 030 FAILED: " + cuCla.isLocalClass());
2036:                if (!cuCla.isAnonymousClass())
2037:                    fail("test_4, case 031 FAILED: " + cuCla.isAnonymousClass());
2038:                if (cuCla.isSynthetic())
2039:                    fail("test_4, case 032 FAILED: " + cuCla.isSynthetic());
2040:                if (cuCla.getCanonicalName() != null)
2041:                    fail("test_4, case 033 FAILED: " + cuCla.getCanonicalName());
2042:                if (!cuCla.getSimpleName().equals(""))
2043:                    fail("test_4, case 034 FAILED: " + cuCla.getSimpleName());
2044:
2045:                cuCla = new $LC003().value2(); // ClassHierarchyTest$1$LC003$1AAA.class (4)
2046:                if (!cuCla.getEnclosingClass().equals($LC003.class))
2047:                    fail("test_4, case 035 FAILED: "
2048:                            + cuCla.getEnclosingClass());
2049:                if (cuCla.getEnumConstants() != null)
2050:                    fail("test_4, case 036 FAILED: " + cuCla.getEnumConstants());
2051:                if (cuCla.isEnum())
2052:                    fail("test_4, case 037 FAILED: " + cuCla.isEnum());
2053:                try {
2054:                    cuCla.asSubclass(ClassHierarchyTest.class);
2055:                    fail("test_4, case 038 FAILED: "
2056:                            + cuCla.asSubclass(ClassHierarchyTest.class));
2057:                } catch (Exception e) {/*e.printStackTrace();*/
2058:                }
2059:                if (!cuCla.getEnclosingMethod().getName().equals("value2"))
2060:                    fail("test_4, case 039 FAILED: "
2061:                            + cuCla.getEnclosingMethod().getName());
2062:                if (cuCla.getEnclosingConstructor() != null)
2063:                    fail("test_4, case 040 FAILED: "
2064:                            + cuCla.getEnclosingConstructor());
2065:                if (cuCla.isMemberClass())
2066:                    fail("test_4, case 041 FAILED: " + cuCla.isMemberClass());
2067:                if (!cuCla.isLocalClass())
2068:                    fail("test_4, case 042 FAILED: " + cuCla.isLocalClass());
2069:                if (cuCla.isAnonymousClass())
2070:                    fail("test_4, case 043 FAILED: " + cuCla.isAnonymousClass());
2071:                if (cuCla.isSynthetic())
2072:                    fail("test_4, case 044 FAILED: " + cuCla.isSynthetic());
2073:                if (cuCla.getCanonicalName() != null)
2074:                    fail("test_4, case 045 FAILED: " + cuCla.getCanonicalName());
2075:                if (!cuCla.getSimpleName().equals("AAA"))
2076:                    fail("test_4, case 046 FAILED: " + cuCla.getSimpleName());
2077:
2078:                try {
2079:                    cuCla = (Class) new $LC003().value()
2080:                            .getDeclaredMethod("m1").invoke(ooo2,
2081:                                    (Object[]) null); // ClassHierarchyTest$1$LC003$1$A.class  (3)
2082:                    Class tc = Class
2083:                            .forName("java.lang.ClassHierarchyTest$2$LC003$1");
2084:                    if (!cuCla.getEnclosingClass().equals(tc))
2085:                        fail("test_4, case 047 FAILED: "
2086:                                + cuCla.getEnclosingClass());
2087:                    if (cuCla.getEnumConstants() != null)
2088:                        fail("test_4, case 048 FAILED: "
2089:                                + cuCla.getEnumConstants());
2090:                    if (cuCla.isEnum())
2091:                        fail("test_4, case 049 FAILED: " + cuCla.isEnum());
2092:                    try {
2093:                        cuCla.asSubclass(ClassHierarchyTest.class);
2094:                        fail("test_4, case 050 FAILED: "
2095:                                + cuCla.asSubclass(ClassHierarchyTest.class));
2096:                    } catch (Exception e) {/*e.printStackTrace();*/
2097:                    }
2098:                    if (cuCla.getEnclosingMethod() != null)
2099:                        fail("test_4, case 051 FAILED: "
2100:                                + cuCla.getEnclosingMethod());
2101:                    if (cuCla.getEnclosingConstructor() != null)
2102:                        fail("test_4, case 052 FAILED: "
2103:                                + cuCla.getEnclosingConstructor());
2104:                    if (!cuCla.isMemberClass())
2105:                        fail("test_4, case 053 FAILED: "
2106:                                + cuCla.isMemberClass());
2107:                    if (cuCla.isLocalClass())
2108:                        fail("test_4, case 054 FAILED: " + cuCla.isLocalClass());
2109:                    if (cuCla.isAnonymousClass())
2110:                        fail("test_4, case 055 FAILED: "
2111:                                + cuCla.isAnonymousClass());
2112:                    if (cuCla.isSynthetic())
2113:                        fail("test_4, case 056 FAILED: " + cuCla.isSynthetic());
2114:                    if (cuCla.getCanonicalName() != null)
2115:                        fail("test_4, case 057 FAILED: "
2116:                                + cuCla.getCanonicalName());
2117:                    if (!cuCla.getSimpleName().equals("A"))
2118:                        fail("test_4, case 058 FAILED: "
2119:                                + cuCla.getSimpleName());
2120:                } catch (ClassNotFoundException e) {
2121:                    fail(e.getMessage());
2122:                } catch (IllegalAccessException e) {
2123:                    fail(e.getMessage());
2124:                } catch (IllegalArgumentException e) {
2125:                    fail(e.getMessage());
2126:                } catch (java.lang.reflect.InvocationTargetException e) {
2127:                    fail(e.getMessage());
2128:                } catch (NoSuchMethodException e) {
2129:                    fail(e.getMessage());
2130:                }
2131:
2132:                cuCla = X$1Y.class; // ClassHierarchyTest$1X$1Y.class  (3)
2133:                if (!cuCla.getEnclosingClass().equals(ClassHierarchyTest.class))
2134:                    fail("test_4, case 059 FAILED: "
2135:                            + cuCla.getEnclosingClass());
2136:                if (cuCla.getEnumConstants() != null)
2137:                    fail("test_4, case 060 FAILED: " + cuCla.getEnumConstants());
2138:                if (cuCla.isEnum())
2139:                    fail("test_4, case 061 FAILED: " + cuCla.isEnum());
2140:                try {
2141:                    cuCla.asSubclass(ClassHierarchyTest.class);
2142:                    fail("test_4, case 062 FAILED: "
2143:                            + cuCla.asSubclass(ClassHierarchyTest.class));
2144:                } catch (Exception e) {/*e.printStackTrace();*/
2145:                }
2146:                if (!cuCla.getEnclosingMethod().getName().equals("test_15"))
2147:                    fail("test_4, case 063 FAILED: "
2148:                            + cuCla.getEnclosingMethod().getName());
2149:                if (cuCla.getEnclosingConstructor() != null)
2150:                    fail("test_4, case 064 FAILED: "
2151:                            + cuCla.getEnclosingConstructor());
2152:                if (cuCla.isMemberClass())
2153:                    fail("test_4, case 065 FAILED: " + cuCla.isMemberClass());
2154:                if (!cuCla.isLocalClass())
2155:                    fail("test_4, case 066 FAILED: " + cuCla.isLocalClass());
2156:                if (cuCla.isAnonymousClass())
2157:                    fail("test_4, case 067 FAILED: " + cuCla.isAnonymousClass());
2158:                if (cuCla.isSynthetic())
2159:                    fail("test_4, case 068 FAILED: " + cuCla.isSynthetic());
2160:                if (cuCla.getCanonicalName() != null)
2161:                    fail("test_4, case 069 FAILED: " + cuCla.getCanonicalName());
2162:                if (!cuCla.getSimpleName().equals("X$1Y"))
2163:                    fail("test_4, case 070 FAILED: " + cuCla.getSimpleName());
2164:
2165:                try {
2166:                    cuCla = (Class) X.class.getDeclaredMethod("m2").invoke(
2167:                            new X(), (Object[]) null); // ClassHierarchyTest$1$LC003$1$A.class  (3)
2168:                    if (!cuCla.getEnclosingClass().equals(X.class))
2169:                        fail("test_4, case 071 FAILED: "
2170:                                + cuCla.getEnclosingClass());
2171:                    if (cuCla.getEnumConstants() != null)
2172:                        fail("test_4, case 072 FAILED: "
2173:                                + cuCla.getEnumConstants());
2174:                    if (cuCla.isEnum())
2175:                        fail("test_4, case 073 FAILED: " + cuCla.isEnum());
2176:                    try {
2177:                        cuCla.asSubclass(ClassHierarchyTest.class);
2178:                        fail("test_4, case 074 FAILED: "
2179:                                + cuCla.asSubclass(ClassHierarchyTest.class));
2180:                    } catch (Exception e) {/*e.printStackTrace();*/
2181:                    }
2182:                    if (!cuCla.getEnclosingMethod().getName().equals("m2"))
2183:                        fail("test_4, case 075 FAILED: "
2184:                                + cuCla.getEnclosingMethod().getName());
2185:                    if (cuCla.getEnclosingConstructor() != null)
2186:                        fail("test_4, case 076 FAILED: "
2187:                                + cuCla.getEnclosingConstructor());
2188:                    if (cuCla.isMemberClass())
2189:                        fail("test_4, case 077 FAILED: "
2190:                                + cuCla.isMemberClass());
2191:                    if (!cuCla.isLocalClass())
2192:                        fail("test_4, case 078 FAILED: " + cuCla.isLocalClass());
2193:                    if (cuCla.isAnonymousClass())
2194:                        fail("test_4, case 079 FAILED: "
2195:                                + cuCla.isAnonymousClass());
2196:                    if (cuCla.isSynthetic())
2197:                        fail("test_4, case 080 FAILED: " + cuCla.isSynthetic());
2198:                    if (cuCla.getCanonicalName() != null)
2199:                        fail("test_4, case 081 FAILED: "
2200:                                + cuCla.getCanonicalName());
2201:                    if (!cuCla.getSimpleName().equals("Y"))
2202:                        fail("test_4, case 082 FAILED: "
2203:                                + cuCla.getSimpleName());
2204:                } catch (IllegalAccessException e) {
2205:                    fail(e.getMessage());
2206:                } catch (IllegalArgumentException e) {
2207:                    fail(e.getMessage());
2208:                } catch (java.lang.reflect.InvocationTargetException e) {
2209:                    fail(e.getMessage());
2210:                } catch (NoSuchMethodException e) {
2211:                    fail(e.getMessage());
2212:                }
2213:            }
2214:
2215:            /**
2216:             * Constructor's generalized local class
2217:             */
2218:            public <T0> void test_16() {
2219:                @i
2220:                class LC000<T1 extends T0> {
2221:
2222:                }
2223:                @i
2224:                class LC001<T1 extends LC000 & java.io.Serializable & java.lang.reflect.Type & GenericDeclaration> {
2225:                    public Class c;
2226:
2227:                    java.lang.reflect.TypeVariable<?>[] getTypeParameters() {
2228:                        return (java.lang.reflect.TypeVariable<?>[]) null;
2229:                    }
2230:
2231:                    public <T2 extends T0, T3 extends T1, T4 extends LC000<T0>> LC001() {
2232:                        @i
2233:                        class LC001_01 {
2234:                        }
2235:                        c = LC001_01.class;
2236:                    }
2237:                }
2238:                ;
2239:                LC001 lc = new LC001();
2240:                lc.getTypeParameters();
2241:                if (!lc.c.getEnclosingClass().getName().equals(
2242:                        "java.lang.ClassHierarchyTest$4LC001"))
2243:                    fail("test_3, case 004 FAILED: "
2244:                            + lc.c.getEnclosingClass().getName());
2245:                if (lc.c.getEnumConstants() != null)
2246:                    fail("test_3, case 009 FAILED: " + lc.c.getEnumConstants());
2247:                if (lc.c.isEnum())
2248:                    fail("test_3, case 000 FAILED: " + lc.c.isEnum());
2249:                try {
2250:                    lc.c.asSubclass(ClassHierarchyTest.class);
2251:                    fail("test_3, case 011 FAILED: "
2252:                            + lc.c.asSubclass(ClassHierarchyTest.class));
2253:                } catch (Exception e) {/*e.printStackTrace();*/
2254:                }
2255:                if (lc.c.getEnclosingMethod() != null)
2256:                    fail("test_3, case 013 FAILED: "
2257:                            + lc.c.getEnclosingMethod().getName());
2258:                if (!lc.c.getEnclosingConstructor().getName().equals(
2259:                        "java.lang.ClassHierarchyTest$4LC001"))
2260:                    fail("test_3, case 014 FAILED: "
2261:                            + lc.c.getEnclosingConstructor());
2262:                if (lc.c.isMemberClass())
2263:                    fail("test_3, case 017 FAILED: " + lc.c.isMemberClass());
2264:                if (!lc.c.isLocalClass())
2265:                    fail("test_3, case 018 FAILED: " + lc.c.isLocalClass());
2266:                if (lc.c.isAnonymousClass())
2267:                    fail("test_3, case 019 FAILED: " + lc.c.isAnonymousClass());
2268:                if (lc.c.isSynthetic())
2269:                    fail("test_3, case 020 FAILED: " + lc.c.isSynthetic());
2270:                if (lc.c.getCanonicalName() != null)
2271:                    fail("test_3, case 021 FAILED: " + lc.c.getCanonicalName());
2272:                if (!lc.c.getSimpleName().equals("LC001_01"))
2273:                    fail("test_3, case 022 FAILED: " + lc.c.getSimpleName());
2274:            }
2275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.