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


001:        /*
002:         * Copyright 1999-2005 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 com.sun.tools.javac.code.*;
029:        import com.sun.tools.javac.util.*;
030:
031:        /** A JVM class file.
032:         *
033:         *  <p>Generic Java classfiles have one additional attribute for classes,
034:         *  methods and fields:
035:         *  <pre>
036:         *   "Signature" (u4 attr-length, u2 signature-index)
037:         *  </pre>
038:         *
039:         *  <p>A signature gives the full Java type of a method or field. When
040:         *  used as a class attribute, it indicates type parameters, followed
041:         *  by supertype, followed by all interfaces.
042:         *  <pre>
043:         *     methodOrFieldSignature ::= type
044:         *     classSignature         ::= [ typeparams ] supertype { interfacetype }
045:         *  </pre>
046:         *  <p>The type syntax in signatures is extended as follows:
047:         *  <pre>
048:         *     type       ::= ... | classtype | methodtype | typevar
049:         *     classtype  ::= classsig { '.' classsig }
050:         *     classig    ::= 'L' name [typeargs] ';'
051:         *     methodtype ::= [ typeparams ] '(' { type } ')' type
052:         *     typevar    ::= 'T' name ';'
053:         *     typeargs   ::= '<' type { type } '>'
054:         *     typeparams ::= '<' typeparam { typeparam } '>'
055:         *     typeparam  ::= name ':' type
056:         *  </pre>
057:         *  <p>This class defines constants used in class files as well
058:         *  as routines to convert between internal ``.'' and external ``/''
059:         *  separators in class names.
060:         *
061:         *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
062:         *  you write code that depends on this, you do so at your own risk.
063:         *  This code and its internal interfaces are subject to change or
064:         *  deletion without notice.</b> */
065:        @Version("@(#)ClassFile.java	1.35 07/05/05")
066:        public class ClassFile {
067:
068:            public final static int JAVA_MAGIC = 0xCAFEBABE;
069:
070:            // see Target
071:            public final static int CONSTANT_Utf8 = 1;
072:            public final static int CONSTANT_Unicode = 2;
073:            public final static int CONSTANT_Integer = 3;
074:            public final static int CONSTANT_Float = 4;
075:            public final static int CONSTANT_Long = 5;
076:            public final static int CONSTANT_Double = 6;
077:            public final static int CONSTANT_Class = 7;
078:            public final static int CONSTANT_String = 8;
079:            public final static int CONSTANT_Fieldref = 9;
080:            public final static int CONSTANT_Methodref = 10;
081:            public final static int CONSTANT_InterfaceMethodref = 11;
082:            public final static int CONSTANT_NameandType = 12;
083:
084:            public final static int MAX_PARAMETERS = 0xff;
085:            public final static int MAX_DIMENSIONS = 0xff;
086:            public final static int MAX_CODE = 0xffff;
087:            public final static int MAX_LOCALS = 0xffff;
088:            public final static int MAX_STACK = 0xffff;
089:
090:            /************************************************************************
091:             * String Translation Routines
092:             ***********************************************************************/
093:
094:            /** Return internal representation of buf[offset..offset+len-1],
095:             *  converting '/' to '.'.
096:             */
097:            public static byte[] internalize(byte[] buf, int offset, int len) {
098:                byte[] translated = new byte[len];
099:                for (int j = 0; j < len; j++) {
100:                    byte b = buf[offset + j];
101:                    if (b == '/')
102:                        translated[j] = (byte) '.';
103:                    else
104:                        translated[j] = b;
105:                }
106:                return translated;
107:            }
108:
109:            /** Return internal representation of given name,
110:             *  converting '/' to '.'.
111:             */
112:            public static byte[] internalize(Name name) {
113:                return internalize(name.table.names, name.index, name.len);
114:            }
115:
116:            /** Return external representation of buf[offset..offset+len-1],
117:             *  converting '.' to '/'.
118:             */
119:            public static byte[] externalize(byte[] buf, int offset, int len) {
120:                byte[] translated = new byte[len];
121:                for (int j = 0; j < len; j++) {
122:                    byte b = buf[offset + j];
123:                    if (b == '.')
124:                        translated[j] = (byte) '/';
125:                    else
126:                        translated[j] = b;
127:                }
128:                return translated;
129:            }
130:
131:            /** Return external representation of given name,
132:             *  converting '/' to '.'.
133:             */
134:            public static byte[] externalize(Name name) {
135:                return externalize(name.table.names, name.index, name.len);
136:            }
137:
138:            /************************************************************************
139:             * Name-and-type
140:             ***********************************************************************/
141:
142:            /** A class for the name-and-type signature of a method or field.
143:             */
144:            public static class NameAndType {
145:                Name name;
146:                Type type;
147:
148:                NameAndType(Name name, Type type) {
149:                    this .name = name;
150:                    this .type = type;
151:                }
152:
153:                public boolean equals(Object other) {
154:                    return other instanceof  NameAndType
155:                            && name == ((NameAndType) other).name
156:                            && type.equals(((NameAndType) other).type);
157:                }
158:
159:                public int hashCode() {
160:                    return name.hashCode() * type.hashCode();
161:                }
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.