⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attribute.java

📁 已经移植好的java虚拟机
💻 JAVA
字号:
/* *	Attribute.java	1.7	02/09/27 * * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. * * This software is the confidential and proprietary information of Sun * Microsystems, Inc. ("Confidential Information").  You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Sun. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING * THIS SOFTWARE OR ITS DERIVATIVES. * Use is subject to license terms. */package components;import java.io.DataOutput;import java.io.DataInput;import java.io.IOException;import java.util.Hashtable;import util.*;/* * A class to represent the general Attribute form. * In its most uninterpreted form, "data" is just an * array of byte. It can also be other things, even * array of ConstantObject.  */public abstractclass Attribute extends ClassComponent{    public UnicodeConstant name;    public int		   length;    protected    Attribute( UnicodeConstant n, int l ){	name = n;	length = l;	resolved = true;    }    public void    externalize( ConstantPool p ){	if ( name != null ){	    name = (UnicodeConstant)p.add( name );	}    }    abstract protected int    writeData( DataOutput o ) throws IOException;    public void write( DataOutput o ) throws IOException {	o.writeShort( name.index );	o.writeInt( length );	int trueLength = writeData( o );	if ( length != trueLength ){	    throw new DataFormatException(Localizer.getString("attribute.bad_attribute_length_for.dataformatexception", name ));	}    }    public void countConstantReferences( boolean isRelocatable ){	//	// if we are producing relocatable output, then	// we will need our name in the string table.	// Else not.	//	if ( isRelocatable )	    name.incReference();    }    /*     * Number of bytes we'll write out     */    public int length(){	return 6+length; // believe length unchanged    }    public static void    externalizeAttributes( Attribute a[], ConstantPool p ){	int arryl = ( a == null ) ? 0 : a.length;	for ( int i = 0; i < arryl; i++ ){	    a[i].externalize(p);	}    }    public static void    writeAttributes( Attribute a[], DataOutput o,  boolean verbose ) throws IOException {	int nattr =  ( a == null ) ? 0 : a.length;	if ( verbose ){	    System.out.println(Localizer.getString("attribute.writing_attributes", Integer.toString(nattr)));	}	o.writeShort( nattr );	for ( int j = 0; j < nattr; j++ ){	    if ( verbose ){		System.out.println("	"+a[j].name.string );	    }	    a[j].write( o );	}    }    public static int    length( Attribute a[] ){	int l = 0;	int arryl = ( a == null ) ? 0 : a.length;	for ( int i = 0; i < arryl; i++ ){	    l += a[i].length();	}	return l + 2;    }    public static Attribute[]     readAttributes( DataInput i, ConstantObject locals[], ConstantObject globals[], Hashtable typetable, boolean verbose ) throws IOException {	int nattr =  i.readUnsignedShort();	if ( verbose ){	    System.out.println(Localizer.getString("attribute.reading_attributes", Integer.toString(nattr)));	}	if ( nattr == 0 ) return null;	Attribute a[] = new Attribute[nattr];	for ( int j = 0; j < nattr; j++ ){	    UnicodeConstant name = (UnicodeConstant)globals[i.readUnsignedShort()];	    String typename = name.string.intern();	    AttributeFactory afact = (AttributeFactory)typetable.get( typename );	    if ( afact == null )		afact = UninterpretedAttributeFactory.instance;	    a[j] = afact.finishReadAttribute( i, name, locals, globals );	}	return a;    }    public static void    countConstantReferences( Attribute a[], boolean isRelocatable ){	if ( a == null ) return;	for ( int i = 0; i < a.length; i++ ){	    a[i].countConstantReferences( isRelocatable );	}    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -