aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs
blob: 3e5ae5a7976a56dd4a8b2dce76647fe0101666ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of the OpenSim Project nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* 
*/
using System;
using System.Collections.Generic;
using System.IO;
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes;

namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
{
    public class ClassRecord
    {
        private ushort m_majorVersion;
        private ushort m_minorVersion;
        private ushort m_constantPoolCount;
        private ushort m_accessFlags;
        private ushort m_thisClass;
        private ushort m_supperClass;
        private ushort m_interfaceCount;
        private ushort m_fieldCount;
        private ushort m_methodCount;
        //private ushort _attributeCount;
        //private string _name;
        public Dictionary<string, BaseType> StaticFields = new Dictionary<string, BaseType>();
        public PoolClass MClass;

        public List<PoolItem> m_constantsPool = new List<PoolItem>();
        private List<MethodInfo> m_methodsList = new List<MethodInfo>();
        private List<FieldInfo> m_fieldList = new List<FieldInfo>();

        public ClassRecord()
        {
        }

        public ClassInstance CreateNewInstance()
        {
            ClassInstance classInst = new ClassInstance();
            classInst.ClassRec = this;
            //TODO: set fields

            return classInst;
        }

        public void LoadClassFromFile(string fileName)
        {
            Console.WriteLine("loading script " + fileName);
            FileStream fs = File.OpenRead(fileName);
            LoadClassFromBytes(ReadFully(fs));
            fs.Close();
        }

        public void LoadClassFromBytes(byte[] data)
        {
            int i = 0;
            i += 4;
            m_minorVersion = (ushort) ((data[i++] << 8) + data[i++]);
            m_majorVersion = (ushort) ((data[i++] << 8) + data[i++]);
            m_constantPoolCount = (ushort) ((data[i++] << 8) + data[i++]);
            Console.WriteLine("there should be " + m_constantPoolCount + " items in the pool");
            for (int count = 0; count < (m_constantPoolCount - 1); count++)
            {
                //read in the constant pool
                byte pooltype = data[i++];
                Console.WriteLine("#" + count + ": new constant type = " + pooltype);
                //Console.WriteLine("start position is: " + i);
                switch (pooltype)
                {
                    case 1: //Utf8
                        ushort uLength = (ushort) ((data[i++] << 8) + data[i++]);

                        // Console.WriteLine("new utf8 type, length is " + uLength);
                        PoolUtf8 utf8 = new PoolUtf8();
                        utf8.readValue(data, ref i, uLength);
                        m_constantsPool.Add(utf8);
                        break;
                    case 3: //Int
                        break;
                    case 4: //Float
                        break;
                    case 7: //Class
                        PoolClass pClass = new PoolClass(this);
                        pClass.readValue(data, ref i);
                        m_constantsPool.Add(pClass);
                        break;
                    case 9: //FieldRef
                        PoolFieldRef pField = new PoolFieldRef(this);
                        pField.readValue(data, ref i);
                        m_constantsPool.Add(pField);
                        break;
                    case 10: //Method
                        PoolMethodRef pMeth = new PoolMethodRef(this);
                        pMeth.readValue(data, ref i);
                        m_constantsPool.Add(pMeth);
                        break;
                    case 12: //NamedType
                        PoolNamedType pNamed = new PoolNamedType(this);
                        pNamed.readValue(data, ref i);
                        m_constantsPool.Add(pNamed);
                        break;
                }
            }

            m_accessFlags = (ushort) ((data[i++] << 8) + data[i++]);
            m_thisClass = (ushort) ((data[i++] << 8) + data[i++]);
            m_supperClass = (ushort) ((data[i++] << 8) + data[i++]);

            if (m_constantsPool[m_thisClass - 1] is PoolClass)
            {
                MClass = ((PoolClass) m_constantsPool[m_thisClass - 1]);
            }

            m_interfaceCount = (ushort) ((data[i++] << 8) + data[i++]);
            //should now read in the info for each interface

            m_fieldCount = (ushort) ((data[i++] << 8) + data[i++]);
            //should now read in the info for each field
            for (int count = 0; count < m_fieldCount; count++)
            {
                FieldInfo fieldInf = new FieldInfo(this);
                fieldInf.ReadData(data, ref i);
                m_fieldList.Add(fieldInf);
            }

            m_methodCount = (ushort) ((data[i++] << 8) + data[i++]);
            for (int count = 0; count < m_methodCount; count++)
            {
                MethodInfo methInf = new MethodInfo(this);
                methInf.ReadData(data, ref i);
                m_methodsList.Add(methInf);
            }
        }

        public void AddMethodsToMemory(MethodMemory memory)
        {
            for (int count = 0; count < m_methodCount; count++)
            {
                m_methodsList[count].AddMethodCode(memory);
            }
        }

        public bool StartMethod(Thread thread, string methodName)
        {
            for (int count = 0; count < m_methodCount; count++)
            {
                if (m_constantsPool[m_methodsList[count].NameIndex - 1] is PoolUtf8)
                {
                    if (((PoolUtf8) m_constantsPool[m_methodsList[count].NameIndex - 1]).Value == methodName)
                    {
                        //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value);
                        thread.SetPC(m_methodsList[count].CodePointer);
                        return true;
                    }
                }
            }
            return false;
        }

        public void PrintToConsole()
        {
            Console.WriteLine("Class File:");
            Console.WriteLine("Major version: " + m_majorVersion);
            Console.WriteLine("Minor version: " + m_minorVersion);
            Console.WriteLine("Pool size: " + m_constantPoolCount);

            for (int i = 0; i < m_constantsPool.Count; i++)
            {
                m_constantsPool[i].Print();
            }

            Console.WriteLine("Access flags: " + m_accessFlags);
            Console.WriteLine("This class: " + m_thisClass);
            Console.WriteLine("Super class: " + m_supperClass);

            for (int count = 0; count < m_fieldCount; count++)
            {
                Console.WriteLine();
                m_fieldList[count].Print();
            }

            for (int count = 0; count < m_methodCount; count++)
            {
                Console.WriteLine();
                m_methodsList[count].Print();
            }

            Console.WriteLine("class name is " + MClass.Name.Value);
        }

        public static byte[] ReadFully(Stream stream)
        {
            byte[] buffer = new byte[1024];
            using (MemoryStream ms = new MemoryStream())
            {
                while (true)
                {
                    int read = stream.Read(buffer, 0, buffer.Length);
                    if (read <= 0)
                        return ms.ToArray();
                    ms.Write(buffer, 0, read);
                }
            }
        }

        #region nested classes

        public class PoolItem
        {
            public virtual void Print()
            {
            }
        }

        public class PoolUtf8 : PoolItem
        {
            public string Value = String.Empty;

            public void readValue(byte[] data, ref int pointer, int length)
            {
                for (int i = 0; i < length; i++)
                {
                    int a = (int) data[pointer++];
                    if ((a & 0x80) == 0)
                    {
                        Value = Value + (char) a;
                    }
                    else if ((a & 0x20) == 0)
                    {
                        int b = (int) data[pointer++];
                        Value = Value + (char) (((a & 0x1f) << 6) + (b & 0x3f));
                    }
                    else
                    {
                        int b = (int) data[pointer++];
                        int c = (int) data[pointer++];
                        Value = Value + (char) (((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f));
                    }
                }
            }

            public override void Print()
            {
                Console.WriteLine("Utf8 type: " + Value);
            }
        }

        private class PoolInt : PoolItem
        {
        }

        public class PoolClass : PoolItem
        {
            //public string name = String.Empty;
            public ushort namePointer = 0;
            private ClassRecord parent;
            public PoolUtf8 Name;

            public PoolClass(ClassRecord paren)
            {
                parent = paren;
            }

            public void readValue(byte[] data, ref int pointer)
            {
                namePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]);
            }

            public override void Print()
            {
                Name = ((PoolUtf8) parent.m_constantsPool[namePointer - 1]);
                Console.Write("Class type: " + namePointer);
                Console.WriteLine(" // " + ((PoolUtf8) parent.m_constantsPool[namePointer - 1]).Value);
            }
        }

        public class PoolFieldRef : PoolItem
        {
            public ushort classPointer = 0;
            public ushort nameTypePointer = 0;
            public PoolNamedType mNameType;
            public PoolClass mClass;
            private ClassRecord parent;

            public PoolFieldRef(ClassRecord paren)
            {
                parent = paren;
            }

            public void readValue(byte[] data, ref int pointer)
            {
                classPointer = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                nameTypePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]);
            }

            public override void Print()
            {
                mNameType = ((PoolNamedType) parent.m_constantsPool[nameTypePointer - 1]);
                mClass = ((PoolClass) parent.m_constantsPool[classPointer - 1]);
                Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer);
            }
        }

        public class PoolMethodRef : PoolItem
        {
            public ushort classPointer = 0;
            public ushort nameTypePointer = 0;
            public PoolNamedType mNameType;
            public PoolClass mClass;
            private ClassRecord parent;

            public PoolMethodRef(ClassRecord paren)
            {
                parent = paren;
            }

            public void readValue(byte[] data, ref int pointer)
            {
                classPointer = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                nameTypePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]);
            }

            public override void Print()
            {
                mNameType = ((PoolNamedType) parent.m_constantsPool[nameTypePointer - 1]);
                mClass = ((PoolClass) parent.m_constantsPool[classPointer - 1]);
                Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer);
            }
        }

        public class PoolNamedType : PoolItem
        {
            public ushort namePointer = 0;
            public ushort typePointer = 0;
            private ClassRecord parent;
            public PoolUtf8 Name;
            public PoolUtf8 Type;

            public PoolNamedType(ClassRecord paren)
            {
                parent = paren;
            }

            public void readValue(byte[] data, ref int pointer)
            {
                namePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                typePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]);
            }

            public override void Print()
            {
                Name = ((PoolUtf8) parent.m_constantsPool[namePointer - 1]);
                Type = ((PoolUtf8) parent.m_constantsPool[typePointer - 1]);
                Console.Write("Named type: " + namePointer + " , " + typePointer);
                Console.WriteLine(" // " + ((PoolUtf8) parent.m_constantsPool[namePointer - 1]).Value);
            }
        }

        //***********************
        public class MethodInfo
        {
            public ushort AccessFlags = 0;
            public ushort NameIndex = 0;
            public string Name = String.Empty;
            public ushort DescriptorIndex = 0;
            public ushort AttributeCount = 0;
            public List<MethodAttribute> Attributes = new List<MethodAttribute>();
            private ClassRecord parent;
            public int CodePointer = 0;

            public MethodInfo(ClassRecord paren)
            {
                parent = paren;
            }

            public void AddMethodCode(MethodMemory memory)
            {
                Array.Copy(Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, Attributes[0].Code.Length);
                memory.Methodcount++;
                CodePointer = memory.NextMethodPC;
                memory.NextMethodPC += Attributes[0].Code.Length;
            }

            public void ReadData(byte[] data, ref int pointer)
            {
                AccessFlags = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                DescriptorIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                AttributeCount = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                for (int i = 0; i < AttributeCount; i++)
                {
                    MethodAttribute attri = new MethodAttribute(parent);
                    attri.ReadData(data, ref pointer);
                    Attributes.Add(attri);
                }
            }

            public void Print()
            {
                Console.WriteLine("Method Info Struct: ");
                Console.WriteLine("AccessFlags: " + AccessFlags);
                Console.WriteLine("NameIndex: " + NameIndex + " // " +
                                  ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value);
                Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " +
                                  ((PoolUtf8) parent.m_constantsPool[DescriptorIndex - 1]).Value);
                Console.WriteLine("Attribute Count:" + AttributeCount);
                for (int i = 0; i < AttributeCount; i++)
                {
                    Attributes[i].Print();
                }
            }

            public class MethodAttribute
            {
                public ushort NameIndex = 0;
                public string Name = String.Empty;
                public Int32 Length = 0;
                //for now only support code attribute
                public ushort MaxStack = 0;
                public ushort MaxLocals = 0;
                public Int32 CodeLength = 0;
                public byte[] Code;
                public ushort ExceptionTableLength = 0;
                public ushort SubAttributeCount = 0;
                public List<SubAttribute> SubAttributes = new List<SubAttribute>();
                private ClassRecord parent;

                public MethodAttribute(ClassRecord paren)
                {
                    parent = paren;
                }

                public void ReadData(byte[] data, ref int pointer)
                {
                    NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                    Length =
                        (Int32)
                        ((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
                    MaxStack = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                    MaxLocals = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                    CodeLength =
                        (Int32)
                        ((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
                    Code = new byte[CodeLength];
                    for (int i = 0; i < CodeLength; i++)
                    {
                        Code[i] = data[pointer++];
                    }
                    ExceptionTableLength = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                    SubAttributeCount = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                    for (int i = 0; i < SubAttributeCount; i++)
                    {
                        SubAttribute subAttri = new SubAttribute(parent);
                        subAttri.ReadData(data, ref pointer);
                        SubAttributes.Add(subAttri);
                    }
                }

                public void Print()
                {
                    Console.WriteLine("Method Attribute: ");
                    Console.WriteLine("Name Index: " + NameIndex + " // " +
                                      ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value);
                    Console.WriteLine("Length: " + Length);
                    Console.WriteLine("MaxStack: " + MaxStack);
                    Console.WriteLine("MaxLocals: " + MaxLocals);
                    Console.WriteLine("CodeLength: " + CodeLength);
                    for (int i = 0; i < Code.Length; i++)
                    {
                        Console.WriteLine("OpCode #" + i + " is: " + Code[i]);
                    }
                    Console.WriteLine("SubAttributes: " + SubAttributeCount);
                    for (int i = 0; i < SubAttributeCount; i++)
                    {
                        SubAttributes[i].Print();
                    }
                }

                public class SubAttribute
                {
                    public ushort NameIndex = 0;
                    public string Name = String.Empty;
                    public Int32 Length = 0;
                    public byte[] Data;
                    private ClassRecord parent;

                    public SubAttribute(ClassRecord paren)
                    {
                        parent = paren;
                    }

                    public void ReadData(byte[] data, ref int pointer)
                    {
                        NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                        Length =
                            (Int32)
                            ((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) +
                             data[pointer++]);
                        Data = new byte[Length];
                        for (int i = 0; i < Length; i++)
                        {
                            Data[i] = data[pointer++];
                        }
                    }

                    public void Print()
                    {
                        Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " +
                                          ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value);
                    }
                }
            }
        }

        private class InterfaceInfo
        {
            public void ReadData(byte[] data, ref int i)
            {
            }
        }

        public class FieldInfo
        {
            public ushort AccessFlags = 0;
            public ushort NameIndex = 0;
            public string Name = String.Empty;
            public ushort DescriptorIndex = 0;
            public ushort AttributeCount = 0;
            public List<FieldAttribute> Attributes = new List<FieldAttribute>();
            private ClassRecord parent;

            public FieldInfo(ClassRecord paren)
            {
                parent = paren;
            }

            public void ReadData(byte[] data, ref int pointer)
            {
                AccessFlags = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                DescriptorIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                AttributeCount = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                for (int i = 0; i < AttributeCount; i++)
                {
                    FieldAttribute attri = new FieldAttribute(parent);
                    attri.ReadData(data, ref pointer);
                    Attributes.Add(attri);
                }
            }

            public void Print()
            {
                Console.WriteLine("Field Info Struct: ");
                Console.WriteLine("AccessFlags: " + AccessFlags);
                Console.WriteLine("NameIndex: " + NameIndex + " // " +
                                  ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value);
                Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " +
                                  ((PoolUtf8) parent.m_constantsPool[DescriptorIndex - 1]).Value);
                Console.WriteLine("Attribute Count:" + AttributeCount);
                //if static, add to static field list
                // if (this.AccessFlags == 9) //public and static
                if ((AccessFlags & 0x08) != 0)
                {
                    switch (((PoolUtf8) parent.m_constantsPool[DescriptorIndex - 1]).Value)
                    {
                        case "I":
                            Int newin = new Int();
                            parent.StaticFields.Add(((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value, newin);
                            break;
                        case "F":
                            Float newfl = new Float();
                            parent.StaticFields.Add(((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value, newfl);
                            break;
                    }
                }
                for (int i = 0; i < AttributeCount; i++)
                {
                    Attributes[i].Print();
                }
            }

            public class FieldAttribute
            {
                public ushort NameIndex = 0;
                public string Name = String.Empty;
                public Int32 Length = 0;
                public byte[] Data;
                private ClassRecord parent;

                public FieldAttribute(ClassRecord paren)
                {
                    parent = paren;
                }

                public void ReadData(byte[] data, ref int pointer)
                {
                    NameIndex = (ushort) ((data[pointer++] << 8) + data[pointer++]);
                    Length =
                        (Int32)
                        ((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
                    Data = new byte[Length];
                    for (int i = 0; i < Length; i++)
                    {
                        Data[i] = data[pointer++];
                    }
                }

                public void Print()
                {
                    Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " +
                                      ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value);
                }
            }
        }

        private class AttributeInfo
        {
            public void ReadData(byte[] data, ref int i)
            {
            }
        }

        #endregion
    }
}