001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.harmony.pack200.tests;
018:
019: import java.io.ByteArrayInputStream;
020: import java.io.IOException;
021: import java.io.InputStream;
022: import java.util.ArrayList;
023:
024: import org.apache.harmony.pack200.AttrDefinitionBands;
025: import org.apache.harmony.pack200.BcBands;
026: import org.apache.harmony.pack200.ClassBands;
027: import org.apache.harmony.pack200.CpBands;
028: import org.apache.harmony.pack200.Pack200Exception;
029: import org.apache.harmony.pack200.Segment;
030: import org.apache.harmony.pack200.SegmentConstantPool;
031:
032: /**
033: * Tests for Pack200 bytecode bands
034: */
035:
036: /*
037: * TODO: The number 8 is used in most of the tests in this class as a low
038: * (non-zero) number that is not likely to indicate a multiple byte number, but
039: * should be replaced with properly encoded byte arrays when encoding is
040: * implemented.
041: */
042: public class BcBandsTest extends AbstractBandsTestCase {
043:
044: public class MockCpBands extends CpBands {
045:
046: public MockCpBands(Segment segment) {
047: super (segment);
048: }
049:
050: public String[] getCpString() {
051: String[] classes = new String[100];
052: for (int index = 0; index < 100; index++) {
053: classes[index] = "java/lang/Stri:ng(J)";
054: }
055: return classes;
056: }
057:
058: public String[] getCpClass() {
059: return getCpString();
060: }
061:
062: public String[] getCpFieldClass() {
063: return getCpClass();
064: }
065:
066: public String[] getCpFieldDescriptor() {
067: return getCpString();
068: }
069:
070: public String[] getCpMethodClass() {
071: return getCpClass();
072: }
073:
074: public String[] getCpMethodDescriptor() {
075: return getCpString();
076: }
077:
078: public String[] getCpIMethodClass() {
079: return getCpClass();
080: }
081:
082: public String[] getCpIMethodDescriptor() {
083: return getCpString();
084: }
085:
086: public int[] getCpInt() {
087: int[] elements = new int[100];
088: for (int index = 0; index < 100; index++) {
089: elements[index] = 1;
090: }
091: return elements;
092: }
093:
094: public float[] getCpFloat() {
095: float[] elements = new float[100];
096: for (int index = 0; index < 100; index++) {
097: elements[index] = 1.0f;
098: }
099: return elements;
100: }
101:
102: public long[] getCpLong() {
103: long[] elements = new long[100];
104: for (int index = 0; index < 100; index++) {
105: elements[index] = 1L;
106: }
107: return elements;
108: }
109:
110: public double[] getCpDouble() {
111: double[] elements = new double[100];
112: for (int index = 0; index < 100; index++) {
113: elements[index] = 1.0D;
114: }
115: return elements;
116: }
117: }
118:
119: public class MockClassBands extends ClassBands {
120: public MockClassBands(Segment segment) {
121: super (segment);
122: }
123:
124: public long[][] getMethodFlags() {
125: long[][] flags = new long[numClasses][];
126: for (int i = 0; i < flags.length; i++) {
127: flags[i] = new long[numMethods[i]];
128: }
129: return flags;
130: }
131:
132: public int[] getCodeMaxStack() {
133: int totalMethods = 0;
134: for (int i = 0; i < numClasses; i++) {
135: totalMethods += numMethods[i];
136: }
137: return new int[totalMethods];
138: }
139:
140: public int[] getCodeMaxNALocals() {
141: int totalMethods = 0;
142: for (int i = 0; i < numClasses; i++) {
143: totalMethods += numMethods[i];
144: }
145: return new int[totalMethods];
146: }
147:
148: public String[][] getMethodDescr() {
149: String[][] descr = new String[numClasses][];
150: for (int i = 0; i < descr.length; i++) {
151: descr[i] = new String[numMethods[i]];
152: for (int j = 0; j < descr[i].length; j++) {
153: descr[i][j] = "hello()";
154: }
155: }
156: return descr;
157: }
158:
159: public String[] getClassThis() {
160: String[] this Classes = new String[numClasses];
161: for (int index = 0; index < numClasses; index++) {
162: this Classes[index] = "java/lang/String";
163: }
164: return this Classes;
165: }
166:
167: public String[] getClassSuper() {
168: String[] super Classes = new String[numClasses];
169: for (int index = 0; index < numClasses; index++) {
170: super Classes[index] = "java/lang/Object";
171: }
172: return super Classes;
173: }
174:
175: public ArrayList[][] getMethodAttributes() {
176: ArrayList[][] attributes = new ArrayList[numClasses][];
177: for (int i = 0; i < attributes.length; i++) {
178: attributes[i] = new ArrayList[numMethods[i]];
179: for (int j = 0; j < attributes[i].length; j++) {
180: attributes[i][j] = new ArrayList();
181: }
182: }
183: return attributes;
184: }
185:
186: public ArrayList getOrderedCodeAttributes() {
187: int totalMethods = 0;
188: for (int classIndex = 0; classIndex < numMethods.length; classIndex++) {
189: totalMethods = totalMethods + numMethods[classIndex];
190: }
191: ArrayList orderedAttributeList = new ArrayList();
192: for (int classIndex = 0; classIndex < totalMethods; classIndex++) {
193: ArrayList currentAttributes = new ArrayList();
194: orderedAttributeList.add(currentAttributes);
195: }
196: return orderedAttributeList;
197: }
198: }
199:
200: public class MockSegment extends AbstractBandsTestCase.MockSegment {
201: public CpBands cpBands;
202:
203: protected AttrDefinitionBands getAttrDefinitionBands() {
204: return new MockAttributeDefinitionBands(this );
205: }
206:
207: protected CpBands getCpBands() {
208: if (null == cpBands) {
209: cpBands = new MockCpBands(this );
210: }
211: return cpBands;
212: }
213:
214: protected ClassBands getClassBands() {
215: return new MockClassBands(this );
216: }
217:
218: public SegmentConstantPool getConstantPool() {
219: return cpBands.getConstantPool();
220: }
221: }
222:
223: BcBands bcBands = new BcBands(new MockSegment());
224:
225: /**
226: * Test with single byte instructions that mean all other bands apart from
227: * bc_codes will be empty.
228: *
229: * @throws IOException
230: * @throws Pack200Exception
231: */
232: public void testSimple() throws IOException, Pack200Exception {
233: byte[] bytes = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
234: 11, 12, 13, 14, 15, 26, 27, 28, 29, 30, 31, 32, 33, 34,
235: 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
236: 49, 50, 51, 52, 53, 59, 60, 61, 62, 63, 64, 65, 66, 67,
237: 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
238: 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
239: 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
240: 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
241: 119, 120, 121, 122, 123, 124, 125, 126, 127,
242: (byte) 128, (byte) 129, (byte) 130, (byte) 131,
243: (byte) 133, (byte) 134, (byte) 135, (byte) 136,
244: (byte) 137, (byte) 138, (byte) 139, (byte) 140,
245: (byte) 141, (byte) 142, (byte) 143, (byte) 144,
246: (byte) 145, (byte) 146, (byte) 147, (byte) 148,
247: (byte) 149, (byte) 150, (byte) 151, (byte) 172,
248: (byte) 173, (byte) 174, (byte) 175, (byte) 176,
249: (byte) 177, (byte) 190, (byte) 191, (byte) 194,
250: (byte) 195, (byte) 255 };
251: InputStream in = new ByteArrayInputStream(bytes);
252: bcBands.unpack(in);
253: assertEquals(bytes.length - 1, bcBands
254: .getMethodByteCodePacked()[0][0].length);
255: }
256:
257: /**
258: * Test with multiple classes but single byte instructions
259: *
260: * @throws IOException
261: * @throws Pack200Exception
262: */
263: public void testMultipleClassesSimple() throws IOException,
264: Pack200Exception {
265: numClasses = 2;
266: numMethods = new int[] { 1, 1 };
267: byte[] bytes = new byte[] { 50, 50, (byte) 255, 50, 50,
268: (byte) 255 };
269: InputStream in = new ByteArrayInputStream(bytes);
270: bcBands.unpack(in);
271: assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
272: assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
273:
274: numClasses = 1;
275: numMethods = new int[] { 1 };
276: }
277:
278: /**
279: * Test with multiple classes and multiple methods but single byte instructions
280: * @throws IOException
281: * @throws Pack200Exception
282: */
283: public void testMultipleMethodsSimple() throws IOException,
284: Pack200Exception {
285: numClasses = 2;
286: numMethods = new int[] { 3, 1 };
287: byte[] bytes = new byte[] { 50, 50, (byte) 255, 50, 50,
288: (byte) 255, 50, 50, (byte) 255, 50, 50, (byte) 255 };
289: InputStream in = new ByteArrayInputStream(bytes);
290: bcBands.unpack(in);
291: assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
292: assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
293:
294: numClasses = 1;
295: numMethods = new int[] { 1 };
296: }
297:
298: /**
299: * Test with codes that require entries in the bc_case_count and bc_case_value bands
300: * @throws Pack200Exception
301: * @throws IOException
302: */
303: public void testBcCaseBands() throws IOException, Pack200Exception {
304: byte[] bytes = new byte[] { (byte) 170, (byte) 171, 0, 0, 0, 0,
305: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 255, 2, 5, // bc_case_count
306: 0, 0, 0, 0, 0, 0, 0, // bc_case_value
307: 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // bc_label
308: InputStream in = new ByteArrayInputStream(bytes);
309: bcBands.unpack(in);
310: assertEquals(18, bcBands.getMethodByteCodePacked()[0][0].length);
311: int[] bc_case_count = bcBands.getBcCaseCount();
312: assertEquals(2, bc_case_count.length);
313: assertEquals(2, bc_case_count[0]);
314: assertEquals(5, bc_case_count[1]);
315: int[] bc_case_value = bcBands.getBcCaseValue();
316: assertEquals(0, bc_case_value[0]);
317: assertEquals(0, bc_case_value[1]);
318: assertEquals(9, bcBands.getBcLabel().length);
319: }
320:
321: /**
322: * Test with codes that should require entries in the bc_byte band
323: *
324: * @throws Pack200Exception
325: * @throws IOException
326: */
327: public void testBcByteBand() throws IOException, Pack200Exception {
328: byte[] bytes = new byte[] { 16, (byte) 132, (byte) 188,
329: (byte) 197, (byte) 255, 8, 8, 8, 8, // bc_byte band
330: 8, // bc_locals band (required by iinc (132))
331: 8 }; // bc_class band (required by multianewarray (197))
332: InputStream in = new ByteArrayInputStream(bytes);
333: bcBands.unpack(in);
334: assertEquals(4, bcBands.getMethodByteCodePacked()[0][0].length);
335: int[] bc_byte = bcBands.getBcByte();
336: assertEquals(4, bc_byte.length);
337: for (int i = 0; i < bc_byte.length; i++) {
338: assertEquals(8, bc_byte[i]);
339: }
340: assertEquals(1, bcBands.getBcLocal().length);
341: assertEquals(1, bcBands.getBcClassRef().length);
342: }
343:
344: /**
345: * Test with codes that should require entries in the bc_short band
346: *
347: * @throws Pack200Exception
348: * @throws IOException
349: */
350: public void testBcShortBand() throws IOException, Pack200Exception {
351: //TODO: Need to fix this testcase so it has enough data to pass.
352: byte[] bytes = new byte[] { 17, (byte) 196, (byte) 132,
353: (byte) 255, 8, 8,// bc_short band
354: 8, 8, 8, 8 }; // bc_locals band (required by wide iinc (196, 132))
355: InputStream in = new ByteArrayInputStream(bytes);
356: bcBands.unpack(in);
357: assertEquals(3, bcBands.getMethodByteCodePacked()[0][0].length);
358: assertEquals(2, bcBands.getBcShort().length);
359: assertEquals(2, bcBands.getBcLocal().length);
360: }
361:
362: /**
363: * Test with codes that should require entries in the bc_local band
364: *
365: * @throws Pack200Exception
366: * @throws IOException
367: */
368: public void testBcLocalBand() throws IOException, Pack200Exception {
369: byte[] bytes = new byte[] { 21, 22, 23, 24, 25, 54, 55, 56, 57,
370: 58, (byte) 169, (byte) 255, 8, 8, 8, 8, 8, 8, 8, 8, 8,
371: 8, 8 }; // bc_local band
372: InputStream in = new ByteArrayInputStream(bytes);
373: bcBands.unpack(in);
374: assertEquals(11, bcBands.getMethodByteCodePacked()[0][0].length);
375: assertEquals(11, bcBands.getBcLocal().length);
376: }
377:
378: /**
379: * Test with codes that should require entries in the bc_label band
380: *
381: * @throws Pack200Exception
382: * @throws IOException
383: */
384: public void testBcLabelBand() throws IOException, Pack200Exception {
385: byte[] bytes = new byte[] { (byte) 159, (byte) 160, (byte) 161,
386: (byte) 162, (byte) 163, (byte) 164, (byte) 165,
387: (byte) 166, (byte) 167, (byte) 168, (byte) 170,
388: (byte) 171, (byte) 198, (byte) 199, (byte) 200,
389: (byte) 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
390: 0, 0, 0, 0, 0, 0, (byte) 255, 2,
391: 2, // bc_case_count (required by tableswitch (170) and lookupswitch (171))
392: 0,
393: 0,
394: 0,
395: 0, // bc_case_value
396: // Now that we're actually doing real label lookup, need valid labels
397: // 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 }; // bc_label band
398: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
399: 0, 0 }; // bc_label band
400: InputStream in = new ByteArrayInputStream(bytes);
401: bcBands.unpack(in);
402: assertEquals(36, bcBands.getMethodByteCodePacked()[0][0].length);
403: assertEquals(20, bcBands.getBcLabel().length);
404: }
405:
406: public void testWideForms() throws IOException, Pack200Exception {
407: byte[] bytes = new byte[] { (byte) 196, (byte) 54, // wide istore
408: (byte) 196, (byte) 132, // wide iinc
409: (byte) 255, 0, // bc_short band
410: 0, 0, 0, 1 }; // bc_locals band
411: InputStream in = new ByteArrayInputStream(bytes);
412: bcBands.unpack(in);
413: assertEquals(4, bcBands.getMethodByteCodePacked()[0][0].length);
414: assertEquals(4, bcBands.getBcLocal().length);
415: assertEquals(1, bcBands.getBcShort().length);
416: }
417:
418: /**
419: * Test with codes that should require entries in the bc_intref band
420: *
421: * @throws Pack200Exception
422: * @throws IOException
423: */
424: public void testBcIntRefBand() throws IOException, Pack200Exception {
425: byte[] bytes = new byte[] { (byte) 234, (byte) 237, (byte) 255,
426: 8, 8 }; // bc_intref band
427: InputStream in = new ByteArrayInputStream(bytes);
428: bcBands.unpack(in);
429: assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
430: int[] bc_intref = bcBands.getBcIntRef();
431: assertEquals(2, bc_intref.length);
432: }
433:
434: /**
435: * Test with codes that should require entries in the bc_floatref band
436: *
437: * @throws Pack200Exception
438: * @throws IOException
439: */
440: public void testBcFloatRefBand() throws IOException,
441: Pack200Exception {
442: byte[] bytes = new byte[] { (byte) 235, (byte) 238, (byte) 255,
443: 8, 8 }; // bc_floatref band
444: InputStream in = new ByteArrayInputStream(bytes);
445: bcBands.unpack(in);
446: assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
447: int[] bc_floatref = bcBands.getBcFloatRef();
448: assertEquals(2, bc_floatref.length);
449: }
450:
451: /**
452: * Test with codes that should require entries in the bc_longref band
453: *
454: * @throws Pack200Exception
455: * @throws IOException
456: */
457: public void testBcLongRefBand() throws IOException,
458: Pack200Exception {
459: byte[] bytes = new byte[] { 20, (byte) 255, 8 }; // bc_longref band
460: InputStream in = new ByteArrayInputStream(bytes);
461: bcBands.unpack(in);
462: assertEquals(1, bcBands.getMethodByteCodePacked()[0][0].length);
463: int[] bc_longref = bcBands.getBcLongRef();
464: assertEquals(1, bc_longref.length);
465: }
466:
467: /**
468: * Test with codes that should require entries in the bc_doubleref band
469: *
470: * @throws Pack200Exception
471: * @throws IOException
472: */
473: public void testBcDoubleRefBand() throws IOException,
474: Pack200Exception {
475: byte[] bytes = new byte[] { (byte) 239, (byte) 255, 8 }; // bc_doubleref band
476: InputStream in = new ByteArrayInputStream(bytes);
477: bcBands.unpack(in);
478: assertEquals(1, bcBands.getMethodByteCodePacked()[0][0].length);
479: int[] bc_doubleref = bcBands.getBcDoubleRef();
480: assertEquals(1, bc_doubleref.length);
481: }
482:
483: /**
484: * Test with codes that should require entries in the bc_stringref band
485: *
486: * @throws Pack200Exception
487: * @throws IOException
488: */
489: public void testBcStringRefBand() throws IOException,
490: Pack200Exception {
491: byte[] bytes = new byte[] { 18, 19, (byte) 255, 8, 8 }; // bc_stringref band
492: InputStream in = new ByteArrayInputStream(bytes);
493: bcBands.unpack(in);
494: assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
495: int[] bc_stringref = bcBands.getBcStringRef();
496: assertEquals(2, bc_stringref.length);
497: }
498:
499: /**
500: * Test with codes that should require entries in the bc_classref band
501: *
502: * @throws Pack200Exception
503: * @throws IOException
504: */
505: public void testBcClassRefBand() throws IOException,
506: Pack200Exception {
507: byte[] bytes = new byte[] { (byte) 233, (byte) 236, (byte) 255,
508: 8, 8 }; // bc_classref band
509: InputStream in = new ByteArrayInputStream(bytes);
510: bcBands.unpack(in);
511: assertEquals(2, bcBands.getMethodByteCodePacked()[0][0].length);
512: int[] bc_classref = bcBands.getBcClassRef();
513: assertEquals(2, bc_classref.length);
514: }
515:
516: /**
517: * Test with codes that should require entries in the bc_fieldref band
518: *
519: * @throws Pack200Exception
520: * @throws IOException
521: */
522: public void testBcFieldRefBand() throws IOException,
523: Pack200Exception {
524: byte[] bytes = new byte[] { (byte) 178, (byte) 179, (byte) 180,
525: (byte) 181, (byte) 255, 8, 8, 8, 8 }; // bc_fieldref band
526: InputStream in = new ByteArrayInputStream(bytes);
527: bcBands.unpack(in);
528: assertEquals(4, bcBands.getMethodByteCodePacked()[0][0].length);
529: int[] bc_fieldref = bcBands.getBcFieldRef();
530: assertEquals(4, bc_fieldref.length);
531: }
532:
533: /**
534: * Test with codes that should require entries in the bc_methodref band
535: *
536: * @throws Pack200Exception
537: * @throws IOException
538: */
539: public void testBcMethodRefBand() throws IOException,
540: Pack200Exception {
541: byte[] bytes = new byte[] { (byte) 182, (byte) 183, (byte) 184,
542: (byte) 255, 8, 8, 8 }; // bc_methodref band
543: InputStream in = new ByteArrayInputStream(bytes);
544: bcBands.unpack(in);
545: assertEquals(3, bcBands.getMethodByteCodePacked()[0][0].length);
546: int[] bc_methodref = bcBands.getBcMethodRef();
547: assertEquals(3, bc_methodref.length);
548: }
549:
550: /**
551: * Test with codes that should require entries in the bc_imethodref band
552: *
553: * @throws Pack200Exception
554: * @throws IOException
555: */
556: public void testBcIMethodRefBand() throws IOException,
557: Pack200Exception {
558: byte[] bytes = new byte[] { (byte) 185, (byte) 255, 8 }; // bc_imethodref band
559: InputStream in = new ByteArrayInputStream(bytes);
560: bcBands.unpack(in);
561: assertEquals(1, bcBands.getMethodByteCodePacked()[0][0].length);
562: int[] bc_imethodref = bcBands.getBcIMethodRef();
563: assertEquals(1, bc_imethodref.length);
564: }
565:
566: /**
567: * Test with codes that should require entries in the bc_thisfieldref band
568: *
569: * @throws Pack200Exception
570: * @throws IOException
571: */
572: public void testBcThisFieldBand() throws IOException,
573: Pack200Exception {
574: byte[] bytes = new byte[] { (byte) 202, (byte) 203, (byte) 204,
575: (byte) 205, (byte) 209, (byte) 210, (byte) 211,
576: (byte) 212, (byte) 255, 8, 8, 8, 8, 8, 8, 8, 8 }; // bc_thisfieldref band
577: InputStream in = new ByteArrayInputStream(bytes);
578: bcBands.unpack(in);
579: assertEquals(8, bcBands.getMethodByteCodePacked()[0][0].length);
580: int[] bc_this field = bcBands.getBcThisField();
581: assertEquals(8, bc_this field.length);
582: }
583:
584: /**
585: * Test with codes that should require entries in the bc_superfield band
586: *
587: * @throws Pack200Exception
588: * @throws IOException
589: */
590: public void testBcSuperFieldBand() throws IOException,
591: Pack200Exception {
592: byte[] bytes = new byte[] { (byte) 216, (byte) 217, (byte) 218,
593: (byte) 219, (byte) 223, (byte) 224, (byte) 225,
594: (byte) 226, (byte) 255, 8, 8, 8, 8, 8, 8, 8, 8 }; // bc_superfield band
595: InputStream in = new ByteArrayInputStream(bytes);
596: bcBands.unpack(in);
597: assertEquals(8, bcBands.getMethodByteCodePacked()[0][0].length);
598: int[] bc_super field = bcBands.getBcSuperField();
599: assertEquals(8, bc_super field.length);
600: }
601:
602: /**
603: * Test with codes that should require entries in the bc_thismethod band
604: *
605: * @throws Pack200Exception
606: * @throws IOException
607: */
608: public void testBcThisMethodBand() throws IOException,
609: Pack200Exception {
610: byte[] bytes = new byte[] { (byte) 206, (byte) 207, (byte) 208,
611: (byte) 213, (byte) 214, (byte) 215, (byte) 255, 8, 8,
612: 8, 8, 8, 8 }; // bc_thismethod band
613: InputStream in = new ByteArrayInputStream(bytes);
614: bcBands.unpack(in);
615: assertEquals(6, bcBands.getMethodByteCodePacked()[0][0].length);
616: int[] bc_this method = bcBands.getBcThisMethod();
617: assertEquals(6, bc_this method.length);
618: }
619:
620: /**
621: * Test with codes that should require entries in the bc_supermethod band
622: *
623: * @throws Pack200Exception
624: * @throws IOException
625: */
626: public void testBcSuperMethodBand() throws IOException,
627: Pack200Exception {
628: //TODO: Need to fix this testcase so it has enough data to pass.
629: if (true)
630: return;
631: byte[] bytes = new byte[] { (byte) 220, (byte) 221, (byte) 222,
632: (byte) 227, (byte) 228, (byte) 229, (byte) 255, 8, 8,
633: 8, 8, 8, 8 }; // bc_supermethod band
634: InputStream in = new ByteArrayInputStream(bytes);
635: bcBands.unpack(in);
636: assertEquals(6, bcBands.getMethodByteCodePacked()[0][0].length);
637: int[] bc_super method = bcBands.getBcSuperMethod();
638: assertEquals(6, bc_super method.length);
639: }
640:
641: /**
642: * Test with codes that should require entries in the bc_initrefref band
643: *
644: * @throws Pack200Exception
645: * @throws IOException
646: */
647: public void testBcInitRefRefBand() throws IOException,
648: Pack200Exception {
649: //TODO: Need to fix this testcase so it has enough data to pass.
650: if (true)
651: return;
652: byte[] bytes = new byte[] { (byte) 230, (byte) 231, (byte) 232,
653: (byte) 255, 8, 8, 8 }; // bc_initrefref band
654: InputStream in = new ByteArrayInputStream(bytes);
655: bcBands.unpack(in);
656: assertEquals(3, bcBands.getMethodByteCodePacked()[0][0].length);
657: int[] bc_initrefref = bcBands.getBcInitRef();
658: assertEquals(3, bc_initrefref.length);
659: }
660:
661: public void testBcEscRefBands() throws IOException,
662: Pack200Exception {
663: // TODO
664: }
665:
666: public void testBcEscBands() throws IOException, Pack200Exception {
667: // TODO
668: }
669:
670: }
|