Lines Matching +full:out +full:- +full:file
3 * contributor license agreements. See the NOTICE file distributed with
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
9 * http://www.apache.org/licenses/LICENSE-2.0
19 import java.io.File;
34 * Display Java .class file data.
43 private FileImageInputStream file; field in ClassDumper
60 * @param file Input stream
61 * @param file_name File name
63 public ClassDumper (FileImageInputStream file, String file_name) { in ClassDumper() argument
65 this.file = file; in ClassDumper()
69 * Parse the given Java class file and return an object that represents
71 * A <em>ClassFormatException</em> is raised, if the file is not a valid
72 * .class file. (This does not include verification of the byte code as it
80 // Check magic tag of class file in dump()
97 // Processed everything of interest, so close the file in dump()
99 if (file != null) { in dump()
100 file.close(); in dump()
109 * Check whether the header of the file is ok.
110 * Of course, this has to be the first action on successive file reads.
115 final int magic = file.readInt(); in processID()
117 throw new ClassFormatException(file_name + " is not a Java .class file"); in processID()
119 System.out.println("Java Class Dump"); in processID()
120 System.out.println(" file: " + file_name); in processID()
121 System.out.printf("%nClass header:%n"); in processID()
122 System.out.printf(" magic: %X%n", magic); in processID()
126 * Process major and minor version of compiler which created the file.
131 minor = file.readUnsignedShort(); in processVersion()
132 System.out.printf(" minor version: %s%n", minor); in processVersion()
134 major = file.readUnsignedShort(); in processVersion()
135 System.out.printf(" major version: %s%n", major); in processVersion()
145 int constant_pool_count = file.readUnsignedShort(); in processConstantPool()
150 System.out.printf("%nConstant pool(%d):%n", constant_pool_count - 1); in processConstantPool()
153 constant_items[i] = Constant.readConstant(file); in processConstantPool()
156 System.out.printf(" #%1d = ", i); in processConstantPool()
158 System.out.printf(" #%2d = ", i); in processConstantPool()
160 System.out.printf(" #%d = ", i); in processConstantPool()
162 System.out.println(constant_items[i]); in processConstantPool()
179 access_flags = file.readUnsignedShort(); in processClassInfo()
192 System.out.printf("%nClass info:%n"); in processClassInfo()
193 System.out.println(" flags: " + BCELifier.printFlags(access_flags, in processClassInfo()
195 class_name_index = file.readUnsignedShort(); in processClassInfo()
196 System.out.printf(" this_class: %d (", class_name_index); in processClassInfo()
197 System.out.println(constantToString(class_name_index) + ")"); in processClassInfo()
199 superclass_name_index = file.readUnsignedShort(); in processClassInfo()
200 System.out.printf(" super_class: %d (", superclass_name_index); in processClassInfo()
201 System.out.println(constantToString(superclass_name_index) + ")"); in processClassInfo()
211 interfaces_count = file.readUnsignedShort(); in processInterfaces()
214 System.out.printf("%nInterfaces(%d):%n", interfaces_count); in processInterfaces()
217 interfaces[i] = file.readUnsignedShort(); in processInterfaces()
220 System.out.printf(" #%1d = ", i); in processInterfaces()
222 System.out.printf(" #%2d = ", i); in processInterfaces()
224 System.out.printf(" #%d = ", i); in processInterfaces()
226 System.out.println(interfaces[i] + " (" + in processInterfaces()
239 fields_count = file.readUnsignedShort(); in processFields()
243 System.out.printf("%nFields(%d):%n", fields_count); in processFields()
247 if (i < fields_count - 1) { in processFields()
248 System.out.println(); in processFields()
260 methods_count = file.readUnsignedShort(); in processMethods()
263 System.out.printf("%nMethods(%d):%n", methods_count); in processMethods()
267 if (i < methods_count - 1) { in processMethods()
268 System.out.println(); in processMethods()
280 attributes_count = file.readUnsignedShort(); in processAttributes()
283 System.out.printf("%nAttributes(%d):%n", attributes_count); in processAttributes()
286 attributes[i] = Attribute.readAttribute(file, constant_pool); in processAttributes()
287 System.out.printf(" %s%n", attributes[i]); in processAttributes()
292 * Construct object from file stream.
293 * @param file Input stream
298 int access_flags = file.readUnsignedShort(); in processFieldOrMethod()
299 int name_index = file.readUnsignedShort(); in processFieldOrMethod()
300 System.out.printf(" name_index: %d (", name_index); in processFieldOrMethod()
301 System.out.println(constantToString(name_index) + ")"); in processFieldOrMethod()
302 System.out.println(" access_flags: " + BCELifier.printFlags(access_flags, in processFieldOrMethod()
304 int descriptor_index = file.readUnsignedShort(); in processFieldOrMethod()
305 System.out.printf(" descriptor_index: %d (", descriptor_index); in processFieldOrMethod()
306 System.out.println(constantToString(descriptor_index) + ")"); in processFieldOrMethod()
308 int attributes_count = file.readUnsignedShort(); in processFieldOrMethod()
310 System.out.println(" attribute count: " + attributes_count); in processFieldOrMethod()
314 file.mark(); in processFieldOrMethod()
315 int attribute_name_index = file.readUnsignedShort(); in processFieldOrMethod()
316 int attribute_length = file.readInt(); in processFieldOrMethod()
317 // restore file location in processFieldOrMethod()
318 file.reset(); in processFieldOrMethod()
320 // System.out.printf(" attribute_name_index: %d (", attribute_name_index); in processFieldOrMethod()
321 // System.out.println(constantToString(attribute_name_index) + ")"); in processFieldOrMethod()
322 // System.out.printf(" atribute offset in file: %x%n", + file.getStreamPosition()); in processFieldOrMethod()
323 // System.out.println(" atribute_length: " + attribute_length); in processFieldOrMethod()
329 long pos1 = file.getStreamPosition(); in processFieldOrMethod()
330 attributes[i] = Attribute.readAttribute(file, constant_pool); in processFieldOrMethod()
331 long pos2 = file.getStreamPosition(); in processFieldOrMethod()
332 if ((pos2 - pos1) != (attribute_length + 6)) { in processFieldOrMethod()
333 … System.out.printf("%nWHOOPS attribute_length: %d pos2-pos1-6: %d pos1: %x(%d) pos2: %x(%d)%n", in processFieldOrMethod()
334 attribute_length, pos2-pos1-6, pos1, pos1, pos2, pos2); in processFieldOrMethod()
336 System.out.printf(" "); in processFieldOrMethod()
337 System.out.println(attributes[i]); in processFieldOrMethod()
356 FileImageInputStream file = new FileImageInputStream(new File(args[0])); in main() local
358 ClassDumper cd = new ClassDumper(file, args[0]); in main()
361 System.out.printf("End of Class Dump%n"); in main()