/* * JavaFieldReader */ public JavaField(JavaReader rdr) { Class = rdr.Class; Flags = (JavaAccessFlags)rdr.Read16(); Name = rdr.ConstUtf8(rdr.Read16()); rdr.Where.Push($"field '{Name}'"); Type = new JavaType(rdr.ConstUtf8(rdr.Read16()), rdr.Where); var attributes = new JavaAttributeSet(rdr); if ((Flags & JavaAccessFlags.ACC_STATIC) != 0) { var constAttr = attributes.GetAttr <JavaAttribute.ConstantValue>(); if (constAttr != null) { InitConstant(constAttr.value, rdr.Where); } } rdr.Where.Pop(); }
public LocalVariableTable(JavaReader rdr) { vars = new Item[rdr.Read16()]; for (int i = 0; i < vars.Length; i++) { vars[i].offset = rdr.Read16(); vars[i].length = rdr.Read16(); vars[i].nameAndType = new JavaFieldRef( rdr.ConstUtf8(rdr.Read16()), rdr.ConstUtf8(rdr.Read16()), rdr.Where); vars[i].index = rdr.Read16(); } }
public MethodParameters(JavaReader rdr) { parms = new Item[rdr.Read8()]; for (int i = 0; i < parms.Length; i++) { parms[i].name = rdr.ConstUtf8(rdr.Read16()); parms[i].flags = rdr.Read16(); } }
public JavaMethod(JavaReader rdr, bool withCode = true) { Class = rdr.Class; Flags = (JavaAccessFlags)rdr.Read16(); Name = rdr.ConstUtf8(rdr.Read16()); rdr.Where.Push($"method '{Name}'"); var tmpMethod = new JavaMethodRef(rdr.ConstUtf8(rdr.Read16()), rdr.Where); ReturnType = tmpMethod.ReturnType; Parameters = tmpMethod.Parameters; var attributes = new JavaAttributeSet(rdr, withCode); Exceptions = attributes.GetAttr <JavaAttribute.Exceptions>()?.classes; var codeAttr = attributes.GetAttr <JavaAttribute.Code>(); if (withCode && codeAttr != null) { #if !DEBUG try { #endif Code = new JavaCode(rdr, this, codeAttr); #if !DEBUG } catch (IndexOutOfRangeException) { throw rdr.Where.Exception("unexpected end of code"); } #endif } InitParameterNames(attributes, codeAttr); rdr.Where.Pop(); }
public InnerClasses(JavaReader rdr) { classes = new JavaClass.InnerClass[rdr.Read16()]; for (int i = 0; i < classes.Length; i++) { classes[i] = new JavaClass.InnerClass(); classes[i].InnerLongName = rdr.ConstClass(rdr.Read16()).ClassName; ushort v = rdr.Read16(); if (v != 0) { classes[i].OuterLongName = rdr.ConstClass(v).ClassName; } v = rdr.Read16(); if (v != 0) { classes[i].InnerShortName = rdr.ConstUtf8(v); } classes[i].Flags = (JavaAccessFlags)rdr.Read16(); } }
public JavaAttributeSet(JavaReader rdr, bool withCode = true) { var count = rdr.Read16(); set = new List <JavaAttribute>(count); for (int i = 0; i < count; i++) { var name = rdr.ConstUtf8(rdr.Read16()); rdr.Where.Push($"attribute '{name}'"); bool popped = false; var length = JavaAttribute.ReadLength(rdr, name); var position = rdr.StreamPosition; JavaAttribute attr; switch (name) { case JavaAttribute.SourceFile.tag: attr = new JavaAttribute.SourceFile(rdr); break; case JavaAttribute.Signature.tag: attr = new JavaAttribute.Signature(rdr); break; case JavaAttribute.Exceptions.tag: attr = new JavaAttribute.Exceptions(rdr); break; case JavaAttribute.InnerClasses.tag: attr = new JavaAttribute.InnerClasses(rdr); break; case JavaAttribute.EnclosingMethod.tag: attr = new JavaAttribute.EnclosingMethod(rdr); break; case JavaAttribute.ConstantValue.tag: attr = new JavaAttribute.ConstantValue(rdr); break; case JavaAttribute.MethodParameters.tag: attr = new JavaAttribute.MethodParameters(rdr); break; // // Code attributes // case JavaAttribute.Code.tag: attr = withCode ? (JavaAttribute) new JavaAttribute.Code(rdr) : (JavaAttribute) new JavaAttribute.Generic(rdr, name, length); break; case JavaAttribute.BootstrapMethods.tag: attr = withCode ? (JavaAttribute) new JavaAttribute.BootstrapMethods(rdr) : (JavaAttribute) new JavaAttribute.Generic(rdr, name, length); break; case JavaAttribute.StackMapTable.tag: attr = new JavaAttribute.StackMapTable(rdr); break; case JavaAttribute.LineNumberTable.tag: attr = new JavaAttribute.LineNumberTable(rdr); break; case JavaAttribute.LocalVariableTable.tag: attr = new JavaAttribute.LocalVariableTable(rdr); break; // // Unhandled attributes // case "Synthetic": case "AnnotationDefault": case "LocalVariableTypeTable": case "RuntimeVisibleAnnotations": case "RuntimeInvisibleAnnotations": case "RuntimeInvisibleParameterAnnotations": case "Deprecated": attr = new JavaAttribute.Generic(rdr, name, length); break; default: rdr.Where.Pop(); popped = true; Console.WriteLine($"skipping unknown attribute '{name}'{rdr.Where}"); attr = new JavaAttribute.Generic(rdr, name, length); break; } set.Add(attr); if (rdr.StreamPosition != position + length) { throw rdr.Where.Exception("attribute too short"); } if (!popped) { rdr.Where.Pop(); } } }
public Signature(JavaReader rdr) { descriptor = rdr.ConstUtf8(rdr.Read16()); }
public SourceFile(JavaReader rdr) { fileName = rdr.ConstUtf8(rdr.Read16()); }