1 package uk.co.codemist.jlisp; 2 3 4 //created 02/02/02 5 6 /************************************************************************** 7 * Copyright (C) 1998-2011, Codemist Ltd. A C Norman * 8 * also contributions from Vijay Chauhan, 2002 * 9 * * 10 * Redistribution and use in source and binary forms, with or without * 11 * modification, are permitted provided that the following conditions are * 12 * met: * 13 * * 14 * * Redistributions of source code must retain the relevant * 15 * copyright notice, this list of conditions and the following * 16 * disclaimer. * 17 * * Redistributions in binary form must reproduce the above * 18 * copyright notice, this list of conditions and the following * 19 * disclaimer in the documentation and/or other materials provided * 20 * with the distribution. * 21 * * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * 25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 26 * COPYRIGHT OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * 28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * 29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * 30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * 31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * 32 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 33 * DAMAGE. * 34 *************************************************************************/ 35 import java.io.*; 36 37 public class CONSTANT_NameAndType_info extends Cp_info 38 { main(String[] args)39 public static void main(String[] args) throws IOException, ResourceException 40 { 41 short nidx = (short)0x5; 42 short didx = (short)0x6; 43 CONSTANT_NameAndType_info cnt = 44 new CONSTANT_NameAndType_info(nidx,didx); 45 cnt.printBytes(cnt.dumpBytes()); 46 Jlisp.println("\n"); 47 48 short nidx2 = (short)0xb; 49 short didx2 = (short)0xc; 50 CONSTANT_NameAndType_info cnt2 = 51 new CONSTANT_NameAndType_info(nidx2,didx2); 52 cnt2.printBytes(cnt2.dumpBytes()); 53 Jlisp.println("\n"); 54 55 } 56 57 short name_index; 58 short descriptor_index; 59 60 61 //constructor CONSTANT_NameAndType_info(short nameIndex, short desIndex)62 CONSTANT_NameAndType_info(short nameIndex, short desIndex) 63 throws IOException 64 { tag = CONSTANT_NameAndType; 65 name_index = nameIndex; 66 descriptor_index = desIndex; 67 //below is the toInfo() method of Code_Attribute.java 68 byte[][] infoTemp = new byte[2][0]; 69 infoTemp[0] = shortToByteArray(name_index); 70 infoTemp[1] = shortToByteArray(descriptor_index); 71 72 info = new byte[4]; 73 info = flatBytes(infoTemp); 74 } 75 76 } 77 78 79 // end of CONSTANT_NameAndType_info.java 80