Source Code Cross Referenced for ClassLiteralAccess.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » compiler » ast » 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 » IDE Eclipse » jdt » org.eclipse.jdt.internal.compiler.ast 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.internal.compiler.ast;
011:
012:        import org.eclipse.jdt.internal.compiler.ASTVisitor;
013:        import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
014:        import org.eclipse.jdt.internal.compiler.codegen.*;
015:        import org.eclipse.jdt.internal.compiler.flow.*;
016:        import org.eclipse.jdt.internal.compiler.impl.Constant;
017:        import org.eclipse.jdt.internal.compiler.lookup.*;
018:
019:        public class ClassLiteralAccess extends Expression {
020:
021:            public TypeReference type;
022:            public TypeBinding targetType;
023:            FieldBinding syntheticField;
024:
025:            public ClassLiteralAccess(int sourceEnd, TypeReference type) {
026:                this .type = type;
027:                type.bits |= IgnoreRawTypeCheck; // no need to worry about raw type usage
028:                this .sourceStart = type.sourceStart;
029:                this .sourceEnd = sourceEnd;
030:            }
031:
032:            public FlowInfo analyseCode(BlockScope currentScope,
033:                    FlowContext flowContext, FlowInfo flowInfo) {
034:
035:                // if reachable, request the addition of a synthetic field for caching the class descriptor
036:                SourceTypeBinding sourceType = currentScope
037:                        .outerMostClassScope().enclosingSourceType();
038:                // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=22334
039:                if (!sourceType.isInterface()
040:                        && !sourceType.isBaseType()
041:                        && currentScope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) {
042:                    syntheticField = sourceType
043:                            .addSyntheticFieldForClassLiteral(targetType,
044:                                    currentScope);
045:                }
046:                return flowInfo;
047:            }
048:
049:            /**
050:             * MessageSendDotClass code generation
051:             *
052:             * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
053:             * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
054:             * @param valueRequired boolean
055:             */
056:            public void generateCode(BlockScope currentScope,
057:                    CodeStream codeStream, boolean valueRequired) {
058:                int pc = codeStream.position;
059:
060:                // in interface case, no caching occurs, since cannot make a cache field for interface
061:                if (valueRequired) {
062:                    codeStream.generateClassLiteralAccessForType(
063:                            type.resolvedType, syntheticField);
064:                    codeStream
065:                            .generateImplicitConversion(this .implicitConversion);
066:                }
067:                codeStream.recordPositionsFrom(pc, this .sourceStart);
068:            }
069:
070:            public StringBuffer printExpression(int indent, StringBuffer output) {
071:
072:                return type.print(0, output).append(".class"); //$NON-NLS-1$
073:            }
074:
075:            public TypeBinding resolveType(BlockScope scope) {
076:
077:                constant = Constant.NotAConstant;
078:                if ((targetType = type
079:                        .resolveType(scope, true /* check bounds*/)) == null)
080:                    return null;
081:
082:                if (targetType.isArrayType()) {
083:                    ArrayBinding arrayBinding = (ArrayBinding) this .targetType;
084:                    TypeBinding leafComponentType = arrayBinding.leafComponentType;
085:                    if (leafComponentType == TypeBinding.VOID) {
086:                        scope.problemReporter().cannotAllocateVoidArray(this );
087:                        return null;
088:                    } else if (leafComponentType.isTypeVariable()) {
089:                        scope
090:                                .problemReporter()
091:                                .illegalClassLiteralForTypeVariable(
092:                                        (TypeVariableBinding) leafComponentType,
093:                                        this );
094:                    }
095:                } else if (this .targetType.isTypeVariable()) {
096:                    scope.problemReporter().illegalClassLiteralForTypeVariable(
097:                            (TypeVariableBinding) targetType, this );
098:                }
099:                ReferenceBinding classType = scope.getJavaLangClass();
100:                if (classType.isGenericType()) {
101:                    // Integer.class --> Class<Integer>, perform boxing of base types (int.class --> Class<Integer>)
102:                    TypeBinding boxedType = null;
103:                    if (targetType.id == T_void) {
104:                        boxedType = scope.environment().getType(JAVA_LANG_VOID);
105:                        if (boxedType == null) {
106:                            boxedType = new ProblemReferenceBinding(
107:                                    JAVA_LANG_VOID, null,
108:                                    ProblemReasons.NotFound);
109:                        }
110:                    } else {
111:                        boxedType = scope.boxing(targetType);
112:                    }
113:                    this .resolvedType = scope
114:                            .environment()
115:                            .createParameterizedType(classType,
116:                                    new TypeBinding[] { boxedType }, null/*not a member*/);
117:                } else {
118:                    this .resolvedType = classType;
119:                }
120:                return this .resolvedType;
121:            }
122:
123:            public void traverse(ASTVisitor visitor, BlockScope blockScope) {
124:
125:                if (visitor.visit(this, blockScope)) {
126:                    type.traverse(visitor, blockScope);
127:                }
128:                visitor.endVisit(this, blockScope);
129:            }
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.