1 cananian 1.1.2.2 // AttributeSynthetic.java, created Mon Jan 18 22:44:36 1999 by cananian 2 cananian 1.1.2.1 // Copyright (C) 1998 C. Scott Ananian <cananian@alumni.princeton.edu> 3 cananian 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 cananian 1.1.2.1 package harpoon.IR.RawClass; 5 cananian 1.1.2.1 6 cananian 1.1.2.1 /** 7 cananian 1.1.2.1 * Java 1.1 compilers are required, when producing bytecodes, to mark any 8 cananian 1.1.2.1 * field or member not directly defined in the source code with an 9 cananian 1.1.2.1 * attribute names <code>Synthetic</code>. These hidden fields and methods 10 cananian 1.1.2.1 * are synthesized by the compiler in order to implement the scoping of 11 cananian 1.1.2.1 * names for inner classes. <p> 12 cananian 1.1.2.1 * The <code>Synthetic</code> attribute is intended to allow tools to 13 cananian 1.1.2.1 * avoid displaying these methods and fields unnecessarily. 14 cananian 1.1.2.1 * 15 cananian 1.1.2.1 * @author C. Scott Ananian <cananian@alumni.princeton.edu> 16 cananian 1.3 * @version $Id: AttributeSynthetic.java,v 1.3 2003/09/05 21:45:16 cananian Exp $ 17 cananian 1.1.2.1 * @see "Inner Classes Specification" 18 cananian 1.1.2.1 * @see AttributeInnerClasses 19 cananian 1.1.2.1 * @see Attribute 20 cananian 1.1.2.1 * @see ClassFile 21 cananian 1.1.2.1 */ 22 cananian 1.1.2.1 public class AttributeSynthetic extends Attribute { 23 cananian 1.3 /** The string naming this <code>Attribute</code> type. */ 24 cananian 1.3 public static final String ATTRIBUTE_NAME = "Synthetic"; 25 cananian 1.1.2.1 /** Constructor. */ 26 cananian 1.1.2.1 AttributeSynthetic(ClassFile parent, ClassDataInputStream in, 27 cananian 1.1.2.1 int attribute_name_index) throws java.io.IOException { 28 cananian 1.1.2.1 super(parent, attribute_name_index); 29 cananian 1.1.2.1 long attribute_length = in.read_u4(); 30 cananian 1.1.2.1 if (attribute_length != attribute_length()) 31 cananian 1.1.2.1 throw new ClassDataException("Synthetic attribute with length " + 32 cananian 1.1.2.1 attribute_length); 33 cananian 1.3 assert ATTRIBUTE_NAME.equals(attribute_name()); 34 cananian 1.1.2.1 } 35 cananian 1.1.2.1 /** Constructor. */ 36 cananian 1.1.2.1 public AttributeSynthetic(ClassFile parent, int attribute_name_index) { 37 cananian 1.1.2.1 super(parent, attribute_name_index); 38 cananian 1.3 assert ATTRIBUTE_NAME.equals(attribute_name()); 39 cananian 1.1.2.1 } 40 cananian 1.1.2.1 41 cananian 1.1.2.1 public long attribute_length() { return 0; } 42 cananian 1.1.2.1 43 cananian 1.1.2.1 /** Write to bytecode stream. */ 44 cananian 1.1.2.1 public void write(ClassDataOutputStream out) throws java.io.IOException { 45 cananian 1.1.2.1 out.write_u2(attribute_name_index); 46 cananian 1.1.2.1 out.write_u4(attribute_length()); 47 cananian 1.1.2.1 } 48 cananian 1.2 }