FileDocCategorySizeDatePackage
SourceDebugExtensionAttribute.javaAPI DocGlassfish v2 API6250Thu Mar 02 11:51:14 GMT 2006oracle.toplink.libraries.asm.attrs

SourceDebugExtensionAttribute

public class SourceDebugExtensionAttribute extends Attribute
The SourceDebugExtension attribute is an optional attribute defined in JSR-045 in the attributes table of the ClassFile structure. There can be no more than one SourceDebugExtension attribute in the attributes table of a given ClassFile structure. The SourceDebugExtension attribute has the following format:
SourceDebugExtension_attribute {
u2 attribute_name_index;
u4 attribute_length;
u1 debug_extension[attribute_length];
}
The items of the SourceDebugExtension_attribute structure are as follows:
attribute_name_index
The value of the attribute_name_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info structure representing the string "SourceDebugExtension".
attribute_length
The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes. The value of the attribute_length item is thus the number of bytes in the debug_extension[] item.
debug_extension[]
The debug_extension array holds a string, which must be in UTF-8 format. There is no terminating zero byte. The string in the debug_extension item will be interpreted as extended debugging information. The content of this string has no semantic effect on the Java Virtual Machine.
see
JSR-045: Debugging Support for Other Languages
author
Eugene Kuleshov

Fields Summary
public String
debugExtension
Constructors Summary
public SourceDebugExtensionAttribute()

    super("SourceDebugExtension");
  
public SourceDebugExtensionAttribute(String debugExtension)

    this();
    this.debugExtension = debugExtension;
  
Methods Summary
private byte[]putUTF8(java.lang.String s)

    int charLength = s.length();
    int byteLength = 0;
    for (int i = 0; i < charLength; ++i) {
      char c = s.charAt(i);
      if (c >= '\001" && c <= '\177") {
        byteLength++;
      } else if (c > '\u07FF") {
        byteLength += 3;
      } else {
        byteLength += 2;
      }
    }
    /*if (byteLength > 65535) {
      throw new IllegalArgumentException();
    }*/
    byte[] data = new byte[byteLength];
    for (int i = 0; i < charLength;) {
      char c = s.charAt(i);
      if (c >= '\001" && c <= '\177") {
        data[i++] = (byte)c;
      } else if (c > '\u07FF") {
        data[i++] = (byte)(0xE0 | c >> 12 & 0xF);
        data[i++] = (byte)(0x80 | c >> 6 & 0x3F);
        data[i++] = (byte)(0x80 | c & 0x3F);
      } else {
        data[i++] = (byte)(0xC0 | c >> 6 & 0x1F);
        data[i++] = (byte)(0x80 | c & 0x3F);
      }
    }
    return data;
  
protected oracle.toplink.libraries.asm.Attributeread(oracle.toplink.libraries.asm.ClassReader cr, int off, int len, char[] buf, int codeOff, oracle.toplink.libraries.asm.Label[] labels)

    return new SourceDebugExtensionAttribute(readUTF8(cr, off, len));
  
private java.lang.StringreadUTF8(oracle.toplink.libraries.asm.ClassReader cr, int index, int utfLen)

    int endIndex = index + utfLen;
    byte[] b = cr.b;
    char[] buf = new char[utfLen];
    int strLen = 0;
    int c, d, e;
    while (index < endIndex) {
      c = b[index++] & 0xFF;
      switch (c >> 4) {
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
          // 0xxxxxxx
          buf[strLen++] = (char)c;
          break;

        case 12:
        case 13:
          // 110x xxxx   10xx xxxx
          d = b[index++];
          buf[strLen++] = (char)(((c & 0x1F) << 6) | (d & 0x3F));
          break;

        default:
          // 1110 xxxx  10xx xxxx  10xx xxxx
          d = b[index++];
          e = b[index++];
          buf[strLen++] = (char)(((c & 0x0F) << 12) | ((d & 0x3F) << 6) | (e & 0x3F));
          break;
      }
    }

    return new String(buf, 0, strLen);
  
public java.lang.StringtoString()

    return debugExtension;
  
protected oracle.toplink.libraries.asm.ByteVectorwrite(oracle.toplink.libraries.asm.ClassWriter cw, byte[] code, int len, int maxStack, int maxLocals)

    byte[] b = putUTF8(debugExtension);
    return new ByteVector().putByteArray(b, 0, b.length);