Source Code Cross Referenced for Target.java in  » 6.0-JDK-Modules-sun » javac-compiler » com » sun » tools » javac » jvm » 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 » 6.0 JDK Modules sun » javac compiler » com.sun.tools.javac.jvm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package com.sun.tools.javac.jvm;
027:
028:        import java.util.*;
029:
030:        import com.sun.tools.javac.code.Flags;
031:        import com.sun.tools.javac.code.Symbol;
032:        import com.sun.tools.javac.util.*;
033:
034:        /** The classfile version target.
035:         *
036:         *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
037:         *  you write code that depends on this, you do so at your own risk.
038:         *  This code and its internal interfaces are subject to change or
039:         *  deletion without notice.</b>
040:         */
041:        @Version("@(#)Target.java	1.50 07/05/05")
042:        public enum Target {
043:            JDK1_1("1.1", 45, 3), JDK1_2("1.2", 46, 0), JDK1_3("1.3", 47, 0),
044:
045:            /** J2SE1.4 = Merlin. */
046:            JDK1_4("1.4", 48, 0),
047:
048:            /** Support for the JSR14 prototype compiler (targeting 1.4 VMs
049:             *  augmented with a few support classes).  This is a transitional
050:             *  option that will not be supported in the product.  */
051:            JSR14("jsr14", 48, 0),
052:
053:            /** The following are undocumented transitional targets that we
054:             *  had used to test VM fixes in update releases.  We do not
055:             *  promise to retain support for them.  */
056:            JDK1_4_1("1.4.1", 48, 0), JDK1_4_2("1.4.2", 48, 0),
057:
058:            /** Tiger. */
059:            JDK1_5("1.5", 49, 0),
060:
061:            /** JDK 6. */
062:            JDK1_6("1.6", 50, 0),
063:
064:            /** JDK 7. */
065:            JDK1_7("1.7", 51, 0);
066:
067:            private static final Context.Key<Target> targetKey = new Context.Key<Target>();
068:
069:            public static Target instance(Context context) {
070:                Target instance = context.get(targetKey);
071:                if (instance == null) {
072:                    Options options = Options.instance(context);
073:                    String targetString = options.get("-target");
074:                    if (targetString != null)
075:                        instance = lookup(targetString);
076:                    if (instance == null)
077:                        instance = DEFAULT;
078:                    context.put(targetKey, instance);
079:                }
080:                return instance;
081:            }
082:
083:            private static Target MIN;
084:
085:            public static Target MIN() {
086:                return MIN;
087:            }
088:
089:            private static Target MAX;
090:
091:            public static Target MAX() {
092:                return MAX;
093:            }
094:
095:            private static Map<String, Target> tab = new HashMap<String, Target>();
096:            static {
097:                for (Target t : values()) {
098:                    if (MIN == null)
099:                        MIN = t;
100:                    MAX = t;
101:                    tab.put(t.name, t);
102:                }
103:                tab.put("5", JDK1_5);
104:                tab.put("6", JDK1_6);
105:                tab.put("7", JDK1_7);
106:            }
107:
108:            public final String name;
109:            public final int majorVersion;
110:            public final int minorVersion;
111:
112:            private Target(String name, int majorVersion, int minorVersion) {
113:                this .name = name;
114:                this .majorVersion = majorVersion;
115:                this .minorVersion = minorVersion;
116:            }
117:
118:            public static final Target DEFAULT = JDK1_6;
119:
120:            public static Target lookup(String name) {
121:                return tab.get(name);
122:            }
123:
124:            /** In -target 1.1 and earlier, the compiler is required to emit
125:             *  synthetic method definitions in abstract classes for interface
126:             *  methods that are not overridden.  We call them "Miranda" methods.
127:             */
128:            public boolean requiresIproxy() {
129:                return compareTo(JDK1_1) <= 0;
130:            }
131:
132:            /** Beginning in 1.4, we take advantage of the possibility of emitting
133:             *  code to initialize fields before calling the superclass constructor.
134:             *  This is allowed by the VM spec, but the verifier refused to allow
135:             *  it until 1.4.  This is necesary to translate some code involving
136:             *  inner classes.  See, for example, 4030374.
137:             */
138:            public boolean initializeFieldsBeforeSuper() {
139:                return compareTo(JDK1_4) >= 0;
140:            }
141:
142:            /** Beginning with -target 1.2 we obey the JLS rules for binary
143:             *  compatibility, emitting as the qualifying type of a reference
144:             *  to a method or field the type of the qualifier.  In earlier
145:             *  targets we use as the qualifying type the class in which the
146:             *  member was found.  The following methods named
147:             *  *binaryCompatibility() indicate places where we vary from this
148:             *  general rule. */
149:            public boolean obeyBinaryCompatibility() {
150:                return compareTo(JDK1_2) >= 0;
151:            }
152:
153:            /** Starting in 1.5, the compiler uses an array type as
154:             *  the qualifier for method calls (such as clone) where required by
155:             *  the language and VM spec.  Earlier versions of the compiler
156:             *  qualified them by Object.
157:             */
158:            public boolean arrayBinaryCompatibility() {
159:                return compareTo(JDK1_5) >= 0;
160:            }
161:
162:            /** Beginning after 1.2, we follow the binary compatibility rules for
163:             *  interface fields.  The 1.2 VMs had bugs handling interface fields
164:             *  when compiled using binary compatibility (see 4400598), so this is
165:             *  an accommodation to them.
166:             */
167:            public boolean interfaceFieldsBinaryCompatibility() {
168:                return compareTo(JDK1_2) > 0;
169:            }
170:
171:            /** Beginning in -target 1.5, we follow the binary compatibility
172:             *  rules for interface methods that redefine Object methods.
173:             *  Earlier VMs had bugs handling such methods compiled using binary
174:             *  compatibility (see 4392595, 4398791, 4392595, 4400415).
175:             *  The VMs were fixed during or soon after 1.4.  See 4392595.
176:             */
177:            public boolean interfaceObjectOverridesBinaryCompatibility() {
178:                return compareTo(JDK1_5) >= 0;
179:            }
180:
181:            /** Beginning in -target 1.4.2, we make synthetic variables
182:             *  package-private instead of private.  This is to prevent the
183:             *  necessity of access methods, which effectively relax the
184:             *  protection of the field but bloat the class files and affect
185:             *  execution.
186:             */
187:            public boolean usePrivateSyntheticFields() {
188:                return compareTo(JDK1_4_2) < 0;
189:            }
190:
191:            /** Sometimes we need to create a field to cache a value like a
192:             *  class literal of the assertions flag.  In -target 1.4.2 and
193:             *  later we create a new synthetic class for this instead of
194:             *  using the outermost class.  See 4401576.
195:             */
196:            public boolean useInnerCacheClass() {
197:                return compareTo(JDK1_4_2) >= 0;
198:            }
199:
200:            /** Return true if cldc-style stack maps need to be generated. */
201:            public boolean generateCLDCStackmap() {
202:                return false;
203:            }
204:
205:            /** Beginning in -target 6, we generate stackmap attribute in
206:             *  compact format. */
207:            public boolean generateStackMapTable() {
208:                return compareTo(JDK1_6) >= 0;
209:            }
210:
211:            /** Do we generate "empty" stackmap slots after double and long?
212:             */
213:            public boolean generateEmptyAfterBig() {
214:                return false;
215:            }
216:
217:            /** Beginning in 1.5, we have an unsynchronized version of
218:             *  StringBuffer called StringBuilder that can be used by the
219:             *  compiler for string concatenation.
220:             */
221:            public boolean useStringBuilder() {
222:                return compareTo(JDK1_5) >= 0;
223:            }
224:
225:            /** Beginning in 1.5, we have flag bits we can use instead of
226:             *  marker attributes.
227:             */
228:            public boolean useSyntheticFlag() {
229:                return compareTo(JDK1_5) >= 0;
230:            }
231:
232:            public boolean useEnumFlag() {
233:                return compareTo(JDK1_5) >= 0;
234:            }
235:
236:            public boolean useAnnotationFlag() {
237:                return compareTo(JDK1_5) >= 0;
238:            }
239:
240:            public boolean useVarargsFlag() {
241:                return compareTo(JDK1_5) >= 0;
242:            }
243:
244:            public boolean useBridgeFlag() {
245:                return compareTo(JDK1_5) >= 0;
246:            }
247:
248:            /** Return the character to be used in constructing synthetic
249:             *  identifiers, where not specified by the JLS.
250:             */
251:            public char syntheticNameChar() {
252:                return '$';
253:            }
254:
255:            /** Does the VM have direct support for class literals?
256:             */
257:            public boolean hasClassLiterals() {
258:                return compareTo(JDK1_5) >= 0;
259:            }
260:
261:            /** Although we may not have support for class literals, should we
262:             *  avoid initializing the class that the literal refers to?
263:             *  See 4468823
264:             */
265:            public boolean classLiteralsNoInit() {
266:                return compareTo(JDK1_4_2) >= 0;
267:            }
268:
269:            /** Although we may not have support for class literals, when we
270:             *  throw a NoClassDefFoundError, should we initialize its cause?
271:             */
272:            public boolean hasInitCause() {
273:                return compareTo(JDK1_4) >= 0;
274:            }
275:
276:            /** For bootstrapping, we use J2SE1.4's wrapper class constructors
277:             *  to implement boxing.
278:             */
279:            public boolean boxWithConstructors() {
280:                return compareTo(JDK1_5) < 0;
281:            }
282:
283:            /** For bootstrapping, we use J2SE1.4's java.util.Collection
284:             *  instead of java.lang.Iterable.
285:             */
286:            public boolean hasIterable() {
287:                return compareTo(JDK1_5) >= 0;
288:            }
289:
290:            /** For bootstrapping javac only, we do without java.lang.Enum if
291:             *  necessary.
292:             */
293:            public boolean compilerBootstrap(Symbol c) {
294:                return this  == JSR14 && (c.flags() & Flags.ENUM) != 0
295:                        && c.flatName().toString().startsWith("com.sun.tools.")
296:                // && !Target.class.getSuperclass().getName().equals("java.lang.Enum")
297:                ;
298:            }
299:
300:            /** In J2SE1.5.0, we introduced the "EnclosingMethod" attribute
301:             *  for improved reflection support.
302:             */
303:            public boolean hasEnclosingMethodAttribute() {
304:                return compareTo(JDK1_5) >= 0 || this == JSR14;
305:            }
306:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.